non security modules update
This commit is contained in:
@@ -1,5 +1,178 @@
|
||||
Metatag 7.x-1.x-dev, xxxx-xx-xx
|
||||
Metatag 7.x-1.4, 2014-10-09
|
||||
---------------------------
|
||||
#2353079 by DamienMcKenna: Fixed Views integration, for real this time.
|
||||
#2344877 by DamienMcKenna: Fixed Panels integration, for real this time.
|
||||
|
||||
|
||||
Metatag 7.x-1.3, 2014-10-07
|
||||
---------------------------
|
||||
#2350967 by das-peter, DamienMcKenna: Fatal error occurred loading any View that
|
||||
did not have meta tags assigned.
|
||||
#2344877 by DamienMcKenna, Mau Palantír, libelle2000: Fixed Panels integration.
|
||||
By DamienMcKenna: metatag_metatags_load()'s documentation was incorrect.
|
||||
#2347193 by DamienMcKenna: Updated Feeds integration to be compatible with the
|
||||
new data structures in 1.0, and revision_id problems.
|
||||
|
||||
|
||||
Metatag 7.x-1.2, 2014-10-04
|
||||
---------------------------
|
||||
#2343909 by DamienMcKenna: Unable to update meta tags on nodes that didn't
|
||||
contain translations.
|
||||
#2185791 by DamienMcKenna: Improved logic for deciding which meta tag values
|
||||
to use for the current language; new advanced option allows loading of the
|
||||
entity's default language's values if nothing else matches.
|
||||
#2346159 by DamienMcKenna: Fixed tag dependencies, which were broken in 1.0.
|
||||
#2346153 by DamienMcKenna: Added Twitter app 'name' tags, misc improvements to
|
||||
Twitter Cards code.
|
||||
#2185791 by DamienMcKenna: Changed the no-values-to-load entity language default
|
||||
logic so that the default language values will be loaded unless disabled.
|
||||
#1304038 by DamienMcKenna: Indicate in the README.txt how to disable output for
|
||||
the three meta tags output by Drupal core by default.
|
||||
#2350129 by DamienMcKenna: Added a Drush command for clearing Metatag's caches.
|
||||
#2341795 by DamienMcKenna: Updated Metatag:Views to be compatible with the new
|
||||
form data structure in 1.0.
|
||||
#2292043 by eric.chenchao, DamienMcKenna: Added Google+ 'itemprop' meta tags.
|
||||
#2341795 by DamienMcKenna: Fixed Views previews.
|
||||
#2289139 by maijs, DamienMcKenna: Allow each Views display to have different
|
||||
meta tag values.
|
||||
|
||||
|
||||
Metatag 7.x-1.1, 2014-09-18
|
||||
---------------------------
|
||||
#2340639 by agoradesign: Additional check needed in hook_requirements to avoid
|
||||
breaking installation profiles.
|
||||
#2340337 by DamienMcKenna: Config system updated for the new language-based
|
||||
data handling.
|
||||
#2330823 by DamienMcKenna: REVERT: Remove the deprecated G+ Author meta tag.
|
||||
|
||||
|
||||
Metatag 7.x-1.0, 2014-09-17
|
||||
---------------------------
|
||||
#2319389 by DamienMcKenna: Additional Open Graph meta tags, for videos.
|
||||
#2169575 by gvorbeck: Workbench Moderation v2 doesn't need any hackery, so
|
||||
removed the message in hook_requirements().
|
||||
#2140189 by ttkaminski, DamienMcKenna: Added an index to {metatag} table for the
|
||||
'type' and 'revision_id' fields.
|
||||
#1391554 by DamienMcKenna: Handle scenarios where the legacy "metatags" module
|
||||
had been installed.
|
||||
#2325459 by DamienMcKenna: Used JSHint to correct some minor JS bugs.
|
||||
#2326197 by Dave Reid: metatag_generate_entity_metatags() cache can be bypassed.
|
||||
By DamienMcKenna: Updated the og:image size guidelines.
|
||||
By DamienMcKenna: Remove the redundant metatag_taxonomy_term_view_alter().
|
||||
By DamienMcKenna: Support Twitter Cards fieldset in Metatag:Context.
|
||||
#1778286 by alberto56: Removed the deprecated metatag_ui module.
|
||||
#2331677 by othermachines: Updates 7025 and 7027 attempted to update the wrong
|
||||
tables.
|
||||
#2330823 by othermachines: Remove the deprecated G+ Author meta tag.
|
||||
#2186155 by DamienMcKenna, grahamC, JeroenT: Resolved problems when saving an
|
||||
entity directly rather than via entity form.
|
||||
By DamienMcKenna: Corrected the namespace prefix for OG video meta tags.
|
||||
#2186155 by DamienMcKenna: Follow-up to fix a number of scenarios.
|
||||
|
||||
|
||||
Metatag 7.x-1.0-rc2, 2014-08-05
|
||||
-------------------------------
|
||||
#1904266 by mvwensen, DamienMcKenna: Added the dcterms.modified meta tag.
|
||||
#2202031 by DamienMcKenna: Don't double-encode output, handle specially.
|
||||
#2026343 by DamienMcKenna, skruf, valkum, wxman: Added many more Open Graph meta
|
||||
tags.
|
||||
#2164919 by DamienMcKenna: Added an Advanced Settings page.
|
||||
#2241083 by DamienMcKenna: API structure for definiting field dependencies;
|
||||
currently limited to hiding/showing fields, can be expanded later with
|
||||
validation logic. Initial implementation for some Open Graph and Twitter Cards
|
||||
meta tags.
|
||||
#2307523 by leewillis77, DamienMcKenna: Additional arguments for two
|
||||
drupal_alter hooks.
|
||||
#2241083 by rooby: Refactored meta tag output generation using a new function,
|
||||
metatag_generate_entity_metatags(), allowing for the tags to be independently
|
||||
obtained for a given entity.
|
||||
#2262159 by DamienMcKenna: Bumped core requirement to 7.28, removed the
|
||||
[node:summary] fix that's no longer needed.
|
||||
#2306449 by DamienMcKenna: Not having the Transliteration or Imagecache Token
|
||||
modules installed no longer reports an error in hook_requirements().
|
||||
#1328562 by andremolnar, Greg Boggs, DamienMcKenna: Improved form descriptions.
|
||||
#1918706 by theunraveler, DamienMcKenna, Zekvyrin, JeroenT: [current-page:title]
|
||||
didn't work correctly on Panels pages.
|
||||
#2153977 by paolomainardi, DamienMcKenna: Fix for translations of base entity
|
||||
type configuration when there is no bundle configuration.
|
||||
|
||||
|
||||
Metatag 7.x-1.0-rc1, 2014-07-12
|
||||
-------------------------------
|
||||
By DamienMcKenna: Small improvement to the comment on update 7007.
|
||||
#2196393 by generalconsensus, aprohl5: Typo in hook_install().
|
||||
#2237507 by SebCorbin: Only delete all records when editing one entity revision.
|
||||
#2056739 by B-Prod: Incorrect language handling when displaying entity pages
|
||||
using Panels.
|
||||
#2205675 by Romlam, greggles: Typo in variable name caused data to not load.
|
||||
#2265447 by opdavies: Ignore comment entities, conflict with comment_fragment.
|
||||
#2271685 by adee147: Typos in metatag_metatags_cache_clear().
|
||||
#2271811 by DamienMcKenna: Replaced theme_metatag_opengraph() with
|
||||
theme_metatag_property().
|
||||
#1282636 by DamienMcKenna: Support meta tags that allow multiple values; first
|
||||
supported tags are og:image and og:image:secure_url.
|
||||
#2273459 by DamienMcKenna: Improved Twitter Cards default values.
|
||||
#2273241 by DamienMcKenna: Use the new hook_metatag_bundled_config_alter() to
|
||||
load settings from submodules.
|
||||
#2273493 by DamienMcKenna: Improved Dublin Core default values.
|
||||
#2274921 by DamienMcKenna: Token browser link missing on settings pages.
|
||||
#2277787 by eugene.ilyin: Missing translations in metatag_context.
|
||||
By DamienMcKenna: Removed duplicate 'devel_generate' setting for 'image_src'.
|
||||
#2282903 by DamienMcKenna: Special handling for meta tags that need to output a
|
||||
secure URL, replace 'http://' with 'https://'.
|
||||
#2281833 by DamienMcKenna: Ensure multi-item values are output in a consistent
|
||||
order.
|
||||
#2275323 by drastik: Provide link to settings page in Metatag:Context module.
|
||||
#1284810 by DamienMcKenna: Really recommend installing Imagecache Token.
|
||||
#1809356 by DamienMcKenna: Sort all meta tags.
|
||||
#2276361 by DamienMcKenna: Move Facebook meta tags into a separate submodule.
|
||||
#2185943 by fizk: Remove warnings about Exclude Node Title.
|
||||
#2266595 by hefox: Change watchdog() message to a warning not critical, to avoid
|
||||
problems with Jenkins.
|
||||
#2193195 by 75th Trombone: Corrected a variable usage in README.txt.
|
||||
#1338612 by Lasac, DamienMcKenna: Added the content-language meta tag.
|
||||
#2291993 by DamienMcKenna: Duplicate fb meta tags causes lots of errors.
|
||||
#2285787 by SebCorbin: Entity Translation problems with revisions.
|
||||
#2025425 by moonray, David_Rothstein, hefox, DamienMcKenna: Cache improvement
|
||||
to separate entity vs page language.
|
||||
#2186241 by nnevill.io1, DamienMcKenna: Revisions support for Panels.
|
||||
#2051407 by cha0s, DamienMcKenna: Language support for token integration.
|
||||
#2183203 by mikeytown2, juampy, DamienMcKenna: Improved queries in
|
||||
metatag_metatags_load_multiple().
|
||||
#2227377 by DamienMcKenna: taxonomy_vocabulary_load() caused problems when
|
||||
executed during hook_entity_info_alter().
|
||||
#1995564 by DamienMcKenna, willieseabrook: Added a warning about a possible
|
||||
conflict with the Admin Language module.
|
||||
#2298337 by DamienMcKenna: Added an API option to indicate one meta tag replaces
|
||||
another; updated API docs accordingly.
|
||||
#2267501 by DamienMcKenna: Renamed the 'twitter:image' meta tag to the correct
|
||||
'twitter:image:src'.
|
||||
#2121437 by DamienMcKenna: Renamed the 'copyright' meta tag to the correct
|
||||
'rights' tag.
|
||||
#2177455 by DamienMcKenna: Avoid errors when updating from older releases due
|
||||
to missing revision_id field.
|
||||
#2178411 by DamienMcKenna, kporras07: Language not assigned correctly on CTools
|
||||
-based pages.
|
||||
|
||||
|
||||
Metatag 7.x-1.0-beta9, 2014-01-18
|
||||
---------------------------------
|
||||
#2174363 by DamienMcKenna: Changed update 7018 to avoid attempting to create
|
||||
duplicate records when updating; instead should there be a collision the
|
||||
record with revision_id 0 will be deleted.
|
||||
#2176351 by DamienMcKenna: 403 and 404 error pages will use the global default
|
||||
for the page title instead of copying the homepage's.
|
||||
#2175843 by DamienMcKenna: It was possible to get to update 7016 without the
|
||||
revision_id field existing, so make sure it exists.
|
||||
#2081787 by attila.fekete: Don't let Metatag:Views overwrite the frontpage meta
|
||||
tag config, matching how Metatag:Panels works.
|
||||
#2176375 by DamienMcKenna: Added note to README.txt about the Textimage module's
|
||||
compatibility with Metatag.
|
||||
#2170771 by DamienMcKenna: Added support for the og:image:secure_url meta tag.
|
||||
|
||||
|
||||
Metatag 7.x-1.0-beta8, 2014-01-15
|
||||
---------------------------------
|
||||
#1995284 by DamienMcKenna: Replace $_SERVER['REQUEST_URI'] with request_uri().
|
||||
By DamienMcKenna: Updated the README.txt's Credits section to match the project
|
||||
page.
|
||||
@@ -56,6 +229,59 @@ By DamienMcKenna: Moved hook_requirements to the top of metatag.install.
|
||||
#2095397 by DamienMcKenna: Allow method to skip skipping metatag_entity_view().
|
||||
#2095501 by DamienMcKenna: Logic mistake in metatag_metatags_delete_multiple()
|
||||
meant records were never deleted.
|
||||
#2072087 by brunascle: Twitter Cards changed to use correct 'name' attribute.
|
||||
#2086037 by greggles: Only show schema warning messages to appropriate people.
|
||||
#1311050 by pasive, DamienMcKenna: Added the og:locale meta tag.
|
||||
#2082539 by DamienMcKenna, hswong3i: {metatag}.revision_id cannot be null.
|
||||
#2082539 by DamienMcKenna: Follow-up to make all revision_id values numeric.
|
||||
#1848338 by DamienMcKenna: Added a list of test scenarios that need to be added.
|
||||
#2152043 by DamienMcKenna: Devel Generate integration via Metatag:Devel
|
||||
submodule.
|
||||
#2152043 by DamienMcKenna: Expanded Devel Generate integration to cover almost
|
||||
all included meta tags.
|
||||
#1572474 by DamienMcKenna, HyperGlide, jyee, Kristen Pol, sylus: Fixes for
|
||||
revisions support.
|
||||
#1876042 by DamienMcKenna: Rename variables to use $entity_id instead of $id
|
||||
in metatag.admin.inc, $entity_type instead of $type in metatag.migrate.inc.
|
||||
#2157689/#2088299 by travelertt, iMiksu, DamienMcKenna: JS error broke
|
||||
CKEditor, etc.
|
||||
#2168343 by DamienMcKenna: Clear EntityCache bins.
|
||||
#2062379 by DamienMcKenna: Restructured caching.
|
||||
#2168939 by DamienMcKenna: Don't skip batch processing on updates ran via Drush.
|
||||
#2169547 by DamienMcKenna: Clarification on Workbench Moderation support.
|
||||
#2090557 by Kristen Pol, DamienMcKenna: Don't cache tags on 403/404 error pages.
|
||||
#1848622 by DamienMcKenna: Translation helper for 'bar'.
|
||||
#1967856 by duozersk: Support for the noimageindex and notranslate robots tag
|
||||
options.
|
||||
#2140463 by zhuber: Small misspelling in a comment.
|
||||
#1963678 by DC_Marc, gnuget, Albert Volkman: Additional Twitter Card meta tags.
|
||||
#2170363 by juampy: Incorrect data handling in DrupalDefaultMetaTag.
|
||||
#1286270 by DamienMcKenna: Provide options for disabling meta tags on specific
|
||||
entity types or entity bundles, see README.txt for details.
|
||||
#2071649 by eelkeblok, DamienMcKenna: Verify the entity still exists when
|
||||
loading meta tag data in metatag_ctools_render_alter() and
|
||||
metatag_views_post_render().
|
||||
#2126157 by hefox: metatag_entity_has_metatags() returns TRUE for disabled
|
||||
entities, not FALSE.
|
||||
#2001178 by jantoine, DamienMcKenna: Verify the language exists before saving.
|
||||
#1864306 by hefox: Export the 'disabled' state via Features, thus allowing
|
||||
disabled configurations to be exported too.
|
||||
#2172883 by Kristen Pol, DamienMcKenna: Only use Workbench Moderation functions
|
||||
on nodes.
|
||||
#1975552 by pivica, DamienMcKenna: Fixed errors when changing {metatag} table's
|
||||
primary keys.
|
||||
#1864306 by DamienMcKenna: Follow-on to only export the $config->disabled
|
||||
setting if it exists.
|
||||
#2173271 by deetergp: Spelling and grammer fixes for README.txt.
|
||||
#2172433 by fabsor, DamienMcKenna: Ensure that update 7015 runs early enough to
|
||||
avoid data corruption or errors during other updates.
|
||||
#2156261 by plopesc, DamienMcKenna: Allow meta tags for 403/404 error pages to
|
||||
be configured, along with some reasonable defaults; removed previous option to
|
||||
control caching on these pages, the meta tags are now always cached.
|
||||
#2173863 by DamienMcKenna: Don't load meta tags on admin pages, provide setting
|
||||
to override this.
|
||||
#2174363 by DamienMcKenna: Don't attempt to create revision records in update
|
||||
7018 if one already exists.
|
||||
|
||||
|
||||
Metatag 7.x-1.0-beta7, 2013-04-22
|
||||
|
@@ -8,9 +8,10 @@ meta tags may help improve your site's & pages' ranking, thus may aid with
|
||||
achieving a more prominent display of your content within search engine
|
||||
results. Additionally, using meta tags can help control the summary content
|
||||
that is used within social networks when visitors link to your site,
|
||||
particularly the Open Graph submodule for use with Facebook (see below).
|
||||
particularly the Open Graph submodule for use with Facebook, LinkedIn, etc (see
|
||||
below).
|
||||
|
||||
This version of the module only works with Drupal 7.15 and newer.
|
||||
This version of the module only works with Drupal 7.28 and newer.
|
||||
|
||||
|
||||
Features
|
||||
@@ -18,7 +19,7 @@ Features
|
||||
The primary features include:
|
||||
|
||||
* The current supported basic meta tags are ABSTRACT, DESCRIPTION, CANONICAL,
|
||||
COPYRIGHT, GENERATOR, IMAGE_SRC, KEYWORDS, PUBLISHER, REVISIT-AFTER, ROBOTS,
|
||||
GENERATOR, IMAGE_SRC, KEYWORDS, PUBLISHER, REVISIT-AFTER, RIGHTS, ROBOTS,
|
||||
SHORTLINK and the page's TITLE tag.
|
||||
|
||||
* Multi-lingual support using the Entity Translation module.
|
||||
@@ -26,7 +27,7 @@ The primary features include:
|
||||
* Translation support using the Internationalization (i18n) module.
|
||||
|
||||
* Full support for entity revisions and workflows based upon revision editing,
|
||||
e.g. Revisioning module.
|
||||
e.g., Revisioning module.
|
||||
|
||||
* Per-path control over meta tags using the "Metatag: Context" submodule
|
||||
(requires the Context module).
|
||||
@@ -41,12 +42,21 @@ The primary features include:
|
||||
* The fifteen Dublin Core Basic Element Set 1.1 meta tags may be added by
|
||||
enabling the "Metatag: Dublin Core" submodule.
|
||||
|
||||
* The Open Graph Protocol meta tags, as used by Facebook, may be added by
|
||||
enabling the "Metatag: Open Graph" submodule.
|
||||
* The Open Graph Protocol meta tags, as used by Facebook, LinkedIn and other
|
||||
sites, may be added by enabling the "Metatag: Open Graph" submodule.
|
||||
|
||||
* The Twitter Cards meta tags may be added by enabling the "Metatag: Twitter
|
||||
Cards" submodule.
|
||||
|
||||
* Certain meta tags used by Google+ may be added by enabling the "Metatag:
|
||||
Google+" submodule.
|
||||
|
||||
* Facebook's fb:app_id and fb:admins meta tags may be added by enabling the
|
||||
"Metatag: Facebook" submodule. These are useful for sites which are using
|
||||
Facebook widgets or are building custom integration with Facebook's APIs,
|
||||
but they are not needed by most sites and have no bearing on the Open Graph
|
||||
meta tags.
|
||||
|
||||
* An API allowing for additional meta tags to be added, beyond what is provided
|
||||
by this module - see metatag.api.php for full details.
|
||||
|
||||
@@ -56,6 +66,17 @@ The primary features include:
|
||||
* Support for the Feeds module for importing data from external data sources or
|
||||
file uploads.
|
||||
|
||||
* Integrates with Devel_Generate, part of the Devel module, to automatically
|
||||
generate meta tags for generated nodes, via the Metatag:Devel submodule.
|
||||
|
||||
* Integrates with Workbench Moderation (both v1 and v2) allowing meta tags on
|
||||
nodes to be managed through the workflow process.
|
||||
|
||||
* The Transliteration and Imagecache Token modules (see below) are highly
|
||||
recommended when using image meta tags, e.g. og:image.
|
||||
|
||||
* Several advanced options may be controlled via the Advanced Settings page.
|
||||
|
||||
|
||||
Configuration
|
||||
------------------------------------------------------------------------------
|
||||
@@ -68,7 +89,7 @@ Configuration
|
||||
- The "Edit meta tags" permission to the roles that are allowed to change
|
||||
meta tags on each individual page (node, term, etc).
|
||||
|
||||
2. The main admininistrative page controls the site-wide defaults, both global
|
||||
2. The main administrative page controls the site-wide defaults, both global
|
||||
settings and defaults per entity (node, term, etc), in addition to those
|
||||
assigned specifically for the front page:
|
||||
admin/config/search/metatags
|
||||
@@ -81,22 +102,32 @@ Configuration
|
||||
|
||||
4. As the meta tags are output using Tokens, it may be necessary to customize
|
||||
the token display for the site's entities (content types, vocabularies,
|
||||
etc). To do this go to e.g. admin/structure/types/manage/article/display, in
|
||||
the "Custom Display Settings" section ensure that "Tokens" is checked (save
|
||||
the form if necessary), then to customize the tokens go to:
|
||||
etc). To do this go to e.g., admin/structure/types/manage/article/display,
|
||||
in the "Custom Display Settings" section ensure that "Tokens" is checked
|
||||
(save the form if necessary), then to customize the tokens go to:
|
||||
admin/structure/types/manage/article/display/token
|
||||
|
||||
|
||||
Internationalization: i18n.module
|
||||
------------------------------------------------------------------------------
|
||||
All default configurations may be translated using the Internationalization
|
||||
(i18n) module. The custom strings that are assigned to e.g. the "Global: Front
|
||||
(i18n) module. The custom strings that are assigned to e.g., the "Global: Front
|
||||
page" configuration will show up in the Translate Interface admin page
|
||||
(admin/config/regional/translate/translate) and may be customized per language.
|
||||
|
||||
|
||||
Fine Tuning
|
||||
------------------------------------------------------------------------------
|
||||
All of these may be controlled from the advanced settings page:
|
||||
admin/config/search/metatags/settings
|
||||
|
||||
* It is possible to "disable" the meta tags provided by Drupal core, i.e.
|
||||
"generator", "canonical URL" and "shortlink", though it may not be completely
|
||||
obvious. Metatag takes over the display of these tags, thus any changes made
|
||||
to them in Metatag will supercede Drupal's normal output. To hide a tag, all
|
||||
that is necessary is to clear the default value for that tag, e.g. on the
|
||||
global settings for nodes, which will result in the tag not being output for
|
||||
those pages.
|
||||
* By default Metatag will load the global default values for all pages that do
|
||||
not have meta tags assigned via the normal entity display or via Metatag
|
||||
Context. This may be disabled by setting the variable 'metatag_load_all_pages'
|
||||
@@ -114,6 +145,36 @@ Fine Tuning
|
||||
required otherwise none of the meta tag fields will display at all. The
|
||||
functionality may be disabled again by either removing the variable or
|
||||
setting it to FALSE.
|
||||
* It's possible to disable Metatag integration for certain entity types or
|
||||
bundles using variables. To disable an entity just assigning a variable
|
||||
'metatag_enable_{$entity_type}' or 'metatag_enable_{$entity_type}__{$bundle}'
|
||||
the value FALSE, e.g.:
|
||||
// Disable metatags for file_entity.
|
||||
$conf['metatag_enable_file'] = FALSE;
|
||||
// Disable metatags for carousel nodes.
|
||||
$conf['metatag_enable_node__carousel'] = FALSE;
|
||||
To enable the entity and/or bundle simply set the value to TRUE or remove the
|
||||
settings.php line. Note that the Metatag cache will need to be cleared after
|
||||
changing these settings, specifically the 'info' records, e.g., 'info:en'; a
|
||||
quick version of doing this is to clear the site caches using either Drush,
|
||||
Admin Menu (flush all caches), or the "Clear all caches" button on
|
||||
admin/config/development/performance.
|
||||
* By default Metatag will not display meta tags on admin pages. To enable meta
|
||||
tags on admin pages simply set the 'metatag_tag_admin_pages' variable to TRUE
|
||||
through one of the following methods:
|
||||
* Use Drush to set the value:
|
||||
drush vset metatag_tag_admin_pages TRUE
|
||||
* Hardcode the value in the site's settings.php file:
|
||||
$conf['metatag_tag_admin_pages'] = TRUE;
|
||||
To re-enable this option simply set the value to FALSE or delete the
|
||||
settings.php line.
|
||||
* When loading an entity with multiple languages for a specific language the
|
||||
meta tag values saved for that language will be used if they exist, otherwise
|
||||
values assigned to the entity's default language will be used. This
|
||||
may be disabled using the enabling the "Don't load entity's default language
|
||||
values if no languages match" option on the Advanced Settings page, which will
|
||||
cause default values to be used should there not be any values assigned for
|
||||
the current requested language.
|
||||
|
||||
|
||||
Developers
|
||||
@@ -124,10 +185,19 @@ To enable Metatag support in custom entities, add 'metatag' => TRUE to either
|
||||
the entity or bundle definition in hook_entity_info(); see metatag.api.php for
|
||||
further details and example code.
|
||||
|
||||
The meta tags for a given entity object (node, etc) can be obtained as follows:
|
||||
$metatags = metatags_get_entity_metatags($entity_id, $entity_type, $langcode);
|
||||
The result will be a nested array of meta tag structures ready for either output
|
||||
via drupal_render(), or examining to identify the actual text values.
|
||||
|
||||
|
||||
Troubleshooting / Known Issues
|
||||
------------------------------------------------------------------------------
|
||||
* When using custom page template files, e.g. page--front.tpl.php, it is
|
||||
* Image fields do not output very easily in meta tags, e.g. for og:image,
|
||||
without use of the Imagecache Token module (see below). This also provides a
|
||||
way of using an image style to resize the original images first, rather than
|
||||
requiring visitors download multi-megabyte original images.
|
||||
* When using custom page template files, e.g., page--front.tpl.php, it is
|
||||
important to ensure that the following code is present in the template file:
|
||||
<?php render($page['content']); ?>
|
||||
or
|
||||
@@ -137,17 +207,11 @@ Troubleshooting / Known Issues
|
||||
taxonomy term pages to work correctly.
|
||||
* Using Metatag with values assigned for the page title and the Page Title
|
||||
module simultaneously can cause conflicts and unexpected results.
|
||||
* Using the Exclude Node Title module will cause the [node:title] token to be
|
||||
empty on node pages, so using [current-page:title] will work around the
|
||||
issue. Note: it isn't possible to "fix" this as it's a by-product of what
|
||||
Exclude Node Title does - it removes the node title from display.
|
||||
* When customizing the meta tags for user pages, it is strongly recommended to
|
||||
not use the [current-user] tokens, these pertain to the person *viewing* the
|
||||
page and not e.g. the person who authored a page.
|
||||
* If images being displayed in image tags need to be resized to fit a specific
|
||||
requirements, use the Imagecache Token module to customize the value.
|
||||
* Certain browser plugins, e.g. on Chrome, can cause the page title so be
|
||||
displayed with additional doublequotes, e.g. instead of:
|
||||
page and not e.g., the person who authored a page.
|
||||
* Certain browser plugins, e.g., on Chrome, can cause the page title to be
|
||||
displayed with additional double quotes, e.g., instead of:
|
||||
<title>The page title | My cool site</title>
|
||||
it will show:
|
||||
<title>"The page title | My cool site"</title>
|
||||
@@ -157,31 +221,45 @@ Troubleshooting / Known Issues
|
||||
tags output by the Metatag:OpenGraph module. Unless it is actually needed for
|
||||
the site, it may be worthwhile to disable the RDF module to avoid any
|
||||
possible problems for the Open Graph integration.
|
||||
* If the Administration Language (admin_language) module is installed, it is
|
||||
recommended to disable the "Force language neutral aliases" setting on the
|
||||
Admin Language settings page, i.e. set the "admin_language_force_neutral"
|
||||
variable to FALSE. Failing to do so can lead to data loss in Metatag.
|
||||
|
||||
|
||||
Related modules
|
||||
------------------------------------------------------------------------------
|
||||
Some modules are available that extend Metatag with additional functionality:
|
||||
|
||||
* Imagecache Token
|
||||
https://www.drupal.org/project/imagecache_token
|
||||
Provides additional tokens for image fields that can be used in e.g. the
|
||||
og:image meta tag; ultimately makes it possible to actually use image meta
|
||||
tags without writing custom code.
|
||||
|
||||
* Transliteration
|
||||
https://drupal.org/project/transliteration
|
||||
Tidies up filenames for uploaded files, e.g. it can remove commas from
|
||||
filenames that could otherwise break certain meta tags.
|
||||
|
||||
* Domain Meta Tags
|
||||
http://drupal.org/project/domain_meta
|
||||
https://drupal.org/project/domain_meta
|
||||
Integrates with the Domain Access module, so each site of a multi-domain
|
||||
install can separately control their meta tags.
|
||||
|
||||
* Select or Other
|
||||
http://drupal.org/project/select_or_other
|
||||
https://drupal.org/project/select_or_other
|
||||
Enhances the user experience of the metatag_opengraph submodule by allowing
|
||||
the creation of custom Open Graph types.
|
||||
|
||||
* Imagecache Token
|
||||
http://drupal.org/project/imagecache_token
|
||||
Provide tokens to load fields using an image style preset, for when meta tags
|
||||
need to fix exact requirements.
|
||||
|
||||
* Node Form Panes
|
||||
https://drupal.org/project/node_form_panes
|
||||
Create custom node-edit forms and control the location of the Metatag fields.
|
||||
|
||||
* Textimage
|
||||
https://drupal.org/project/textimage
|
||||
Supports using Textimage's custom tokens in meta tag fields.
|
||||
|
||||
|
||||
Credits / Contact
|
||||
------------------------------------------------------------------------------
|
||||
|
@@ -80,3 +80,9 @@ div.metatag-config-details ul li {
|
||||
div.metatag-config-details > p {
|
||||
margin: 0.25em 0;
|
||||
}*/
|
||||
|
||||
|
||||
/* For the advanced settings page */
|
||||
.metatag-bundle-checkbox {
|
||||
margin-left: 2em;
|
||||
}
|
||||
|
@@ -308,6 +308,10 @@ function metatag_config_edit_form($form, &$form_state, $config) {
|
||||
metatag_metatags_form($form, $config->instance, $config->config, $options);
|
||||
$form['metatags']['#type'] = 'container';
|
||||
|
||||
// Make the token browser available.
|
||||
$form['metatags']['#prefix'] = $form['metatags'][LANGUAGE_NONE]['#description'];
|
||||
unset($form['metatags'][LANGUAGE_NONE]['#description']);
|
||||
|
||||
$form['actions']['#type'] = 'actions';
|
||||
$form['actions']['save'] = array(
|
||||
'#type' => 'submit',
|
||||
@@ -328,8 +332,8 @@ function metatag_config_edit_form_submit($form, &$form_state) {
|
||||
form_state_values_clean($form_state);
|
||||
$config = (object) $form_state['values'];
|
||||
// @todo Consider renaming the config field from 'config' to 'metatags'
|
||||
$config->config = $config->metatags;
|
||||
unset($config->metatags);
|
||||
$config->config = $config->metatags[LANGUAGE_NONE];
|
||||
unset($config->metatags[LANGUAGE_NONE]);
|
||||
metatag_config_save($config);
|
||||
|
||||
$label = metatag_config_instance_label($config->instance);
|
||||
@@ -490,23 +494,23 @@ function metatag_bulk_revert_batch_operation($entity_type, $bundle, &$context) {
|
||||
// Process 25 entities per iteration.
|
||||
$query->range(0, 25);
|
||||
$result = $query->execute();
|
||||
$ids = !empty($result[$entity_type]) ? array_keys($result[$entity_type]) : array();
|
||||
foreach ($ids as $id) {
|
||||
$metatags = metatag_metatags_load($entity_type, $id);
|
||||
$entity_ids = !empty($result[$entity_type]) ? array_keys($result[$entity_type]) : array();
|
||||
foreach ($entity_ids as $entity_id) {
|
||||
$metatags = metatag_metatags_load($entity_type, $entity_id);
|
||||
if (!empty($metatags)) {
|
||||
db_delete('metatag')->condition('entity_type', $entity_type)
|
||||
->condition('entity_id', $id)
|
||||
->condition('entity_id', $entity_id)
|
||||
->execute();
|
||||
metatag_metatags_cache_clear($entity_type, $id);
|
||||
metatag_metatags_cache_clear($entity_type, $entity_id);
|
||||
$context['results'][] = t('Reverted metatags for @bundle with id @id.', array(
|
||||
'@bundle' => $entity_type . ': ' . $bundle,
|
||||
'@id' => $id,
|
||||
'@id' => $entity_id,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$context['sandbox']['count'] += count($ids);
|
||||
$context['sandbox']['current'] = max($ids);
|
||||
$context['sandbox']['count'] += count($entity_ids);
|
||||
$context['sandbox']['current'] = max($entity_ids);
|
||||
|
||||
if ($context['sandbox']['count'] != $context['sandbox']['total']) {
|
||||
$context['finished'] = $context['sandbox']['count'] / $context['sandbox']['total'];
|
||||
@@ -532,3 +536,115 @@ function metatag_bulk_revert_batch_finished($success, $results, $operations) {
|
||||
array('@operation' => $error_operation[0], '@args' => print_r($error_operation[0], TRUE))));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Misc settings page.
|
||||
*/
|
||||
function metatag_admin_settings_form() {
|
||||
$form = array();
|
||||
|
||||
$form['#attached'] = array(
|
||||
'js' => array(
|
||||
drupal_get_path('module', 'metatag') . '/metatag.admin.js',
|
||||
),
|
||||
'css' => array(
|
||||
drupal_get_path('module', 'metatag') . '/metatag.admin.css',
|
||||
),
|
||||
);
|
||||
|
||||
$form['advanced'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Advanced settings'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
);
|
||||
|
||||
$form['advanced']['metatag_load_all_pages'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Output meta tags even if only global settings apply'),
|
||||
'#description' => t('By default Metatag will load the global default values for all pages that do not have meta tags assigned via the normal entity display or via Metatag Context. This may be disabled so that meta tags will only be output on pages that specifically have meta tags configured for them.'),
|
||||
'#default_value' => variable_get('metatag_load_all_pages', TRUE),
|
||||
);
|
||||
|
||||
$form['advanced']['metatag_tag_admin_pages'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Output meta tags on admin pages'),
|
||||
'#description' => t('By default meta tags will not be output on admin pages, but it may be beneficial for some sites to do so.'),
|
||||
'#default_value' => variable_get('metatag_tag_admin_pages', FALSE),
|
||||
);
|
||||
|
||||
$form['advanced']['metatag_extended_permissions'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Advanced permissions'),
|
||||
'#description' => t('Optionally add a permission for each individual meta tag. This provides tremendous flexibility for the editorial process, at the expense of making the permissions configuration more tedious.'),
|
||||
'#default_value' => variable_get('metatag_extended_permissions', FALSE),
|
||||
);
|
||||
|
||||
$form['advanced']['metatag_entity_no_lang_default'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t("Don't load entity's default language values if no languages match"),
|
||||
'#description' => t("On a site with multiple languages it is possible for an entity to not have meta tag values assigned for the language of the current page. By default the meta tags for an entity's default language value will be used in this scenario, with the canonical URL pointing to the URL. This option may be disabled, i.e. to only load meta tags for languages that specifically have them assigned, otherwise using defaults."),
|
||||
'#default_value' => variable_get('metatag_entity_no_lang_default', FALSE),
|
||||
);
|
||||
|
||||
$form['entities'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Master controls for all entities'),
|
||||
'#description' => t('By enabling and disabling items here, it is possible to control which entities (e.g. nodes, taxonomy terms) and bundles (e.g. content types, vocabularies) will have meta tags available to them.<br />Note: the entities first have to have meta tags enabled via hook_entity_info; see the API documentation for full details.'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => TRUE,
|
||||
);
|
||||
|
||||
foreach (entity_get_info() as $entity_name => $entity_info) {
|
||||
// Only show entities that have been enabled via the hooks.
|
||||
if (!empty($entity_info['metatags'])) {
|
||||
$form['entities']['metatag_enable_' . $entity_name] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t($entity_info['label']),
|
||||
'#default_value' => variable_get('metatag_enable_' . $entity_name, TRUE),
|
||||
'#description' => t('Enable meta tags for all pages this entity type.'),
|
||||
);
|
||||
|
||||
if (!empty($entity_info['bundles'])) {
|
||||
$desc_added = FALSE;
|
||||
foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
|
||||
// Some entities, e.g. User, (core) File, have a bundle with the same
|
||||
// name as the entity, so
|
||||
if ($bundle_name != $entity_name) {
|
||||
// Add an extra line to the description introducing the entity
|
||||
// bundles.
|
||||
if (!$desc_added) {
|
||||
$form['entities']['metatag_enable_' . $entity_name]['#disabled'] = TRUE;
|
||||
$form['entities']['metatag_enable_' . $entity_name]['#default_value'] = TRUE;
|
||||
$form['entities']['metatag_enable_' . $entity_name]['#description'] = t('Each bundle for this entity must be controlled individually.');
|
||||
$desc_added = TRUE;
|
||||
}
|
||||
$form['entities']['metatag_enable_' . $entity_name . '__' . $bundle_name] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t($bundle_info['label']),
|
||||
'#default_value' => variable_get('metatag_enable_' . $entity_name . '__' . $bundle_name, isset($bundle_info['metatags']) ? $bundle_info['metatags'] : TRUE),
|
||||
'#attributes' => array(
|
||||
// Add some theming that'll indent this bundle.
|
||||
'class' => array('metatag-bundle-checkbox'),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extra submission logic.
|
||||
$form['#submit'][] = 'metatag_admin_settings_form_submit';
|
||||
|
||||
return system_settings_form($form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Form API submission callback for metatag_admin_settings_form().
|
||||
*/
|
||||
function metatag_admin_settings_form_submit() {
|
||||
cache_clear_all('entity_info:', 'cache', TRUE);
|
||||
cache_clear_all('*', 'cache_metatag', TRUE);
|
||||
drupal_set_message(t('The Metatag cache has been cleared, so all meta tags can be reloaded.'));
|
||||
}
|
||||
|
@@ -1,13 +1,19 @@
|
||||
/**
|
||||
* @file
|
||||
* Custom admin-side JS for the Metatag module.
|
||||
*/
|
||||
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
Drupal.behaviors.metatagUIConfigListing = {
|
||||
attach: function (context) {
|
||||
// Hide elements to be visible if JavaScript is enabled.
|
||||
// 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'});
|
||||
$(this).css({'cursor': 'pointer'});
|
||||
})
|
||||
.click(function(){
|
||||
$(this).find('a.toggle-details', context).trigger('click');
|
||||
@@ -37,6 +43,6 @@ Drupal.behaviors.metatagUIConfigListing = {
|
||||
event.stopPropagation();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
@@ -114,6 +114,21 @@ function hook_metatag_config_default() {
|
||||
return $configs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal hook for adding further configuration values in bundled submodules.
|
||||
*
|
||||
* The defaults provided by the main Metatag module need to be extended by the
|
||||
* bundled submodules before they are presented to other modules for altering
|
||||
* via hook_metatag_config_default_alter(), in case differences in module
|
||||
* weights and loading priorities cause the submodules' settings to run after
|
||||
* those of any custom modules.
|
||||
*
|
||||
* @see hook_metatag_config_default()
|
||||
* @see hook_metatag_config_default_alter()
|
||||
*/
|
||||
function hook_metatag_bundled_config_alter(&$config) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@@ -170,7 +185,74 @@ function hook_metatag_config_update($config) {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Definition of the meta tags and groups.
|
||||
*
|
||||
* @return array
|
||||
* A nested array of 'tags' and 'groups', each keyed off the machine name for
|
||||
* their respective structure type, with the following values:
|
||||
* Tags:
|
||||
* 'label' - The name for this meta tag.
|
||||
* 'description' - An explanation of what this meta tag is used for and what
|
||||
* values are permissible.
|
||||
* 'class' - The class name that controls this meta tag.
|
||||
* 'weight' - Used to sort the meta tags during output.
|
||||
* 'group' - The machine name of a group this meta tag will be contained
|
||||
* within.
|
||||
* 'context' - Optionally control the type of configuration the meta tag
|
||||
* will be available from. Possible values are:
|
||||
* [empty] - All meta tags apply to all possible objects, by default.
|
||||
* 'global' - This will make it only show in the global meta tag
|
||||
* configuration form.
|
||||
* [entity type] - Makes the meta tag only show for specific entity types.
|
||||
* 'header' - Optionally output the meta tag as an HTTP header value.
|
||||
* 'element' - Optional attributes for rendering the meta tag. Should
|
||||
* contain the following:
|
||||
* '#theme' - The theming function used to render the meta tag.
|
||||
* 'replaces' - An optional array of meta tags that this meta tag replaces.
|
||||
* Used to indicate that these deprecated meta tags will be replaced by
|
||||
* this newer one, their values will be used, upon the next object save
|
||||
* the deprecated tag will be entirely replaced by the new meta tag. While
|
||||
* one meta tag can replace several others, only one of the possible
|
||||
* values will be used, the others will be silently purged upon the next
|
||||
* configuration/object save.
|
||||
* 'form' - Optional items to be passed directly to the form; uses standard
|
||||
* Form API values.
|
||||
* 'devel_generate' - Optional values to be passed to the Devel Generate
|
||||
* submodule. Should be an array containing one of the following values:
|
||||
* 'type' - One of the following:
|
||||
* 'canonical' - The token for the absolute URL for the current page.
|
||||
* 'email' - An email address randomly generated at the site's hostname.
|
||||
* 'float' - A random floating point number between 0.0 and 999.999.
|
||||
* 'image' - A randomly generated image.
|
||||
* 'integer' - A random integer between 0 and 999.
|
||||
* 'phone' - A phone number in the format 999-999-9999.
|
||||
* 'select' - A value randomly selected from the available form options.
|
||||
* 'text' - Random text string.
|
||||
* 'twitter' - A Twitter username.
|
||||
* 'url' - A randomly generated URL on this site.
|
||||
* 'maxlength' - The maximum length / number of iterations of this value,
|
||||
* defaults to 10.
|
||||
* 'dependencies' - Optional nested array of values to indicate other meta
|
||||
* tags that must be present in order for this meta tag to be visible. See
|
||||
* The Open Graph and Twitter Cards submodules for example usage. Each
|
||||
* dependency must contain the following elements:
|
||||
* 'dependency' - The name of the meta tag that is required.
|
||||
* 'attribute' - The name of the other meta tag that is to be checked,
|
||||
* most meta tags use "value" as the attribute name.
|
||||
* 'condition' - The state condition to be checked against, e.g. "filled"
|
||||
* to check text values, "checked" for a checkbox, "value" to compare
|
||||
* the raw selection; see https://api.drupal.org/drupal_process_states
|
||||
* for more details.
|
||||
* 'value' - The field value to check the 'condition' against. see
|
||||
* https://api.drupal.org/drupal_process_states for further details.
|
||||
* Groups:
|
||||
* 'label' - The name for this group.
|
||||
* 'description' - A detailed explanation of these meta tags.
|
||||
* 'form' - Additional items to be passed directly to the form.
|
||||
* Note: 'label', 'description', and any text strings passed in 'form', should
|
||||
* be translated.
|
||||
*
|
||||
* @see metatag_metatag_info().
|
||||
*/
|
||||
function hook_metatag_info() {
|
||||
return array();
|
||||
@@ -199,8 +281,10 @@ function hook_metatag_load_entity_from_path_alter(&$path, $result) {
|
||||
* @param string $instance
|
||||
* An identifier for the current page's page type, typically a combination
|
||||
* of the entity name and bundle name, e.g. "node:story".
|
||||
* @param array $options
|
||||
* All of the options used to generate the meta tags.
|
||||
*/
|
||||
function hook_metatag_metatags_view_alter(&$output, $instance) {
|
||||
function hook_metatag_metatags_view_alter(&$output, $instance, $options) {
|
||||
if (isset($output['description']['#attached']['drupal_add_html_head'][0][0]['#value'])) {
|
||||
$output['description']['#attached']['drupal_add_html_head'][0][0]['#value'] = 'O rly?';
|
||||
}
|
||||
@@ -270,10 +354,12 @@ function hook_metatag_token_types_alter(&$options) {
|
||||
* user object being the value. Some token types, like 'site', do not require
|
||||
* any explicit information from $data and can be replaced even if it is
|
||||
* empty.
|
||||
* @param string $tag_name
|
||||
* The name of the meta tag being altered.
|
||||
*
|
||||
* @see DrupalTextMetaTag::getValue()
|
||||
*/
|
||||
function hook_metatag_pattern_alter(&$pattern, &$types) {
|
||||
function hook_metatag_pattern_alter(&$pattern, &$types, $tag_name) {
|
||||
if (strpos($pattern, 'token_type1') !== FALSE) {
|
||||
$types['token_type1'] = "data to be used in hook_tokens for replacement";
|
||||
}
|
||||
|
21
sites/all/modules/contrib/seo/metatag/metatag.drush.inc
Normal file
21
sites/all/modules/contrib/seo/metatag/metatag.drush.inc
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Drush integration for Metatag.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_drush_cache_clear().
|
||||
*/
|
||||
function metatag_drush_cache_clear(&$types) {
|
||||
if (function_exists('module_exists') && module_exists('metatag')) {
|
||||
$types['metatag'] = 'drush_metatag_cache_clear_token_info';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear caches internal to Metatag module.
|
||||
*/
|
||||
function drush_metatag_cache_clear_token_info() {
|
||||
metatag_config_cache_clear();
|
||||
}
|
@@ -36,6 +36,9 @@ function metatag_features_export_render($module_name, $data, $export = NULL) {
|
||||
if ($config = metatag_config_load($name)) {
|
||||
$export = new stdClass();
|
||||
$export->instance = $config->instance;
|
||||
if (isset($config->disabled)) {
|
||||
$export->disabled = $config->disabled;
|
||||
}
|
||||
$export->config = $config->config;
|
||||
$export = features_var_export($export, ' ');
|
||||
$key = features_var_export($name);
|
||||
|
@@ -32,22 +32,32 @@ function metatag_feeds_set_target($source, $entity, $target, $value) {
|
||||
// Strip the prefix that was added above.
|
||||
$name = str_replace('meta_', '', $target);
|
||||
|
||||
// Load full metatag object if exists and has not been already loaded.
|
||||
// Check for any existing data that may not have been loaded already.
|
||||
if (!isset($entity->metatags) && !empty($entity->feeds_item->entity_id) && is_numeric($entity->feeds_item->entity_id)) {
|
||||
$entity->metatags = array();
|
||||
$entity_type = $entity->feeds_item->entity_type;
|
||||
$entity_id = $entity->feeds_item->entity_id;
|
||||
$entities = entity_load($entity_type, array($entity_id));
|
||||
if (!empty($entities)) {
|
||||
$stored_entity = reset($entities);
|
||||
$metatags = metatag_metatags_load($entity_type, $entity_id);
|
||||
if (!empty($stored_entity) && !empty($metatags)) {
|
||||
$stored_entity_language = metatag_entity_get_language($entity_type, $stored_entity);
|
||||
$entity->metatags = isset($metatags[$stored_entity_language]) ? $metatags[$stored_entity_language] : array();
|
||||
|
||||
// Load the existing entity.
|
||||
$stored_entities = entity_load($entity_type, array($entity_id));
|
||||
if (!empty($stored_entities)) {
|
||||
$stored_entity = reset($stored_entities);
|
||||
if (!empty($stored_entity)) {
|
||||
// This function returns all values for all revisions.
|
||||
$metatags = metatag_metatags_load($entity_type, $entity_id);
|
||||
if (!empty($metatags)) {
|
||||
// Only load meta tags for the current revision.
|
||||
list(, $revision_id) = entity_extract_ids($entity_type, $stored_entity);
|
||||
if (!empty($metatags[$revision_id])) {
|
||||
// Just copy all meta tags for all languages.
|
||||
$entity->metatags = $metatags[$revision_id];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Assign the value.
|
||||
$entity->metatags[$name]['value'] = $value;
|
||||
$langcode = metatag_entity_get_language($entity_type, $entity);
|
||||
$entity->metatags[$langcode][$name]['value'] = $value;
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,8 @@ interface DrupalMetaTagInterface {
|
||||
|
||||
function getValue();
|
||||
|
||||
function getWeight();
|
||||
|
||||
function getElement();
|
||||
|
||||
function tidyValue($value);
|
||||
@@ -27,6 +29,7 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
|
||||
protected $info;
|
||||
protected $data = array('value' => '');
|
||||
protected $weight = 0;
|
||||
|
||||
function __construct(array $info, array $data = NULL) {
|
||||
$this->info = $info;
|
||||
@@ -35,38 +38,87 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the weight or this meta tag.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public function getWeight() {
|
||||
static $counter = 0;
|
||||
|
||||
// If no weight value is found, stack this meta tag at the end.
|
||||
$weight = 100;
|
||||
if (!empty($this->info['weight'])) {
|
||||
$weight = $this->info['weight'];
|
||||
}
|
||||
|
||||
return $weight + ($counter++ * 0.1);
|
||||
}
|
||||
|
||||
public function getForm(array $options = array()) {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getValue(array $options = array()) {
|
||||
return tidyValue($this->data['value']);
|
||||
return $this->tidyValue($this->data['value']);
|
||||
}
|
||||
|
||||
public function getElement(array $options = array()) {
|
||||
$element = isset($this->info['element']) ? $this->info['element'] : array();
|
||||
|
||||
$value = $this->getValue($options);
|
||||
if (strlen($value) === 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$element += array(
|
||||
'#theme' => 'metatag',
|
||||
'#tag' => 'meta',
|
||||
'#id' => 'metatag_' . $this->info['name'],
|
||||
'#name' => $this->info['name'],
|
||||
'#value' => $value,
|
||||
);
|
||||
// The stack of elements that will be output.
|
||||
$elements = array();
|
||||
|
||||
// Add header information if desired.
|
||||
if (!empty($this->info['header'])) {
|
||||
$element['#attached']['drupal_add_http_header'][] = array($this->info['header'], $value);
|
||||
// Dynamically add each option to this setting.
|
||||
$base_element = isset($this->info['element']) ? $this->info['element'] : array();
|
||||
|
||||
// Single item.
|
||||
if (empty($this->info['multiple'])) {
|
||||
$values = array($value);
|
||||
}
|
||||
|
||||
return array(
|
||||
'#attached' => array('drupal_add_html_head' => array(array($element, $element['#id']))),
|
||||
);
|
||||
// Multiple items.
|
||||
else {
|
||||
$values = array_filter(explode(',', $value));
|
||||
}
|
||||
|
||||
// Loop over each item.
|
||||
if (!empty($values)) {
|
||||
foreach ($values as $ctr => $value) {
|
||||
$value = trim($value);
|
||||
|
||||
// Some meta tags must be output as secure URLs.
|
||||
if (!empty($this->info['secure'])) {
|
||||
$value = str_replace('http://', 'https://', $value);
|
||||
}
|
||||
|
||||
// Combine the base configuration for this meta tag with the value.
|
||||
$element = $base_element + array(
|
||||
'#theme' => 'metatag',
|
||||
'#tag' => 'meta',
|
||||
'#id' => 'metatag_' . $this->info['name'] . '_' . $ctr,
|
||||
'#name' => $this->info['name'],
|
||||
'#value' => $value,
|
||||
'#weight' => $this->getWeight(),
|
||||
);
|
||||
|
||||
// Add header information if desired.
|
||||
if (!empty($this->info['header'])) {
|
||||
$element['#attached']['drupal_add_http_header'][] = array($this->info['header'], $value);
|
||||
}
|
||||
|
||||
$elements[] = array($element, $element['#id']);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($elements)) {
|
||||
return array(
|
||||
'#attached' => array('drupal_add_html_head' => $elements),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,6 +131,11 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface {
|
||||
* The meta tag value after it has been tidied up.
|
||||
*/
|
||||
public function tidyValue($value) {
|
||||
// Specifically replace encoded spaces, because some WYSIWYG editors are
|
||||
// silly. Do this before decoding the other HTML entities so that the output
|
||||
// doesn't end up with a bunch of a-circumflex characters.
|
||||
$value = str_replace(' ', ' ', $value);
|
||||
|
||||
// Convert any HTML entities into regular characters.
|
||||
$value = decode_entities($value);
|
||||
|
||||
@@ -117,6 +174,21 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag {
|
||||
'#maxlength' => 1024,
|
||||
);
|
||||
|
||||
if (!empty($this->info['multiple'])) {
|
||||
$form['value']['#description'] .= ' ' . t('Multiple values may be used, separated by a comma. Note: Tokens that return multiple values will be handled automatically.');
|
||||
}
|
||||
|
||||
// Support for dependencies, using Form API's #states system.
|
||||
// @see metatag.api.php.
|
||||
// @see https://api.drupal.org/drupal_process_states
|
||||
if (!empty($this->info['dependencies'])) {
|
||||
foreach ($this->info['dependencies'] as $specs) {
|
||||
$form['value']['#states']['visible'][':input[name*="[' . $specs['dependency'] . '][' . $specs['attribute'] . ']"]'] = array(
|
||||
$specs['condition'] => $specs['value'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
@@ -135,7 +207,7 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag {
|
||||
if (empty($options['raw'])) {
|
||||
// Give other modules the opportunity to use hook_metatag_pattern_alter()
|
||||
// to modify defined token patterns and values before replacement.
|
||||
drupal_alter('metatag_pattern', $value, $options['token data']);
|
||||
drupal_alter('metatag_pattern', $value, $options['token data'], $this->info['name']);
|
||||
$value = token_replace($value, $options['token data'], $options);
|
||||
}
|
||||
return $this->tidyValue($value);
|
||||
@@ -161,12 +233,13 @@ class DrupalLinkMetaTag extends DrupalTextMetaTag {
|
||||
'#id' => 'metatag_' . $this->info['name'],
|
||||
'#name' => $this->info['name'],
|
||||
'#value' => $value,
|
||||
'#weight' => $this->getWeight(),
|
||||
);
|
||||
|
||||
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', '<' . check_plain($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(
|
||||
@@ -185,7 +258,7 @@ class DrupalTitleMetaTag extends DrupalTextMetaTag {
|
||||
|
||||
public function getElement(array $options = array()) {
|
||||
$element = array();
|
||||
$value = check_plain($this->getValue($options));
|
||||
$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));
|
||||
return $element;
|
||||
|
@@ -3,8 +3,9 @@ description = "Adds support and an API to implement meta tags."
|
||||
package = SEO
|
||||
core = 7.x
|
||||
|
||||
; This requires Drupal 7.15 or newer.
|
||||
dependencies[] = system (>=7.15)
|
||||
; This requires Drupal 7.28 or newer as it fixes the [node:summary] token that
|
||||
; was previously broken.
|
||||
dependencies[] = system (>=7.28)
|
||||
|
||||
; CTools and Token are also required.
|
||||
dependencies[] = ctools
|
||||
@@ -16,9 +17,9 @@ files[] = metatag.inc
|
||||
files[] = metatag.migrate.inc
|
||||
files[] = metatag.test
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
datestamp = "1412909330"
|
||||
|
||||
|
@@ -12,7 +12,48 @@ function metatag_requirements($phase) {
|
||||
// Ensure translations don't break during installation.
|
||||
$t = get_t();
|
||||
|
||||
if ($phase == 'runtime') {
|
||||
if ($phase == 'install') {
|
||||
// Handle scenarios where the site had the legacy "metatags" module
|
||||
// installed but then had Metatag installed on top of it.
|
||||
if (function_exists('db_table_exists') && function_exists('db_field_exists') && function_exists('db_query') && Database::isActiveConnection()) {
|
||||
// Check if the primary table already exists.
|
||||
if (db_table_exists('metatag')) {
|
||||
// Check to see if all of the fields exist in the table. If one of the
|
||||
// fields does not exist, proceed with the fix.
|
||||
$fields = array(
|
||||
'entity_type',
|
||||
'entity_id',
|
||||
'revision_id',
|
||||
'language',
|
||||
'data',
|
||||
);
|
||||
foreach ($fields as $field) {
|
||||
// This field doesn't exist, so determine what to do.
|
||||
if (!db_field_exists('metatag', $field)) {
|
||||
// The table contains data, so rename it.
|
||||
if (db_query("SELECT COUNT(*) FROM {metatag}")->fetchField() > 0) {
|
||||
db_query("RENAME TABLE {metatag} TO {metatag}_legacy");
|
||||
$message = 'An out-of-date version of the {metatag} table was discovered. As the table contained data it was renamed with a suffix of "_legacy". This will not prevent installation from continuing, but will need to be dealt with later. See <a href="https://www.drupal.org/node/1391554">https://www.drupal.org/node/1391554</a> for further details.';
|
||||
}
|
||||
// The table is empty, so delete it.
|
||||
else {
|
||||
db_query("DROP TABLE {metatag}");
|
||||
$message = 'An out-of-date version of the {metatag} table was discovered. As the table was empty it was simply removed so that it could be recreated in the correct format. Installation may now proceed. See <a href="https://www.drupal.org/node/1391554">https://www.drupal.org/node/1391554</a> for further details.';
|
||||
}
|
||||
$requirements['metatag'] = array(
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Legacy data discovered.'),
|
||||
'description' => $t($message),
|
||||
);
|
||||
drupal_set_message($t($message), 'warning');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($phase == 'runtime') {
|
||||
// Work out the release of D7 that is currently running.
|
||||
list($major, $minor) = explode('.', VERSION);
|
||||
// Strip off any suffixes on the version string, e.g. "17-dev".
|
||||
@@ -20,24 +61,14 @@ function metatag_requirements($phase) {
|
||||
list($minor, $suffix) = explode('-', $minor);
|
||||
}
|
||||
|
||||
// Releases of Drupal older than 7.15 did not have entity_language(), which
|
||||
// is now required.
|
||||
if ($minor < 15) {
|
||||
// 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) {
|
||||
$requirements['metatag'] = array(
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Upgrade Drupal core to v7.15 or newer'),
|
||||
'description' => $t("This older version of Drupal core is missing functionality necessary for the module's multilingual support, it must be upgraded to at least version 7.15."),
|
||||
);
|
||||
}
|
||||
// Releases of Drupal older than 7.17 did not trigger hook_entity_view on
|
||||
// term pages, so recommend updating.
|
||||
elseif ($minor < 17) {
|
||||
$requirements['metatag'] = array(
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Upgrade Drupal core to v7.17 or newer'),
|
||||
'description' => $t('Your older version of Drupal core is missing functionality necessary for taxonomy term pages to work correctly, it is strongly recommended to upgrade to the latest release.'),
|
||||
'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."),
|
||||
);
|
||||
}
|
||||
// Everything's OK.
|
||||
@@ -46,7 +77,7 @@ function metatag_requirements($phase) {
|
||||
'severity' => REQUIREMENT_OK,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Drupal core is compatible'),
|
||||
'description' => $t('Older versions of Drupal core were missing functionality necessary for taxonomy term pages to work correctly, but this version <em>will</em> work correctly.'),
|
||||
'description' => $t('Older versions of Drupal core contained bugs that made them incompatible with Metatag, but this version will work correctly.'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -60,16 +91,6 @@ function metatag_requirements($phase) {
|
||||
);
|
||||
}
|
||||
|
||||
// Add a note if Page Title is also installed.
|
||||
if (module_exists('exclude_node_title')) {
|
||||
$requirements['metatag_exclude_node_title'] = array(
|
||||
'severity' => REQUIREMENT_INFO,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Possible conflicts with Exclude Node Title module'),
|
||||
'description' => $t('The Metatag module\'s default settings for content types (nodes) uses [node:title] for the page title. Unfortunately, Exclude Node Title hides this so the page title ends up blank. It is recommended to <a href="!config">change the "title" field\'s default value</a> to "[current-page:title]" instead of "[node:title]" for any content types affected by Exclude Node Title.', array('!config' => 'admin/config/search/metatags')),
|
||||
);
|
||||
}
|
||||
|
||||
// Add a note if the deprecated metatag.entity_translation.inc file still
|
||||
// exists.
|
||||
$filename = 'metatag.entity_translation.inc';
|
||||
@@ -94,6 +115,38 @@ function metatag_requirements($phase) {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// It's recommended to install the Transliteration module to clean up file
|
||||
// paths for use with image meta tags.
|
||||
if (!module_exists('transliteration')) {
|
||||
$requirements['metatag_transliteration'] = array(
|
||||
'severity' => REQUIREMENT_INFO,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('The Transliteration module is recommended.'),
|
||||
'description' => $t("It is recommended to install the <a href=\"@url\">Transliteration module</a> to clean up filenames of uploaded files that may be used with image meta tags.", array('@url' => 'https://drupal.org/project/transliteration')),
|
||||
);
|
||||
}
|
||||
|
||||
// It's recommended to install the Imagecache Token module to make image
|
||||
// tokens easier to do.
|
||||
if (!module_exists('imagecache_token')) {
|
||||
$requirements['metatag_imagecache_token'] = array(
|
||||
'severity' => REQUIREMENT_INFO,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('The Imagecache Token module is recommended.'),
|
||||
'description' => $t("It is recommended to install the <a href=\"@url\">Imagecache Token module</a> to make it easier to control image meta tags, e.g. og:image.", array('@url' => 'https://drupal.org/project/imagecache_token')),
|
||||
);
|
||||
}
|
||||
|
||||
// The Admin Language module can cause problems.
|
||||
if (!module_exists('admin_language') && variable_get('admin_language_force_neutral', 0)) {
|
||||
$requirements['metatag_admin_language'] = array(
|
||||
'severity' => REQUIREMENT_WARNING,
|
||||
'title' => 'Metatag',
|
||||
'value' => $t('Conflict with Admin Language module.'),
|
||||
'description' => $t("Using the \"@option\" with Metatag can lead to data loss, so it is recommended to <a href=\"@url\">disable that option</a>.", array('@option' => t('Force language neutral aliases'), '@url' => url('admin/config/regional/language/admin_language'))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $requirements;
|
||||
@@ -169,7 +222,7 @@ function metatag_schema() {
|
||||
'revision_id' => array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => FALSE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The revision_id for the entity object this data is attached to.',
|
||||
),
|
||||
@@ -187,6 +240,9 @@ function metatag_schema() {
|
||||
'serialize' => TRUE,
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'type_revision' => array('entity_type','revision_id'),
|
||||
),
|
||||
'primary key' => array('entity_type', 'entity_id', 'revision_id', 'language'),
|
||||
);
|
||||
|
||||
@@ -200,7 +256,7 @@ function metatag_schema() {
|
||||
* Implements hook_install().
|
||||
*/
|
||||
function metatag_install() {
|
||||
drupal_set_message(t("Thank you for installing the Metatag module. It is recommended to read the module's <a href=\"!url\" title=\"Read the Metatag module's documentation\">README.txt</a> file as there are some known issues that may afffect this site.", array('!url' => url(drupal_get_path('module', 'metatag') . '/README.txt'))));
|
||||
drupal_set_message(t("Thank you for installing the Metatag module. It is recommended to read the module's <a href=\"!url\" title=\"Read the Metatag module's documentation\">README.txt</a> file as there are some known issues that may affect this site.", array('!url' => url(drupal_get_path('module', 'metatag') . '/README.txt'))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -209,6 +265,21 @@ function metatag_install() {
|
||||
function metatag_uninstall() {
|
||||
// This variable is created via hook_enable.
|
||||
variable_del('metatag_schema_installed');
|
||||
// Used to control whether 403/404 pages are cached.
|
||||
variable_del('metatag_cache_error_pages');
|
||||
// Used to make meta tags display on admin pages.
|
||||
variable_del('metatag_tag_admin_pages');
|
||||
|
||||
// Temp variables, just in case they weren't removed already.
|
||||
variable_del('metatag_skip_update_7017');
|
||||
|
||||
// Used to note that the schema for the main {metatag} table were sufficiently
|
||||
// updated.
|
||||
variable_del('metatag_has_revision_id');
|
||||
|
||||
// Used to force an entity's default language values to be used if nothing
|
||||
// else matched.
|
||||
variable_del('metatag_entity_no_lang_default');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,9 +319,13 @@ function metatag_update_7001() {
|
||||
);
|
||||
$keys = array('primary key' => array($field_name));
|
||||
|
||||
// Before making any changes, drop the existing primary key. Unforunately
|
||||
// there is no API way to check if a primary key exists, so if it doesn't
|
||||
// exist the db_drop_primary_key() call will fail.
|
||||
// Before making any changes, drop the existing primary key.
|
||||
// Let's add a temporary unique key for cid so MySQL will let it go.
|
||||
// Hint taken from https://drupal.org/node/2064305#comment-7753197.
|
||||
db_add_unique_key($table_name, 'temp_key', array($field_name, 'instance'));
|
||||
|
||||
// Unforunately there is no API way to check if a primary key exists, so if
|
||||
// it doesn't exist the db_drop_primary_key() call will fail.
|
||||
try {
|
||||
db_drop_primary_key($table_name);
|
||||
}
|
||||
@@ -260,6 +335,9 @@ function metatag_update_7001() {
|
||||
|
||||
// Rejig the field, and turn on the primary key again.
|
||||
db_change_field($table_name, $field_name, $field_name, $field_spec, $keys);
|
||||
|
||||
// Finally, remove the temporary unique key because it's no longer useful.
|
||||
db_drop_unique_key($table_name, 'temp_key');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -351,8 +429,8 @@ function metatag_update_7006() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove {metatag} records for objects that have been deleted; older versions
|
||||
* of Metatag may have failed to purge these.
|
||||
* Remove {metatag} records for nodes, users and taxonomy terms that have been
|
||||
* deleted; older versions of Metatag may have failed to purge these.
|
||||
*/
|
||||
function metatag_update_7007() {
|
||||
$nodes = db_query("SELECT m.entity_id
|
||||
@@ -440,6 +518,9 @@ function metatag_update_7008() {
|
||||
*/
|
||||
function metatag_update_7009() {
|
||||
if (module_exists('taxonomy')) {
|
||||
// Fix the {metatag} table first.
|
||||
metatag_update_7015();
|
||||
|
||||
// Remove duplicates.
|
||||
_metatag_remove_dupes('taxonomy_term');
|
||||
}
|
||||
@@ -456,6 +537,9 @@ function metatag_update_7009() {
|
||||
* Fix {metatag} records for users.
|
||||
*/
|
||||
function metatag_update_7010() {
|
||||
// Fix the {metatag} table first.
|
||||
metatag_update_7015();
|
||||
|
||||
// Remove duplicates.
|
||||
_metatag_remove_dupes('user');
|
||||
|
||||
@@ -470,6 +554,9 @@ function metatag_update_7010() {
|
||||
* Fix {metatag} records for nodes.
|
||||
*/
|
||||
function metatag_update_7011(&$sandbox) {
|
||||
// Fix the {metatag} table first.
|
||||
metatag_update_7015();
|
||||
|
||||
// Only proceed if Entity_Translation is not enabled as it allows each node
|
||||
// record to have multiple languages available.
|
||||
if (module_exists('entity_translation')) {
|
||||
@@ -481,7 +568,12 @@ function metatag_update_7011(&$sandbox) {
|
||||
// When a group is processed, the batch update engine determines whether it
|
||||
// should continue processing in the same request or provide progress
|
||||
// feedback to the user and wait for the next request.
|
||||
$limit = 20;
|
||||
$limit = 10;
|
||||
// When ran through Drush it's Ok to process a larger number of objects at a
|
||||
// time.
|
||||
if (drupal_is_cli()) {
|
||||
$limit = 100;
|
||||
}
|
||||
|
||||
// Use the sandbox at your convenience to store the information needed
|
||||
// to track progression between successive calls to the function.
|
||||
@@ -528,15 +620,8 @@ function metatag_update_7011(&$sandbox) {
|
||||
$limit = 1;
|
||||
}
|
||||
|
||||
// The for loop will run as normal when ran via update.php, but when ran via
|
||||
// Drush it'll just run 'til it's finished.
|
||||
$increment = 1;
|
||||
if (drupal_is_cli()) {
|
||||
$increment = 0;
|
||||
}
|
||||
|
||||
// Set default values.
|
||||
for ($ctr = 0; $ctr < $limit; $ctr += $increment) {
|
||||
for ($ctr = 0; $ctr < $limit; $ctr++) {
|
||||
$sandbox['current_record']++;
|
||||
if (empty($sandbox['records'][$sandbox['current_record']])) {
|
||||
break;
|
||||
@@ -581,6 +666,9 @@ function metatag_update_7011(&$sandbox) {
|
||||
* Remove duplicate {metatag} records for non-core entities.
|
||||
*/
|
||||
function metatag_update_7012() {
|
||||
// Fix the {metatag} table first.
|
||||
metatag_update_7015();
|
||||
|
||||
if (module_exists('entity_translation')) {
|
||||
drupal_set_message(t("Entity Translation is enabled, duplicate meta tags will not be removed for custom entities, to avoid accidental dataloss."));
|
||||
return;
|
||||
@@ -611,6 +699,9 @@ function metatag_update_7012() {
|
||||
* take a while, depending on how much data needs to be converted.
|
||||
*/
|
||||
function metatag_update_7013(&$sandbox) {
|
||||
// Fix the {metatag} table first.
|
||||
metatag_update_7015();
|
||||
|
||||
if (module_exists('entity_translation')) {
|
||||
drupal_set_message(t("Entity Translation is enabled, meta tags will not be updated for custom entities, to avoid accidental dataloss."));
|
||||
return;
|
||||
@@ -666,16 +757,14 @@ function metatag_update_7013(&$sandbox) {
|
||||
// should continue processing in the same request or provide progress
|
||||
// feedback to the user and wait for the next request.
|
||||
$limit = 10;
|
||||
|
||||
// The for loop will run as normal when ran via update.php, but when ran via
|
||||
// Drush it'll just run 'til it's finished.
|
||||
$increment = 1;
|
||||
// When ran through Drush it's Ok to process a larger number of objects at a
|
||||
// time.
|
||||
if (drupal_is_cli()) {
|
||||
$increment = 0;
|
||||
$limit = 100;
|
||||
}
|
||||
|
||||
// Set default values.
|
||||
for ($ctr = 0; $ctr < $limit; $ctr += $increment) {
|
||||
for ($ctr = 0; $ctr < $limit; $ctr++) {
|
||||
$sandbox['current_record']++;
|
||||
if (empty($sandbox['records'][$sandbox['current_record']])) {
|
||||
break;
|
||||
@@ -904,21 +993,559 @@ function metatag_update_7014() {
|
||||
* keys accordingly.
|
||||
*/
|
||||
function metatag_update_7015() {
|
||||
// Add the new field.
|
||||
db_add_field('metatag', 'revision_id', array(
|
||||
if (!db_field_exists('metatag', 'revision_id')) {
|
||||
// Leave a note for metatag_metatags_load_multiple() that the revision_id
|
||||
// field has been added.
|
||||
variable_set('metatag_has_revision_id', TRUE);
|
||||
|
||||
// Tell update 7017 that it isn't needed.
|
||||
variable_set('metatag_skip_update_7017', TRUE);
|
||||
|
||||
// Add the new field.
|
||||
db_add_field('metatag', 'revision_id', array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The revision_id for the entity object this data is attached to.',
|
||||
));
|
||||
|
||||
// Remove the existing primary key. This may take some work so it can be
|
||||
// database agnostic, i.e. some databases will not like it.
|
||||
db_drop_primary_key('metatag');
|
||||
|
||||
// Add the new primary key.
|
||||
db_add_primary_key('metatag', array('entity_type', 'entity_id', 'revision_id', 'language'));
|
||||
|
||||
drupal_set_message(t('Added the {metatag}.revision_id field.'));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('The {metatag}.revision_id field has already been added, nothing to do.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the revision ID to fix the NULL values, help avoid problems with
|
||||
* update 7017.
|
||||
*/
|
||||
function metatag_update_7016() {
|
||||
// It's possible that 7015 was not executed if the site had been updated to
|
||||
// an early dev release, so make sure the revision_id field exists.
|
||||
metatag_update_7015();
|
||||
|
||||
// Run the update.
|
||||
db_query("UPDATE {metatag} SET revision_id = 0 WHERE revision_id IS NULL");
|
||||
}
|
||||
|
||||
/**
|
||||
* The {metatag}.revision_id field is required.
|
||||
*/
|
||||
function metatag_update_7017() {
|
||||
if (!variable_get('metatag_skip_update_7017', FALSE)) {
|
||||
// Let's add a temporary unique key so MySQL will let it go.
|
||||
db_add_unique_key('metatag', 'temp_key', array('entity_type', 'entity_id', 'revision_id', 'language'));
|
||||
|
||||
// Now remove the PK before changing a field from serial.
|
||||
db_drop_primary_key('metatag');
|
||||
|
||||
// Change the field.
|
||||
db_change_field('metatag', 'revision_id', 'revision_id', array(
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => FALSE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'description' => 'The revision_id for the entity object this data is attached to.',
|
||||
));
|
||||
|
||||
// Remove the existing primary key. This may take some work so it can be
|
||||
// database agnostic, i.e. some databases will not like it.
|
||||
db_drop_primary_key('metatag');
|
||||
// Manually re-add the PK.
|
||||
db_add_primary_key('metatag', array('entity_type', 'entity_id', 'revision_id', 'language'));
|
||||
|
||||
// Add the new primary key.
|
||||
db_add_primary_key('metatag', array('entity_type', 'entity_id', 'revision_id', 'language'));
|
||||
// Finally, remove the temporary unique key because it's no longer useful.
|
||||
db_drop_unique_key('metatag', 'temp_key');
|
||||
|
||||
drupal_set_message(t('Added the {metatag}.revision_id field.'));
|
||||
drupal_set_message(t('Fixed the {metatag}.revision_id field.'));
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t("Didn't need to fix the {metatag}.revision_id field; please disperse, nothing to see here."));
|
||||
}
|
||||
|
||||
// Delete the temporary variable.
|
||||
variable_del('metatag_skip_update_7017');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the revision ID for each record. This may take some time. Should any
|
||||
* nodes be discovered with a meta tag record for both revision_id 0 and the
|
||||
* correct revision_id, the "0" value will be deleted; if this is not the
|
||||
* desired result the {metatag} table must be manually pruned to have the
|
||||
* correct records prior to letting this update run.
|
||||
*/
|
||||
function metatag_update_7018(&$sandbox) {
|
||||
// Process records in small groups.
|
||||
// When a group is processed, the batch update engine determines whether it
|
||||
// should continue processing in the same request or provide progress
|
||||
// feedback to the user and wait for the next request.
|
||||
$limit = 10;
|
||||
// When ran through Drush it's Ok to process a larger number of objects at a
|
||||
// time.
|
||||
if (drupal_is_cli()) {
|
||||
$limit = 100;
|
||||
}
|
||||
|
||||
// Use the sandbox at your convenience to store the information needed
|
||||
// to track progression between successive calls to the function.
|
||||
if (!isset($sandbox['progress'])) {
|
||||
// The count of records visited so far.
|
||||
$sandbox['progress'] = 0;
|
||||
|
||||
// Get a list of all records affected.
|
||||
$sandbox['records'] = db_query("SELECT entity_type, entity_id, language
|
||||
FROM {metatag}
|
||||
WHERE revision_id = 0")
|
||||
->fetchAll();
|
||||
|
||||
// If there's no data, don't bother with the extra work.
|
||||
if (empty($sandbox['records'])) {
|
||||
watchdog('metatag', 'Update 7018: No {metatag} records needed to have the revision_id value fixed.', array(), WATCHDOG_INFO);
|
||||
if (drupal_is_cli()) {
|
||||
drupal_set_message(t('Update 7018: No {metatag} records needed to have the revision_id value fixed.'));
|
||||
}
|
||||
return t('No {metatag} records needed to have the revision_id value fixed.');
|
||||
}
|
||||
|
||||
// Total records that must be visited.
|
||||
$sandbox['max'] = count($sandbox['records']);
|
||||
|
||||
// A place to store messages during the run.
|
||||
$sandbox['messages'] = array();
|
||||
|
||||
// An initial record of the number of records to be updated.
|
||||
watchdog('metatag', 'Update 7018: !count records to update.', array('!count' => $sandbox['max']), WATCHDOG_INFO);
|
||||
if (drupal_is_cli()) {
|
||||
drupal_set_message(t('Update 7018: !count records to update.', array('!count' => $sandbox['max'])));
|
||||
}
|
||||
|
||||
// Last record processed.
|
||||
$sandbox['current_record'] = -1;
|
||||
|
||||
// Because a lot of other processing happens on the first iteration, just do
|
||||
// one.
|
||||
$limit = 1;
|
||||
}
|
||||
|
||||
// Work out which entities support languages and revisions.
|
||||
$has_language = array();
|
||||
$has_revisions = array();
|
||||
foreach (entity_get_info() as $entity_type => $info) {
|
||||
$has_language[$entity_type] = FALSE;
|
||||
$has_revisions[$entity_type] = FALSE;
|
||||
if (!empty($info['entity keys']['language'])) {
|
||||
$has_language[$entity_type] = $info['entity keys']['language'];
|
||||
}
|
||||
if (!empty($info['entity keys']['revision'])) {
|
||||
$has_revisions[$entity_type] = $info['entity keys']['revision'];
|
||||
}
|
||||
}
|
||||
|
||||
// Set default values.
|
||||
for ($ctr = 0; $ctr < $limit; $ctr++) {
|
||||
$sandbox['current_record']++;
|
||||
if (empty($sandbox['records'][$sandbox['current_record']])) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Shortcuts for later.
|
||||
$entity_type = $sandbox['records'][$sandbox['current_record']]->entity_type;
|
||||
$entity_id = $sandbox['records'][$sandbox['current_record']]->entity_id;
|
||||
// Make sure to load the correct language record.
|
||||
$language = $sandbox['records'][$sandbox['current_record']]->language;
|
||||
$conditions = array();
|
||||
// Some entities don't include a language value.
|
||||
if (!empty($has_language[$entity_type])) {
|
||||
$conditions['language'] = $language;
|
||||
}
|
||||
$records = entity_load($entity_type, array($entity_id), $conditions);
|
||||
|
||||
// Fix this record.
|
||||
if (!empty($records)) {
|
||||
$entity = reset($records);
|
||||
|
||||
// Speed up the handling of entities that don't support revisions.
|
||||
$revision_id = 0;
|
||||
if (!empty($has_revisions[$entity_type])) {
|
||||
list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
|
||||
$revision_id = intval($revision_id);
|
||||
}
|
||||
|
||||
// Don't bother updating records if the revision_id is 0.
|
||||
if (!empty($revision_id)) {
|
||||
$exists = db_query("SELECT entity_id
|
||||
FROM {metatag}
|
||||
WHERE entity_type = :entity_type
|
||||
AND entity_id = :entity_id
|
||||
AND revision_id = :revision_id
|
||||
AND language = :language",
|
||||
array(
|
||||
':entity_type' => $entity_type,
|
||||
':entity_id' => $entity_id,
|
||||
':revision_id' => $revision_id,
|
||||
':language' => $language,
|
||||
))->fetchObject();
|
||||
// There isn't already a record for the revision_id, so update the
|
||||
// metatag record.
|
||||
if (!$exists) {
|
||||
db_update('metatag')
|
||||
->fields(array('revision_id' => $revision_id))
|
||||
->condition('entity_type', $entity_type)
|
||||
->condition('entity_id', $entity_id)
|
||||
->condition('revision_id', 0)
|
||||
->condition('language', $language)
|
||||
->execute();
|
||||
}
|
||||
// The record exists, so delete the old one under the grounds that the
|
||||
// one with a revision_id is newer.
|
||||
// Disclaimer: this is completely arbitrary, without providing a UI to
|
||||
// let the site maintainer/builder choose which of the two records to
|
||||
// keep, we're stuck with a bad scenario. Thankfully this should not
|
||||
// happen very often and would only affect sites that were running a
|
||||
// dev release. Also, sorry :(
|
||||
else {
|
||||
db_delete('metatag')
|
||||
->condition('entity_type', $entity_type)
|
||||
->condition('entity_id', $entity_id)
|
||||
->condition('revision_id', 0)
|
||||
->condition('language', $language)
|
||||
->execute();
|
||||
}
|
||||
|
||||
// Nodes can have multiple revisions, so create new {metatag} records
|
||||
// for each of the other revisions.
|
||||
if ($entity_type == 'node') {
|
||||
$revisions = node_revision_list($entity);
|
||||
if (count($revisions) > 1) {
|
||||
$metatags = db_query("SELECT data
|
||||
FROM {metatag}
|
||||
WHERE entity_type = :entity_type
|
||||
AND entity_id = :entity_id
|
||||
AND language = :language",
|
||||
array(
|
||||
':entity_type' => $entity_type,
|
||||
':entity_id' => $entity_id,
|
||||
':language' => $language,
|
||||
));
|
||||
if (!empty($metatags) && isset($metatags->data) && !empty($metatags->data)) {
|
||||
foreach ($revisions as $vid => $revision) {
|
||||
// Only one record per nid/vid/langcode, thank you.
|
||||
if ($vid != $revision_id) {
|
||||
// Check that there isn't already a record for this revision.
|
||||
$exists = db_query("SELECT entity_id
|
||||
FROM {metatag}
|
||||
WHERE entity_type = :entity_type
|
||||
AND entity_id = :entity_id
|
||||
AND revision_id = :revision_id
|
||||
AND language = :language",
|
||||
array(
|
||||
':entity_type' => $entity_type,
|
||||
':entity_id' => $entity_id,
|
||||
':revision_id' => $vid,
|
||||
':language' => $language,
|
||||
))->fetchObject();
|
||||
if (!$exists) {
|
||||
$node = node_load($entity_id, $vid);
|
||||
$record = new StdClass();
|
||||
$record->entity_type = $entity_type;
|
||||
$record->entity_id = $entity_id;
|
||||
$record->revision_id = $vid;
|
||||
$record->language = $language;
|
||||
$record->data = $metatags->data;
|
||||
drupal_write_record('metatag', $record);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Other entity types.
|
||||
else {
|
||||
drupal_set_message(t('Metatag records for @type objects have not been checked for revisions.', array('@type' => $entity_type)), 'status', FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update our progress information.
|
||||
$sandbox['progress']++;
|
||||
}
|
||||
|
||||
// Set the "finished" status, to tell batch engine whether this function
|
||||
// needs to run again. If you set a float, this will indicate the progress of
|
||||
// the batch so the progress bar will update.
|
||||
$sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
|
||||
|
||||
if ($sandbox['#finished']) {
|
||||
// Clear all caches so the fixed data will be reloaded.
|
||||
cache_clear_all('*', 'cache_metatag', TRUE);
|
||||
|
||||
// A final log of the number of records that were converted.
|
||||
watchdog('metatag', 'Update 7018: !count records were updated in total.', array('!count' => $sandbox['progress']), WATCHDOG_INFO);
|
||||
if (drupal_is_cli()) {
|
||||
drupal_set_message(t('Update 7018: !count records were updated.', array('!count' => $sandbox['progress'])));
|
||||
}
|
||||
|
||||
// hook_update_N() may optionally return a string which will be displayed
|
||||
// to the user.
|
||||
return t('Fixed the revision_id values for !count {metatag} records.', array('!count' => $sandbox['progress']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the entity_cache bins.
|
||||
*/
|
||||
function metatag_update_7019() {
|
||||
if (module_exists('entitycache')) {
|
||||
foreach (drupal_get_schema() as $table_name => $spec) {
|
||||
if (strpos($table_name, 'cache_entity_') === 0) {
|
||||
cache_clear_all('*', $table_name, TRUE);
|
||||
drupal_set_message(t("Cleared the @table cache bin", array('@table' => $table_name)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t("The EntityCache module is not installed, nothing to do."));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the Metatag cache.
|
||||
*/
|
||||
function metatag_update_7020() {
|
||||
cache_clear_all('*', 'cache_metatag', TRUE);
|
||||
return t('All Metatag caches cleared.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the existing Metatag cache so all unwanted 403/404 paths can be
|
||||
* purged.
|
||||
*/
|
||||
function metatag_update_7021() {
|
||||
cache_clear_all('*', 'cache_metatag', TRUE);
|
||||
return t('All Metatag caches cleared.');
|
||||
}
|
||||
|
||||
/**
|
||||
* A minor bit of tidy-up after update 7015.
|
||||
*/
|
||||
function metatag_update_7022() {
|
||||
variable_del('metatag_skip_update_7015');
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the Metatag cache because $cid_parts was changed.
|
||||
*/
|
||||
function metatag_update_7023() {
|
||||
cache_clear_all('*', 'cache_metatag', TRUE);
|
||||
return t('All Metatag caches cleared.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the 'twitter:image' meta tag to 'twitter:image:src', part 1.
|
||||
*/
|
||||
function metatag_update_7024() {
|
||||
// Find all {metatag} records that contained an entry for the old meta tag.
|
||||
$records = db_query("SELECT entity_type, entity_id, revision_id, language, data
|
||||
FROM {metatag}
|
||||
WHERE data LIKE '%twitter:image%'");
|
||||
// This message will be returned if nothing needed to be updated.
|
||||
$none_message = t('No Metatag entity records needed to have the "twitter:image" meta tag fixed.');
|
||||
|
||||
if ($records->rowCount() == 0) {
|
||||
drupal_set_message($none_message);
|
||||
}
|
||||
else {
|
||||
$keys = array('entity_type', 'entity_id', 'revision_id', 'language');
|
||||
|
||||
// Loop over the values and correct them.
|
||||
$counter = 0;
|
||||
foreach ($records as $record) {
|
||||
$record->data = unserialize($record->data);
|
||||
if (isset($record->data['twitter:image'])) {
|
||||
$record->data['twitter:image:src'] = $record->data['twitter:image'];
|
||||
unset($record->data['twitter:image']);
|
||||
drupal_write_record('metatag', $record, $keys);
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
if ($counter == 0) {
|
||||
drupal_set_message($none_message);
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('Converted the "twitter:image" meta tag for @count entity records to the correct "twitter:image:src" meta tag.', array('@count' => $counter)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaced by update 7030.
|
||||
*/
|
||||
function metatag_update_7025() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the 'copyright' meta tag to 'rights', part 1.
|
||||
*/
|
||||
function metatag_update_7026() {
|
||||
// Find all {metatag} records that contained an entry for the old meta tag.
|
||||
$records = db_query("SELECT entity_type, entity_id, revision_id, language, data
|
||||
FROM {metatag}
|
||||
WHERE data LIKE '%copyright%'");
|
||||
// This message will be returned if nothing needed to be updated.
|
||||
$none_message = t('No Metatag entity records needed to have the "copyright" meta tag fixed.');
|
||||
|
||||
if ($records->rowCount() == 0) {
|
||||
drupal_set_message($none_message);
|
||||
}
|
||||
else {
|
||||
$keys = array('entity_type', 'entity_id', 'revision_id', 'language');
|
||||
|
||||
// Loop over the values and correct them.
|
||||
$counter = 0;
|
||||
foreach ($records as $record) {
|
||||
$record->data = unserialize($record->data);
|
||||
if (isset($record->data['copyright'])) {
|
||||
$record->data['rights'] = $record->data['copyright'];
|
||||
unset($record->data['copyright']);
|
||||
drupal_write_record('metatag', $record, $keys);
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
if ($counter == 0) {
|
||||
drupal_set_message($none_message);
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('Converted the "copyright" meta tag for @count entity records to the correct "rights" meta tag.', array('@count' => $counter)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaced by update 7031.
|
||||
*/
|
||||
function metatag_update_7027() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the menu cache so the new Advanced Settings page will be picked up.
|
||||
*/
|
||||
function metatag_update_7028() {
|
||||
variable_set('menu_rebuild_needed', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an index to the {metatag} table to speed up some queries.
|
||||
*/
|
||||
function metatag_update_7029() {
|
||||
db_add_index('metatag', 'type_revision', array('entity_type', 'revision_id'));
|
||||
drupal_set_message(t('Added an index to the main Metatag table that will hopefully improve performance a little.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the 'twitter:image' meta tag to 'twitter:image:src', part 2.
|
||||
*/
|
||||
function metatag_update_7030() {
|
||||
// Find all {metatag_config} records that contained an entry for the old meta
|
||||
// tag.
|
||||
$records = db_query("SELECT cid, config
|
||||
FROM {metatag_config}
|
||||
WHERE config LIKE '%twitter:image%'");
|
||||
// This message will be returned if nothing needed to be updated.
|
||||
$none_message = t('No Metatag configuration records needed to have the "twitter:image" meta tag fixed. That said, there may be other configurations elsewhere that do need updating.');
|
||||
|
||||
// Loop over the values and correct them.
|
||||
if ($records->rowCount() == 0) {
|
||||
drupal_set_message($none_message);
|
||||
}
|
||||
else {
|
||||
$keys = array('cid');
|
||||
|
||||
// Loop over the values and correct them.
|
||||
$counter = 0;
|
||||
foreach ($records as $record) {
|
||||
$record->config = unserialize($record->config);
|
||||
if (isset($record->config['twitter:image'])) {
|
||||
$record->config['twitter:image:src'] = $record->config['twitter:image'];
|
||||
unset($record->config['twitter:image']);
|
||||
drupal_write_record('metatag_config', $record, $keys);
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
if ($counter == 0) {
|
||||
drupal_set_message($none_message);
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('Converted the "twitter:image" meta tag for @count configurations to the correct "twitter:image:src" meta tag.', array('@count' => $counter)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the 'copyright' meta tag to 'rights', part 2.
|
||||
*/
|
||||
function metatag_update_7031() {
|
||||
// Find all {metatag_config} records that contained an entry for the old meta
|
||||
// tag.
|
||||
$records = db_query("SELECT cid, config
|
||||
FROM {metatag_config}
|
||||
WHERE config LIKE '%copyright%'");
|
||||
// This message will be returned if nothing needed to be updated.
|
||||
$none_message = t('No Metatag configuration records needed to have the "copyright" meta tag fixed. That said, there may be other configurations elsewhere that do need updating.');
|
||||
|
||||
// Loop over the values and correct them.
|
||||
if ($records->rowCount() == 0) {
|
||||
drupal_set_message($none_message);
|
||||
}
|
||||
else {
|
||||
$keys = array('cid');
|
||||
|
||||
// Loop over the values and correct them.
|
||||
$counter = 0;
|
||||
foreach ($records as $record) {
|
||||
$record->config = unserialize($record->config);
|
||||
if (isset($record->config['copyright'])) {
|
||||
$record->config['rights'] = $record->config['copyright'];
|
||||
unset($record->config['copyright']);
|
||||
drupal_write_record('metatag_config', $record, $keys);
|
||||
$counter++;
|
||||
}
|
||||
}
|
||||
if ($counter == 0) {
|
||||
drupal_set_message($none_message);
|
||||
}
|
||||
else {
|
||||
drupal_set_message(t('Converted the "copyright" meta tag for @count configurations to the correct "rights" meta tag.', array('@count' => $counter)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the Metatag cache.
|
||||
*/
|
||||
function metatag_update_7032() {
|
||||
cache_clear_all('*', 'cache_metatag', TRUE);
|
||||
return t('All Metatag caches cleared.');
|
||||
}
|
||||
|
||||
/**
|
||||
* These originally removed the 'author' meta tag, but it was subsequently
|
||||
* decided that this was not the correct approach, that the meta tag should not
|
||||
* be removed after all.
|
||||
*
|
||||
* @see https://www.drupal.org/node/2330823
|
||||
*/
|
||||
function metatag_update_7033() {
|
||||
}
|
||||
function metatag_update_7034() {
|
||||
}
|
||||
function metatag_update_7035() {
|
||||
}
|
||||
|
@@ -29,6 +29,26 @@ function metatag_metatag_config_default() {
|
||||
);
|
||||
$configs[$config->instance] = $config;
|
||||
|
||||
$config = new stdClass();
|
||||
$config->instance = 'global:403';
|
||||
$config->api_version = 1;
|
||||
$config->disabled = FALSE;
|
||||
$config->config = array(
|
||||
'canonical' => array('value' => '[site:url]'),
|
||||
'shortlink' => array('value' => '[site:url]'),
|
||||
);
|
||||
$configs[$config->instance] = $config;
|
||||
|
||||
$config = new stdClass();
|
||||
$config->instance = 'global:404';
|
||||
$config->api_version = 1;
|
||||
$config->disabled = FALSE;
|
||||
$config->config = array(
|
||||
'canonical' => array('value' => '[site:url]'),
|
||||
'shortlink' => array('value' => '[site:url]'),
|
||||
);
|
||||
$configs[$config->instance] = $config;
|
||||
|
||||
$config = new stdClass();
|
||||
$config->instance = 'node';
|
||||
$config->api_version = 1;
|
||||
@@ -60,6 +80,12 @@ function metatag_metatag_config_default() {
|
||||
);
|
||||
$configs[$config->instance] = $config;
|
||||
|
||||
// Before returning these, allow the bundled submodules to override them, thus
|
||||
// extending the "real" defaults before they can then be altered by other
|
||||
// modules.
|
||||
// See hook_metatag_bundled_config_alter() in the API documentation.
|
||||
drupal_alter('metatag_bundled_config', $configs);
|
||||
|
||||
return $configs;
|
||||
}
|
||||
|
||||
@@ -69,9 +95,8 @@ function metatag_metatag_config_default() {
|
||||
function metatag_metatag_config_instance_info() {
|
||||
$info['global'] = array('label' => t('Global'));
|
||||
$info['global:frontpage'] = array('label' => t('Front page'));
|
||||
// @todo The 403 and 404 meta tag contexts are disabled until they can be properly implemented.
|
||||
//$info['global:403'] = array('label' => t('403 page not found'));
|
||||
//$info['global:404'] = array('label' => t('404 page not found'));
|
||||
$info['global:403'] = array('label' => t('403 access denied'));
|
||||
$info['global:404'] = array('label' => t('404 page not found'));
|
||||
|
||||
// Add instance information for entities.
|
||||
$entity_types = entity_get_info();
|
||||
@@ -104,16 +129,21 @@ function metatag_metatag_info() {
|
||||
),
|
||||
);
|
||||
|
||||
// "Simple" meta tags go first.
|
||||
$weight = 0;
|
||||
|
||||
$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."),
|
||||
'class' => 'DrupalTitleMetaTag',
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
|
||||
$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."),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'weight' => ++$weight,
|
||||
'form' => array(
|
||||
'#type' => 'textarea',
|
||||
'#rows' => 2,
|
||||
@@ -125,6 +155,7 @@ function metatag_metatag_info() {
|
||||
'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."),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'weight' => ++$weight,
|
||||
'form' => array(
|
||||
'#type' => 'textarea',
|
||||
'#rows' => 2,
|
||||
@@ -134,8 +165,9 @@ 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> used by most search engines."),
|
||||
'description' => t("A comma-separated list of keywords about the page. This meta tag is <em>not</em> supported by most search engines."),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
|
||||
// More advanced meta tags.
|
||||
@@ -143,19 +175,22 @@ function metatag_metatag_info() {
|
||||
'label' => t('Robots'),
|
||||
'description' => t("Provides search engines with specific directions for what to do when this page is indexed."),
|
||||
'class' => 'DrupalListMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'form' => array(
|
||||
'#options' => array(
|
||||
'index' => t('Allow search engines to index this page (assumed).'),
|
||||
'follow' => t('Allow search engines to follow links on this page (assumed).'),
|
||||
'noindex' => t('Prevent search engines from indexing this page.'),
|
||||
'nofollow' => t('Prevent search engines from following links on this page.'),
|
||||
'noarchive' => t('Prevent a cached copy of this page from being available in the search results.'),
|
||||
'nosnippet' => t('Prevents a description from appearing below the page in the search results, as well as prevents caching of the page.'),
|
||||
'noodp' => t('Blocks the <a href="@odp-url">Open Directory Project</a> description of the page from being used in the description that appears below the page in the search results.', array('@odp-url' => 'http://www.dmoz.org/')),
|
||||
'noindex' => t('Prevents search engines from indexing this page.'),
|
||||
'nofollow' => t('Prevents search engines from following links on this page.'),
|
||||
'noarchive' => t('Prevents cached copies of this page from appearing in search results.'),
|
||||
'nosnippet' => t('Prevents descriptions from appearing in search results, and prevents page caching.'),
|
||||
'noodp' => t('Blocks the !opendirectory description from appearing in search results.', array('!opendirectory' => l('Open Directory Project', 'http://www.dmoz.org/'))),
|
||||
'noydir' => t('Prevents Yahoo! from listing this page in the <a href="@ydir">Yahoo! Directory</a>.', array('@ydir' => 'http://dir.yahoo.com/')),
|
||||
'noimageindex' => t('Prevent search engines from indexing images on this page.'),
|
||||
'notranslate' => t('Prevent search engines from offering to translation this page in search results.'),
|
||||
),
|
||||
),
|
||||
'group' => 'advanced',
|
||||
);
|
||||
|
||||
$info['tags']['news_keywords'] = array(
|
||||
@@ -163,13 +198,15 @@ function metatag_metatag_info() {
|
||||
'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')),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
|
||||
|
||||
$info['tags']['standout'] = array(
|
||||
'label' => t('Google Standout'),
|
||||
'description' => t("Highlight standout journalism on the web, especially for breaking news; used as an indicator in <a href=\"@google_news\">Google News</a>. Warning: Don't abuse it, to be used a maximum of 7 times per calendar week!", array('@google_news' => 'https://support.google.com/news/publisher/answer/191283?hl=en&ref_topic=2484650')),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
|
||||
$info['tags']['generator'] = array(
|
||||
@@ -179,13 +216,18 @@ function metatag_metatag_info() {
|
||||
'header' => 'X-Generator',
|
||||
'context' => array('global'),
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
|
||||
$info['tags']['copyright'] = array(
|
||||
'label' => t('Copyright'),
|
||||
'description' => t("Details a copyright, trademark, patent, or other information that pertains to intellectual property about this page. Note that this will not automatically protect your site's content or your intellectual property."),
|
||||
$info['tags']['rights'] = array(
|
||||
'label' => t('Rights'),
|
||||
'description' => t("Details about intellectual property, such as copyright or trademarks; does not automatically protect the site's content or intellectual property."),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'replaces' => array(
|
||||
'copyright',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['image_src'] = array(
|
||||
@@ -193,20 +235,32 @@ function metatag_metatag_info() {
|
||||
'description' => t("An image associated with this page, for use as a thumbnail in social networks and other services."),
|
||||
'class' => 'DrupalLinkMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'image',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['canonical'] = array(
|
||||
'label' => t('Canonical URL'),
|
||||
'description' => t("Tells search engines where the preferred location or URL is for this page to help eliminate self-created duplicate content for search engines."),
|
||||
'description' => t("Preferred page location or URL to help eliminate duplicate content for search engines."),
|
||||
'class' => 'DrupalLinkMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'canonical',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['shortlink'] = array(
|
||||
'label' => t('Shortlink URL'),
|
||||
'description' => '',
|
||||
'description' => t('A brief URL, often created by a URL shortening service.'),
|
||||
'class' => 'DrupalLinkMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'shortlink',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['publisher'] = array(
|
||||
@@ -214,6 +268,10 @@ function metatag_metatag_info() {
|
||||
'description' => '',
|
||||
'class' => 'DrupalLinkMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['author'] = array(
|
||||
@@ -221,6 +279,10 @@ function metatag_metatag_info() {
|
||||
'description' => t("Used by some search engines to confirm authorship of the content on a page. Should be either the full URL for the author's Google+ profile page or a local page with information about the author."),
|
||||
'class' => 'DrupalLinkMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['original-source'] = array(
|
||||
@@ -229,6 +291,10 @@ function metatag_metatag_info() {
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'advanced',
|
||||
'description' => t("Used to indicate the URL that broke the story, and can link to either an internal URL or an external source. If the full URL is not known it is acceptable to use a partial URL or just the domain name."),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['revisit-after'] = array(
|
||||
@@ -236,6 +302,21 @@ function metatag_metatag_info() {
|
||||
'description' => t('Tell search engines when to index the page again. Very few search engines support this tag, it is more useful to use an <a href="@xmlsitemap">XML Sitemap</a> file.', array('@xmlsitemap' => 'http://drupal.org/project/xmlsitemap')),
|
||||
'class' => 'DrupalDateIntervalMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'date',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['content-language'] = array(
|
||||
'label' => t('Content language'),
|
||||
'description' => t("A deprecated meta tag for defining this page's two-letter language code(s)."),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'advanced',
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_http_equiv',
|
||||
),
|
||||
);
|
||||
|
||||
return $info;
|
||||
|
@@ -82,14 +82,14 @@ function metatag_migrate_api() {
|
||||
class MigrateMetatagHandler extends MigrateDestinationHandler {
|
||||
|
||||
public function __construct() {
|
||||
$types = array();
|
||||
$entity_types = array();
|
||||
foreach (entity_get_info() as $entity_type => $entity_info) {
|
||||
if (isset($entity_info['metatags']) && $entity_info['metatags']) {
|
||||
$types[] = $entity_type;
|
||||
$entity_types[] = $entity_type;
|
||||
}
|
||||
}
|
||||
|
||||
$this->registerTypes($types);
|
||||
$this->registerTypes($entity_types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@ class MetaTagsUnitTest extends MetaTagsTestHelper {
|
||||
return array(
|
||||
'name' => 'Meta tag unit tests',
|
||||
'description' => 'Test basic meta tag functionality.',
|
||||
'group' => 'Meta tags',
|
||||
'group' => 'Metatag',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,3 +94,168 @@ class MetaTagsUnitTest extends MetaTagsTestHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TODO: Test each meta tag.
|
||||
// TODO: Scenarios.
|
||||
//
|
||||
// 1. Node
|
||||
// * No language assignment.
|
||||
// * First save.
|
||||
//
|
||||
// 2. Node
|
||||
// * No language assignment.
|
||||
// * Edit existing revision.
|
||||
//
|
||||
// 3. Node
|
||||
// * No language assignment.
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
//
|
||||
// 4. Node
|
||||
// * No language assignment.
|
||||
// * Create new revision.
|
||||
// * Delete new revision.
|
||||
//
|
||||
// 5. Node + Translation
|
||||
// * No language assignment
|
||||
// * Change language assignment.
|
||||
// * Edit existing revision.
|
||||
//
|
||||
// 6. Node + Translation
|
||||
// * No language assignment
|
||||
// * Change language assignment.
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
//
|
||||
// 7. Node + Translation
|
||||
// * No language assignment
|
||||
// * Change language assignment.
|
||||
// * Create new revision.
|
||||
// * Delete new revision.
|
||||
//
|
||||
// 8. Node + Translation
|
||||
// * Initial language assignment
|
||||
//
|
||||
// 9. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
//
|
||||
// 10. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Create new revision.
|
||||
// * Delete new revision.
|
||||
//
|
||||
// 11. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Change language assignment.
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
//
|
||||
// 12. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Change language assignment.
|
||||
// * Create new revision.
|
||||
// * Delete new revision.
|
||||
//
|
||||
// 13. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Create translated node.
|
||||
//
|
||||
// 14. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
// * Create translated node.
|
||||
//
|
||||
// 15. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
// * Create translated node.
|
||||
// * Delete translated node.
|
||||
//
|
||||
// 16. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Create translated node.
|
||||
// * Delete original node.
|
||||
//
|
||||
// 17. Node + Translation
|
||||
// * Initial language assignment
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
// * Create translated node.
|
||||
// * Delete original node.
|
||||
//
|
||||
// 18. Node + entity_translation
|
||||
// * Initial language assignment
|
||||
// * Create translated node.
|
||||
//
|
||||
// 19. Node + entity_translation
|
||||
// * Initial language assignment
|
||||
// * Create translated node.
|
||||
// * Delete original.
|
||||
//
|
||||
// 20. Node + entity_translation
|
||||
// * Initial language assignment
|
||||
// * Create translated node.
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
//
|
||||
// 21. Node + entity_translation
|
||||
// * Initial language assignment
|
||||
// * Create translated node.
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
// * Delete new revision.
|
||||
//
|
||||
// 22. Node + entity_translation
|
||||
// * Initial language assignment
|
||||
// * Create translated node.
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
// * Delete original.
|
||||
//
|
||||
// 23. Node + entity_translation
|
||||
// * Initial language assignment
|
||||
// * Create translated node.
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
// * Delete original.
|
||||
//
|
||||
// 24. Node + entity_translation
|
||||
// * Initial language assignment
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
// * Create translated node.
|
||||
//
|
||||
// 25. Node + entity_translation
|
||||
// * Initial language assignment
|
||||
// * Create new revision.
|
||||
// * Publish new revision.
|
||||
// * Create translated node.
|
||||
// * Delete new revision.
|
||||
//
|
||||
//
|
||||
// 30. Node + i18n
|
||||
//
|
||||
//
|
||||
// 50. Term
|
||||
// * Create term.
|
||||
//
|
||||
// 51. Term
|
||||
// * Create term.
|
||||
// * Change values.
|
||||
//
|
||||
//
|
||||
// 60. User
|
||||
// * Create user.
|
||||
//
|
||||
// 61. User
|
||||
// * Create user.
|
||||
// * Change values.
|
||||
//
|
||||
//
|
||||
// 70. Custom path
|
||||
// * Defaults loaded.
|
||||
|
@@ -56,3 +56,16 @@ function theme_metatag_link_rev($variables) {
|
||||
unset($element['#value']);
|
||||
return theme('html_tag', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme callback for a proprty meta tag.
|
||||
*
|
||||
* The format is:
|
||||
* <meta property="[name]" content="[value]" />
|
||||
*/
|
||||
function theme_metatag_property($variables) {
|
||||
$element = &$variables['element'];
|
||||
element_set_attributes($element, array('#name' => 'property', '#value' => 'content'));
|
||||
unset($element['#value']);
|
||||
return theme('html_tag', $variables);
|
||||
}
|
||||
|
@@ -84,67 +84,6 @@ function metatag_tokens($type, $tokens, array $data = array(), array $options =
|
||||
return $replacements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_tokens_alter().
|
||||
*
|
||||
* Fix [node:summary] until http://drupal.org/node/1295524 is committed, this
|
||||
* code is retrofitted from the patches in that issue.
|
||||
*/
|
||||
function metatag_tokens_alter(array &$replacements, array $context) {
|
||||
// Only proceed if this is working on a node.
|
||||
if ($context['type'] == 'node' && !empty($context['data']['node'])) {
|
||||
// Loop through each of the tokens.
|
||||
foreach ($context['tokens'] as $name => $original) {
|
||||
// Only deal with the 'node:summary' token, that's the one being fixed.
|
||||
if ($name == 'summary') {
|
||||
// A shortcut to the node being processed.
|
||||
$node = $context['data']['node'];
|
||||
|
||||
// Work out the langcode being used.
|
||||
if (isset($context['options']['language'])) {
|
||||
$langcode = $context['options']['language']->language;
|
||||
}
|
||||
else {
|
||||
$langcode = NULL;
|
||||
}
|
||||
|
||||
// Decide whether the string needs to be sanitized.
|
||||
$sanitize = !empty($context['options']['sanitize']);
|
||||
|
||||
if ($items = field_get_items('node', $node, 'body', $langcode)) {
|
||||
$instance = field_info_instance('node', 'body', $node->type);
|
||||
$field_langcode = field_language('node', $node, 'body', $langcode);
|
||||
|
||||
// If the summary is not empty, use it.
|
||||
if (!empty($items[0]['summary'])) {
|
||||
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'summary') : $items[0]['summary'];
|
||||
}
|
||||
|
||||
// Attempt to provide a suitable version of the 'body' field.
|
||||
else {
|
||||
$output = $sanitize ? _text_sanitize($instance, $field_langcode, $items[0], 'value') : $items[0]['value'];
|
||||
// A summary was requested.
|
||||
if ($name == 'summary') {
|
||||
if (isset($instance['display']['teaser']['settings']['trim_length'])) {
|
||||
$trim_length = $instance['display']['teaser']['settings']['trim_length'];
|
||||
}
|
||||
else {
|
||||
// Use default value.
|
||||
$trim_length = NULL;
|
||||
}
|
||||
// Generate an optionally trimmed summary of the body field.
|
||||
$output = text_summary($output, $instance['settings']['text_processing'] ? $items[0]['format'] : NULL, $trim_length);
|
||||
}
|
||||
}
|
||||
|
||||
// Override the original value.
|
||||
$replacements[$original] = $output;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an array of meta tags for a given entity.
|
||||
*/
|
||||
@@ -157,7 +96,13 @@ function metatag_token_generate_array($entity, $entity_type, $bundle) {
|
||||
$options['token data'][$token_type] = $entity;
|
||||
$options['entity'] = $entity;
|
||||
|
||||
$metatags = isset($entity->metatags) ? $entity->metatags : array();
|
||||
$metatags = array();
|
||||
if (!empty($entity->metatags)) {
|
||||
$language = metatag_entity_get_language($entity_type, $entity);
|
||||
if (!empty($entity->metatags[$language])) {
|
||||
$metatags = $entity->metatags[$language];
|
||||
}
|
||||
}
|
||||
$metatags += metatag_config_load_with_defaults($instance);
|
||||
|
||||
$result = array();
|
||||
|
@@ -1,14 +1,24 @@
|
||||
/**
|
||||
* @file
|
||||
* Custom JS for controlling the Metatag vertical tab.
|
||||
*/
|
||||
|
||||
(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 default_name = $(this).attr('name').replace(/\[value\]/, '[default]');
|
||||
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()) {
|
||||
if (default_value.length && default_value.val() === $(this).val()) {
|
||||
// Meta tag has a default value and form value matches default value.
|
||||
return true;
|
||||
}
|
||||
|
@@ -19,8 +19,8 @@ function metatag_context_context_overview() {
|
||||
// metatag admin page".
|
||||
if (isset($context->reactions['metatag_context_reaction']['metatag_admin']) && $context->reactions['metatag_context_reaction']['metatag_admin']) {
|
||||
$ops = array(
|
||||
l('Edit', 'admin/config/search/metatags/context/' . $context->name, array('query' => array('destination' => 'admin/config/search/metatags/context'))),
|
||||
l('Delete', 'admin/config/search/metatags/context/' . $context->name . '/delete', array('query' => array('destination' => 'admin/config/search/metatags/context'))),
|
||||
l(t('Edit'), 'admin/config/search/metatags/context/' . $context->name, array('query' => array('destination' => 'admin/config/search/metatags/context'))),
|
||||
l(t('Delete'), 'admin/config/search/metatags/context/' . $context->name . '/delete', array('query' => array('destination' => 'admin/config/search/metatags/context'))),
|
||||
);
|
||||
$rows[] = array(
|
||||
$context->name,
|
||||
@@ -101,8 +101,15 @@ function metatag_context_config_edit_form($form, &$form_state, $context) {
|
||||
$instance = "";
|
||||
$options = array();
|
||||
|
||||
$metatags = $context->reactions['metatag_context_reaction']['metatags'];
|
||||
if (!isset($metatags[LANGUAGE_NONE])) {
|
||||
$metatags = array(
|
||||
LANGUAGE_NONE => $metatags,
|
||||
);
|
||||
}
|
||||
|
||||
// Load the METATAG form.
|
||||
metatag_metatags_form($form, $instance, $context->reactions['metatag_context_reaction']['metatags'], $options);
|
||||
metatag_metatags_form($form, $instance, $metatags[LANGUAGE_NONE], $options);
|
||||
|
||||
$form['paths'] = array(
|
||||
'#title' => 'Path',
|
||||
|
@@ -11,11 +11,21 @@ class metatag_context_reaction extends context_reaction {
|
||||
// Don't care about the instance name, the data is being managed by
|
||||
// Context and not Metatag.
|
||||
$instance = "";
|
||||
|
||||
// Load the previously saved settings.
|
||||
$data = $this->fetch_from_context($context);
|
||||
if (!isset($data['metatags'])) {
|
||||
$data['metatags'] = array();
|
||||
}
|
||||
|
||||
// Support the pre-v1.0 data structures that were not nested with the
|
||||
// language code.
|
||||
if (!isset($data['metatags'][LANGUAGE_NONE])) {
|
||||
$data['metatags'] = array(
|
||||
LANGUAGE_NONE => $data['metatags'],
|
||||
);
|
||||
}
|
||||
|
||||
// No options currently available.
|
||||
$options = array();
|
||||
|
||||
@@ -32,7 +42,7 @@ class metatag_context_reaction extends context_reaction {
|
||||
);
|
||||
|
||||
// Load the basic Metatag form.
|
||||
metatag_metatags_form($form, $instance, $data['metatags'], $options);
|
||||
metatag_metatags_form($form, $instance, $data['metatags'][LANGUAGE_NONE], $options);
|
||||
|
||||
// Stop the meta tag fields appearing within a fieldset.
|
||||
$form['metatags']['#type'] = 'container';
|
||||
@@ -43,30 +53,30 @@ class metatag_context_reaction extends context_reaction {
|
||||
// Flatten the fieldsets because otherwise the Context module will not save
|
||||
// them properly.
|
||||
// TODO: Perhaps it can be done in a better way with #tree and #parents?
|
||||
foreach (array('advanced', 'dublin-core', 'open-graph') as $fieldset) {
|
||||
if (isset($form['metatags'][$fieldset])) {
|
||||
$form['metatags'][$fieldset . '_heading'] = array(
|
||||
foreach (array('advanced', 'dublin-core', 'open-graph', 'twitter-cards') as $fieldset) {
|
||||
if (isset($form['metatags'][LANGUAGE_NONE][$fieldset])) {
|
||||
$form['metatags'][LANGUAGE_NONE][$fieldset . '_heading'] = array(
|
||||
'#prefix' => '<hr /><h3>',
|
||||
'#markup' => $form['metatags'][$fieldset]['#title'],
|
||||
'#markup' => $form['metatags'][LANGUAGE_NONE][$fieldset]['#title'],
|
||||
'#suffix' => '</h3>',
|
||||
);
|
||||
if (isset($form['metatags'][$fieldset]['#description'])) {
|
||||
$form['metatags'][$fieldset . '_description'] = array(
|
||||
if (isset($form['metatags'][LANGUAGE_NONE][$fieldset]['#description'])) {
|
||||
$form['metatags'][LANGUAGE_NONE][$fieldset . '_description'] = array(
|
||||
'#prefix' => '<p>',
|
||||
'#markup' => $form['metatags'][$fieldset]['#description'],
|
||||
'#markup' => $form['metatags'][LANGUAGE_NONE][$fieldset]['#description'],
|
||||
'#suffix' => '</p>',
|
||||
);
|
||||
}
|
||||
foreach ($form['metatags'][$fieldset] as $key => $value) {
|
||||
foreach ($form['metatags'][LANGUAGE_NONE][$fieldset] as $key => $value) {
|
||||
if (substr($key, 0, 1) == '#') {
|
||||
unset ($form['metatags'][$fieldset][$key]);
|
||||
unset($form['metatags'][LANGUAGE_NONE][$fieldset][$key]);
|
||||
continue;
|
||||
}
|
||||
$form['metatags'][$key] = $value;
|
||||
unset($form['metatags'][$key]['#parents']);
|
||||
unset($form['metatags'][$fieldset][$key]);
|
||||
$form['metatags'][LANGUAGE_NONE][$key] = $value;
|
||||
unset($form['metatags'][LANGUAGE_NONE][$key]['#parents']);
|
||||
unset($form['metatags'][LANGUAGE_NONE][$fieldset][$key]);
|
||||
}
|
||||
unset($form['metatags'][$fieldset]);
|
||||
unset($form['metatags'][LANGUAGE_NONE][$fieldset]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +109,9 @@ class metatag_context_reaction extends context_reaction {
|
||||
foreach ($contexts as $context) {
|
||||
if (!empty($context->reactions['metatag_context_reaction']['metatags'])) {
|
||||
$metadata_array = $context->reactions['metatag_context_reaction']['metatags'];
|
||||
if (isset($metadata_array[LANGUAGE_NONE])) {
|
||||
$metadata_array = $metadata_array[LANGUAGE_NONE];
|
||||
}
|
||||
foreach ($metadata_array as $key => $data) {
|
||||
if (!empty($data['value'])) {
|
||||
$metatags[$key] = $data;//t(check_plain($data['value']));
|
||||
|
@@ -5,10 +5,11 @@ core = 7.x
|
||||
dependencies[] = context
|
||||
dependencies[] = metatag
|
||||
files[] = metatag_context.test
|
||||
configure = admin/config/search/metatags/context
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
datestamp = "1412909330"
|
||||
|
||||
|
@@ -14,7 +14,7 @@ class MetatagContextTestCase extends DrupalWebTestCase {
|
||||
return array(
|
||||
'name' => 'Meta tag context tests',
|
||||
'description' => 'Test basic meta tag context functionality.',
|
||||
'group' => 'Meta tags',
|
||||
'group' => 'Metatag',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,10 +112,10 @@ class MetatagContextTestCase extends DrupalWebTestCase {
|
||||
function editMetatag($metatag_object) {
|
||||
$edit_metatag = array(
|
||||
'paths' => $metatag_object->path,
|
||||
'metatags[title][value]' => $metatag_object->title,
|
||||
'metatags[description][value]' => $metatag_object->description,
|
||||
'metatags[abstract][value]' => $metatag_object->abstract,
|
||||
'metatags[keywords][value]' => $metatag_object->keywords,
|
||||
'metatags[und][title][value]' => $metatag_object->title,
|
||||
'metatags[und][description][value]' => $metatag_object->description,
|
||||
'metatags[und][abstract][value]' => $metatag_object->abstract,
|
||||
'metatags[und][keywords][value]' => $metatag_object->keywords,
|
||||
);
|
||||
$this->drupalPost('admin/config/search/metatags/context/' . $metatag_object->name, $edit_metatag, t('Save'));
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
Metatag: Dublin Core
|
||||
--------------------
|
||||
This module adds the fifteen Dublin Core Metadata Element Set [1] to the
|
||||
available meta tags, as defined by the Dublin Core Metadata Institute [2].
|
||||
This module adds the fifteen Dublin Core Metadata Element Set [1] (plus one) to
|
||||
the available meta tags, as defined by the Dublin Core Metadata Institute [2].
|
||||
|
||||
The following tags are provided:
|
||||
* dcterms.contributor
|
||||
@@ -12,6 +12,7 @@ The following tags are provided:
|
||||
* dcterms.format
|
||||
* dcterms.identifier
|
||||
* dcterms.language
|
||||
* dcterms.modified (additional, not part of the DCES)
|
||||
* dcterms.publisher
|
||||
* dcterms.relation
|
||||
* dcterms.rights
|
||||
|
@@ -4,9 +4,9 @@ package = SEO
|
||||
core = 7.x
|
||||
dependencies[] = metatag
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
datestamp = "1412909330"
|
||||
|
||||
|
@@ -5,50 +5,60 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_metatag_config_default_alter().
|
||||
* Implements hook_metatag_bundled_config_alter().
|
||||
*/
|
||||
function metatag_dc_metatag_config_default_alter(array &$configs) {
|
||||
function metatag_dc_metatag_bundled_config_alter(array &$configs) {
|
||||
foreach ($configs as &$config) {
|
||||
switch ($config->instance) {
|
||||
case 'global':
|
||||
$config->config += array(
|
||||
'dcterms.format' => array('value' => 'text/html'),
|
||||
'dcterms.identifier' => array('value' => '[current-page:url:absolute]'),
|
||||
'dcterms.title' => array('value' => '[current-page:title]'),
|
||||
'dcterms.type' => array('value' => 'Text'),
|
||||
'dcterms.format' => array('value' => 'text/html'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'global:frontpage':
|
||||
$config->config += array(
|
||||
'dcterms.title' => array('value' => '[site:name]'),
|
||||
'dcterms.description' => array('value' => '[site:slogan]'),
|
||||
'dcterms.identifier' => array('value' => '[site:url]'),
|
||||
'dcterms.title' => array('value' => '[site:name]'),
|
||||
);
|
||||
break;
|
||||
|
||||
// On error pages point everything to the homepage.
|
||||
case 'global:403':
|
||||
case 'global:404':
|
||||
$config->config += array(
|
||||
'dcterms.identifier' => array('value' => '[site:url]'),
|
||||
'dcterms.title' => array('value' => '[site:name]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
$config->config += array(
|
||||
'dcterms.title' => array('value' => '[node:title]'),
|
||||
'dcterms.date' => array('value' => '[node:created:custom:Y-m-d\TH:iP]'),
|
||||
'dcterms.identifier' => array('value' => '[current-page:url:absolute]'),
|
||||
'dcterms.language' => array('value' => '[node:language]'),
|
||||
'dcterms.creator' => array('value' => '[node:author]'),
|
||||
'dcterms.date' => array('value' => '[node:created:custom:Y-m-d\TH:iP]'),
|
||||
'dcterms.modified' => array('value' => '[node:changed:custom:Y-m-d\TH:iP]'),
|
||||
'dcterms.description' => array('value' => '[node:summary]'),
|
||||
'dcterms.language' => array('value' => '[node:language]'),
|
||||
'dcterms.title' => array('value' => '[node:title]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'taxonomy_term':
|
||||
$config->config += array(
|
||||
'dcterms.title' => array('value' => '[term:name]'),
|
||||
'dcterms.identifier' => array('value' => '[current-page:url:absolute]'),
|
||||
'dcterms.description' => array('value' => '[term:description]'),
|
||||
'dcterms.title' => array('value' => '[term:name]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
$config->config += array(
|
||||
'dcterms.title' => array('value' => '[user:name]'),
|
||||
'dcterms.date' => array('value' => '[user:created:custom:Y-m-d\TH:iP]'),
|
||||
'dcterms.identifier' => array('value' => '[current-page:url:absolute]'),
|
||||
'dcterms.creator' => array('value' => '[user:name]'),
|
||||
'dcterms.date' => array('value' => '[user:created:custom:Y-m-d\TH:iP]'),
|
||||
'dcterms.title' => array('value' => '[user:name]'),
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -67,6 +77,10 @@ function metatag_dc_metatag_info() {
|
||||
'#weight' => 70,
|
||||
),
|
||||
);
|
||||
|
||||
// Dublin Core meta tags stack after the Twitter Cards tags.
|
||||
$weight = 70;
|
||||
|
||||
$info['tags']['dcterms.title'] = array(
|
||||
'label' => t('Dublin Core Title'),
|
||||
'description' => t('The name given to the resource.'),
|
||||
@@ -76,6 +90,7 @@ function metatag_dc_metatag_info() {
|
||||
'#type' => 'term',
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.creator'] = array(
|
||||
'label' => t('Dublin Core Creator'),
|
||||
@@ -85,6 +100,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.subject'] = array(
|
||||
'label' => t('Dublin Core Subject'),
|
||||
@@ -94,6 +110,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.description'] = array(
|
||||
'label' => t('Dublin Core Description'),
|
||||
@@ -103,6 +120,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.publisher'] = array(
|
||||
'label' => t('Dublin Core Publisher'),
|
||||
@@ -112,6 +130,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.contributor'] = array(
|
||||
'label' => t('Dublin Core Contributor'),
|
||||
@@ -121,6 +140,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.date'] = array(
|
||||
'label' => t('Dublin Core Date'),
|
||||
@@ -130,6 +150,23 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'date',
|
||||
),
|
||||
);
|
||||
$info['tags']['dcterms.modified'] = array(
|
||||
'label' => t('Dublin Core Modified Date'),
|
||||
'description' => t('Date on which the resource was changed.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'dublin-core',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'date',
|
||||
),
|
||||
);
|
||||
$info['tags']['dcterms.type'] = array(
|
||||
'label' => t('Dublin Core Type'),
|
||||
@@ -144,6 +181,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.format'] = array(
|
||||
'label' => t('Dublin Core Format'),
|
||||
@@ -153,6 +191,10 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'devel_generate' => array(
|
||||
'maxlength' => 1,
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.identifier'] = array(
|
||||
'label' => t('Dublin Core Identifier'),
|
||||
@@ -162,6 +204,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.source'] = array(
|
||||
'label' => t('Dublin Core Source'),
|
||||
@@ -171,6 +214,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.language'] = array(
|
||||
'label' => t('Dublin Core Language'),
|
||||
@@ -180,6 +224,10 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'devel_generate' => array(
|
||||
'maxlength' => 1,
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.relation'] = array(
|
||||
'label' => t('Dublin Core Relation'),
|
||||
@@ -189,6 +237,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.coverage'] = array(
|
||||
'label' => t('Dublin Core Coverage'),
|
||||
@@ -198,6 +247,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
$info['tags']['dcterms.rights'] = array(
|
||||
'label' => t('Dublin Core Rights'),
|
||||
@@ -207,6 +257,7 @@ function metatag_dc_metatag_info() {
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_dc',
|
||||
),
|
||||
'weight' => ++$weight,
|
||||
);
|
||||
|
||||
return $info;
|
||||
|
@@ -0,0 +1,13 @@
|
||||
name = Metatag:Devel
|
||||
description = Provides development / debugging functionality for the Metatag module. Integrates with Devel Generate.
|
||||
package = Development
|
||||
core = 7.x
|
||||
tags[] = developer
|
||||
dependencies[] = metatag
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1412909330"
|
||||
|
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:Devel.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for devel_generate_content_form.
|
||||
*
|
||||
* Add extra options.
|
||||
*/
|
||||
function metatag_devel_form_devel_generate_content_form_alter(&$form, &$form_state, $form_id) {
|
||||
$form['metatag_skip'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Skip some meta tag values'),
|
||||
'#options' => array(
|
||||
0 => t("All meta tags given a value"),
|
||||
2 => t('Every 2nd value'),
|
||||
3 => t('Every 3rd value'),
|
||||
4 => t('Every 4th value'),
|
||||
5 => t('Every 5th value'),
|
||||
),
|
||||
'#default' => 0,
|
||||
'#description' => t('Control whether all of the meta tags will be given values, or .'),
|
||||
);
|
||||
|
||||
// Move the submit button to after the rest of the fields.
|
||||
$form['submit']['#weight'] = 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_node_insert().
|
||||
*
|
||||
* Integrate with Devel Generate.
|
||||
*/
|
||||
function metatag_devel_node_insert($node) {
|
||||
// Check to see if the node is generated by Devel Generate.
|
||||
if (isset($node->devel_generate)) {
|
||||
$metatags = array();
|
||||
|
||||
// Max length of words.
|
||||
$title_length = $node->devel_generate['title_length'];
|
||||
|
||||
// Pregenerate the URL.
|
||||
$url = url('<front>', array('absolute' => TRUE));
|
||||
|
||||
// Types of images.
|
||||
$image_types = array('jpg' => 'jpg', 'png' => 'png', 'gif' => 'gif');
|
||||
|
||||
// Optionally skip some meta tags.
|
||||
$skip = $node->devel_generate['metatag_skip'];
|
||||
|
||||
// Generate some meta tags.
|
||||
$count = 0;
|
||||
foreach (metatag_get_info('tags') as $tag => $tag_info) {
|
||||
// Optionally skip records.
|
||||
if (empty($skip) || $count == 0 || (($count % $skip) == 0)) {
|
||||
// Default to ten words per tag.
|
||||
$maxlength = 10;
|
||||
|
||||
// By default, just assume a simple text value.
|
||||
$type = 'text';
|
||||
if (strpos($tag, 'title') !== FALSE) {
|
||||
$maxlength = $title_length;
|
||||
}
|
||||
|
||||
// Allow tags to customize the generation settings.
|
||||
if (!empty($tag_info['devel_generate'])) {
|
||||
if (!empty($tag_info['devel_generate']['type'])) {
|
||||
$type = $tag_info['devel_generate']['type'];
|
||||
}
|
||||
if (!empty($tag_info['devel_generate']['maxlength'])) {
|
||||
$maxlength = $tag_info['devel_generate']['maxlength'];
|
||||
}
|
||||
}
|
||||
|
||||
// Work out how to handle possibly more complicated meta tags.
|
||||
elseif (isset($tag_info['form']) && is_array($tag_info['form'])) {
|
||||
// Textarea fields can be longer than other tags.
|
||||
if (isset($tag_info['form']['#type']) && $tag_info['form']['#type'] == 'textarea') {
|
||||
$maxlength = 20;
|
||||
}
|
||||
// Anything with an '#options' value will have one item picked at
|
||||
// random.
|
||||
elseif (isset($tag_info['form']['#options'])) {
|
||||
$type = 'select';
|
||||
}
|
||||
}
|
||||
|
||||
// Simple values.
|
||||
if ($type == 'text') {
|
||||
$metatags[$tag]['value'] = devel_create_greeking($maxlength, TRUE);
|
||||
}
|
||||
|
||||
// Select lists, pick a value at random.
|
||||
elseif ($type == 'select') {
|
||||
// Nested arrays, aka opgroups - collapse it down to one level.
|
||||
if (is_array($tag_info['form']['#options'])) {
|
||||
$options = array();
|
||||
foreach ($tag_info['form']['#options'] as $option => $subopts) {
|
||||
if (is_array($subopts)) {
|
||||
$options += array_keys($subopts);
|
||||
}
|
||||
else {
|
||||
$options[] = $option;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$options = $tag_info['form']['#options'];
|
||||
}
|
||||
$metatags[$tag]['value'] = array_rand(drupal_map_assoc($options));
|
||||
|
||||
// Support checkboxes, which require the default value be an array.
|
||||
if ($tag_info['class'] == 'DrupalListMetaTag') {
|
||||
$metatags[$tag]['value'] = array($metatags[$tag]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// URL values.
|
||||
elseif ($type == 'url') {
|
||||
$metatags[$tag]['value'] = $url . strtolower(str_replace(' ', '/', devel_create_greeking($maxlength, TRUE)));
|
||||
}
|
||||
|
||||
// Image URL values.
|
||||
elseif ($type == 'image') {
|
||||
$filepath = strtolower(str_replace(' ', '/', devel_create_greeking($maxlength, TRUE)));
|
||||
$ext = array_rand($image_types);
|
||||
$metatags[$tag]['value'] = $url . $filepath . '.' . $ext;
|
||||
}
|
||||
|
||||
// Integers, generate an integer between 0 and 999.
|
||||
elseif ($type == 'integer') {
|
||||
$metatags[$tag]['value'] = rand(0, 999);
|
||||
}
|
||||
|
||||
// Floats, generate an integer between 0 and 999.
|
||||
elseif ($type == 'float') {
|
||||
$metatags[$tag]['value'] = rand(0, 999) . '.' . rand(0, 999);
|
||||
}
|
||||
|
||||
// Phone numbers will be given the US format of XXX-XXX-XXXX.
|
||||
elseif ($type == 'phone') {
|
||||
$metatags[$tag]['value'] = rand(100, 999) . '-' . rand(100, 999) . '-' . rand(1000, 9999);
|
||||
}
|
||||
|
||||
// Email addresses.
|
||||
elseif ($type == 'email') {
|
||||
$metatags[$tag]['value'] = strtolower(devel_create_greeking(1, TRUE) . '@' . devel_create_greeking(1, TRUE) . '.com');
|
||||
}
|
||||
|
||||
// Canonical URL values - just fill in the absolute URL for the current
|
||||
// page.
|
||||
elseif ($type == 'canonical') {
|
||||
$metatags[$tag]['value'] = '[current-page:url:absolute]';
|
||||
}
|
||||
|
||||
// Twitter usernames.
|
||||
elseif ($type == 'twitter') {
|
||||
$metatags[$tag]['value'] = '@' . devel_create_greeking(1, TRUE);
|
||||
}
|
||||
|
||||
// Replace spaces in keyword fields with commas.
|
||||
if (strpos($tag, 'keyword') !== FALSE) {
|
||||
$metatags[$tag]['value'] = str_replace(' ', ',', $metatags[$tag]['value']);
|
||||
}
|
||||
}
|
||||
|
||||
// Bump the counter.
|
||||
$count++;
|
||||
}
|
||||
|
||||
// Save the meta tags.
|
||||
metatag_metatags_save('node', $node->nid, $node->vid, $metatags, $node->language);
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
name = Metatag: Facebook
|
||||
description = "Provides support for Facebook's custom meta tags."
|
||||
package = SEO
|
||||
core = 7.x
|
||||
dependencies[] = metatag
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1412909330"
|
||||
|
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Installation and update scripts for Metatag:Facebook.
|
||||
*/
|
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag:Facebook module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_metatag_info().
|
||||
*/
|
||||
function metatag_facebook_metatag_info() {
|
||||
$info['groups']['facebook'] = array(
|
||||
'label' => t('Facebook'),
|
||||
'description' => t("Meta tags used to integrate with Facebook's APIs. Most sites do not need to use these, they are primarily of benefit for sites using either the Facebook widgets, the Facebook Connect single-signon system, or are using Facebook's APIs in a custom way. Sites that do need these meta tags usually will only need to set them globally."),
|
||||
'form' => array(
|
||||
'#weight' => 55,
|
||||
),
|
||||
);
|
||||
|
||||
// Facebook meta tags stack after the simple tags.
|
||||
$weight = 20;
|
||||
|
||||
// Default values for each meta tag.
|
||||
$tag_info_defaults = array(
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'facebook',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_property',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['fb:admins'] = array(
|
||||
'label' => t('Admins'),
|
||||
'description' => t('A comma-separated list of Facebook user IDs of people who are considered administrators or moderators of this page.'),
|
||||
'weight' => ++$weight,
|
||||
) + $tag_info_defaults;
|
||||
|
||||
$info['tags']['fb:app_id'] = array(
|
||||
'label' => t('Application ID'),
|
||||
'description' => t('A comma-separated list of Facebook Platform Application IDs applicable for this site.'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
) + $tag_info_defaults;
|
||||
|
||||
// If the FB_Social module is installed already, disable the app_id field.
|
||||
if (module_exists('fb_social')) {
|
||||
$info['tags']['fb:app_id']['form']['#disabled'] = TRUE;
|
||||
$info['tags']['fb:app_id']['form']['#description'] = t('The FB_Social module will automatically output this meta tag, go to the <a href="!fb_social">FB_Social settings page</a> to customize it.', array('!fb_social' => url('admin/config/user-interface/fb_social')));
|
||||
}
|
||||
|
||||
return $info;
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag:Facebook.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_api().
|
||||
*/
|
||||
function metatag_facebook_ctools_plugin_api($owner, $api) {
|
||||
if ($owner == 'metatag' && $api == 'metatag') {
|
||||
return array('version' => 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_html().
|
||||
*/
|
||||
function metatag_facebook_preprocess_html(&$variables) {
|
||||
$variables['rdf_namespaces'] .= "\n xmlns:fb=\"http://ogp.me/ns/fb#\"";
|
||||
}
|
||||
|
||||
/*
|
||||
fb:admins
|
||||
fb:app_id
|
||||
*/
|
@@ -0,0 +1,60 @@
|
||||
Metatag: Google+
|
||||
-----------------
|
||||
This module adds support for meta tag configuration for Google+ Snippet [1].
|
||||
|
||||
The following Google+ tags are provided:
|
||||
|
||||
* itemprop:name
|
||||
* itemprop:description
|
||||
* itemprop:image
|
||||
|
||||
Also itemtype is provided to add schema in the HTML markup as follows:
|
||||
|
||||
<html itemscope itemtype="http://schema.org/Article">
|
||||
|
||||
|
||||
Usage
|
||||
--------------------------------------------------------------------------------
|
||||
Page type (itemtype) provides default type options from the Google+ Snippet page
|
||||
[1]; to add other types either install select_or_other module [2] or use the
|
||||
Metatag hooks (see metatag.api.php).
|
||||
|
||||
|
||||
Known Issues
|
||||
--------------------------------------------------------------------------------
|
||||
- When using Zen or its derived theme, the RDF Namespaces will be serialized
|
||||
into an RDFa 1.1 prefix attribute, which means itemtype will be included in
|
||||
prefix="...". To avoid this problem, this module will not add a itemtype
|
||||
directly to $variable['rdf_namespaces'], instead, it will be necessary to add
|
||||
code manually in the template.php or the custom theme.
|
||||
|
||||
Example code to use and adapt as needed:
|
||||
|
||||
/**
|
||||
* Implements template_preprocess_html().
|
||||
*
|
||||
* Add itemtype code for Google+ in the 'html_attributes_array' which is only
|
||||
* available in Zen theme. Note Zen will convert rdf_namespaces to RDFa 1.1 with
|
||||
* prefix, so putting itemtype there will cause it to be added to the
|
||||
* prefix="itemtype=..." attribute.
|
||||
*
|
||||
* @see zen_preprocess_html()
|
||||
*/
|
||||
function MYTHEME_preprocess_html(&$variables, $hook) {
|
||||
if (module_exists('metatag_google_plus') && isset($variables['itemtype'])) {
|
||||
$variables['html_attributes_array']['itemscope itemtype'] = "http://schema.org/{$variables['itemtype']}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Credits / Contact
|
||||
--------------------------------------------------------------------------------
|
||||
Originally developed by Eric Chen [3] and sponsored by Monkii [4].
|
||||
|
||||
|
||||
References
|
||||
--------------------------------------------------------------------------------
|
||||
1: https://developers.google.com/+/web/snippet/
|
||||
2. https://drupal.org/project/select_or_other
|
||||
3: https://drupal.org/user/265729
|
||||
4: http://monkii.com
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Metatag controller for Google+.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Schema meta tag controller.
|
||||
*
|
||||
* This extends DrupalTextMetaTag as we need to alter variables in
|
||||
* template_preprocess_html() rather output a normal meta tag.
|
||||
*
|
||||
* This controller is little different from DrupalTitleMetaTag and same value in
|
||||
* the itemtype instead of title. So in the MYTHEME_preprocess_html(),
|
||||
* $variable['itemtype'] will be provided.
|
||||
*/
|
||||
class DrupalSchemaMetaTag extends DrupalTextMetaTag {
|
||||
|
||||
public function getElement(array $options = array()) {
|
||||
$element = array();
|
||||
$value = $this->getValue($options);
|
||||
$element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'itemtype', $value);
|
||||
return $element;
|
||||
}
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
name = Metatag: Google+
|
||||
description = "Provides support for Google+ 'itemscope' meta tags."
|
||||
package = SEO
|
||||
core = 7.x
|
||||
|
||||
dependencies[] = metatag
|
||||
|
||||
files[] = metatag_google_plus.inc
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1412909330"
|
||||
|
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Metatag integration for the Metatag Google+ module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_metatag_bundled_config_alter().
|
||||
*/
|
||||
function metatag_google_plus_metatag_bundled_config_alter(array &$configs) {
|
||||
foreach ($configs as &$config) {
|
||||
switch ($config->instance) {
|
||||
case 'global':
|
||||
$config->config += array(
|
||||
'itemprop:name' => array('value' => '[current-page:title]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'global:frontpage':
|
||||
$config->config += array(
|
||||
'itemprop:name' => array('value' => '[current-page:title]'),
|
||||
);
|
||||
break;
|
||||
|
||||
// On error pages point everything to the homepage.
|
||||
case 'global:403':
|
||||
case 'global:404':
|
||||
$config->config += array(
|
||||
'itemprop:name' => array('value' => '[current-page:title]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
$config->config += array(
|
||||
'itemprop:description' => array('value' => '[node:summary]'),
|
||||
'itemprop:name' => array('value' => '[current-page:title]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'taxonomy_term':
|
||||
$config->config += array(
|
||||
'itemprop:description' => array('value' => '[term:description]'),
|
||||
'itemprop:name' => array('value' => '[term:name]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
$config->config += array(
|
||||
'itemprop:name' => array('value' => '[user:name]'),
|
||||
);
|
||||
if (variable_get('user_pictures')) {
|
||||
$config->config += array(
|
||||
'itemprop:image' => array('value' => '[user:picture:url]'),
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_metatag_info().
|
||||
*/
|
||||
function metatag_google_plus_metatag_info() {
|
||||
$info['groups']['google-plus'] = array(
|
||||
'label' => t('Google+'),
|
||||
'description' => t('A set of meta tags specially for controlling the summaries displayed when content is shared on <a href="!url">Google+</a>.', array('!url' => 'https://plus.google.com/')),
|
||||
'form' => array(
|
||||
'#weight' => 70,
|
||||
),
|
||||
);
|
||||
|
||||
// Google+ meta tags stack after the Twitter Cards tags.
|
||||
$weight = 60;
|
||||
|
||||
// Defaults used for all cards.
|
||||
$defaults = array(
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'google-plus',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_google_plus',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['itemtype'] = array(
|
||||
'label' => t('Page type'),
|
||||
'description' => t('Schema type. <a href="!url">More schema info</a>. If your page type does not exist in options above, please install <a href="!url2">select_or_other</a> module to enter page type manually.', array('!url' => 'http://schema.org/docs/schemas.html', '!url2' => 'https://drupal.org/project/select_or_other')),
|
||||
'class' => 'DrupalSchemaMetaTag',
|
||||
'weight' => ++$weight,
|
||||
'form' => array(
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'Article' => t('Article'),
|
||||
'Blog' => t('Blog'),
|
||||
'Book' => t('Book'),
|
||||
'Event' => t('Event'),
|
||||
'LocalBusiness' => t('Local Business'),
|
||||
'Organization' => t('Organization'),
|
||||
'Person' => t('Person'),
|
||||
'Product' => t('Product'),
|
||||
'Review' => t('Review'),
|
||||
),
|
||||
'#empty_option' => t('- None -'),
|
||||
),
|
||||
) + $defaults;
|
||||
|
||||
if (module_exists('select_or_other')) {
|
||||
$info['tags']['itemtype']['form']['#type'] = 'select_or_other';
|
||||
$info['tags']['itemtype']['form']['#other'] = 'Other (please type a value)';
|
||||
$info['tags']['itemtype']['form']['#multiple'] = FALSE;
|
||||
$info['tags']['itemtype']['form']['#other_unknown_defaults'] = 'other';
|
||||
$info['tags']['itemtype']['form']['#select_type'] = 'select';
|
||||
}
|
||||
|
||||
$info['tags']['itemprop:name'] = array(
|
||||
'label' => t('Title'),
|
||||
'description' => t('A Google+ title for the page being shared. Keep keywords towards the front.'),
|
||||
'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+'),
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['itemprop:image'] = array(
|
||||
'label' => t('Image URL'),
|
||||
'description' => t('The URL to a unique image representing the content of the page. Do not use a generic image such as your website logo, author photo, or other image that spans multiple pages. '),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'image',
|
||||
),
|
||||
) + $defaults;
|
||||
|
||||
return $info;
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Primary hook implementations for Metatag: Google+.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_ctools_plugin_api().
|
||||
*/
|
||||
function metatag_google_plus_ctools_plugin_api($owner, $api) {
|
||||
if ($owner == 'metatag' && $api == 'metatag') {
|
||||
return array('version' => 1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function metatag_google_plus_theme() {
|
||||
$info['metatag_google_plus'] = array(
|
||||
'render element' => 'element',
|
||||
);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme callback for an Google+ meta tag.
|
||||
*
|
||||
* The format is:
|
||||
* <meta itemprop="[itemprop]" content="[value]" />
|
||||
*/
|
||||
function theme_metatag_google_plus($variables) {
|
||||
$element = &$variables['element'];
|
||||
|
||||
// The format is e.g. 'itemprop:name'. Remove 'itemprop:' and store the rest
|
||||
// in '#itemprop'.
|
||||
$element['#itemprop'] = substr($element['#name'], 9);
|
||||
element_set_attributes($element, array('#itemprop' => 'itemprop', '#value' => 'content'));
|
||||
unset($element['#value']);
|
||||
|
||||
return theme('html_tag', $variables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_html().
|
||||
*
|
||||
* Add itemtype when available.
|
||||
*
|
||||
* We will not add itemtype in the rdf_namespaces when using Zen and its derived
|
||||
* themes as Zen will serialize RDF Namespaces into an RDFa 1.1 prefix
|
||||
* attribute, which means itemtype will be included in prefix="...".
|
||||
*
|
||||
* @see zen_preprocess_html()
|
||||
*/
|
||||
function metatag_google_plus_preprocess_html(&$variables) {
|
||||
if (isset($variables['itemtype']) && !function_exists('zen_preprocess_html')) {
|
||||
$variables['rdf_namespaces'] .= "\n itemscope itemtype= \"http://schema.org/{$variables['itemtype']}\"";
|
||||
}
|
||||
}
|
@@ -1,12 +1,12 @@
|
||||
name = Metatag: Open Graph
|
||||
description = Provides support for open graph meta tags.
|
||||
name = Metatag:OpenGraph
|
||||
description = Provides support for Open Graph Protocol meta tags.
|
||||
package = SEO
|
||||
core = 7.x
|
||||
dependencies[] = metatag
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
datestamp = "1412909330"
|
||||
|
||||
|
@@ -35,3 +35,22 @@ function metatag_opengraph_install() {
|
||||
drupal_set_message(t('The core RDF module is known to cause validation problems for Open Graph meta tags. Unless it is actually needed for the site, it may be worthwhile to disable the RDF module to avoid any possible problems for the Open Graph integration.'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementations of hook_update_N().
|
||||
*/
|
||||
|
||||
/**
|
||||
* Enable the new Metatag:Facebook submodule.
|
||||
*/
|
||||
function metatag_opengraph_update_7100() {
|
||||
module_enable(array('metatag_facebook'));
|
||||
drupal_set_message(t('Enabled the new Metatag:Facebook submodule. If the Facebook meta tags are not being used then it is safe to disable.'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave a warning about the two og:type value changes.
|
||||
*/
|
||||
function metatag_opengraph_update_7101() {
|
||||
drupal_set_message(t('The "Movie" and "TV Show" values for the "Content type" open graph meta tag changed, if this site used those values they will need to be manually updated.'));
|
||||
}
|
||||
|
@@ -5,49 +5,67 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_metatag_config_default_alter().
|
||||
* Implements hook_metatag_bundled_config_alter().
|
||||
*/
|
||||
function metatag_opengraph_metatag_config_default_alter(array &$configs) {
|
||||
function metatag_opengraph_metatag_bundled_config_alter(array &$configs) {
|
||||
foreach ($configs as &$config) {
|
||||
switch ($config->instance) {
|
||||
case 'global':
|
||||
$config->config += array(
|
||||
'og:type' => array('value' => 'article'),
|
||||
'og:title' => array('value' => '[current-page:title]'),
|
||||
'og:site_name' => array('value' => '[site:name]'),
|
||||
'og:title' => array('value' => '[current-page:title]'),
|
||||
'og:type' => array('value' => 'article'),
|
||||
'og:url' => array('value' => '[current-page:url:absolute]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'global:frontpage':
|
||||
$config->config += array(
|
||||
'og:type' => array('value' => 'website'),
|
||||
'og:description' => array('value' => '[site:slogan]'),
|
||||
'og:title' => array('value' => '[site:name]'),
|
||||
'og:type' => array('value' => 'website'),
|
||||
'og:url' => array('value' => '[site:url]'),
|
||||
);
|
||||
break;
|
||||
|
||||
// On error pages point everything to the homepage.
|
||||
case 'global:403':
|
||||
case 'global:404':
|
||||
$config->config += array(
|
||||
'og:title' => array('value' => '[site:name]'),
|
||||
'og:type' => array('value' => 'website'),
|
||||
'og:url' => array('value' => '[site:url]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
$config->config += array(
|
||||
'og:title' => array('value' => '[node:title]'),
|
||||
'article:modified_time' => array('value' => '[node:changed:custom:c]'),
|
||||
'article:published_time' => array('value' => '[node:created:custom:c]'),
|
||||
'og:description' => array('value' => '[node:summary]'),
|
||||
'og:title' => array('value' => '[node:title]'),
|
||||
'og:updated_time' => array('value' => '[node:changed:custom:c]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'taxonomy_term':
|
||||
$config->config += array(
|
||||
'og:title' => array('value' => '[term:name]'),
|
||||
'og:description' => array('value' => '[term:description]'),
|
||||
'og:title' => array('value' => '[term:name]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
$config->config += array(
|
||||
'og:type' => array('value' => 'profile'),
|
||||
'og:title' => array('value' => '[user:name]'),
|
||||
'og:type' => array('value' => 'profile'),
|
||||
'profile:username' => array('value' => '[user:name]'),
|
||||
);
|
||||
if (variable_get('user_pictures')) {
|
||||
$config->config += array(
|
||||
'og:image' => array('value' => '[user:picture:url]'),
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -59,79 +77,54 @@ function metatag_opengraph_metatag_config_default_alter(array &$configs) {
|
||||
function metatag_opengraph_metatag_info() {
|
||||
$info['groups']['open-graph'] = array(
|
||||
'label' => t('Open Graph'),
|
||||
'description' => t("The <a href=\"@ogp\">Open Graph meta tags</a> are used control how Facebook, LinkedIn an other social networking sites interpret the site's content.", array('@ogp' => 'http://ogp.me/')),
|
||||
'form' => array(
|
||||
'#weight' => 50,
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['fb:admins'] = array(
|
||||
'label' => t('Facebook Admins'),
|
||||
'description' => t('A comma-separated list of Facebook user IDs of people who are considered administrators or moderators of this page. Most sites will only need to assign this on the global settings page.'),
|
||||
// Default values for each meta tag.
|
||||
$og_defaults = array(
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
'#theme' => 'metatag_property',
|
||||
),
|
||||
);
|
||||
$info['tags']['fb:app_id'] = array(
|
||||
'label' => t('Facebook Application ID'),
|
||||
'description' => t('A comma-separated list of Facebook Platform Application IDs applicable for this site. Most sites will only need to assign this on the global settings page.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
if (module_exists('fb_social')) {
|
||||
$info['tags']['fb:app_id']['form']['#disabled'] = TRUE;
|
||||
$info['tags']['fb:app_id']['form']['#description'] = t('The FB_Social module will automatically output this meta tag, go to the <a href="!fb_social">FB_Social settings page</a> to customize it.', array('!fb_social' => url('admin/config/user-interface/fb_social')));
|
||||
}
|
||||
|
||||
// Open Graph meta tags stack after the Facebook tags.
|
||||
$weight = 25;
|
||||
|
||||
$info['tags']['og:site_name'] = array(
|
||||
'label' => t('Open Graph site name'),
|
||||
'description' => t('A human-readable name for your site, e.g., <em>IMDb</em>.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'label' => t('Site name'),
|
||||
'description' => t('A human-readable name for the site, e.g., <em>IMDb</em>.'),
|
||||
'context' => array('global'),
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['og:title'] = array(
|
||||
'label' => t('Open Graph title'),
|
||||
'description' => t('The title of your object as it should appear within the graph, e.g., <em>The Rock</em>.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['og:description'] = array(
|
||||
'label' => t('Open Graph description'),
|
||||
'description' => t('A one to two sentence description of your page.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:type'] = array(
|
||||
'label' => t('Open Graph type'),
|
||||
'description' => t('The type of your object, e.g., <em>movie</em>.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
'label' => t('Content type'),
|
||||
'description' => t('The type of the content, e.g., <em>movie</em>.'),
|
||||
'weight' => ++$weight,
|
||||
'form' => array(
|
||||
'#type' => 'select',
|
||||
'#options' => _metatag_opengraph_type_options(),
|
||||
'#empty_option' => t('- None -'),
|
||||
),
|
||||
);
|
||||
'devel_generate' => array(
|
||||
'type' => 'select',
|
||||
),
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:url'] = array(
|
||||
'label' => t('Page URL'),
|
||||
'description' => t('Preferred page location or URL to help eliminate duplicate content for search engines, e.g., <em>http://www.imdb.com/title/tt0117500/</em>.'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'canonical',
|
||||
),
|
||||
) + $og_defaults;
|
||||
|
||||
if (module_exists('select_or_other')) {
|
||||
// Enhance the og:type field to support custom types.
|
||||
@@ -142,172 +135,411 @@ function metatag_opengraph_metatag_info() {
|
||||
$info['tags']['og:type']['form']['#element_validate'] = array('select_or_other_element_validate');
|
||||
}
|
||||
|
||||
$info['tags']['og:image'] = array(
|
||||
'label' => t('Open Graph image'),
|
||||
'description' => t('An image URL which should represent your object within the graph. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1. We support PNG, JPEG and GIF formats.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:title'] = array(
|
||||
'label' => t('Content title'),
|
||||
'description' => t('The title of the content, e.g., <em>The Rock</em>.'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:url'] = array(
|
||||
'label' => t('Open Graph URL'),
|
||||
'description' => t('The canonical URL of your object that will be used as its permanent ID in the graph, e.g., <em>http://www.imdb.com/title/tt0117500/</em>.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['og:latitude'] = array(
|
||||
'label' => t('Open Graph Latitude'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:longitude'] = array(
|
||||
'label' => t('Open Graph Longitude'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['og:street-address'] = array(
|
||||
'label' => t('Open Graph Street Address'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:locality'] = array(
|
||||
'label' => t('Open Graph Locality'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:region'] = array(
|
||||
'label' => t('Open Graph Region'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:postal-code'] = array(
|
||||
'label' => t('Open Graph Postal Code'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:country-name'] = array(
|
||||
'label' => t('Open Graph Country Name'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['og:email'] = array(
|
||||
'label' => t('Open Graph Email'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:phone_number'] = array(
|
||||
'label' => t('Open Graph Phone Number'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:fax_number'] = array(
|
||||
'label' => t('Open Graph Fax Number'),
|
||||
'description' => '',
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['og:video'] = array(
|
||||
'label' => t('Open Graph Video (URL)'),
|
||||
'description' => t('A URL to a video file that complements this object.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:video:secure_url'] = array(
|
||||
'label' => t('Open Graph Video Secure'),
|
||||
'description' => t('A URL to a video file that complements this object using the HTTPS protocol.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:video:width'] = array(
|
||||
'label' => t('Open Graph Video Width'),
|
||||
'description' => t('The width of the video.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:video:height'] = array(
|
||||
'label' => t('Open Graph Video Height'),
|
||||
'description' => t('The height of the video.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
);
|
||||
$info['tags']['og:video:type'] = array(
|
||||
'label' => t('Open Graph Video Type'),
|
||||
'description' => t('The type of the video file.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'open-graph',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_opengraph',
|
||||
),
|
||||
$info['tags']['og:determiner'] = array(
|
||||
'label' => t('Content title determiner'),
|
||||
'description' => t("The word that appears before the content's title in a sentence. The default ignores this value, the 'Automatic' value should be sufficient if this is actually needed."),
|
||||
'weight' => ++$weight,
|
||||
'form' => array(
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'application/x-shockwave-flash' => 'Flash - playable directly from the feed',
|
||||
'text/html' => 'Separate HTML page',
|
||||
'auto' => 'Automatic',
|
||||
'a' => 'A',
|
||||
'an' => 'An',
|
||||
'the' => 'The',
|
||||
),
|
||||
'#empty_option' => t('- Ignore -'),
|
||||
),
|
||||
'devel_generate' => array(
|
||||
'type' => 'select',
|
||||
),
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:description'] = array(
|
||||
'label' => t('Content description'),
|
||||
'description' => t('A one to two sentence description of the content.'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
|
||||
// Basic tags.
|
||||
$info['tags']['og:updated_time'] = array(
|
||||
'label' => t('Content modification date & time'),
|
||||
'description' => t("The date this content was last modified, with an optional time value. Needs to be in <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601</a> format. Can be the same as the 'Article modification date' tag."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:see_also'] = array(
|
||||
'label' => t('See also'),
|
||||
'description' => t('URLs to related content.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:image'] = array(
|
||||
'label' => t('Image URL'),
|
||||
'description' => t('The URL of an image which should represent the content. For best results use an image that is at least 1200 x 630 pixels in size, but at least 600 x 316 pixels is a recommended minimum. Supports PNG, JPEG and GIF formats.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'image',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:image:secure_url'] = array(
|
||||
'label' => t('Secure image URL'),
|
||||
'description' => t('The secure URL (HTTPS) of an image which should represent the content. The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1. Supports PNG, JPEG and GIF formats. All "http://" URLs will automatically be converted to "https://".'),
|
||||
'multiple' => TRUE,
|
||||
'secure' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'image',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:image:type'] = array(
|
||||
'label' => t('Image type'),
|
||||
'description' => t('The type of image referenced above. Should be either "image/gif" for a GIF image, "image/jpeg" for a JPG/JPEG image, or "image/png" for a PNG image.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:image:width'] = array(
|
||||
'label' => t('Image width'),
|
||||
'description' => t('The width of the above image(s). Note: if both the unsecured and secured images are provided, they should both be the same size.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'image',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:image:height'] = array(
|
||||
'label' => t('Image height'),
|
||||
'description' => t('The height of the above image(s). Note: if both the unsecured and secured images are provided, they should both be the same size.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'image',
|
||||
),
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:latitude'] = array(
|
||||
'label' => t('Latitude'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'float',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:longitude'] = array(
|
||||
'label' => t('Longitude'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'float',
|
||||
),
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:street-address'] = array(
|
||||
'label' => t('Street address'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:locality'] = array(
|
||||
'label' => t('Locality'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:region'] = array(
|
||||
'label' => t('Region'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:postal-code'] = array(
|
||||
'label' => t('Postal/ZIP code'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:country-name'] = array(
|
||||
'label' => t('Country name'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:email'] = array(
|
||||
'label' => t('Email'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'email',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:phone_number'] = array(
|
||||
'label' => t('Phone number'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'phone',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:fax_number'] = array(
|
||||
'label' => t('Fax number'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'phone',
|
||||
),
|
||||
) + $og_defaults;
|
||||
|
||||
$info['tags']['og:locale'] = array(
|
||||
'label' => t('Locale'),
|
||||
'description' => 'The locale these tags are marked up in, must be in the format language_TERRITORY. Default is en_US.',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'maxlength' => 1,
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:locale:alternate'] = array(
|
||||
'label' => t('Alternative locales'),
|
||||
'description' => 'Other locales this content is available in, must be in the format language_TERRITORY, e.g. "fr_FR".',
|
||||
'weight' => ++$weight,
|
||||
'multiple' => TRUE,
|
||||
'devel_generate' => array(
|
||||
'maxlength' => 1,
|
||||
),
|
||||
) + $og_defaults;
|
||||
|
||||
// For the "article" og:type.
|
||||
$article_defaults = array(
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'og:type',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'value',
|
||||
'value' => 'article',
|
||||
),
|
||||
'#empty_option' => t('- None -'),
|
||||
),
|
||||
);
|
||||
$info['tags']['article:author'] = array(
|
||||
'label' => t('Article author'),
|
||||
'description' => t("Links an article to an author's Facebook profile, should be either URLs to the author's profile page or their Facebook profile IDs."),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $article_defaults;
|
||||
$info['tags']['article:publisher'] = array(
|
||||
'label' => t('Article publisher'),
|
||||
'description' => t("Links an article to a publisher's Facebook page."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $article_defaults;
|
||||
$info['tags']['article:section'] = array(
|
||||
'label' => t('Article section'),
|
||||
'description' => t('The primary section of this website the content belongs to.'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $article_defaults;
|
||||
$info['tags']['article:tag'] = array(
|
||||
'label' => t('Article tag(s)'),
|
||||
'description' => t('Appropriate keywords for this content.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $article_defaults;
|
||||
$info['tags']['article:published_time'] = array(
|
||||
'label' => t('Article publication date & time'),
|
||||
'description' => t("The date this content was published on, with an optional time value. Needs to be in <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601</a> format."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $article_defaults;
|
||||
$info['tags']['article:modified_time'] = array(
|
||||
'label' => t('Article modification date & time'),
|
||||
'description' => t("The date this content was last modified, with an optional time value. Needs to be in <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601</a> format."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $article_defaults;
|
||||
$info['tags']['article:expiration_time'] = array(
|
||||
'label' => t('Article expiration date & time'),
|
||||
'description' => t("The date this content will expire, with an optional time value. Needs to be in <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601</a> format."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $article_defaults;
|
||||
|
||||
// For the "profile" og:type.
|
||||
$profile_defaults = array(
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'og:type',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'value',
|
||||
'value' => 'profile',
|
||||
),
|
||||
),
|
||||
);
|
||||
$info['tags']['profile:first_name'] = array(
|
||||
'label' => t('First name'),
|
||||
'description' => t("The first name of the person who's Profile page this is."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $profile_defaults;
|
||||
$info['tags']['profile:last_name'] = array(
|
||||
'label' => t('Last name'),
|
||||
'description' => t("The person's last name."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $profile_defaults;
|
||||
$info['tags']['profile:username'] = array(
|
||||
'label' => t('Username'),
|
||||
'description' => t("A pseudonym / alias of this person."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $profile_defaults;
|
||||
$info['tags']['profile:gender'] = array(
|
||||
'label' => t('Gender'),
|
||||
'description' => t("Any of Facebook's gender values should be allowed, the initial two being 'male' and 'female'."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $profile_defaults;
|
||||
|
||||
// Tags related to audio.
|
||||
$info['tags']['og:audio'] = array(
|
||||
'label' => t('Audio URL'),
|
||||
'description' => t('The URL to an audio file that complements this object.'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:audio:secure_url'] = array(
|
||||
'label' => t('Audio secure URL'),
|
||||
'description' => t('The secure URL to an audio file that complements this object. All "http://" URLs will automatically be converted to "https://".'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:audio:type'] = array(
|
||||
'label' => t('Audio type'),
|
||||
'description' => t('The MIME type of the audio file. Examples include "application/mp3" for an MP3 file.'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
|
||||
// For the "book" og:type.
|
||||
$book_defaults = array(
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'og:type',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'value',
|
||||
'value' => 'book',
|
||||
),
|
||||
),
|
||||
);
|
||||
$info['tags']['book:author'] = array(
|
||||
'label' => t("Book's author"),
|
||||
'description' => t("Links to the book's author's Facebook profile, should be either URLs to the author's profile page or their Facebook profile IDs."),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $book_defaults;
|
||||
$info['tags']['book:isbn'] = array(
|
||||
'label' => t("Book's ISBN"),
|
||||
'description' => t("The book's <a href=\"http://en.wikipedia.org/wiki/International_Standard_Book_Number\">International Standard Book Number</a>, which may be in one of several formats."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $book_defaults;
|
||||
$info['tags']['book:release_date'] = array(
|
||||
'label' => t('Book release date'),
|
||||
'description' => t("The date this content will expire, with an optional time value. Needs to be in <a href='http://en.wikipedia.org/wiki/ISO_8601'>ISO 8601</a> format."),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $book_defaults;
|
||||
$info['tags']['book:tag'] = array(
|
||||
'label' => t('Book tags'),
|
||||
'description' => t('Appropriate keywords for this book.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $book_defaults;
|
||||
|
||||
// For the "video" og:type.
|
||||
$video_defaults = array();
|
||||
// 'dependencies' => array(
|
||||
// array(
|
||||
// 'dependency' => 'og:type',
|
||||
// 'attribute' => 'value',
|
||||
// 'condition' => 'value',
|
||||
// 'value' => 'profile',
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
$info['tags']['og:video'] = array(
|
||||
'label' => t('Video URL'),
|
||||
'description' => t('The URL to a video file that complements this object.'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:video:secure_url'] = array(
|
||||
'label' => t('Video secure URL'),
|
||||
'description' => t('A URL to a video file that complements this object using the HTTPS protocol. All "http://" URLs will automatically be converted to "https://".'),
|
||||
'secure' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:video:width'] = array(
|
||||
'label' => t('Video width'),
|
||||
'description' => t('The width of the video.'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:video:height'] = array(
|
||||
'label' => t('Video height'),
|
||||
'description' => t('The height of the video.'),
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
) + $og_defaults;
|
||||
$info['tags']['og:video:type'] = array(
|
||||
'label' => t('Video type'),
|
||||
'description' => t('The MIME type of the video file. Examples include "application/x-shockwave-flash" for a Flash video, or "text/html" if this is a standalone web page containing a video.'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults;
|
||||
$info['tags']['video:actor'] = array(
|
||||
'label' => t('Actor(s)'),
|
||||
'description' => t('Links to the Facebook profiles for actor(s) that appear in the video.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $video_defaults;
|
||||
$info['tags']['video:actor:role'] = array(
|
||||
'label' => t("Actors' role"),
|
||||
'description' => t("The roles of the actor(s)."),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $video_defaults;
|
||||
$info['tags']['video:director'] = array(
|
||||
'label' => t('Director(s)'),
|
||||
'description' => t('Links to the Facebook profiles for director(s) that worked on the video.'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $video_defaults;
|
||||
$info['tags']['video:writer'] = array(
|
||||
'label' => t('Scriptwriter(s)'),
|
||||
'description' => t('Links to the Facebook profiles for scriptwriter(s) for the video.'),
|
||||
'description' => t("Scriptwriters from the video."),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $video_defaults;
|
||||
$info['tags']['video:duration'] = array(
|
||||
'label' => t('Video duration (seconds)'),
|
||||
'description' => t('The length of the video in seconds'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $video_defaults;
|
||||
$info['tags']['video:release_date'] = array(
|
||||
'label' => t('Release date'),
|
||||
'description' => t('The date the video was released.'),
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $video_defaults;
|
||||
$info['tags']['video:tag'] = array(
|
||||
'label' => t('Tag'),
|
||||
'description' => t('Tag words associated with this video.'),
|
||||
'multiple' => TRUE,
|
||||
'weight' => ++$weight,
|
||||
) + $og_defaults + $video_defaults;
|
||||
$info['tags']['video:series'] = array(
|
||||
'label' => t('Series'),
|
||||
'description' => t('The TV show this series belongs to.'),
|
||||
'weight' => ++$weight,
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'og:type',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'value',
|
||||
'value' => 'video.episode',
|
||||
),
|
||||
),
|
||||
) + $og_defaults + $video_defaults;
|
||||
|
||||
return $info;
|
||||
}
|
||||
@@ -319,7 +551,7 @@ function _metatag_opengraph_type_options() {
|
||||
'sport' => t('Sport'),
|
||||
),
|
||||
t('Businesses') => array(
|
||||
'bar' => t('Bar'),
|
||||
'bar' => t('Bar', array('context' => 'an establishment')),
|
||||
'company' => t('Company'),
|
||||
'cafe' => t('Cafe'),
|
||||
'hotel' => t('Hotel'),
|
||||
@@ -359,10 +591,12 @@ function _metatag_opengraph_type_options() {
|
||||
'drink' => t('Drink'),
|
||||
'food' => t('Food'),
|
||||
'game' => t('Game'),
|
||||
'movie' => t('Movie'),
|
||||
'product' => t('Product'),
|
||||
'song' => t('Song'),
|
||||
'tv_show' => t('TV show'),
|
||||
'video.movie' => t('Movie'),
|
||||
'video.tv_show' => t('TV show'),
|
||||
'video.episode' => t('TV show episode'),
|
||||
'video.other' => t('Miscellaneous video'),
|
||||
),
|
||||
t('Websites') => array(
|
||||
'blog' => t('Blog'),
|
||||
|
@@ -9,6 +9,18 @@ function metatag_opengraph_preprocess_html(&$variables) {
|
||||
if (!module_exists('rdf')) {
|
||||
$variables['rdf_namespaces'] .= "\n xmlns:og=\"http://ogp.me/ns#\"";
|
||||
}
|
||||
|
||||
// @TODO Would it be worth dynamically identifying whether these should be
|
||||
// added, or just output them all?
|
||||
|
||||
// Need an extra namespace for the "article" tags.
|
||||
$variables['rdf_namespaces'] .= "\n xmlns:article=\"http://ogp.me/ns/article#\"";
|
||||
// Need an extra namespace for the "book" tags.
|
||||
$variables['rdf_namespaces'] .= "\n xmlns:book=\"http://ogp.me/ns/book#\"";
|
||||
// Need an extra namespace for the "profile" tags.
|
||||
$variables['rdf_namespaces'] .= "\n xmlns:profile=\"http://ogp.me/ns/profile#\"";
|
||||
// Need an extra namespace for the "video" tags.
|
||||
$variables['rdf_namespaces'] .= "\n xmlns:video=\"http://ogp.me/ns/video#\"";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20,27 +32,6 @@ function metatag_opengraph_ctools_plugin_api($owner, $api) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function metatag_opengraph_theme() {
|
||||
$info['metatag_opengraph'] = array(
|
||||
'render element' => 'element',
|
||||
);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme callback for an OpenGraph meta tag.
|
||||
*/
|
||||
function theme_metatag_opengraph($variables) {
|
||||
$element = &$variables['element'];
|
||||
element_set_attributes($element, array('#name' => 'property', '#value' => 'content'));
|
||||
unset($element['#value']);
|
||||
return theme('html_tag', $variables);
|
||||
}
|
||||
|
||||
/*
|
||||
og:title = [node:title] / [user:name]
|
||||
og:type = article / profile
|
||||
@@ -74,7 +65,4 @@ og:audio:type
|
||||
|
||||
og:upc
|
||||
og:isbn
|
||||
|
||||
fb:admins
|
||||
fb:app_id
|
||||
*/
|
||||
|
@@ -8,9 +8,9 @@ dependencies[] = metatag
|
||||
dependencies[] = panels
|
||||
dependencies[] = token
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
datestamp = "1412909330"
|
||||
|
||||
|
@@ -56,10 +56,15 @@ function metatag_panels_form($form, $form_state) {
|
||||
// Don't set any metatag instance name as the configuration data is managed locally within panels.
|
||||
$instance = '';
|
||||
$options = array('token types' => $token_types);
|
||||
$conf = empty($handler->conf['metatag_panels']) ? array() : $handler->conf['metatag_panels']['metatags'];
|
||||
$metatags = empty($handler->conf['metatag_panels']) ? array() : $handler->conf['metatag_panels']['metatags'];
|
||||
|
||||
// This leaves some possibility for future versions to support translation.
|
||||
if (!isset($metatags[LANGUAGE_NONE])) {
|
||||
$metatags = array(LANGUAGE_NONE => $metatags);
|
||||
}
|
||||
|
||||
// Load the metatag form (passed by reference).
|
||||
metatag_metatags_form($form, $instance, $conf, $options);
|
||||
metatag_metatags_form($form, $instance, $metatags[LANGUAGE_NONE], $options);
|
||||
|
||||
// Modify metatag form defaults.
|
||||
$form['metatags']['#collapsible'] = FALSE;
|
||||
@@ -81,7 +86,7 @@ function metatag_panels_form($form, $form_state) {
|
||||
function metatag_panels_form_submit($form, $form_state) {
|
||||
$conf = array(
|
||||
'enabled' => $form_state['values']['metatags_enabled'],
|
||||
'metatags' => $form_state['values']['metatags'],
|
||||
'metatags' => $form_state['values']['metatags'][LANGUAGE_NONE],
|
||||
);
|
||||
|
||||
$form_state['handler']->conf['metatag_panels'] = $conf;
|
||||
@@ -99,8 +104,26 @@ function metatag_panels_ctools_render_alter($info, $page, $context) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This leaves some possibility for future versions to support translation.
|
||||
$metatags = $handler->conf['metatag_panels']['metatags'];
|
||||
$metatags += metatag_config_load_with_defaults('');
|
||||
if (!is_array($metatags) || empty($metatags)) {
|
||||
$metatags = array();
|
||||
}
|
||||
|
||||
// If meta tags were found but they're not nested for the language, fix it.
|
||||
// This leaves some possibility for future versions to support translation.
|
||||
if (!empty($metatags) && !isset($metatags[LANGUAGE_NONE])) {
|
||||
$metatags = array(LANGUAGE_NONE => $metatags);
|
||||
}
|
||||
|
||||
// Append global defaults.
|
||||
$all_metatags = array();
|
||||
foreach ($metatags as $langcode => $values) {
|
||||
if (!empty($values)) {
|
||||
$all_metatags = $values + metatag_config_load_with_defaults('');
|
||||
}
|
||||
}
|
||||
$metatags = $all_metatags;
|
||||
|
||||
if (empty($metatags)) {
|
||||
return;
|
||||
@@ -117,6 +140,13 @@ function metatag_panels_ctools_render_alter($info, $page, $context) {
|
||||
$tokens[$task_context->keyword] = $task_context->data;
|
||||
}
|
||||
|
||||
// Because of page execution order, sometimes the page title does not get set
|
||||
// by Panels in time for metatags to use it, so we'll explicitly set it here
|
||||
// if we need to.
|
||||
if (!empty($info['title'])) {
|
||||
drupal_set_title($info['title'], PASS_THROUGH);
|
||||
}
|
||||
|
||||
// Build the Metatag.
|
||||
$options = array(
|
||||
'instance' => 'panels:' . $handler->name,
|
||||
|
@@ -9,7 +9,7 @@ tags are provided:
|
||||
* twitter:url
|
||||
* twitter:title
|
||||
* twitter:description
|
||||
* twitter:image
|
||||
* twitter:image:src
|
||||
* twitter:image:width
|
||||
* twitter:image:height
|
||||
* twitter:player
|
||||
|
@@ -3,9 +3,9 @@ description = "Provides support for Twitter's Card meta tags."
|
||||
package = SEO
|
||||
core = 7.x
|
||||
dependencies[] = metatag
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
datestamp = "1412909330"
|
||||
|
||||
|
@@ -5,29 +5,38 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_metatag_config_default_alter().
|
||||
* Implements hook_metatag_bundled_config_alter().
|
||||
*/
|
||||
function metatag_twitter_cards_metatag_config_default_alter(array &$configs) {
|
||||
function metatag_twitter_cards_metatag_bundled_config_alter(array &$configs) {
|
||||
foreach ($configs as &$config) {
|
||||
switch ($config->instance) {
|
||||
case 'global':
|
||||
$config->config += array(
|
||||
'twitter:card' => array('value' => 'summary'),
|
||||
'twitter:description' => array('value' => '[site:slogan]'),
|
||||
'twitter:title' => array('value' => '[site:name]'),
|
||||
'twitter:title' => array('value' => '[current-page:title]'),
|
||||
'twitter:url' => array('value' => '[current-page:url:absolute]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'global:frontpage':
|
||||
$config->config += array(
|
||||
'twitter:description' => array('value' => ''),
|
||||
'twitter:description' => array('value' => '[site:slogan]'),
|
||||
'twitter:title' => array('value' => '[site:name]'),
|
||||
'twitter:url' => array('value' => '[site:url]'),
|
||||
);
|
||||
break;
|
||||
|
||||
// On error pages point everything to the homepage.
|
||||
case 'global:403':
|
||||
case 'global:404':
|
||||
$config->config += array(
|
||||
'twitter:title' => array('value' => '[site:name]'),
|
||||
'twitter:url' => array('value' => '[site:url]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'node':
|
||||
$config->config += array(
|
||||
'twitter:card' => array('value' => 'summary'),
|
||||
'twitter:description' => array('value' => '[node:summary]'),
|
||||
'twitter:title' => array('value' => '[node:title]'),
|
||||
);
|
||||
@@ -35,10 +44,21 @@ function metatag_twitter_cards_metatag_config_default_alter(array &$configs) {
|
||||
|
||||
case 'taxonomy_term':
|
||||
$config->config += array(
|
||||
'twitter:card' => array('value' => 'summary'),
|
||||
'twitter:title'=> array('value' => '[term:name]'),
|
||||
'twitter:description' => array('value' => '[term:description]'),
|
||||
'twitter:title' => array('value' => '[term:name]'),
|
||||
);
|
||||
break;
|
||||
|
||||
case 'user':
|
||||
$config->config += array(
|
||||
'twitter:title' => array('value' => '[user:name]'),
|
||||
);
|
||||
if (variable_get('user_pictures')) {
|
||||
$config->config += array(
|
||||
'twitter:image:src' => array('value' => '[user:picture:url]'),
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,160 +75,351 @@ function metatag_twitter_cards_metatag_info() {
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['twitter:card'] = array(
|
||||
'label' => t('Twitter card type'),
|
||||
'description' => t('Notes: no other fields are required for a <em>Summary</em> card, a <em>Photo</em> card requires the \'image\' field, while a <em>Media player</em> card requires the \'title\', \'description\', \'media player URL\', \'media player width\', \'media player height\' and \'image\' fields.'),
|
||||
// Twitter Cards meta tags stack after the Open Graph tags.
|
||||
$weight = 40;
|
||||
|
||||
// Defaults used for all cards.
|
||||
$defaults = array(
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
),
|
||||
);
|
||||
|
||||
$info['tags']['twitter:card'] = array(
|
||||
'label' => t('Twitter card type'),
|
||||
'description' => t('Notes: no other fields are required for a <em>Summary</em> card, a <em>Photo</em> card requires the \'image\' field, a <em>Media player</em> card requires the \'title\', \'description\', \'media player URL\', \'media player width\', \'media player height\' and \'image\' fields, a <em>Summary Card with Large Image</em> card requires the \'Summary\' field and the \'image\' field, a <em>Gallery Card</em> requires all the \'Gallery Image\' fields, an <em>App Card</em> requires the \'iPhone app ID\' field, the \'iPad app ID\' field and the \'Google Play app ID\' field, a <em>Product Card</em> requires the \'description\' field, the \'image\' field, the \'Label 1\' field, the \'Data 1\' field, the \'Label 2\' field and the \'Data 2\' field.'),
|
||||
'weight' => ++$weight,
|
||||
'form' => array(
|
||||
'#type' => 'select',
|
||||
'#options' => array(
|
||||
'summary' => t('Summary (default)'),
|
||||
'summary_large_image' => t('Summary with large image'),
|
||||
'photo' => t('Photo'),
|
||||
'player' => t('Media player'),
|
||||
'gallery' => t('Gallery'),
|
||||
'app' => t('App'),
|
||||
'product' => t('Product'),
|
||||
),
|
||||
'#empty_option' => t('- None -'),
|
||||
),
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
),
|
||||
);
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:site'] = array(
|
||||
'label' => t('Site\'s Twitter account'),
|
||||
'description' => t('The @username for the website, which will be displayed in the Card\'s footer; must include the @ symbol.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'context' => array('global'),
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'twitter',
|
||||
),
|
||||
);
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:site:id'] = array(
|
||||
'label' => t('Site\'s Twitter account ID'),
|
||||
'description' => t('The numerical Twitter account ID for the website, which will be displayed in the Card\'s footer.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'context' => array('global'),
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
);
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:creator'] = array(
|
||||
'label' => t('Creator\'s Twitter account'),
|
||||
'description' => t('The @username for the content creator / author for this page, including the @ symbol.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'twitter',
|
||||
),
|
||||
);
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:creator:id'] = array(
|
||||
'label' => t('Creator\'s Twitter account ID'),
|
||||
'description' => t('The numerical Twitter account ID for the content creator / author for this page.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
);
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:url'] = array(
|
||||
'label' => t('Page URL'),
|
||||
'description' => t('The permalink / canonical URL of the current page.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'canonical',
|
||||
),
|
||||
);
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:title'] = array(
|
||||
'label' => t('Title'),
|
||||
'description' => t('The page\'s title, which should be concise; it will be truncated at 70 characters by Twitter. This field is required unless this the \'type\' field is set to "photo".'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
),
|
||||
);
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:description'] = array(
|
||||
'label' => t('Description'),
|
||||
'description' => t('A description that concisely summarizes the content of the page, as appropriate for presentation within a Tweet. Do not re-use the title text as the description, or use this field to describe the general services provided by the website. The string will be truncated, by Twitter, at the word to 200 characters.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
),
|
||||
);
|
||||
$info['tags']['twitter:image'] = array(
|
||||
'weight' => ++$weight,
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:image:src'] = array(
|
||||
'label' => t('Image URL'),
|
||||
'description' => t('The URL to a unique image representing the content of the page. Do not use a generic image such as your website logo, author photo, or other image that spans multiple pages. Images larger than 120x120px will be resized and cropped square based on longest dimension. Images smaller than 60x60px will not be shown. If the \'type\' is set to <em>Photo</em> then the image must be at least 280x150px.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'replaces' => array(
|
||||
'twitter:image',
|
||||
),
|
||||
);
|
||||
'devel_generate' => array(
|
||||
'type' => 'image',
|
||||
),
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:image:width'] = array(
|
||||
'label' => t('Image width'),
|
||||
'description' => t('The width of the image being linked to, in pixels.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'twitter:image:src',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'filled',
|
||||
'value' => TRUE,
|
||||
),
|
||||
),
|
||||
);
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:image:height'] = array(
|
||||
'label' => t('Image height'),
|
||||
'description' => t('The height of the image being linked to, in pixels.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'twitter:image:src',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'filled',
|
||||
'value' => TRUE,
|
||||
),
|
||||
),
|
||||
);
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
) + $defaults;
|
||||
|
||||
// 'gallery' cards.
|
||||
$gallery_defaults = array(
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'twitter:card',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'value',
|
||||
'value' => 'gallery',
|
||||
),
|
||||
),
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:image0'] = array(
|
||||
'label' => t('1st Gallery Image'),
|
||||
'description' => t('A URL to the image representing the first photo in your gallery.'),
|
||||
'weight' => ++$weight,
|
||||
) + $gallery_defaults;
|
||||
$info['tags']['twitter:image1'] = array(
|
||||
'label' => t('2nd Gallery Image'),
|
||||
'description' => t('A URL to the image representing the second photo in your gallery.'),
|
||||
'weight' => ++$weight,
|
||||
) + $gallery_defaults;
|
||||
$info['tags']['twitter:image2'] = array(
|
||||
'label' => t('3rd Gallery Image'),
|
||||
'description' => t('A URL to the image representing the third photo in your gallery.'),
|
||||
'weight' => ++$weight,
|
||||
) + $gallery_defaults;
|
||||
$info['tags']['twitter:image3'] = array(
|
||||
'label' => t('4th Gallery Image'),
|
||||
'description' => t('A URL to the image representing the fourth photo in your gallery.'),
|
||||
'weight' => ++$weight,
|
||||
) + $gallery_defaults;
|
||||
|
||||
// 'player' cards.
|
||||
$player_defaults = array(
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'twitter:card',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'value',
|
||||
'value' => 'player',
|
||||
),
|
||||
),
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:player'] = array(
|
||||
'label' => t('Media player URL'),
|
||||
'description' => t('The full URL for loading a media player. Required when using a <em>Media player</em> card.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
);
|
||||
) + $player_defaults;
|
||||
$info['tags']['twitter:player:width'] = array(
|
||||
'label' => t('Media player width'),
|
||||
'description' => t('The width of the media player iframe, in pixels. Required when using a <em>Media player</em> card.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
);
|
||||
) + $player_defaults;
|
||||
$info['tags']['twitter:player:height'] = array(
|
||||
'label' => t('Media player height'),
|
||||
'description' => t('The height of the media player iframe, in pixels. Required when using a <em>Media player</em> card.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
);
|
||||
) + $player_defaults;
|
||||
$info['tags']['twitter:player:stream'] = array(
|
||||
'label' => t('MP4 media stream URL'),
|
||||
'description' => t('The full URL for an MP4 video (h.264) or audio (AAC) stream, takes precidence over the other media player field.'),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'type' => 'url',
|
||||
),
|
||||
);
|
||||
) + $player_defaults;
|
||||
$info['tags']['twitter:player:stream:content_type'] = array(
|
||||
'label' => t('MP4 media stream MIME type'),
|
||||
'description' => t('The MIME type for the media contained in the stream URL, as defined by <a href="!url">RFC 4337</a>.', array('!url' => 'http://tools.ietf.org/rfc/rfc4337.txt')),
|
||||
'class' => 'DrupalTextMetaTag',
|
||||
'group' => 'twitter-cards',
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards',
|
||||
'weight' => ++$weight,
|
||||
'devel_generate' => array(
|
||||
'maxlength' => 1,
|
||||
),
|
||||
) + $player_defaults;
|
||||
|
||||
// 'app' cards.
|
||||
$app_defaults = $defaults + array(
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'twitter:card',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'value',
|
||||
'value' => 'app',
|
||||
),
|
||||
),
|
||||
);
|
||||
$info['tags']['twitter:app:country'] = array(
|
||||
'label' => t('App Store Country'),
|
||||
'description' => t('If your application is not available in the US App Store, you must set this value to the two-letter country code for the App Store that contains your application.'),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:name:iphone'] = array(
|
||||
'label' => t('iPhone app name'),
|
||||
'description' => t("The name of the iPhone app."),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:id:iphone'] = array(
|
||||
'label' => t('iPhone app ID'),
|
||||
'description' => t("String value, should be the numeric representation of your iPhone app's ID in the App Store."),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:url:iphone'] = array(
|
||||
'label' => t('iPhone app\'s custom URL scheme'),
|
||||
'description' => t('The iPhone app\'s custom URL scheme (must include "://" after the scheme name).'),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:name:ipad'] = array(
|
||||
'label' => t('iPad app name'),
|
||||
'description' => t("The name of the iPad app."),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:id:ipad'] = array(
|
||||
'label' => t('iPad app ID'),
|
||||
'description' => t("String value, should be the numeric representation of your iPad app's ID in the App Store."),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:url:ipad'] = array(
|
||||
'label' => t('iPad app\'s custom URL scheme'),
|
||||
'description' => t('The iPad app\'s custom URL scheme (must include "://" after the scheme name).'),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:name:googleplay'] = array(
|
||||
'label' => t('Google Play app name'),
|
||||
'description' => t("The name of the app in the Google Play app store."),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:id:googleplay'] = array(
|
||||
'label' => t('Google Play app ID'),
|
||||
'description' => t("String value, and should be the numeric representation of your app's ID in Google Play."),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
$info['tags']['twitter:app:url:googleplay'] = array(
|
||||
'label' => t('Google Play app\'s custom URL scheme'),
|
||||
'description' => t('The Google Play app\'s custom URL scheme (must include "://" after the scheme name).'),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $app_defaults;
|
||||
|
||||
// 'product' cards.
|
||||
$product_defaults = array(
|
||||
'dependencies' => array(
|
||||
array(
|
||||
'dependency' => 'twitter:card',
|
||||
'attribute' => 'value',
|
||||
'condition' => 'value',
|
||||
'value' => 'product',
|
||||
),
|
||||
),
|
||||
) + $defaults;
|
||||
$info['tags']['twitter:label1'] = array(
|
||||
'label' => t('Label 1'),
|
||||
'description' => t('This field expects a string, and you can specify values for labels such as price, items in stock, sizes, etc.'),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $product_defaults;
|
||||
$info['tags']['twitter:data1'] = array(
|
||||
'label' => t('Data 1'),
|
||||
'description' => t('This field expects a string, and allows you to specify the types of data you want to offer (price, country, etc.).'),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $product_defaults;
|
||||
$info['tags']['twitter:label2'] = array(
|
||||
'label' => t('Label 2'),
|
||||
'description' => t('This field expects a string, and you can specify values for labels such as price, items in stock, sizes, etc.'),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $product_defaults;
|
||||
$info['tags']['twitter:data2'] = array(
|
||||
'label' => t('Data 2'),
|
||||
'description' => t('This field expects a string, and allows you to specify the types of data you want to offer (price, country, etc.).'),
|
||||
'weight' => ++$weight,
|
||||
'element' => array(
|
||||
'#theme' => 'metatag_twitter_cards'
|
||||
),
|
||||
) + $product_defaults;
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ function metatag_twitter_cards_theme() {
|
||||
*/
|
||||
function theme_metatag_twitter_cards($variables) {
|
||||
$element = &$variables['element'];
|
||||
element_set_attributes($element, array('#name' => 'property', '#value' => 'content'));
|
||||
element_set_attributes($element, array('#name' => 'name', '#value' => 'content'));
|
||||
unset($element['#value']);
|
||||
return theme('html_tag', $variables);
|
||||
}
|
||||
|
@@ -1,14 +0,0 @@
|
||||
name = Meta tag UI
|
||||
description = "DEPRECATED admin interface for the Meta tag API, this functionality has be merged into the main module."
|
||||
package = SEO
|
||||
core = 7.x
|
||||
dependencies[] = metatag
|
||||
dependencies[] = ctools
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
|
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Empty file for the deprecated Metatag UI module.
|
||||
*/
|
@@ -8,9 +8,9 @@ dependencies[] = views
|
||||
|
||||
files[] = metatag_views_plugin_display_extender_metatags.inc
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
datestamp = "1412909330"
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* Implements hook_views_api().
|
||||
*/
|
||||
function metatag_views_views_api() {
|
||||
return array('api' => 3);
|
||||
return array('api' => 3.0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -25,78 +25,79 @@ function metatag_views_ctools_plugin_api($owner, $api) {
|
||||
* Implements hook_view_preview_info_alter().
|
||||
*/
|
||||
function metatag_views_views_preview_info_alter(&$rows, $view) {
|
||||
if (metatag_views_views_display_has_metatags($view->display_handler)) {
|
||||
$instance = 'view:' . $view->name;
|
||||
$metatags = $view->display_handler->get_option('metatags');
|
||||
$metatags = !empty($metatags) ? $metatags : array();
|
||||
$metatags = $view->display_handler->get_option('metatags');
|
||||
if (!is_array($metatags) || empty($metatags)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set the page title to be the previewed views title before fetching meta
|
||||
// tag values.
|
||||
$title = drupal_set_title();
|
||||
if ($view_title = $view->get_title()) {
|
||||
drupal_set_title($view_title);
|
||||
}
|
||||
// If meta tags were found but they're not nested for the language, fix it.
|
||||
// This leaves some possibility for future versions to support translation.
|
||||
if (!empty($metatags) && !isset($metatags[LANGUAGE_NONE])) {
|
||||
$metatags = array(LANGUAGE_NONE => $metatags);
|
||||
}
|
||||
|
||||
$options['token data']['view'] = $view;
|
||||
$values = metatag_metatags_values($instance, $metatags, $options);
|
||||
foreach ($values as $metatag => $value) {
|
||||
$metatag_info = metatag_get_info('tags', $metatag);
|
||||
$values[$metatag] = check_plain($metatag_info['label']) . ': ' . check_plain($value);
|
||||
}
|
||||
// Set the page title to be the previewed views title before fetching meta
|
||||
// tag values.
|
||||
$title = drupal_set_title();
|
||||
if ($view_title = $view->get_title()) {
|
||||
drupal_set_title($view_title);
|
||||
}
|
||||
|
||||
$instance = 'view:' . $view->name;
|
||||
$options['token data']['view'] = $view;
|
||||
$values = metatag_metatags_values($instance, $metatags, $options);
|
||||
foreach ($values as $metatag => $value) {
|
||||
$metatag_info = metatag_get_info('tags', $metatag);
|
||||
$values[$metatag] = check_plain($metatag_info['label']) . ': ' . check_plain($value);
|
||||
}
|
||||
if (!empty($values)) {
|
||||
$rows['query'][] = array(
|
||||
'<strong>' . t('Meta tags') . '</strong>',
|
||||
implode('<br />', $values),
|
||||
);
|
||||
|
||||
// Restore the page title.
|
||||
drupal_set_title($title);
|
||||
}
|
||||
|
||||
// Restore the page title.
|
||||
drupal_set_title($title);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_page_alter().
|
||||
*/
|
||||
function metatag_views_page_alter(&$page) {
|
||||
if ($view = views_get_page_view()) {
|
||||
$view = views_get_page_view();
|
||||
|
||||
// Check if Views metatags are enabled.
|
||||
if (!empty($view) && metatag_config_is_enabled('view')) {
|
||||
// The following is taken from views_get_page_view().
|
||||
// If a module is still putting in the display like we used to, catch that.
|
||||
if (is_subclass_of($view, 'views_plugin_display')) {
|
||||
$view = $view->view;
|
||||
}
|
||||
|
||||
// Load the
|
||||
if (metatag_views_views_display_has_metatags($view->display_handler)) {
|
||||
$saved_metatags = $view->display_handler->get_option('metatags');
|
||||
$metatags = array();
|
||||
if (!empty($saved_metatags)) {
|
||||
$metatags[LANGUAGE_NONE] = $saved_metatags;
|
||||
}
|
||||
|
||||
// Build options for meta tag rendering.
|
||||
$instance = 'view:' . $view->name;
|
||||
$options = array();
|
||||
$options['token data']['view'] = $view;
|
||||
|
||||
// Add the metatags.
|
||||
$page['content']['metatags'][$instance] = metatag_metatags_view($instance, $metatags, $options);
|
||||
// Prevent Views settings from overwriting global:frontpage.
|
||||
if (drupal_is_front_page() && metatag_config_is_enabled('global:frontpage')) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the requested view display has meta tags saved.
|
||||
*
|
||||
* @param $display views_plugin_display
|
||||
* The view display plugin that will be checked.
|
||||
*
|
||||
* @return
|
||||
* Simple boolean to indicate whether there are meta tags saved.
|
||||
*/
|
||||
function metatag_views_views_display_has_metatags(views_plugin_display $display) {
|
||||
if (method_exists($display, 'has_metatags')) {
|
||||
return $display->has_metatags();
|
||||
}
|
||||
else {
|
||||
return $display->has_path() && $display->uses_breadcrumb();
|
||||
// Load the meta tags for this view.
|
||||
$metatags = $view->display_handler->get_option('metatags');
|
||||
if (!is_array($metatags) || empty($metatags)) {
|
||||
$metatags = array();
|
||||
}
|
||||
|
||||
// If meta tags were found but they're not nested for the language, fix it.
|
||||
// This leaves some possibility for future versions to support translation.
|
||||
if (!empty($metatags) && !isset($metatags[LANGUAGE_NONE])) {
|
||||
$metatags = array(LANGUAGE_NONE => $metatags);
|
||||
}
|
||||
|
||||
// Build options for meta tag rendering.
|
||||
$instance = 'view:' . $view->name;
|
||||
$options = array();
|
||||
$options['token data']['view'] = $view;
|
||||
|
||||
// Add the metatags.
|
||||
$page['content']['metatags'][$instance] = metatag_metatags_view($instance, $metatags, $options);
|
||||
}
|
||||
}
|
||||
|
@@ -14,6 +14,7 @@ function metatag_views_views_plugins() {
|
||||
'help' => t('Provides meta tags for views.'),
|
||||
'handler' => 'metatag_views_plugin_display_extender_metatags',
|
||||
'enabled' => TRUE,
|
||||
'path' => drupal_get_path('module', 'metatag_views'),
|
||||
);
|
||||
|
||||
return $plugins;
|
||||
|
@@ -6,47 +6,94 @@
|
||||
|
||||
class metatag_views_plugin_display_extender_metatags extends views_plugin_display_extender {
|
||||
|
||||
protected function has_metatags() {
|
||||
return metatag_views_views_display_has_metatags($this->display);
|
||||
/**
|
||||
* Default values.
|
||||
*/
|
||||
function options_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['metatags'] = array('default' => '');
|
||||
return $options;
|
||||
}
|
||||
|
||||
function options_definition_alter(&$options) {
|
||||
$options['metatags'] = array('default' => array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines where within the Views admin UI the new settings will be visible.
|
||||
*/
|
||||
function options_summary(&$categories, &$options) {
|
||||
if ($this->has_metatags()) {
|
||||
$categories['metatags'] = array(
|
||||
'title' => t('Meta tags'),
|
||||
'column' => 'second',
|
||||
);
|
||||
$metatags = $this->display->get_option('metatags');
|
||||
$options['metatags'] = array(
|
||||
'category' => 'metatags',
|
||||
'title' => t('Meta tags'),
|
||||
'value' => !empty($metatags) ? t('Overridden') : t('Using defaults'),
|
||||
);
|
||||
}
|
||||
$categories['metatags'] = array(
|
||||
'title' => t('Meta tags'),
|
||||
'column' => 'second',
|
||||
);
|
||||
$options['metatags'] = array(
|
||||
'category' => 'metatags',
|
||||
'title' => t('Meta tags'),
|
||||
'value' => $this->has_metatags() ? t('Overridden') : t('Using defaults'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the form.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
if ($form_state['section'] == 'metatags') {
|
||||
$form['#title'] .= t('The meta tags for this display');
|
||||
$metatags = $this->get_metatags();
|
||||
|
||||
// Build/inject the Metatag form.
|
||||
$instance = 'view:' . $form_state['view']->name;
|
||||
$metatags = $this->display->get_option('metatags');
|
||||
$metatags = !empty($metatags) ? $metatags : array();
|
||||
$options['token types'] = array('view');
|
||||
$options['context'] = 'view';
|
||||
metatag_metatags_form($form, $instance, $metatags, $options);
|
||||
metatag_metatags_form($form, $instance, $metatags[LANGUAGE_NONE], $options);
|
||||
|
||||
$form['metatags']['#type'] = 'container';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the form values.
|
||||
*/
|
||||
function options_submit(&$form, &$form_state) {
|
||||
if ($form_state['section'] == 'metatags') {
|
||||
$metatags = $form_state['values']['metatags'];
|
||||
metatag_filter_values_from_defaults($metatags);
|
||||
|
||||
// Leave some possibility for future versions to support translation.
|
||||
foreach ($metatags as $langcode => $values) {
|
||||
if (!empty($form['metatags'][$langcode]['#metatag_defaults'])) {
|
||||
metatag_filter_values_from_defaults($form_state['values']['metatags'][$langcode], $form['metatags'][$langcode]['#metatag_defaults']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->display->set_option('metatags', $metatags);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Identify whether or not the current display has custom meta tags defined.
|
||||
*/
|
||||
protected function has_metatags() {
|
||||
$metatags = $this->get_metatags();
|
||||
return !empty($metatags[LANGUAGE_NONE]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Metatag configuration for this display.
|
||||
*
|
||||
* @return array
|
||||
* The meta tag values, keys by language (default LANGUAGE_NONE).
|
||||
*/
|
||||
private function get_metatags() {
|
||||
$metatags = $this->display->get_option('metatags');
|
||||
|
||||
// Leave some possibility for future versions to support translation.
|
||||
if (empty($metatags)) {
|
||||
$metatags = array(LANGUAGE_NONE => array());
|
||||
}
|
||||
if (!isset($metatags[LANGUAGE_NONE])) {
|
||||
$metatags = array(LANGUAGE_NONE => $metatags);
|
||||
}
|
||||
|
||||
return $metatags;
|
||||
}
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@ core = 7.x
|
||||
dependencies[] = metatag
|
||||
hidden = TRUE
|
||||
|
||||
; Information added by drupal.org packaging script on 2013-09-23
|
||||
version = "7.x-1.0-beta7+54-dev"
|
||||
; Information added by Drupal.org packaging script on 2014-10-10
|
||||
version = "7.x-1.4"
|
||||
core = "7.x"
|
||||
project = "metatag"
|
||||
datestamp = "1379942674"
|
||||
datestamp = "1412909330"
|
||||
|
||||
|
Reference in New Issue
Block a user