updated elysia_cron, elfinder, metatag, libraries, email_registration, migrate, nodeform_cols
This commit is contained in:
@@ -1,3 +1,80 @@
|
||||
Metatag 7.x-1.25, 2018-04-03
|
||||
----------------------------
|
||||
#2958362 by DamienMcKenna, didierlebouc: Undefined index error in 7.x-1.24.
|
||||
#2958208 by DamienMcKenna: Bug in count() statement in metatag.metatag.inc.
|
||||
|
||||
|
||||
Metatag 7.x-1.24, 2018-04-03
|
||||
----------------------------
|
||||
#2958279 by joelpittet: Fatal error: Call to undefined function int_val().
|
||||
|
||||
|
||||
Metatag 7.x-1.23, 2018-04-03
|
||||
----------------------------
|
||||
#2906312 by DamienMcKenna: Added the twitter:dnt meta tag.
|
||||
#2903980 by DamienMcKenna, Chris Charlton: Undefined index in
|
||||
metatag_token_info.
|
||||
#2143979 by bpleduc, drunken monkey, DamienMcKenna, thirdender, davidthou:
|
||||
Allow Views meta tags to "Use replacement tokens from the first row".
|
||||
#2882769 by DamienMcKenna: List Schema Metatag as a related module.
|
||||
#2882769 by DamienMcKenna: Added a hook_requirements() message about the
|
||||
Schema.org Metatag module.
|
||||
#2929487 by volkswagenchick, porkloin: Typo in metatag_dc.install, aka "Dublin"
|
||||
misspelled by the guy from Ireland.
|
||||
#2931744 by DamienMcKenna: Fix tests for the 7.x-1.x branch,
|
||||
testXssMetatagConfig has a regression.
|
||||
#2932110 by thejimbirch: Update Description's meta description to 320 chars
|
||||
(for 2018).
|
||||
#2933940 by DamienMcKenna: og:image must be at least 200x200 otherwise it is
|
||||
ignored by Facebook.
|
||||
#2946145 by DamienMcKenna, bkosborne: Remove usage of deprecrated each()
|
||||
function for PHP 7.2+ future proofing.
|
||||
#2872206 by jenlampton: Drush command for importing from Page Title throws
|
||||
fatal.
|
||||
#2872446 by jenlampton, DamienMcKenna: Complete the drush command for importing
|
||||
nodewords meta tags.
|
||||
#1282806 by DamienMcKenna, iamEAP, osopolar, victoriachan, malcomio, HyperGlide,
|
||||
Murz, dandaman, klokie: Upgrade script for Meta Tags Quick.
|
||||
By DamienMcKenna: Updated README.txt related to the importer module.
|
||||
#2950652 by Les Lim: metatag_favicons_get_mime_type() is mostly wrong.
|
||||
#2933194 by ocastle: Issue with URL Decoding panel substitutions.
|
||||
#2932401 by DamienMcKenna: New tag: Set-Cookie.
|
||||
#2945589 by ron_s: Apostrophe encoded in page title when using Panels
|
||||
substitutions.
|
||||
#2956465 by DamienMcKenna, alexpott: Make sure $_GET['page'] is an integer.
|
||||
#2832101 by DamienMcKenna, jenstechs: hreflang tokens should support Content
|
||||
Translation.
|
||||
#2309017 by DamienMcKenna, rodrigoaguilera, nmillin, John_B, David Hernández,
|
||||
ctarres, cmseasy, computerbarry, skein, erwangel, espurnes, zmove:
|
||||
Automatically trim meta tag lengths.
|
||||
#2958206 by DamienMcKenna: Fix hreflang tags for entity_translation.
|
||||
#2864078 by DamienMcKenna: Improve coding standards on Metatags 7.x-1.x.
|
||||
#2924181 by Mike Lewis: Default value for Robots on config form does not
|
||||
reflect stored configuration.
|
||||
#2853251 by kpaxman: Code to use only first item doesn't work if first item is
|
||||
blank.
|
||||
#1624266 by L-four, angrytoast: Add support Views Bulk Operations for mass
|
||||
updating metatags.
|
||||
#2854539 by DamienMcKenna, jalpesh, zhouhana: http://drupal.org instead of
|
||||
https://www.drupal.org in default generator tag.
|
||||
|
||||
|
||||
Metatag 7.x-1.22, 2017-07-03
|
||||
----------------------------
|
||||
#2853699 by DamienMcKenna: Drupal core 7.40 is the minimum version supported.
|
||||
#2857982 by arosboro: Fixed tests due to changes in Entity Translation.
|
||||
#2864524 by JamesK: Improve field description for the abstract meta tag.
|
||||
#2868750 by DamienMcKenna: List Metatag Cxense as a related module.
|
||||
#2882048 by jyraya: i18n integration shouldn't assume a tag has a group.
|
||||
#2882703 by smustgrave: module_load_include() doesn't work quite as intended if
|
||||
the module is not installed.
|
||||
#2864834 by DamienMcKenna: Added a note to update script 7114 to note that
|
||||
output caching has been disabled.
|
||||
#2297647 by greggles, DamienMcKenna: Run views_invalidate_cache() when
|
||||
metatag_views is disabled.
|
||||
#2857088 by arosboro: Fixed parsing of percentages in URLs in Metatag:Panels.
|
||||
|
||||
|
||||
Metatag 7.x-1.21, 2017-02-15
|
||||
----------------------------
|
||||
#2844504 by DamienMcKenna: Add project names to all dependencies.
|
||||
|
@@ -11,7 +11,7 @@ that is used within social networks when visitors link to your site,
|
||||
particularly the Open Graph submodule for use with Facebook, Pinterest,
|
||||
LinkedIn, etc (see below).
|
||||
|
||||
This version of the module only works with Drupal 7.28 and newer.
|
||||
This version of the module only works with Drupal 7.40 and newer.
|
||||
|
||||
For additional information, see the online documentation:
|
||||
https://www.drupal.org/docs/7/modules/metatag
|
||||
@@ -37,6 +37,10 @@ The primary features include:
|
||||
|
||||
* Automatically extracts URLs from image fields, no need for extra modules.
|
||||
|
||||
* String-based meta tags may be automatically trimmed to a certain length, and
|
||||
the lengths may be easily customized to accommodate changes in search engine
|
||||
algorithms.
|
||||
|
||||
* A custom pager string may be added to meta tags by inserting the token
|
||||
[current-page:pager] into e.g. page titles, description tags, etc. The
|
||||
replacement string may be customized from the settings page.
|
||||
@@ -127,8 +131,9 @@ The primary features include:
|
||||
|
||||
* Several advanced options may be controlled via the Settings page.
|
||||
|
||||
* An import script is provided in the Metatag:Importer submodule for D6 sites
|
||||
that used Nodewords and need to migrate the data.
|
||||
* An import script is provided in the Metatag:Importer submodule for sites that
|
||||
need to import data from Metatags Quick, Nodewords (Drupal 6 only), or Page
|
||||
Title.
|
||||
|
||||
* If the Media module (v2) is installed, the Media WYSIWYG submodule will be
|
||||
used to automatically filter out Media's embed codes.
|
||||
@@ -332,6 +337,10 @@ Related modules
|
||||
Some modules are available that extend Metatag with additional or complimentary
|
||||
functionality:
|
||||
|
||||
* Schema.org Metatag
|
||||
https://www.drupal.org/project/schema_metatag
|
||||
Extensive solution for adding schema.org / JSON-LD support to Metatag.
|
||||
|
||||
* Transliteration
|
||||
https://drupal.org/project/transliteration
|
||||
Tidies up filenames for uploaded files, e.g. it can remove commas from
|
||||
@@ -382,6 +391,10 @@ functionality:
|
||||
https://www.drupal.org/project/parsely
|
||||
Automatically generates meta tags for the Parse.ly service.
|
||||
|
||||
* Metatag Cxense
|
||||
https://www.drupal.org/project/metatag_cxense
|
||||
Adds support for the Cxense meta tags used by their DMP and Insight services.
|
||||
|
||||
|
||||
Credits / contact
|
||||
--------------------------------------------------------------------------------
|
||||
|
@@ -85,7 +85,7 @@ function metatag_config_overview() {
|
||||
$row['class'][] = 'warning';
|
||||
}
|
||||
|
||||
// Close the details div
|
||||
// Close the details div.
|
||||
$details .= '</div>';
|
||||
|
||||
// Add indentation to the leading cell based on how many parents the config has.
|
||||
@@ -383,10 +383,11 @@ function metatag_config_export_form($config) {
|
||||
* Form constructor to revert nodes to their default metatags.
|
||||
*
|
||||
* @see metatag_bulk_revert_form_submit()
|
||||
*
|
||||
* @ingroup forms
|
||||
*/
|
||||
function metatag_bulk_revert_form() {
|
||||
// Get the list of entity:bundle options
|
||||
// Get the list of entity:bundle options.
|
||||
$options = array();
|
||||
foreach (entity_get_info() as $entity_type => $entity_info) {
|
||||
foreach (array_keys($entity_info['bundles']) as $bundle) {
|
||||
@@ -550,7 +551,7 @@ function metatag_bulk_revert_batch_operation($entity_type, $bundle, $tags, $lang
|
||||
$entities = entity_load($entity_type, array($entity_id));
|
||||
if (!empty($entities[$entity_id])) {
|
||||
// We only care about the revision_id.
|
||||
list(, $revision_id, ) = entity_extract_ids($entity_type, $entities[$entity_id]);
|
||||
list(, $revision_id,) = entity_extract_ids($entity_type, $entities[$entity_id]);
|
||||
}
|
||||
metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $bundle);
|
||||
$reset = TRUE;
|
||||
@@ -776,6 +777,32 @@ function metatag_admin_settings_form() {
|
||||
'#default_value' => variable_get('metatag_token_sanitize', FALSE),
|
||||
);
|
||||
|
||||
$form['lengths'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Maximum meta tag lengths'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
'#description' => t('Many meta tags may be shortened to a certain length. To reset to the default, leave the field blank. To keep the entire meta tag, regardless of length, set the value to zero (0). Note: the meta tag will be shortened <em>after</em> the tokens have been replaced, not before.'),
|
||||
);
|
||||
$info = metatag_get_info();
|
||||
$groups = $info['groups'];
|
||||
$tags = $info['tags'];
|
||||
foreach ($tags as $tag => $info) {
|
||||
if (isset($info['maxlength'])) {
|
||||
$default = $info['maxlength'];
|
||||
$var_name = 'metatag_maxlength_' . $tag;
|
||||
$title = $info['label'];
|
||||
if (!empty($info['group']) && isset($groups[$info['group']])) {
|
||||
$title = $groups[$info['group']]['label'] . ': ' . $title;
|
||||
}
|
||||
$form['lengths'][$var_name] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => $title,
|
||||
'#default_value' => intval(variable_get($var_name, $default)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Extra submission logic.
|
||||
$form['#submit'][] = 'metatag_admin_settings_form_submit';
|
||||
|
||||
@@ -785,8 +812,21 @@ function metatag_admin_settings_form() {
|
||||
/**
|
||||
* Form API submission callback for metatag_admin_settings_form().
|
||||
*/
|
||||
function metatag_admin_settings_form_submit() {
|
||||
cache_clear_all('entity_info:', 'cache', TRUE);
|
||||
function metatag_admin_settings_form_submit($form, &$form_state) {
|
||||
// Only keep maxlength values that are numeric. Any empty, non-zero values
|
||||
// will be removed.
|
||||
foreach ($form_state['values'] as $name => $value) {
|
||||
if (strpos($name, 'metatag_maxlength_') !== FALSE) {
|
||||
if ((empty($value) && $value !== 0 && $value !== '0') || !is_numeric($value)) {
|
||||
unset($form_state['values'][$name]);
|
||||
variable_del($name);
|
||||
}
|
||||
else {
|
||||
$form_state['values'][$name] = intval($value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cache_clear_all('*', 'cache_metatag', TRUE);
|
||||
drupal_set_message(t('The Metatag cache has been cleared, so all meta tags can be reloaded.'));
|
||||
drupal_set_message(t('The Metatag cache has been cleared so all meta tags can be reloaded.'));
|
||||
}
|
||||
|
@@ -6,43 +6,43 @@
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
Drupal.behaviors.metatagUIConfigListing = {
|
||||
attach: function (context) {
|
||||
// Hidden elements to be visible if JavaScript is enabled.
|
||||
$('.js-show').show();
|
||||
Drupal.behaviors.metatagUIConfigListing = {
|
||||
attach: function (context) {
|
||||
// Hidden elements to be visible if JavaScript is enabled.
|
||||
$('.js-show').show();
|
||||
|
||||
// Make the leaf arrow clickable.
|
||||
$('.metatag-config-label').hover(function(){
|
||||
$(this).css({'cursor': 'pointer'});
|
||||
})
|
||||
.click(function(){
|
||||
$(this).find('a.toggle-details', context).trigger('click');
|
||||
});
|
||||
// Make the leaf arrow clickable.
|
||||
$('.metatag-config-label').hover(function(){
|
||||
$(this).css({'cursor': 'pointer'});
|
||||
})
|
||||
.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() {
|
||||
if ($(this).hasClass('js-hide')) {
|
||||
$(this).slideDown('slow').removeClass('js-hide');
|
||||
// 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() {
|
||||
if ($(this).hasClass('js-hide')) {
|
||||
$(this).slideDown('slow').removeClass('js-hide');
|
||||
}
|
||||
else {
|
||||
$(this).slideUp('slow').addClass('js-hide');
|
||||
}
|
||||
});
|
||||
|
||||
// Change the expanded or collapsed state of the instance label.
|
||||
if ($(this).parent('div').hasClass('collapsed')) {
|
||||
$(this).parent('div').removeClass('collapsed').addClass('expanded');
|
||||
}
|
||||
else {
|
||||
$(this).slideUp('slow').addClass('js-hide');
|
||||
$(this).parent('div').removeClass('expanded').addClass('collapsed');
|
||||
}
|
||||
|
||||
// This event may be triggered by a parent element click - so we don't
|
||||
// want the click to bubble up otherwise we get recursive click events.
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
// Change the expanded or collapsed state of the instance label.
|
||||
if ($(this).parent('div').hasClass('collapsed')) {
|
||||
$(this).parent('div').removeClass('collapsed').addClass('expanded');
|
||||
}
|
||||
else {
|
||||
$(this).parent('div').removeClass('expanded').addClass('collapsed');
|
||||
}
|
||||
|
||||
// This event may be triggered by a parent element click - so we don't
|
||||
// want the click to bubble up otherwise we get recursive click events.
|
||||
event.stopPropagation();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* API documentation for the Metatag module.
|
||||
@@ -35,7 +36,7 @@ function hook_metatag_config_default() {
|
||||
$config->disabled = FALSE;
|
||||
$config->config = array(
|
||||
'title' => array('value' => '[current-page:title] | [site:name]'),
|
||||
'generator' => array('value' => 'Drupal 7 (http://drupal.org)'),
|
||||
'generator' => array('value' => 'Drupal 7 (https://www.drupal.org)'),
|
||||
'canonical' => array('value' => '[current-page:url:absolute]'),
|
||||
'shortlink' => array('value' => '[current-page:url:unaliased]'),
|
||||
);
|
||||
@@ -214,6 +215,11 @@ function hook_metatag_config_delete($config) {
|
||||
* 'url' - If set to TRUE, relative paths will be converted to absolute.
|
||||
* 'is_language' - If set to TRUE, will not allow the Drupal default
|
||||
* language value "und" to be output.
|
||||
* 'maxlength' - If set to a numeric value, meta tag values will be trimmed
|
||||
* to this limit, which may be overridden via the settings page. Note: any
|
||||
* meta tags with this value assigned can have its maxlength controlled,
|
||||
* so setting the attribute to an empty string will allow site builders to
|
||||
* adjust the meta tag lengths as needed.
|
||||
* 'select_or_other' - If set to TRUE, form[#type] is set to 'select' and
|
||||
* the "select_or_other" module is available, that module will be used to
|
||||
* provide a text field to manually insert another option.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Drush integration for Metatag.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Features integration for the Metatag module.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Feeds mapping implementation for the Metatag module.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Internationalization (i18n) hooks.
|
||||
@@ -79,7 +80,6 @@ function metatag_i18n_object_info() {
|
||||
// 'class' => 'metatag_i18n_metatag',
|
||||
// @todo Is this needed? What does it do?
|
||||
// 'translation set' => TRUE,
|
||||
|
||||
// The object key field.
|
||||
'key' => 'instance',
|
||||
// Placeholders for automatic paths. This connects the 'key' to strings in
|
||||
|
@@ -1,26 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag primary classes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The master interface for all tags.
|
||||
*/
|
||||
interface DrupalMetaTagInterface {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $info
|
||||
* The information about the meta tag from metatag_get_info().
|
||||
*/
|
||||
function __construct(array $info, array $data = array());
|
||||
|
||||
function getForm();
|
||||
public function getForm();
|
||||
|
||||
//function validateForm();
|
||||
|
||||
//function processForm();
|
||||
|
||||
function getValue();
|
||||
public function getValue();
|
||||
|
||||
function getWeight();
|
||||
|
||||
@@ -30,14 +34,43 @@ interface DrupalMetaTagInterface {
|
||||
|
||||
function convertUrlToAbsolute($url);
|
||||
|
||||
function truncate($value);
|
||||
|
||||
function maxlength();
|
||||
|
||||
static function text_summary($text, $size);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The default meta tag class from which all others inherit.
|
||||
*/
|
||||
class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
|
||||
/**
|
||||
* All of the basic information about this tag.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $info;
|
||||
|
||||
/**
|
||||
* The values submitted for this tag.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = array('value' => '');
|
||||
|
||||
/**
|
||||
* This item's weight; used for sorting the output.
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
protected $weight = 0;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
function __construct(array $info, array $data = NULL) {
|
||||
$this->info = $info;
|
||||
if (isset($data)) {
|
||||
@@ -48,9 +81,10 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
/**
|
||||
* Calculate the weight of this meta tag.
|
||||
*
|
||||
* @return integer
|
||||
* @return int
|
||||
* Weight.
|
||||
*/
|
||||
public function getWeight() {
|
||||
function getWeight() {
|
||||
static $counter = 0;
|
||||
|
||||
// If no weight value is found, stack this meta tag at the end.
|
||||
@@ -86,7 +120,7 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
// options as the context so it can be handled appropriately.
|
||||
$value = metatag_translate_metatag($value, $this->info['name'], $options, NULL, TRUE);
|
||||
|
||||
return $value;
|
||||
return $this->truncate($this->tidyValue($this->data['value']));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -156,7 +190,7 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
/**
|
||||
* Remove unwanted formatting from a meta tag.
|
||||
*
|
||||
* @param $value string
|
||||
* @param string $value
|
||||
* The meta tag value to be tidied up.
|
||||
*
|
||||
* @return string
|
||||
@@ -206,7 +240,7 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
// URLs.
|
||||
if (strpos($url, base_path()) === 0 && strpos($url, '//') !== 0) {
|
||||
// Logic:
|
||||
// * Get the length of the base_path(),
|
||||
// * Get the length of the base_path(),
|
||||
// * Get a portion of the image's path starting from the position equal
|
||||
// to the base_path()'s length; this will result in a path relative
|
||||
// to the Drupal installation's base directory.
|
||||
@@ -219,6 +253,149 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
return file_create_url($url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shorten a string to a certain length using text_summary().
|
||||
*
|
||||
* @param string $value
|
||||
* String to shorten.
|
||||
*
|
||||
* @return string
|
||||
* Shortened string.
|
||||
*/
|
||||
function truncate($value) {
|
||||
$maxlength = $this->maxlength();
|
||||
|
||||
if (!empty($value) && $maxlength > 0) {
|
||||
$value = $this->text_summary($value, $maxlength);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify the maximum length of which strings will be allowed.
|
||||
*
|
||||
* @return int
|
||||
* Maxlenght.
|
||||
*/
|
||||
function maxlength() {
|
||||
if (isset($this->info['maxlength'])) {
|
||||
return intval(variable_get('metatag_maxlength_' . $this->info['name'], $this->info['maxlength']));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
static function text_summary($text, $size) {
|
||||
// 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);
|
||||
// }
|
||||
// Find where the delimiter is in the body.
|
||||
$delimiter = strpos($text, '<!--break-->');
|
||||
|
||||
// If the size is zero, and there is no delimiter,
|
||||
// the entire body is the summary.
|
||||
if ($size == 0 && $delimiter === FALSE) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
// If a valid delimiter has been specified, use it to chop off the summary.
|
||||
if ($delimiter !== FALSE) {
|
||||
return substr($text, 0, $delimiter);
|
||||
}
|
||||
|
||||
// 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.
|
||||
// if (isset($format)) {
|
||||
// $filters = filter_list_format($format);
|
||||
// if (isset($filters['php_code']) && $filters['php_code']->status && strpos($text, '<?') !== FALSE) {
|
||||
// return $text;
|
||||
// }
|
||||
// }
|
||||
// If we have a short body, the entire body is the summary.
|
||||
if (drupal_strlen($text) <= $size) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
// If the delimiter has not been specified, try to split at paragraph or
|
||||
// sentence boundaries.
|
||||
// The summary may not be longer than maximum length specified.
|
||||
// Initial slice.
|
||||
$summary = truncate_utf8($text, $size);
|
||||
|
||||
// Store the actual length of the UTF8 string -- which might not be the same
|
||||
// as $size.
|
||||
$max_rpos = strlen($summary);
|
||||
|
||||
// How much to cut off the end of the summary so that it doesn't end in the
|
||||
// middle of a paragraph, sentence, or word.
|
||||
// Initialize it to maximum in order to find the minimum.
|
||||
$min_rpos = $max_rpos;
|
||||
|
||||
// Store the reverse of the summary. We use strpos on the reversed needle
|
||||
// and haystack for speed and convenience.
|
||||
$reversed = strrev($summary);
|
||||
|
||||
// Build an array of arrays of break points grouped by preference.
|
||||
$break_points = array();
|
||||
|
||||
// A paragraph near the end of sliced summary is most preferable.
|
||||
$break_points[] = array('</p>' => 0);
|
||||
|
||||
// If no complete paragraph then treat line breaks as paragraphs.
|
||||
// $line_breaks = array('<br />' => 6, '<br>' => 4);
|
||||
// Newline only indicates a line break if line break converter
|
||||
// filter is present.
|
||||
// if (isset($filters['filter_autop'])) {
|
||||
// $line_breaks["\n"] = 1;
|
||||
// }
|
||||
// $break_points[] = $line_breaks;
|
||||
// If the first paragraph is too long, split at the end of a sentence.
|
||||
// $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1);
|
||||
// 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);
|
||||
$break_points[] = $word_breaks;
|
||||
|
||||
// Iterate over the groups of break points until a break point is found.
|
||||
foreach ($break_points as $points) {
|
||||
// Look for each break point, starting at the end of the summary.
|
||||
foreach ($points as $point => $offset) {
|
||||
// The summary is already reversed, but the break point isn't.
|
||||
$rpos = strpos($reversed, strrev($point));
|
||||
if ($rpos !== FALSE) {
|
||||
$min_rpos = min($rpos + $offset, $min_rpos);
|
||||
}
|
||||
}
|
||||
|
||||
// If a break point was found in this group, slice and stop searching.
|
||||
if ($min_rpos !== $max_rpos) {
|
||||
// Don't slice with length 0. Length must be <0 to slice from RHS.
|
||||
$summary = ($min_rpos === 0) ? $summary : substr($summary, 0, 0 - $min_rpos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the htmlcorrector filter is present, apply it to the generated
|
||||
// summary.
|
||||
// if (isset($filters['filter_htmlcorrector'])) {
|
||||
// $summary = _filter_htmlcorrector($summary);
|
||||
// }
|
||||
return trim($summary);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,6 +428,12 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag {
|
||||
$form['value']['#description'] .= ' ' . t('Multiple values may be used, separated by a comma. Note: Tokens that return multiple values will be handled automatically.');
|
||||
}
|
||||
|
||||
// Optionally limit the field to a certain length.
|
||||
$maxlength = $this->maxlength();
|
||||
if (!empty($maxlength)) {
|
||||
$form['value']['#description'] .= ' ' . t('This will be truncated to a maximum of %max characters.', array('%max' => $maxlength));
|
||||
}
|
||||
|
||||
// Optional handling for images.
|
||||
if (!empty($this->info['image'])) {
|
||||
$form['value']['#description'] .= ' ' . t('This will be able to extract the URL from an image field.');
|
||||
@@ -321,8 +504,8 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag {
|
||||
// Special handling for images and other URLs.
|
||||
if (!empty($this->info['image']) || !empty($this->info['url'])) {
|
||||
// Support multiple items, whether it's needed or not. Also remove the
|
||||
// empty values.
|
||||
$values = array_filter(explode(',', $value));
|
||||
// empty values and reindex the array.
|
||||
$values = array_values(array_filter(explode(',', $value)));
|
||||
|
||||
// If this meta tag does *not* allow multiple items, only keep the first
|
||||
// one.
|
||||
@@ -354,8 +537,12 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag {
|
||||
$value = implode(',', $values);
|
||||
}
|
||||
|
||||
// Clean up the string a bit.
|
||||
$value = $this->tidyValue($value);
|
||||
|
||||
// Optionally truncate the value.
|
||||
$value = $this->truncate($value);
|
||||
|
||||
// Translate the final output string prior to output. Use the
|
||||
// 'output' i18n_string object type, and pass along the meta tag's
|
||||
// options as the context so it can be handled appropriately.
|
||||
@@ -394,7 +581,9 @@ class DrupalLinkMetaTag extends DrupalTextMetaTag {
|
||||
if (!isset($this->info['header']) || !empty($this->info['header'])) {
|
||||
// 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);
|
||||
$element['#attached']['drupal_add_http_header'][] = array(
|
||||
'Link', '<' . $value . '>;' . drupal_http_header_attributes(array('rel' => $element['#name'])), TRUE,
|
||||
);
|
||||
}
|
||||
|
||||
return array(
|
||||
@@ -418,8 +607,16 @@ class DrupalTitleMetaTag extends DrupalTextMetaTag {
|
||||
public function getElement(array $options = array()) {
|
||||
$element = array();
|
||||
if ($value = $this->getValue($options)) {
|
||||
$element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'head_title', $value);
|
||||
$element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'head_array', array('title' => $value));
|
||||
$element['#attached']['metatag_set_preprocess_variable'][] = array(
|
||||
'html',
|
||||
'head_title',
|
||||
decode_entities($value),
|
||||
);
|
||||
$element['#attached']['metatag_set_preprocess_variable'][] = array(
|
||||
'html',
|
||||
'head_array',
|
||||
array('title' => $value),
|
||||
);
|
||||
}
|
||||
return $element;
|
||||
}
|
||||
@@ -525,9 +722,9 @@ class DrupalDateIntervalMetaTag extends DrupalDefaultMetaTag {
|
||||
}
|
||||
}
|
||||
|
||||
// Translate the final output string prior to output. Use the
|
||||
// 'output' i18n_string object type, and pass along the meta tag's
|
||||
// options as the context so it can be handled appropriately.
|
||||
// Translate the final output string prior to output. Use the 'output'
|
||||
// i18n_string object type, and pass along the meta tag's options as the
|
||||
// context so it can be handled appropriately.
|
||||
$value = metatag_translate_metatag($value, $this->info['name'], $options, NULL, TRUE);
|
||||
|
||||
return $value;
|
||||
|
@@ -3,9 +3,8 @@ description = "Adds support and an API to implement meta tags."
|
||||
package = SEO
|
||||
core = 7.x
|
||||
|
||||
; This requires Drupal 7.28 or newer as it fixes the [node:summary] token that
|
||||
; was previously broken.
|
||||
dependencies[] = drupal:system (>= 7.28)
|
||||
; This requires Drupal 7.40 because of the project:module dependency structure.
|
||||
dependencies[] = drupal:system (>= 7.40)
|
||||
|
||||
; CTools is required.
|
||||
dependencies[] = ctools:ctools
|
||||
@@ -105,9 +104,8 @@ files[] = tests/metatag.with_views.test
|
||||
; Other test dependencies.
|
||||
test_dependencies[] = context:context
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Install, update, and uninstall functions for the metatag module.
|
||||
@@ -9,6 +10,7 @@
|
||||
*/
|
||||
function metatag_requirements($phase) {
|
||||
$requirements = array();
|
||||
|
||||
// Ensure translations don't break during installation.
|
||||
$t = get_t();
|
||||
|
||||
@@ -64,14 +66,14 @@ function metatag_requirements($phase) {
|
||||
list($minor, $suffix) = explode('-', $minor);
|
||||
}
|
||||
|
||||
// Releases of Drupal older than 7.28 did not have entity_language(), which
|
||||
// is now required, and had a broken [node:summary] token.
|
||||
if ($minor < 28) {
|
||||
// Releases of Drupal older than 7.40 support did not project:module syntax
|
||||
// for dependencies.
|
||||
if ($minor < 40) {
|
||||
$requirements['metatag'] = array(
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Upgrade Drupal core to v7.28 or newer'),
|
||||
'description' => $t("This older version of Drupal core is missing functionality necessary for the module's multilingual support and contains a broken [node:summary] token, it must be upgraded to version 7.28 or newer."),
|
||||
'value' => $t('Upgrade Drupal core to v7.40 or newer'),
|
||||
'description' => $t("This older version of Drupal core is missing functionality necessary for Metatag to work correctly, it must be upgraded to version 7.40 or newer."),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -211,6 +213,25 @@ function metatag_requirements($phase) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Recommend the Schema.org Metatag module.
|
||||
if (!module_exists('schema_metatag')) {
|
||||
$requirements['metatag_schema'] = array(
|
||||
'severity' => REQUIREMENT_INFO,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Schema.org Metatag is recommended'),
|
||||
'description' => $t('The <a href="@module">Schema.org Metatag</a> module is highly recommended to add <a href="@jsonld">JSON-LD</a> -formatted <a href="@schema">schema.org</a> compatible data structures to the site.', array('@module' => 'https://www.drupal.org/project/schema_metatag', '@jsonld' => 'https://json-ld.org', '@schema' => 'http://schema.org')),
|
||||
);
|
||||
}
|
||||
else {
|
||||
$requirements['metatag_schema'] = array(
|
||||
'severity' => REQUIREMENT_OK,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Schema.org Metatag is installed'),
|
||||
'description' => $t('The <a href="@module">Schema.org Metatag</a> module is installed.', array('@module' => 'https://www.drupal.org/project/schema_metatag')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
@@ -475,6 +496,13 @@ function metatag_uninstall() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all of the maxlength variables.
|
||||
variable_del('metatag_maxlength_title');
|
||||
variable_del('metatag_maxlength_description');
|
||||
variable_del('metatag_maxlength_abstract');
|
||||
variable_del('metatag_maxlength_keywords');
|
||||
variable_del('metatag_maxlength_news_keywords');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -578,7 +606,7 @@ function metatag_update_replace_entity_value(&$sandbox, $meta_tag, $old_value, $
|
||||
|
||||
if (!isset($sandbox['progress'])) {
|
||||
// Count of all {metatag} records that contained an entry for the old meta
|
||||
// tag value
|
||||
// tag value.
|
||||
$records_count = db_select('metatag', 'm')
|
||||
->condition($db_and)
|
||||
->countQuery()
|
||||
@@ -2575,6 +2603,7 @@ function metatag_update_7113() {
|
||||
*/
|
||||
function metatag_update_7114() {
|
||||
variable_del('metatag_cache_output');
|
||||
drupal_set_message(t('Note: Output caching of meta tags has been disabled, it may be reenabled from the Metatag settings page if needed.'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag API implementations to provide the basic meta tags.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_metatag_config_default().
|
||||
*/
|
||||
@@ -17,7 +22,7 @@ function metatag_metatag_config_default() {
|
||||
$config->disabled = FALSE;
|
||||
$config->config = array(
|
||||
'title' => array('value' => '[current-page:title] | [current-page:pager][site:name]'),
|
||||
'generator' => array('value' => 'Drupal 7 (http://drupal.org)'),
|
||||
'generator' => array('value' => 'Drupal 7 (https://www.drupal.org)'),
|
||||
'canonical' => array('value' => '[current-page:url:absolute]'),
|
||||
'shortlink' => array('value' => '[current-page:url:unaliased]'),
|
||||
);
|
||||
@@ -112,7 +117,7 @@ function metatag_metatag_config_instance_info() {
|
||||
if (metatag_entity_supports_metatags($entity_type)) {
|
||||
$info[$entity_type] = array('label' => $entity_info['label']);
|
||||
foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
|
||||
if (count($entity_info['bundles'] == 1) && $bundle == $entity_type) {
|
||||
if (count($entity_info['bundles']) == 1 && $bundle == $entity_type) {
|
||||
// Skip default bundles (entities that do not really have bundles).
|
||||
continue;
|
||||
}
|
||||
@@ -150,6 +155,7 @@ function metatag_metatag_info() {
|
||||
$info['tags']['title'] = array(
|
||||
'label' => t('Page title'),
|
||||
'description' => t("The text to display in the title bar of a visitor's web browser when they view this page. This meta tag may also be used as the title of the page when a visitor bookmarks or favorites this page."),
|
||||
'maxlength' => 0,
|
||||
'class' => 'DrupalTitleMetaTag',
|
||||
'group' => 'basic',
|
||||
'weight' => ++$weight,
|
||||
@@ -157,7 +163,8 @@ function metatag_metatag_info() {
|
||||
|
||||
$info['tags']['description'] = array(
|
||||
'label' => t('Description'),
|
||||
'description' => t("A brief and concise summary of the page's content, preferably 150 characters or less. The description meta tag may be used by search engines to display a snippet about the page in search results."),
|
||||
'description' => t("A brief and concise summary of the page's content, preferably 320 characters or less. The description meta tag may be used by search engines to display a snippet about the page in search results."),
|
||||
'maxlength' => 380,
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'basic',
|
||||
'weight' => ++$weight,
|
||||
@@ -170,7 +177,8 @@ function metatag_metatag_info() {
|
||||
|
||||
$info['tags']['abstract'] = array(
|
||||
'label' => t('Abstract'),
|
||||
'description' => t("A brief and concise summary of the page's content, preferably 150 characters or less. The abstract meta tag may be used by search engines for archiving purposes."),
|
||||
'description' => t("A brief and concise summary of the page's content, preferably 150 characters or less. Where as the description meta tag may be used by search engines to display a snippet about the page in search results, the abstract tag may be used to archive a summary about the page. This meta tag is <em>no longer</em> supported by major search engines."),
|
||||
'maxlength' => 0,
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'basic',
|
||||
'weight' => ++$weight,
|
||||
@@ -184,6 +192,7 @@ function metatag_metatag_info() {
|
||||
$info['tags']['keywords'] = array(
|
||||
'label' => t('Keywords'),
|
||||
'description' => t("A comma-separated list of keywords about the page. This meta tag is <em>not</em> supported by most search engines anymore."),
|
||||
'maxlength' => 0,
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'basic',
|
||||
'weight' => ++$weight,
|
||||
@@ -215,6 +224,7 @@ function metatag_metatag_info() {
|
||||
$info['tags']['news_keywords'] = array(
|
||||
'label' => t('Google News Keywords'),
|
||||
'description' => t('A comma-separated list of keywords about the page. This meta tag is used as an indicator in <a href="@google_news">Google News</a>.', array('@google_news' => 'http://support.google.com/news/publisher/bin/answer.py?hl=en&answer=68297')),
|
||||
'maxlength' => 0,
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
@@ -312,6 +322,18 @@ function metatag_metatag_info() {
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['set_cookie'] = array(
|
||||
'label' => t('Set cookie'),
|
||||
'description' => t('<a href="https://www.metatags.org/meta_http_equiv_set_cookie">Sets a cookie</a> on the visitor\'s browser. Can be in either NAME=VALUE format, or a more verbose format including the path and expiration date; see the link for full details on the syntax.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'is_language' => TRUE,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_http_equiv',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['shortlink'] = array(
|
||||
'label' => t('Shortlink URL'),
|
||||
'description' => t('A brief URL, often created by a URL shortening service.'),
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag support for Migrate.
|
||||
@@ -125,4 +126,5 @@ class MigrateMetatagHandler extends MigrateDestinationHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -247,6 +247,147 @@ function metatag_flush_caches() {
|
||||
return array('cache_metatag');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_action_info().
|
||||
* Provides integration with Views bulk operations.
|
||||
*/
|
||||
function metatag_action_info() {
|
||||
return array(
|
||||
'metatag_modify_metatags_action' => array(
|
||||
'type' => 'entity',
|
||||
'label' => t('Modify entity metatags'),
|
||||
'configurable' => FALSE,
|
||||
'vbo_configurable' => TRUE,
|
||||
'behavior' => array('changes_property'),
|
||||
'triggers' => array('any'),
|
||||
'permissions' => array('edit meta tags'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates entity metatags with values from the action form.
|
||||
*
|
||||
* @param object $entity
|
||||
* The entity housing the metatags to modify.
|
||||
* @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) {
|
||||
if (empty($entity)) {
|
||||
drupal_set_message(t("Error while trying to update an entity's metatags."),
|
||||
'warning', FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
$updates = $context['updates'];
|
||||
$language = $entity->language;
|
||||
|
||||
// Reset metatags to the entity default configs.
|
||||
if ($context['reset_default']) {
|
||||
$instance = $context['entity_type'] . ':' . $entity->type;
|
||||
$entity_defaults = metatag_config_load_with_defaults($instance);
|
||||
|
||||
// Clean up empty values.
|
||||
foreach ($entity_defaults as $name => $tag) {
|
||||
if (empty($tag['value'])) {
|
||||
unset($entity_defaults[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
$entity->metatags[$language] = $entity_defaults;
|
||||
}
|
||||
// Otherwise, we're updating existing values. Ensure that the entity has any
|
||||
// metatags already set. If so then merge the updates to avoid overwriting
|
||||
// existing values that may exist as an array. E.g. robots.
|
||||
elseif (!empty($entity->metatags) && !empty($entity->metatags[$language])) {
|
||||
foreach ($updates as $tag => $value_array) {
|
||||
if (is_array($updates[$tag]['value']) && !empty($entity->metatags[$language][$tag]['value'])) {
|
||||
$entity->metatags[$language][$tag]['value'] = array_merge($entity->metatags[$language][$tag]['value'],
|
||||
array_filter($updates[$tag]['value']));
|
||||
}
|
||||
elseif (!empty($updates[$tag]['value'])) {
|
||||
$entity->metatags[$language][$tag]['value'] = $updates[$tag]['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
// Otherwise just set the net new tags.
|
||||
else {
|
||||
$entity->metatags[$language] = $updates;
|
||||
}
|
||||
|
||||
entity_save($context['entity_type'], $entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* The Views bulk operation configuration form for modifying metatags.
|
||||
*
|
||||
* @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) {
|
||||
$form = array(
|
||||
'#entity_type' => $context['entity_type'],
|
||||
);
|
||||
|
||||
// There can be multiple instances being edited here. So the 2nd param passed
|
||||
// here is as generic as possible.
|
||||
metatag_metatags_form($form, 'global');
|
||||
|
||||
// Force the metatags tab to be fully visible and save a click from the user.
|
||||
$form['metatags']['#collapsed'] = FALSE;
|
||||
$form['metatags']['#collapsible'] = FALSE;
|
||||
|
||||
// If we're reseting to the entity default, then we don't need to show the
|
||||
// form fields.
|
||||
$form['metatags']['#states'] = array(
|
||||
'visible' => array(
|
||||
':input[name="reset_default"]' => array('checked' => FALSE),
|
||||
),
|
||||
);
|
||||
|
||||
// Add an option to reset selected entities to the default configuration.
|
||||
$form['reset_default'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Reset to metatag defaults'),
|
||||
'#default_value' => FALSE,
|
||||
'#description' => t('Check to <strong>fully reset all metatags</strong> on
|
||||
the entities being modified to their <a href="@settings">default
|
||||
configuration</a>.', 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.
|
||||
*
|
||||
* @return array
|
||||
* The updated metatag values that is ultimately keyed at $context['updates'].
|
||||
*/
|
||||
function metatag_modify_metatags_action_submit($form, &$form_state) {
|
||||
$updates = $form_state['values']['metatags'][LANGUAGE_NONE];
|
||||
$defaults = metatag_config_load_with_defaults($form['#entity_type']);
|
||||
|
||||
// Filter out the true updates.
|
||||
metatag_filter_values_from_defaults($updates, $defaults);
|
||||
|
||||
return array(
|
||||
'updates' => $updates,
|
||||
'reset_default' => $form_state['values']['reset_default'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a metatag configuration record with all the defaults merged in.
|
||||
*
|
||||
@@ -581,7 +722,7 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $
|
||||
* 'value' => "[node:field_thumbnail]",
|
||||
* ),
|
||||
* ),
|
||||
* );.
|
||||
* );
|
||||
* @param string|null $bundle
|
||||
* The bundle of the entity that is being saved. Optional.
|
||||
*/
|
||||
@@ -1435,9 +1576,16 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array(
|
||||
|
||||
// Get the form element from the meta tag class.
|
||||
$metatag_form = $metatag_instance->getForm($options);
|
||||
if (isset($metatag_form['value']['#default_value']) && is_array($metatag_form['value']['#default_value'])) {
|
||||
$metatag_form['value']['#default_value'] = array_filter($metatag_form['value']['#default_value']);
|
||||
}
|
||||
|
||||
// Add a default value form element.
|
||||
if (isset($options['defaults'][$metatag]['value'])) {
|
||||
if (is_array($options['defaults'][$metatag]['value'])) {
|
||||
$options['defaults'][$metatag]['value'] = array_filter($options['defaults'][$metatag]['value']);
|
||||
}
|
||||
|
||||
$metatag_form['default'] = array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $options['defaults'][$metatag]['value'],
|
||||
@@ -1638,7 +1786,7 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) {
|
||||
// 'metatag_enable_{$entity_type}' the value FALSE, e.g.:
|
||||
//
|
||||
// // Disable metatags for file_entity.
|
||||
// $conf['metatag_enable_file'] = FALSE;.
|
||||
// $conf['metatag_enable_file'] = FALSE;
|
||||
//
|
||||
// @see Settings page.
|
||||
if (variable_get('metatag_enable_' . $entity_name, FALSE) == FALSE) {
|
||||
@@ -1660,7 +1808,7 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) {
|
||||
// 'metatag_enable_{$entity_type}__{$bundle}' the value FALSE, e.g.:
|
||||
//
|
||||
// // Disable metatags for carousel nodes.
|
||||
// $conf['metatag_enable_node__carousel'] = FALSE;.
|
||||
// $conf['metatag_enable_node__carousel'] = FALSE;
|
||||
//
|
||||
// @see Settings page.
|
||||
if (variable_get('metatag_enable_' . $entity_name . '__' . $bundle_name, TRUE) == FALSE) {
|
||||
@@ -2599,7 +2747,6 @@ function _metatag_isdefaultrevision($entity) {
|
||||
//
|
||||
// Every moderation module saving a forward revision needs to return FALSE.
|
||||
// @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.
|
||||
@@ -2647,8 +2794,8 @@ function metatag_cache_default_cid_parts(array $cid_parts = array()) {
|
||||
}
|
||||
|
||||
// Allow each page in a sequence to have different values.
|
||||
if (isset($_GET['page'])) {
|
||||
$cid_parts['page'] = $_GET['page'];
|
||||
if (isset($_GET['page']) && is_numeric($_GET['page'])) {
|
||||
$cid_parts['page'] = intval($_GET['page']);
|
||||
}
|
||||
|
||||
// Allow other modules to customize the data using
|
||||
|
@@ -19,9 +19,13 @@ function metatag_search_api_alter_callback_info() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds meta tag values to the indexed items.
|
||||
* Only add the class if Search API is installed.
|
||||
*/
|
||||
if (class_exists('SearchApiAbstractAlterCallback')) {
|
||||
|
||||
/**
|
||||
* Adds meta tag values to the indexed items.
|
||||
*/
|
||||
class MetatagSearchAlterCallback extends SearchApiAbstractAlterCallback {
|
||||
|
||||
/**
|
||||
@@ -62,6 +66,7 @@ if (class_exists('SearchApiAbstractAlterCallback')) {
|
||||
case 'DrupalLinkMetaTag':
|
||||
$type = 'uri';
|
||||
break;
|
||||
|
||||
default:
|
||||
$type = 'text';
|
||||
break;
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Custom tokens for Metatag.
|
||||
@@ -26,7 +27,7 @@ function metatag_token_info() {
|
||||
}
|
||||
$info['tokens']['metatag'][$value['name']] = array(
|
||||
'name' => $label,
|
||||
'description' => $value['description'],
|
||||
'description' => isset($value['description']) ? $value['description'] : '',
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of variables for Variable API module.
|
||||
@@ -8,7 +9,6 @@
|
||||
* Implements hook_variable_info().
|
||||
*/
|
||||
function metatag_variable_info($options) {
|
||||
|
||||
$variables['metatag_pager_string'] = array(
|
||||
'title' => t('Custom pager string', array(), $options),
|
||||
'type' => 'string',
|
||||
@@ -19,6 +19,29 @@ function metatag_variable_info($options) {
|
||||
'multidomain' => TRUE,
|
||||
);
|
||||
|
||||
$info = metatag_get_info();
|
||||
$groups = $info['groups'];
|
||||
$tags = $info['tags'];
|
||||
foreach ($tags as $tag => $info) {
|
||||
if (isset($info['maxlength'])) {
|
||||
$default = $info['maxlength'];
|
||||
$var_name = 'metatag_maxlength_' . $tag;
|
||||
$title = $info['label'];
|
||||
if (!empty($info['group']) && isset($groups[$info['group']])) {
|
||||
$title = $groups[$info['group']]['label'] . ': ' . $title;
|
||||
}
|
||||
$variables[$var_name] = array(
|
||||
'title' => t('Maximum length for @tag', array('@tag' => $title), $options),
|
||||
'type' => 'string',
|
||||
'description' => t('Controls the maximum length of the @tag meta tag, values longer than this will be truncated. If set to "0" the maximum length will be ignored.', array('@tag' => $title), $options),
|
||||
'default' => intval(variable_get($var_name, $default)),
|
||||
'group' => 'metatag',
|
||||
'localize' => TRUE,
|
||||
'multidomain' => TRUE,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $variables;
|
||||
}
|
||||
|
||||
|
@@ -6,52 +6,53 @@
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
Drupal.behaviors.metatagFieldsetSummaries = {
|
||||
attach: function (context) {
|
||||
$('fieldset.metatags-form', context).drupalSetSummary(function (context) {
|
||||
var vals = [];
|
||||
$("input[type='text'], select, textarea", context).each(function() {
|
||||
var input_field = $(this).attr('name');
|
||||
// Verify the field exists before proceeding.
|
||||
if (input_field === undefined) {
|
||||
return false;
|
||||
Drupal.behaviors.metatagFieldsetSummaries = {
|
||||
attach: function (context) {
|
||||
$('fieldset.metatags-form', context).drupalSetSummary(function (context) {
|
||||
var vals = [];
|
||||
$("input[type='text'], select, textarea", context).each(function() {
|
||||
var input_field = $(this).attr('name');
|
||||
// Verify the field exists before proceeding.
|
||||
if (input_field === undefined) {
|
||||
return false;
|
||||
}
|
||||
var default_name = input_field.replace(/\[value\]/, '[default]');
|
||||
var default_value = $("input[type='hidden'][name='" + default_name + "']", context);
|
||||
if (default_value.length && default_value.val() === $(this).val()) {
|
||||
// Meta tag has a default value and form value matches default
|
||||
// value.
|
||||
return true;
|
||||
}
|
||||
else if (!default_value.length && !$(this).val().length) {
|
||||
// Meta tag has no default value and form value is empty.
|
||||
return true;
|
||||
}
|
||||
var label = $("label[for='" + $(this).attr('id') + "']").text();
|
||||
vals.push(Drupal.t('@label: @value', {
|
||||
'@label': $.trim(label),
|
||||
'@value': Drupal.truncate($(this).val(), 25) || Drupal.t('None')
|
||||
}));
|
||||
});
|
||||
if (vals.length === 0) {
|
||||
return Drupal.t('Using defaults');
|
||||
}
|
||||
var default_name = input_field.replace(/\[value\]/, '[default]');
|
||||
var default_value = $("input[type='hidden'][name='" + default_name + "']", context);
|
||||
if (default_value.length && default_value.val() === $(this).val()) {
|
||||
// Meta tag has a default value and form value matches default value.
|
||||
return true;
|
||||
else {
|
||||
return vals.join('<br />');
|
||||
}
|
||||
else if (!default_value.length && !$(this).val().length) {
|
||||
// Meta tag has no default value and form value is empty.
|
||||
return true;
|
||||
}
|
||||
var label = $("label[for='" + $(this).attr('id') + "']").text();
|
||||
vals.push(Drupal.t('@label: @value', {
|
||||
'@label': $.trim(label),
|
||||
'@value': Drupal.truncate($(this).val(), 25) || Drupal.t('None')
|
||||
}));
|
||||
});
|
||||
if (vals.length === 0) {
|
||||
return Drupal.t('Using defaults');
|
||||
}
|
||||
else {
|
||||
return vals.join('<br />');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Encode special characters in a plain-text string for display as HTML.
|
||||
*/
|
||||
Drupal.truncate = function (str, limit) {
|
||||
if (str.length > limit) {
|
||||
return str.substr(0, limit) + '...';
|
||||
}
|
||||
else {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Encode special characters in a plain-text string for display as HTML.
|
||||
*/
|
||||
Drupal.truncate = function (str, limit) {
|
||||
if (str.length > limit) {
|
||||
return str.substr(0, limit) + '...';
|
||||
}
|
||||
else {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -8,9 +8,8 @@ dependencies[] = metatag:metatag
|
||||
files[] = tests/metatag_app_links.test
|
||||
files[] = tests/metatag_app_links.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag:App Links module.
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag App Links tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag App Links tags work correctly.
|
||||
*/
|
||||
@@ -64,7 +69,6 @@ class MetatagAppLinksTagsTest extends MetatagTagsTestBase {
|
||||
*/
|
||||
public function getTestTagName($tag_name) {
|
||||
// All of the tags have their underlines replaced with colons.
|
||||
|
||||
// Start with the beginning of the string.
|
||||
$tag_name = str_replace('al_', 'al:', $tag_name);
|
||||
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag AppLinks module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag AppLinks module.
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin settings page for Metatag Context.
|
||||
@@ -199,7 +200,7 @@ function metatag_context_delete_form($form, &$form_state, $context) {
|
||||
$form_state['metatag_context']['context'] = $context;
|
||||
|
||||
$form['delete'] = array(
|
||||
'#value' => 'This action will permanently remove this item from your database.'
|
||||
'#value' => 'This action will permanently remove this item from your database.',
|
||||
);
|
||||
|
||||
$form['actions']['#type'] = 'actions';
|
||||
@@ -241,8 +242,7 @@ function metatag_context_load_default_context() {
|
||||
$context->metatag = TRUE;
|
||||
$context->conditions = array(
|
||||
'path' => array(
|
||||
'values' => array(
|
||||
),
|
||||
'values' => array(),
|
||||
),
|
||||
);
|
||||
$context->reactions = array(
|
||||
|
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Context reaction for Metatag.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Context reaction for Metatag.
|
||||
*/
|
||||
class metatag_context_reaction extends context_reaction {
|
||||
function options_form($context) {
|
||||
$form = array();
|
||||
@@ -193,6 +197,7 @@ class metatag_context_reaction extends context_reaction {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Internationalization (i18n) hooks.
|
||||
@@ -64,10 +65,15 @@ function metatag_context_i18n_object_info() {
|
||||
|
||||
// Build a suitable structure for this meta tag.
|
||||
$tag_name = $tag_info['name'];
|
||||
$tag_group = $tag_info['group'];
|
||||
$group_label = isset($groups[$tag_group]['label']) ? $groups[$tag_group]['label'] : $tag_group;
|
||||
$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;
|
||||
}
|
||||
|
||||
$info['metatag_context']['string translation']['properties'][$tag_name] = array(
|
||||
'title' => $group_label . ': ' . $tag_info['label'],
|
||||
'title' => $title,
|
||||
'field' => "reactions.metatag_context_reaction.und.{$tag_name}.value",
|
||||
);
|
||||
}
|
||||
|
@@ -12,9 +12,8 @@ dependencies[] = context:context
|
||||
files[] = tests/metatag_context.test
|
||||
files[] = tests/metatag_context.i18n.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation and update hooks for Metatag:Context.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the metatag_context module.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag Context.
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests the Metatag:Context module for i18n integration.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests the Metatag:Context module for i18n integration.
|
||||
*/
|
||||
@@ -52,7 +57,7 @@ class MetatagContextI18nTest extends MetatagTestHelper {
|
||||
|
||||
// Log in the admin user.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
|
||||
// Reload the translations.
|
||||
drupal_flush_all_caches();
|
||||
module_load_include('admin.inc', 'i18n_string');
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functional tests for the Metatag:Context module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Functional tests for the Metatag:Context module.
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Context reaction for Metatag:Context tests.
|
||||
|
@@ -9,9 +9,8 @@ dependencies[] = context:context
|
||||
dependencies[] = metatag:metatag
|
||||
dependencies[] = metatag:metatag_context
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:Context tests.
|
||||
|
@@ -8,9 +8,8 @@ dependencies[] = metatag:metatag
|
||||
files[] = tests/metatag_dc.test
|
||||
files[] = tests/metatag_dc.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,12 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation and update scripts for metatag_dc_advanced.
|
||||
* Installation and update scripts for metatag_dc.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Dublic Core Additional Tags meta tags are now in a new submodule.
|
||||
*/
|
||||
function metatag_dc_update_7100() {
|
||||
drupal_set_message(t('The Dublic Core Additional Tags meta tags have been moved into the new "Metatag: Dublin Core Advanced" submodule.'));
|
||||
drupal_set_message(t('The Dublin Core Additional Tags meta tags have been moved into the new "Metatag: Dublin Core Advanced" submodule.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function metatag_dc_uninstall() {
|
||||
// Remove all of the maxlength variables.
|
||||
variable_del('metatag_maxlength_dcterms.subject');
|
||||
variable_del('metatag_maxlength_dcterms.description');
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the metatag_dc module.
|
||||
@@ -107,11 +108,13 @@ function metatag_dc_metatag_info() {
|
||||
$info['tags']['dcterms.subject'] = array(
|
||||
'label' => t('Subject'),
|
||||
'description' => t('The topic of the resource. Typically, the subject will be represented using keywords, key phrases, or classification codes. Recommended best practice is to use a controlled vocabulary. To describe the spatial or temporal topic of the resource, use the Coverage element.'),
|
||||
'maxlength' => 0,
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['dcterms.description'] = array(
|
||||
'label' => t('Description'),
|
||||
'description' => t('An account of the resource. Description may include but is not limited to: an abstract, a table of contents, a graphical representation, or a free-text account of the resource.'),
|
||||
'maxlength' => 0,
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['dcterms.publisher'] = array(
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the metatag_dc module.
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag Dublin Core tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag Dublin Core tags work correctly.
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag DC module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag DC module.
|
||||
*/
|
||||
|
@@ -9,9 +9,8 @@ dependencies[] = metatag:metatag_dc
|
||||
files[] = tests/metatag_dc_advanced.test
|
||||
files[] = tests/metatag_dc_advanced.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the metatag_dc module.
|
||||
@@ -48,6 +49,7 @@ function metatag_dc_advanced_metatag_info() {
|
||||
$info['tags']['dcterms.abstract'] = array(
|
||||
'label' => t('Abstract'),
|
||||
'description' => t('A summary of the resource.'),
|
||||
'maxlength' => 0,
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['dcterms.accessRights'] = array(
|
||||
@@ -73,6 +75,7 @@ function metatag_dc_advanced_metatag_info() {
|
||||
$info['tags']['dcterms.alternative'] = array(
|
||||
'label' => t('Alternative Title'),
|
||||
'description' => t('An alternative name for the resource.'),
|
||||
'maxlength' => 0,
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['dcterms.audience'] = array(
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the metatag_dc_advanced module.
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag Advanced Dublin Core tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag Advanced Dublin Core tags work correctly.
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag DC Advanced module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag DC Advanced module.
|
||||
*/
|
||||
|
@@ -8,9 +8,8 @@ dependencies[] = metatag:metatag
|
||||
; Tests.
|
||||
files[] = tests/metatag_devel.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:Devel.
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag Devel module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag Devel module.
|
||||
*/
|
||||
|
@@ -8,9 +8,8 @@ dependencies[] = metatag:metatag
|
||||
files[] = tests/metatag_facebook.test
|
||||
files[] = tests/metatag_facebook.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation and update scripts for Metatag:Facebook.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag:Facebook module.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:Facebook.
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag Facebook tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag Facebook tags work correctly.
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag Facebook module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag Facebook module.
|
||||
*/
|
||||
|
@@ -11,9 +11,8 @@ files[] = metatag_favicons.mask-icon.class.inc
|
||||
files[] = tests/metatag_favicons.test
|
||||
files[] = tests/metatag_favicons.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Update scripts, etc for the Metatag Favicons module.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Custom class for the mask-icon meta tag's custom data.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag:favicons module.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:favicons.
|
||||
@@ -139,41 +140,29 @@ function metatag_favicons_get_theme_favicon() {
|
||||
* The MIME type on success, an empty string on failure.
|
||||
*/
|
||||
function metatag_favicons_get_mime_type($uri) {
|
||||
// Look for the last period in the URL.
|
||||
$extension_dot = strrpos($uri, '.');
|
||||
$type = '';
|
||||
|
||||
// URLs must have a file extension in order for this to work.
|
||||
if ($extension_dot) {
|
||||
$extension = strtolower(substr($uri, $extension_dot + 1));
|
||||
|
||||
// Work out the file's extension.
|
||||
switch ($extension) {
|
||||
case 'ico':
|
||||
$type = 'vnd.microsoft.icon';
|
||||
break;
|
||||
|
||||
// Rename JPEG images as JPG.
|
||||
case 'jpeg':
|
||||
$extension = 'jpeg';
|
||||
|
||||
// Basic image types.
|
||||
case 'gif':
|
||||
case 'jpg':
|
||||
case 'png':
|
||||
// Keep the extension as it is.
|
||||
break;
|
||||
|
||||
// This shouldn't happen, only GIF, JPG, ICO or PNG files are supported.
|
||||
default:
|
||||
$extension = '';
|
||||
}
|
||||
|
||||
// Only compile the MIME type if a supported extension was found.
|
||||
if (!empty($extension)) {
|
||||
$type = 'image/' . $extension;
|
||||
}
|
||||
$extension_dot = strrpos($uri, '.');
|
||||
if (!$extension_dot) {
|
||||
return '';
|
||||
}
|
||||
// Return the proper MIME type based on the extension.
|
||||
$extension = strtolower(substr($uri, $extension_dot + 1));
|
||||
switch ($extension) {
|
||||
case 'ico':
|
||||
return 'image/vnd.microsoft.icon';
|
||||
|
||||
return $type;
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
return 'image/jpeg';
|
||||
|
||||
case 'svg':
|
||||
return 'image/svg+xml';
|
||||
|
||||
case 'gif':
|
||||
case 'png':
|
||||
return 'image/' . $extension;
|
||||
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag Favicons tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag Favicons tags work correctly.
|
||||
*/
|
||||
@@ -75,28 +80,28 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'icon_16x16',
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'icon_16x16'.
|
||||
*/
|
||||
public function icon_16x16_test_output_xpath() {
|
||||
return "//link[@rel='icon' and @sizes='16x16']";
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'icon_192x192',
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'icon_192x192'.
|
||||
*/
|
||||
public function icon_192x192_test_output_xpath() {
|
||||
return "//link[@rel='icon' and @sizes='192x192']";
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'icon_32x32',
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'icon_32x32'.
|
||||
*/
|
||||
public function icon_32x32_test_output_xpath() {
|
||||
return "//link[@rel='icon' and @sizes='32x32']";
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'icon_96x96',
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'icon_96x96'.
|
||||
*/
|
||||
public function icon_96x96_test_output_xpath() {
|
||||
return "//link[@rel='icon' and @sizes='96x96']";
|
||||
@@ -104,7 +109,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_precomposed',
|
||||
* 'apple_touch_icon_precomposed'.
|
||||
*/
|
||||
public function apple_touch_icon_precomposed_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon-precomposed' and not(@sizes)]";
|
||||
@@ -112,7 +117,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_precomposed_114x114',
|
||||
* 'apple_touch_icon_precomposed_114x114'.
|
||||
*/
|
||||
public function apple_touch_icon_precomposed_114x114_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon-precomposed' and @sizes='114x114']";
|
||||
@@ -120,7 +125,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_precomposed_120x120',
|
||||
* 'apple_touch_icon_precomposed_120x120'.
|
||||
*/
|
||||
public function apple_touch_icon_precomposed_120x120_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon-precomposed' and @sizes='120x120']";
|
||||
@@ -128,7 +133,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_precomposed_144x144',
|
||||
* 'apple_touch_icon_precomposed_144x144'.
|
||||
*/
|
||||
public function apple_touch_icon_precomposed_144x144_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon-precomposed' and @sizes='144x144']";
|
||||
@@ -136,7 +141,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_precomposed_152x152',
|
||||
* 'apple_touch_icon_precomposed_152x152'.
|
||||
*/
|
||||
public function apple_touch_icon_precomposed_152x152_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon-precomposed' and @sizes='152x152']";
|
||||
@@ -144,7 +149,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_precomposed_180x180',
|
||||
* 'apple_touch_icon_precomposed_180x180'.
|
||||
*/
|
||||
public function apple_touch_icon_precomposed_180x180_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon-precomposed' and @sizes='180x180']";
|
||||
@@ -152,7 +157,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_precomposed_72x72',
|
||||
* 'apple_touch_icon_precomposed_72x72'.
|
||||
*/
|
||||
public function apple_touch_icon_precomposed_72x72_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon-precomposed' and @sizes='72x72']";
|
||||
@@ -160,14 +165,14 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_precomposed_76x76',
|
||||
* 'apple_touch_icon_precomposed_76x76'.
|
||||
*/
|
||||
public function apple_touch_icon_precomposed_76x76_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon-precomposed' and @sizes='76x76']";
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'apple_touch_icon',
|
||||
* Implements {meta_tag_name}_test_output_xpath() for 'apple_touch_icon'.
|
||||
*/
|
||||
public function apple_touch_icon_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon' and not(@sizes)]";
|
||||
@@ -175,7 +180,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_114x114',
|
||||
* 'apple_touch_icon_114x114'.
|
||||
*/
|
||||
public function apple_touch_icon_114x114_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon' and @sizes='114x114']";
|
||||
@@ -183,7 +188,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_120x120',
|
||||
* 'apple_touch_icon_120x120'.
|
||||
*/
|
||||
public function apple_touch_icon_120x120_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon' and @sizes='120x120']";
|
||||
@@ -191,7 +196,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_144x144',
|
||||
* 'apple_touch_icon_144x144'.
|
||||
*/
|
||||
public function apple_touch_icon_144x144_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon' and @sizes='144x144']";
|
||||
@@ -199,7 +204,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_152x152',
|
||||
* 'apple_touch_icon_152x152'.
|
||||
*/
|
||||
public function apple_touch_icon_152x152_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon' and @sizes='152x152']";
|
||||
@@ -207,7 +212,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_180x180',
|
||||
* 'apple_touch_icon_180x180'.
|
||||
*/
|
||||
public function apple_touch_icon_180x180_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon' and @sizes='180x180']";
|
||||
@@ -215,7 +220,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_72x72',
|
||||
* 'apple_touch_icon_72x72'.
|
||||
*/
|
||||
public function apple_touch_icon_72x72_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon' and @sizes='72x72']";
|
||||
@@ -223,7 +228,7 @@ class MetatagFaviconsTagsTest extends MetatagTagsTestBase {
|
||||
|
||||
/**
|
||||
* Implements {meta_tag_name}_test_output_xpath() for
|
||||
* 'apple_touch_icon_76x76',
|
||||
* 'apple_touch_icon_76x76'.
|
||||
*/
|
||||
public function apple_touch_icon_76x76_test_output_xpath() {
|
||||
return "//link[@rel='apple-touch-icon' and @sizes='76x76']";
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag Favicons module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag Favicons module.
|
||||
*/
|
||||
@@ -74,8 +79,8 @@ class MetatagFaviconsTest extends MetatagTestHelper {
|
||||
// Confirm the meta tag is present.
|
||||
$xpath = $this->xpath("//link[@rel='mask-icon']");
|
||||
$this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.');
|
||||
$this->assertNotEqual((string)$xpath[0]['href'], $svg_path);
|
||||
$this->assertEqual((string)$xpath[0]['href'], $absolute_path);
|
||||
$this->assertNotEqual((string) $xpath[0]['href'], $svg_path);
|
||||
$this->assertEqual((string) $xpath[0]['href'], $absolute_path);
|
||||
|
||||
// Before proceeding, clear the site's caches.
|
||||
drupal_flush_all_caches();
|
||||
@@ -92,8 +97,8 @@ class MetatagFaviconsTest extends MetatagTestHelper {
|
||||
// Confirm the meta tag is present.
|
||||
$xpath = $this->xpath("//link[@rel='mask-icon']");
|
||||
$this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.');
|
||||
$this->assertNotEqual((string)$xpath[0]['href'], $svg_path);
|
||||
$this->assertNotEqual((string)$xpath[0]['href'], $relative_path);
|
||||
$this->assertNotEqual((string) $xpath[0]['href'], $svg_path);
|
||||
$this->assertNotEqual((string) $xpath[0]['href'], $relative_path);
|
||||
|
||||
// Before proceeding, clear the site's caches.
|
||||
drupal_flush_all_caches();
|
||||
@@ -110,13 +115,13 @@ class MetatagFaviconsTest extends MetatagTestHelper {
|
||||
// Confirm the meta tag is present.
|
||||
$xpath = $this->xpath("//link[@rel='mask-icon']");
|
||||
$this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.');
|
||||
$this->assertNotEqual((string)$xpath[0]['href'], $svg_path);
|
||||
$this->assertEqual((string)$xpath[0]['href'], $absolute_path);
|
||||
$this->assertNotEqual((string) $xpath[0]['href'], $svg_path);
|
||||
$this->assertEqual((string) $xpath[0]['href'], $absolute_path);
|
||||
|
||||
// Before proceeding, clear the site's caches.
|
||||
drupal_flush_all_caches();
|
||||
|
||||
// Test filling in an absolute path for an external file
|
||||
// Test filling in an absolute path for an external file.
|
||||
$path = 'https://www.example.com/example.svg';
|
||||
$config = metatag_config_load('global');
|
||||
$config->config['mask-icon']['value'] = $path;
|
||||
@@ -129,8 +134,8 @@ class MetatagFaviconsTest extends MetatagTestHelper {
|
||||
// Confirm the meta tag is present.
|
||||
$xpath = $this->xpath("//link[@rel='mask-icon']");
|
||||
$this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.');
|
||||
$this->assertNotEqual((string)$xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string)$xpath[0]['href'], $path);
|
||||
$this->assertNotEqual((string) $xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string) $xpath[0]['href'], $path);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -161,8 +166,8 @@ class MetatagFaviconsTest extends MetatagTestHelper {
|
||||
// Confirm the meta tag is present.
|
||||
$xpath = $this->xpath("//link[@rel='mask-icon']");
|
||||
$this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.');
|
||||
$this->assertEqual((string)$xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string)$xpath[0]['color'], $color);
|
||||
$this->assertEqual((string) $xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string) $xpath[0]['color'], $color);
|
||||
|
||||
// Before proceeding, clear the site's caches.
|
||||
drupal_flush_all_caches();
|
||||
@@ -183,8 +188,8 @@ class MetatagFaviconsTest extends MetatagTestHelper {
|
||||
// Confirm the meta tag is present.
|
||||
$xpath = $this->xpath("//link[@rel='mask-icon']");
|
||||
$this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.');
|
||||
$this->assertEqual((string)$xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string)$xpath[0]['color'], $color);
|
||||
$this->assertEqual((string) $xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string) $xpath[0]['color'], $color);
|
||||
|
||||
// Try a color RGB value.
|
||||
$color = 'rgb(153, 0, 0)';
|
||||
@@ -202,8 +207,8 @@ class MetatagFaviconsTest extends MetatagTestHelper {
|
||||
// Confirm the meta tag is present.
|
||||
$xpath = $this->xpath("//link[@rel='mask-icon']");
|
||||
$this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.');
|
||||
$this->assertEqual((string)$xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string)$xpath[0]['color'], $color);
|
||||
$this->assertEqual((string) $xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string) $xpath[0]['color'], $color);
|
||||
|
||||
// Try empty color.
|
||||
$color = '';
|
||||
@@ -221,7 +226,7 @@ class MetatagFaviconsTest extends MetatagTestHelper {
|
||||
// Confirm the meta tag is present.
|
||||
$xpath = $this->xpath("//link[@rel='mask-icon']");
|
||||
$this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.');
|
||||
$this->assertEqual((string)$xpath[0]['href'], $absolute_path);
|
||||
$this->assertEqual((string) $xpath[0]['href'], $absolute_path);
|
||||
$this->assertFalse(isset($xpath[0]['color']));
|
||||
}
|
||||
|
||||
|
@@ -8,9 +8,8 @@ dependencies[] = metatag:metatag
|
||||
files[] = tests/metatag_google_cse.test
|
||||
files[] = tests/metatag_google_cse.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation and update scripts for Metatag:Google CSE.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag:Google CSE.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:Google CSE.
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag Google CSE tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag Google CSE tags work correctly.
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag Google CSE module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag Google CSE module.
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag controller for Google+.
|
||||
|
@@ -11,9 +11,8 @@ files[] = metatag_google_plus.inc
|
||||
files[] = tests/metatag_google_plus.test
|
||||
files[] = tests/metatag_google_plus.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Various update scripts for Metatag: Google Plus.
|
||||
@@ -22,3 +23,11 @@ function metatag_google_plus_install() {
|
||||
function metatag_google_plus_update_7100() {
|
||||
drupal_set_message(t("Note that the template's html.tpl.php must be updated in order for the Metatag: Google+ module to work correctly. Please see its README.txt file for details."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function metatag_google_plus_uninstall() {
|
||||
// Remove all of the maxlength variables.
|
||||
variable_del('metatag_maxlength_itemprop:description');
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag Google+ module.
|
||||
@@ -111,11 +112,13 @@ function metatag_google_plus_metatag_info() {
|
||||
$info['tags']['itemprop:name'] = array(
|
||||
'label' => t('Title'),
|
||||
'description' => t('A Google+ title for the page being shared. Keep keywords towards the front.'),
|
||||
'maxlength' => 0,
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['itemprop:description'] = array(
|
||||
'label' => t('Description'),
|
||||
'description' => t('Longer form description, you’ve 200 words here that can specifically reference your presence on Google+'),
|
||||
'maxlength' => 0,
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['itemprop:image'] = array(
|
||||
@@ -149,6 +152,5 @@ function metatag_google_plus_metatag_info() {
|
||||
),
|
||||
) + $defaults;
|
||||
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag: Google+.
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag GooglePlus tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag GooglePlus tags work correctly.
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag GooglePlus module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag GooglePlus module.
|
||||
*/
|
||||
|
@@ -17,9 +17,8 @@ test_dependencies[] = devel:devel
|
||||
test_dependencies[] = entity_translation:entity_translation
|
||||
files[] = tests/metatag_hreflang.with_entity_translation.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Various update scripts for Metatag:hrelang.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag:hreflang module.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:hreflang.
|
||||
@@ -6,7 +7,6 @@
|
||||
|
||||
// @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().
|
||||
*/
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag module to ensure the hreflang meta tags work correctly.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Custom tokens for Metatag:hreflang.
|
||||
@@ -17,7 +18,7 @@ function metatag_hreflang_token_info() {
|
||||
// Don't do anything if the patch was applied to Entity Translation to add
|
||||
// these.
|
||||
// @see https://www.drupal.org/node/2603056
|
||||
if (module_load_include('tokens.inc', 'entity_translation')) {
|
||||
if (module_exists('entity_translation') && module_load_include('tokens.inc', 'entity_translation')) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,27 +59,53 @@ function metatag_hreflang_tokens($type, $tokens, array $data = array(), array $o
|
||||
// Shortcuts.
|
||||
$node = $data['node'];
|
||||
|
||||
// Only generate tokens if there are multiple translations.
|
||||
if (isset($node->translations) && !empty($node->translations->data)) {
|
||||
$languages = language_list('enabled');
|
||||
if (!empty($languages[1]) && is_array($languages[1]) && count($languages[1]) > 1) {
|
||||
foreach ($tokens as $name => $original) {
|
||||
// The original entity's URL.
|
||||
if ($name == 'url-original') {
|
||||
if (isset($node->translations->original, $languages[1][$node->translations->original])) {
|
||||
$url_options = $options;
|
||||
$url_options['language'] = $languages[1][$node->translations->original];
|
||||
$url_options['absolute'] = TRUE;
|
||||
$replacements[$original] = url('node/' . $node->nid, $url_options);
|
||||
$languages = language_list('enabled');
|
||||
if (!empty($languages[1]) && is_array($languages[1]) && count($languages[1]) > 1) {
|
||||
foreach ($tokens as $name => $original) {
|
||||
// The original entity's URL.
|
||||
if ($name == 'url-original') {
|
||||
// Basic options regardless of the translation mechanism used.
|
||||
$url_options = $options;
|
||||
$url_options['absolute'] = TRUE;
|
||||
|
||||
// Core's content translation.
|
||||
if (!empty($node->tnid)) {
|
||||
$node_original = node_load($node->tnid);
|
||||
// Only deal with published nodes.
|
||||
if ($node_original->status) {
|
||||
$url_options['language'] = $languages[1][$node_original->language];
|
||||
$replacements[$original] = url('node/' . $node_original->nid, $url_options);
|
||||
}
|
||||
}
|
||||
// Entity Translation stores the translation data differently to core.
|
||||
elseif (isset($node->translations, $node->translations->original, $languages[1][$node->translations->original])) {
|
||||
$url_options['language'] = $languages[1][$node->translations->original];
|
||||
$replacements[$original] = url('node/' . $node->nid, $url_options);
|
||||
}
|
||||
}
|
||||
|
||||
// Separate URLs for each translation.
|
||||
foreach ($node->translations->data as $langcode => $translation) {
|
||||
if ($name == 'url-' . $langcode) {
|
||||
// Separate URLs for each translation.
|
||||
// Core's content translation.
|
||||
if (!empty($node->tnid)) {
|
||||
$translations = translation_node_get_translations($node->tnid);
|
||||
foreach ($translations as $langcode => $translation) {
|
||||
// Only deal with published nodes.
|
||||
if ($translation->status && $name == 'url-' . $langcode) {
|
||||
$url_options = $options;
|
||||
$url_options['language'] = $languages[1][$langcode];
|
||||
$url_options['absolute'] = TRUE;
|
||||
$url_options['language'] = $languages[1][$langcode];
|
||||
$replacements[$original] = url('node/' . $translation->nid, $url_options);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Entity Translation.
|
||||
elseif (isset($node->translations, $node->translations->data)) {
|
||||
foreach ($node->translations->data as $langcode => $translation) {
|
||||
// Only deal with published nodes.
|
||||
if ($translation['status'] && $name == 'url-' . $langcode) {
|
||||
$url_options = $options;
|
||||
$url_options['absolute'] = TRUE;
|
||||
$url_options['language'] = $languages[1][$langcode];
|
||||
$replacements[$original] = url('node/' . $node->nid, $url_options);
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag Hreflang tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag Hreflang tags work correctly.
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag HrefLang module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag HrefLang module.
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for hreflang handle when Entity Translation is used.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for hreflang handle when Entity Translation is used.
|
||||
*/
|
||||
@@ -114,7 +119,7 @@ class MetatagHreflangWithEntityTranslationTest extends MetatagTestHelper {
|
||||
// Confirm each of the support locales has its own field and the appropriate
|
||||
// default value.
|
||||
foreach ($this->supportedLocales() as $langcode) {
|
||||
$this->assertFieldByName("metatags[{$form_langcode}][hreflang_{$langcode}][value]", "[node:url-{$langcode}]", format_string('Found the hreflang field for the "%lang" locale and it has the correct default value.', array('%lang' => $langcode)));
|
||||
$this->assertFieldByName("metatags[{$form_langcode}][hreflang_{$langcode}][default]", "[node:url-{$langcode}]", format_string('Found the hreflang field for the "%lang" locale and it has the correct default value.', array('%lang' => $langcode)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +132,7 @@ class MetatagHreflangWithEntityTranslationTest extends MetatagTestHelper {
|
||||
$this->assertResponse(200);
|
||||
|
||||
// Confirm the fields exist.
|
||||
$this->assertHreflangFields();
|
||||
$this->assertHreflangFields('en');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -236,12 +241,12 @@ class MetatagHreflangWithEntityTranslationTest extends MetatagTestHelper {
|
||||
// The node's default language should not have been found, it should have
|
||||
// been turned into an xdefault.
|
||||
if ($langcode == $node->language) {
|
||||
$this->assertFalse((bool)$found, format_string("A regular hreflang meta tag for the node's default language (%lang) was not found.", array('%lang' => $langcode)));
|
||||
$this->assertFalse((bool) $found, format_string("A regular hreflang meta tag for the node's default language (%lang) was not found.", array('%lang' => $langcode)));
|
||||
}
|
||||
|
||||
// Translations should have been found.
|
||||
else {
|
||||
$this->assertTrue((bool)$found, format_string('The hreflang meta tag for %lang was found.', array('%lang' => $langcode)));
|
||||
$this->assertTrue((bool) $found, format_string('The hreflang meta tag for %lang was found.', array('%lang' => $langcode)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,7 +274,7 @@ class MetatagHreflangWithEntityTranslationTest extends MetatagTestHelper {
|
||||
$found = $ctr;
|
||||
}
|
||||
}
|
||||
$this->assertTrue((bool)$found, "Found an hreflang meta tag for the node's default locale.");
|
||||
$this->assertTrue((bool) $found, "Found an hreflang meta tag for the node's default locale.");
|
||||
if ($found) {
|
||||
$this->assertEqual($xpath[$found]['hreflang'], $node->language);
|
||||
}
|
||||
|
@@ -3,23 +3,32 @@ Metatag: Importer
|
||||
This module imports data from other modules. An administrative interface is
|
||||
provided (admin/config/search/metatags/importer), as well as a series of Drush
|
||||
commands:
|
||||
* metatag-convert-page-title - Convert data from the Page Title module.
|
||||
|
||||
* metatag-convert-metatags-quick / mtcmq
|
||||
Convert data from the Metatags Quick module.
|
||||
|
||||
* metatag-convert-nodewords / mtcnw
|
||||
Convert data from the Nodewords module.
|
||||
|
||||
* metatag-convert-page-title / mtcpt
|
||||
Convert data from the Page Title module.
|
||||
|
||||
|
||||
Known Issues
|
||||
--------------------------------------------------------------------------------
|
||||
- The admin page (currently) only supports migrating data from Nodewords.
|
||||
- The Drush commands (currently) only supports migrating data from Page Title.
|
||||
- The admin page (currently) only supports migrating data from Nodewords and
|
||||
Page Title.
|
||||
- Only entities are currently supported, other configuration types will be
|
||||
supported soon.
|
||||
|
||||
|
||||
Credits / Contact
|
||||
--------------------------------------------------------------------------------
|
||||
Currently maintained by Damien McKenna [1]. Originally developed by jantoine [2]
|
||||
with contributions by drupalninja99 [3], stuart.crouch [4], subhojit777 [5],
|
||||
KarlShea [6], stefan.r [7], HyperGlide [8] and jenlampton [9].
|
||||
|
||||
Currently maintained by Damien McKenna [1]. Originally developed by Jon Antoine
|
||||
[2] with contributions by Jay Callicott [3], Stuart Crouch [4], Subhojit Paul
|
||||
[5], Karl Shea [6], Stefan Ruijsenaars [7], HyperGlide [8], Jen Lampton [9],
|
||||
Eric Peterson [10], Lars Schröter [11], Victoria Chan [12], Malcolm Young [13],
|
||||
Alexey Korepov [14], klokie [15] and Dan Ficker [16].
|
||||
|
||||
|
||||
References
|
||||
@@ -33,3 +42,10 @@ References
|
||||
7: https://www.drupal.org/u/stefan.r
|
||||
8: https://www.drupal.org/u/hyperglide
|
||||
9: https://www.drupal.org/u/jenlampton
|
||||
10: https://www.drupal.org/u/iameap
|
||||
11: https://www.drupal.org/u/osopolar
|
||||
12: https://www.drupal.org/u/victoriachan
|
||||
13: https://www.drupal.org/u/malcomio
|
||||
14: https://www.drupal.org/u/murz
|
||||
15: https://www.drupal.org/u/klokie
|
||||
16: https://www.drupal.org/u/dandaman
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Starter page.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Drush integration for the Metatag Importer module.
|
||||
@@ -8,20 +9,39 @@
|
||||
* Implements hook_drush_command().
|
||||
*/
|
||||
function metatag_importer_drush_command() {
|
||||
// This needs to be fixed.
|
||||
// $items['metatag-convert-nodewords'] = array(
|
||||
// 'description' => dt('Convert data from Nodewords into Metatag.'),
|
||||
// 'drupal dependencies' => array('metatag'),
|
||||
// );
|
||||
$items['metatag-convert-metatags-quick'] = array(
|
||||
'description' => dt('Convert data from Metatags Quick into Metatag'),
|
||||
'drupal dependencies' => array('metatag', 'metatag_importer'),
|
||||
'aliases' => array('mtcmq'),
|
||||
);
|
||||
|
||||
$items['metatag-convert-nodewords'] = array(
|
||||
'description' => dt('Convert data from Nodewords into Metatag.'),
|
||||
'drupal dependencies' => array('metatag', 'metatag_importer'),
|
||||
'aliases' => array('mtcnw'),
|
||||
);
|
||||
|
||||
$items['metatag-convert-page-title'] = array(
|
||||
'description' => dt('Convert data from Page Title into Metatag.'),
|
||||
'drupal dependencies' => array('metatag'),
|
||||
'drupal dependencies' => array('metatag', 'metatag_importer'),
|
||||
'aliases' => array('mtcpt'),
|
||||
);
|
||||
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to convert all Metatags Quick data.
|
||||
*/
|
||||
function drush_metatag_importer_metatag_convert_metatags_quick() {
|
||||
if (!drush_confirm(dt('Ready to convert all data from Metatags Quick?'))) {
|
||||
return;
|
||||
}
|
||||
|
||||
include 'metatag_importer.metatags_quick.inc';
|
||||
metatag_importer_metatags_quick_import();
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to convert all Nodewords data.
|
||||
*/
|
||||
@@ -32,16 +52,16 @@ function drush_metatag_importer_metatag_convert_nodewords() {
|
||||
|
||||
// Need to make sure the Nodewords table actually exists.
|
||||
if (!db_table_exists('nodewords')) {
|
||||
drush_set_error('metatag_importer', dt('Could not find the nodewords table.'));
|
||||
drush_set_error('metatag_importer', dt('Could not find the nodewords table!'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Offload all of the logic to the code contained in the admin file.
|
||||
include('metatag_importer.nodewords.inc');
|
||||
include 'metatag_importer.nodewords.inc';
|
||||
|
||||
// Start the import.
|
||||
// @todo This isn't working.
|
||||
_metatag_importer_import();
|
||||
$types = array_keys(_metatag_importer_list_nodewords());
|
||||
_metatag_importer_import($types);
|
||||
|
||||
drush_print(dt('Data converesion finished.'));
|
||||
}
|
||||
@@ -65,7 +85,7 @@ function drush_metatag_importer_metatag_convert_page_title() {
|
||||
return;
|
||||
}
|
||||
|
||||
include('metatag_importer.page_title.inc');
|
||||
include 'metatag_importer.page_title.inc';
|
||||
|
||||
// Start the importer.
|
||||
$count = metatag_importer_for_page_title();
|
||||
|
@@ -9,9 +9,8 @@ dependencies[] = metatag:metatag
|
||||
; Tests.
|
||||
files[] = tests/metatag_importer.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -0,0 +1,225 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Convert data from Metatags Quick to Metatag.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Import all data from Metatags Quick and delete it.
|
||||
*/
|
||||
function metatag_importer_metatags_quick_import() {
|
||||
// Get a list of Metatags Quick fields.
|
||||
$fields = metatag_importer_get_quick_fields();
|
||||
|
||||
$message = 'Converting records from @count Metatags Quick field(s).';
|
||||
$vars = array('@count' => count($data));
|
||||
if (drupal_is_cli() && function_exists('drush_print')) {
|
||||
drush_print(dt($message, $vars));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t($message, $vars));
|
||||
}
|
||||
|
||||
// Get all of the data for these fields.
|
||||
$data = metatag_importer_get_quick_data($fields);
|
||||
|
||||
// Process the data.
|
||||
foreach ($data as $quick) {
|
||||
$message = 'Converting @count records from Metatags Quick..';
|
||||
$vars = array('@count' => count($quick));
|
||||
if (drupal_is_cli() && function_exists('drush_print')) {
|
||||
drush_print(dt($message, $vars));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t($message, $vars));
|
||||
}
|
||||
|
||||
metatag_importer_metatags_quick_process($quick);
|
||||
}
|
||||
|
||||
if (drupal_is_cli() && function_exists('drush_print')) {
|
||||
drush_print(dt('All done!'));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('All done!'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a row from Metatags Quick.
|
||||
*
|
||||
* Imports data into metatag structure, and deletes Metatags Quick data.
|
||||
*
|
||||
* @param array $quick
|
||||
* Row of data from Metatags Quick.
|
||||
*/
|
||||
function metatag_importer_metatags_quick_process(array $quick) {
|
||||
// Identify which Metatag meta tags will be filled by Metatags Quick values.
|
||||
$tag_map = array(
|
||||
'title' => 'title',
|
||||
'keywords' => 'keywords',
|
||||
'abstract' => 'abstract',
|
||||
'description' => 'description',
|
||||
'canonical' => 'canonical',
|
||||
);
|
||||
if (module_exists('metatag_opengraph')) {
|
||||
$tag_map['og:title'] = 'title';
|
||||
$tag_map['og:description'] = 'description';
|
||||
}
|
||||
if (module_exists('metatag_twitter_cards')) {
|
||||
$tag_map['twitter:title'] = 'title';
|
||||
$tag_map['twitter:description'] = 'description';
|
||||
}
|
||||
|
||||
$entity_type = $quick['entity_type'];
|
||||
$entity_id = $quick['entity_id'];
|
||||
$revision_id = $quick['revision_id'];
|
||||
$langcode = $quick['language'];
|
||||
|
||||
// Fallback to entity language if no field language is set.
|
||||
if (LANGUAGE_NONE == $langcode) {
|
||||
$entities = entity_load($entity_type, array($entity_id));
|
||||
if (!empty($entities[$entity_id])) {
|
||||
$langcode = entity_language($entity_type, $entities[$entity_id]);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for an existing record.
|
||||
$data = metatag_metatags_load($entity_type, $entity_id);
|
||||
|
||||
// Drop back one level because the results will be keyed by revision_id.
|
||||
if (!empty($data)) {
|
||||
$data = reset($data);
|
||||
}
|
||||
|
||||
// Map the Quick meta tags.
|
||||
foreach ($tag_map as $dest => $source) {
|
||||
if (!empty($quick['fields'][$source]['value'])) {
|
||||
$data[$langcode][$dest] = array('value' => $quick['fields'][$source]['value']);
|
||||
// Add the default suffix to the page title.
|
||||
if ($dest == 'title') {
|
||||
$data[$langcode][$dest]['value'] .= ' | [site:name]';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create or update the {metatag} record.
|
||||
if (!empty($data)) {
|
||||
metatag_metatags_save($entity_type, $entity_id, $revision_id, $data);
|
||||
}
|
||||
|
||||
if (!empty($quick['fields'])) {
|
||||
metatag_importer_delete_quick_data($quick['fields']);
|
||||
}
|
||||
|
||||
// Reset the entity cache. If entitycache module is used, this also resets
|
||||
// its permanent cache.
|
||||
entity_get_controller($entity_type)->resetCache(array($entity_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all fields from Metatags Quick.
|
||||
*
|
||||
* @return array
|
||||
* Array of field names, keyed by name.
|
||||
*/
|
||||
function metatag_importer_get_quick_fields() {
|
||||
$fields = array();
|
||||
|
||||
// Get a list of all entities that use a Metatags Quick field.
|
||||
foreach (field_info_instances() as $entity_type => $bundles) {
|
||||
// Skip the custon entity type provided by Metatags Quick.
|
||||
if ($entity_type == 'metatags_path_based') {
|
||||
continue;
|
||||
}
|
||||
foreach ($bundles as $bundle_name => $bundle) {
|
||||
foreach ($bundle as $field_name => $field) {
|
||||
if ($field['widget']['module'] == 'metatags_quick') {
|
||||
$fields[$field_name] = $field_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get metatags_quick data from the database.
|
||||
*
|
||||
* @param array $fields
|
||||
* Array of field names.
|
||||
*
|
||||
* @return array
|
||||
* Metadata
|
||||
*/
|
||||
function metatag_importer_get_quick_data(array $fields) {
|
||||
$data = array();
|
||||
foreach ($fields as $field_name) {
|
||||
$meta_tag = str_replace('meta_', '', str_replace('field_', '', $field_name));
|
||||
$results = db_select('field_data_' . $field_name, 'f')
|
||||
->fields('f', array(
|
||||
'entity_type',
|
||||
'bundle',
|
||||
'entity_id',
|
||||
'revision_id',
|
||||
'language',
|
||||
$field_name . '_metatags_quick',
|
||||
))
|
||||
->condition('f.entity_type', array('metatags_path_based'), '<>')
|
||||
->orderBy('f.entity_type', 'ASC')
|
||||
->orderBy('f.entity_id', 'ASC')
|
||||
->orderBy('f.revision_id', 'ASC')
|
||||
->execute();
|
||||
|
||||
foreach ($results as $result) {
|
||||
$id = implode(':', array(
|
||||
$result->entity_type,
|
||||
$result->entity_id,
|
||||
$result->revision_id,
|
||||
$result->language,
|
||||
));
|
||||
|
||||
if (!isset($data[$id])) {
|
||||
$data[$id] = array(
|
||||
'entity_type' => $result->entity_type,
|
||||
'bundle' => $result->bundle,
|
||||
'entity_id' => $result->entity_id,
|
||||
'revision_id' => $result->revision_id,
|
||||
'language' => $result->language,
|
||||
'fields' => array(),
|
||||
);
|
||||
}
|
||||
$data[$id]['fields'][$meta_tag] = array(
|
||||
'field_name' => $field_name,
|
||||
'value' => $result->{$field_name . '_metatags_quick'},
|
||||
'meta_tag' => $meta_tag,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the old metatags_quick records.
|
||||
*
|
||||
* @param array $quick
|
||||
* Records to delete.
|
||||
*/
|
||||
function metatag_importer_delete_quick_data(array $quick) {
|
||||
foreach ($quick as $field) {
|
||||
db_delete('field_data_' . $field['field_name'])
|
||||
->condition('entity_type', $quick['entity_type'])
|
||||
->condition('entity_id', $quick['entity_id'])
|
||||
->condition('language', $quick['language'])
|
||||
->execute();
|
||||
|
||||
db_delete('field_revision_' . $field['field_name'])
|
||||
->condition('entity_type', $quick['entity_type'])
|
||||
->condition('entity_id', $quick['entity_id'])
|
||||
->condition('language', $quick['language'])
|
||||
->execute();
|
||||
}
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations.
|
||||
|
@@ -6,16 +6,16 @@
|
||||
*/
|
||||
|
||||
// The Nodwords record types.
|
||||
define('NODEWORDS_TYPE_DEFAULT', 1);
|
||||
define('NODEWORDS_TYPE_ERRORPAGE', 2);
|
||||
define('NODEWORDS_TYPE_FRONTPAGE', 3);
|
||||
define('NODEWORDS_TYPE_NONE', 0);
|
||||
define('NODEWORDS_TYPE_NODE', 5);
|
||||
define('NODEWORDS_TYPE_PAGE', 10);
|
||||
define('NODEWORDS_TYPE_PAGER', 4);
|
||||
define('NODEWORDS_TYPE_TERM', 6);
|
||||
define('NODEWORDS_TYPE_TRACKER', 7);
|
||||
define('NODEWORDS_TYPE_USER', 8);
|
||||
define('NODEWORDS_TYPE_DEFAULT', 1);
|
||||
define('NODEWORDS_TYPE_ERRORPAGE', 2);
|
||||
define('NODEWORDS_TYPE_FRONTPAGE', 3);
|
||||
define('NODEWORDS_TYPE_NONE', 0);
|
||||
define('NODEWORDS_TYPE_NODE', 5);
|
||||
define('NODEWORDS_TYPE_PAGE', 10);
|
||||
define('NODEWORDS_TYPE_PAGER', 4);
|
||||
define('NODEWORDS_TYPE_TERM', 6);
|
||||
define('NODEWORDS_TYPE_TRACKER', 7);
|
||||
define('NODEWORDS_TYPE_USER', 8);
|
||||
define('NODEWORDS_TYPE_VOCABULARY', 9);
|
||||
|
||||
/**
|
||||
@@ -32,7 +32,6 @@ function metatag_importer_nodewords_form($form, &$form_state) {
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Records to import'),
|
||||
'#options' => $types,
|
||||
'#disabled' => TRUE,
|
||||
);
|
||||
|
||||
$form['notes'] = array(
|
||||
@@ -128,16 +127,28 @@ function _metatag_importer_list_nodewords() {
|
||||
function _metatag_importer_import(array $types = array()) {
|
||||
$batch = array(
|
||||
'title' => t('Importing Nodewords data..'),
|
||||
'init_message' => t('Nodewords import is starting.'),
|
||||
'progress_message' => t('Processed @current out of @total.'),
|
||||
'error_message' => t('Nodewords import has encountered an error.'),
|
||||
'operations' => array(
|
||||
array('_metatag_importer_migrate', array($types)),
|
||||
),
|
||||
'finished' => '_metatag_importer_finished',
|
||||
'file' => drupal_get_path('module', 'metatag_importer') . '/metatag_importer.nodewords.inc',
|
||||
);
|
||||
batch_set($batch);
|
||||
|
||||
// Kick off the batch.
|
||||
batch_process();
|
||||
// Kick off the batch, using Drush if available.
|
||||
if (drupal_is_cli() && function_exists('drush_backend_batch_process')) {
|
||||
// Add some special magic for CLI before setting the batch.
|
||||
$batch['progressive'] = FALSE;
|
||||
batch_set($batch);
|
||||
// Process the batch.
|
||||
drush_backend_batch_process();
|
||||
}
|
||||
else {
|
||||
batch_set($batch);
|
||||
batch_process();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +238,6 @@ function _metatag_importer_migrate(array $types = array(), &$context = array())
|
||||
// Process the meta tag value, possibly also rename the meta tag name
|
||||
// itself.
|
||||
list($meta_tag, $value) = _metatag_importer_convert_data($result->name, unserialize($result->content));
|
||||
|
||||
// Don't import empty values.
|
||||
if (!empty($value)) {
|
||||
// Add the value to the stack.
|
||||
@@ -287,13 +297,13 @@ function _metatag_importer_migrate(array $types = array(), &$context = array())
|
||||
metatag_config_save($config);
|
||||
break;
|
||||
|
||||
// // 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);
|
||||
// break;
|
||||
// @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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,9 +318,26 @@ function _metatag_importer_migrate(array $types = array(), &$context = array())
|
||||
$context['finished'] = (empty($context['sandbox']['max']) || $context['sandbox']['progress'] >= $context['sandbox']['max']) ? TRUE : ($context['sandbox']['progress'] / $context['sandbox']['max']);
|
||||
|
||||
if ($context['finished'] === TRUE) {
|
||||
drupal_set_message(t('Imported @imported Nodewords records.', array('@imported' => $context['sandbox']['progress'])));
|
||||
$message = 'Imported @imported Nodewords records.';
|
||||
$vars = array('@imported' => $context['sandbox']['progress']);
|
||||
|
||||
if (drupal_is_cli() && function_exists('drush_print')) {
|
||||
drush_print(dt($message, $vars));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t($message, $vars));
|
||||
}
|
||||
|
||||
if (!empty($context['sandbox']['skipped'])) {
|
||||
drupal_set_message(t('@skipped records were skipped because the corresponding entities were previously deleted.', array('@skipped' => count($context['sandbox']['skipped']))));
|
||||
$message = '@skipped records were skipped because the corresponding entities were previously deleted.';
|
||||
$vars = array('@skipped' => count($context['sandbox']['skipped']));
|
||||
|
||||
if (drupal_is_cli() && function_exists('drush_print')) {
|
||||
drush_print(dt($message, $vars));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t($message, $vars));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,22 +347,35 @@ function _metatag_importer_migrate(array $types = array(), &$context = array())
|
||||
*/
|
||||
function _metatag_importer_finished($success, $results, $operations) {
|
||||
if ($success) {
|
||||
// Here we do something meaningful with the results.
|
||||
$message = t("!count items were processed.", array(
|
||||
'!count' => count($results),
|
||||
));
|
||||
$message .= theme('item_list', array('items' => $results));
|
||||
drupal_set_message($message);
|
||||
if (drupal_is_cli() && function_exists('drush_print')) {
|
||||
// Make a bulleted list of messages for the command line.
|
||||
foreach ($results as $result) {
|
||||
drush_print(dt('* ' . $result));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Make a bulleted list of messages for the browser.
|
||||
$message = theme('item_list', array('items' => $results));
|
||||
drupal_set_message(t($message));
|
||||
}
|
||||
}
|
||||
else {
|
||||
// An error occurred.
|
||||
// $operations contains the operations that remained unprocessed.
|
||||
$error_operation = reset($operations);
|
||||
$message = t('An error occurred while processing %error_operation with arguments: @arguments', array(
|
||||
$message = 'An error occurred while processing %error_operation';
|
||||
$vars = array(
|
||||
'%error_operation' => $error_operation[0],
|
||||
'@arguments' => print_r($error_operation[1], TRUE),
|
||||
));
|
||||
drupal_set_message($message, 'error');
|
||||
);
|
||||
|
||||
if (drupal_is_cli() && function_exists('drush_print')) {
|
||||
drush_set_error('metatag_importer', dt($message, $vars));
|
||||
}
|
||||
else {
|
||||
$message .= ' with arguments: @arguments';
|
||||
$vars[] = array('@arguments' => print_r($error_operation[1], TRUE));
|
||||
drupal_set_message(t($message, $vars), 'error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,10 +427,9 @@ function _metatag_importer_convert_type($type) {
|
||||
case 8:
|
||||
return 'user';
|
||||
|
||||
// @todo Vocabulary records need to be converted to a config for that entity
|
||||
// bundle.
|
||||
// case 9:
|
||||
// return 'vocabulary';
|
||||
// Vocabulary records convert into a config for that entity bundle.
|
||||
case 9:
|
||||
return 'vocabulary';
|
||||
|
||||
// @todo Page records need to be converted to Context definitions.
|
||||
// case 10:
|
||||
@@ -536,7 +575,6 @@ function _metatag_importer_convert_data($name, $value) {
|
||||
// 0 - NODEWORDS_GENERATION_NEVER - never auto-generate the string.
|
||||
// 1 - NODEWORDS_GENERATION_WHEN_EMPTY - when the field is empty. Default.
|
||||
// 2 - NODEWORDS_GENERATION_ALWAYS - always use the generated string.
|
||||
|
||||
// 'nodewords_metatags_generation_method_' . $type:
|
||||
// 1 - NODEWORDS_GENERATION_BODY - use the body field.
|
||||
// 2 - NODEWORDS_GENERATION_TEASER - use the node teaser. Default.
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Functionality for migrating data from the Page Title module.
|
||||
@@ -38,12 +39,20 @@ function metatag_importer_for_page_title() {
|
||||
$skipped = array();
|
||||
|
||||
// Loop over each of the page_title records.
|
||||
$entity_info = entity_get_info();
|
||||
while ($pt_data = $page_titles->fetchObject()) {
|
||||
$entity_type = $pt_data->type;
|
||||
$entity_id = $pt_data->id;
|
||||
|
||||
// Load the entity.
|
||||
$entity = entity_load($entity_type, array($entity_id));
|
||||
if ($entity_type == 'term') {
|
||||
// Use the proper class name instead of what's in the page_title table.
|
||||
$entity_type = 'taxonomy_term';
|
||||
}
|
||||
|
||||
$entity = array();
|
||||
if (array_key_exists($entity_type, $entity_info)) {
|
||||
$entity = entity_load($entity_type, array($entity_id));
|
||||
}
|
||||
if (empty($entity)) {
|
||||
$skipped[] = $entity_type . ':' . $entity_id;
|
||||
continue;
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag Importer module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag Importer module.
|
||||
*/
|
||||
|
@@ -8,9 +8,8 @@ dependencies[] = metatag:metatag
|
||||
files[] = tests/metatag_mobile.test
|
||||
files[] = tests/metatag_mobile.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag:Facebook module.
|
||||
@@ -128,7 +129,7 @@ function metatag_mobile_metatag_info() {
|
||||
$info['tags']['apple-mobile-web-app-title'] = array(
|
||||
'label' => t('Apple Mobile Web App Title'),
|
||||
'description' => t('Overrides the long site title when using the Apple Add to Home Screen.'),
|
||||
'weight' => ++$weight
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
|
||||
$info['tags']['format-detection'] = array(
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:Mobile.
|
||||
@@ -78,13 +79,13 @@ function theme_metatag_mobile_alt_handheld($variables) {
|
||||
}
|
||||
|
||||
/*
|
||||
* theme-color
|
||||
* MobileOptimized
|
||||
* HandheldFriendly
|
||||
* viewport
|
||||
* cleartype
|
||||
* apple-mobile-web-app-capable
|
||||
* apple-mobile-web-app-status-bar-style
|
||||
* format-detection
|
||||
* android-app
|
||||
*/
|
||||
* theme-color
|
||||
* MobileOptimized
|
||||
* HandheldFriendly
|
||||
* viewport
|
||||
* cleartype
|
||||
* apple-mobile-web-app-capable
|
||||
* apple-mobile-web-app-status-bar-style
|
||||
* format-detection
|
||||
* android-app
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests that each of the Metatag Mobile tags work correctly.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests that each of the Metatag Mobile tags work correctly.
|
||||
*/
|
||||
|
@@ -1,5 +1,10 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Tests for the Metatag Mobile module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tests for the Metatag Mobile module.
|
||||
*/
|
||||
|
@@ -8,9 +8,8 @@ dependencies[] = metatag:metatag
|
||||
files[] = tests/metatag_opengraph.test
|
||||
files[] = tests/metatag_opengraph.tags.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-02-15
|
||||
version = "7.x-1.21"
|
||||
; Information added by Drupal.org packaging script on 2018-04-04
|
||||
version = "7.x-1.25"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1487171290"
|
||||
|
||||
datestamp = "1522849089"
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Installation and update scripts for Metatag:OpenGraph.
|
||||
@@ -47,6 +48,15 @@ function metatag_opengraph_update_dependencies() {
|
||||
return $dependencies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function metatag_opengraph_uninstall() {
|
||||
// Remove all of the maxlength variables.
|
||||
variable_del('metatag_maxlength_og:title');
|
||||
variable_del('metatag_maxlength_og:description');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementations of hook_update_N().
|
||||
*/
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user