diff --git a/metatag.inc b/metatag.inc index 939a127..7c7ccb2 100644 --- a/metatag.inc +++ b/metatag.inc @@ -202,7 +202,7 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { // ones that are relative to the Drupal root path. if (strpos($url, base_path()) === 0) { // Logic: - // * Get the length of the base_path(), + // * Get the length of the base_path(), // * Get a portion of the image's path starting from the position equal // to the base_path()'s length; this will result in a path relative // to the Drupal installation's base directory. @@ -349,6 +349,209 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag { } /** + * Extended meta tag controller for tags supporting the full attribute set. + */ +class DrupalExtendedMetaTag extends DrupalTextMetaTag { + + /** + * Implements DrupalMetaTagInterface::getForm(). + */ + public function getForm(array $options = array()) { + // Ensure the 'token types' element is available. + $options += array( + 'token types' => array(), + ); + + $form['item'] = array( + '#type' => 'fieldset', + '#title' => $this->info['label'], + '#description' => !empty($this->info['description']) ? $this->info['description'] : '', + '#attributes' => array('class' => array('metatag-item', 'extended-metatag-item')), + // '#tree' => TRUE, + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $form['item']['value'] = isset($this->info['form']['value']) ? $this->info['form']['value'] : array(); + + // Check for old single value format. + if (!empty($this->data['value'])) { + $this->data['item']['value'] = $this->data['value']; + } + + $form['item']['value'] += array( + '#type' => 'textfield', + '#title' => t('Value'), + '#description' => t('The actual value to be used on this field.'), + '#default_value' => isset($this->data['item']['value']) ? $this->data['item']['value'] : '', + '#attributes' => array('class' => array('extended-metatag-field')), + '#element_validate' => array('token_element_validate'), + '#token_types' => $options['token types'], + '#maxlength' => 1024, + ); + + $form['item']['scheme'] = isset($this->info['form']['scheme']) ? $this->info['form']['scheme'] : array(); + + $form['item']['scheme'] += array( + '#type' => 'textfield', + '#title' => t('Scheme'), + '#description' => t('Some metadata standards specify encoding schemes, though it is rarely used.'), + '#default_value' => isset($this->data['item']['scheme']) ? $this->data['item']['scheme'] : '', + '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), + '#element_validate' => array('token_element_validate'), + '#token_types' => $options['token types'], + ); + + $form['item']['lang'] = isset($this->info['form']['lang']) ? $this->info['form']['lang'] : array(); + + $form['item']['lang'] += array( + '#type' => 'textfield', + '#title' => t('Language'), + '#description' => t("A language code that identifies a natural language spoken, written, or otherwise used for the communication of information."), + '#default_value' => isset($this->data['item']['lang']) ? $this->data['item']['lang'] : '', + '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), + '#element_validate' => array('token_element_validate'), + '#token_types' => $options['token types'], + ); + + $form['item']['dir'] = isset($this->info['form']['dir']) ? $this->info['form']['dir'] : array(); + + $form['item']['dir'] += array( + '#type' => 'select', + '#title' => t('Text direction'), + '#description' => t("Specifies the base direction of directionally-neutral text."), + '#default_value' => isset($this->data['item']['dir']) ? $this->data['item']['dir'] : '', + '#options' => array( + FALSE => t('- none -'), + 'ltr' => t('Left to right'), + 'rtl' => t('Right to left'), + ), + '#attributes' => array('class' => array('extended-metatag-field', 'metatag-exclude')), + ); + + return $form; + } + + /** + * Implements DrupalMetaTagInterface::getValue(). + */ + public function getValue(array $options = array()) { + $name = "metatag:" . $options["instance"] . ":" . $this->info["name"]; + + $options += array( + 'token data' => array(), + 'clear' => TRUE, + 'sanitize' => TRUE, + 'raw' => FALSE, + ); + + // Check for old single value format. + if (!empty($this->data['value'])) { + $this->data['item']['value'] = $this->data['value']; + } + + if (!isset($this->data['item']['value'])) { + return NULL; + } + + $value = metatag_translate_metatag($this->data['item']['value'], $name, $options); + if (empty($options['raw'])) { + // Give other modules the opportunity to use hook_metatag_pattern_alter() + // to modify defined token patterns and values before replacement. + drupal_alter('metatag_pattern', $value, $options['token data']); + $value = token_replace($value, $options['token data'], $options); + } + + $value = $this->tidyValue($value); + + return $value; + } + + /** + * Return the item attributes for the extended tag. + * + * @param array $options + * (optional) An array of options. + * + * @return array + * An array of values. + */ + public function getAttributes(array $options = array()) { + + $options += array( + 'token data' => array(), + 'clear' => TRUE, + 'sanitize' => TRUE, + 'raw' => FALSE, + ); + + $values = $this->data['item']; + + unset($values['value']); + + foreach ($values as $name => $value) { + if (empty($value)) { + unset($values[$name]); + } + } + + if (isset($values['lang'])) { + $values['xml:lang'] = $values['lang']; + } + + foreach ($values as $key => $value) { + if (empty($options['raw'])) { + $value = token_replace($value, $options['token data'], $options); + } + + $values[$key] = $this->tidyValue($value); + } + + return $values; + } + + /** + * Implements DrupalMetaTagInterface::getElement(). + */ + public function getElement(array $options = array()) { + + $element = isset($this->info['element']) ? $this->info['element'] : array(); + + $value = $this->getValue($options); + if (strlen($value) === 0) { + return array(); + } + + $element += array( + '#theme' => 'metatag', + '#tag' => 'meta', + '#id' => 'metatag_' . $this->info['name'], + '#name' => $this->info['name'], + '#value' => $value, + '#attributes' => $this->getAttributes($options), + ); + + // Add header information if desired. + if (!empty($this->info['header'])) { + $element['#attached']['drupal_add_http_header'][] = array( + $this->info['header'], + $value, + ); + } + + return array( + '#attached' => array( + 'drupal_add_html_head' => array( + array( + $element, + $element['#id'], + ), + ), + ), + ); + } +} + +/** * Link type meta tag controller. */ class DrupalLinkMetaTag extends DrupalTextMetaTag { diff --git a/metatag.info b/metatag.info index 8999677..8fb807c 100644 --- a/metatag.info +++ b/metatag.info @@ -30,6 +30,8 @@ files[] = tests/metatag.term.test files[] = tests/metatag.user.test ; Handling of core's default meta tags. files[] = tests/metatag.core_tag_removal.test +; Handling of extended meta tags. +files[] = tests/metatag.extended.test ; String handling. files[] = tests/metatag.string_handling.test files[] = tests/metatag.string_handling_with_i18n.test @@ -76,4 +78,3 @@ version = "7.x-1.16" core = "7.x" project = "metatag" datestamp = "1464975552" - diff --git a/metatag.migrate.inc b/metatag.migrate.inc index a9876cb..a5ed8b1 100644 --- a/metatag.migrate.inc +++ b/metatag.migrate.inc @@ -120,7 +120,14 @@ class MigrateMetatagHandler extends MigrateDestinationHandler { $metatag_field = 'metatag_' . $value['name']; if (isset($entity->$metatag_field)) { $language = isset($entity->language) ? $entity->language : LANGUAGE_NONE; - $entity->metatags[$language][$value['name']]['value'] = $entity->$metatag_field; + // Support the expanded meta tag option. + if (is_array($entity->$metatag_field)) { + $entity->metatags[$language][$value['name']]['item'] = $entity->$metatag_field; + } + // Normal meta tags. + else { + $entity->metatags[$language][$value['name']]['value'] = $entity->$metatag_field; + } unset($entity->$metatag_field); } } diff --git a/metatag.module b/metatag.module index 32bc198..546a871 100644 --- a/metatag.module +++ b/metatag.module @@ -279,9 +279,9 @@ function metatag_config_load_with_defaults($instance, $include_global = TRUE) { continue; } - // Add config to the defaults array. + // Add config to the defaults array, favoring existing values. if (!empty($configs[$key]->config)) { - $defaults[$cid] += $configs[$key]->config; + $defaults[$cid] = drupal_array_merge_deep($defaults[$cid], $configs[$key]->config, $defaults[$cid]); } } @@ -1207,8 +1207,8 @@ function metatag_metatags_view($instance, array $metatags = array(), array $opti } } - // Add any default tags to the mix. - $metatags += metatag_config_load_with_defaults($instance); + // Add any default tags to the mix, preserving stored values. + $metatags = drupal_array_merge_deep($metatags, metatag_config_load_with_defaults($instance), $metatags); $options['instance'] = $instance; @@ -1216,7 +1216,7 @@ function metatag_metatags_view($instance, array $metatags = array(), array $opti $current_pager = metatag_get_current_pager(); foreach ($metatags as $metatag => $data) { - if ((!empty($data['value']) || (isset($data['value']) && is_numeric($data['value']))) + if ((!empty($data['value']) || (isset($data['value']) && is_numeric($data['value'])) || (isset($data['item']) && !empty($data['item']['value']))) && $metatag_instance = metatag_get_instance($metatag, $data)) { $tag_output = $metatag_instance->getElement($options); // Don't output the pager if that's all there is. @@ -1367,8 +1367,8 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( } } - // Merge in the default meta tag configurations. - $metatags += $options['defaults']; + // Merge in the default meta tag configurations, favoring existing values. + $metatags = drupal_array_merge_deep($metatags, $options['defaults'], $metatags); // This will be used later. $group_metatag_access = array(); @@ -1390,6 +1390,11 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( // Get the form element from the meta tag class. $metatag_form = $metatag_instance->getForm($options); + // Adds DrupalExtendedMetaTag item value if available. + if (isset($options['defaults'][$metatag]['item']['value'])) { + $options['defaults'][$metatag]['value'] = $options['defaults'][$metatag]['item']['value']; + } + // Add a default value form element. if (isset($options['defaults'][$metatag]['value'])) { $metatag_form['default'] = array( @@ -2177,17 +2182,69 @@ function metatag_config_instance_info($instance = NULL) { function metatag_filter_values_from_defaults(array &$values, array $defaults = array()) { foreach ($values as $metatag => $data) { $default = isset($data['default']) ? $data['default'] : (isset($defaults[$metatag]['value']) ? $defaults[$metatag]['value'] : NULL); - if (isset($default) && isset($data['value']) && $default === $data['value']) { - // Meta tag has a default, and it matches user-submitted value. - unset($values[$metatag]); + + if (isset($data['value']) && is_array($data['value'])) { + foreach ($data['value'] as $property => $value) { + // Meta tag has a default, and it matches user-submitted value. + if (isset($default[$property]) && $default[$property] === $value) { + unset($values[$metatag]['value'][$property]); + } + + // Metatag does not have a default, and user did not submit a value. + elseif (!isset($default[$property]) && (is_string($value) && !drupal_strlen($value) || (is_array($value) && !array_filter($value)))) { + unset($values[$metatag][$property]); + } + + // Unset the default hidden value. + if (isset($values[$metatag]['default'][$property])) { + unset($values[$metatag]['default'][$property]); + } + } + // Clean up empty arrays. + if (empty($values[$metatag]['default'])) { + unset($values[$metatag]['default']); + } + if (empty($values[$metatag]['value'])) { + unset($values[$metatag]['value']); + } + if (empty($values[$metatag])) { + unset($values[$metatag]); + } } - elseif (!isset($default) && (is_string($data['value']) && !drupal_strlen($data['value']) || (is_array($data['value']) && !array_filter($data['value'])))) { - // Metatag does not have a default, and user did not submit a value. - unset($values[$metatag]); + elseif (isset($data['item']) && is_array($data['item'])) { + // Array values provided by DrupalExtendedMetaTag, call recursively. + foreach ($data['item'] as $property => $value) { + if (isset($defaults[$metatag]['item'][$property]) && $defaults[$metatag]['item'][$property] === $value) { + unset($values[$metatag]['item'][$property]); + } + if (isset($values[$metatag]['default'])) { + unset($values[$metatag]['default']); + } + } + // Clean up empty arrays. + if (empty($values[$metatag]['item'])) { + unset($values[$metatag]['item']); + } + if (empty($values[$metatag])) { + unset($values[$metatag]); + } } - if (isset($values[$metatag]['default'])) { + else { + if (isset($data['value'])) { + // Meta tag has a default, and it matches user-submitted value. + if (!empty($default) && $default === $data['value']) { + unset($values[$metatag]); + } + + // Metatag does not have a default, and user did not submit a value. + elseif (!isset($default) && (is_string($data['value']) && !drupal_strlen($data['value']) || (is_array($data['value']) && !array_filter($data['value'])))) { + unset($values[$metatag]); + } + } // Unset the default hidden value. - unset($values[$metatag]['default']); + if (isset($values[$metatag]['default'])) { + unset($values[$metatag]['default']); + } } } } diff --git a/metatag.vertical-tabs.js b/metatag.vertical-tabs.js index 242cf61..a128d66 100644 --- a/metatag.vertical-tabs.js +++ b/metatag.vertical-tabs.js @@ -10,13 +10,21 @@ Drupal.behaviors.metatagFieldsetSummaries = { attach: function (context) { $('fieldset.metatags-form', context).drupalSetSummary(function (context) { var vals = []; - $("input[type='text'], select, textarea", context).each(function() { + $("input[type='text'], select, textarea", context).not('.metatag-exclude').each(function() { var input_field = $(this).attr('name'); // Verify the field exists before proceeding. if (input_field === undefined) { return false; } - var default_name = input_field.replace(/\[value\]/, '[default]'); + if ($(this).hasClass('extended-metatag-field')) { + var default_name = input_field.replace(/\[item\]/, '').replace(/\[value\]/, '[default]'); + var label = $(this).closest('.extended-metatag-item').find('a.fieldset-title').text().replace(/^Hide|Show/, ''); + } + else { + var default_name = input_field.replace(/\[value\]/, '[default]'); + var label = $("label[for='" + $(this).attr('id') + "']").text(); + } + var default_value = $("input[type='hidden'][name='" + default_name + "']", context); if (default_value.length && default_value.val() === $(this).val()) { // Meta tag has a default value and form value matches default value. @@ -26,7 +34,6 @@ Drupal.behaviors.metatagFieldsetSummaries = { // Meta tag has no default value and form value is empty. return true; } - var label = $("label[for='" + $(this).attr('id') + "']").text(); vals.push(Drupal.t('@label: @value', { '@label': $.trim(label), '@value': Drupal.truncate($(this).val(), 25) || Drupal.t('None') diff --git a/metatag_dc/metatag_dc.metatag.inc b/metatag_dc/metatag_dc.metatag.inc index dce93b0..b10a2c3 100644 --- a/metatag_dc/metatag_dc.metatag.inc +++ b/metatag_dc/metatag_dc.metatag.inc @@ -12,18 +12,18 @@ function metatag_dc_metatag_bundled_config_alter(array &$configs) { switch ($config->instance) { case 'global': $config->config += array( - 'dcterms.format' => array('value' => 'text/html'), - 'dcterms.identifier' => array('value' => '[current-page:url:absolute]'), - 'dcterms.title' => array('value' => '[current-page:title]'), - 'dcterms.type' => array('value' => 'Text'), + 'dcterms.title' => array('item' => array('value' => '[current-page:title]')), + 'dcterms.identifier' => array('item' => array('value' => '[current-page:url:absolute]')), + 'dcterms.type' => array('item' => array('value' => 'Text')), + 'dcterms.format' => array('item' => array('value' => 'text/html')), ); break; case 'global:frontpage': $config->config += array( - 'dcterms.description' => array('value' => '[site:slogan]'), - 'dcterms.identifier' => array('value' => '[site:url]'), - 'dcterms.title' => array('value' => '[site:name]'), + 'dcterms.description' => array('item' => array('value' => '[site:slogan]')), + 'dcterms.title' => array('item' => array('value' => '[site:name]')), + 'dcterms.identifier' => array('item' => array('value' => '[site:url]')), ); break; @@ -31,33 +31,34 @@ function metatag_dc_metatag_bundled_config_alter(array &$configs) { case 'global:403': case 'global:404': $config->config += array( - 'dcterms.identifier' => array('value' => '[site:url]'), - 'dcterms.title' => array('value' => '[site:name]'), + 'dcterms.identifier' => array('item' => array('value' => '[site:url]')), + 'dcterms.title' => array('item' => array('value' => '[site:name]')), ); break; case 'node': $config->config += array( - 'dcterms.creator' => array('value' => '[node:author]'), - 'dcterms.date' => array('value' => '[node:created:custom:Y-m-d\TH:iP]'), - 'dcterms.description' => array('value' => '[node:summary]'), - 'dcterms.language' => array('value' => '[node:language]'), - 'dcterms.title' => array('value' => '[node:title]'), + 'dcterms.creator' => array('item' => array('value' => '[node:author]')), + 'dcterms.date' => array('item' => array('value' => '[node:created:custom:Y-m-d\TH:iP]')), + 'dcterms.description' => array('item' => array('value' => '[node:summary]')), + 'dcterms.language' => array('item' => array('value' => '[node:language]')), + 'dcterms.title' => array('item' => array('value' => '[node:title]')), ); break; case 'taxonomy_term': $config->config += array( - 'dcterms.description' => array('value' => '[term:description]'), - 'dcterms.title' => array('value' => '[term:name]'), + 'dcterms.description' => array('item' => array('value' => '[term:description]')), + 'dcterms.title' => array('item' => array('value' => '[term:name]')), + 'dcterms.identifier' => array('item' => array('value' => '[current-page:url:absolute]')), ); break; case 'user': $config->config += array( - 'dcterms.creator' => array('value' => '[user:name]'), - 'dcterms.date' => array('value' => '[user:created:custom:Y-m-d\TH:iP]'), - 'dcterms.title' => array('value' => '[user:name]'), + 'dcterms.creator' => array('item' => array('value' => '[user:name]')), + 'dcterms.date' => array('item' => array('value' => '[user:created:custom:Y-m-d\TH:iP]')), + 'dcterms.title' => array('item' => array('value' => '[user:name]')), ); break; } @@ -82,11 +83,10 @@ function metatag_dc_metatag_info() { // Basic tags. $defaults = array( - 'class' => 'DrupalTextMetaTag', + 'class' => 'DrupalExtendedMetaTag', 'group' => 'dublin-core', 'element' => array( '#type' => 'term', - '#theme' => 'metatag_dc', ), ); @@ -95,7 +95,6 @@ function metatag_dc_metatag_info() { 'description' => t('The name given to the resource.'), 'element' => array( '#type' => 'term', - '#theme' => 'metatag_dc', ), 'weight' => ++$weight, ) + $defaults; diff --git a/metatag_dc/metatag_dc.module b/metatag_dc/metatag_dc.module index 648fab0..b41a573 100644 --- a/metatag_dc/metatag_dc.module +++ b/metatag_dc/metatag_dc.module @@ -12,29 +12,3 @@ function metatag_dc_ctools_plugin_api($owner, $api) { return array('version' => 1); } } - -/** - * Implements hook_theme(). - */ -function metatag_dc_theme() { - $info['metatag_dc'] = array( - 'render element' => 'element', - ); - - return $info; -} - -/** - * Theme callback for a Dublin Core meta tag. - */ -function theme_metatag_dc($variables) { - $element = &$variables['element']; - $args = array( - '#name' => 'name', - '#schema' => 'schema', - '#value' => 'content', - ); - element_set_attributes($element, $args); - unset($element['#value']); - return theme('html_tag', $variables); -} diff --git a/metatag_panels/metatag_panels.module b/metatag_panels/metatag_panels.module index 72ca8f5..741326c 100644 --- a/metatag_panels/metatag_panels.module +++ b/metatag_panels/metatag_panels.module @@ -175,9 +175,12 @@ function metatag_panels_ctools_render_alter($info, $page, $context) { // Substitute Panels context variables. foreach ($metatags as $metatag => $data) { - if (is_string($data['value']) && strpos($data['value'], '%') !== FALSE) { + if (!empty($data['value']) && is_string($data['value']) && strpos($data['value'], '%') !== FALSE) { $metatags[$metatag]['value'] = ctools_context_keyword_substitute($data['value'], array(), $context['handler']->conf['display']->context); } + elseif (!empty($data['item']['value']) && strpos($data['item']['value'], '%') !== FALSE) { + $metatags[$metatag]['item']['value'] = ctools_context_keyword_substitute($data['item']['value'], array(), $context['handler']->conf['display']->context); + } } // Get the contexts that exist within this panel. @@ -209,9 +212,12 @@ function metatag_panels_ctools_render_alter($info, $page, $context) { foreach ($metatags as $metatag => $data) { // Render CTools context substitution values prior to rendering the meta // tag. - if (is_string($data['value'])) { + if (!empty($data['value']) && is_string($data['value'])) { $data['value'] = ctools_context_keyword_substitute(trim($data['value']), array(), $task_contexts); } + elseif (!empty($data['item']['value']) && is_string($data['item']['value'])) { + $data['item']['value'] = ctools_context_keyword_substitute(trim($data['item']['value']), array(), $task_contexts); + } $metatag_instance = metatag_get_instance($metatag, $data); if ($metatag_instance) { diff --git a/metatag-1.6-patched/tests/metatag.extended.test b/tests/metatag.extended.test new file mode 100644 index 0000000..7e75876 --- /dev/null +++ b/tests/metatag.extended.test @@ -0,0 +1,114 @@ + 'Extended metatag tests', + 'description' => 'Test extended meta tags functionality.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_dc'; + parent::setUp($modules); + } + + /** + * Tests extended metatag as used by DC. + */ + public function testExtendedMetatag() { + $this->drupalCreateContentType(array( + 'type' => 'metatag_test', + 'name' => 'Test', + )); + $this->adminUser = $this->drupalCreateUser(array( + 'administer meta tags', + 'edit meta tags', + 'create metatag_test content', + 'delete any metatag_test content', + 'edit any metatag_test content', + )); + $this->drupalLogin($this->adminUser); + + $this->drupalGet('admin/config/search/metatags/config/add'); + $this->drupalPost(NULL, array( + 'instance' => 'node:metatag_test', + ), t('Add and configure')); + // Assert the default is sane. + $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); + $this->drupalPost(NULL, array( + 'metatags[und][dcterms.title][item][value]' => '[node:title]', + 'metatags[und][dcterms.creator][item][value]' => '[node:author]', + 'metatags[und][dcterms.date][item][value]' => '[node:created:custom:Y-m-d\TH:iP]', + 'metatags[und][dcterms.format][item][value]' => 'text/html', + 'metatags[und][dcterms.identifier][item][value]' => '[current-page:url:absolute]', + 'metatags[und][dcterms.language][item][value]' => '[node:language]', + ), t('Save')); + // Assert field values saved correctly. + $this->drupalGet('admin/config/search/metatags/config/node:metatag_test'); + $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); + // Submit a node and check default filtering. + $this->drupalGet('node/add/metatag-test'); + // Assert the default is sane. + $this->assertFieldByName('metatags[und][dcterms.title][item][value]', '[node:title]'); + $this->drupalPost(NULL, array( + 'metatags[und][dcterms.title][item][value]' => '[node:title] ponies', + 'metatags[und][robots][value][index]' => '1', + 'metatags[und][dcterms.title][item][dir]' => 'ltr', + 'title' => 'Who likes magic', + ), t('Save')); + $this->assertText(t('Test Who likes magic has been created.')); + $matches = array(); + if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { + $nid = end($matches); + $node = node_load($nid); + // Only the non-default values are stored. + $expected = array( + 'und' => array( + 'robots' => array( + 'value' => array( + 'index' => 'index', + ), + ), + 'dcterms.title' => array( + 'item' => array( + 'value' => '[node:title] ponies', + 'dir' => 'ltr', + ), + ), + ), + ); + $this->assertEqual($expected, $node->metatags); + } + else { + $this->fail('Could not determine node ID for created node.'); + } + $xpath = $this->xpath("//meta[@name='dcterms.title']"); + $this->assertEqual(count($xpath), 1); + $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); + $this->assertEqual($xpath[0]['dir'], 'ltr'); + $xpath = $this->xpath("//meta[@name='robots']"); + $this->assertEqual(count($xpath), 1); + $this->assertEqual($xpath[0]['content'], 'index'); + } + +} diff --git a/tests/metatag.helper.test b/tests/metatag.helper.test index 15f9e53..2b27db0 100644 --- a/tests/metatag.helper.test +++ b/tests/metatag.helper.test @@ -219,10 +219,10 @@ class MetatagTestHelper extends DrupalWebTestCase { // 'content-language' => array('value' => ''),' // Dublin Core meta tags. - 'dcterms.format' => array('value' => 'text/html'), - 'dcterms.identifier' => array('value' => '[current-page:url:absolute]'), - 'dcterms.title' => array('value' => '[current-page:title]'), - 'dcterms.type' => array('value' => 'Text'), + 'dcterms.format' => array('item' => array('value' => 'text/html')), + 'dcterms.identifier' => array('item' => array('value' => '[current-page:url:absolute]')), + 'dcterms.title' => array('item' => array('value' => '[current-page:title]')), + 'dcterms.type' => array('item' => array('value' => 'Text')), // Google+ meta tags. 'itemprop:name' => array('value' => '[current-page:title]'), diff --git a/tests/metatag.node.test b/tests/metatag.node.test index f256fc7..697199b 100644 --- a/tests/metatag.node.test +++ b/tests/metatag.node.test @@ -65,12 +65,12 @@ class MetatagCoreNodeTest extends MetatagTestHelper { // Submit the form with some values. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[node:title]', - 'metatags[und][dcterms.creator][value]' => '[node:author]', - 'metatags[und][dcterms.date][value]' => '[node:created:custom:Y-m-d\TH:iP]', - 'metatags[und][dcterms.format][value]' => 'text/html', - 'metatags[und][dcterms.identifier][value]' => '[current-page:url:absolute]', - 'metatags[und][dcterms.language][value]' => '[node:language]', + 'metatags[und][dcterms.subject][item][value]' => '[node:title]', + 'metatags[und][dcterms.creator][item][value]' => '[node:author]', + 'metatags[und][dcterms.date][item][value]' => '[node:created:custom:Y-m-d\TH:iP]', + 'metatags[und][dcterms.format][item][value]' => 'text/html', + 'metatags[und][dcterms.identifier][item][value]' => '[current-page:url:absolute]', + 'metatags[und][dcterms.language][item][value]' => '[node:language]', ), t('Save')); $this->assertResponse(200); @@ -92,7 +92,7 @@ class MetatagCoreNodeTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[node:title] ponies', + 'metatags[und][dcterms.subject][item][value]' => '[node:title] ponies', 'title' => 'Who likes magic', ), t('Save')); $this->assertResponse(200); @@ -101,7 +101,9 @@ class MetatagCoreNodeTest extends MetatagTestHelper { $expected = array( 'und' => array( 'dcterms.subject' => array( - 'value' => '[node:title] ponies', + 'item' => array( + 'value' => '[node:title] ponies', + ), ), ), ); @@ -180,7 +182,7 @@ class MetatagCoreNodeTest extends MetatagTestHelper { $this->assertResponse(200); // Try submitting text to the page. $args = array( - 'metatags[und][dcterms.subject][value]' => '[node:title] kittens', + 'metatags[und][dcterms.subject][item][value]' => '[node:title] kittens', 'title' => $new_title, 'revision' => 1, 'log' => 'Creating a new revision', @@ -193,7 +195,9 @@ class MetatagCoreNodeTest extends MetatagTestHelper { $expected_updated = array( 'und' => array( 'dcterms.subject' => array( - 'value' => '[node:title] kittens', + 'item' => array( + 'value' => '[node:title] kittens', + ), ), ), ); diff --git a/tests/metatag.term.test b/tests/metatag.term.test index 5361c0b..9085217 100644 --- a/tests/metatag.term.test +++ b/tests/metatag.term.test @@ -80,9 +80,9 @@ class MetatagCoreTermTest extends MetatagTestHelper { // Submit the form with some values. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[term:name]', - 'metatags[und][dcterms.format][value]' => 'text/html', - 'metatags[und][dcterms.identifier][value]' => '[current-page:url:absolute]', + 'metatags[und][dcterms.subject][item][value]' => '[term:name]', + 'metatags[und][dcterms.format][item][value]' => 'text/html', + 'metatags[und][dcterms.identifier][item][value]' => '[current-page:url:absolute]', ), t('Save')); $this->assertResponse(200); @@ -104,7 +104,7 @@ class MetatagCoreTermTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[term:name] ponies', + 'metatags[und][dcterms.subject][item][value]' => '[term:name] ponies', 'name' => $term_name, 'path[alias]' => $term_path, ), t('Save')); @@ -145,7 +145,9 @@ class MetatagCoreTermTest extends MetatagTestHelper { $expected = array( 'und' => array( 'dcterms.subject' => array( - 'value' => '[term:name] ponies', + 'item' => array( + 'value' => '[term:name] ponies', + ), ), ), ); diff --git a/tests/metatag.user.test b/tests/metatag.user.test index 8d17602..bde75e6 100644 --- a/tests/metatag.user.test +++ b/tests/metatag.user.test @@ -36,7 +36,7 @@ class MetatagCoreUserTest extends MetatagTestHelper { // Submit the form with some values. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[user:name]', + 'metatags[und][dcterms.subject][item][value]' => '[user:name]', ), t('Save')); $this->assertResponse(200); @@ -56,7 +56,7 @@ class MetatagCoreUserTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[user:name] ponies', + 'metatags[und][dcterms.subject][item][value]' => '[user:name] ponies', ), t('Save')); $this->assertResponse(200); @@ -76,7 +76,9 @@ class MetatagCoreUserTest extends MetatagTestHelper { $expected = array( 'und' => array( 'dcterms.subject' => array( - 'value' => '[user:name] ponies', + 'item' => array( + 'value' => '[user:name] ponies', + ), ), ), ); diff --git a/tests/metatag.with_panels.test b/tests/metatag.with_panels.test index 8fa5fbc..aa10c0f 100644 --- a/tests/metatag.with_panels.test +++ b/tests/metatag.with_panels.test @@ -65,7 +65,7 @@ class MetatagCoreWithPanelsTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[node:title] ponies', + 'metatags[und][dcterms.subject][item][value]' => '[node:title] ponies', 'title' => 'Who likes magic', ), t('Save')); $this->assertResponse(200); diff --git a/tests/metatag.with_views.test b/tests/metatag.with_views.test index 00d5c3c..f0fcdeb 100644 --- a/tests/metatag.with_views.test +++ b/tests/metatag.with_views.test @@ -78,9 +78,9 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { // Submit the form with some values. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[term:name]', - 'metatags[und][dcterms.format][value]' => 'text/html', - 'metatags[und][dcterms.identifier][value]' => '[current-page:url:absolute]', + 'metatags[und][dcterms.subject][item][value]' => '[term:name]', + 'metatags[und][dcterms.format][item][value]' => 'text/html', + 'metatags[und][dcterms.identifier][item][value]' => '[current-page:url:absolute]', ), t('Save')); $this->assertResponse(200); @@ -102,7 +102,7 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( - 'metatags[und][dcterms.subject][value]' => '[term:name] ponies', + 'metatags[und][dcterms.subject][item][value]' => '[term:name] ponies', 'name' => $term_name, 'path[alias]' => $term_path, ), t('Save')); @@ -167,7 +167,9 @@ class MetatagCoreWithViewsTest extends MetatagTestHelper { $expected = array( 'und' => array( 'dcterms.subject' => array( - 'value' => '[term:name] ponies', + 'item' => array( + 'value' => '[term:name] ponies', + ), ), ), );