Commit ef2fb062 authored by jcfiala's avatar jcfiala
Browse files

Issue #1063764 by bdragon,jcfiala: Renamed all field formatters to start with...

Issue #1063764 by bdragon,jcfiala: Renamed all field formatters to start with 'link_' so they will be unique.
parent 69c4d301
......@@ -5,6 +5,11 @@
* Install file for the link module.
*/
/**
* Upgrade notes:
* Things we need to make sure work when upgrading from Drupal 6 to Drupal 7:
*/
/**
* Implements hook_field_schema().
*/
......@@ -76,4 +81,38 @@ function link_update_7000() {
}
return t("Instance settings have been set with the data from the field settings.");
}
\ No newline at end of file
}
/**
* Renames all displays from foobar to link_foobar
*/
function link_update_7001() {
// for each field that is a link field, we need to update the display types:
$result = db_query("SELECT id, field_name, data FROM {field_config} WHERE module = 'link' AND type = 'link_field'");
foreach ($result as $field) {
$field_id = $field->id;
$name = $field->field_name;
$field_data = unserialize($field->data);
$instances = db_query("SELECT id, data FROM {field_config_instance} WHERE field_id = :field_id", array(':field_id' => $field_id));
foreach ($instances as $instance) {
// If this field has been updated already, we want to skip it.
$instance_data = unserialize($instance->data);
$update_instance = FALSE;
foreach ($instance_data['display'] as $display_name => $display_data) {
if ($display_data['type'] && (0 !== strpos($display_data['type'], 'link_'))) {
$instance_data['display'][$display_name]['type'] = 'link_'. $display_data['type'];
$update_instance = TRUE;
}
}
if ($update_instance) {
// update the database.
$num_updated = db_update('field_config_instance')
->fields(array('data' => serialize($instance_data)))
->condition('id', $instance->id)
->execute();
}
}
}
}
......@@ -51,7 +51,7 @@ function link_field_info() {
),
),
'default_widget' => 'link_field',
'default_formatter' => 'default',
'default_formatter' => 'link_default',
),
);
}
......@@ -472,22 +472,22 @@ function link_theme() {
/*'link_field_settings' => array(
'variables' => array('element' => NULL),
),*/
'link_formatter_default' => array(
'link_formatter_link_default' => array(
'variables' => array('element' => NULL),
),
'link_formatter_plain' => array(
'link_formatter_link_plain' => array(
'variables' => array('element' => NULL),
),
'link_formatter_url' => array(
'link_formatter_link_url' => array(
'variables' => array('element' => NULL),
),
'link_formatter_short' => array(
'link_formatter_link_short' => array(
'variables' => array('element' => NULL),
),
'link_formatter_label' => array(
'link_formatter_link_label' => array(
'variables' => array('element' => NULL),
),
'link_formatter_separate' => array(
'link_formatter_link_separate' => array(
'variables' => array('element' => NULL),
),
'link_field' => array(
......@@ -596,32 +596,32 @@ function link_field_process($element, $form_state, $complete_form) {
*/
function link_field_formatter_info() {
return array(
'default' => array(
'link_default' => array(
'label' => t('Title, as link (default)'),
'field types' => array('link_field'),
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
),
'url' => array(
'link_url' => array(
'label' => t('URL, as link'),
'field types' => array('link_field'),
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
),
'plain' => array(
'link_plain' => array(
'label' => t('URL, as plain text'),
'field types' => array('link_field'),
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
),
'short' => array(
'link_short' => array(
'label' => t('Short, as link with title "Link"'),
'field types' => array('link_field'),
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
),
'label' => array(
'link_label' => array(
'label' => t('Label, as link with label as title'),
'field types' => array('link_field'),
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
),
'separate' => array(
'link_separate' => array(
'label' => t('Separate title and URL'),
'field types' => array('link_field'),
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
......@@ -645,7 +645,7 @@ function link_field_formatter_view($entity_type, $entity, $field, $instance, $la
/**
* Theme function for 'default' text field formatter.
*/
function theme_link_formatter_default($vars) {
function theme_link_formatter_link_default($vars) {
$link_options = $vars['element'];
unset($link_options['element']['title']);
unset($link_options['element']['url']);
......@@ -665,7 +665,7 @@ function theme_link_formatter_default($vars) {
/**
* Theme function for 'plain' text field formatter.
*/
function theme_link_formatter_plain($vars) {
function theme_link_formatter_link_plain($vars) {
$link_options = $vars['element'];
unset($link_options['element']['title']);
unset($link_options['element']['url']);
......@@ -677,7 +677,7 @@ function theme_link_formatter_plain($vars) {
/**
* Theme function for 'url' text field formatter.
*/
function theme_link_formatter_url($vars) {
function theme_link_formatter_link_url($vars) {
$link_options = $vars['element'];
unset($link_options['element']['title']);
unset($link_options['element']['url']);
......@@ -687,7 +687,7 @@ function theme_link_formatter_url($vars) {
/**
* Theme function for 'short' text field formatter.
*/
function theme_link_formatter_short($vars) {
function theme_link_formatter_link_short($vars) {
$link_options = $vars['element'];
unset($link_options['element']['title']);
unset($link_options['element']['url']);
......@@ -697,7 +697,7 @@ function theme_link_formatter_short($vars) {
/**
* Theme function for 'label' text field formatter.
*/
function theme_link_formatter_label($vars) {
function theme_link_formatter_link_label($vars) {
$link_options = $vars['element'];
unset($link_options['element']['title']);
unset($link_options['element']['url']);
......@@ -708,7 +708,7 @@ function theme_link_formatter_label($vars) {
* Theme function for 'separate' text field formatter.
*/
function theme_link_formatter_separate($vars) {
function theme_link_formatter_link_separate($vars) {
$class = empty($vars['element']['attributes']['class']) ? '' : ' '. $vars['element']['attributes']['class'];
unset($vars['element']['attributes']['class']);
$link_options = $vars['element'];
......
......@@ -261,7 +261,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'plain',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -292,7 +292,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'plain',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -323,7 +323,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'plain',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -354,7 +354,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'url',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -384,7 +384,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'url',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -414,7 +414,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'url',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -444,7 +444,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'short',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -475,7 +475,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'short',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -506,7 +506,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'short',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -537,7 +537,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'label',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -568,7 +568,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'label',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -599,7 +599,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'label',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -630,7 +630,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'separate',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -661,7 +661,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'separate',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
);
$this->drupalPost(NULL, $edit, t('Save'));
......@@ -692,7 +692,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'separate',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
);
$this->drupalPost(NULL, $edit, t('Save'));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment