diff --git a/metatag.admin.inc b/metatag.admin.inc index b662db4..36c3123 100644 --- a/metatag.admin.inc +++ b/metatag.admin.inc @@ -5,6 +5,17 @@ * Administration page callbacks for the metatag module. */ +/** + * Indent the output for a given overview item. + * + * @param string $text + * The text that needs to be indented. + * @param object $instance + * The configuration object being processed. + * + * @return string + * The appropriately-indented configuration overview. + */ function _metatag_config_overview_indent($text, $instance) { $parents = metatag_config_get_parent_instances($instance); array_shift($parents); @@ -19,6 +30,12 @@ function _metatag_config_overview_indent($text, $instance) { return $text; } +/** + * Menu callback for the main Metatag configuration page. + * + * @return array + * A render array with all of the configuration items. + */ function metatag_config_overview() { ctools_include('export'); @@ -59,7 +76,11 @@ function metatag_config_overview() { // Show how this config inherits from its parents. if (!empty($inherits)) { - $details .= '

' . t('Inherits meta tags from: @parents', array('@parents' => implode(', ', $inherits))) . '

'; + $details .= '
'; + $details .= '

'; + $details .= t('Inherits meta tags from: @parents', array('@parents' => implode(', ', $inherits))); + $details .= '

'; + $details .= '
'; } // Add a summary of the configuration's defaults. @@ -88,7 +109,8 @@ function metatag_config_overview() { // Close the details div. $details .= ''; - // Add indentation to the leading cell based on how many parents the config has. + // Add indentation to the leading cell based on how many parents the config + // has. $details = _metatag_config_overview_indent($details, $config->instance); $row['data']['details'] = $details; @@ -209,6 +231,9 @@ function _metatag_config_instance_get_available_options() { return $options; } +/** + * Form API callback for adding a default configuration. + */ function metatag_config_add_form($form, &$form_state) { $form['instance'] = array( '#type' => 'select', @@ -236,6 +261,9 @@ function metatag_config_add_form($form, &$form_state) { return $form; } +/** + * Form API submission callback for metatag_config_add_form(). + */ function metatag_config_add_form_submit($form, &$form_state) { form_state_values_clean($form_state); $config = (object) $form_state['values']; @@ -243,6 +271,9 @@ function metatag_config_add_form_submit($form, &$form_state) { $form_state['redirect'] = 'admin/config/search/metatags/config/' . $config->instance; } +/** + * Form API callback for editing a default configuration. + */ function metatag_config_edit_form($form, &$form_state, $config) { $form['cid'] = array( '#type' => 'value', @@ -307,6 +338,9 @@ function metatag_config_edit_form($form, &$form_state, $config) { return $form; } +/** + * Form API submission callback for metatag_config_edit_form(). + */ function metatag_config_edit_form_submit($form, &$form_state) { // Build the configuration object and save it. form_state_values_clean($form_state); @@ -322,6 +356,12 @@ function metatag_config_edit_form_submit($form, &$form_state) { $form_state['redirect'] = 'admin/config/search/metatags'; } +/** + * Menu callback for enabling a default configuration. + * + * @param object $config + * The default configuration object to enable. + */ function metatag_config_enable($config) { if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'enable-' . $config->instance)) { return MENU_ACCESS_DENIED; @@ -334,6 +374,12 @@ function metatag_config_enable($config) { drupal_goto(); } +/** + * Menu callback for disabling a default configuration. + * + * @param object $config + * The default configuration object to disable. + */ function metatag_config_disable($config) { if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'disable-' . $config->instance)) { return MENU_ACCESS_DENIED; @@ -346,6 +392,9 @@ function metatag_config_disable($config) { drupal_goto(); } +/** + * Form API callback for deleting a default configuration. + */ function metatag_config_delete_form($form, &$form_state, $config) { $form['cid'] = array('#type' => 'value', '#value' => $config->cid); $form['instance'] = array('#type' => 'value', '#value' => $config->instance); @@ -362,6 +411,9 @@ function metatag_config_delete_form($form, &$form_state, $config) { ); } +/** + * Form API submission callback for metatag_config_delete_form(). + */ function metatag_config_delete_form_submit($form, &$form_state) { $config = metatag_config_load($form_state['values']['instance']); metatag_config_delete($config); @@ -374,6 +426,9 @@ function metatag_config_delete_form_submit($form, &$form_state) { $form_state['redirect'] = 'admin/config/search/metatags'; } +/** + * Form API callback for exporting a default configuration. + */ function metatag_config_export_form($config) { ctools_include('export'); return drupal_get_form('ctools_export_form', ctools_export_crud_export('metatag_config', $config), t('Export')); @@ -463,13 +518,22 @@ function metatag_bulk_revert_form_submit($form, &$form_state) { 'file' => drupal_get_path('module', 'metatag') . '/metatag.admin.inc', ); - $tags = isset($form_state['values']['tags']) ? array_filter($form_state['values']['tags']) : array(); - $languages = isset($form_state['values']['languages']) ? array_filter($form_state['values']['languages']) : array(); + $tags = array(); + if (isset($form_state['values']['tags'])) { + $tags = array_filter($form_state['values']['tags']); + } + $languages = array(); + if (isset($form_state['values']['languages'])) { + $languages = array_filter($form_state['values']['languages']); + } // Set a batch operation per entity:bundle. foreach (array_filter($form_state['values']['update']) as $option) { list($entity_type, $bundle) = explode(':', $option); - $batch['operations'][] = array('metatag_bulk_revert_batch_operation', array($entity_type, $bundle, $tags, $languages)); + $batch['operations'][] = array( + 'metatag_bulk_revert_batch_operation', + array($entity_type, $bundle, $tags, $languages), + ); } batch_set($batch); @@ -491,12 +555,12 @@ function metatag_bulk_revert_batch_operation($entity_type, $bundle, $tags, $lang ->propertyCondition($entity_info['entity keys']['id'], $context['sandbox']['current'], '>') ->propertyOrderBy($entity_info['entity keys']['id']); if ($entity_type != 'user') { - /** - * Entities which do not define a bundle such as User fail returning no results. - * @see https://www.drupal.org/node/1054168#comment-5266208 - */ + // Entities which do not define a bundle such as User fail returning no + // results. + // @see https://www.drupal.org/node/1054168#comment-5266208 $query->entityCondition('bundle', $bundle); } + // Get the total amount of entities to process. if (!isset($context['sandbox']['total'])) { $context['sandbox']['total'] = $query->count()->execute(); @@ -590,7 +654,10 @@ function metatag_bulk_revert_batch_finished($success, $results, $operations) { else { $error_operation = reset($operations); drupal_set_message(t('An error occurred while processing @operation with arguments : @args', - array('@operation' => $error_operation[0], '@args' => print_r($error_operation[0], TRUE)))); + array( + '@operation' => $error_operation[0], + '@args' => print_r($error_operation[0], TRUE), + ))); } } @@ -612,7 +679,7 @@ function metatag_admin_settings_form() { $form['entities'] = array( '#type' => 'fieldset', '#title' => t('Master controls for all entities'), - '#description' => t('By enabling and disabling items here, it is possible to control which entities (e.g. nodes, taxonomy terms) and bundles (e.g. content types, vocabularies) will have the meta tag form available on their respective edit pages. If an entity type is disabled it also disables it for all of that entity type\'s bundles.
Technical note: Entity types must not be configuration entities and must have view modes in order to be compatible.'), + '#description' => t("By enabling and disabling items here, it is possible to control which entities (e.g. nodes, taxonomy terms) and bundles (e.g. content types, vocabularies) will have the meta tag form available on their respective edit pages. If an entity type is disabled it also disables it for all of that entity type's bundles.
Technical note: Entity types must not be configuration entities and must have view modes in order to be compatible."), '#collapsible' => TRUE, '#collapsed' => FALSE, ); @@ -625,7 +692,6 @@ function metatag_admin_settings_form() { '#type' => 'checkbox', '#title' => t($entity_info['label']), '#default_value' => $entity_enabled, - // '#description' => t('Enable meta tags for all pages of this entity type.'), ); // Some entities, e.g. User, (core) File, have a single bundle with the diff --git a/metatag.admin.js b/metatag.admin.js index b157e6e..d57bf30 100644 --- a/metatag.admin.js +++ b/metatag.admin.js @@ -12,16 +12,16 @@ $('.js-show').show(); // Make the leaf arrow clickable. - $('.metatag-config-label').hover(function(){ + $('.metatag-config-label').hover(function () { $(this).css({'cursor': 'pointer'}); }) - .click(function(){ + .click(function () { $(this).find('a.toggle-details', context).trigger('click'); }); // Show or hide the summary. - $('table.metatag-config-overview a.toggle-details', context).click(function(event) { - $(this).parent('div').siblings('div.metatag-config-details').each(function() { + $('table.metatag-config-overview a.toggle-details', context).click(function (event) { + $(this).parent('div').siblings('div.metatag-config-details').each(function () { if ($(this).hasClass('js-hide')) { $(this).slideDown('slow').removeClass('js-hide'); } diff --git a/metatag.api.php b/metatag.api.php index 242ef71..f48e957 100644 --- a/metatag.api.php +++ b/metatag.api.php @@ -290,7 +290,7 @@ function hook_metatag_info_alter(&$info) { * @param array $options * All of the options used to generate the meta tags. */ -function hook_metatag_metatags_alter(array &$metatags, array $instance, array $options) { +function hook_metatag_metatags_alter(array &$metatags, $instance, array $options) { if (isset($metatags['description']['value'])) { $metatags['description']['value'] = '0 rly?'; } @@ -310,7 +310,7 @@ function hook_metatag_metatags_alter(array &$metatags, array $instance, array $o * @param array $options * All of the options used to generate the meta tags. */ -function hook_metatag_metatags_view_alter(&$output, $instance, $options) { +function hook_metatag_metatags_view_alter(array &$output, $instance, array $options) { if (isset($output['description']['#attached']['drupal_add_html_head'][0][0]['#value'])) { $output['description']['#attached']['drupal_add_html_head'][0][0]['#value'] = 'O rly?'; } @@ -318,23 +318,36 @@ function hook_metatag_metatags_view_alter(&$output, $instance, $options) { /** * Allow other modules to customize the data to generate the cache ID. + * + * @param array $cid_parts + * The identifiers used to identify this cache object. */ -function hook_metatag_page_cache_cid_parts_alter(&$cid_parts) { +function hook_metatag_page_cache_cid_parts_alter(array &$cid_parts) { } /** * Allow other modules to alter the meta tags prior to saving. + * + * @param array $metatags + * The meta tags being saved for this entity. + * @param string $entity_type + * The type of entity being saved. + * @param int $entity_id + * The ID of the entity being saved. + * @param int $revision_id + * The revision ID of the entity being saved. + * @param string $langcode + * The language code for the entity being saved. */ -function hook_metatag_presave(&$metatags, $entity_type, $entity_id, $revision_id, $langcode) { +function hook_metatag_presave(array &$metatags, $entity_type, $entity_id, $revision_id, $langcode) { } /** - * Allows modules to alter the defined list of tokens available - * for metatag patterns replacements. + * Allows modules to alter the list of tokens available for replacement. * - * By default only context (for example: global, node, etc...) - * related tokens are made available to metatag patterns replacements. - * This hook allows other modules to extend the default declared tokens. + * By default only context (for example: global, node, etc...) related tokens + * are made available to metatag patterns replacements. This hook allows other + * modules to extend the default declared tokens. * * @param array $options * (optional) An array of options including the following keys and values: @@ -345,7 +358,7 @@ function hook_metatag_presave(&$metatags, $entity_type, $entity_id, $revision_id * @see metatag_config_edit_form() * @see metatag_field_attach_form() */ -function hook_metatag_token_types_alter(&$options) { +function hook_metatag_token_types_alter(array &$options) { // Watchout: $options['token types'] might be empty. if (!isset($options['token types'])) { $options['token types'] = array(); @@ -385,7 +398,7 @@ function hook_metatag_token_types_alter(&$options) { * * @see DrupalTextMetaTag::getValue() */ -function hook_metatag_pattern_alter(&$pattern, &$types, $tag_name) { +function hook_metatag_pattern_alter(&$pattern, array &$types, $tag_name) { if (strpos($pattern, 'token_type1') !== FALSE) { $types['token_type1'] = "data to be used in hook_tokens for replacement"; } @@ -414,7 +427,7 @@ function hook_metatag_pattern_alter(&$pattern, &$types, $tag_name) { * The full specifications for this entity type, as returned by * entity_get_info(). */ -function hook_metatag_entity_type_is_supported_alter(&$suitable, $entity_type, $entity_info) { +function hook_metatag_entity_type_is_supported_alter(&$suitable, $entity_type, array $entity_info) { // Enable Metatag support for a custom entity that might otherwise be // ignored, e.g. it doesn't allow fields. if ($entity_type == 'my_entity') { @@ -432,7 +445,7 @@ function hook_metatag_entity_type_is_supported_alter(&$suitable, $entity_type, $ * @param object $view * The view object being displayed. * - * @return string|NULL + * @return string|null * Should return a string indicating an entity type that will be paired with * the views' first argument ($view->args[0]) to load that entity. */ @@ -444,8 +457,7 @@ function hook_metatag_views_post_render_get_entity($view) { } /** - * Allow the context string being passed to i18n_string to be changed before it - * is used. + * Allow the context string passed to i18n_string to be changed before use. * * If the string is set to an empty value it will cause this meta tag to not * be translated. @@ -470,13 +482,13 @@ function hook_metatag_i18n_context_alter(&$context, $tag_name) { * By default Metatag caches everything as CACHE_PERMANENT, this alter allows to * change that. * - * @param $expire + * @param int $expire * The expire value to change. - * @param $cid + * @param string $cid * The cid about to be cached. - * @param $data + * @param array $data * The data to be cached. */ -function hook_metatag_cache_set_expire_alter(&$expire, $cid, $data) { +function hook_metatag_cache_set_expire_alter(&$expire, $cid, array $data) { $expire = CACHE_TEMPORARY; } diff --git a/metatag.inc b/metatag.inc index 22c2571..8a1dcc3 100644 --- a/metatag.inc +++ b/metatag.inc @@ -15,30 +15,62 @@ interface DrupalMetaTagInterface { * * @param array $info * The information about the meta tag from metatag_get_info(). + * @param array $data + * The data to load for this meta tag, usually including the item 'value'. */ - function __construct(array $info, array $data = array()); + public function __construct(array $info, array $data = array()); + /** + * Build the form for this meta tag. + * + * @return array + * A standard FormAPI array. + */ public function getForm(); - //function validateForm(); - - //function processForm(); - + /** + * Get the string value of this meta tag. + * + * @return string + * The value of this meta tag. + */ public function getValue(); - function getWeight(); + /** + * Calculate the weight of this meta tag. + * + * @return int + * Weight. + */ + public function getWeight(); - function getElement(); + /** + * Get the HTML tag for this meta tag. + * + * @return array + * A render array for this meta tag. + */ + public function getElement(); - function tidyValue($value); - - function convertUrlToAbsolute($url); - - function truncate($value); - - function maxlength(); - - static function text_summary($text, $size); + /** + * Copied from text.module with the following changes:. + * + * Change 1: $size is required. + * Change 2: $format is removed. + * Change 3: Don't trim at the end of short sentences + * (https://www.drupal.org/node/1620104). + * Change 4: Word boundaries (https://www.drupal.org/node/1482178). + * Change 5: Trim the final string. + * + * @param string $text + * The string to be processed. + * @param int $size + * The maximum length to trim the string to. + * + * @return string + * The string after it is truncated. + */ + public static function textSummary($text, $size); } @@ -69,9 +101,9 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { protected $weight = 0; /** - * Constructor. + * {@inheritdoc} */ - function __construct(array $info, array $data = NULL) { + public function __construct(array $info, array $data = NULL) { $this->info = $info; if (isset($data)) { $this->data = $data; @@ -79,12 +111,9 @@ function __construct(array $info, array $data = NULL) { } /** - * Calculate the weight of this meta tag. - * - * @return int - * Weight. + * {@inheritdoc} */ - function getWeight() { + public function getWeight() { static $counter = 0; // If no weight value is found, stack this meta tag at the end. @@ -97,20 +126,14 @@ function getWeight() { } /** - * Build the form for this meta tag. - * - * @return array - * A standard FormAPI array. + * {@inheritdoc} */ public function getForm(array $options = array()) { return array(); } /** - * Get the string value of this meta tag. - * - * @return string - * The value of this meta tag. + * {@inheritdoc} */ public function getValue(array $options = array()) { $value = $this->tidyValue($this->data['value']); @@ -124,10 +147,7 @@ public function getValue(array $options = array()) { } /** - * Get the HTML tag for this meta tag. - * - * @return array - * A render array for this meta tag. + * {@inheritdoc} */ public function getElement(array $options = array()) { $value = $this->getValue($options); @@ -173,7 +193,10 @@ public function getElement(array $options = array()) { // Add header information if desired. if (!empty($this->info['header'])) { - $element['#attached']['drupal_add_http_header'][] = array($this->info['header'], $value); + $element['#attached']['drupal_add_http_header'][] = array( + $this->info['header'], + $value, + ); } $elements[] = array($element, $element['#id']); @@ -196,7 +219,7 @@ public function getElement(array $options = array()) { * @return string * The meta tag value after it has been tidied up. */ - public function tidyValue($value) { + protected function tidyValue($value) { // This shouldn't happen, but protect against tokens returning arrays. if (!is_string($value)) { return ''; @@ -246,7 +269,7 @@ public function tidyValue($value) { * @return string * The argument converted to an absolute URL. */ - function convertUrlToAbsolute($url) { + protected function convertUrlToAbsolute($url) { // Convert paths relative to the hostname, that start with a slash, to // ones that are relative to the Drupal root path; ignore protocol-relative // URLs. @@ -266,7 +289,7 @@ function convertUrlToAbsolute($url) { } /** - * Shorten a string to a certain length using text_summary(). + * Shorten a string to a certain length using ::textSummary(). * * @param string $value * String to shorten. @@ -274,11 +297,11 @@ function convertUrlToAbsolute($url) { * @return string * Shortened string. */ - function truncate($value) { + protected function truncate($value) { $maxlength = $this->maxlength(); if (!empty($value) && $maxlength > 0) { - $value = $this->text_summary($value, $maxlength); + $value = $this->textSummary($value, $maxlength); } return $value; @@ -290,7 +313,7 @@ function truncate($value) { * @return int * Maxlenght. */ - function maxlength() { + protected function maxlength() { if (isset($this->info['maxlength'])) { return intval(variable_get('metatag_maxlength_' . $this->info['name'], $this->info['maxlength'])); } @@ -298,26 +321,21 @@ function maxlength() { } /** - * Copied from text.module with the following changes:. - * - * Change 1: $size is required. - * Change 2: $format is removed. - * Change 3: Don't trim at the end of short sentences - * (https://www.drupal.org/node/1620104). - * Change 4: Word boundaries (https://www.drupal.org/node/1482178). - * Change 5: Trim the final string. + * {@inheritdoc} */ - static function text_summary($text, $size) { + public static function textSummary($text, $size) { + // What used to be called 'teaser' is now called 'summary', but + // the variable 'teaser_length' is preserved for backwardscompatibility. + // @code // if (!isset($size)) { - // // What used to be called 'teaser' is now called 'summary', but - // // the variable 'teaser_length' is preserved for backwards compatibility. // $size = variable_get('teaser_length', 600); // } + // @endcode // Find where the delimiter is in the body. $delimiter = strpos($text, ''); - // If the size is zero, and there is no delimiter, - // the entire body is the summary. + // If the size is zero, and there is no delimiter, the entire body is the + // summary. if ($size == 0 && $delimiter === FALSE) { return $text; } @@ -330,12 +348,14 @@ static function text_summary($text, $size) { // We check for the presence of the PHP evaluator filter in the current // format. If the body contains PHP code, we do not split it up to prevent // parse errors. + // @code // if (isset($format)) { // $filters = filter_list_format($format); // if (isset($filters['php_code']) && $filters['php_code']->status && strpos($text, '' => 6, '
' => 4); // Newline only indicates a line break if line break converter // filter is present. + // @code // if (isset($filters['filter_autop'])) { // $line_breaks["\n"] = 1; // } // $break_points[] = $line_breaks; + // @endcode // If the first paragraph is too long, split at the end of a sentence. + // @code // $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1); + // @endcode // From https://www.drupal.org/node/1482178. // If the first sentence is too long, split at the first word break. $word_breaks = array(' ' => 0, "\t" => 0); @@ -402,9 +426,11 @@ static function text_summary($text, $size) { // If the htmlcorrector filter is present, apply it to the generated // summary. + // @code // if (isset($filters['filter_htmlcorrector'])) { // $summary = _filter_htmlcorrector($summary); // } + // @endcode return trim($summary); } @@ -557,7 +583,7 @@ public function getValue(array $options = array()) { $values = array($values[0]); } - foreach ($values as $key => &$image_value) { + foreach ($values as &$image_value) { // Remove any unwanted whitespace around the value. $image_value = trim($image_value); @@ -626,12 +652,16 @@ public function getElement(array $options = array()) { // Also send the generator in the HTTP header. // @todo This does not support 'rev' or alternate link headers. $element['#attached']['drupal_add_http_header'][] = array( - 'Link', '<' . $value . '>;' . drupal_http_header_attributes(array('rel' => $element['#name'])), TRUE, + 'Link', + '<' . $value . '>;' . drupal_http_header_attributes(array('rel' => $element['#name'])), + TRUE, ); } return array( - '#attached' => array('drupal_add_html_head' => array(array($element, $element['#id']))), + '#attached' => array( + 'drupal_add_html_head' => array(array($element, $element['#id'])), + ), ); } @@ -675,7 +705,7 @@ class DrupalListMetaTag extends DrupalDefaultMetaTag { /** * {@inheritdoc} */ - function __construct(array $info, array $data = NULL) { + public function __construct(array $info, array $data = NULL) { // Ensure that the $data['value] argument is an array. if (empty($data['value'])) { $data['value'] = array(); diff --git a/metatag.install b/metatag.install index e246509..f634567 100644 --- a/metatag.install +++ b/metatag.install @@ -135,7 +135,7 @@ function metatag_requirements($phase) { 'severity' => REQUIREMENT_INFO, 'title' => 'Metatag', 'value' => $t('The Fast Token Browser module is recommended.'), - 'description' => $t("Using the !url can help avoid problems with the token browser.", array('!url' => l('Fast Token Browser module', 'https://www.drupal.org/project/fast_token_browser'))), + 'description' => $t("Using the !url can help avoid problems with the token browser.", array('!url' => l(t('Fast Token Browser module'), 'https://www.drupal.org/project/fast_token_browser'))), ); } @@ -532,7 +532,7 @@ function metatag_enable() { * @param string $new_tag * The meta tag that replaces the old one. */ -function metatag_update_replace_entity_tag(&$sandbox, $old_tag, $new_tag) { +function metatag_update_replace_entity_tag(array &$sandbox, $old_tag, $new_tag) { if (!isset($sandbox['progress'])) { // Count of all {metatag} records that contained an entry for the old meta // tag. @@ -608,7 +608,7 @@ function metatag_update_replace_entity_tag(&$sandbox, $old_tag, $new_tag) { * @param string $new_value * The meta tag value that replaces the old one. */ -function metatag_update_replace_entity_value(&$sandbox, $meta_tag, $old_value, $new_value) { +function metatag_update_replace_entity_value(array &$sandbox, $meta_tag, $old_value, $new_value) { // The condition used for both queries. $db_and = db_and(); $db_and->condition('m.data', '%' . db_like('"' . $meta_tag . '"') . '%', 'LIKE'); @@ -799,7 +799,7 @@ function metatag_update_replace_config_value($meta_tag, $old_value, $new_value) /** * Remove a specific meta tag from all configs. * - * @param string $$tag_name + * @param string $tag_name * The meta tag that is to be removed. */ function metatag_update_delete_config($tag_name) { @@ -890,8 +890,7 @@ function metatag_update_7001() { } /** - * Disable the deprecated metatag_ui module which has been merged into metatag, - * again. + * Uninstall the deprecated metatag_ui module, the UI is now in the main module. */ function metatag_update_7002() { if (module_exists('metatag_ui')) { @@ -935,8 +934,7 @@ function metatag_update_7004() { } /** - * Removing wrong metatag watchdog entries that break the admin/reports/dblog - * page. + * Removing wrong metatag watchdog entries that break the dblog page. */ function metatag_update_7005() { if (db_table_exists('watchdog')) { @@ -948,10 +946,11 @@ function metatag_update_7005() { } /** - * Remove {metatag} records that were added by old versions of the module for - * entities that don't actually support Metatag. A more complete version of - * this will be added later on after it's (hopefully) guaranteed that all - * modules have updated to the correct API usage. + * Remove {metatag} records that were added by old versions of the module. + * + * This is for entities that don't actually support Metatag. A more complete + * version of this will be added later on after it's (hopefully) guaranteed that + * all modules have updated to the correct API usage. */ function metatag_update_7006() { $entity_types = array( @@ -978,8 +977,9 @@ function metatag_update_7006() { } /** - * Remove {metatag} records for nodes, users and taxonomy terms that have been - * deleted; older versions of Metatag may have failed to purge these. + * Remove {metatag} records for entities that have been deleted. + * + * Older versions of Metatag may have failed to purge these. */ function metatag_update_7007() { $nodes = db_query("SELECT m.entity_id @@ -1102,7 +1102,7 @@ function metatag_update_7010() { /** * Fix {metatag} records for nodes. */ -function metatag_update_7011(&$sandbox) { +function metatag_update_7011(array &$sandbox) { // Fix the {metatag} table first. metatag_update_7015(); @@ -1249,10 +1249,11 @@ function metatag_update_7012() { } /** - * Fix the {metatag} language value for all non-core entity records. This might - * take a while, depending on how much data needs to be converted. + * Fix the {metatag} language value for all non-core entity records. + * + * This might take a while, depending on how much data needs to be converted. */ -function metatag_update_7013(&$sandbox) { +function metatag_update_7013(array &$sandbox) { // Fix the {metatag} table first. metatag_update_7015(); @@ -1385,7 +1386,7 @@ function metatag_update_7013(&$sandbox) { * It should be OK to run this without doing a separate batch process as there * shouldn't be many records that have this problem. Hopefully. * - * @param $entity_type + * @param string $entity_type * The name of an entity type to check for. */ function _metatag_remove_dupes($entity_type) { @@ -1548,8 +1549,9 @@ function metatag_update_7014() { } /** - * Add the revision_id from the entity into metatag schema, adjust the primary - * keys accordingly. + * Add the revision_id from the entity into metatag schema. + * + * Also adjust the primary keys accordingly. */ function metatag_update_7015() { if (!db_field_exists('metatag', 'revision_id')) { @@ -1562,12 +1564,12 @@ function metatag_update_7015() { // Add the new field. db_add_field('metatag', 'revision_id', array( - 'type' => 'int', - 'unsigned' => TRUE, - 'not null' => TRUE, - 'default' => 0, - 'description' => 'The revision_id for the entity object this data is attached to.', - )); + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'description' => 'The revision_id for the entity object this data is attached to.', + )); // Remove the existing primary key. This may take some work so it can be // database agnostic, i.e. some databases will not like it. @@ -1584,8 +1586,9 @@ function metatag_update_7015() { } /** - * Update the revision ID to fix the NULL values, help avoid problems with - * update 7017. + * Update the revision ID to fix the NULL values. + * + * Help avoid problems with update 7017. */ function metatag_update_7016() { // It's possible that 7015 was not executed if the site had been updated to @@ -1633,13 +1636,14 @@ function metatag_update_7017() { } /** - * Update the revision ID for each record. This may take some time. Should any - * nodes be discovered with a meta tag record for both revision_id 0 and the - * correct revision_id, the "0" value will be deleted; if this is not the - * desired result the {metatag} table must be manually pruned to have the + * Update the revision ID for each record. This may take some time. + * + * Should any nodes be discovered with a meta tag record for both revision_id 0 + * and the correct revision_id, the "0" value will be deleted; if this is not + * the desired result the {metatag} table must be manually pruned to have the * correct records prior to letting this update run. */ -function metatag_update_7018(&$sandbox) { +function metatag_update_7018(array &$sandbox) { // Process records in small groups. // When a group is processed, the batch update engine determines whether it // should continue processing in the same request or provide progress @@ -1774,7 +1778,7 @@ function metatag_update_7018(&$sandbox) { // let the site maintainer/builder choose which of the two records to // keep, we're stuck with a bad scenario. Thankfully this should not // happen very often and would only affect sites that were running a - // dev release. Also, sorry :( + // dev release. Also, sorry :( . else { db_delete('metatag') ->condition('entity_type', $entity_type) @@ -1895,8 +1899,7 @@ function metatag_update_7020() { } /** - * Clear the existing Metatag cache so all unwanted 403/404 paths can be - * purged. + * Clear the Metatag cache so all unwanted 403/404 paths can be purged. */ function metatag_update_7021() { cache_clear_all('*', 'cache_metatag', TRUE); @@ -1935,7 +1938,7 @@ function metatag_update_7025() { /** * Rename the 'copyright' meta tag to 'rights', part 1. */ -function metatag_update_7026(&$sandbox) { +function metatag_update_7026(array &$sandbox) { $old_tag = 'copyright'; $new_tag = 'rights'; return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); @@ -1993,16 +1996,25 @@ function metatag_update_7032() { } /** - * These originally removed the 'author' meta tag, but it was subsequently - * decided that this was not the correct approach, that the meta tag should not - * be removed after all. + * These originally removed the 'author' meta tag but are now skipped. + * + * It was subsequently decided that this was not the correct approach, that the + * meta tag should not be removed after all. * * @see https://www.drupal.org/node/2330823 */ function metatag_update_7033() { } + +/** + * Skipped. + */ function metatag_update_7034() { } + +/** + * Skipped. + */ function metatag_update_7035() { } @@ -2085,8 +2097,7 @@ function metatag_update_7037() { } /** - * Manually enable all content types, vocabularies and the user entity to help - * resolve issues from 1.5's architecture change. + * Manually enable all core entity types to resolve issues from 1.5's changes. */ function metatag_update_7038() { foreach (array('node', 'taxonomy_term', 'user') as $entity_type) { @@ -2115,10 +2126,9 @@ function metatag_update_7039() { } /** - * Fix robots meta tags that might have been broken when they were imported - * from Nodewords. + * Fix any robots meta tags that were broken during importing from Nodewords. */ -function metatag_update_7040(&$sandbox) { +function metatag_update_7040(array &$sandbox) { // Process records by groups of 10 (arbitrary value). // When a group is processed, the batch update engine determines whether it // should continue processing in the same request or provide progress @@ -2244,10 +2254,12 @@ function metatag_update_7040(&$sandbox) { } /** - * Rerun update 7018 that was fixed to run correctly when using Entity - * Translation. This may take some time. + * Rerun update 7018. This may take some time. + * + * The original did not run correctly when using Entity Translation. This was + * fixed. */ -function metatag_update_7041(&$sandbox) { +function metatag_update_7041(array &$sandbox) { metatag_update_7018($sandbox); } @@ -2323,7 +2335,7 @@ function metatag_update_7103() { /** * Remove the entity revision ID from the translation strings. */ -function metatag_update_7104(&$sandbox) { +function metatag_update_7104(array &$sandbox) { // Verify that locales are being used in the first place. if (!module_exists('locale') || !db_table_exists('locales_source')) { return t('Metatag: No translations to fix as the locale system is not enabled.'); @@ -2441,10 +2453,10 @@ function metatag_update_7105() { return t('Fixed the Metatag output strings.'); } - /** - * The output translation strings were renamed to something shorter, so rerun - * update 7105. + * Rerun update 7105. + * + * The output translation strings were renamed to something shorter. */ function metatag_update_7106() { return metatag_update_7105(); @@ -2470,7 +2482,7 @@ function metatag_update_7107() { /** * Delete output translations if it's disabled. */ -function metatag_update_7108(&$sandbox) { +function metatag_update_7108(array &$sandbox) { if (!module_exists('locale') || !db_table_exists('locales_source')) { return t('No translations to fix as the locale system is not enabled.'); } @@ -2565,7 +2577,7 @@ function metatag_update_7108(&$sandbox) { /** * Rename the 'icon_any' meta tag to 'mask-icon' in the entity records. */ -function metatag_update_7109(&$sandbox) { +function metatag_update_7109(array &$sandbox) { module_load_include('install', 'metatag'); $old_tag = 'icon_any'; $new_tag = 'mask-icon'; diff --git a/metatag.module b/metatag.module index 6a88685..93f7e75 100644 --- a/metatag.module +++ b/metatag.module @@ -257,9 +257,9 @@ function metatag_flush_caches() { /** * Implements hook_action_info(). - * Provides integration with Views bulk operations. */ function metatag_action_info() { + // Provides integration with Views bulk operations. return array( 'metatag_modify_metatags_action' => array( 'type' => 'entity', @@ -276,14 +276,14 @@ function metatag_action_info() { /** * Updates entity metatags with values from the action form. * - * @param object $entity + * @param object $entity * The entity housing the metatags to modify. - * @param array $context + * @param array $context * Contextual information passed from the View bulk operation configuration * form. The updated metatag values for the entity are stored in * $context['updates']. */ -function metatag_modify_metatags_action($entity, $context) { +function metatag_modify_metatags_action($entity, array $context) { if (empty($entity)) { drupal_set_message(t("Error while trying to update an entity's metatags."), 'warning', FALSE); @@ -332,14 +332,14 @@ function metatag_modify_metatags_action($entity, $context) { /** * The Views bulk operation configuration form for modifying metatags. * - * @param array $context + * @param array $context * Contextual information passed from the View bulk operation configuration * form. * * @return array * A form API compatible array. */ -function metatag_modify_metatags_action_form($context) { +function metatag_modify_metatags_action_form(array $context) { $form = array( '#entity_type' => $context['entity_type'], ); @@ -365,20 +365,17 @@ function metatag_modify_metatags_action_form($context) { '#type' => 'checkbox', '#title' => t('Reset to metatag defaults'), '#default_value' => FALSE, - '#description' => t('Check to fully reset all metatags on - the entities being modified to their default - configuration.', array( - '@settings' => url('admin/config/search/metatags'), - )), + '#description' => t('Check to fully reset all metatags on the entities being modified to their default configuration.', array('@settings' => url('admin/config/search/metatags'))), ); return $form; } /** - * Submit handler for metatag_modify_metatags_action_form(). Filters out - * the user entered values from the defaults and returns the updated values to - * the $context array. + * Submit handler for metatag_modify_metatags_action_form(). + * + * Filters out the user entered values from the defaults and returns the + * updated values to the $context array. * * @return array * The updated metatag values that is ultimately keyed at $context['updates']. @@ -718,6 +715,7 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $ * @param array $metatags * All of the tag information, keyed by the language code. Most meta tags use * the 'value' element, so the structure should look like: + * @code * array( * LANGUAGE_NONE => array( * 'title' => array( @@ -731,10 +729,11 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $ * ), * ), * ); + * @endcode * @param string|null $bundle * The bundle of the entity that is being saved. Optional. */ -function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $bundle = NULL) { +function metatag_metatags_save($entity_type, $entity_id, $revision_id, array $metatags, $bundle = NULL) { // Check that $entity_id is numeric because of Entity API and string IDs. if (!is_numeric($entity_id)) { return; @@ -1615,7 +1614,10 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( if (!empty($metatag_info['group'])) { $group_key = $metatag_info['group']; if (isset($info['groups'][$group_key]['label']) && !isset($form['metatags'][$langcode][$group_key])) { - $group = $info['groups'][$group_key] + array('form' => array(), 'description' => NULL); + $group = $info['groups'][$group_key] + array( + 'form' => array(), + 'description' => NULL, + ); $form['metatags'][$langcode][$group_key] = $group['form'] + array( '#type' => 'fieldset', '#title' => $group['label'], @@ -1796,10 +1798,10 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) { // Entiy types are enabled by default. // Allow entities to be disabled by assigning a variable // 'metatag_enable_{$entity_type}' the value FALSE, e.g.: - // - // // Disable metatags for file_entity. - // $conf['metatag_enable_file'] = FALSE; - // + // @code + // // Disable metatags for file_entity. + // $conf['metatag_enable_file'] = FALSE; + // @endcode // @see Settings page. if (variable_get('metatag_enable_' . $entity_name, FALSE) == FALSE) { $entity_types[$entity_name] = FALSE; @@ -1818,10 +1820,10 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) { // Allow bundles to be disabled by assigning a variable // 'metatag_enable_{$entity_type}__{$bundle}' the value FALSE, e.g.: - // - // // Disable metatags for carousel nodes. - // $conf['metatag_enable_node__carousel'] = FALSE; - // + // @code + // // Disable metatags for carousel nodes. + // $conf['metatag_enable_node__carousel'] = FALSE; + // @endcode // @see Settings page. if (variable_get('metatag_enable_' . $entity_name . '__' . $bundle_name, TRUE) == FALSE) { $entity_types[$entity_name][$bundle_name] = FALSE; @@ -1859,9 +1861,9 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) { * Enable support for a specific entity type if setting does not exist. * * @param string $entity_type - * The entity type. + * The entity type. * @param string $bundle - * The bundle of the entity. + * The bundle of the entity. * @param bool $force_enable * If TRUE, then the type is enabled regardless of any stored variables. * @@ -1898,9 +1900,9 @@ function metatag_entity_type_enable($entity_type, $bundle = NULL, $force_enable * Disable support for a specific entity type. * * @param string $entity_type - * The entity type. + * The entity type. * @param string $bundle - * The bundle of the entity. + * The bundle of the entity. */ function metatag_entity_type_disable($entity_type, $bundle = NULL) { // The bundle was defined. @@ -1924,7 +1926,7 @@ function metatag_entity_type_disable($entity_type, $bundle = NULL) { * @param array $metatags * An array of meta tags from metatag_metatags_view(). */ -function metatag_page_set_metatags($instance, $metatags) { +function metatag_page_set_metatags($instance, array $metatags) { $page_metatags = &drupal_static(__FUNCTION__, array()); $page_metatags[$instance] = $metatags; } @@ -1940,7 +1942,7 @@ function metatag_page_get_metatags() { /** * Implements hook_page_build(). */ -function metatag_page_build(&$page) { +function metatag_page_build(array &$page) { // By default do not add meta tags to admin pages. To enable meta tags on // admin pages set the 'metatag_tag_admin_pages' variable to TRUE. if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) { @@ -2028,9 +2030,9 @@ function metatag_page_build(&$page) { * Returns whether the current page is the page of the passed in entity. * * @param string $entity_type - * The entity type; e.g. 'node' or 'user'. + * The entity type; e.g. 'node' or 'user'. * @param object $entity - * The entity object. + * The entity object. * * @return mixed * TRUE if the current page is the page of the specified entity, or FALSE @@ -2369,7 +2371,9 @@ function metatag_html_head_alter(&$elements) { 'canonical', 'shortlink', // Leave the shortcut icon, that's more of a theming thing. - // 'shortcut icon',. + // @code + // 'shortcut icon', + // @endcode ); foreach ($elements as $name => &$element) { // Ignore meta tags provided by Metatag. @@ -2766,7 +2770,7 @@ function _metatag_isdefaultrevision($entity) { // - https://www.drupal.org/node/1522154 // // Every moderation module saving a forward revision needs to return FALSE. - // @todo: Refactor this workaround under D8. + // @todo Refactor this workaround under D8. // Workbench Moderation v1 uses the hook_node_presave() for some custom logic. // This was replaced with hook_entity_presave() in v3, so only proceed if the // old hook implementation is present. @@ -2893,14 +2897,14 @@ function metatag_admin_menu_cache_info() { * modes, must be fieldable, and may not be a configuration entity. * * @param string $entity_type - * The entity type. + * The entity type. * @param array $entity_info - * Entity information. + * Entity information. * * @return bool - * Return TRUE if suitable. + * Return TRUE if suitable. */ -function metatag_entity_type_is_suitable($entity_type, $entity_info = array()) { +function metatag_entity_type_is_suitable($entity_type, array $entity_info = array()) { $suitable = TRUE; // If the entity info was not passed along, load it. @@ -2959,10 +2963,9 @@ function metatag_entity_type_is_suitable($entity_type, $entity_info = array()) { /** * Implements hook_node_type_insert(). - * - * When a content type is created, enable it for use with Metatag. */ function metatag_node_type_insert($info) { + // When a content type is created, enable it for use with Metatag. if (metatag_entity_supports_metatags('node')) { if (metatag_entity_type_enable('node', $info->type)) { drupal_set_message(t('Metatag support has been enabled for the @label content type.', array('@label' => $info->name))); @@ -2972,19 +2975,17 @@ function metatag_node_type_insert($info) { /** * Implements hook_node_type_delete(). - * - * When a content type is deleted, remove the corresponding Metatag variable. */ function metatag_node_type_delete($info) { + // When a content type is deleted, remove the corresponding Metatag variable. variable_del('metatag_enable_node__' . $info->type); } /** * Implements hook_taxonomy_vocabulary_insert(). - * - * When a vocabulary is created, enable it for use with Metatag. */ function metatag_taxonomy_vocabulary_insert($vocabulary) { + // When a vocabulary is created, enable it for use with Metatag. if (metatag_entity_supports_metatags('taxonomy_term')) { if (metatag_entity_type_enable('taxonomy_term', $vocabulary->machine_name)) { drupal_set_message(t('Metatag support has been enabled for the @label vocabulary.', array('@label' => $vocabulary->name))); @@ -2994,10 +2995,9 @@ function metatag_taxonomy_vocabulary_insert($vocabulary) { /** * Implements hook_taxonomy_vocabulary_delete(). - * - * When a vocabulary is deleted, remove the corresponding Metatag variable. */ function metatag_taxonomy_vocabulary_delete($info) { + // When a vocabulary is deleted, remove the corresponding Metatag variable. variable_del('metatag_enable_taxonomy_term__' . $info->machine_name); } @@ -3043,12 +3043,11 @@ function _metatag_config_instance_sort($a, $b) { /** * Implements hook_entity_translation_delete(). - * - * Required for content translations being handled via Entity_Translation to - * remove the appropriate record when a translation is removed without the - * corresponding entity record also being removed. */ function metatag_entity_translation_delete($entity_type, $entity, $langcode) { + // Required for content translations being handled via Entity_Translation to + // remove the appropriate record when a translation is removed without the + // corresponding entity record also being removed. // Get the entity's ID. list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); $revision_id = intval($revision_id); @@ -3182,7 +3181,7 @@ function metatag_translate_metatag($string, $tag_name, $context, $langcode = NUL * @param bool $update * Whether or not to create/update records in {locales_source}. */ -function metatag_translate_metatags(&$metatags, $context = NULL, $langcode = NULL, $update = TRUE) { +function metatag_translate_metatags(array &$metatags, $context = NULL, $langcode = NULL, $update = TRUE) { if (!empty($metatags)) { foreach ($metatags as $key => $data) { if (!empty($data['value']) && is_string($data['value'])) { @@ -3202,7 +3201,7 @@ function metatag_translate_metatags(&$metatags, $context = NULL, $langcode = NUL * @param string $context * The string that will be used to group strings in the translation UI. */ -function metatag_translations_update($metatags, $context) { +function metatag_translations_update(array $metatags, $context) { // Store the context as it was originally provided. $original_context = $context; @@ -3243,7 +3242,7 @@ function metatag_translations_update($metatags, $context) { * @param string $context * The string that will be used to group strings in the translation UI. */ -function metatag_translations_delete($metatags, $context) { +function metatag_translations_delete(array $metatags, $context) { // Store the context as it was originally provided. $original_context = $context; @@ -3278,30 +3277,27 @@ function metatag_translations_delete($metatags, $context) { /** * Implements hook_config_insert(). - * - * Implements hook_metatag_config_insert() on behalf of i18n_string. */ function i18n_string_metatag_config_insert($config) { + // Implements hook_metatag_config_insert() on behalf of i18n_string. $context = 'metatag_config:' . $config->instance; metatag_translations_update($config->config, $context); } /** * Implements hook_config_update(). - * - * Implements hook_metatag_config_update() on behalf of i18n_string. */ function i18n_string_metatag_config_update($config) { + // Implements hook_metatag_config_update() on behalf of i18n_string. // Defer to the 'insert' function. i18n_string_metatag_config_insert($config); } /** * Implements hook_config_delete(). - * - * Implements hook_metatag_config_delete() on behalf of i18n_string. */ function i18n_string_metatag_config_delete($config) { + // Implements hook_metatag_config_delete() on behalf of i18n_string. $context = 'metatag_config:' . $config->instance; metatag_translations_delete($config->config, $context); } diff --git a/metatag.tokens.inc b/metatag.tokens.inc index 630fa83..3127453 100644 --- a/metatag.tokens.inc +++ b/metatag.tokens.inc @@ -23,7 +23,7 @@ function metatag_token_info() { $label = $metatag_info['groups'][$value['group']]['label'] . ': ' . $value['label']; } else { - $label = t('Basic tags') . ': ' . $value['label']; + $label = t('Basic tags: @label', array('@label' => $value['label'])); } $info['tokens']['metatag'][$value['name']] = array( 'name' => $label, @@ -60,7 +60,10 @@ function metatag_token_info() { $page = str_replace('PAGER', 12, $pager); $info['tokens']['current-page']['pager'] = array( 'name' => t('Custom pager'), - 'description' => t('A custom pager (from the Metatag module). Currently set to "@pager" which would be output as e.g. "@page".', array('@pager' => $pager, '@page' => $page)), + 'description' => t('A custom pager (from the Metatag module). Currently set to "@pager" which would be output as e.g. "@page".', array( + '@pager' => $pager, + '@page' => $page, + )), ); // Custom summary tokens for each long text field. @@ -77,7 +80,10 @@ function metatag_token_info() { if (!empty($instance['entity_type']) && !empty($instance['label'])) { $info['tokens'][$instance['entity_type']][$field_name . '-summary'] = array( 'name' => t('@label (summary)', array('@label' => $instance['label'])), - 'description' => t('A summary of the @label field, trimmed to @length characters.', array('@label' => $instance['label'], '@length' => $trim_length)), + 'description' => t('A summary of the @label field, trimmed to @length characters.', array( + '@label' => $instance['label'], + '@length' => $trim_length, + )), ); } } @@ -233,8 +239,10 @@ function metatag_token_generate_array($entity, $entity_type, $bundle) { } /** - * Loop through metatags to avoid recursion on entity tokens. It will replace - * entity metatag token to its actual entity metatag field value. + * Loop through metatags to avoid recursion on entity tokens. + * + * It will replace entity metatag token to its actual entity metatag field + * value. * * @param array $metatags * An array of entity metatag tokens. @@ -244,7 +252,7 @@ function metatag_token_generate_array($entity, $entity_type, $bundle) { * @return array * Return metatags array with entity metatag tokens replaced. */ -function _metatag_token_process_metatag($metatags, $token_type) { +function _metatag_token_process_metatag(array $metatags, $token_type) { foreach ($metatags as $metatag => $data) { // Skip values that are not strings. if (!is_string($data['value'])) { @@ -294,7 +302,7 @@ function _metatag_token_process_metatag($metatags, $token_type) { * @return string * The replaced value of $token. */ -function metatag_token_entitymetatagtoken_replace($metatags, $token, $token_type, $search_tokens = array(), $replace_tokens = array()) { +function metatag_token_entitymetatagtoken_replace(array $metatags, $token, $token_type, array $search_tokens = array(), array $replace_tokens = array()) { $data_tokens = token_scan($token); // Check field has tokens. if (isset($data_tokens[$token_type])) { diff --git a/metatag.vertical-tabs.js b/metatag.vertical-tabs.js index d14f375..8488a03 100644 --- a/metatag.vertical-tabs.js +++ b/metatag.vertical-tabs.js @@ -10,7 +10,7 @@ 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).each(function () { var input_field = $(this).attr('name'); // Verify the field exists before proceeding. if (input_field === undefined) { diff --git a/metatag.views.inc b/metatag.views.inc index 6510829..3dfe9f4 100644 --- a/metatag.views.inc +++ b/metatag.views.inc @@ -30,8 +30,10 @@ function metatag_views_data() { 'left_field' => $info['entity keys'][$support_revisions ? 'revision' : 'id'], 'extra' => array( array('field' => 'entity_type', 'value' => $entity_type), - // @todo Replace with real language support - # array('field' => 'language', 'value' => LANGUAGE_NONE) + // @todo Replace with real language support. + // @code + // array('field' => 'language', 'value' => LANGUAGE_NONE), + // @endcode ), ); } @@ -44,7 +46,7 @@ function metatag_views_data() { // Assign a field handler based on the tag class. $handlers = array( - 'DrupalListMetaTag' => 'metatag_handler_field_serialized_list' + 'DrupalListMetaTag' => 'metatag_handler_field_serialized_list', ); // Add a field for each known meta tag. @@ -61,7 +63,7 @@ function metatag_views_data() { $field['field'] = array( 'real field' => 'data', - 'path' => array($name, 'value') + 'path' => array($name, 'value'), ); $field['field']['handler'] = isset($handlers[$options['class']]) ? $handlers[$options['class']] : $handler_default; $field['field']['metatag'] = $name; @@ -70,7 +72,7 @@ function metatag_views_data() { // @todo Might have to check leading characters. $safe_name = preg_replace('/[^a-z0-9_]/', '_', $name); if (!isset($blacklist[$safe_name])) { - // Name not yet used, add to blacklist with a count of 1 + // Name not yet used, add to blacklist with a count of 1. $blacklist[$safe_name] = 1; } else { diff --git a/metatag_app_links/tests/MetatagAppLinksTagsTest.test b/metatag_app_links/tests/MetatagAppLinksTagsTest.test index 3a5b5b1..dbc3eaa 100644 --- a/metatag_app_links/tests/MetatagAppLinksTagsTest.test +++ b/metatag_app_links/tests/MetatagAppLinksTagsTest.test @@ -60,7 +60,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_app_links'; parent::setUp($modules); } diff --git a/metatag_context/metatag_context.admin.inc b/metatag_context/metatag_context.admin.inc index 3e8ba62..275e2ae 100644 --- a/metatag_context/metatag_context.admin.inc +++ b/metatag_context/metatag_context.admin.inc @@ -11,7 +11,8 @@ function metatag_context_context_overview() { $contexts = context_enabled_contexts(TRUE); - $header = array(t('Name'), t('Paths'), t('Weight'), t('Operations')); $rows = array(); + $header = array(t('Name'), t('Paths'), t('Weight'), t('Operations')); + $rows = array(); $caption = t('Values assigned here inherit from the global defaults. Use the weight to specify the order the context meta tags run.', array('@url' => url('admin/config/search/metatags/config/global'))); diff --git a/metatag_context/metatag_context.context.inc b/metatag_context/metatag_context.context.inc index 0ea51d1..8b7133c 100644 --- a/metatag_context/metatag_context.context.inc +++ b/metatag_context/metatag_context.context.inc @@ -9,7 +9,11 @@ * Context reaction for Metatag. */ class metatag_context_reaction extends context_reaction { - function options_form($context) { + + /** + * {@inheritdoc} + */ + public function options_form($context) { $form = array(); // Don't care about the instance name, the data is being managed by @@ -116,7 +120,7 @@ function options_form($context) { /** * Output a list of active contexts. */ - function execute() { + public function execute() { $output = &drupal_static('metatag_context'); if (!isset($output)) { @@ -148,7 +152,10 @@ function execute() { $weight = isset($context->reactions['metatag_context_reaction']['weight']) ? $context->reactions['metatag_context_reaction']['weight'] : 0; - $instance_names[] = array('name' => $context->name, 'weight' => $weight); + $instance_names[] = array( + 'name' => $context->name, + 'weight' => $weight, + ); } } diff --git a/metatag_context/metatag_context.i18n.inc b/metatag_context/metatag_context.i18n.inc index df8bfd9..2632503 100644 --- a/metatag_context/metatag_context.i18n.inc +++ b/metatag_context/metatag_context.i18n.inc @@ -14,24 +14,34 @@ function metatag_context_i18n_object_info() { // Callback to load all config objects. 'list callback' => 'metatag_context_i18n_list_contexts', // The object load callback. + // @code // 'load callback' => 'metatag_context_i18n_load', + // @endcode // @todo Custom i18n object overrides. - // 'class' => 'metatag_context_i18n_metatag', + // @code + // 'class' => 'metatag_context_i18n_metatag' + // @endcode // @todo Is this needed? What does it do? - // 'translation set' => TRUE, - + // @code + // 'translation set' => TRUE + // @endcode // The object key field. 'key' => 'name', // Placeholders for automatic paths. This connects the 'key' to strings in // the paths listed below. + // @code // 'placeholders' => array( // '%name' => 'name', // ), + // @endcode // To produce edit links automatically. + // @code // 'edit path' => 'admin/config/search/metatags/config/%instance', + // @endcode // Auto-generate a 'translate' tab. + // @code // 'translate tab' => 'admin/config/search/metatags/config/%instance/translate', - + // @endcode // Properties for string translation. 'string translation' => array( // The textgroup, type and (below) name will be concatenated into a single @@ -43,7 +53,9 @@ function metatag_context_i18n_object_info() { // Translatable properties of these objects, this will be added later. 'properties' => array(), // The path to translate individual strings. + // @code // 'translate path' => 'admin/config/search/metatags/config/%instance/translate/%i18n_language', + // @endcode ), ); @@ -68,8 +80,10 @@ function metatag_context_i18n_object_info() { $title = $tag_info['label']; if (!empty($tag_info['group'])) { $tag_group = $tag_info['group']; - $group_label = !empty($groups[$tag_group]['label']) ? $groups[$tag_group]['label'] : $tag_group; - $title = $group_label . ': ' . $title; + if (empty($groups[$tag_group]['label'])) { + $tag_group = $groups[$tag_group]['label']; + } + $title = $tag_group . ': ' . $title; } $info['metatag_context']['string translation']['properties'][$tag_name] = array( @@ -83,10 +97,9 @@ function metatag_context_i18n_object_info() { /** * Implements hook_i18n_string_list(). - * - * @todo Functionality to delete translation records when Panels are deleted. */ function metatag_context_i18n_string_list($group) { + // @todo Functionality to delete translation records when Panels are deleted. if ($group == 'metatag' || $group == 'all') { $strings = array(); diff --git a/metatag_context/tests/MetatagContextWithI18nTest.test b/metatag_context/tests/MetatagContextWithI18nTest.test index cfc1a70..197aa75 100644 --- a/metatag_context/tests/MetatagContextWithI18nTest.test +++ b/metatag_context/tests/MetatagContextWithI18nTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'context'; $modules[] = 'metatag_context'; diff --git a/metatag_dc/tests/MetatagDcTagsTest.test b/metatag_dc/tests/MetatagDcTagsTest.test index cb4337a..5859537 100644 --- a/metatag_dc/tests/MetatagDcTagsTest.test +++ b/metatag_dc/tests/MetatagDcTagsTest.test @@ -46,7 +46,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_dc'; parent::setUp($modules); } diff --git a/metatag_dc_advanced/tests/MetatagDcAdvancedTagsTest.test b/metatag_dc_advanced/tests/MetatagDcAdvancedTagsTest.test index e506331..3e4dadb 100644 --- a/metatag_dc_advanced/tests/MetatagDcAdvancedTagsTest.test +++ b/metatag_dc_advanced/tests/MetatagDcAdvancedTagsTest.test @@ -71,7 +71,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_dc_advanced'; parent::setUp($modules); } diff --git a/metatag_devel/tests/MetatagDevelTest.test b/metatag_devel/tests/MetatagDevelTest.test index d203aab..aa71ef9 100644 --- a/metatag_devel/tests/MetatagDevelTest.test +++ b/metatag_devel/tests/MetatagDevelTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_devel'; parent::setUp($modules); diff --git a/metatag_facebook/tests/MetatagFacebookTagsTest.test b/metatag_facebook/tests/MetatagFacebookTagsTest.test index fb9aab4..f879547 100644 --- a/metatag_facebook/tests/MetatagFacebookTagsTest.test +++ b/metatag_facebook/tests/MetatagFacebookTagsTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_facebook'; parent::setUp($modules); } diff --git a/metatag_favicons/metatag_favicons.metatag.inc b/metatag_favicons/metatag_favicons.metatag.inc index 759ac3a..da9079a 100644 --- a/metatag_favicons/metatag_favicons.metatag.inc +++ b/metatag_favicons/metatag_favicons.metatag.inc @@ -27,7 +27,7 @@ function metatag_favicons_metatag_info() { ), ); - // favicons meta tags stack after the simple tags. + // Favicons meta tags stack after the simple tags. $weight = 100; // Default values for each meta tag. diff --git a/metatag_favicons/metatag_favicons.module b/metatag_favicons/metatag_favicons.module index a3ed575..6ca2cfb 100644 --- a/metatag_favicons/metatag_favicons.module +++ b/metatag_favicons/metatag_favicons.module @@ -117,7 +117,7 @@ function theme_metatag_shortcut_icon($variables) { * Helper function to get the theme's favicon URL. * * @return string - * The absolute URL to the favicon, empty string if not found. + * The absolute URL to the favicon, empty string if not found. */ function metatag_favicons_get_theme_favicon() { $favicon_url = ''; @@ -137,7 +137,7 @@ function metatag_favicons_get_theme_favicon() { * The URI, or URL, of the favicon to be checked. * * @return string - * The MIME type on success, an empty string on failure. + * The MIME type on success, an empty string on failure. */ function metatag_favicons_get_mime_type($uri) { // URLs must have a file extension in order for this to work. diff --git a/metatag_favicons/tests/MetatagFaviconsTagsTest.test b/metatag_favicons/tests/MetatagFaviconsTagsTest.test index 88b582a..4f11d6f 100644 --- a/metatag_favicons/tests/MetatagFaviconsTagsTest.test +++ b/metatag_favicons/tests/MetatagFaviconsTagsTest.test @@ -53,7 +53,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_favicons'; parent::setUp($modules); } diff --git a/metatag_google_plus/tests/MetatagGooglePlusTagsTest.test b/metatag_google_plus/tests/MetatagGooglePlusTagsTest.test index ddd65ad..6621c83 100644 --- a/metatag_google_plus/tests/MetatagGooglePlusTagsTest.test +++ b/metatag_google_plus/tests/MetatagGooglePlusTagsTest.test @@ -38,7 +38,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_google_plus'; parent::setUp($modules); } diff --git a/metatag_hreflang/metatag_hreflang.module b/metatag_hreflang/metatag_hreflang.module index ac32a69..7cfdf84 100644 --- a/metatag_hreflang/metatag_hreflang.module +++ b/metatag_hreflang/metatag_hreflang.module @@ -7,6 +7,7 @@ // @todo Clear caches for all versions of an entity when a translation is edited // so that the hreflang meta tags update appropriately. + /** * Implements hook_ctools_plugin_api(). */ @@ -46,7 +47,7 @@ function theme_metatag_link_hreflang($variables) { } /** - * Implements hook_form_FORM_ID_alter for metatag_admin_settings_form(). + * Implements hook_form_FORM_ID_alter() for metatag_admin_settings_form(). */ function metatag_hreflang_form_metatag_admin_settings_form_alter(&$form, &$form_state, $form_id) { $form['advanced']['metatag_hreflang_allow_dupe'] = array( @@ -59,13 +60,12 @@ function metatag_hreflang_form_metatag_admin_settings_form_alter(&$form, &$form_ /** * Implements hook_metatag_metatags_view_alter(). - * - * Remove any hreflang="LANGCODE" values that match hreflang="x-default". Using - * this hook instead of hook_html_head_alter() as it gets closer to Metatag's - * data structures, and the results are cached so this won't be executed on - * every page request. */ function metatag_hreflang_metatag_metatags_view_alter(&$output, $instance, $options) { + // Remove any hreflang="LANGCODE" values that match hreflang="x-default". + // Using this hook instead of hook_html_head_alter() as it gets closer to + // Metatag's data structures, and the results are cached so this won't be + // executed on every page request. // This behaviour may be disabled from the Metatag settings page. if (!variable_get('metatag_hreflang_allow_dupe', FALSE)) { if (!empty($output['hreflang_xdefault'])) { diff --git a/metatag_hreflang/tests/MetatagHreflangTagsTest.test b/metatag_hreflang/tests/MetatagHreflangTagsTest.test index a1ebd53..f7e3bc8 100644 --- a/metatag_hreflang/tests/MetatagHreflangTagsTest.test +++ b/metatag_hreflang/tests/MetatagHreflangTagsTest.test @@ -34,7 +34,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_hreflang'; parent::setUp($modules); diff --git a/metatag_hreflang/tests/MetatagHreflangWithEntityTranslationTest.test b/metatag_hreflang/tests/MetatagHreflangWithEntityTranslationTest.test index f5e78da..3a6691b 100644 --- a/metatag_hreflang/tests/MetatagHreflangWithEntityTranslationTest.test +++ b/metatag_hreflang/tests/MetatagHreflangWithEntityTranslationTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Used for debugging some token values. $modules[] = 'devel'; @@ -112,7 +112,7 @@ private function supportedLocales() { * The langcode of the current form. Defaults to LANGUAGE_NONE, which is * what is used on an empty node/add form. */ - private function assertHreflangFields($form_langcode = LANGUAGE_NONE) { + protected function assertHreflangFields($form_langcode = LANGUAGE_NONE) { // The x-default field has a specific default. $this->assertFieldByName("metatags[{$form_langcode}][hreflang_xdefault][value]", "[node:url-original]", 'Found the hreflang=x-default meta tag and it has the correct default value.'); @@ -127,7 +127,7 @@ private function assertHreflangFields($form_langcode = LANGUAGE_NONE) { * Confirm that each locale has a field added and shows the appropriate * default value. */ - function testFormFields() { + public function testFormFields() { $this->drupalGet('node/add/page'); $this->assertResponse(200); @@ -138,7 +138,7 @@ function testFormFields() { /** * Confirm that the meta tags output are correct. */ - function testOutput() { + public function testOutput() { // All of the locales we're supporting in these tests. The languages have // been enabled already, so this gets a list of language objects. $languages = language_list('enabled'); @@ -230,11 +230,13 @@ function testOutput() { $this->assertEqual($xpath[$ctr]['hreflang'], $langcode); // @todo Fix this. Not sure why, but the url() call returns the URL // without the language prefix. + // @code // $url_options = array( // 'language' => $locale, // 'absolute' => TRUE, // ); // $this->assertEqual($xpath[$ctr]['href'], url('node/' . $node->nid, $url_options)); + // @endcode } } diff --git a/metatag_importer/metatag_importer.nodewords.inc b/metatag_importer/metatag_importer.nodewords.inc index 93ae682..0982572 100644 --- a/metatag_importer/metatag_importer.nodewords.inc +++ b/metatag_importer/metatag_importer.nodewords.inc @@ -36,15 +36,15 @@ function metatag_importer_nodewords_form($form, &$form_state) { $form['notes'] = array( '#markup' => '

' . t('Notes') . ':' . '

' - . '', + . '', ); $form['actions']['migrate'] = array( @@ -71,6 +71,12 @@ function metatag_importer_nodewords_form_submit($form, &$form_state) { _metatag_importer_import($types); } +/** + * List all Nodewords data. + * + * @return array + * A list of Nodewords data keyed by the type of record. + */ function _metatag_importer_list_nodewords() { $keys = array( NODEWORDS_TYPE_DEFAULT => t('Default'), @@ -123,6 +129,9 @@ function _metatag_importer_list_nodewords() { /** * Migrates Nodewords data to the Metatag module. + * + * @param array $types + * The types of Nodewords data to convert. */ function _metatag_importer_import(array $types = array()) { $batch = array( @@ -152,7 +161,7 @@ function _metatag_importer_import(array $types = array()) { } /** - * Migrates Nodewords data to the Metatag module. + * Batch API callback to convert Nodewords data to the Metatag module. */ function _metatag_importer_migrate(array $types = array(), &$context = array()) { // Process this number of {nodewords} records at a time. @@ -257,7 +266,9 @@ function _metatag_importer_migrate(array $types = array(), &$context = array()) case 'node': case 'taxonomy_term': case 'user': + // @code // watchdog('metatag_importer', 'Importing meta tags for @entity_type ID @id..', array('@entity_type' => $type, '@id' => $record_id), WATCHDOG_INFO); + // @endcode $entity = entity_load($type, array($record_id)); $entity = reset($entity); $langcode = metatag_entity_get_language($type, $entity); @@ -270,7 +281,9 @@ function _metatag_importer_migrate(array $types = array(), &$context = array()) } metatag_metatags_save($type, $entity_id, $revision_id, $entity->metatags); + // @code // watchdog('metatag_importer', 'Imported meta tags for @entity_type ID @id.', array('@entity_type' => $type, '@id' => $record_id), WATCHDOG_INFO); + // @endcode break; // Other Nodewords settings are converted to {metatag_config} records @@ -297,12 +310,14 @@ function _metatag_importer_migrate(array $types = array(), &$context = array()) metatag_config_save($config); break; - // @todo: A 'vocabulary' setting becomes a default configuration? + // @todo A 'vocabulary' setting becomes a default configuration? case 'vocabulary': - // $metatags = metatag_metatags_load($record->entity_type, $record->entity_id); - // $metatags = array_merge($metatags, $record->data); - // $vocabulary = taxonomy_vocabulary_load($record->entity_id); - // metatag_metatags_save($record->entity_type, $record->entity_id, $vocabulary->vid, $metatags); + // @code + // $metatags = metatag_metatags_load($record->entity_type, $record->entity_id); + // $metatags = array_merge($metatags, $record->data); + // $vocabulary = taxonomy_vocabulary_load($record->entity_id); + // metatag_metatags_save($record->entity_type, $record->entity_id, $vocabulary->vid, $metatags); + // @endcode break; } } @@ -382,13 +397,14 @@ function _metatag_importer_finished($success, $results, $operations) { /** * Converts the Nodewords type to a Metatag entity or Metatag config instance. * - * @param $type + * @param string $type * Nodewords type. * * @return * Metatag entity type or configuration instance. */ function _metatag_importer_convert_type($type) { + // @code // define('NODEWORDS_TYPE_DEFAULT', 1); // define('NODEWORDS_TYPE_ERRORPAGE', 2); // define('NODEWORDS_TYPE_FRONTPAGE', 3); @@ -399,7 +415,8 @@ function _metatag_importer_convert_type($type) { // define('NODEWORDS_TYPE_TERM', 6); // define('NODEWORDS_TYPE_TRACKER', 7); // define('NODEWORDS_TYPE_USER', 8); - // define('NODEWORDS_TYPE_VOCABULARY', 9); + // define('NODEWORDS_TYPE_VOCABULARY', 9);. + // @endcode switch ($type) { case 1: return 'global'; @@ -411,9 +428,10 @@ function _metatag_importer_convert_type($type) { return 'global:frontpage'; // @todo Not yet sure how to handle pager items? + // @code // case 4: // return 'pager'; - + // @endcode case 5: return 'node'; @@ -421,9 +439,10 @@ function _metatag_importer_convert_type($type) { return 'taxonomy_term'; // @todo Not sure what to do with tracker pages. + // @code // case 7: // return 'tracker'; - + // @endcode case 8: return 'user'; @@ -432,8 +451,10 @@ function _metatag_importer_convert_type($type) { return 'vocabulary'; // @todo Page records need to be converted to Context definitions. + // @code // case 10: // return 'page'; + // @endcode } return FALSE; @@ -447,8 +468,8 @@ function _metatag_importer_convert_type($type) { * @param $value * Meta tag value in Nodewords format. * - * @return - * The two arguments returned after being converted, in an array. + * @return array + * The two arguments returned after being converted. */ function _metatag_importer_convert_data($name, $value) { // Initial simplification of simple values. @@ -564,7 +585,6 @@ function _metatag_importer_convert_data($name, $value) { return array($name, $value); } - /** * The following will not be converted because they refer to site-wide defaults * that should be customized appropriately based on the D7 site's content type diff --git a/metatag_importer/metatag_importer.page_title.inc b/metatag_importer/metatag_importer.page_title.inc index d7451c7..eae5b6b 100644 --- a/metatag_importer/metatag_importer.page_title.inc +++ b/metatag_importer/metatag_importer.page_title.inc @@ -128,7 +128,7 @@ function metatag_importer_for_page_title() { $converted += db_delete('page_title') ->condition('type', $entity_type) ->condition('id', $entity_id) - ->execute(); + ->execute(); } // Log any records that were skipped. diff --git a/metatag_importer/tests/MetatagImporterTest.test b/metatag_importer/tests/MetatagImporterTest.test index 43d773e..d93f275 100644 --- a/metatag_importer/tests/MetatagImporterTest.test +++ b/metatag_importer/tests/MetatagImporterTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_importer'; parent::setUp($modules); diff --git a/metatag_mobile/metatag_mobile.module b/metatag_mobile/metatag_mobile.module index 5cb3a4a..3610f99 100644 --- a/metatag_mobile/metatag_mobile.module +++ b/metatag_mobile/metatag_mobile.module @@ -59,7 +59,6 @@ function theme_metatag_mobile_ios_app($variables) { return theme('metatag_link_rel', $variables); } - /** * Theme callback for a handheld-formatted alternative URL. * diff --git a/metatag_mobile/tests/MetatagMobileTagsTest.test b/metatag_mobile/tests/MetatagMobileTagsTest.test index 16fe871..154f059 100644 --- a/metatag_mobile/tests/MetatagMobileTagsTest.test +++ b/metatag_mobile/tests/MetatagMobileTagsTest.test @@ -65,7 +65,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_mobile'; parent::setUp($modules); } diff --git a/metatag_opengraph/metatag_opengraph.metatag.inc b/metatag_opengraph/metatag_opengraph.metatag.inc index 701d9ce..84598aa 100644 --- a/metatag_opengraph/metatag_opengraph.metatag.inc +++ b/metatag_opengraph/metatag_opengraph.metatag.inc @@ -66,7 +66,9 @@ function metatag_opengraph_metatag_bundled_config_alter(array &$configs) { $config->config += array( 'og:image' => array('value' => '[user:picture:url]'), // For now keep the old default. + // @code // 'og:image:url' => array('value' => '[user:picture:url]'), + // @endcode ); } break; @@ -467,6 +469,7 @@ function metatag_opengraph_metatag_info() { // For the "video" og:type. $video_defaults = array(); + // @code // 'dependencies' => array( // array( // 'dependency' => 'og:type', @@ -475,7 +478,7 @@ function metatag_opengraph_metatag_info() { // 'value' => 'profile', // ), // ), - // ); + // @endcode $info['tags']['og:video:url'] = array( 'label' => t('Video URL'), 'description' => t('The URL of an video which should represent the content. For best results use a source that is at least 1200 x 630 pixels in size, but at least 600 x 316 pixels is a recommended minimum. Object types supported include video.episode, video.movie, video.other, and video.tv_show.'), @@ -573,6 +576,12 @@ function metatag_opengraph_metatag_info() { return $info; } +/** + * Provide a list of Open Graph "type" values, grouped by topic. + * + * @return array + * A list of OG "type" values. + */ function _metatag_opengraph_type_options() { $options = array( t('Activities') => array( diff --git a/metatag_opengraph/metatag_opengraph.module b/metatag_opengraph/metatag_opengraph.module index 15e9283..0df765e 100644 --- a/metatag_opengraph/metatag_opengraph.module +++ b/metatag_opengraph/metatag_opengraph.module @@ -14,9 +14,8 @@ function metatag_opengraph_preprocess_html(&$variables) { return; } - // @TODO Would it be worth dynamically identifying whether these should be + // @todo Would it be worth dynamically identifying whether these should be // added, or just output them all? - // Need an extra namespace for the 'og' tags. $variables['rdf_namespaces'] .= "\n xmlns:og=\"http://ogp.me/ns#\""; } diff --git a/metatag_opengraph/tests/MetatagOpenGraphTagsTest.test b/metatag_opengraph/tests/MetatagOpenGraphTagsTest.test index 973be81..3fb8b54 100644 --- a/metatag_opengraph/tests/MetatagOpenGraphTagsTest.test +++ b/metatag_opengraph/tests/MetatagOpenGraphTagsTest.test @@ -89,7 +89,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_opengraph'; parent::setUp($modules); } diff --git a/metatag_opengraph_products/tests/MetatagOpenGraphProductsTagsTest.test b/metatag_opengraph_products/tests/MetatagOpenGraphProductsTagsTest.test index 540c9fa..d3cf4dc 100644 --- a/metatag_opengraph_products/tests/MetatagOpenGraphProductsTagsTest.test +++ b/metatag_opengraph_products/tests/MetatagOpenGraphProductsTagsTest.test @@ -57,7 +57,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_opengraph_products'; parent::setUp($modules); } diff --git a/metatag_panels/metatag_panels.i18n.inc b/metatag_panels/metatag_panels.i18n.inc index 6fef736..a38dbe1 100644 --- a/metatag_panels/metatag_panels.i18n.inc +++ b/metatag_panels/metatag_panels.i18n.inc @@ -46,23 +46,35 @@ function metatag_panels_i18n_object_info() { // Callback to load all config objects. 'list callback' => 'metatag_panels_i18n_list_panels', // The object load callback. + // @code // 'load callback' => 'metatag_panels_i18n_load', + // @endcode // @todo Custom i18n object overrides. + // @code // 'class' => 'metatag_panels_i18n_metatag', + // @endcode // @todo Is this needed? What does it do? + // @code // 'translation set' => TRUE, + // @endcode // The object's "key" field, this tells i18n_string to use the $panel->name // attribute. 'key' => 'name', // Placeholders for automatic paths. This connects the 'key' to strings in // the paths listed below. + // @code // 'placeholders' => array( // '%did' => 'did', // ), + // @endcode // To produce edit links automatically. + // @code // 'edit path' => 'admin/config/search/metatags/config/%instance', + // @endcode // Auto-generate a 'translate' tab. + // @code // 'translate tab' => 'admin/config/search/metatags/config/%instance/translate', + // @endcode // Properties for string translation. 'string translation' => array( // The textgroup, type and (below) name will be concatenated into a single @@ -70,11 +82,15 @@ function metatag_panels_i18n_object_info() { 'textgroup' => 'metatag', 'type' => 'metatag_panels', // Table where the object is stored, to automate string lists. + // @code // 'table' => 'page_manager_handlers', + // @endcode // Translatable properties of these objects, this will be added later. 'properties' => $properties, // The path to translate individual strings. + // @code // 'translate path' => 'admin/config/search/metatags/config/%instance/translate/%i18n_language', + // @endcode ), ); diff --git a/metatag_panels/tests/MetatagPanelsI18nTest.test b/metatag_panels/tests/MetatagPanelsI18nTest.test index aa17156..16a40ba 100644 --- a/metatag_panels/tests/MetatagPanelsI18nTest.test +++ b/metatag_panels/tests/MetatagPanelsI18nTest.test @@ -18,14 +18,16 @@ public static function getInfo() { 'name' => 'Metatag:Panels i18n tests', 'description' => 'Test Metatag integration via the Metatag:Panels module.', 'group' => 'Metatag', - 'dependencies' => array('ctools', 'devel', 'token', 'panels', 'page_manager', 'i18n'), + 'dependencies' => array( + 'ctools', 'devel', 'token', 'panels', 'page_manager', 'i18n', + ), ); } /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'panels'; $modules[] = 'metatag_panels'; diff --git a/metatag_panels/tests/MetatagPanelsTest.test b/metatag_panels/tests/MetatagPanelsTest.test index d66c00f..613dc3a 100644 --- a/metatag_panels/tests/MetatagPanelsTest.test +++ b/metatag_panels/tests/MetatagPanelsTest.test @@ -18,14 +18,16 @@ public static function getInfo() { 'name' => 'Metatag:Panels tests', 'description' => 'Test Metatag integration via the Metatag:Panels module.', 'group' => 'Metatag', - 'dependencies' => array('ctools', 'devel', 'token', 'panels', 'page_manager'), + 'dependencies' => array( + 'ctools', 'devel', 'token', 'panels', 'page_manager', + ), ); } /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'panels'; // Can't really do anything without Page Manager. diff --git a/metatag_pinterest/tests/MetatagPinterestTagsTest.test b/metatag_pinterest/tests/MetatagPinterestTagsTest.test index 6e098b1..1907fba 100644 --- a/metatag_pinterest/tests/MetatagPinterestTagsTest.test +++ b/metatag_pinterest/tests/MetatagPinterestTagsTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_pinterest'; parent::setUp($modules); } diff --git a/metatag_twitter_cards/tests/MetatagTwitterCardsTagsTest.test b/metatag_twitter_cards/tests/MetatagTwitterCardsTagsTest.test index e140c46..be88c04 100644 --- a/metatag_twitter_cards/tests/MetatagTwitterCardsTagsTest.test +++ b/metatag_twitter_cards/tests/MetatagTwitterCardsTagsTest.test @@ -67,7 +67,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_twitter_cards'; parent::setUp($modules); } diff --git a/metatag_verification/tests/MetatagVerificationTagsTest.test b/metatag_verification/tests/MetatagVerificationTagsTest.test index 8596600..f025561 100644 --- a/metatag_verification/tests/MetatagVerificationTagsTest.test +++ b/metatag_verification/tests/MetatagVerificationTagsTest.test @@ -34,13 +34,13 @@ public static function getInfo() { 'p:domain_verify', 'pocket-site-verification', 'yandex-verification', - 'zoom-domain-verification' + 'zoom-domain-verification', ); /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'metatag_verification'; parent::setUp($modules); } diff --git a/metatag_views/metatag_views.i18n.inc b/metatag_views/metatag_views.i18n.inc index 70c0e44..88b684a 100644 --- a/metatag_views/metatag_views.i18n.inc +++ b/metatag_views/metatag_views.i18n.inc @@ -14,24 +14,34 @@ function metatag_views_i18n_object_info() { // Callback to load all config objects. 'list callback' => 'metatag_views_i18n_list_displays', // The object load callback. + // @code // 'load callback' => 'metatag_views_i18n_load', + // @endcode // Custom i18n object overrides. Right now this avoids problems with the // object ID as defined by get_string_context(). 'class' => 'metatag_views_i18n_metatag', // @todo Is this needed? What does it do? + // @code // 'translation set' => TRUE, + // @endcode // The object key field; multiple values will be concatenated with ":" as // the separator. 'key' => array('vid', 'id'), // Placeholders for automatic paths. This connects the 'key' to strings in // the paths listed below. + // @code // 'placeholders' => array( // '%did' => 'did', // ), + // @endcode // To produce edit links automatically. + // @code // 'edit path' => 'admin/config/search/metatags/config/%instance', + // @endcode // Auto-generate a 'translate' tab. + // @code // 'translate tab' => 'admin/config/search/metatags/config/%instance/translate', + // @endcode // Properties for string translation. 'string translation' => array( // The textgroup, type and (below) name will be concatenated into a single @@ -39,11 +49,15 @@ function metatag_views_i18n_object_info() { 'textgroup' => 'metatag', 'type' => 'metatag_views', // Table where the object is stored, to automate string lists. + // @code // 'table' => 'views_display', + // @endcode // Translatable properties of these objects, this will be added later. 'properties' => array(), // The path to translate individual strings. + // @code // 'translate path' => 'admin/config/search/metatags/config/%instance/translate/%i18n_language', + // @endcode ), ); diff --git a/metatag_views/metatag_views_plugin_display_extender_metatags.inc b/metatag_views/metatag_views_plugin_display_extender_metatags.inc index cb30af3..d80c078 100644 --- a/metatag_views/metatag_views_plugin_display_extender_metatags.inc +++ b/metatag_views/metatag_views_plugin_display_extender_metatags.inc @@ -13,7 +13,7 @@ class metatag_views_plugin_display_extender_metatags extends views_plugin_displa /** * {@inheritdoc} */ - function options_definition() { + public function options_definition() { $options = parent::option_definition(); $options['metatags'] = array('default' => ''); $options['metatags_tokenize'] = array('bool' => TRUE, 'default' => FALSE); @@ -23,7 +23,7 @@ function options_definition() { /** * {@inheritdoc} */ - function options_definition_alter(&$options) { + public function options_definition_alter(&$options) { $options['metatags'] = array('default' => array()); $options['metatags_tokenize'] = array('bool' => TRUE, 'default' => FALSE); } @@ -31,7 +31,7 @@ function options_definition_alter(&$options) { /** * {@inheritdoc} */ - function options_summary(&$categories, &$options) { + public function options_summary(&$categories, &$options) { // Defines where within the Views admin UI the new settings will be visible. $categories['metatags'] = array( 'title' => t('Meta tags'), @@ -47,7 +47,7 @@ function options_summary(&$categories, &$options) { /** * {@inheritdoc} */ - function options_form(&$form, &$form_state) { + public function options_form(&$form, &$form_state) { // Defines the form. if ($form_state['section'] == 'metatags') { $form['#title'] .= t('The meta tags for this display'); @@ -84,7 +84,7 @@ function options_form(&$form, &$form_state) { } if (!empty($options)) { - $output = '

' . t('The following tokens are available. If you would like to have the characters \'[\' and \']\' please use the html entity codes \'%5B\' or \'%5D\' or they will get replaced with empty space.' . '

'); + $output = '

' . t("The following tokens are available. If you would like to have the characters '[' and ']' please use the html entity codes '%5B' or '%5D' or they will get replaced with empty space.") . '

'; foreach (array_keys($options) as $type) { if (!empty($options[$type])) { $items = array(); @@ -124,7 +124,7 @@ function options_form(&$form, &$form_state) { /** * {@inheritdoc} */ - function options_submit(&$form, &$form_state) { + public function options_submit(&$form, &$form_state) { // Save the form values. if ($form_state['section'] == 'metatags') { $metatags = $form_state['values']['metatags']; diff --git a/metatag_views/tests/MetatagViewsI18nTest.test b/metatag_views/tests/MetatagViewsI18nTest.test index 38d384a..ac43c6c 100644 --- a/metatag_views/tests/MetatagViewsI18nTest.test +++ b/metatag_views/tests/MetatagViewsI18nTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'views'; $modules[] = 'metatag_views'; diff --git a/metatag_views/tests/MetatagViewsTest.test b/metatag_views/tests/MetatagViewsTest.test index 6e87325..883a5c7 100644 --- a/metatag_views/tests/MetatagViewsTest.test +++ b/metatag_views/tests/MetatagViewsTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'views'; // Enable the hidden submodule to manage some default configs. diff --git a/tests/MetatagBulkRevertTest.test b/tests/MetatagBulkRevertTest.test index e2fbe35..5c28333 100644 --- a/tests/MetatagBulkRevertTest.test +++ b/tests/MetatagBulkRevertTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * Test the Bulk Revert functionality works. */ - function testBulkRevertPageLoads() { + public function testBulkRevertPageLoads() { $this->adminUser = $this->createAdminUser(); $this->drupalLogin($this->adminUser); diff --git a/tests/MetatagCoreImageTest.test b/tests/MetatagCoreImageTest.test index 4c210a8..1a17223 100644 --- a/tests/MetatagCoreImageTest.test +++ b/tests/MetatagCoreImageTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Needs the OpenGraph submodule because of testNodeFieldValueMultiple(). $modules[] = 'metatag_opengraph'; @@ -39,10 +39,9 @@ function setUp(array $modules = array()) { } /** - * Confirm that an image can be added to a global configuration using the - * image's absolute URL. + * Confirm images can be added to a global config with its absolute URL. */ - function testConfigAbsoluteURL() { + public function testConfigAbsoluteURL() { // Generate a test image. $image_uri = $this->generateImage(); $this->verbose($image_uri); @@ -73,10 +72,9 @@ function testConfigAbsoluteURL() { } /** - * Confirm that an image can be added to a global configuration using the - * image's relative URL. + * Confirm images can be added to a global config using its relative URL. */ - function testConfigDrupalRelativeURL() { + public function testConfigDrupalRelativeURL() { // Generate a test image. $image_uri = $this->generateImage(); $this->verbose($image_uri); @@ -114,10 +112,9 @@ function testConfigDrupalRelativeURL() { } /** - * Confirm that an image can be added to a global configuration using the - * image's relative URL. + * Confirm images can be added to a global config using its relative URL. */ - function testConfigRelativeURL() { + public function testConfigRelativeURL() { // Generate a test image. $image_uri = $this->generateImage(); $this->verbose($image_uri); @@ -155,10 +152,9 @@ function testConfigRelativeURL() { } /** - * Confirm that an image can be added to a global configuration using the - * image's protocol-relative URL. + * Confirm images can be added to a global config w its protocol-relative URL. */ - function testConfigProtocolRelativeURL() { + public function testConfigProtocolRelativeURL() { // Generate a test image. $image_uri = $this->generateImage(); $this->verbose($image_uri); @@ -189,10 +185,9 @@ function testConfigProtocolRelativeURL() { } /** - * Confirm that an image can be added to a global configuration using the - * image's internal URI. + * Confirm images can be added to a global config with its internal URI. */ - function testConfigInternalURL() { + public function testConfigInternalURL() { // Generate a test image. $image_uri = $this->generateImage(); $this->verbose($image_uri); @@ -230,9 +225,9 @@ function testConfigInternalURL() { } /** - * Confirm that an image with a space in its URL will be handled properly. + * Confirm images with a space in its URL will be handled properly. */ - function testConfigImageWithSpaceInURL() { + public function testConfigImageWithSpaceInURL() { // Generate a test image. $image_uri = $this->generateImage(); $this->verbose($image_uri); @@ -283,7 +278,7 @@ function testConfigImageWithSpaceInURL() { /** * Confirm that a default value on an image field will be output correctly. */ - function testNodeFieldDefault() { + public function testNodeFieldDefault() { // Generate a test image file object. $image = $this->generateImageFile(); $image_url = file_create_url($image->uri); @@ -327,7 +322,7 @@ function testNodeFieldDefault() { /** * Confirm that a file on an image field will be output correctly. */ - function testNodeFieldValue() { + public function testNodeFieldValue() { // Update the 'content' config to use the field_image field as the // image_src meta tag. $config = metatag_config_load('node'); @@ -371,10 +366,9 @@ function testNodeFieldValue() { } /** - * Confirm that when using a file field that allows multiple values, only the - * first item will be used when outputting a single meta tag. + * Confirm that only a single meta tag will be output with non-multiple tags. */ - function testNodeFieldValueNotMultiple() { + public function testNodeFieldValueNotMultiple() { // Update the 'content' config to use the field_image field as the // image_src meta tag. $config = metatag_config_load('node'); @@ -429,10 +423,9 @@ function testNodeFieldValueNotMultiple() { } /** - * Confirm that when using a file field that allows multiple values, that - * multiple images can be used and then it will result in multiple meta tags. + * Confirm that multiple tags will be output with tags that allow multiples. */ - function testNodeFieldValueMultiple() { + public function testNodeFieldValueMultiple() { // Update the 'content' config to use the field_image field as the // image_src meta tag. $config = metatag_config_load('node'); diff --git a/tests/MetatagCoreLocaleTest.test b/tests/MetatagCoreLocaleTest.test index 397cf01..2a699b6 100644 --- a/tests/MetatagCoreLocaleTest.test +++ b/tests/MetatagCoreLocaleTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Need Locale for the multiple languages. $modules[] = 'locale'; @@ -35,7 +35,7 @@ function setUp(array $modules = array()) { /** * Test that the node form meta tag fields are translated correctly. */ - function testNodeFormTranslations() { + public function testNodeFormTranslations() { $content_type = 'metatag_test'; $content_type_path = str_replace('_', '-', $content_type); $label = 'Test'; @@ -134,7 +134,7 @@ function testNodeFormTranslations() { /** * Verify language meta tags don't output LANGUAGE_NONE / 'und'. */ - function testLanguageNone() { + public function testLanguageNone() { // Set the global node defaults to set "content-language" to the node's // language. $config = metatag_config_load('node'); diff --git a/tests/MetatagCoreNodeTest.test b/tests/MetatagCoreNodeTest.test index 076b405..69a35ee 100644 --- a/tests/MetatagCoreNodeTest.test +++ b/tests/MetatagCoreNodeTest.test @@ -111,11 +111,15 @@ public function testEntityCreationWorkflow() { ); // Verify that the node saved correctly. + // @code // $xpath = $this->xpath("//h1"); + // @endcode $t_args = array('@type' => 'Test', '%title' => 'Who likes magic'); // This doesn't work for some reason, it seems the HTML is stripped off // during output so the %title's standard Drupal wrappers don't match. + // @code // $this->assertText(t('@type %title has been created.', $t_args)); + // @endcode // .. so this has to be done instead. $this->assertText(strip_tags(t('@type %title has been created.', $t_args))); @@ -160,7 +164,7 @@ public function testEntityCreationWorkflow() { // Verify the node summary is being used correctly. $xpath = $this->xpath("//meta[@name='description']"); $this->assertEqual(count($xpath), 1); - $this->assertEqual($xpath[0]['content'], DrupalDefaultMetaTag::text_summary($body, 380)); + $this->assertEqual($xpath[0]['content'], DrupalDefaultMetaTag::textSummary($body, 380)); // Verify the maxlength functionality is working correctly. $maxlength = 10; @@ -220,11 +224,15 @@ public function testEntityCreationWorkflow() { ); // Verify that the node saved correctly. + // @code // $xpath = $this->xpath("//h1"); + // @endcode $t_args = array('@type' => 'Test', '%title' => $new_title); // This doesn't work for some reason, it seems the HTML is stripped off // during output so the %title's standard Drupal wrappers don't match. + // @code // $this->assertText(t('@type %title has been updated.', $t_args)); + // @endcode // .. so this has to be done instead. $this->assertText(strip_tags(t('@type %title has been updated.', $t_args))); @@ -266,7 +274,12 @@ public function testEntityCreationWorkflow() { // the {metatag} records for *all* of the entity's revisions. $metatags = metatag_metatags_load_multiple('node', array($updated_node->nid)); $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $updated_node->nid . '))'); - $this->assertEqual(array($updated_node->nid => array($node->vid => $expected, $updated_node->vid => $expected_updated)), $metatags); + $this->assertEqual(array( + $updated_node->nid => array( + $node->vid => $expected, + $updated_node->vid => $expected_updated, + ), + ), $metatags); // Confirm the APIs can load the data for this node revision. $metatags = metatag_metatags_load('node', $updated_node->nid, $updated_vid); @@ -275,7 +288,11 @@ public function testEntityCreationWorkflow() { $this->assertNotEqual($expected, $metatags); $metatags = metatag_metatags_load_multiple('node', array($updated_node->nid), array($updated_node->vid)); $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $updated_node->nid . '), array(' . $updated_node->vid . '))'); - $this->assertEqual(array($updated_node->nid => array($updated_node->vid => $expected_updated)), $metatags); + $this->assertEqual(array( + $updated_node->nid => array( + $updated_node->vid => $expected_updated, + ), + ), $metatags); // Load the current revision again. $this->drupalGet('node/' . $node->nid); @@ -379,8 +396,9 @@ public function testNodePreviewOption2() { } /** - * Change the node preview option at the content type level, confirm meta tags - * still save correctly. + * Change the node preview option at the content type level. + * + * Confirm that meta tags still save correctly. * * @param int $option * A suitable value for the 'node_preview' option for a content type, must @@ -391,7 +409,7 @@ public function testNodePreviewOption2() { * - if $option === 1, $preview is considered, a preview may be performed. * - if $option === 2, $preview is ignored, a preview is performed. */ - function checkNodePreviewOption($option, $preview = FALSE) { + protected function checkNodePreviewOption($option, $preview = FALSE) { $content_type = 'article'; $label = 'Test'; diff --git a/tests/MetatagCoreNodeWithI18nTest.test b/tests/MetatagCoreNodeWithI18nTest.test index a840504..eeacc04 100644 --- a/tests/MetatagCoreNodeWithI18nTest.test +++ b/tests/MetatagCoreNodeWithI18nTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Need the i18n and i18n_strings modules. $modules[] = 'i18n'; $modules[] = 'i18n_string'; diff --git a/tests/MetatagCoreStringHandlingTest.test b/tests/MetatagCoreStringHandlingTest.test index a18891f..4c31479 100644 --- a/tests/MetatagCoreStringHandlingTest.test +++ b/tests/MetatagCoreStringHandlingTest.test @@ -10,12 +10,6 @@ */ class MetatagCoreStringHandlingTest extends MetatagTestBase { - /** - * @var $admin_user - * An admin user. - */ - protected $admin_user; - /** * {@inheritdoc} */ @@ -31,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { parent::setUp($modules); $content_type = 'page'; @@ -55,28 +49,28 @@ function setUp(array $modules = array()) { /** * Tests that a meta tag with single quote is not double escaped. */ - function testSingleQuote() { + public function testSingleQuote() { $this->_testAString("bla'bleblu"); } /** * Tests that a meta tag with a double quote is not double escaped. */ - function testDoubleQuote() { + public function testDoubleQuote() { $this->_testAString('bla"bleblu'); } /** * Tests that a meta tag with an ampersand is not double escaped. */ - function testAmpersand() { + public function testAmpersand() { $this->_testAString("blable&blu"); } /** * Tests that specific strings are not double escaped. */ - function _testAString($string) { + public function _testAString($string) { $this->_testConfig($string); $this->_testNode($string); $this->_testEncodedField($string); @@ -85,7 +79,7 @@ function _testAString($string) { /** * Tests that a specific config string is not double encoded. */ - function _testConfig($string) { + protected function _testConfig($string) { // The original strings. $title_original = 'Title: ' . $string; $desc_original = 'Description: ' . $string; @@ -156,7 +150,7 @@ function _testConfig($string) { /** * Tests that a specific node string is not double escaped. */ - function _testNode($string) { + protected function _testNode($string) { // The original strings. $title_original = 'Title: ' . $string; $desc_original = 'Description: ' . $string; @@ -230,7 +224,7 @@ function _testNode($string) { /** * Tests that fields with encoded HTML entities will not be double-encoded. */ - function _testEncodedField($string) { + protected function _testEncodedField($string) { // The original strings. $title_original = 'Title: ' . $string; $desc_original = 'Description: ' . $string; @@ -276,7 +270,7 @@ function _testEncodedField($string) { /** * Test JavaScript handling. */ - function testjavaScript() { + public function testjavaScript() { // Create a node with a script tag that has no line breaks. $node = $this->drupalCreateNode(array( 'title' => $this->randomName() . ' ' . $this->randomName(), @@ -325,7 +319,7 @@ function testjavaScript() { /** * Test CSS handling. */ - function testCss() { + public function testCss() { // Create a node with a style tag that has no line breaks. $node = $this->drupalCreateNode(array( 'title' => $this->randomName() . ' ' . $this->randomName(), diff --git a/tests/MetatagCoreStringHandlingWithI18nTest.test b/tests/MetatagCoreStringHandlingWithI18nTest.test index d534739..8be69bc 100644 --- a/tests/MetatagCoreStringHandlingWithI18nTest.test +++ b/tests/MetatagCoreStringHandlingWithI18nTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { parent::setUp(array('i18n', 'i18n_string')); } diff --git a/tests/MetatagCoreTagRemovalTest.test b/tests/MetatagCoreTagRemovalTest.test index 6d6a8ce..0395d21 100644 --- a/tests/MetatagCoreTagRemovalTest.test +++ b/tests/MetatagCoreTagRemovalTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * Test that the core meta tags work correctly. */ - function testCoreTagRemoval() { + public function testCoreTagRemoval() { // The default generator strings from core and Metatag. $generator_core = 'Drupal 7 (http://drupal.org)'; $generator_metatag = 'Drupal 7 (https://www.drupal.org)'; diff --git a/tests/MetatagCoreTermTest.test b/tests/MetatagCoreTermTest.test index e9ae005..3996432 100644 --- a/tests/MetatagCoreTermTest.test +++ b/tests/MetatagCoreTermTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Need the Path module to set a alias which can then be loaded. $modules[] = 'path'; parent::setUp($modules); @@ -104,7 +104,9 @@ public function testEntityCreationWorkflow() { // Verify the page loaded correctly. // @todo Update this to extract the H1 tag. + // @code // $this->assertText(strip_tags(t('Create @name', array('@name' => $vocabulary->name)))); + // @endcode // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( 'metatags[und][abstract][value]' => '[term:name] ponies', diff --git a/tests/MetatagCoreTermWithI18nTest.test b/tests/MetatagCoreTermWithI18nTest.test index 46ad1ef..f44e2d1 100644 --- a/tests/MetatagCoreTermWithI18nTest.test +++ b/tests/MetatagCoreTermWithI18nTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Need the i18n and i18n_strings modules. $modules[] = 'i18n'; $modules[] = 'i18n_string'; diff --git a/tests/MetatagCoreUnitTest.test b/tests/MetatagCoreUnitTest.test index d90f019..f731156 100644 --- a/tests/MetatagCoreUnitTest.test +++ b/tests/MetatagCoreUnitTest.test @@ -46,12 +46,35 @@ public function testConfigLoadDefaults() { * Test the basic entity handling. */ public function testEntitySupport() { - $test_cases[1] = array('type' => 'node', 'bundle' => 'article', 'expected' => TRUE); - $test_cases[2] = array('type' => 'node', 'bundle' => 'page', 'expected' => TRUE); - $test_cases[3] = array('type' => 'node', 'bundle' => 'invalid-bundle', 'expected' => FALSE); - $test_cases[4] = array('type' => 'user', 'expected' => TRUE); - $test_cases[5] = array('type' => 'taxonomy_term', 'bundle' => 'tags', 'expected' => TRUE); - $test_cases[6] = array('type' => 'taxonomy_term', 'bundle' => 'invalid-bundle', 'expected' => FALSE); + $test_cases[1] = array( + 'type' => 'node', + 'bundle' => 'article', + 'expected' => TRUE, + ); + $test_cases[2] = array( + 'type' => 'node', + 'bundle' => 'page', + 'expected' => TRUE, + ); + $test_cases[3] = array( + 'type' => 'node', + 'bundle' => 'invalid-bundle', + 'expected' => FALSE, + ); + $test_cases[4] = array( + 'type' => 'user', + 'expected' => TRUE, + ); + $test_cases[5] = array( + 'type' => 'taxonomy_term', + 'bundle' => 'tags', + 'expected' => TRUE, + ); + $test_cases[6] = array( + 'type' => 'taxonomy_term', + 'bundle' => 'invalid-bundle', + 'expected' => FALSE, + ); foreach ($test_cases as $test_case) { $test_case += array('bundle' => NULL); $this->assertMetatagEntitySupportsMetatags($test_case['type'], $test_case['bundle'], $test_case['expected']); @@ -77,13 +100,13 @@ public function testEntitySupport() { * The name of the entity type to test. * @param string $bundle * The name of the entity bundle to test. - * @param array $expected + * @param bool $expected * The expected results. * * @return object * An assertion. */ - function assertMetatagEntitySupportsMetatags($entity_type, $bundle, $expected) { + protected function assertMetatagEntitySupportsMetatags($entity_type, $bundle, $expected) { $entity = entity_create_stub_entity($entity_type, array(0, NULL, $bundle)); return $this->assertEqual( metatag_entity_supports_metatags($entity_type, $bundle), diff --git a/tests/MetatagCoreWithI18nConfigTest.test b/tests/MetatagCoreWithI18nConfigTest.test index 7b04cbd..2336b5a 100644 --- a/tests/MetatagCoreWithI18nConfigTest.test +++ b/tests/MetatagCoreWithI18nConfigTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Need the i18n and i18n_strings modules. $modules[] = 'i18n'; $modules[] = 'i18n_string'; diff --git a/tests/MetatagCoreWithI18nDisabledTest.test b/tests/MetatagCoreWithI18nDisabledTest.test index de84363..7e6b5e7 100644 --- a/tests/MetatagCoreWithI18nDisabledTest.test +++ b/tests/MetatagCoreWithI18nDisabledTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Need the i18n and i18n_strings modules. $modules[] = 'i18n'; $modules[] = 'i18n_string'; diff --git a/tests/MetatagCoreWithI18nOutputTest.test b/tests/MetatagCoreWithI18nOutputTest.test index 6a87986..095f53e 100644 --- a/tests/MetatagCoreWithI18nOutputTest.test +++ b/tests/MetatagCoreWithI18nOutputTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Need the i18n and i18n_strings modules. $modules[] = 'i18n'; $modules[] = 'i18n_string'; @@ -152,7 +152,7 @@ public function testI18nOutputTranslationsDisabled() { } /** - * + * Test the menu paths. */ public function testMenuPaths() { $paths = metatag_test_menu(); diff --git a/tests/MetatagCoreWithMeTest.test b/tests/MetatagCoreWithMeTest.test index 98fb3f2..6ff84c7 100644 --- a/tests/MetatagCoreWithMeTest.test +++ b/tests/MetatagCoreWithMeTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'me'; parent::setUp($modules); diff --git a/tests/MetatagCoreWithMediaTest.test b/tests/MetatagCoreWithMediaTest.test index 4641010..6360feb 100644 --- a/tests/MetatagCoreWithMediaTest.test +++ b/tests/MetatagCoreWithMediaTest.test @@ -18,14 +18,16 @@ public static function getInfo() { 'name' => 'Metatag core tests with Media', 'description' => 'Test Metatag integration with the Media module.', 'group' => 'Metatag', - 'dependencies' => array('ctools', 'devel', 'token', 'file_entity', 'media'), + 'dependencies' => array( + 'ctools', 'devel', 'token', 'file_entity', 'media', + ), ); } /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'file_entity'; $modules[] = 'media'; // The filter is in the WYSIWYG submodule. @@ -46,17 +48,17 @@ public function testMediaFilter() { LANGUAGE_NONE => array( array( 'value' => $desc . '[[' - . json_encode(array( - 'fid' => 1, - 'view_mode' => 'default', - 'type' => 'media', - 'attributes' => array( - 'height' => '100', - 'width' => '100', - 'class' => 'media-element file-default', - ), - )) - . ']]', + . json_encode(array( + 'fid' => 1, + 'view_mode' => 'default', + 'type' => 'media', + 'attributes' => array( + 'height' => '100', + 'width' => '100', + 'class' => 'media-element file-default', + ), + )) + . ']]', 'format' => filter_default_format(), ), ), @@ -83,10 +85,24 @@ public function testMediaFilterLongToken() { LANGUAGE_NONE => array( array( 'value' => $desc . '[[' - . json_encode(array( - 'fid' => 1, - 'view_mode' => 'default', - 'fields' => array( + . json_encode(array( + 'fid' => 1, + 'view_mode' => 'default', + 'fields' => array( + 'alt' => 'alt text field value', + 'style' => 'height: auto;', + 'class' => 'media-element file-default cke_widget_element', + 'data-delta' => 25, + 'format' => 'default', + 'alignment' => 'center', + 'field_image_width[und][0][value]' => '', + 'field_file_image_alt_text[und][0][value]' => 'alt text field value', + 'field_caption[und][0][value]' => '', + 'field_file_image_title_text[und][0][value]' => FALSE, + ), + 'type' => 'media', + 'field_deltas' => array( + 25 => array( 'alt' => 'alt text field value', 'style' => 'height: auto;', 'class' => 'media-element file-default cke_widget_element', @@ -98,29 +114,15 @@ public function testMediaFilterLongToken() { 'field_caption[und][0][value]' => '', 'field_file_image_title_text[und][0][value]' => FALSE, ), - 'type' => 'media', - 'field_deltas' => array( - 25 => array( - 'alt' => 'alt text field value', - 'style' => 'height: auto;', - 'class' => 'media-element file-default cke_widget_element', - 'data-delta' => 25, - 'format' => 'default', - 'alignment' => 'center', - 'field_image_width[und][0][value]' => '', - 'field_file_image_alt_text[und][0][value]' => 'alt text field value', - 'field_caption[und][0][value]' => '', - 'field_file_image_title_text[und][0][value]' => FALSE, - ), - ), - 'attributes' => array( - 'alt' => 'alt text field value', - 'style' => 'height:auto', - 'class' => 'file-default media-element media-wysiwyg-align-center', - 'data-delta' => '25', - ), - )) - .']]', + ), + 'attributes' => array( + 'alt' => 'alt text field value', + 'style' => 'height:auto', + 'class' => 'file-default media-element media-wysiwyg-align-center', + 'data-delta' => '25', + ), + )) + . ']]', 'format' => filter_default_format(), ), ), @@ -147,17 +149,17 @@ public function testMediaFilterTokenAtBeginning() { LANGUAGE_NONE => array( array( 'value' => '[[' - . json_encode(array( - 'fid' => '1', - 'view_mode' => 'default', - 'type' => 'media', - 'attributes' => array( - 'height' => '100', - 'width' => '100', - 'class' => 'media-element file-default', - ), - )) - . ']]' . $desc, + . json_encode(array( + 'fid' => '1', + 'view_mode' => 'default', + 'type' => 'media', + 'attributes' => array( + 'height' => '100', + 'width' => '100', + 'class' => 'media-element file-default', + ), + )) + . ']]' . $desc, 'format' => filter_default_format(), ), ), @@ -184,10 +186,24 @@ public function testMediaFilterTokenAtBeginningLongToken() { LANGUAGE_NONE => array( array( 'value' => '[[' - . json_encode(array( - 'fid' => '1', - 'view_mode' => 'default', - 'fields' => array( + . json_encode(array( + 'fid' => '1', + 'view_mode' => 'default', + 'fields' => array( + 'alt' => 'alt text field value', + 'style' => 'height: auto;', + 'class' => 'media-element file-default cke_widget_element', + 'data-delta' => 25, + 'format' => 'default', + 'alignment' => 'center', + 'field_image_width[und][0][value]' => '', + 'field_file_image_alt_text[und][0][value]' => 'alt text field value', + 'field_caption[und][0][value]' => '', + 'field_file_image_title_text[und][0][value]' => FALSE, + ), + 'type' => 'media', + 'field_deltas' => array( + 25 => array( 'alt' => 'alt text field value', 'style' => 'height: auto;', 'class' => 'media-element file-default cke_widget_element', @@ -199,29 +215,15 @@ public function testMediaFilterTokenAtBeginningLongToken() { 'field_caption[und][0][value]' => '', 'field_file_image_title_text[und][0][value]' => FALSE, ), - 'type' => 'media', - 'field_deltas' => array( - 25 => array( - 'alt' => 'alt text field value', - 'style' => 'height: auto;', - 'class' => 'media-element file-default cke_widget_element', - 'data-delta' => 25, - 'format' => 'default', - 'alignment' => 'center', - 'field_image_width[und][0][value]' => '', - 'field_file_image_alt_text[und][0][value]' => 'alt text field value', - 'field_caption[und][0][value]' => '', - 'field_file_image_title_text[und][0][value]' => FALSE, - ), - ), - 'attributes' => array( - 'alt' => 'alt text field value', - 'style' => 'height:auto', - 'class' => 'file-default media-element media-wysiwyg-align-center', - 'data-delta' => 25, - ), - )) - . ']]' . $desc, + ), + 'attributes' => array( + 'alt' => 'alt text field value', + 'style' => 'height:auto', + 'class' => 'file-default media-element media-wysiwyg-align-center', + 'data-delta' => 25, + ), + )) + . ']]' . $desc, 'format' => filter_default_format(), ), ), diff --git a/tests/MetatagCoreWithPanelsTest.test b/tests/MetatagCoreWithPanelsTest.test index c33ff4b..ee9bfd3 100644 --- a/tests/MetatagCoreWithPanelsTest.test +++ b/tests/MetatagCoreWithPanelsTest.test @@ -18,14 +18,16 @@ public static function getInfo() { 'name' => 'Metatag core tests with Panels', 'description' => 'Test Metatag integration with the Panels module.', 'group' => 'Metatag', - 'dependencies' => array('ctools', 'devel', 'token', 'panels', 'page_manager'), + 'dependencies' => array( + 'ctools', 'devel', 'token', 'panels', 'page_manager', + ), ); } /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // We'll be using Panels but most of the work is actually in Page Manager. $modules[] = 'page_manager'; $modules[] = 'panels'; @@ -61,7 +63,6 @@ public function testPanelsNodeView() { $this->drupalLogin($this->adminUser); // Create a test node. - // Load the node form. $this->drupalGet('node/add/' . $content_type_path); $this->assertResponse(200); @@ -78,7 +79,9 @@ public function testPanelsNodeView() { $this->assertResponse(200); // Verify that the node saved correctly. + // @code // $xpath = $this->xpath("//h1"); + // @endcode $t_args = array('@type' => 'Test', '%title' => 'Who likes magic'); // This doesn't work for some reason, it seems the HTML is stripped off // during output so the %title's standard Drupal wrappers don't match. @@ -133,7 +136,7 @@ public function testPanelsNodeView() { // Confirm the process completed successfully. $this->assertEqual($this->getUrl(), url('admin/structure/pages/edit/node_view', array('absolute' => TRUE))); - $this->assertText(t('Panel') . ': Test'); + $this->assertText'Panel: Test'); // Clear all caches, so we can start off properly. drupal_flush_all_caches(); @@ -148,7 +151,7 @@ public function testPanelsNodeView() { * @param string $path * Optional path to load, if not present the current path will be used. */ - function confirmNodeTags($path = NULL) { + public function confirmNodeTags($path = NULL) { if (!empty($path)) { $this->drupalGet($path); $this->assertResponse(200); @@ -165,19 +168,23 @@ function confirmNodeTags($path = NULL) { * * @todo Write this. */ + // @code // public function testPanelsTermView() { // // Enable the Page Manager display for terms. // variable_set('page_manager_term_view_disabled', FALSE); // } + // @endcode /** * Test out a user_view Panels display with Metatag. * * @todo Write this. */ + // @code // public function testPanelsUserView() { // // Enable the Page Manager display for users. // variable_set('page_manager_user_view_disabled', FALSE); // } + // @endcode } diff --git a/tests/MetatagCoreWithProfile2Test.test b/tests/MetatagCoreWithProfile2Test.test index 031da77..7f2a1a2 100644 --- a/tests/MetatagCoreWithProfile2Test.test +++ b/tests/MetatagCoreWithProfile2Test.test @@ -28,7 +28,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'profile2'; parent::setUp($modules); diff --git a/tests/MetatagCoreWithSearchApiTest.test b/tests/MetatagCoreWithSearchApiTest.test index 94b575c..1ceacc5 100644 --- a/tests/MetatagCoreWithSearchApiTest.test +++ b/tests/MetatagCoreWithSearchApiTest.test @@ -39,14 +39,16 @@ public static function getInfo() { 'name' => 'Metatag Search API tests', 'description' => 'Tests the Metatag Search API integration.', 'group' => 'Metatag', - 'dependencies' => array('ctools', 'devel', 'token', 'entity', 'search_api'), + 'dependencies' => array( + 'ctools', 'devel', 'token', 'entity', 'search_api', + ), ); } /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Needed for Search API. $modules[] = 'entity'; // The module. diff --git a/tests/MetatagCoreWithViewsTest.test b/tests/MetatagCoreWithViewsTest.test index f7346ef..76b3763 100644 --- a/tests/MetatagCoreWithViewsTest.test +++ b/tests/MetatagCoreWithViewsTest.test @@ -25,7 +25,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'views'; $modules[] = 'views_ui'; @@ -102,7 +102,9 @@ public function testTermViews() { // Verify the page loaded correctly. // @todo Update this to extract the H1 tag. + // @code // $this->assertText(strip_tags(t('Create @name', array('@name' => $vocabulary->name)))); + // @endcode // Verify that it's possible to submit values to the form. $this->drupalPost(NULL, array( 'metatags[und][abstract][value]' => '[term:name] ponies', diff --git a/tests/MetatagCoreWithWorkbenchModerationTest.test b/tests/MetatagCoreWithWorkbenchModerationTest.test index 118855e..782dae3 100644 --- a/tests/MetatagCoreWithWorkbenchModerationTest.test +++ b/tests/MetatagCoreWithWorkbenchModerationTest.test @@ -18,14 +18,16 @@ public static function getInfo() { 'name' => 'Metatag core tests with Workbench Moderation v3', 'description' => 'Test Metatag integration with the Workbench Moderation module (v3).', 'group' => 'Metatag', - 'dependencies' => array('ctools', 'devel', 'token', 'workbench_moderation'), + 'dependencies' => array( + 'ctools', 'devel', 'token', 'workbench_moderation', + ), ); } /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { $modules[] = 'workbench_moderation'; parent::setUp($modules); diff --git a/tests/MetatagCoreXSSTest.test b/tests/MetatagCoreXSSTest.test index 95b95b1..73d9751 100644 --- a/tests/MetatagCoreXSSTest.test +++ b/tests/MetatagCoreXSSTest.test @@ -63,7 +63,7 @@ public static function getInfo() { /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { parent::setUp($modules); $content_type = 'page'; @@ -82,7 +82,9 @@ function setUp(array $modules = array()) { $this->drupalLogin($this->adminUser); // Generate the encoded version of $xssImageString. + // @code // '' + // @endcode $prefix = ' + // @endcode $method = "{$tag_name}_test_output_xpath"; if (method_exists($this, $method)) { $xpath_string = $this->$method(); diff --git a/tests/MetatagTestBase.test b/tests/MetatagTestBase.test index 5c3b89d..f91bfed 100644 --- a/tests/MetatagTestBase.test +++ b/tests/MetatagTestBase.test @@ -10,17 +10,10 @@ */ abstract class MetatagTestBase extends DrupalWebTestCase { - /** - * Admin user. - * - * @var \StdClass - */ - protected $adminUser; - /** * {@inheritdoc} */ - function setUp(array $modules = array()) { + public function setUp(array $modules = array()) { // Make sure these modules are enabled so that we can use their entity // types later. $modules[] = 'node'; @@ -76,8 +69,16 @@ public function clearAllCaches() { /** * Create a content type for the tests. + * + * @param string $machine_name + * The machine name of a content type to create. + * @param string $label + * The human-readable name of the content type + * + * @return array + * The content type definition. */ - function createContentType($machine_name, $label) { + public function createContentType($machine_name, $label) { // Create a content type. $content_type = $this->drupalCreateContentType(array( 'type' => $machine_name, @@ -99,7 +100,7 @@ function createContentType($machine_name, $label) { * @return object * A user object. */ - function createAdminUser($extra_permissions = array()) { + public function createAdminUser(array $extra_permissions = array()) { $permissions = array( // Basic permissions for the module. 'administer meta tags', @@ -126,7 +127,7 @@ function createAdminUser($extra_permissions = array()) { * @return object * A user object. */ - function createUser($extra_permissions) { + public function createUser(array $extra_permissions) { // Basic permissions for the module. $permissions = array( 'edit meta tags', @@ -143,16 +144,16 @@ function createUser($extra_permissions) { /** * Returns a new vocabulary with random properties. * - * @param $vocab_name + * @param string $vocab_name * If empty a random string will be used. - * @param $content_type + * @param string $content_type * Any content types listed will have a Taxonomy Term reference field added * that points to the new vocabulary. * * @return object * A vocabulary object. */ - function createVocabulary($vocab_name = NULL, $content_type = NULL) { + public function createVocabulary($vocab_name = NULL, $content_type = NULL) { if (empty($vocab_name)) { $vocab_name = $this->randomName(); } @@ -187,7 +188,7 @@ function createVocabulary($vocab_name = NULL, $content_type = NULL) { * @return object * A taxonomy term object. */ - function createTerm($vocabulary, $term_name = NULL) { + public function createTerm($vocabulary, $term_name = NULL) { if (empty($term_name)) { $term_name = $this->randomName(); } @@ -212,33 +213,44 @@ function createTerm($vocabulary, $term_name = NULL) { * This should cover all of the default meta tags provided for a test:foo * entity. * + * @return array + * List of meta tag default values to test. + * * @todo Expand to cover more meta tags. * * @see metatag_test_metatag_config_default() */ - function getTestDefaults() { + public function getTestDefaults() { return array( // Basic meta tags. 'title' => array('value' => 'Test altered title'), 'description' => array('value' => 'Test foo description'), 'abstract' => array('value' => 'Test foo abstract'), + // @code // 'keywords' => array('value' => ''), + // @endcode // Advanced meta tags. + // @code // 'robots' => array('value' => ''), // 'news_keywords' => array('value' => ''), // 'standout' => array('value' => ''), // 'robots' => array('value' => ''), // 'standout' => array('value' => ''), + // @endcode 'generator' => array('value' => 'Drupal 7 (https://www.drupal.org)'), + // @code // 'standout' => array('value' => ''), // 'image_src' => array('value' => ''), + // @endcode 'canonical' => array('value' => '[current-page:url:absolute]'), 'shortlink' => array('value' => '[current-page:url:unaliased]'), + // @code // 'publisher' => array('value' => ''), // 'author' => array('value' => ''), // 'original-source' => array('value' => ''), // 'revisit-after' => array('value' => ''), // 'content-language' => array('value' => ''),' + // @endcode ); } @@ -246,6 +258,9 @@ function getTestDefaults() { * Add a locale to the site. * * This assumes the Locale module is enabled. + * + * @param string $langcode + * The language code to add. */ public function addSiteLanguage($langcode) { // Load the language-add page. @@ -336,10 +351,10 @@ public function setupLocales(array $locales = array()) { * @param string $textgroup * This string's textgroup; defaults to 'metatag'. * - * @return integer + * @return int * The {locales_source}.lid value for this string. */ - function getTranslationLidByContext($context, $textgroup = 'metatag') { + public function getTranslationLidByContext($context, $textgroup = 'metatag') { // Extra debug output. $this->debugLocalesSourcesByContext($context); @@ -363,10 +378,10 @@ function getTranslationLidByContext($context, $textgroup = 'metatag') { * @param string $textgroup * This string's textgroup; defaults to 'metatag'. * - * @return integer + * @return int * The {locales_source}.lid value for this string. */ - function getTranslationLidBySource($string, $textgroup = 'metatag') { + public function getTranslationLidBySource($string, $textgroup = 'metatag') { // Extra debug output. $this->debugLocalesSourcesByContext('', $textgroup); @@ -390,10 +405,10 @@ function getTranslationLidBySource($string, $textgroup = 'metatag') { * @param string $textgroup * This string's textgroup; defaults to 'metatag'. * - * @return integer + * @return int * The {locales_source}.lid value for this string. */ - function getTranslationsByContext($context, $textgroup = 'metatag') { + public function getTranslationsByContext($context, $textgroup = 'metatag') { return db_query("SELECT lid FROM {locales_source} WHERE textgroup = :textgroup @@ -413,7 +428,7 @@ function getTranslationsByContext($context, $textgroup = 'metatag') { * @param string $textgroup * This string's textgroup; defaults to 'metatag'. */ - function debugLocalesSourcesByContext($context, $textgroup = 'metatag') { + public function debugLocalesSourcesByContext($context, $textgroup = 'metatag') { // Get a dump of all i18n strings for Metatag. $records = db_query("SELECT lid, location, textgroup, source, context, version FROM {locales_source} @@ -454,7 +469,7 @@ function debugLocalesSourcesByContext($context, $textgroup = 'metatag') { * @param string $string_target * The destination string. */ - function saveTranslationString($lid, $context, $langcode, $string_source, $string_target) { + public function saveTranslationString($lid, $context, $langcode, $string_source, $string_target) { // Load the translation page for the front page's title tag. $this->drupalGet('admin/config/regional/translate/edit/' . $lid); $this->assertResponse(200, 'Loaded the front page title tag string translation page.'); @@ -512,7 +527,7 @@ function saveTranslationString($lid, $context, $langcode, $string_source, $strin * @param string $context * The translation context to search against. */ - function debugLocalesTargetsByContext($context) { + public function debugLocalesTargetsByContext($context) { // , lt.i18n_status $records = db_query("SELECT lt.lid, lt.translation, lt.language, lt.plid, lt.plural FROM {locales_target} lt @@ -551,7 +566,7 @@ function debugLocalesTargetsByContext($context) { * @return object * A mapping object. */ - function createTestObject($identifier, $path) { + public function createTestObject($identifier, $path) { $test_object = new stdClass(); $test_object->name = $identifier; $test_object->path = $path; @@ -566,10 +581,10 @@ function createTestObject($identifier, $path) { /** * Generates meta tags by path from a test_object. * - * @return $test_object + * @param object $test_object * Metatag mapping object. */ - function generateByPathConfig($test_object) { + public function generateByPathConfig($test_object) { // Verify the "add context" page works. $this->drupalGet('admin/config/search/metatags/context'); $this->assertResponse(200); @@ -592,10 +607,10 @@ function generateByPathConfig($test_object) { /** * Edits meta tags by path from a test_object. * - * @return $test_object + * @param object $test_object * Metatag mapping object. */ - function editByPathConfig($test_object) { + public function editByPathConfig($test_object) { $edit = array( 'paths' => $test_object->path, 'metatags[und][title][value]' => $test_object->title, @@ -610,10 +625,10 @@ function editByPathConfig($test_object) { /** * Checks if meta tags have been added correctly from a test_object. * - * @return $test_object + * @param object $test_object * Metatag mapping object. */ - function checkByPathConfig($test_object) { + public function checkByPathConfig($test_object) { $this->drupalGet($test_object->path); $this->assertResponse(200); @@ -634,7 +649,6 @@ function checkByPathConfig($test_object) { } } - /** * Check the translation page for a specific string. * @@ -646,7 +660,7 @@ function checkByPathConfig($test_object) { * By default strings are expeted to be found. If the string is not expected * to be translatable yet then pass in FALSE. */ - function searchTranslationPage($string, $context, $assert_true = TRUE) { + public function searchTranslationPage($string, $context, $assert_true = TRUE) { // Load the translation page. $search = array( 'string' => $string, @@ -692,7 +706,7 @@ function searchTranslationPage($string, $context, $assert_true = TRUE) { * @return string * The URL to a public file. */ - function generateImage($image_size = '200x200', $format = 'png') { + public function generateImage($image_size = '200x200', $format = 'png') { // Only proceed if the Devel Generate module is installed. if (module_exists('devel_generate')) { // Load the Devel Generate image generator logic. @@ -720,7 +734,7 @@ function generateImage($image_size = '200x200', $format = 'png') { * @return object * The file object for the generated image. */ - function generateImageFile($image_size = '200x200', $format = 'png') { + public function generateImageFile($image_size = '200x200', $format = 'png') { // Generate a test image. $image_uri = $this->generateImage(); @@ -744,7 +758,7 @@ function generateImageFile($image_size = '200x200', $format = 'png') { * @param object $user * A user object that is to be tested. */ - function assertUserEntityTags($user) { + protected function assertUserEntityTags($user) { // Load the user's profile page. $this->drupalGet('user/' . $user->uid); $this->assertResponse(200); @@ -765,7 +779,7 @@ function assertUserEntityTags($user) { * A string that contains lowercase letters and numbers, with a letter as * the first character. */ - function randomMachineName($length = 8) { + public function randomMachineName($length = 8) { return strtolower($this->randomName($length)); } diff --git a/views/metatag_handler_field_entity.inc b/views/metatag_handler_field_entity.inc index a542bad..b24829c 100644 --- a/views/metatag_handler_field_entity.inc +++ b/views/metatag_handler_field_entity.inc @@ -24,7 +24,6 @@ function _metatag_entity_type_from_table($table) { return isset($base_tables[$table]) ? $base_tables[$table] : NULL; } - /** * Class metatag_handler_entity. * @@ -33,8 +32,15 @@ function _metatag_entity_type_from_table($table) { */ class metatag_handler_field_entity extends views_handler_field { - var $entity_type_alias; - var $entity_id_alias; + /** + * @var string + */ + public $entity_type_alias; + + /** + * @var string + */ + public $entity_id_alias; /** * Set the base_table and base_table_alias. @@ -44,11 +50,12 @@ class metatag_handler_field_entity extends views_handler_field { * @return string * The base table which is used in the current view "context". */ - function get_base_table() { + public function get_base_table() { $base_table = $this->view->base_table; // If the current field is under a relationship you can't be sure that the // base table of the view is the base table of the current field. - // For example a field from a node author on a node view does have users as base table. + // For example a field from a node author on a node view does have users as + // base table. if (!empty($this->options['relationship']) && $this->options['relationship'] != 'none') { $relationships = $this->view->display_handler->get_option('relationships'); if (!empty($relationships[$this->options['relationship']])) { @@ -66,7 +73,7 @@ function get_base_table() { * By default, the only columns added to the query are entity_id and * entity_type. This is because other needed data is fetched by entity_load(). */ - function query() { + public function query() { parent::query(); $base_table = $this->get_base_table(); @@ -84,11 +91,17 @@ function query() { $this->entity_type_alias = $this->query->add_field(NULL, "'$entity_type'", $entity_type_alias); } - function get_entity_type($values) { + /** + * {@inheritdoc} + */ + public function get_entity_type($values) { return isset($values->{$this->entity_type_alias}) ? $values->{$this->entity_type_alias} : NULL; } - function get_entity($values) { + /** + * {@inheritdoc} + */ + public function get_entity($values) { $entity_type = $this->get_entity_type($values); $entity_id = isset($values->{$this->entity_id_alias}) ? $values->{$this->entity_id_alias} : NULL; if (!is_null($entity_id)) { diff --git a/views/metatag_handler_field_serialized.inc b/views/metatag_handler_field_serialized.inc index b539d13..6b1d439 100644 --- a/views/metatag_handler_field_serialized.inc +++ b/views/metatag_handler_field_serialized.inc @@ -1,12 +1,31 @@ array( @@ -17,7 +36,10 @@ function option_definition() { return $options; } - function options_form(&$form, &$form_state) { + /** + * {@inheritdoc} + */ + public function options_form(&$form, &$form_state) { parent::options_form($form, $form_state); $form['metatag'] = array( '#type' => 'fieldset', @@ -28,18 +50,21 @@ function options_form(&$form, &$form_state) { '#type' => 'checkbox', '#title' => 'Use default metatag value', '#description' => 'Display default value if no value has been defined on entity.', - '#default_value' => $this->options['metatag']['use_default'] + '#default_value' => $this->options['metatag']['use_default'], ); $form['metatag']['replace_tokens'] = array( '#type' => 'checkbox', '#title' => 'Replace tokens', '#description' => 'Attempt to replace all tokens with their (entity) values. Note: Tokens in metatags will be replaced before Views tokens.', - '#default_value' => $this->options['metatag']['replace_tokens'] + '#default_value' => $this->options['metatag']['replace_tokens'], ); } - function get_value($values, $field = NULL) { + /** + * {@inheritdoc} + */ + public function get_value($values, $field = NULL) { $value = parent::get_value($values); if (!is_null($value)) { $value = @unserialize($value); @@ -54,7 +79,10 @@ function get_value($values, $field = NULL) { return $value; } - function get_default_value($values) { + /** + * {@inheritdoc} + */ + public function get_default_value($values) { $entity_type = $this->get_entity_type($values); $instance = $entity_type; $entity = $this->get_entity($values); @@ -66,7 +94,10 @@ function get_default_value($values) { return $this->get_nested_value($defaults, $this->definition['path']); } - function replace_tokens($value, $values) { + /** + * {@inheritdoc} + */ + public function replace_tokens($value, $values) { $entity_type = $this->get_entity_type($values); $entity = $this->get_entity($values); // Reload the entity object from cache as it may have been altered. @@ -80,8 +111,16 @@ function replace_tokens($value, $values) { /** * Retrieves a nested value from an array. + * + * @param array $value + * An array of meta tag values. + * @param string $path + * The path to search for. + * + * @return string|null + * The matching string, otherwise NULL. */ - function get_nested_value($value, $path) { + public function get_nested_value(array $value, $path) { foreach ($path as $index) { if (!isset($value[$index])) { return NULL; @@ -91,7 +130,10 @@ function get_nested_value($value, $path) { return $value; } - function render($values) { + /** + * {@inheritdoc} + */ + public function render($values) { $value = (string) $this->get_value($values); if (strlen($value) && !empty($this->options['metatag']['replace_tokens'])) { $value = $this->replace_tokens($value, $values); diff --git a/views/metatag_handler_field_serialized_list.inc b/views/metatag_handler_field_serialized_list.inc index 29f373d..d558493 100644 --- a/views/metatag_handler_field_serialized_list.inc +++ b/views/metatag_handler_field_serialized_list.inc @@ -1,19 +1,36 @@ get_value($values); return $this->sanitize_value(implode(',', $value)); }