From 699b0cb787082129c6ebf5eab092f88f46bacdbb Mon Sep 17 00:00:00 2001 From: Marlene Williams Date: Mon, 3 Dec 2018 18:46:19 -0800 Subject: [PATCH] Updating the Metatag module to 7.x-1.25 --- .../modules/contrib/metatag/.codeclimate.yml | 25 + sites/all/modules/contrib/metatag/.csslintrc | 2 + .../all/modules/contrib/metatag/.eslintignore | 1 + sites/all/modules/contrib/metatag/.eslintrc | 213 ++ .../all/modules/contrib/metatag/CHANGELOG.txt | 649 +++++- .../contrib/metatag/CODE_OF_CONDUCT.txt | 3 + sites/all/modules/contrib/metatag/README.txt | 366 +++- .../modules/contrib/metatag/metatag.admin.inc | 364 +++- .../modules/contrib/metatag/metatag.admin.js | 64 +- .../modules/contrib/metatag/metatag.api.php | 288 ++- .../modules/contrib/metatag/metatag.drush.inc | 1 + .../contrib/metatag/metatag.features.inc | 8 + .../modules/contrib/metatag/metatag.feeds.inc | 26 +- .../modules/contrib/metatag/metatag.i18n.inc | 133 +- sites/all/modules/contrib/metatag/metatag.inc | 428 +++- .../all/modules/contrib/metatag/metatag.info | 108 +- .../modules/contrib/metatag/metatag.install | 1403 +++++++++++-- .../contrib/metatag/metatag.metatag.inc | 250 ++- .../contrib/metatag/metatag.migrate.inc | 42 +- .../modules/contrib/metatag/metatag.module | 1841 +++++++++++++---- .../contrib/metatag/metatag.search_api.inc | 85 + .../all/modules/contrib/metatag/metatag.test | 261 --- .../modules/contrib/metatag/metatag.theme.inc | 30 +- .../contrib/metatag/metatag.tokens.inc | 155 +- .../contrib/metatag/metatag.variable.inc | 60 + .../contrib/metatag/metatag.vertical-tabs.js | 87 +- .../metatag/metatag_app_links/README.txt | 40 + .../metatag_app_links/metatag_app_links.info | 15 + .../metatag_app_links.metatag.inc | 163 ++ .../metatag_app_links.module | 15 + .../tests/metatag_app_links.tags.test | 89 + .../tests/metatag_app_links.test | 48 + .../metatag/metatag_context/README.txt | 6 +- .../metatag_context/metatag_context.admin.inc | 42 +- .../metatag_context.context.inc | 114 +- .../metatag_context/metatag_context.i18n.inc | 132 ++ .../metatag_context/metatag_context.info | 18 +- .../metatag_context/metatag_context.install | 1 + .../metatag_context.metatag.inc | 14 + .../metatag_context/metatag_context.module | 44 +- .../metatag_context/metatag_context.test | 145 -- .../tests/metatag_context.i18n.test | 144 ++ .../tests/metatag_context.test | 114 + .../tests/metatag_context_tests.context.inc | 57 + .../tests/metatag_context_tests.info | 16 + .../tests/metatag_context_tests.module | 36 + .../contrib/metatag/metatag_dc/README.txt | 12 +- .../metatag/metatag_dc/metatag_dc.info | 13 +- .../metatag/metatag_dc/metatag_dc.install | 22 + .../metatag/metatag_dc/metatag_dc.metatag.inc | 165 +- .../metatag/metatag_dc/metatag_dc.module | 6 +- .../metatag_dc/tests/metatag_dc.tags.test | 81 + .../metatag/metatag_dc/tests/metatag_dc.test | 48 + .../metatag/metatag_dc_advanced/README.txt | 52 + .../metatag_dc_advanced.info | 16 + .../metatag_dc_advanced.metatag.inc | 271 +++ .../metatag_dc_advanced.module | 15 + .../tests/metatag_dc_advanced.tags.test | 85 + .../tests/metatag_dc_advanced.test | 48 + .../metatag/metatag_devel/metatag_devel.info | 14 +- .../metatag_devel/metatag_devel.module | 8 +- .../metatag_devel/tests/metatag_devel.test | 48 + .../metatag_facebook/metatag_facebook.info | 13 +- .../metatag_facebook/metatag_facebook.install | 1 + .../metatag_facebook.metatag.inc | 13 +- .../metatag_facebook/metatag_facebook.module | 16 +- .../tests/metatag_facebook.tags.test | 53 + .../tests/metatag_facebook.test | 48 + .../metatag_favicons/metatag_favicons.info | 18 + .../metatag_favicons/metatag_favicons.install | 17 + .../metatag_favicons.mask-icon.class.inc | 105 + .../metatag_favicons.metatag.inc | 282 +++ .../metatag_favicons/metatag_favicons.module | 168 ++ .../tests/druplicon-vector.svg | 109 + .../tests/metatag_favicons.tags.test | 251 +++ .../tests/metatag_favicons.test | 233 +++ .../metatag/metatag_google_cse/README.txt | 22 + .../metatag_google_cse.info | 15 + .../metatag_google_cse.install | 6 + .../metatag_google_cse.metatag.inc | 63 + .../metatag_google_cse.module | 48 + .../tests/metatag_google_cse.tags.test | 57 + .../tests/metatag_google_cse.test | 48 + .../metatag/metatag_google_plus/README.txt | 36 +- .../metatag_google_plus.inc | 5 + .../metatag_google_plus.info | 15 +- .../metatag_google_plus.install | 33 + .../metatag_google_plus.metatag.inc | 47 +- .../metatag_google_plus.module | 21 +- .../tests/metatag_google_plus.tags.test | 123 ++ .../tests/metatag_google_plus.test | 48 + .../metatag/metatag_hreflang/README.txt | 39 + .../metatag_hreflang/metatag_hreflang.info | 24 + .../metatag_hreflang/metatag_hreflang.install | 71 + .../metatag_hreflang.metatag.inc | 97 + .../metatag_hreflang/metatag_hreflang.module | 86 + .../metatag_hreflang/metatag_hreflang.test | 31 + .../metatag_hreflang.tokens.inc | 118 ++ .../tests/metatag_hreflang.tags.test | 113 + .../tests/metatag_hreflang.test | 48 + ...atag_hreflang.with_entity_translation.test | 283 +++ .../metatag/metatag_importer/README.txt | 51 + .../metatag_importer.admin.inc | 19 + .../metatag_importer.drush.inc | 94 + .../metatag_importer/metatag_importer.info | 16 + .../metatag_importer.metatags_quick.inc | 225 ++ .../metatag_importer/metatag_importer.module | 42 + .../metatag_importer.nodewords.inc | 581 ++++++ .../metatag_importer.page_title.inc | 140 ++ .../tests/metatag_importer.test | 48 + .../contrib/metatag/metatag_mobile/README.txt | 91 + .../metatag_mobile/metatag_mobile.info | 15 + .../metatag_mobile/metatag_mobile.metatag.inc | 310 +++ .../metatag_mobile/metatag_mobile.module | 91 + .../tests/metatag_mobile.tags.test | 225 ++ .../metatag_mobile/tests/metatag_mobile.test | 48 + .../metatag_opengraph/metatag_opengraph.info | 15 +- .../metatag_opengraph.install | 88 +- .../metatag_opengraph.metatag.inc | 64 +- .../metatag_opengraph.module | 35 +- .../tests/metatag_opengraph.tags.test | 183 ++ .../tests/metatag_opengraph.test | 48 + .../metatag_opengraph_products.info | 16 + .../metatag_opengraph_products.metatag.inc | 165 ++ .../metatag_opengraph_products.module | 15 + .../metatag_opengraph_products.tags.test | 88 + .../tests/metatag_opengraph_products.test | 48 + .../contrib/metatag/metatag_panels/README.txt | 6 +- .../metatag_panels/metatag_panels.i18n.inc | 127 ++ .../metatag_panels/metatag_panels.info | 17 +- .../metatag_panels/metatag_panels.metatag.inc | 14 + .../metatag_panels/metatag_panels.module | 91 +- .../tests/metatag_panels.i18n.test | 110 + .../metatag_panels/tests/metatag_panels.test | 67 + .../tests/metatag_panels_tests.info | 17 + .../tests/metatag_panels_tests.module | 15 + .../metatag_panels_tests.pages_default.inc | 130 ++ .../metatag/metatag_twitter_cards/README.txt | 8 +- .../metatag_twitter_cards.info | 14 +- .../metatag_twitter_cards.install | 59 + .../metatag_twitter_cards.metatag.inc | 97 +- .../metatag_twitter_cards.module | 7 +- .../tests/metatag_twitter_cards.tags.test | 143 ++ .../tests/metatag_twitter_cards.test | 48 + .../metatag/metatag_verification/README.txt | 16 + .../metatag_verification.info | 15 + .../metatag_verification.install | 26 + .../metatag_verification.metatag.inc | 67 + .../metatag_verification.module | 15 + .../tests/metatag_verification.tags.test | 54 + .../tests/metatag_verification.test | 48 + .../contrib/metatag/metatag_views/README.txt | 2 +- .../metatag_views/metatag_views.i18n.inc | 101 + .../metatag/metatag_views/metatag_views.inc | 26 + .../metatag/metatag_views/metatag_views.info | 16 +- .../metatag_views/metatag_views.install | 15 + .../metatag_views/metatag_views.metatag.inc | 5 +- .../metatag_views/metatag_views.module | 97 +- .../metatag_views/metatag_views.tokens.inc | 1 + .../metatag_views/metatag_views.views.inc | 1 + ...views_plugin_display_extender_metatags.inc | 89 +- .../tests/metatag_views.i18n.test | 106 + .../metatag_views/tests/metatag_views.test | 60 + .../tests/metatag_views_tests.info | 16 + .../tests/metatag_views_tests.module | 13 + .../metatag_views_tests.views_default.inc | 453 ++++ .../content_types/node_form_metatags.inc | 75 + .../metatag/tests/metatag.bulk_revert.test | 56 + .../tests/metatag.core_tag_removal.test | 78 + .../contrib/metatag/tests/metatag.helper.test | 772 +++++++ .../contrib/metatag/tests/metatag.image.test | 491 +++++ .../contrib/metatag/tests/metatag.locale.test | 157 ++ .../contrib/metatag/tests/metatag.node.test | 450 ++++ .../metatag/tests/metatag.node.with_i18n.test | 118 ++ .../metatag/tests/metatag.output_caching.test | 127 ++ .../tests/metatag.string_handling.test | 276 +++ .../metatag.string_handling_with_i18n.test | 32 + .../contrib/metatag/tests/metatag.tags.test | 297 +++ .../metatag/tests/metatag.tags_helper.test | 267 +++ .../contrib/metatag/tests/metatag.term.test | 169 ++ .../metatag/tests/metatag.term.with_i18n.test | 118 ++ .../contrib/metatag/tests/metatag.unit.test | 147 ++ .../contrib/metatag/tests/metatag.user.test | 94 + .../tests/metatag.with_i18n_config.test | 331 +++ .../tests/metatag.with_i18n_disabled.test | 105 + .../tests/metatag.with_i18n_output.test | 185 ++ .../metatag/tests/metatag.with_me.test | 73 + .../metatag/tests/metatag.with_media.test | 64 + .../metatag/tests/metatag.with_panels.test | 183 ++ .../metatag/tests/metatag.with_profile2.test | 133 ++ .../tests/metatag.with_search_api.test | 139 ++ .../metatag/tests/metatag.with_views.test | 191 ++ .../metatag.with_workbench_moderation.test | 117 ++ .../contrib/metatag/tests/metatag.xss.test | 209 ++ .../metatag/tests/metatag_search_test.info | 15 + .../metatag/tests/metatag_search_test.module | 48 + .../contrib/metatag/tests/metatag_test.info | 14 +- .../metatag/tests/metatag_test.metatag.inc | 22 +- .../contrib/metatag/tests/metatag_test.module | 63 +- 199 files changed, 20541 insertions(+), 1922 deletions(-) create mode 100644 sites/all/modules/contrib/metatag/.codeclimate.yml create mode 100644 sites/all/modules/contrib/metatag/.csslintrc create mode 100644 sites/all/modules/contrib/metatag/.eslintignore create mode 100644 sites/all/modules/contrib/metatag/.eslintrc create mode 100644 sites/all/modules/contrib/metatag/CODE_OF_CONDUCT.txt create mode 100644 sites/all/modules/contrib/metatag/metatag.search_api.inc delete mode 100644 sites/all/modules/contrib/metatag/metatag.test create mode 100644 sites/all/modules/contrib/metatag/metatag.variable.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_app_links/README.txt create mode 100644 sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info create mode 100644 sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.module create mode 100644 sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.test create mode 100644 sites/all/modules/contrib/metatag/metatag_context/metatag_context.i18n.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_context/metatag_context.metatag.inc delete mode 100644 sites/all/modules/contrib/metatag/metatag_context/metatag_context.test create mode 100644 sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.i18n.test create mode 100644 sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.test create mode 100644 sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.context.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info create mode 100644 sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.module create mode 100644 sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.install create mode 100644 sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.test create mode 100644 sites/all/modules/contrib/metatag/metatag_dc_advanced/README.txt create mode 100644 sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info create mode 100644 sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.module create mode 100644 sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.test create mode 100644 sites/all/modules/contrib/metatag/metatag_devel/tests/metatag_devel.test create mode 100644 sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.test create mode 100644 sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info create mode 100644 sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.install create mode 100644 sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.mask-icon.class.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.module create mode 100644 sites/all/modules/contrib/metatag/metatag_favicons/tests/druplicon-vector.svg create mode 100644 sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.test create mode 100644 sites/all/modules/contrib/metatag/metatag_google_cse/README.txt create mode 100644 sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info create mode 100644 sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.install create mode 100644 sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.module create mode 100644 sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test create mode 100644 sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.install create mode 100644 sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.test create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/README.txt create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.install create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.module create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.test create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.tokens.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.test create mode 100644 sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.with_entity_translation.test create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/README.txt create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.admin.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.drush.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.metatags_quick.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.module create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.nodewords.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.page_title.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_importer/tests/metatag_importer.test create mode 100644 sites/all/modules/contrib/metatag/metatag_mobile/README.txt create mode 100644 sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info create mode 100644 sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module create mode 100644 sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.test create mode 100644 sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.test create mode 100644 sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info create mode 100644 sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.module create mode 100644 sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.test create mode 100644 sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.i18n.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.i18n.test create mode 100644 sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.test create mode 100644 sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info create mode 100644 sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.module create mode 100644 sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.pages_default.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.install create mode 100644 sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.test create mode 100644 sites/all/modules/contrib/metatag/metatag_verification/README.txt create mode 100644 sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info create mode 100644 sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.install create mode 100644 sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.metatag.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.module create mode 100644 sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.tags.test create mode 100644 sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.test create mode 100644 sites/all/modules/contrib/metatag/metatag_views/metatag_views.i18n.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_views/metatag_views.inc create mode 100644 sites/all/modules/contrib/metatag/metatag_views/metatag_views.install create mode 100644 sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.i18n.test create mode 100644 sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.test create mode 100644 sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info create mode 100644 sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.module create mode 100644 sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.views_default.inc create mode 100644 sites/all/modules/contrib/metatag/plugins/content_types/node_form_metatags.inc create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.bulk_revert.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.core_tag_removal.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.helper.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.image.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.locale.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.node.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.node.with_i18n.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.output_caching.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.string_handling.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.string_handling_with_i18n.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.tags.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.tags_helper.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.term.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.term.with_i18n.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.unit.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.user.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_i18n_config.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_i18n_disabled.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_i18n_output.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_me.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_media.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_panels.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_profile2.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_search_api.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_views.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag.xss.test create mode 100644 sites/all/modules/contrib/metatag/tests/metatag_search_test.info create mode 100644 sites/all/modules/contrib/metatag/tests/metatag_search_test.module diff --git a/sites/all/modules/contrib/metatag/.codeclimate.yml b/sites/all/modules/contrib/metatag/.codeclimate.yml new file mode 100644 index 00000000..e8b0bd07 --- /dev/null +++ b/sites/all/modules/contrib/metatag/.codeclimate.yml @@ -0,0 +1,25 @@ +--- +engines: + csslint: + enabled: true + duplication: + enabled: true + config: + languages: + - javascript + - php + eslint: + enabled: true + fixme: + enabled: true + phpmd: + enabled: true +ratings: + paths: + - "**.css" + - "**.inc" + - "**.install" + - "**.js" + - "**.module" + - "**.php" + - "**.test" diff --git a/sites/all/modules/contrib/metatag/.csslintrc b/sites/all/modules/contrib/metatag/.csslintrc new file mode 100644 index 00000000..aacba956 --- /dev/null +++ b/sites/all/modules/contrib/metatag/.csslintrc @@ -0,0 +1,2 @@ +--exclude-exts=.min.css +--ignore=adjoining-classes,box-model,ids,order-alphabetical,unqualified-attributes diff --git a/sites/all/modules/contrib/metatag/.eslintignore b/sites/all/modules/contrib/metatag/.eslintignore new file mode 100644 index 00000000..96212a35 --- /dev/null +++ b/sites/all/modules/contrib/metatag/.eslintignore @@ -0,0 +1 @@ +**/*{.,-}min.js diff --git a/sites/all/modules/contrib/metatag/.eslintrc b/sites/all/modules/contrib/metatag/.eslintrc new file mode 100644 index 00000000..9faa3750 --- /dev/null +++ b/sites/all/modules/contrib/metatag/.eslintrc @@ -0,0 +1,213 @@ +ecmaFeatures: + modules: true + jsx: true + +env: + amd: true + browser: true + es6: true + jquery: true + node: true + +# http://eslint.org/docs/rules/ +rules: + # Possible Errors + comma-dangle: [2, never] + no-cond-assign: 2 + no-console: 0 + no-constant-condition: 2 + no-control-regex: 2 + no-debugger: 2 + no-dupe-args: 2 + no-dupe-keys: 2 + no-duplicate-case: 2 + no-empty: 2 + no-empty-character-class: 2 + no-ex-assign: 2 + no-extra-boolean-cast: 2 + no-extra-parens: 0 + no-extra-semi: 2 + no-func-assign: 2 + no-inner-declarations: [2, functions] + no-invalid-regexp: 2 + no-irregular-whitespace: 2 + no-negated-in-lhs: 2 + no-obj-calls: 2 + no-regex-spaces: 2 + no-sparse-arrays: 2 + no-unexpected-multiline: 2 + no-unreachable: 2 + use-isnan: 2 + valid-jsdoc: 0 + valid-typeof: 2 + + # Best Practices + accessor-pairs: 2 + block-scoped-var: 0 + complexity: [2, 6] + consistent-return: 0 + curly: 0 + default-case: 0 + dot-location: 0 + dot-notation: 0 + eqeqeq: 2 + guard-for-in: 2 + no-alert: 2 + no-caller: 2 + no-case-declarations: 2 + no-div-regex: 2 + no-else-return: 0 + no-empty-label: 2 + no-empty-pattern: 2 + no-eq-null: 2 + no-eval: 2 + no-extend-native: 2 + no-extra-bind: 2 + no-fallthrough: 2 + no-floating-decimal: 0 + no-implicit-coercion: 0 + no-implied-eval: 2 + no-invalid-this: 0 + no-iterator: 2 + no-labels: 0 + no-lone-blocks: 2 + no-loop-func: 2 + no-magic-number: 0 + no-multi-spaces: 0 + no-multi-str: 0 + no-native-reassign: 2 + no-new-func: 2 + no-new-wrappers: 2 + no-new: 2 + no-octal-escape: 2 + no-octal: 2 + no-proto: 2 + no-redeclare: 2 + no-return-assign: 2 + no-script-url: 2 + no-self-compare: 2 + no-sequences: 0 + no-throw-literal: 0 + no-unused-expressions: 2 + no-useless-call: 2 + no-useless-concat: 2 + no-void: 2 + no-warning-comments: 0 + no-with: 2 + radix: 2 + vars-on-top: 0 + wrap-iife: 2 + yoda: 0 + + # Strict + strict: 0 + + # Variables + init-declarations: 0 + no-catch-shadow: 2 + no-delete-var: 2 + no-label-var: 2 + no-shadow-restricted-names: 2 + no-shadow: 0 + no-undef-init: 2 + no-undef: 0 + no-undefined: 0 + no-unused-vars: 0 + no-use-before-define: 0 + + # Node.js and CommonJS + callback-return: 2 + global-require: 2 + handle-callback-err: 2 + no-mixed-requires: 0 + no-new-require: 0 + no-path-concat: 2 + no-process-exit: 2 + no-restricted-modules: 0 + no-sync: 0 + + # Stylistic Issues + array-bracket-spacing: 0 + block-spacing: 0 + brace-style: 0 + camelcase: 0 + comma-spacing: 0 + comma-style: 0 + computed-property-spacing: 0 + consistent-this: 0 + eol-last: 0 + func-names: 0 + func-style: 0 + id-length: 0 + id-match: 0 + indent: 0 + jsx-quotes: 0 + key-spacing: 0 + linebreak-style: 0 + lines-around-comment: 0 + max-depth: 0 + max-len: 0 + max-nested-callbacks: 0 + max-params: 0 + max-statements: [2, 30] + new-cap: 0 + new-parens: 0 + newline-after-var: 0 + no-array-constructor: 0 + no-bitwise: 0 + no-continue: 0 + no-inline-comments: 0 + no-lonely-if: 0 + no-mixed-spaces-and-tabs: 0 + no-multiple-empty-lines: 0 + no-negated-condition: 0 + no-nested-ternary: 0 + no-new-object: 0 + no-plusplus: 0 + no-restricted-syntax: 0 + no-spaced-func: 0 + no-ternary: 0 + no-trailing-spaces: 0 + no-underscore-dangle: 0 + no-unneeded-ternary: 0 + object-curly-spacing: 0 + one-var: 0 + operator-assignment: 0 + operator-linebreak: 0 + padded-blocks: 0 + quote-props: 0 + quotes: 0 + require-jsdoc: 0 + semi-spacing: 0 + semi: 0 + sort-vars: 0 + space-after-keywords: 0 + space-before-blocks: 0 + space-before-function-paren: 0 + space-before-keywords: 0 + space-in-parens: 0 + space-infix-ops: 0 + space-return-throw-case: 0 + space-unary-ops: 0 + spaced-comment: 0 + wrap-regex: 0 + + # ECMAScript 6 + arrow-body-style: 0 + arrow-parens: 0 + arrow-spacing: 0 + constructor-super: 0 + generator-star-spacing: 0 + no-arrow-condition: 0 + no-class-assign: 0 + no-const-assign: 0 + no-dupe-class-members: 0 + no-this-before-super: 0 + no-var: 0 + object-shorthand: 0 + prefer-arrow-callback: 0 + prefer-const: 0 + prefer-reflect: 0 + prefer-spread: 0 + prefer-template: 0 + require-yield: 0 diff --git a/sites/all/modules/contrib/metatag/CHANGELOG.txt b/sites/all/modules/contrib/metatag/CHANGELOG.txt index adaec00a..da1008a4 100644 --- a/sites/all/modules/contrib/metatag/CHANGELOG.txt +++ b/sites/all/modules/contrib/metatag/CHANGELOG.txt @@ -1,3 +1,647 @@ +Metatag 7.x-1.25, 2018-04-03 +---------------------------- +#2958362 by DamienMcKenna, didierlebouc: Undefined index error in 7.x-1.24. +#2958208 by DamienMcKenna: Bug in count() statement in metatag.metatag.inc. + + +Metatag 7.x-1.24, 2018-04-03 +---------------------------- +#2958279 by joelpittet: Fatal error: Call to undefined function int_val(). + + +Metatag 7.x-1.23, 2018-04-03 +---------------------------- +#2906312 by DamienMcKenna: Added the twitter:dnt meta tag. +#2903980 by DamienMcKenna, Chris Charlton: Undefined index in + metatag_token_info. +#2143979 by bpleduc, drunken monkey, DamienMcKenna, thirdender, davidthou: + Allow Views meta tags to "Use replacement tokens from the first row". +#2882769 by DamienMcKenna: List Schema Metatag as a related module. +#2882769 by DamienMcKenna: Added a hook_requirements() message about the + Schema.org Metatag module. +#2929487 by volkswagenchick, porkloin: Typo in metatag_dc.install, aka "Dublin" + misspelled by the guy from Ireland. +#2931744 by DamienMcKenna: Fix tests for the 7.x-1.x branch, + testXssMetatagConfig has a regression. +#2932110 by thejimbirch: Update Description's meta description to 320 chars + (for 2018). +#2933940 by DamienMcKenna: og:image must be at least 200x200 otherwise it is + ignored by Facebook. +#2946145 by DamienMcKenna, bkosborne: Remove usage of deprecrated each() + function for PHP 7.2+ future proofing. +#2872206 by jenlampton: Drush command for importing from Page Title throws + fatal. +#2872446 by jenlampton, DamienMcKenna: Complete the drush command for importing + nodewords meta tags. +#1282806 by DamienMcKenna, iamEAP, osopolar, victoriachan, malcomio, HyperGlide, + Murz, dandaman, klokie: Upgrade script for Meta Tags Quick. +By DamienMcKenna: Updated README.txt related to the importer module. +#2950652 by Les Lim: metatag_favicons_get_mime_type() is mostly wrong. +#2933194 by ocastle: Issue with URL Decoding panel substitutions. +#2932401 by DamienMcKenna: New tag: Set-Cookie. +#2945589 by ron_s: Apostrophe encoded in page title when using Panels + substitutions. +#2956465 by DamienMcKenna, alexpott: Make sure $_GET['page'] is an integer. +#2832101 by DamienMcKenna, jenstechs: hreflang tokens should support Content + Translation. +#2309017 by DamienMcKenna, rodrigoaguilera, nmillin, John_B, David Hernández, + ctarres, cmseasy, computerbarry, skein, erwangel, espurnes, zmove: + Automatically trim meta tag lengths. +#2958206 by DamienMcKenna: Fix hreflang tags for entity_translation. +#2864078 by DamienMcKenna: Improve coding standards on Metatags 7.x-1.x. +#2924181 by Mike Lewis: Default value for Robots on config form does not + reflect stored configuration. +#2853251 by kpaxman: Code to use only first item doesn't work if first item is + blank. +#1624266 by L-four, angrytoast: Add support Views Bulk Operations for mass + updating metatags. +#2854539 by DamienMcKenna, jalpesh, zhouhana: http://drupal.org instead of + https://www.drupal.org in default generator tag. + + +Metatag 7.x-1.22, 2017-07-03 +---------------------------- +#2853699 by DamienMcKenna: Drupal core 7.40 is the minimum version supported. +#2857982 by arosboro: Fixed tests due to changes in Entity Translation. +#2864524 by JamesK: Improve field description for the abstract meta tag. +#2868750 by DamienMcKenna: List Metatag Cxense as a related module. +#2882048 by jyraya: i18n integration shouldn't assume a tag has a group. +#2882703 by smustgrave: module_load_include() doesn't work quite as intended if + the module is not installed. +#2864834 by DamienMcKenna: Added a note to update script 7114 to note that + output caching has been disabled. +#2297647 by greggles, DamienMcKenna: Run views_invalidate_cache() when + metatag_views is disabled. +#2857088 by arosboro: Fixed parsing of percentages in URLs in Metatag:Panels. + + +Metatag 7.x-1.21, 2017-02-15 +---------------------------- +#2844504 by DamienMcKenna: Add project names to all dependencies. +By DamienMcKenna: Backported some minor text changes from the D8 branch. +#2821713 by WidgetsBurritos: Don't output the mask-icon 'color' attribute if + it's empty. +By DamienMcKenna, Michelle: Minor updates to README.txt. +#2852260 by DamienMcKenna: Output caching wasn't fully disabled for the front + page or non-entity pages that used the global defaults. +#2852737 by DamienMcKenna: Added CodeClimate config files. +By DamienMcKenna, klausi: Information disclosure issue under certain + circumstances. + + +Metatag 7.x-1.20, 2017-01-18 +---------------------------- +#2840500 by DamienMcKenna: Bring back compatibility with Workbench Moderation + v1. +#2841064 by klausi, DamienMcKenna: Fix sandbox-based update scripts so they + don't run into infinite loops. + + +Metatag 7.x-1.19, 2017-01-01 +---------------------------- +#2832427 by dmitry.kazberovich, e2thex, DamienMcKenna: Allow the metatag cache + expiration time to be modified. +#2780025 by DamienMcKenna: Backported output tests from D8. Also fixes the + output of the shortcut icon, ios-app, android-app, author, publisher, and made + the Google CSE thumbnail tag an 'image'. Left some others to be fixed later. +#2832476 by czigor; Added the 'product.group' and 'place' og:type options. +#2835614 by drumm: metatag_metatags_load_multiple() doesn't need to sort the + results. +By DamienMcKenna: Noted in the metatag_google_plus info file and README.txt that + it includes the Author and Publisher meta tags. +By DamienMcKenna: Tweaked the favicons module description. +By DamienMcKenna: Updated main tests to match the latest coding standards. +By DamienMcKenna: Minor updates to various Google CSE labels. +By DamienMcKenna: A string in metatag_opengraph_products wasn't using an + argument that was being passed to it. +By DamienMcKenna: Minor adjustment to metatag_mobile strings. +By DamienMcKenna: Updated submodule tests to match the latest coding standards. +#2838198 by DamienMcKenna, Mixologic: Test dependency changes to workaround + changes in the DrupalCI platform. +#2831073 by dxvargas, DamienMcKenna: Remove old workarounds due to Workbench + Moderation 3.x API changes, warn if older version installed. + + +Metatag 7.x-1.18, 2016-11-30 +---------------------------- +#2761817 by DamienMcKenna: Fixed metatag_update_replace_config() so it isn't + hardcoded to only work with og:video. +#2759843 by DamienMcKenna: Removed the Alexa verification tag. +#2759855 by DamienMcKenna: Removed the Yahoo verification tag. +By DamienMcKenna: Clear Metatag's caches after deleting or renaming a meta tag. +#2763499 by DamienMcKenna: Don't use entity_load() when saving Metatag data, + it can cause anomolies. +#2750705 by jalpesh, susannecoates: Updated description of the Google Play app + ID meta tag. +#2771603 by FeyP: Fixed incorrect argument name to metatag_metatag_save(). +#2745177 by DamienMcKenna: Tests to confirm each meta tag can be filled in and + added to the global settings. +#2773839 by DamienMcKenna: Remove 'metatag_ui' from the {system} table. +#2773465 by DamienMcKenna: Because Page Title is now fully deprecated, promote + converting its settings and uninstalling it. +#1944862 by FeyP, DamienMcKenna: Allow control over which meta tags and + languages are reverted on the Bulk Revert page. +#2766315 by recrit, DamienMcKenna: metatag_entity_type_enable() would + incorrectly change settings in certain circumstances. +#2774859 by DamienMcKenna: Refactored main tests to not use the submodules by + default. +#2678896 by nmalinoski: Fixed redundant t() calls to fix double translation. +#2787189 by DamienMcKenna: Added some tests to confirm that the different node + preview options don't interfere with saving meta tag values. +By DamienMcKenna: Added a Known Issue for problems with Entity Token. +#2790967 by DamienMcKenna: Added tests for taxonomy term config translations + using i18n. +#2795255 by lazysoundsystem: 'disabled' was misspelled. +By DamienMcKenna: Updated the description of content-language to clarify its + usage and the fact that Bing may still use it. +#1865228 by DamienMcKenna: Moved Author meta tag to GooglePlus submodule. +#1343914 by DamienMcKenna: Moved Publisher meta tag to GooglePlus submodule. +#2784879 by sorinb, DamienMcKenna: Change metatag_update_7108 to use a sandbox. +#2791963 by ttkaminski, DamienMcKenna: Don't change protocol-relative URLs in + image values. +#2797069 by Internet, DamienMcKenna: Corrected the URL to Wikipedia's ICBM page. +#2799317 by mdooley: Use a static date example for the Expires meta tag's + description to avoid flooding the {locales_source} table. +#2800479 by DamienMcKenna, david.gil: Avoid showing errors if Search API is not + installed. +By DamienMcKenna: Slight reordering of the main info file. +#2663208 by DamienMcKenna, geertvd: Don't load meta tags on the /user/me page, + avoid problems when the Me module is installed. +#2813429 by DamienMcKenna: Added tests for metatag_mobile. +#2813427 by DamienMcKenna: Added support for the amphtml link tag. +#2811735 by Stevel, DamienMcKenna: Added dependencies to all tests so that tests + will only be listed if those dependencies are also available. +By stimalsina: Minor improvements to the amphtml meta tag's description. +#2823367 by DamienMcKenna: Fixed tests after internal API change in Media. +#2826023 by renatog, DamienMcKenna, gfcamilo: Coding standards fixes for + metatag.module. +#2831030 by prince_zyxware: Fixed some minor coding standard bugs, spacing + issues. +#2759461 by DamienMcKenna: hreflang=x-default is no longer removed when another + hreflang meta tag has the same URL, instead the other tag is removed as it + was supposed to be. Added a new [node:url-original] token for showing the + URL for the source node for translations; updated the default value for + the hreflang=x-default meta tag to use the new token instead of + [node:source:url]. Updates to many tests to allow these changes. +#2532588 by cebasqueira, renatog, DamienMcKenna: Added new meta tags for Google + CSE. +#2796701 by DrupalDano, DamienMcKenna: Some XSS tests for meta tag handling. +#2831073 by DamienMcKenna: Added Workbench Moderation as a test dependency, for + future use. +#2831822 by DamienMcKenna: Added support for the handheld mobile alternate link + tag, supported by Google. + + +Metatag 7.x-1.17, 2016-06-30 +---------------------------- +#2748627 by jalpesh: Corrected twitter:app:id:googleplay description. +#2752319 by DamienMcKenna: Fixed output of the mask-icon meta tag. +#2752319 by DamienMcKenna: Added the mask-icon 'color' attribute, the new 'url' + option for meta tag definitions, and tests for the mask-icon meta tag. +#2754263 by DamienMcKenna: Meta tags with multiple values should still be + returned as a string from metatag_get_value(). +#1953080 by DamienMcKenna: Don't output language/locale meta tags if they are + equal to LANGUAGE_NONE/"und". +#2659906 by DamienMcKenna: Rewrote update 7040 to use less memory and work + better. +#2720723 by IRuslan: Allow config instance names to be changed. +#2669592 by DamienMcKenna: Fix for possible problem with removal of meta tags + that Metatag is already outputting. +#2162397 by DamienMckenna: Added test dependency for Profile2. +#2162397 by roderick, DamienMckenna, hideaway: Fixed loading multiple entities + on the same path when at least one of them is not enabled for use with + Metatag and gets in the way of the one which is enabled. + + +Metatag 7.x-1.16, 2016-06-03 +---------------------------- +#2742063 by jalpesh, DamienMcKenna: Fix syntax error in verification module. +#2742123 by DamienMcKenna: Added test for all submodules to ensure they could be + enabled. + + +Metatag 7.x-1.15, 2016-06-03 +---------------------------- +#2700217 by DamienMcKenna: Added Media module as a test dependency. +#2700217 by DamienMcKenna: Automatically filter out Media embed codes from meta + tags when the Media WYSIWYG module is installed. +#2709985 by alzz: Added fb:pages meta tag for Facebook Instant Pages. +#2703081 by DylanUnderwood: Added apple-mobile-web-app-title meta tag. +#2704805 by jcnventura: Fixed the hreflang meta tag. +#2678004 by alvar0hurtad0: Improvements to the API documentation. +By DamienMcKenna: Corrected some messages in metatag_update_7104. +By DamienMcKenna: Incorrect indenting in metatag_favicons.metatag.inc. +#2687309 by das-peter, skein, DamienMcKenna, k_zoltan: Fixed output translations + so it's actually disabled when it's turned off. +#2712815 by Chalk, DamienMcKenna: Rewrote update scripts that rename meta tags + to use two new shared functions, and always use a sandbox for it. +#2720463 by DamienMcKenna: Rename the icon_any favicon to mask-icon. +#2276855 by ben.kyriakou: Properly handle the 'disabled' state when featurized + configs are reverted. +#2687309 by das-peter, DamienMcKenna: Submodules shouldn't update translations + during page load. +#2725251 by DamienMcKenna, Jim.M: Added validation tags for Alexa, Baidu, Norton + Safe Web and Yahoo. +#2725741 by DamienMcKenna: Ensure the Locale module is enabled before running db + queries against the {locales_source} table. +By DamienMcKenna: Updated the docblock comment for metatag_metatags_save(). +#2728919 by DYdave: Workaround for CTools bug that causes the Views popup to be + tiny. +#2728933 by DYdave, DamienMcKenna: Trigger hook_metatag_token_types() from + metatag_metatags_form() instead of metatag_field_attach_form() so it works + with all submodules too. +#2710377 by DamienMcKenna: Updated the message for og:image:url to make it + clear it might be better to not use it. +#2539388 by DamienMcKenna: All image meta tags will be output with absolute URLs + and spaces will be replaced with '%20'. +#2692877 by stefan.r, DamienMcKenna, Drunkey Monkey: Search API integration. +#2720221 by dnmurray: Allow sanitizing of values through token_replace(); for + advanced usage only, may lead to other issues. +#2497043 by marcelovani, uzlov: Allow Metatag:Context configs to be sorted by a + 'weight' value. + + +Metatag 7.x-1.14, 2016-04-02 +---------------------------- +By DamienMcKenna: Corrected return code from update 7107. +#2664624 by DamienMcKenna: Added a space in front of the Google Plus schemaorg + variable to avoid HTML validation errors because of the lack of space. +#2658902 by DamienMcKenna, swentel: Renamed the 'Add a Metatag default' link to + match the D8 wording. +#2665206 by DamienMcKenna: Don't add an index in 7029 if it already exists. +#2670842 by Ambient.Impact: Fixed permissions in the Importer submodule. +#2613598 by DamienMcKenna: Removed the Contributor Covenant, replaced it with a + link to https://www.drupal.org/dcoc. +#2692933 by doostinharrell, DamienMcKenna: $metatags variable in + metatag_field_attach_form() may not be an array in certain circumstances. +#2658808 by tommik: Rewrote query in update 7040 so it works better. +#2688963 by DamienMcKenna: Added a note about the Yoast SEO module. +#2687847 by DamienMcKenna: Added a note about the Parse.ly module. +#2696445 by Simon Georges: Added the twitter:image:alt meta tag. +#2678896 by Dave Reid: Fixed double-encoding of form fields. +#2667214 by DamienMcKenna: Improved tests for string encoding. +#2667214 by joelstein, DamienMcKenna: Decode HTML entities prior to rendering + meta tags. + + +Metatag 7.x-1.13, 2016-03-04 +---------------------------- +#2662952 by DamienMcKenna: Fixed logic on hook_requirements for checking the + version of Token that is installed. + + +Metatag 7.x-1.12, 2016-03-04 +---------------------------- +#2644742 by kev5873, DamienMcKenna: Variable scoping issue with Metatag:Panels + could lead to incorrect meta tag output. +#2309017 by DamienMcKenna, rodrigoaguilera: Tidied up the install file a little. +#2658808 by DamienMcKenna: Improved query to skip update 7040 if it isn't + needed. +#2658262 by Devin Carlson, DamienMcKenna: Fixed hook_metatag_config_delete(), + this time with tests. +#2661378 by DamienMcKenna: No longer require Token v7.x-1.6, just highly + recommend it. +#2661408 by DamienMcKenna: Removed the status message when core is up-to-date. +#2661412 by DamienMcKenna: Improve hook_requirements check for Entity + Translation. +#2661434 by DamienMcKenna: Removed the status message about alt_hreflang. +#2652120 by DamienMcKenna: Fixes for old config translations that weren't + fixed with previous updates. + + +Metatag 7.x-1.11, 2016-01-26 +---------------------------- +#2568499 by DamienMcKenna, DD 85: Removed an errant space. +#2655582 by DamienMcKenna, MihaiMiculescu: Fixed automatic image parsing. +By DamienMcKenna: Minor changes to the README.txt file. +#2655614 by DamienMcKenna: Added tests for image handling. +#2655662 by DamienMcKenna: Fixed handling of output translation on pages with + really long paths. + + +Metatag 7.x-1.10, 2016-01-22 +---------------------------- +#2654838 by Plazik, DamienMcKenna: Disabling output caching lead to Undefined + Variable errors. +#2654638 by DamienMcKenna, noah, marleythedog: Allow updates 7104 and 7105 to + run if Locale is not enabled. +#2654530 by DamienMcKenna, Adenn, deja711: Twitter Cards update 7100 and + OpenGraph update 7103 cannot run until Metatag update 7100 has finished. + + +Metatag 7.x-1.9, 2016-01-21 +--------------------------- +#2652772 by DamienMcKenna: Fix update 7101 and rerun it to correct translation + data. +#2651812 by DamienMcKenna: Added an option to disable the i18n integration. +#2420489 by Les Lim, DamienMcKenna: New caching process for entities. +#2652260 by DamienMcKenna: Remove the revision_id from translation string IDs. +#2509246 by DamienMcKenna, zniki.ru: Remove meta tags added by core, with option + to leave them as-is. +#2652294 by DamienMcKenna: Incorrect string context was being used for meta tag + output translation. +#2653434 by DamienMcKenna, reinchek: Fixed metatag_metatags_load(). +#2653446 by DamienMcKenna: Wrong variable name passed to + metatag_config_delete(). +#1858540 by DamienMcKenna, friera: Added the pragma, cache-control and expires + meta tags. + + +Metatag 7.x-1.8, 2016-01-14 +--------------------------- +#2546636 by DamienMcKenna: Fixes to the custom Panels pane for editing tags. +#2113501 by DamienMcKenna: Shortened i18n translation context to just + "metatag:METATAGNAME" to make translations easier. +#2552829 by DamienMcKenna: Move the basic meta tags to a group. +#2552827 by DamienMcKenna: Group meta tag tokens so they're less confusing. +#2552849 by DamienMcKenna: Meta tag tokens for user entities. +#1986032 by DamienMcKenna, izus, yang_yi_cn, Placinta, maijs, Tharna, stijndmd: + Improved i18n compatibility for the Views, Panels and Context submodules. +#2518690 by manikaprasanth: Added support for editing Commerce product entities. +#2550001 by DamienMcKenna: Renamed twitter:image:src back to twitter:image. LOL. +#2559359 by labboy0276: Errors if the Views integration can't find the expected + display object. +#2560649 by DamienMcKenna: Added optional second-stage translation for meta tag + output. +#2556741 by DamienMcKenna: Fixed robots handling on Nodewords importer; moved + Nodewords importer into a separate file to keep the Importer module more + general. +#1809652 by DamienMcKenna: Added a new [current-page:pager] token for inserting + a pager into meta tags. +#1809652 by DamienMcKenna: Update default node title to insert the pager. +#2518690 by DamienMcKenna: Improvements to Commerce Product handling. +#2568499 by DamienMcKenna: Added new Apple-specific meta tags to the Mobile + submodule. +#2568463 by DamienMcKenna: Added the android-app deeplink meta tag. +#2569093 by DamienMcKenna: Added the ios-app deeplink meta tag. +#2568955 by DamienMcKenna: Don't output meta tags that only contain a pager. +#2556741 by DamienMcKenna: BatchAPI call wasn't updated after the Nodewords + importer file was renamed. +#2514916 by DamienMcKenna: Split up the tests file, moved them into the tests + directory, added new tests for node revisions. +#2567621 by hass: Allow the custom pager to be translated using the i18n + Variable module. +#2572371 by Dave Reid: Remove support for comments. +#2572291 by Dave Reid: Always display config items in the correct order - global + items first, then sorted alphabetically. +#2567677 by Perignon, DamienMcKenna: og:video meta tag renamed. +#2556741 by DamienMcKenna: Follow-up to fix imported robots meta tags. +#2556741 by DamienMcKenna: Updated the final commit message to show the correct + count. +#2498213 by makangus: Added the Android manifest meta tag. +#2573869 by DamienMcKenna: Fixed variable bug in update 7040. +#2579871 by DamienMcKenna: Added more test dependencies. +#2579201 by lesonunique, DamienMcKenna: Missing 'secure' option on + og:audio:secure_url. +#2580623 by marcvangend: Incorrect check for admin_language. +#2580523 by DamienMcKenna: Add a note to hook_requirements if hreflang module + is not installed and there are multiple locales enabled on the site. +#2587369 by DamienMcKenna: Added two placeholder files for storing tests for the + Views integration. +#2587371 by DamienMcKenna: Added two placeholder files for storing tests for the + Panels integration. +#2376857 by DamienMcKenna: Work around entity definitions that don't have a + 'bundles' attribute. +#2455777 by DamienMcKenna: Don't try to save any {metatag} records if the entity + or bundle is not supported. +#2597301 by DamienMcKenna: New submodule for handling the hreflang meta tag. +#2603058 by FluxSauce: Fixed problem loading migrate.inc file if Migrate is not + enabled. +#1957358 by pjonckiere, DamienMcKenna: Add tests to ensure that the meta tag + string encoding works correctly. +By DamienMcKenna: Some commit messages were in the wrong place. +#2603458 by Frando: Fixed update 7018 for sites using Entity Translation, and + re-run it. +#1355788 by DamienMcKenna: Allow use of 'public://' file scheme for images. +#2550001 by Dave Reid: Blank out metatag_update_7024() and metatag_update_7030() + because the 'twitter:image:src' meta tag was renamed back to 'twitter:image' + so these updates don't need to ever run. +#1957358 by DamienMcKenna: Added tests to confirm that HTML entities work + correctly in the page title. +#2619438 by DamienMcKenna: Improve documentation on the mobile subtheme. +#2597301 by DamienMcKenna: Only use the new locale-URL tokens when translations + modules are enabled. +#2180031 by DamienMcKenna: Fixed double-encoding of tokens. +#2635144 by DamienMcKenna: Added the apple-itunes-app meta tag. +#1904542 by DamienMcKenna: Added a bunch of Windows and IE -focused meta tags. +#2636132 by SpaghettiBolognese: Inconsistency in submodule naming. +#2637026 by matthewordie, DamienMcKenna: Mention in the og:image meta tag how + Facebook will handle multiple images (It defaults to the largest one). +#2564483 by DamienMcKenna, drupov, mas0h, das-peter, pwiniacki, sylus, webflo, + Gábor Hojtsy, pjonckiere, k_zoltan: Fixed i18n integration for core module and + all submodules; added over 1,000 new test assertions in major expansion of the + test suite. +#2644156 by DamienMcKenna: Default value of image_src meta tag for user entity + was set incorrectly. +#2639170 by anthonyleach: Use the correct hooks to add the RDF namespaces. +#2628558 by marcelovani: Renamed the bundled Context definitions to avoid + conflicts. +By DamienMcKenna: Fixed an accidental removal of the Token v1.6 requirement. +#2622662 by rollsd: Adjusted logic to fix problem with entity types that only + have one bundle. +#2648804 by DamienMcKenna: Removed some unfinished code from + metatag_metatags_delete_multiple(). +#2587725 by DamienMcKenna: Fixed display of meta tag labels in localized entity + & config forms. +#2389929 by michee.lengronne, scor, DamienMcKenna, sint: Fixed Google+ HTML + head declaration so it validates, but a change to the site's html.tpl.php is + now required. +#2184857 by DamienMcKenna, mikeytown2: Expanded metatag_metatags_load() to allow + meta tags to be loaded by revision ID. +#1838554 by dimchich, jcnventura, Bao Truong, marcelovani, DamienMcKenna: Allow + entity tokens to be properly used on entity pages via Metatag:Context i.e. + 'by path'. +#2361343 by marcelovani: Allow by-path definitions to override the page title of + all pages. +#2493689 by DamienMcKenna: Removed two arguments from metatag_metatags_save() + that weren't actually being used. +#2613598 by DamienMcKenna: Added a copy of the Contributor Covenant in the + CODE_OF_CONDUCT.txt file. +#2335015 by DamienMcKenna: Remove og:type 'blog'. +#2649816 by DamienMcKenna: Added a copy of the GPL 2.0 license to the + repository. +#2338211 by DamienMcKenna: Only output the first item of a token for image meta + tags that only support one value. + + +Metatag 7.x-1.7, 2015-07-24 +--------------------------- +#2537738 by deepak_zyxware: Incorrect path to fb_social settings page. +#2535178 by DamienMcKenna: 'multiple' option on Viewport causes problems with + the meta tag's intended values. +#2524460 by DamienMcKenna, adriancotter, gbirch, jrb: Remove custom wrangling + for Views-based custom entity displays, added new hook to allow other modules + to customize as needed (hook_metatag_views_post_render_get_entity). +#2199533 by Adrian Richardson, DamienMcKenna, mairi: Don't reload entities when + processing tokens, it causes problems with content workflows. +#2513892 by DamienMcKenna: Tests for user objects. +#1658970 by DamienMcKenna, stefan.r, subhojit777, HyperGlide, jenlampton: Drush + script to convert data from the Page Title module. + + +Metatag 7.x-1.6, 2015-06-30 +--------------------------- +#2503089 by DamienMcKenna: Added support for the "any" favicon, used for SVG + files in Safari 9. +#2499865 by DamienMcKenna: Improvements to entity selection, all sites will now + automatically start off supporting news, terms and users. +#2503097 by DamienMcKenna: Added the theme-color meta tag. +#2503089 by jdanthinne, DamienMcKenna: Improved wording of the SVG favicon + description. +#2499737 by DamienMcKenna: Moved the Dublin Core Additional Tags meta tags into + a new submodule, metatag_dc_advanced. +#2499739 by DamienMcKenna: Moved the Open Graph Products meta tags into a new + submodule, metatag_opengraph_products. +#2498173 by DamienMcKenna: Clarified the touch icon meta tags available by + adding separate primary vs precomposed tags. +#2499739 by DamienMcKenna: Follow-up to fix a missing variable. +#2507025 by DamienMcKenna: Fixed Panels/Panelizer support for entities after + changes in 1.5. +#2505051 by DamienMcKenna: Automatically check for image URLs in image meta + tags; added a new 'image' attribute to meta tag specifications. +#2504561 by hanoii: Remove unused metatag_load_entity_from_path() function and + corresponding hook. +#2222711 by hanoii, DamienMcKenna, andyg5000: Fixed Views support for entities + after API changes in 1.5. +#2467587 by DamienMcKenna: Clear the Metatag cache when a node's state is + changed via Workbench Moderation. +#2449425 by DamienMcKenna: Only process string values for token replacement. +#2265453 by zd123, DamienMcKenna: CTools keyword substitution for Panels + integration. +#2512284 by DamienMcKenna: Missing token browser link on main Metatag fieldset. +#2513890 by DamienMcKenna: Added tests for taxonomy term integration. +#1404270 by JStanton, DamienMcKenna: Added the Refresh meta tag. +#2384673 by etroid, DamienMcKenna: Added the shortcut icon meta tag. +#2514852 by rrfegade: Spelling mistakes in README.txt files. +#2514878 by DamienMcKenna: Ignore admin pages on Views/CTools-driven entity + pages. +#2514812 by david_garcia: Fix Views integration for ECK entities. +#2514572 by DamienMcKenna: Don't check if records exist when deleting them, + just run the deletion query. + + +Metatag 7.x-1.5, 2015-05-29 +--------------------------- +#2442183 by DamienMcKenna, jwilson: Mention the Image URL Formatter module in + the README.txt file. +#2451231 by DamienMcKenna: Fixed the Devel:Generate integration. +By DamienMcKenna: Rearranged og:type select_or_other integration code to be + after the og:type tag definition. +By DamienMcKenna: Removed duplicate description for video:writer meta tag. +By DamienMcKenna: Standardized structure of all theme functions. +#2452985 by DamienMcKenna: Added 39 additional Dublin Core meta tags. +By DamienMcKenna: Removed duplicate dcterms.rights tag. +By DamienMcKenna: Updated new 'date' dcterms tags to use 'date' generator. +#2460791 by DamienMcKenna: Allow the page region used to trigger output to be + changed; see the advanced settings page for details. +#2462117 by DamienMcKenna: Allow the included default configurations to be + disabled. +#2454499 by Dmitriy.trt: metatag_config_is_enabled() returned FALSE for empty + config, when checked with defaults. +#2407477 by greggles: Provide support for Twitter app tags without having to use + an "app" type. +By DamienMcKenna: Fixed a small mistake in output of metatag_update_7011(). +#2429091 by deviantintegral, DamienMcKenna: Add support for applinks.org tags. +#2417155 by dobe: Feeds import fails because of placement of entity_type. +By DamienMcKenna: Minor text improvements per D8 branch. +By DamienMcKenna: Clarified compatibility with Workbench Moderation. +#2473459 by DamienMcKenna: Updated all links to d.o. +#2479325 by DamienMcKenna: Require Token 1.6. +#1491562 by jonathan_hunt, knalstaaf: Add instructions to README.txt explaining + how to configure meta tags for entity bundles. +#2449425 by DamienMcKenna: Refactored select_or_other usage, API addition. +#2487179 by DamienMcKenna: Allow longer cache IDs to reduce conflicts. +#2473107 by DamienMcKenna: Added a warning about having more og:image:type + values than there are og:image values, it can lead to Facebook validation + errors. +#2474427 by DamienMcKenna: Added an advanced option to disable the output cache. +#2432517 by undertext, DamienMcKenna: Check all CTools contexts, not just the + first one. +#2449425 by DamienMcKenna: Follow-up for select_or_other bug. +#2415983 by ciss, DamienMcKenna: Core elements not removed when no metatag + substitute provided. +#2490846 by DamienMcKenna: Using [metatag] tokens failed if the value was empty. +#2466629 by DamienMcKenna, rupertj: Ensure entity is an object before checking + its language code. +#2081717 by DamienMcKenna: Added Admin Menu item for flush the Metatag caches. +By DamienMcKenna: Noted that the 'shortlink' meta tag replaces 'shorturl'. +#2493711 by akoe, DamienMcKenna: Added geo.position, geo.placename, geo.region + and icbm meta tags. +#2493395 by das-peter: Google+ itemtype meta tag malformatted. +#1915926 by DamienMcKenna: Allow multiple fb:admins values. +#2494271 by DamienMcKenna: og:street_address, og:postal_code, og:country_name + are incorrect. +#1498762 by DamienMcKenna: Added the Rating meta tag. +#2451271 by DamienMcKenna: Added the Referrer meta tag. +#1285946 by DamienMcKenna: Added metatag_mobile submodule with a few mobile + -related meta tags. +#2475147 by MatthewHager, DamienMcKenna: Fixed Feeds integration after its API + changed. +#2070821 by DamienMcKenna, pounard: Major re-architecture to how supported + entities are handled. +#2495877 by DamienMcKenna: Added a Context global config instance. +#2495875 by DamienMcKenna: Added a Panels global config instance. +#1281138 by jantoine, DamienMcKenna, drupalninja99, stuart.crouch, subhojit777, + KarlShea: Metatag:Importer submodule for importing data from Nodewords (D6). +#2376921 by DamienMcKenna: Trigger an entity cache clear when meta tags are + saved or deleted. +#2496487 by DamienMcKenna: The function is called entity_get_info(), not + entity_info(). +#2103321 by mistermoper, DamienMcKenna: Added 24 more Open Graph meta tags for + managing product information. +#2085747 by DamienMcKenna: Added twelve favicon varieties to a new submodule, + Metatag: Favicons. +By DamienMcKenna: Removed message from metatag_opengraph_install() warning about + compatibility with the RDF module, which is no longer applicable. +#2408211 by infinet, MatthewHager: Context substitution added to Metatag: Panels + output. +#2156653 by mitsuroseba, undertext, asgorobets, DamienMcKenna: Added a custom + pane for adding the meta tags fieldset to a node form customized via Panels. +#2496487 by DamienMcKenna: Follow-up on previous commit, remove unneeded + function_exists() call. + + +Metatag 7.x-1.5-beta1, 2015-02-02 +--------------------------------- +#2362639 by DamienMcKenna: Improved defaults for Google+ meta tags. +#2318985 by DamienMcKenna: Indicate that Open Graph tags are used on Pinterest. +#2362639 by DamienMcKenna: Added itemtype default values for Google+ meta tags. +#2358137 by DamienMcKenna: Added a submodule for managing site verification + meta tags, the first of which is for Google. +#2358131 by DamienMcKenna: Support for the Pinterest verification meta tag. +#1848338 by larowlan, DamienMcKenna: Added more tests, especially one for + checking the editorial process on a node. +#2362893 by ipo4ka704: Don't assume the first Panels context is an object. +#2363591 by DamienMcKenna: Added a default for the 'image' meta tag on user + entity pages. +#1967856 by duozersk: Fixed a minor mistake in the previous commit. +#2370943 by Simon George: Removed redundant comment. +#2373189 by nmillin: Added support for the Bing verification code. +#2358139 by nmillin: Added support for the Yandex verification code. +#2378127 by DamienMcKenna: Support for rel="alternate" hreflang="x" link tag. +#2376915 by jenlampton, DamienMcKenna: Added the og:image:url meta tag. +#1978708 by DamienMcKenna, scor: Updated warning about compatibility with the + RDF module in Drupal core before 7.33. +#2385265 by mikemiles86: Correctly flatten Metatag form fieldsets in Context + integration. +#2370439 by potop, DamienMcKenna: Work around hook_entity_load() problems by + loading entity info in metatag_entity_supports_metatags() on demand. +#1868460 by preshetin: Added the rel=prev and rel=next meta tags. +#2388339 by das-peter: Fix select_or_other integration for Metatag:GooglePlus, + add the missing element_validator. +#2391975 by Spleshka: Support scenarios where the entity is possibly blank or + has no entity_id assigned yet, e.g. Profile2 pages. +#2400241 by greggles: Typo in description of robots-notranslate option. +#2400529 by greggles: Add support for OG product price:amount, price:currency. +#2411607 by liberatr, DamienMcKenna: README.txt note about using the + field_multiple_types module to control how many items are output. +#2415025 by DamienMcKenna: l() in metatag_metatag_info() creates recursion bug. +#2411477 by betz, DamienMcKenna: $form[#entity] doesn't work for all entities. +#2411549 by maijs: Language is lost during migration. +#2198669 by D2ev: Using metatag tokens can easily cause an infinite loop. +#2411477 by DamienMcKenna, betz: Follow-up to last change. + + Metatag 7.x-1.4, 2014-10-09 --------------------------- #2353079 by DamienMcKenna: Fixed Views integration, for real this time. @@ -70,6 +714,7 @@ 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. @@ -95,6 +740,8 @@ Metatag 7.x-1.0-rc2, 2014-08-05 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. +#2572891 by DamienMcKenna: Removed most 'fine tuning' items from the README.txt + file, added notes again about using Imagecache_Token to improve images. Metatag 7.x-1.0-rc1, 2014-07-12 @@ -272,7 +919,7 @@ By DamienMcKenna: Moved hook_requirements to the top of metatag.install. 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. +#2173271 by deetergp: Spelling and grammar 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 diff --git a/sites/all/modules/contrib/metatag/CODE_OF_CONDUCT.txt b/sites/all/modules/contrib/metatag/CODE_OF_CONDUCT.txt new file mode 100644 index 00000000..587ba66b --- /dev/null +++ b/sites/all/modules/contrib/metatag/CODE_OF_CONDUCT.txt @@ -0,0 +1,3 @@ +Contributor Code of Conduct +--------------------------- +See: https://www.drupal.org/dcoc diff --git a/sites/all/modules/contrib/metatag/README.txt b/sites/all/modules/contrib/metatag/README.txt index 6bec0398..4350c115 100644 --- a/sites/all/modules/contrib/metatag/README.txt +++ b/sites/all/modules/contrib/metatag/README.txt @@ -8,26 +8,42 @@ 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, LinkedIn, etc (see -below). +particularly the Open Graph submodule for use with Facebook, Pinterest, +LinkedIn, etc (see below). -This version of the module only works with Drupal 7.28 and newer. +This version of the module only works with Drupal 7.40 and newer. + +For additional information, see the online documentation: + https://www.drupal.org/docs/7/modules/metatag Features ------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- The primary features include: * The current supported basic meta tags are ABSTRACT, DESCRIPTION, CANONICAL, - GENERATOR, IMAGE_SRC, KEYWORDS, PUBLISHER, REVISIT-AFTER, RIGHTS, ROBOTS, - SHORTLINK and the page's TITLE tag. + GENERATOR, GEO.PLACENAME, GEO.POSITION, GEO.REGION, ICBM IMAGE_SRC, KEYWORDS, + PUBLISHER, REFRESH, REVISIT-AFTER, RIGHTS, ROBOTS, SHORTLINK, and the page's + TITLE tag. * Multi-lingual support using the Entity Translation module. -* Translation support using the Internationalization (i18n) module. +* Translation support using the Internationalization (i18n) module of the global + configurations, the values for all three submodules (Metatag:Context, + Metatag:Panels, Metatag:Views), and the final meta tags being output. * Full support for entity revisions and workflows based upon revision editing, - e.g., Revisioning module. + including compatibility with the Revisioning and Workbench Moderation modules. + +* Automatically extracts URLs from image fields, no need for extra modules. + +* String-based meta tags may be automatically trimmed to a certain length, and + the lengths may be easily customized to accommodate changes in search engine + algorithms. + +* A custom pager string may be added to meta tags by inserting the token + [current-page:pager] into e.g. page titles, description tags, etc. The + replacement string may be customized from the settings page. * Per-path control over meta tags using the "Metatag: Context" submodule (requires the Context module). @@ -42,8 +58,14 @@ 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, LinkedIn and other - sites, may be added by enabling the "Metatag: Open Graph" submodule. +* Forty additional Dublin Core meta tags may be added by enabling the "Metatag: + Dublin Core Advanced" submodule. + +* The Open Graph Protocol meta tags, as used by Facebook, Pinterest, LinkedIn + and other sites, may be added by enabling the "Metatag: Open Graph" submodule. + +* Twenty six additional Open Graph Protocol meta tags are provided for + describing products in the "Metatag: Open Graph Products" submodule. * The Twitter Cards meta tags may be added by enabling the "Metatag: Twitter Cards" submodule. @@ -51,11 +73,32 @@ The primary features include: * 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. +* Facebook's fb:app_id, fb:admins and fb:pages 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. + +* The App Links meta tags may be added by enabling the Metatag: App Links + submodule. + +* Site verification meta tags can be added, e.g. as used by the Google search + engine to confirm ownership of the site; see the "Metatag: Verification" + submodule. + +* The Metatag: Mobile & UI Adjustments submodule adds the MobileOptimized, + HandheldFriendly, viewport, cleartype, theme-color, format-detection, + apple-mobile-web-app-capable, apple-mobile-web-app-status-bar-style, the + android-app and ios-app alternative link meta tags, and the Android manifest + tag. + +* The hreflang meta tags are available via the Metatag:hreflang submodule. + +* Support for meta tags specific to Google Custom Search Appliance are available + in the "Metatag: Google Custom Search Engine (CSE)" submodule. + +* A variety of favicon sizes and styles can be added to the global configuration + using the Metatag: Favicons submodule. * An API allowing for additional meta tags to be added, beyond what is provided by this module - see metatag.api.php for full details. @@ -66,20 +109,38 @@ The primary features include: * Support for the Feeds module for importing data from external data sources or file uploads. +* Support for the Search API module for indexing of keywords. + * 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. +* Integrates with Workbench Moderation (v1) allowing meta tags on nodes to be + managed through the workflow process; this custom support is not needed in + Workbench Moderation v3 so the extra logic is automatically ignored. + +* The Transliteration module (see below) is highly recommended when using image + meta tags, e.g. og:image, to ensure that filenames are HTML-safe. + +* Adds an extra item to the "Flush all caches" menu for the Admin Menu module, + allowing for a quick way to clear the Metatag module's custom caches. -* The Transliteration and Imagecache Token modules (see below) are highly - recommended when using image meta tags, e.g. og:image. +* A custom pane, called "Node form meta tags", is available for adding the meta + tags fieldset when the node_edit page is customized using Panels; the + Metatag: Panels submodule does not need to be enabled in order for this to + work. -* Several advanced options may be controlled via the Advanced Settings page. +* Several advanced options may be controlled via the Settings page. + +* An import script is provided in the Metatag:Importer submodule for sites that + need to import data from Metatags Quick, Nodewords (Drupal 6 only), or Page + Title. + +* If the Media module (v2) is installed, the Media WYSIWYG submodule will be + used to automatically filter out Media's embed codes. Configuration ------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- 1. On the People Permissions administration page ("Administer >> People >> Permissions") you need to assign: @@ -94,13 +155,20 @@ Configuration assigned specifically for the front page: admin/config/search/metatags - 3. Each supported entity object (nodes, terms, users) will have a set of meta + 3. The list of supported entity types (nodes, taxonomy terms, etc) and bundles + (content types, vocabularies, etc) may be controlled from the Settings page: + admin/config/search/metatags/settings + + 4. In order to provide a specific configuration per entity bundle (content + type, vocabulary, etc), click "Add default meta tags". + + 5. Each supported entity object (nodes, terms, users) will have a set of meta tag fields available for customization on their respective edit page, these will inherit their values from the defaults assigned in #2 above. Any values that are not overridden per object will automatically update should the defaults be updated. - 4. As the meta tags are output using Tokens, it may be necessary to customize + 6. 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 @@ -108,18 +176,73 @@ Configuration 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 -page" configuration will show up in the Translate Interface admin page -(admin/config/regional/translate/translate) and may be customized per language. +Internationalization with the Translation (core) and Entity Translation modules +-------------------------------------------------------------------------------- +The module works with the core Translation module, allowing the meta tags for a +specific entity (node, term, etc) to be tied to a specific language. It also +supports the Entity Translation module, which may work better thank the basic +Translation module depending upon the site's desired functionality. This +integration means that content creators can customize an entity's meta tags for +each language supported on the site, and that the correct meta tags should +always be displayed for each locale. + + +Internationalization with the i18n modules +-------------------------------------------------------------------------------- +Using the String Translation (i18n_string) submodule of the Internationalization +(i18n) module package it is possible to translate meta tags: + +* All default configurations (admin/config/search/metatag) are translatable. + When a configuration is created or updated it will pass the values to the + i18n_string system. Additionally it is possible to bulk update them via the + string translation page (admin/config/regional/translate/i18n_string). + +* Meta tags for all submodules (Metatag:Context, Metatag:Panels, Metatag:Views) + are translatable. Similar to the default configurations, these meta tags are + made available when they are created and/or update, and may also be bulk + updated. +* Meta tags from entities (nodes, terms, etc) are not directly translatable. -Fine Tuning ------------------------------------------------------------------------------- -All of these may be controlled from the advanced settings page: -admin/config/search/metatags/settings +* The final output meta tags are passed through the translation system when the + page is being loaded. It is not possible to use the strings bulk updater to + spool all pages on the site, to do so it would be necessary to spool the page + using a separate script or tool. + +Additionally, certain variables are available for translation using the Variable +Translation submodule of the i18n package: + +* metatag_pager_string - The custom pager string. + + +Internationalization with the Smartling module +-------------------------------------------------------------------------------- +The Smartling translation service may be used with the Metatag module provide an +improved UX around the meta tag translation process. In order to do this, the +Smartling Interface Translation (smartling_interface_translation) module must +be enabled. + +For further details see the module's project page: + https://www.drupal.org/project/smartling + + +Search API integration +-------------------------------------------------------------------------------- +Entity meta tag values can be made searchable using the Search API module +(https://www.drupal.org/project/search_api). + + 1. Select "Meta tags" under "Data alterations" in the filters for the + index: + admin/config/search/search_api/index/INDEX NAME/workflow + 2. Meta tag fields will now appear under "Fields" and can be enabled there: + admin/config/search/search_api/index/INDEX NAME/fields + + +Fine tuning & suggestions +-------------------------------------------------------------------------------- +* There are many options available on the settings page to control how Metatag + works: + 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 @@ -128,62 +251,38 @@ admin/config/search/metatags/settings 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' - to FALSE through one of the following methods: - * Use Drush to set the value: - drush vset metatag_load_all_pages FALSE - * Hardcode the value in the site's settings.php file: - $conf['metatag_load_all_pages'] = FALSE; - To re-enable this option simply set the value to TRUE. -* By default users will be able to edit meta tags on forms based on the 'Edit - meta tags' permission. The 'metatag_extended_permissions' variable may be set - to TRUE to give each individual meta tag a separate permission. This allows - fine-tuning of the site's editorial control, and for rarely-used fields to be - hidden from most users. Note: The 'Edit meta tags' permission is still - 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. + +* When using Features to export Metatag configurations, it is suggested to + override all of the default configurations and then disable the default + configurations via the advanced settings page; doing so will avoid potential + conflicts of the same configurations being loaded by both the Metatag module + and the new Features-based modules. + +* Using fields to automatically fill in values for image meta tags is the + recommended way of inserting images - the module will automatically extract + the URL from the value. However, by default this forces social networks, + search engines and certain browsers to download the original version of the + image, which could be multiple megabytes. The alternative is to use the + Imagecache_Token module to instead load meta tags via a specific image style. + As an example, in order to load an image from a node field named + "field_meta_tag_image" using the "seo_thumbnail" style, the following token + would be used: + [node:field_meta_tag_image:seo_thumbnail:uri] + or + [node:field_meta_tag_image:seo_thumbnail] + (They give the same results) + Additionally, dimensions of the image may be obtained from the following: + [node:field_meta_tag_image:seo_thumbnail:width] + [node:field_meta_tag_image:seo_thumbnail:height] Developers ------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- Full API documentation is available in metatag.api.php. -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. +It is not necessary to control Metatag via the entity API, any entity that has +view modes defined and is not a configuration entity is automatically suitable +for use. 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); @@ -191,22 +290,25 @@ 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 ------------------------------------------------------------------------------- -* 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. +Troubleshooting / known issues +-------------------------------------------------------------------------------- * 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: or Without one of these being present the meta tags will not be displayed. +* An alternative method to fixing the missing-tags problem is to change the page + region used to output the meta tags. The region used may be controlled from + the settings page, it is recommended to test different options to identify the + one that works best for a specific site. * Versions of Drupal older than v7.17 were missing necessary functionality for 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. + module simultaneously can cause conflicts and unexpected results. It is + strongly recommended to convert the Page Title settings to Metatag and just + uninstall Page Title entirely. See https://www.drupal.org/node/2774833 for + further details. * 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. @@ -217,31 +319,45 @@ Troubleshooting / Known Issues "The page title | My cool site" The solution is to remove the browser plugin - the page's actual output is not affected, it is just a problem in the browser. -* The core RDF module is known to cause validation problems for Open Graph meta - 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. +* Drupal core versions before v7.33 had a bug which caused validation problems + in the Open Graph output if the RDF module was also enabled. The solution is + to update to core v7.33 or newer. * 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. +* If Entity Token is installed (a dependency for Rules, Commerce and others) it + is possible that the token browser may not work correctly and may either + timeout or give an error instead of a browsable list of tokens. This is a + limitation of the token browser. Related modules ------------------------------------------------------------------------------- -Some modules are available that extend Metatag with additional functionality: +-------------------------------------------------------------------------------- +Some modules are available that extend Metatag with additional or complimentary +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. +* Schema.org Metatag + https://www.drupal.org/project/schema_metatag + Extensive solution for adding schema.org / JSON-LD support to Metatag. * Transliteration https://drupal.org/project/transliteration Tidies up filenames for uploaded files, e.g. it can remove commas from filenames that could otherwise break certain meta tags. +* Imagecache Token + https://www.drupal.org/project/imagecache_token + Use tokens to load images via image styles, rather than forcing meta tags to + use the original image. + +* Alternative hreflang + https://www.drupal.org/project/hreflang + An alternative to the Metatag:hreflang module. Automatically outputs + meta tags on every page + for each language/locale available on the site. Also does not provide any way + of overriding the values or setting the x-default value. + * Domain Meta Tags https://drupal.org/project/domain_meta Integrates with the Domain Access module, so each site of a multi-domain @@ -249,8 +365,8 @@ Some modules are available that extend Metatag with additional functionality: * 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. + Enhances the user experience of the metatag_google_plus and metatag_opengraph + submodules by allowing the creation of custom itemtype and og:types values. * Node Form Panes https://drupal.org/project/node_form_panes @@ -260,24 +376,44 @@ Some modules are available that extend Metatag with additional functionality: https://drupal.org/project/textimage Supports using Textimage's custom tokens in meta tag fields. +* Field Multiple Limit + https://drupal.org/project/field_multiple_limit + Allows control over how many items are output in a multi-item field, useful + with meta tags that only allow for one item but which are assigned from fields + which accept multiple items, e.g. og:audio and og:video. + +* Real-time SEO for Drupal + https://www.drupal.org/project/yoast_seo + Uses the YoastSEO.js library and service (https://yoast.com/) to provide + realtime feedback on the meta tags. + +* Parse.ly Publishing Analytics + https://www.drupal.org/project/parsely + Automatically generates meta tags for the Parse.ly service. + +* Metatag Cxense + https://www.drupal.org/project/metatag_cxense + Adds support for the Cxense meta tags used by their DMP and Insight services. + -Credits / Contact ------------------------------------------------------------------------------- +Credits / contact +-------------------------------------------------------------------------------- Currently maintained by Damien McKenna [1] and Dave Reid [2]; all initial development was by Dave Reid. -Ongoing development is sponsored by Mediacurrent [3] and Palantir.net [4]. All -initial development was sponsored by Acquia [5] and Palantir.net. +Ongoing development is sponsored by Mediacurrent [3] and Lullabot [4]. All +initial development was sponsored by Acquia [5] and Palantir.net [6]. The best way to contact the authors is to submit an issue, be it a support request, a feature request or a bug report, in the project issue queue: - http://drupal.org/project/issues/metatag + https://www.drupal.org/project/issues/metatag References ------------------------------------------------------------------------------- -1: http://drupal.org/user/108450 -2: http://drupal.org/user/53892 -3: http://www.mediacurrent.com/ -4: http://www.palantir.net/ -5: http://www.acquia.com/ +-------------------------------------------------------------------------------- +1: https://www.drupal.org/u/damienmckenna +2: https://www.drupal.org/u/dave-reid +3: https://www.mediacurrent.com/ +4: https://www.lullabot.com/ +5: https://www.acquia.com/ +6: https://www.palantir.net/ diff --git a/sites/all/modules/contrib/metatag/metatag.admin.inc b/sites/all/modules/contrib/metatag/metatag.admin.inc index 9138d038..30b2a3f4 100644 --- a/sites/all/modules/contrib/metatag/metatag.admin.inc +++ b/sites/all/modules/contrib/metatag/metatag.admin.inc @@ -5,29 +5,6 @@ * Administration page callbacks for the metatag module. */ -function _metatag_config_sort($a, $b) { - $return = NULL; - $a_contexts = explode(':', $a->instance); - $b_contexts = explode(':', $b->instance); - for ($i = 0; $i < max(count($a_contexts), count($b_contexts)); $i++) { - $a_context = isset($a_contexts[$i]) ? $a_contexts[$i] : ''; - $b_context = isset($b_contexts[$i]) ? $b_contexts[$i] : ''; - if ($a_context == $b_context) { - continue; - } - elseif ($a_context == 'global') { - $return = -1; - } - elseif ($a_context == '') { - $return = -1; - } - else { - $return = strcmp($a_context, $b_context); - } - } - return $return; -} - function _metatag_config_overview_indent($text, $instance) { $parents = metatag_config_get_parent_instances($instance); array_shift($parents); @@ -48,8 +25,7 @@ function metatag_config_overview() { $metatags = metatag_get_info('tags'); $configs = ctools_export_crud_load_all('metatag_config'); - ksort($configs); - //uasort($configs, '_metatag_config_sort'); + uksort($configs, '_metatag_config_instance_sort'); $rows = array(); foreach ($configs as $config) { @@ -109,7 +85,7 @@ function metatag_config_overview() { $row['class'][] = 'warning'; } - // Close the details div + // Close the details div. $details .= ''; // Add indentation to the leading cell based on how many parents the config has. @@ -158,6 +134,12 @@ function metatag_config_overview() { 'title' => t('Export'), 'href' => 'admin/config/search/metatags/config/' . $config->instance . '/export', ); + if (module_exists('i18n_string') && !variable_get('metatag_i18n_disabled', FALSE)) { + $operations['translate'] = array( + 'title' => t('Translate'), + 'href' => 'admin/config/search/metatags/config/' . $config->instance . '/translate', + ); + } $row['data']['operations'] = array( 'data' => array( '#theme' => 'links', @@ -188,6 +170,7 @@ function metatag_config_overview() { drupal_get_path('module', 'metatag') . '/metatag.admin.css', ), ), + '#suffix' => '

' . t('Any items marked "Unknown" are configurations in the system for entity types or bundles which have been disabled via the API or the Settings page; they will not be used.', array('@url' => url('admin/config/search/metatags/settings'))) . '

', ); return $build; @@ -281,7 +264,8 @@ function metatag_config_edit_form($form, &$form_state, $config) { else { $options['token types'] = array($contexts[0]); } - // Allow hook_metatag_token_types_alter() to modify the defined tokens. + // Trigger hook_metatag_token_types_alter(). + // Allow the defined tokens to be modified. drupal_alter('metatag_token_types', $options); } @@ -308,10 +292,6 @@ 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', @@ -333,7 +313,7 @@ function metatag_config_edit_form_submit($form, &$form_state) { $config = (object) $form_state['values']; // @todo Consider renaming the config field from 'config' to 'metatags' $config->config = $config->metatags[LANGUAGE_NONE]; - unset($config->metatags[LANGUAGE_NONE]); + unset($config->metatags); metatag_config_save($config); $label = metatag_config_instance_label($config->instance); @@ -362,7 +342,7 @@ function metatag_config_disable($config) { ctools_export_crud_disable('metatag_config', $config); $label = metatag_config_instance_label($config->instance); - drupal_set_message(t('The meta tag defaults for @label have been disabed.', array('@label' => $label))); + drupal_set_message(t('The meta tag defaults for @label have been disabled.', array('@label' => $label))); drupal_goto(); } @@ -384,7 +364,7 @@ function metatag_config_delete_form($form, &$form_state, $config) { function metatag_config_delete_form_submit($form, &$form_state) { $config = metatag_config_load($form_state['values']['instance']); - metatag_config_delete($config->instance); + metatag_config_delete($config); $label = metatag_config_instance_label($config->instance); $delete = metatag_config_access('delete', $config); @@ -403,16 +383,16 @@ function metatag_config_export_form($config) { * Form constructor to revert nodes to their default metatags. * * @see metatag_bulk_revert_form_submit() + * * @ingroup forms */ function metatag_bulk_revert_form() { - // Get the list of entity:bundle options + // Get the list of entity:bundle options. $options = array(); foreach (entity_get_info() as $entity_type => $entity_info) { foreach (array_keys($entity_info['bundles']) as $bundle) { if (metatag_entity_supports_metatags($entity_type, $bundle)) { - $options[$entity_type . ':' . $bundle] = - $entity_info['label'] . ': ' . $entity_info['bundles'][$bundle]['label']; + $options[$entity_type . ':' . $bundle] = $entity_info['label'] . ': ' . $entity_info['bundles'][$bundle]['label']; } } } @@ -426,6 +406,41 @@ function metatag_bulk_revert_form() { '#description' => t('All meta tags will be removed for all content of the selected entities.'), ); + $metatags = metatag_get_info(); + $options = array(); + foreach ($metatags['tags'] as $tag_name => $tag) { + $options[$tag_name] = t('@group_label: @tag_label', array( + '@group_label' => $metatags['groups'][$tag['group']]['label'], + '@tag_label' => $tag['label'], + )); + } + + if (count($options) > 0) { + $form['tags'] = array( + '#type' => 'checkboxes', + '#required' => FALSE, + '#title' => t('Select the tags to revert'), + '#description' => t('If you select any tags, only those tags will be reverted.'), + '#options' => $options, + ); + } + + $languages = language_list(); + $options = array( + LANGUAGE_NONE => t('Language neutral'), + ); + foreach ($languages as $language) { + $options[$language->language] = $language->name; + } + + $form['languages'] = array( + '#type' => 'checkboxes', + '#required' => FALSE, + '#title' => t('Select the languages to revert'), + '#description' => t('If you select any languages, only tags for those languages will be reverted.'), + '#options' => $options, + ); + $form['submit'] = array( '#type' => 'submit', '#value' => t('Revert'), @@ -448,10 +463,13 @@ function metatag_bulk_revert_form_submit($form, &$form_state) { 'file' => drupal_get_path('module', 'metatag') . '/metatag.admin.inc', ); + $tags = isset($form_state['values']['tags']) ? array_filter($form_state['values']['tags']) : array(); + $languages = isset($form_state['values']['languages']) ? array_filter($form_state['values']['languages']) : array(); + // Set a batch operation per entity:bundle. foreach (array_filter($form_state['values']['update']) as $option) { list($entity_type, $bundle) = explode(':', $option); - $batch['operations'][] = array('metatag_bulk_revert_batch_operation', array($entity_type, $bundle)); + $batch['operations'][] = array('metatag_bulk_revert_batch_operation', array($entity_type, $bundle, $tags, $languages)); } batch_set($batch); @@ -460,7 +478,7 @@ function metatag_bulk_revert_form_submit($form, &$form_state) { /** * Batch callback: delete custom metatags for selected bundles. */ -function metatag_bulk_revert_batch_operation($entity_type, $bundle, &$context) { +function metatag_bulk_revert_batch_operation($entity_type, $bundle, $tags, $languages, &$context) { if (!isset($context['sandbox']['current'])) { $context['sandbox']['count'] = 0; $context['sandbox']['current'] = 0; @@ -475,7 +493,7 @@ function metatag_bulk_revert_batch_operation($entity_type, $bundle, &$context) { if ($entity_type != 'user') { /** * Entities which do not define a bundle such as User fail returning no results. - * @see http://drupal.org/node/1054168#comment-5266208 + * @see https://www.drupal.org/node/1054168#comment-5266208 */ $query->entityCondition('bundle', $bundle); } @@ -498,14 +516,53 @@ function metatag_bulk_revert_batch_operation($entity_type, $bundle, &$context) { 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', $entity_id) - ->execute(); - metatag_metatags_cache_clear($entity_type, $entity_id); - $context['results'][] = t('Reverted metatags for @bundle with id @id.', array( - '@bundle' => $entity_type . ': ' . $bundle, - '@id' => $entity_id, - )); + $reset = FALSE; + if (empty($tags)) { + // All tags should be reset, so we just delete any records from the db. + $query = db_delete('metatag') + ->condition('entity_type', $entity_type) + ->condition('entity_id', $entity_id); + if (!empty($languages)) { + $query->condition('language', $languages, 'IN'); + } + $query->execute(); + metatag_metatags_cache_clear($entity_type, $entity_id); + $reset = TRUE; + } + else { + // Iterate over tags and unset those, that we want to reset. + $needs_reset = FALSE; + foreach ($metatags as $metatags_language => $metatags_tags) { + if (empty($languages) || in_array($metatags_language, $languages)) { + foreach ($metatags_tags as $metatags_tag => $metatags_value) { + if (in_array($metatags_tag, $tags)) { + unset($metatags[$metatags_language][$metatags_tag]); + $needs_reset = TRUE; + } + } + } + } + // Save modified metatags. + if ($needs_reset) { + // We don't have a revision id, so we'll get the active one. + // Unfortunately, the only way of getting the active revision ID is to + // first load the entity, and then extract the ID. This is a bit + // performance intensive, but it seems to be the only way of doing it. + $entities = entity_load($entity_type, array($entity_id)); + if (!empty($entities[$entity_id])) { + // We only care about the revision_id. + list(, $revision_id,) = entity_extract_ids($entity_type, $entities[$entity_id]); + } + metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $bundle); + $reset = TRUE; + } + } + if ($reset) { + $context['results'][] = t('Reverted metatags for @bundle with id @id.', array( + '@bundle' => $entity_type . ': ' . $bundle, + '@id' => $entity_id, + )); + } } } @@ -552,11 +609,108 @@ function metatag_admin_settings_form() { ), ); + $form['entities'] = array( + '#type' => 'fieldset', + '#title' => t('Master controls for all entities'), + '#description' => t('By enabling and disabling items here, it is possible to control which entities (e.g. nodes, taxonomy terms) and bundles (e.g. content types, vocabularies) will have the meta tag form available on their respective edit pages. If an entity type is disabled it also disables it for all of that entity type\'s bundles.
Technical note: Entity types must not be configuration entities and must have view modes in order to be compatible.'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + + foreach (entity_get_info() as $entity_type => $entity_info) { + // Only show entities that are capable of using meta tags. + if (metatag_entity_type_is_suitable($entity_type, $entity_info)) { + $entity_enabled = metatag_entity_supports_metatags($entity_type); + $form['entities']['metatag_enable_' . $entity_type] = array( + '#type' => 'checkbox', + '#title' => t($entity_info['label']), + '#default_value' => $entity_enabled, + // '#description' => t('Enable meta tags for all pages of this entity type.'), + ); + + // Some entities, e.g. User, (core) File, have a single bundle with the + // same name as the entity, so only show the bundles list if there is + // more than one of them and the bundle's name isn't the same as the + // entity type's. + if (!empty($entity_info['bundles'])) { + foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { + if (count($entity_info['bundles']) > 1 || $entity_type != $bundle_name) { + // If the entity type was disabled, automatically enable the bundle. + // This will have the effect that if the entity type is enabled in + // the form then all of the bundles will then also be enabled. This + // is safe to do because in the rest of the module the bundle will + // be ignored if the entity is disabled. + $form['entities']['metatag_enable_' . $entity_type . '__' . $bundle_name] = array( + '#type' => 'checkbox', + '#title' => t($bundle_info['label']), + '#default_value' => !$entity_enabled || metatag_entity_supports_metatags($entity_type, $bundle_name), + '#attributes' => array( + // Add some theming that'll indent this bundle. + 'class' => array('metatag-bundle-checkbox'), + ), + '#states' => array( + 'visible' => array( + ':input[name="metatag_enable_' . $entity_type . '"]' => array('checked' => TRUE), + ), + ), + ); + } + } + } + } + } + + $form['additional'] = array( + '#type' => 'fieldset', + '#title' => t('Additional settings'), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + + $form['additional']['metatag_pager_string'] = array( + '#title' => t('Custom pager string'), + '#type' => 'textfield', + '#description' => t('When the current page includes a pager, e.g. the URL contains "?page=42", the [current-page:pager] token may be added to a meta tag to differentiate between two pages that would otherwise have the same meta tags. The value "PAGER" (must be in uppercase) will be replaced by the actual page count. Note: the pager will only output if the page number is 2 or above and the string "page=NUMBER" is in the URL.
For best use, it may be worthwhile to add the [current-page:pager] to the page title to the left of the site name, to the start of description tags, etc.'), + '#default_value' => variable_get('metatag_pager_string', 'Page PAGER | '), + ); + + $form['i18n'] = array( + '#type' => 'fieldset', + '#title' => t('Internationalization options'), + '#description' => t('Additional options are available when using the Internationalization module.', array('@url' => 'https://www.drupal.org/project/i18n')), + '#collapsible' => TRUE, + '#collapsed' => FALSE, + ); + + $form['i18n']['metatag_i18n_disabled'] = array( + '#title' => t('Disable i18n integration'), + '#type' => 'checkbox', + '#description' => t('If the i18n_string module is enabled but the site does not need to translate Metatag strings, the integration may be disabled to avoid a large volume of records being added to the translation system.'), + '#default_value' => variable_get('metatag_i18n_disabled', FALSE), + '#disabled' => !module_exists('i18n_string'), + ); + + $form['i18n']['metatag_i18n_translate_output'] = array( + '#title' => t('Translate output'), + '#type' => 'checkbox', + '#description' => t('Optionally translate the final page output.'), + '#default_value' => variable_get('metatag_i18n_translate_output', FALSE), + '#disabled' => !module_exists('i18n_string'), + ); + + $form['i18n']['metatag_i18n_enable_watchdog'] = array( + '#title' => t('Enable logging of translations to Watchdog'), + '#type' => 'checkbox', + '#description' => t('Optionally log to Watchdog any changes that happen.'), + '#default_value' => variable_get('metatag_i18n_enable_watchdog', FALSE), + '#disabled' => !module_exists('i18n_string'), + ); + $form['advanced'] = array( '#type' => 'fieldset', '#title' => t('Advanced settings'), '#collapsible' => TRUE, - '#collapsed' => FALSE, + '#collapsed' => TRUE, ); $form['advanced']['metatag_load_all_pages'] = array( @@ -587,50 +741,65 @@ function metatag_admin_settings_form() { '#default_value' => variable_get('metatag_entity_no_lang_default', FALSE), ); - $form['entities'] = array( + $form['advanced']['metatag_load_defaults'] = array( + '#type' => 'checkbox', + '#title' => t("Load the module's default configurations"), + '#description' => t("Control whether the module's default configuration is used. This will not affect configurations exported via Features."), + '#default_value' => variable_get('metatag_load_defaults', TRUE), + ); + + $form['advanced']['metatag_cache_output'] = array( + '#type' => 'checkbox', + '#title' => t('Cache meta tag output'), + '#description' => t('Enabling this will cause all meta tag output to be cached for each page, which may aid with site performance in some circumstances. Should not be used if there are paths which include user-specific meta tags for the current user, they may lead to information about the user being accidentally leaked; this problem does not affect the "user/[uid]" pages. It may also cause the {cache_metatag} cache table to grow to be extremely large in certain circumstances.'), + '#default_value' => variable_get('metatag_cache_output', FALSE), + ); + + $form['advanced']['metatag_leave_core_tags'] = array( + '#type' => 'checkbox', + '#title' => t("Leave core's meta tags as-is"), + '#description' => t("Drupal core outputs a number of meta tags itself: canonical, shortlink, and generator. Metatag can be used to replace these with custom values. Should Metatag not have values for these meta tags, core's tags will normally be removed. Enabling this option will leave those meta tags on the page, even if Metatag is not replacing them."), + '#default_value' => variable_get('metatag_leave_core_tags', FALSE), + ); + + $form['advanced']['metatag_page_region'] = array( + '#type' => 'select', + '#title' => t("Page region to use"), + '#description' => t("By default Metatag uses the 'Content' region to trigger output of the meta tags. Some themes do not have this region, so it can be necessary to pick another."), + '#options' => system_region_list(variable_get('theme_default', 'bartik')), + '#default_value' => variable_get('metatag_page_region', 'content'), + ); + + $form['advanced']['metatag_token_sanitize'] = array( + '#type' => 'checkbox', + '#title' => t('Sanitize content during token replacement'), + '#description' => t('If checked, will ensure that metatag value output is encoded and text filters are processed.'), + '#default_value' => variable_get('metatag_token_sanitize', FALSE), + ); + + $form['lengths'] = 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.
Note: the entities first have to have meta tags enabled via hook_entity_info; see the API documentation for full details.'), + '#title' => t('Maximum meta tag lengths'), '#collapsible' => TRUE, '#collapsed' => TRUE, + '#description' => t('Many meta tags may be shortened to a certain length. To reset to the default, leave the field blank. To keep the entire meta tag, regardless of length, set the value to zero (0). Note: the meta tag will be shortened after the tokens have been replaced, not before.'), ); - - 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'), - ), - ); - } - } + $info = metatag_get_info(); + $groups = $info['groups']; + $tags = $info['tags']; + foreach ($tags as $tag => $info) { + if (isset($info['maxlength'])) { + $default = $info['maxlength']; + $var_name = 'metatag_maxlength_' . $tag; + $title = $info['label']; + if (!empty($info['group']) && isset($groups[$info['group']])) { + $title = $groups[$info['group']]['label'] . ': ' . $title; } + $form['lengths'][$var_name] = array( + '#type' => 'textfield', + '#title' => $title, + '#default_value' => intval(variable_get($var_name, $default)), + ); } } @@ -643,8 +812,21 @@ function metatag_admin_settings_form() { /** * Form API submission callback for metatag_admin_settings_form(). */ -function metatag_admin_settings_form_submit() { - cache_clear_all('entity_info:', 'cache', TRUE); +function metatag_admin_settings_form_submit($form, &$form_state) { + // Only keep maxlength values that are numeric. Any empty, non-zero values + // will be removed. + foreach ($form_state['values'] as $name => $value) { + if (strpos($name, 'metatag_maxlength_') !== FALSE) { + if ((empty($value) && $value !== 0 && $value !== '0') || !is_numeric($value)) { + unset($form_state['values'][$name]); + variable_del($name); + } + else { + $form_state['values'][$name] = intval($value); + } + } + } + cache_clear_all('*', 'cache_metatag', TRUE); - drupal_set_message(t('The Metatag cache has been cleared, so all meta tags can be reloaded.')); + drupal_set_message(t('The Metatag cache has been cleared so all meta tags can be reloaded.')); } diff --git a/sites/all/modules/contrib/metatag/metatag.admin.js b/sites/all/modules/contrib/metatag/metatag.admin.js index 64e6778f..b157e6ed 100644 --- a/sites/all/modules/contrib/metatag/metatag.admin.js +++ b/sites/all/modules/contrib/metatag/metatag.admin.js @@ -6,43 +6,43 @@ (function ($) { 'use strict'; -Drupal.behaviors.metatagUIConfigListing = { - attach: function (context) { - // Hidden elements to be visible if JavaScript is enabled. - $('.js-show').show(); + Drupal.behaviors.metatagUIConfigListing = { + attach: function (context) { + // Hidden elements to be visible if JavaScript is enabled. + $('.js-show').show(); - // Make the leaf arrow clickable. - $('.metatag-config-label').hover(function(){ - $(this).css({'cursor': 'pointer'}); - }) - .click(function(){ - $(this).find('a.toggle-details', context).trigger('click'); - }); + // Make the leaf arrow clickable. + $('.metatag-config-label').hover(function(){ + $(this).css({'cursor': 'pointer'}); + }) + .click(function(){ + $(this).find('a.toggle-details', context).trigger('click'); + }); - // Show or hide the summary - $('table.metatag-config-overview a.toggle-details', context).click(function(event) { - $(this).parent('div').siblings('div.metatag-config-details').each(function() { - if ($(this).hasClass('js-hide')) { - $(this).slideDown('slow').removeClass('js-hide'); + // Show or hide the summary. + $('table.metatag-config-overview a.toggle-details', context).click(function(event) { + $(this).parent('div').siblings('div.metatag-config-details').each(function() { + if ($(this).hasClass('js-hide')) { + $(this).slideDown('slow').removeClass('js-hide'); + } + else { + $(this).slideUp('slow').addClass('js-hide'); + } + }); + + // Change the expanded or collapsed state of the instance label. + if ($(this).parent('div').hasClass('collapsed')) { + $(this).parent('div').removeClass('collapsed').addClass('expanded'); } else { - $(this).slideUp('slow').addClass('js-hide'); + $(this).parent('div').removeClass('expanded').addClass('collapsed'); } - }); - // Change the expanded or collapsed state of the instance label. - if ($(this).parent('div').hasClass('collapsed')) { - $(this).parent('div').removeClass('collapsed').addClass('expanded'); - } - else { - $(this).parent('div').removeClass('expanded').addClass('collapsed'); - } - - // This event may be triggered by a parent element click - so we don't - // want the click to bubble up otherwise we get recursive click events. - event.stopPropagation(); - }); - } -}; + // This event may be triggered by a parent element click - so we don't + // want the click to bubble up otherwise we get recursive click events. + event.stopPropagation(); + }); + } + }; })(jQuery); diff --git a/sites/all/modules/contrib/metatag/metatag.api.php b/sites/all/modules/contrib/metatag/metatag.api.php index bdcb4dd5..9d4bc4d2 100644 --- a/sites/all/modules/contrib/metatag/metatag.api.php +++ b/sites/all/modules/contrib/metatag/metatag.api.php @@ -1,70 +1,10 @@ TRUE to the - * entity definition in hook_entity_info(), e.g.: - * - * /** - * * Implements hook_entity_info(). - * * - * * Taken from the Examples module. - * * / - * function entity_example_entity_info() { - * $info['entity_example_basic'] = array( - * 'label' => t('Example Basic Entity'), - * 'controller class' => 'EntityExampleBasicController', - * 'base table' => 'entity_example_basic', - * 'uri callback' => 'entity_example_basic_uri', - * 'fieldable' => TRUE, - * 'metatags' => TRUE, - * 'entity keys' => array( - * 'id' => 'basic_id' , // The 'id' (basic_id here) is the unique id. - * 'bundle' => 'bundle_type' // Bundle will be determined by the 'bundle_type' field - * ), - * 'bundle keys' => array( - * 'bundle' => 'bundle_type', - * ), - * 'static cache' => TRUE, - * 'bundles' => array( - * 'first_example_bundle' => array( - * 'label' => 'First example bundle', - * 'admin' => array( - * 'path' => 'admin/structure/entity_example_basic/manage', - * 'access arguments' => array('administer entity_example_basic entities'), - * ), - * ), - * ), - * 'view modes' => array( - * 'tweaky' => array( - * 'label' => t('Tweaky'), - * 'custom settings' => FALSE, - * ), - * ) - * ); - * - * return $info; - * } - * - * The definition of each bundle may be handled separately, thus support may be - * disabled for the entity as a whole but enabled for individual bundles. This - * is handled via the 'metatags' value on the bundle definition, e.g.: - * - * 'bundles' => array( - * 'first_example_bundle' => array( - * 'label' => 'First example bundle', - * 'metatags' => TRUE, - * 'admin' => array( - * 'path' => 'admin/structure/entity_example_basic/manage', - * 'access arguments' => array('administer entity_example_basic entities'), - * ), - * ), - * ), - */ - /** * Provides a default configuration for Metatag intances. * @@ -80,7 +20,7 @@ * The $config->disabled boolean attribute indicates whether the Metatag * instance should be enabled (FALSE) or disabled (TRUE) by default. * - * @return + * @return array * An associative array containing the structures of Metatag instances, as * generated from the Export tab, keyed by the Metatag config name. * @@ -96,7 +36,7 @@ function hook_metatag_config_default() { $config->disabled = FALSE; $config->config = array( 'title' => array('value' => '[current-page:title] | [site:name]'), - 'generator' => array('value' => 'Drupal 7 (http://drupal.org)'), + 'generator' => array('value' => 'Drupal 7 (https://www.drupal.org)'), 'canonical' => array('value' => '[current-page:url:absolute]'), 'shortlink' => array('value' => '[current-page:url:unaliased]'), ); @@ -114,6 +54,12 @@ function hook_metatag_config_default() { return $configs; } +/** + * Allow the exported configurations to be changed prior to being cached. + */ +function hook_metatag_config_default_alter(&$config) { +} + /** * Internal hook for adding further configuration values in bundled submodules. * @@ -128,60 +74,105 @@ function hook_metatag_config_default() { */ function hook_metatag_bundled_config_alter(&$config) { } - + /** - * + * Allow modules to act upon the record insertion. */ -function hook_metatag_config_default_alter(&$config) { +function hook_metatag_config_instance_info() { + return array(); } /** - * + * Alter record insertion provided by modules with the previous hook. + * + * @see hook_metatag_config_instance_info() */ -function hook_metatag_config_delete($entity_type, $entity_ids, $revision_ids, $langcode) { +function hook_metatag_config_instance_info_alter(&$info) { } /** - * + * Allow the Metatag config instance name to be changed. + * + * By default, Metatag module define config instance per entity bundle, making + * it impossible to store set of meta tags based on other criteria. Combining + * this hook with hook_metatag_config_instance_info_alter() it is possible to + * alter the logic of how instances are named based on any custom criteria. + * + * @param string $instance + * The name of the instance generated by default. + * @param object $entity + * The entity object to generate the Metatag instance name for. + * @param string $entity_type + * The entity type of the entity. + * @param string $bundle + * The bundle of the entity. */ -function hook_metatag_config_insert($config) { +function hook_metatag_get_entity_metatags_instance_alter(&$instance, $entity, $entity_type, $bundle) { + if ($entity_type == 'user') { + // Split config instances based on user roles. + foreach (array_reverse(user_roles(), TRUE) as $rid => $role) { + if ($rid == DRUPAL_AUTHENTICATED_RID) { + continue; + } + + if (isset($entity->roles[$rid])) { + $instance = 'user:' . $role; + break; + } + } + } } /** - * + * Never triggered? + * + * @todo Confirm whether this still exists. */ -function hook_metatag_config_instance_info() { - return array(); +function hook_metatag_config_load() { } /** - * + * Never triggered? + * + * @todo Confirm whether this still exists. */ -function hook_metatag_config_instance_info_alter(&$info) { +function hook_metatag_config_load_presave() { } /** - * + * Allow a Metatag configuration to be modified prior to being saved. + * + * @param object $config + * The configuration object that is about to be saved. */ -function hook_metatag_config_load() { +function hook_metatag_config_presave($config) { } /** - * + * Triggered when a Metatag configuration is created. + * + * @param object $config + * The configuration object that was created. */ -function hook_metatag_config_load_presave() { +function hook_metatag_config_insert($config) { } /** - * + * Triggered when a Metatag configuration is updated. + * + * @param object $config + * The configuration object that was modified. */ -function hook_metatag_config_presave($config) { +function hook_metatag_config_update($config) { } /** - * + * Triggered when a Metatag configuration is removed. + * + * @param object $config + * The name of the configuration object that was removed. */ -function hook_metatag_config_update($config) { +function hook_metatag_config_delete($config) { } /** @@ -215,6 +206,23 @@ function hook_metatag_config_update($config) { * 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. + * 'multiple' - If set to TRUE the output will be comma-separated and output + * as multiple tags. + * 'image' - If set to TRUE some additional effort will be added to attempt + * extracting image URLs from the value. Currently limited to matching + * the default output of core image theming, i.e. the following string: + * src="[URL]" width= + * 'url' - If set to TRUE, relative paths will be converted to absolute. + * 'is_language' - If set to TRUE, will not allow the Drupal default + * language value "und" to be output. + * 'maxlength' - If set to a numeric value, meta tag values will be trimmed + * to this limit, which may be overridden via the settings page. Note: any + * meta tags with this value assigned can have its maxlength controlled, + * so setting the attribute to an empty string will allow site builders to + * adjust the meta tag lengths as needed. + * 'select_or_other' - If set to TRUE, form[#type] is set to 'select' and + * the "select_or_other" module is available, that module will be used to + * provide a text field to manually insert another option. * '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 @@ -252,24 +260,20 @@ function hook_metatag_config_update($config) { * Note: 'label', 'description', and any text strings passed in 'form', should * be translated. * - * @see metatag_metatag_info(). + * @see metatag_metatag_info() */ function hook_metatag_info() { return array(); } /** - * + * Alter record insertion provided by modules with the previous hook. + * + * @see hook_metatag_info() */ function hook_metatag_info_alter(&$info) { } -/** - * - */ -function hook_metatag_load_entity_from_path_alter(&$path, $result) { -} - /** * Alter metatags before being cached. * @@ -291,13 +295,13 @@ function hook_metatag_metatags_view_alter(&$output, $instance, $options) { } /** - * + * Allow other modules to customize the data to generate the cache ID. */ function hook_metatag_page_cache_cid_parts_alter(&$cid_parts) { } /** - * + * Allow other modules to alter the meta tags prior to saving. */ function hook_metatag_presave(&$metatags, $entity_type, $entity_id, $revision_id, $langcode) { } @@ -320,16 +324,16 @@ function hook_metatag_presave(&$metatags, $entity_type, $entity_id, $revision_id * @see metatag_field_attach_form() */ function hook_metatag_token_types_alter(&$options) { - // Watchout: $options['token types'] might be empty + // Watchout: $options['token types'] might be empty. if (!isset($options['token types'])) { $options['token types'] = array(); } - if ($options['context'] == 'config1'){ - $options['token types'] += array('token_type1','token_type2'); + if ($options['context'] == 'config1') { + $options['token types'] += array('token_type1', 'token_type2'); } - elseif ($options['context'] == 'config2'){ - $options['token types'] += array('token_type3','token_type4'); + elseif ($options['context'] == 'config2') { + $options['token types'] += array('token_type3', 'token_type4'); } } @@ -343,11 +347,11 @@ function hook_metatag_token_types_alter(&$options) { * * See facetapi and facetapi_bonus modules for an example of implementation. * - * @param $pattern + * @param string $pattern * A string potentially containing replaceable tokens. The pattern could also * be altered by reference, allowing modules to implement further logic, such * as tokens lists or masks/filters. - * @param $types + * @param array $types * Corresponds to the 'token data' property of the $options object. * (optional) An array of keyed objects. For simple replacement scenarios * 'node', 'user', and others are common keys, with an accompanying node or @@ -370,3 +374,87 @@ function hook_metatag_pattern_alter(&$pattern, &$types, $tag_name) { $pattern = str_replace('[token_type3]', '', $pattern); } } + +/** + * Allow modules to override whether entity types are enabled for use. + * + * By default the system only support entities that are not configuration + * entities, have multiple view modes (excluding those created by the ical, + * diff and token modules), are fieldable, and are not one of the following: + * - field_collection_item (from the Field Collection module) + * - paragraphs_item (from the Paragraphs module) + * + * @param bool $suitable + * Whether or not the entity type is enabled for use with Metatag. + * @param string $entity_type + * The machine name of the entity type. + * @param array $entity_info + * The full specifications for this entity type, as returned by + * entity_get_info(). + */ +function hook_metatag_entity_type_is_supported_alter(&$suitable, $entity_type, $entity_info) { + // Enable Metatag support for a custom entity that might otherwise be + // ignored, e.g. it doesn't allow fields. + if ($entity_type == 'my_entity') { + $suitable = TRUE; + } +} + +/** + * Identify the entity type provided by a specific view. + * + * When a view is used to display a page it can be difficult to identify what + * entity type is being managed. Use this hook to inform Metatag what type of + * entity is being displayed. + * + * @param object $view + * The view object being displayed. + * + * @return string|NULL + * Should return a string indicating an entity type that will be paired with + * the views' first argument ($view->args[0]) to load that entity. + */ +function hook_metatag_views_post_render_get_entity($view) { + $display = $view->display[$view->current_display]; + if ($display->display_options['path'] == 'coolpage/%') { + return 'my_entity'; + } +} + +/** + * Allow the context string being passed to i18n_string to be changed before it + * is used. + * + * If the string is set to an empty value it will cause this meta tag to not + * be translated. + * + * @param string $context + * The context string being passed into i18n_string. Will usually be in the + * format "[category]:[path-identifier]", e.g. "[node:123]", "[page:contact]", + * etc. + * @param string $tag_name + * The name of the meta tag being translated. + */ +function hook_metatag_i18n_context_alter(&$context, $tag_name) { + // Don't bother translating the canonical URL. + if ($tag_name == 'canonical') { + $context = ''; + } +} + +/** + * Allow modules to overide the expiration of metatag caches. + * + * By default Metatag caches everything as CACHE_PERMANENT, this alter allows to + * change that. + * + * @param $expire + * The expire value to change. + * @param $cid + * The cid about to be cached. + * @param $data + * The data to be cached. + */ +function hook_metatag_cache_set_expire_alter(&$expire, $cid, $data) { + $expire = CACHE_TEMPORARY; +} diff --git a/sites/all/modules/contrib/metatag/metatag.drush.inc b/sites/all/modules/contrib/metatag/metatag.drush.inc index 950e5607..710e96ac 100644 --- a/sites/all/modules/contrib/metatag/metatag.drush.inc +++ b/sites/all/modules/contrib/metatag/metatag.drush.inc @@ -1,4 +1,5 @@ instance = $config; $object->config = $feature_conf[$config]['config']; metatag_config_save($object); + + if (!empty($feature_conf[$config]['disabled'])) { + ctools_export_crud_disable('metatag_config', $config); + } + else { + ctools_export_crud_enable('metatag_config', $config); + } } } } diff --git a/sites/all/modules/contrib/metatag/metatag.feeds.inc b/sites/all/modules/contrib/metatag/metatag.feeds.inc index 00a91c59..3d29f247 100644 --- a/sites/all/modules/contrib/metatag/metatag.feeds.inc +++ b/sites/all/modules/contrib/metatag/metatag.feeds.inc @@ -1,4 +1,5 @@ $tag) { $targets['meta_' . $name] = array( - 'name' => 'Meta tag: ' . check_plain($tag['label']), + 'name' => t('Meta tag: !label', array('!label' => $tag['label'])), 'callback' => 'metatag_feeds_set_target', 'description' => $tag['description'], ); @@ -23,19 +24,27 @@ function metatag_feeds_processor_targets_alter(&$targets, $entity_type, $bundle) /** * Callback function to set value of a metatag tag. */ -function metatag_feeds_set_target($source, $entity, $target, $value) { +function metatag_feeds_set_target($source, $entity, $target, $values) { // Don't do anything if we weren't given any data. - if (empty($value)) { + if (empty($values)) { return; } + // The Feed API was changed so that the $values are passed as an array rather + // than a single value. For backwards compatibility, support both. + if (!is_array($values)) { + $values = array($values); + } + // Strip the prefix that was added above. $name = str_replace('meta_', '', $target); + // Identify the type of entity being imported. + $entity_type = $entity->feeds_item->entity_type; + // 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; // Load the existing entity. @@ -43,11 +52,12 @@ function metatag_feeds_set_target($source, $entity, $target, $value) { if (!empty($stored_entities)) { $stored_entity = reset($stored_entities); if (!empty($stored_entity)) { + // Only load meta tags for the current revision. + list(, $revision_id) = entity_extract_ids($entity_type, $stored_entity); + // This function returns all values for all revisions. - $metatags = metatag_metatags_load($entity_type, $entity_id); + $metatags = metatag_metatags_load($entity_type, $entity_id, $revision_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]; @@ -59,5 +69,5 @@ function metatag_feeds_set_target($source, $entity, $target, $value) { // Assign the value. $langcode = metatag_entity_get_language($entity_type, $entity); - $entity->metatags[$langcode][$name]['value'] = $value; + $entity->metatags[$langcode][$name]['value'] = $values[0]; } diff --git a/sites/all/modules/contrib/metatag/metatag.i18n.inc b/sites/all/modules/contrib/metatag/metatag.i18n.inc index 194d14c1..7f884c37 100644 --- a/sites/all/modules/contrib/metatag/metatag.i18n.inc +++ b/sites/all/modules/contrib/metatag/metatag.i18n.inc @@ -1,4 +1,5 @@ t('Metatag'), - 'description' => t('Configurable metatags.'), + 'description' => t('Configurable meta tags.'), + + // This group does not have strings with text formats. 'format' => FALSE, - 'list' => FALSE, + + // This group can list all strings. + // @todo What does this actually do? + 'list' => TRUE, ); return $groups; } + +/** + * Implements hook_i18n_object_info(). + */ +function metatag_i18n_object_info() { + // Compile all of the tags to add to the translation stack. + $meta_tag_info = metatag_get_info(); + $groups = $meta_tag_info['groups']; + $config_properties = $output_properties = array(); + foreach ($meta_tag_info['tags'] as $tag_name => $tag_info) { + // Ignore certain field types that aren't translatable, mostly fields that + // list predetermined options in various forms. + if (!empty($tag_info['class']) && $tag_info['class'] == 'DrupalListMetaTag') { + continue; + } + elseif (!empty($tag_info['form']['#type']) && $tag_info['form']['#type'] == 'select') { + continue; + } + elseif (!empty($tag_info['form']['#options'])) { + continue; + } + + // Build a suitable structure for this meta tag. + if (!empty($tag_info['group']) && !empty($groups[$tag_info['group']]['label'])) { + $group_label = $groups[$tag_info['group']]['label'] . ': '; + } + elseif (!empty($tag_info['group'])) { + $group_label = $tag_info['group'] . ': '; + } + else { + $group_label = ''; + } + + // Configuration items. + $config_properties[$tag_name] = array( + 'title' => $group_label . $tag_info['label'], + 'field' => "config.{$tag_name}.value", + ); + + // Output items. + $output_properties[$tag_name] = array( + 'title' => $group_label . ': ' . $tag_info['label'], + 'field' => "data.{$tag_name}.value", + ); + } + + // The main Metatag configuration items. + $info['metatag_config'] = array( + 'title' => t('Metatag configuration'), + // Callback to load all config objects. + 'list callback' => 'metatag_i18n_list_metatag_config', + // The object load callback. + 'load callback' => 'metatag_config_load', + // @todo Custom i18n object overrides. + // 'class' => 'metatag_i18n_metatag', + // @todo Is this needed? What does it do? + // 'translation set' => TRUE, + // The object key field. + 'key' => 'instance', + // Placeholders for automatic paths. This connects the 'key' to strings in + // the paths listed below. + 'placeholders' => array( + '%instance' => 'instance', + ), + // To produce edit links automatically. + 'edit path' => 'admin/config/search/metatags/config/%instance', + // Auto-generate a 'translate' tab. + 'translate tab' => 'admin/config/search/metatags/config/%instance/translate', + + // Properties for string translation. + 'string translation' => array( + // The textgroup, type and (below) name will be concatenated into a single + // string as the {locales_source} context. + 'textgroup' => 'metatag', + 'type' => 'metatag_config', + // Table where the object is stored, to automate string lists. + 'table' => 'metatag_config', + // Translatable properties of these objects. + 'properties' => $config_properties, + // The path to translate individual strings. + 'translate path' => 'admin/config/search/metatags/config/%instance/translate/%i18n_language', + ), + ); + + // The final meta tags being output on the page. + if (variable_get('metatag_i18n_translate_output', FALSE)) { + $info['output'] = array( + 'title' => t('Metatag final tag output'), + + // Properties for string translation. + 'string translation' => array( + // The textgroup, type and (below) name will be concatenated into a + // single string as the {locales_source} context. + 'textgroup' => 'metatag', + 'type' => 'output', + // Translatable properties of these objects. + 'properties' => $output_properties, + ), + ); + } + + return $info; +} + +/** + * List callback for {metatag_config} strings. + */ +function metatag_i18n_list_metatag_config() { + ctools_include('export'); + $configs = ctools_export_crud_load_all('metatag_config'); + + if (!empty($configs)) { + // Unserialize the config array. + foreach ($configs as &$config) { + if (is_string($config->config)) { + $config->config = unserialize($config->config); + } + } + } + + return $configs; +} diff --git a/sites/all/modules/contrib/metatag/metatag.inc b/sites/all/modules/contrib/metatag/metatag.inc index 0a575178..5bbdcf15 100644 --- a/sites/all/modules/contrib/metatag/metatag.inc +++ b/sites/all/modules/contrib/metatag/metatag.inc @@ -1,36 +1,76 @@ ''); + + /** + * This item's weight; used for sorting the output. + * + * @var float + */ protected $weight = 0; + /** + * Constructor. + */ function __construct(array $info, array $data = NULL) { $this->info = $info; if (isset($data)) { @@ -39,11 +79,12 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { } /** - * Calculate the weight or this meta tag. + * Calculate the weight of this meta tag. * - * @return integer + * @return int + * Weight. */ - public function getWeight() { + function getWeight() { static $counter = 0; // If no weight value is found, stack this meta tag at the end. @@ -55,14 +96,39 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { return $weight + ($counter++ * 0.1); } + /** + * Build the form for this meta tag. + * + * @return array + * A standard FormAPI array. + */ public function getForm(array $options = array()) { return array(); } + /** + * Get the string value of this meta tag. + * + * @return string + * The value of this meta tag. + */ public function getValue(array $options = array()) { - return $this->tidyValue($this->data['value']); + $value = $this->tidyValue($this->data['value']); + + // Translate the final output string prior to output. Use the + // 'output' i18n_string object type, and pass along the meta tag's + // options as the context so it can be handled appropriately. + $value = metatag_translate_metatag($value, $this->info['name'], $options, NULL, TRUE); + + return $this->truncate($this->tidyValue($this->data['value'])); } + /** + * Get the HTML tag for this meta tag. + * + * @return array + * A render array for this meta tag. + */ public function getElement(array $options = array()) { $value = $this->getValue($options); if (strlen($value) === 0) { @@ -124,19 +190,27 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { /** * Remove unwanted formatting from a meta tag. * - * @param $value string + * @param string $value * The meta tag value to be tidied up. * * @return string * The meta tag value after it has been tidied up. */ public function tidyValue($value) { + // Check for Media strings from the WYSIWYG submodule. + if (module_exists('media_wysiwyg') && strpos($value, '[[{') !== FALSE) { + // In https://www.drupal.org/node/2129273 media_wysiwyg_filter() was + // changed to require several additional arguments. + $langcode = language_default('language'); + $value = media_wysiwyg_filter($value, NULL, NULL, $langcode, NULL, NULL); + } + // 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. + // Decode HTML entities. $value = decode_entities($value); // Remove any HTML code that might have been included. @@ -150,6 +224,178 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { return $value; } + + /** + * Make sure a given URL is absolute. + * + * @param string $url + * The URL to convert to an absolute URL. + * + * @return string + * The argument converted to an absolute URL. + */ + function convertUrlToAbsolute($url) { + // Convert paths relative to the hostname, that start with a slash, to + // ones that are relative to the Drupal root path; ignore protocol-relative + // URLs. + if (strpos($url, base_path()) === 0 && strpos($url, '//') !== 0) { + // Logic: + // * Get the length of the base_path(), + // * Get a portion of the image's path starting from the position equal + // to the base_path()'s length; this will result in a path relative + // to the Drupal installation's base directory. + $len = strlen(base_path()); + $url = substr($url, $len); + } + + // Pass everything else through file_create_url(). The alternative is to + // use url() but it would insert '?q=' into the path. + return file_create_url($url); + } + + /** + * Shorten a string to a certain length using text_summary(). + * + * @param string $value + * String to shorten. + * + * @return string + * Shortened string. + */ + function truncate($value) { + $maxlength = $this->maxlength(); + + if (!empty($value) && $maxlength > 0) { + $value = $this->text_summary($value, $maxlength); + } + + return $value; + } + + /** + * Identify the maximum length of which strings will be allowed. + * + * @return int + * Maxlenght. + */ + function maxlength() { + if (isset($this->info['maxlength'])) { + return intval(variable_get('metatag_maxlength_' . $this->info['name'], $this->info['maxlength'])); + } + return 0; + } + + /** + * Copied from text.module with the following changes:. + * + * Change 1: $size is required. + * Change 2: $format is removed. + * Change 3: Don't trim at the end of short sentences + * (https://www.drupal.org/node/1620104). + * Change 4: Word boundaries (https://www.drupal.org/node/1482178). + * Change 5: Trim the final string. + */ + static function text_summary($text, $size) { + // if (!isset($size)) { + // // What used to be called 'teaser' is now called 'summary', but + // // the variable 'teaser_length' is preserved for backwards compatibility. + // $size = variable_get('teaser_length', 600); + // } + // Find where the delimiter is in the body. + $delimiter = strpos($text, ''); + + // If the size is zero, and there is no delimiter, + // the entire body is the summary. + if ($size == 0 && $delimiter === FALSE) { + return $text; + } + + // If a valid delimiter has been specified, use it to chop off the summary. + if ($delimiter !== FALSE) { + return substr($text, 0, $delimiter); + } + + // We check for the presence of the PHP evaluator filter in the current + // format. If the body contains PHP code, we do not split it up to prevent + // parse errors. + // if (isset($format)) { + // $filters = filter_list_format($format); + // if (isset($filters['php_code']) && $filters['php_code']->status && strpos($text, '' => 0); + + // If no complete paragraph then treat line breaks as paragraphs. + // $line_breaks = array('
' => 6, '
' => 4); + // Newline only indicates a line break if line break converter + // filter is present. + // if (isset($filters['filter_autop'])) { + // $line_breaks["\n"] = 1; + // } + // $break_points[] = $line_breaks; + // If the first paragraph is too long, split at the end of a sentence. + // $break_points[] = array('. ' => 1, '! ' => 1, '? ' => 1, '。' => 0, '؟ ' => 1); + // From https://www.drupal.org/node/1482178. + // If the first sentence is too long, split at the first word break. + $word_breaks = array(' ' => 0, "\t" => 0); + $break_points[] = $word_breaks; + + // Iterate over the groups of break points until a break point is found. + foreach ($break_points as $points) { + // Look for each break point, starting at the end of the summary. + foreach ($points as $point => $offset) { + // The summary is already reversed, but the break point isn't. + $rpos = strpos($reversed, strrev($point)); + if ($rpos !== FALSE) { + $min_rpos = min($rpos + $offset, $min_rpos); + } + } + + // If a break point was found in this group, slice and stop searching. + if ($min_rpos !== $max_rpos) { + // Don't slice with length 0. Length must be <0 to slice from RHS. + $summary = ($min_rpos === 0) ? $summary : substr($summary, 0, 0 - $min_rpos); + break; + } + } + + // If the htmlcorrector filter is present, apply it to the generated + // summary. + // if (isset($filters['filter_htmlcorrector'])) { + // $summary = _filter_htmlcorrector($summary); + // } + return trim($summary); + } + } /** @@ -157,6 +403,9 @@ class DrupalDefaultMetaTag implements DrupalMetaTagInterface { */ class DrupalTextMetaTag extends DrupalDefaultMetaTag { + /** + * {@inheritdoc} + */ public function getForm(array $options = array()) { $options += array( 'token types' => array(), @@ -174,10 +423,39 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag { '#maxlength' => 1024, ); + // Optional handling for items that allow multiple values. 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.'); } + // Optionally limit the field to a certain length. + $maxlength = $this->maxlength(); + if (!empty($maxlength)) { + $form['value']['#description'] .= ' ' . t('This will be truncated to a maximum of %max characters.', array('%max' => $maxlength)); + } + + // Optional handling for images. + if (!empty($this->info['image'])) { + $form['value']['#description'] .= ' ' . t('This will be able to extract the URL from an image field.'); + } + + // Optional handling for languages. + if (!empty($this->info['is_language'])) { + $form['value']['#description'] .= ' ' . t('This will not be displayed if it is set to the "Language neutral" (i.e. "und").'); + } + + // Optional support for select_or_other. + if ($form['value']['#type'] == 'select' && !empty($this->info['select_or_other']) && module_exists('select_or_other')) { + $form['value']['#type'] = 'select_or_other'; + $form['value']['#other'] = t('Other (please type a value)'); + $form['value']['#multiple'] = FALSE; + $form['value']['#other_unknown_defaults'] = 'other'; + $form['value']['#other_delimiter'] = FALSE; + $form['value']['#theme'] = 'select_or_other'; + $form['value']['#select_type'] = 'select'; + $form['value']['#element_validate'] = array('select_or_other_element_validate'); + } + // Support for dependencies, using Form API's #states system. // @see metatag.api.php. // @see https://api.drupal.org/drupal_process_states @@ -192,26 +470,87 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag { return $form; } + /** + * {@inheritdoc} + */ public function getValue(array $options = array()) { $options += array( 'instance' => '', 'token data' => array(), + // Remove any remaining token after the string is parsed. 'clear' => TRUE, - 'sanitize' => TRUE, + 'sanitize' => variable_get('metatag_token_sanitize', FALSE), 'raw' => FALSE, ); - $name = "metatag:" . $options["instance"] . ":" . $this->info["name"]; + $value = $this->data['value']; - $value = metatag_translate($name, $this->data['value']); 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'], $this->info['name']); $value = token_replace($value, $options['token data'], $options); } - return $this->tidyValue($value); + + // Special handling for language meta tags. + if (!empty($this->info['is_language'])) { + // If the meta tag value equals LANGUAGE_NONE, i.e. "und", then don't + // output it. + if (is_string($value) && $value == LANGUAGE_NONE) { + $value = ''; + } + } + + // Special handling for images and other URLs. + if (!empty($this->info['image']) || !empty($this->info['url'])) { + // Support multiple items, whether it's needed or not. Also remove the + // empty values and reindex the array. + $values = array_values(array_filter(explode(',', $value))); + + // If this meta tag does *not* allow multiple items, only keep the first + // one. + if (empty($this->info['multiple']) && !empty($values[0])) { + $values = array($values[0]); + } + + foreach ($values as $key => &$image_value) { + // Remove any unwanted whitespace around the value. + $image_value = trim($image_value); + + // If this contains embedded image tags, extract the image URLs. + if (!empty($this->info['image']) && strip_tags($image_value) != $image_value) { + $matches = array(); + preg_match('/src="([^"]*)"/', $image_value, $matches); + if (!empty($matches[1])) { + $image_value = $matches[1]; + } + } + + // Convert the URL to an absolute URL. + $image_value = $this->convertUrlToAbsolute($image_value); + + // Replace spaces the URL encoded entity to avoid validation problems. + $image_value = str_replace(' ', '%20', $image_value); + } + + // Combine the multiple values into a single string. + $value = implode(',', $values); + } + + // Clean up the string a bit. + $value = $this->tidyValue($value); + + // Optionally truncate the value. + $value = $this->truncate($value); + + // Translate the final output string prior to output. Use the + // 'output' i18n_string object type, and pass along the meta tag's + // options as the context so it can be handled appropriately. + $value = metatag_translate_metatag($value, $this->info['name'], $options, NULL, TRUE); + + return $value; } + } /** @@ -219,6 +558,9 @@ class DrupalTextMetaTag extends DrupalDefaultMetaTag { */ class DrupalLinkMetaTag extends DrupalTextMetaTag { + /** + * {@inheritdoc} + */ public function getElement(array $options = array()) { $element = isset($this->info['element']) ? $this->info['element'] : array(); @@ -239,13 +581,16 @@ class DrupalLinkMetaTag extends DrupalTextMetaTag { if (!isset($this->info['header']) || !empty($this->info['header'])) { // Also send the generator in the HTTP header. // @todo This does not support 'rev' or alternate link headers. - $element['#attached']['drupal_add_http_header'][] = array('Link', '<' . $value . '>;' . drupal_http_header_attributes(array('rel' => $element['#name'])), TRUE); + $element['#attached']['drupal_add_http_header'][] = array( + 'Link', '<' . $value . '>;' . drupal_http_header_attributes(array('rel' => $element['#name'])), TRUE, + ); } return array( '#attached' => array('drupal_add_html_head' => array(array($element, $element['#id']))), ); } + } /** @@ -256,13 +601,26 @@ class DrupalLinkMetaTag extends DrupalTextMetaTag { */ class DrupalTitleMetaTag extends DrupalTextMetaTag { + /** + * {@inheritdoc} + */ public function getElement(array $options = array()) { $element = array(); - $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)); + if ($value = $this->getValue($options)) { + $element['#attached']['metatag_set_preprocess_variable'][] = array( + 'html', + 'head_title', + decode_entities($value), + ); + $element['#attached']['metatag_set_preprocess_variable'][] = array( + 'html', + 'head_array', + array('title' => $value), + ); + } return $element; } + } /** @@ -270,6 +628,9 @@ class DrupalTitleMetaTag extends DrupalTextMetaTag { */ class DrupalListMetaTag extends DrupalDefaultMetaTag { + /** + * {@inheritdoc} + */ function __construct(array $info, array $data = NULL) { // Ensure that the $data['value] argument is an array. if (empty($data['value'])) { @@ -280,6 +641,9 @@ class DrupalListMetaTag extends DrupalDefaultMetaTag { parent::__construct($info, $data); } + /** + * {@inheritdoc} + */ public function getForm(array $options = array()) { $form['value'] = isset($this->info['form']) ? $this->info['form'] : array(); @@ -293,12 +657,23 @@ class DrupalListMetaTag extends DrupalDefaultMetaTag { return $form; } + /** + * {@inheritdoc} + */ public function getValue(array $options = array()) { $values = array_keys(array_filter($this->data['value'])); sort($values); $value = implode(', ', $values); - return $this->tidyValue($value); + $value = $this->tidyValue($value); + + // Translate the final output string prior to output. Use the + // 'output' i18n_string object type, and pass along the meta tag's + // options as the context so it can be handled appropriately. + $value = metatag_translate_metatag($value, $this->info['name'], $options, NULL, TRUE); + + return $value; } + } /** @@ -306,10 +681,13 @@ class DrupalListMetaTag extends DrupalDefaultMetaTag { */ class DrupalDateIntervalMetaTag extends DrupalDefaultMetaTag { + /** + * {@inheritdoc} + */ public function getForm(array $options = array()) { $form['value'] = array( '#type' => 'textfield', - '#title' => t('@title interval', array('@title' => $this->info['label'])), + '#title' => t('!title interval', array('!title' => $this->info['label'])), '#default_value' => isset($this->data['value']) ? $this->data['value'] : '', '#element_validate' => array('element_validate_integer_positive'), '#maxlength' => 4, @@ -317,7 +695,7 @@ class DrupalDateIntervalMetaTag extends DrupalDefaultMetaTag { ); $form['period'] = array( '#type' => 'select', - '#title' => t('@title interval type', array('@title' => $this->info['label'])), + '#title' => t('!title interval type', array('!title' => $this->info['label'])), '#default_value' => isset($this->data['period']) ? $this->data['period'] : '', '#options' => array( '' => t('- none -'), @@ -331,6 +709,9 @@ class DrupalDateIntervalMetaTag extends DrupalDefaultMetaTag { return $form; } + /** + * {@inheritdoc} + */ public function getValue(array $options = array()) { $value = ''; if (!empty($this->data['value'])) { @@ -340,6 +721,13 @@ class DrupalDateIntervalMetaTag extends DrupalDefaultMetaTag { $value = format_plural($interval, '@count ' . $period, '@count ' . $period . 's'); } } + + // Translate the final output string prior to output. Use the 'output' + // i18n_string object type, and pass along the meta tag's options as the + // context so it can be handled appropriately. + $value = metatag_translate_metatag($value, $this->info['name'], $options, NULL, TRUE); + return $value; } + } diff --git a/sites/all/modules/contrib/metatag/metatag.info b/sites/all/modules/contrib/metatag/metatag.info index 416cdf87..f3937817 100644 --- a/sites/all/modules/contrib/metatag/metatag.info +++ b/sites/all/modules/contrib/metatag/metatag.info @@ -3,23 +3,109 @@ description = "Adds support and an API to implement meta tags." package = SEO core = 7.x -; This requires Drupal 7.28 or newer as it fixes the [node:summary] token that -; was previously broken. -dependencies[] = system (>=7.28) +; This requires Drupal 7.40 because of the project:module dependency structure. +dependencies[] = drupal:system (>= 7.40) -; CTools and Token are also required. -dependencies[] = ctools -dependencies[] = token +; CTools is required. +dependencies[] = ctools:ctools + +; Requires Token; v7.x-1.6 is highly recommended due to bugs with certain tags +; when using older versions. +dependencies[] = token:token configure = admin/config/search/metatags +; The main classes. files[] = metatag.inc + +; Defines the basic meta tags. files[] = metatag.migrate.inc -files[] = metatag.test -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +; Search API integration. +files[] = metatag.search_api.inc + + +; Tests. +files[] = tests/metatag.helper.test + +; Basic configuration handling. +files[] = tests/metatag.unit.test + +; Basic tag testing. +files[] = tests/metatag.tags_helper.test +files[] = tests/metatag.tags.test + +; Core entities. +files[] = tests/metatag.node.test +files[] = tests/metatag.term.test +files[] = tests/metatag.user.test + +; Handling of core's default meta tags. +files[] = tests/metatag.core_tag_removal.test + +; The custom Bulk Revert functionality. +files[] = tests/metatag.bulk_revert.test + +; String handling. +files[] = tests/metatag.string_handling.test +files[] = tests/metatag.string_handling_with_i18n.test + +; XSS testing. +files[] = tests/metatag.xss.test + +; Output caching. +files[] = tests/metatag.output_caching.test + +; Images need specia attention. +test_dependencies[] = devel:devel +test_dependencies[] = imagecache_token:imagecache_token +files[] = tests/metatag.image.test + +; Internationalization & translation. +test_dependencies[] = entity_translation:entity_translation +test_dependencies[] = i18n:i18n +files[] = tests/metatag.locale.test +files[] = tests/metatag.node.with_i18n.test +files[] = tests/metatag.term.with_i18n.test +files[] = tests/metatag.with_i18n_output.test +files[] = tests/metatag.with_i18n_disabled.test +files[] = tests/metatag.with_i18n_config.test + +; Basic integration with Me. +test_dependencies[] = me:me +files[] = tests/metatag.with_me.test + +; Basic integration with Media. +test_dependencies[] = file_entity:file_entity +test_dependencies[] = media:media (>= 2.0, < 3.0) +files[] = tests/metatag.with_media.test + +; Basic integration with Panels. +test_dependencies[] = panels:panels +files[] = tests/metatag.with_panels.test + +; Basic integration with Profile2. +test_dependencies[] = profile2:profile2 +files[] = tests/metatag.with_profile2.test + +; Basic integration with Search API. +test_dependencies[] = entity:entity +test_dependencies[] = search_api:search_api +files[] = tests/metatag.with_search_api.test + +; Integration with Workbench Moderation. +test_dependencies[] = workbench_moderation:workbench_moderation +files[] = tests/metatag.with_workbench_moderation.test + +; Basic integration with Views. +test_dependencies[] = views:views +files[] = tests/metatag.with_views.test + +; Other test dependencies. +test_dependencies[] = context:context + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag.install b/sites/all/modules/contrib/metatag/metatag.install index 73cfaa94..12d5f4f2 100644 --- a/sites/all/modules/contrib/metatag/metatag.install +++ b/sites/all/modules/contrib/metatag/metatag.install @@ -1,4 +1,5 @@ REQUIREMENT_WARNING, 'title' => 'Metatag', - 'value' => $t('Upgrade Drupal core to v7.28 or newer'), - 'description' => $t("This older version of Drupal core is missing functionality necessary for the module's multilingual support and contains a broken [node:summary] token, it must be upgraded to version 7.28 or newer."), - ); - } - // Everything's OK. - else { - $requirements['metatag'] = array( - 'severity' => REQUIREMENT_OK, - 'title' => 'Metatag', - 'value' => $t('Drupal core is compatible'), - 'description' => $t('Older versions of Drupal core contained bugs that made them incompatible with Metatag, but this version will work correctly.'), + 'value' => $t('Upgrade Drupal core to v7.40 or newer'), + 'description' => $t("This older version of Drupal core is missing functionality necessary for Metatag to work correctly, it must be upgraded to version 7.40 or newer."), ); } // Add a note if Page Title is also installed. if (module_exists('page_title')) { $requirements['metatag_page_title'] = array( - 'severity' => REQUIREMENT_INFO, + 'severity' => REQUIREMENT_WARNING, 'title' => 'Metatag', - 'value' => $t('Possible conflicts with Page Title module'), - 'description' => $t('The Metatag module is able to customize page titles so running the Page Title module simultaneously can lead to complications.'), + 'value' => $t('Page Title module should be removed'), + 'description' => $t('The Metatag module is able to customize page titles, so running the Page Title module simultaneously can lead to complications. Please follow the instructions to convert the Page Title settings and uninstall the module.', array('@page' => 'https://www.drupal.org/node/2774833')), ); } @@ -104,16 +100,16 @@ function metatag_requirements($phase) { } // Check that Entity_Translation is current. - if (module_exists('entity_translation')) { - $rev = db_query("SELECT schema_version FROM {system} WHERE name = :module", array(':module' => 'entity_translation'))->fetchColumn(); - if ($rev < 7004) { - $requirements['metatag_et_old'] = array( - 'severity' => REQUIREMENT_ERROR, - 'title' => 'Metatag', - 'value' => $t('Entity_Translation is out of date and requires updating', array('@url' => 'http://drupal.org/project/entity_translation')), - 'description' => $t('The Entity_Translation module is out of date and needs to be updated in order to be compatible with Metatag.'), - ); - } + if (module_exists('entity_translation') + && !empty($module_data['entity_translation']) + && !empty($module_data['entity_translation']->schema_version) + && $module_data['entity_translation']->schema_version < 7004) { + $requirements['metatag_et_version'] = array( + 'severity' => REQUIREMENT_ERROR, + 'title' => 'Metatag', + 'value' => $t('Entity_Translation is out of date and requires updating', array('@url' => 'https://www.drupal.org/project/entity_translation')), + 'description' => $t('The Entity_Translation module is out of date and needs to be updated in order to be compatible with Metatag.'), + ); } // It's recommended to install the Transliteration module to clean up file @@ -134,12 +130,12 @@ function metatag_requirements($phase) { 'severity' => REQUIREMENT_INFO, 'title' => 'Metatag', 'value' => $t('The Imagecache Token module is recommended.'), - 'description' => $t("It is recommended to install the Imagecache Token module to make it easier to control image meta tags, e.g. og:image.", array('@url' => 'https://drupal.org/project/imagecache_token')), + 'description' => $t("It is recommended to install the Imagecache Token module to make it easier to control image meta tags, e.g. og:image. See the Metatag module's README.txt for details.", 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)) { + if (module_exists('admin_language') && variable_get('admin_language_force_neutral', 0)) { $requirements['metatag_admin_language'] = array( 'severity' => REQUIREMENT_WARNING, 'title' => 'Metatag', @@ -147,6 +143,95 @@ function metatag_requirements($phase) { 'description' => $t("Using the \"@option\" with Metatag can lead to data loss, so it is recommended to disable that option.", array('@option' => t('Force language neutral aliases'), '@url' => url('admin/config/regional/language/admin_language'))), ); } + + // Token v7.x-1.6 is *highly* recommended. + $token_module = $module_data['token']; + // If the version string is not present then it means the module is running + // from git, which means it can't be compared against. Alternatively, look + // for the test file, which was the last commit of the 1.6 release. + if (!empty($token_module->info['version']) + || empty($token_module->info['files'])) { + // If there's no test file then this is older than v1.6. + if (empty($token_module->info['files'])) { + $minor = 5; + } + // Otherwise check the version string. + else { + // Versions are in the format 7.x-1.y, so split the string up to find + // the 'y' portion. + $version = explode('-', $token_module->info['version']); + if (isset($version[1])) { + list($major, $minor) = explode('.', $version[1]); + // Strip off any suffixes on the version string, e.g. "17-dev". + if (strpos('-', $minor)) { + list($minor, $suffix) = explode('-', $minor); + } + } + // If the version string couldn't be extracted correctly, assume that + // an incorrect version is installed. + else { + $minor = 0; + } + } + // If v1.6 is not installed, give a warning. + if ($minor < 6) { + $requirements['metatag_token_version'] = array( + 'severity' => REQUIREMENT_WARNING, + 'title' => 'Metatag', + 'value' => $t('Token module is out of date.'), + 'description' => $t('It is highly recommended to install Token module v7.x-1.6 or newer, otherwise there may be problems using certain meta tags.'), + ); + } + } + + // If Workbench Moderation is installed, show a message if it is out of + // date. + if (module_exists('workbench_moderation')) { + $wm_module = $module_data['workbench_moderation']; + // If the version string is not present then it means the module is + // running from git, which means it can't be compared against. + if (!empty($wm_module->info['version'])) { + // Versions are in the format 7.x-1.y, so split the string up to find + // the 'y' portion. + $version = explode('-', $wm_module->info['version']); + if (isset($version[1])) { + list($major, $minor) = explode('.', $version[1]); + } + // If the version string couldn't be extracted correctly, assume that + // an incorrect version is installed. + else { + $major = 0; + } + } + // If v3.x is not installed, give a message. + if ($major < 3) { + $requirements['metatag_wm_version'] = array( + 'severity' => REQUIREMENT_INFO, + 'title' => 'Metatag', + 'value' => $t('Workbench Moderation module is out of date.'), + 'description' => $t('It is recommended to use Workbench Moderation module v7.x-3.0 or newer.'), + ); + } + } + + // Recommend the Schema.org Metatag module. + if (!module_exists('schema_metatag')) { + $requirements['metatag_schema'] = array( + 'severity' => REQUIREMENT_INFO, + 'title' => 'Metatag', + 'value' => $t('Schema.org Metatag is recommended'), + 'description' => $t('The Schema.org Metatag module is highly recommended to add JSON-LD -formatted schema.org compatible data structures to the site.', array('@module' => 'https://www.drupal.org/project/schema_metatag', '@jsonld' => 'https://json-ld.org', '@schema' => 'http://schema.org')), + ); + } + else { + $requirements['metatag_schema'] = array( + 'severity' => REQUIREMENT_OK, + 'title' => 'Metatag', + 'value' => $t('Schema.org Metatag is installed'), + 'description' => $t('The Schema.org Metatag module is installed.', array('@module' => 'https://www.drupal.org/project/schema_metatag')), + ); + } + } return $requirements; @@ -241,13 +326,21 @@ function metatag_schema() { ), ), 'indexes' => array( - 'type_revision' => array('entity_type','revision_id'), + 'type_revision' => array( + 'entity_type', + 'revision_id', + ), + ), + 'primary key' => array( + 'entity_type', + 'entity_id', + 'revision_id', + 'language', ), - 'primary key' => array('entity_type', 'entity_id', 'revision_id', 'language'), ); $schema['cache_metatag'] = drupal_get_schema_unprocessed('system', 'cache'); - $schema['cache_metatag']['description'] = t('Cache table for the generated meta tag output.'); + $schema['cache_metatag']['description'] = 'Cache table for the generated meta tag output.'; return $schema; } @@ -257,6 +350,86 @@ function metatag_schema() { */ function metatag_install() { drupal_set_message(t("Thank you for installing the Metatag module. It is recommended to read the module's README.txt file as there are some known issues that may affect this site.", array('!url' => url(drupal_get_path('module', 'metatag') . '/README.txt')))); + + // Always enable the node, taxonomy term and user entities. + foreach (array('node', 'taxonomy_term', 'user') as $entity_type) { + // Enable the main entity type. + $variable_name = 'metatag_enable_' . $entity_type; + variable_set($variable_name, TRUE); + + // Update each entity bundle too. + $entity_info = entity_get_info($entity_type); + if (!empty($entity_info['bundles'])) { + foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { + $variable_name = 'metatag_enable_' . $entity_type . '__' . $bundle_name; + variable_set($variable_name, TRUE); + } + } + } + + // Possibly enable other entities, if they're specifically requested. + foreach (entity_get_info() as $entity_type => $entity_info) { + // Skip the three entity types that were already enabled. + if (in_array($entity_type, array('node', 'taxonomy_term', 'user'))) { + continue; + } + + $variable_name = 'metatag_enable_' . $entity_type; + + // Configuration entities are skipped. + if (isset($entity_info['configuration']) && $entity_info['configuration'] == TRUE) { + continue; + } + + // Entities must have bundles. + if (empty($entity_info['bundles'])) { + continue; + } + + // Entities must be fieldable. + elseif (empty($entity_info['fieldable'])) { + continue; + } + + // Ignore some view modes that are automatically added by certain modules. + unset($entity_info['view modes']['ical']); + unset($entity_info['view modes']['diff_standard']); + unset($entity_info['view modes']['token']); + + // Entities without view modes are skipped. + if (empty($entity_info['view modes'])) { + continue; + } + + // At this point, disable the entity by default. + $entity_enabled = FALSE; + + // Anything that was specifically enabled via hook_entity_info() from older + // versions will be enabled if not configured already. + if (!empty($entity_info['metatag']) || !empty($entity_info['metatags'])) { + $entity_enabled = variable_get($variable_name, 'monkey'); + if ($entity_enabled === 'monkey') { + $entity_enabled = TRUE; + } + } + + variable_set($variable_name, $entity_enabled); + + // Loop through the bundles, but only if the entity is enabled. + if ($entity_enabled) { + foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { + $variable_name = 'metatag_enable_' . $entity_type . '__' . $bundle_name; + + // If it wasn't specifically disabled before, enable it. + $bundle_enabled = variable_get($variable_name, 'monkey'); + if ($bundle_name != FALSE) { + variable_set($variable_name, TRUE); + } + } + } + } + + drupal_set_message(t('It may be worth verifying on the Settings page which types of content on the site should allow meta tags.', array('@url' => url('admin/config/search/metatags/settings')))); } /** @@ -280,6 +453,56 @@ function metatag_uninstall() { // Used to force an entity's default language values to be used if nothing // else matched. variable_del('metatag_entity_no_lang_default'); + + // Controls which page region is used to trigger output of the meta tags. + variable_del('metatag_page_region'); + + // Optionally disable the default configurations. + variable_del('metatag_load_defaults'); + + // Optionally disables the output cache. + variable_del('metatag_cache_output'); + + // Customizable pager string. + variable_del('metatag_pager_string'); + + // Optionally enable translations of final output. + variable_del('metatag_i18n_translate_output'); + + // Optionally enable the automatic watchdog logging of i18n strings. + variable_del('metatag_i18n_enable_watchdog'); + + // Optionally disable the i18n integration. + variable_del('metatag_i18n_disabled'); + + // Optionally output core's meta tags. + variable_del('metatag_leave_core_tags'); + + // Optionally enable individual permissions for each meta tag. + variable_del('metatag_extended_permissions'); + + // Optionally load meta tags on admin pages. + variable_del('metatag_load_all_pages'); + + // Sanitize token replacement output. + variable_del('metatag_token_sanitize'); + + // Remove all possible 'enable' variables. + foreach (entity_get_info() as $entity_type => $entity_info) { + variable_del('metatag_enable_' . $entity_type); + if (!empty($entity_info['bundles'])) { + foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { + variable_del('metatag_enable_' . $entity_type . '__' . $bundle_name); + } + } + } + + // Remove all of the maxlength variables. + variable_del('metatag_maxlength_title'); + variable_del('metatag_maxlength_description'); + variable_del('metatag_maxlength_abstract'); + variable_del('metatag_maxlength_keywords'); + variable_del('metatag_maxlength_news_keywords'); } /** @@ -290,13 +513,329 @@ function metatag_enable() { } /** - * Implements hook_disable(). + * Replace one meta tag's with another in the entity records. + * + * @param array $sandbox + * A Batch API sandbox, passed by reference. + * @param string $old_tag + * The meta tag that is to be replaced. + * @param string $new_tag + * The meta tag that replaces the old one. + */ +function metatag_update_replace_entity_tag(&$sandbox, $old_tag, $new_tag) { + if (!isset($sandbox['progress'])) { + // Count of all {metatag} records that contained an entry for the old meta + // tag. + $records_count = db_select('metatag', 'm') + ->condition('m.data', '%' . db_like('"' . $old_tag . '"') . '%', 'LIKE') + ->countQuery() + ->execute() + ->fetchField(); + + if (empty($records_count)) { + return t('No Metatag entity records needed to have the "@tag" meta tag renamed.', array('@tag' => $old_tag)); + } + + $sandbox['max'] = $records_count; + $sandbox['progress'] = 0; + } + + // Count of rows that will be processed per iteration. + $limit = 100; + + // Fetches a part of records. + $records = db_select('metatag', 'm') + ->fields('m', array()) + ->condition('m.data', '%' . db_like('"' . $old_tag . '"') . '%', 'LIKE') + ->range(0, $limit) + ->execute(); + + $count = 0; + $keys = array('entity_type', 'entity_id', 'revision_id', 'language'); + + // Loop over the values and correct them. + foreach ($records as $record) { + $record->data = unserialize($record->data); + + if (isset($record->data[$old_tag])) { + $record->data[$new_tag] = $record->data[$old_tag]; + unset($record->data[$old_tag]); + drupal_write_record('metatag', $record, $keys); + + // Clear the cache for the entity this belongs to. + entity_get_controller($record->entity_type)->resetCache(array($record->entity_id)); + } + + $count++; + } + + if (!empty($count)) { + $sandbox['progress'] += $count; + // In some cases the query yields results that cannot be fixed and we would + // run into an infinite loop. Stop immediately if we processed all records. + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } + } + else { + $sandbox['#finished'] = TRUE; + return t('Converted the "@old_tag" meta tag for @count entity records to "@new_tag" meta tag.', array('@old_tag' => $old_tag, '@new_tag' => $new_tag, '@count' => $sandbox['progress'])); + } +} + +/** + * Replace one meta tag's value in the entity records. + * + * @param array $sandbox + * A Batch API sandbox, passed by reference. + * @param string $meta_tag + * The meta tag that needs its value replaced. + * @param string $old_value + * The meta tag value that is to be replaced. + * @param string $new_value + * The meta tag value that replaces the old one. + */ +function metatag_update_replace_entity_value(&$sandbox, $meta_tag, $old_value, $new_value) { + // The condition used for both queries. + $db_and = db_and(); + $db_and->condition('m.data', '%' . db_like('"' . $meta_tag . '"') . '%', 'LIKE'); + $db_and->condition('m.data', '%' . db_like('"' . $old_value . '"') . '%', 'LIKE'); + + if (!isset($sandbox['progress'])) { + // Count of all {metatag} records that contained an entry for the old meta + // tag value. + $records_count = db_select('metatag', 'm') + ->condition($db_and) + ->countQuery() + ->execute() + ->fetchField(); + + if (empty($records_count)) { + return t('No Metatag entity records needed to have the "@tag" meta tag "@old_value" value replaced.', array('@tag' => $meta_tag, '@old_value' => $old_value)); + } + + $sandbox['max'] = $records_count; + $sandbox['progress'] = 0; + + // Keep track of the number of replaced values separately. + $sandbox['count'] = 0; + } + + // Count of rows that will be processed per iteration. + $limit = 100; + + // Fetches a part of records. + $records = db_select('metatag', 'm') + ->fields('m', array()) + ->condition($db_and) + ->range(0, $limit) + ->execute(); + + $count = 0; + $keys = array('entity_type', 'entity_id', 'revision_id', 'language'); + + // Loop over the values and correct them. + foreach ($records as $record) { + $record->data = unserialize($record->data); + + if (isset($record->data[$meta_tag])) { + $record->data[$meta_tag]['value'] = str_replace($old_value, $new_value, $record->data[$meta_tag]['value']); + drupal_write_record('metatag', $record, $keys); + + // Clear the cache for the entity this belongs to. + entity_get_controller($record->entity_type)->resetCache(array($record->entity_id)); + + $sandbox['count']++; + } + + $sandbox['progress']++; + } + + if (!empty($count)) { + // In some cases the query yields results that cannot be fixed and we would + // run into an infinite loop. Stop immediately if we processed all records. + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } + } + else { + $sandbox['#finished'] = TRUE; + return t('Replaced the value of @count entity records for the "@meta_tag" meta tag.', array('@meta_tag' => $meta_tag, '@count' => $sandbox['count'])); + } +} + +/** + * Replace one meta tag with another in the configs. + * + * @param string $old_tag + * The meta tag that is to be replaced. + * @param string $new_tag + * The meta tag that replaces the old one. + */ +function metatag_update_replace_config_tag($old_tag, $new_tag) { + // Find all {metatag_config} records that contained an entry for the old meta + // tag. + $records = db_select('metatag_config', 'm') + ->fields('m', array('cid', 'config')) + ->condition('m.config', '%' . db_like('"' . $old_tag . '"') . '%', 'LIKE') + ->execute(); + // This message will be returned if nothing needed to be updated. + $none_message = t('No Metatag configuration records needed to have the "@tag" meta tag fixed. That said, there may be other configurations elsewhere that do need updating.', array('@tag' => $old_tag)); + + // Loop over the values and correct them. + if ($records->rowCount() == 0) { + $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[$old_tag])) { + $record->config[$new_tag] = $record->config[$old_tag]; + unset($record->config[$old_tag]); + drupal_write_record('metatag_config', $record, $keys); + $counter++; + } + } + if ($counter == 0) { + $message = $none_message; + } + else { + $message = t('Converted the "@old_tag" meta tag for @count configurations to the new "@new_tag" meta tag.', array('@old_tag' => $old_tag, '@new_tag' => $new_tag, '@count' => $counter)); + } + } + + // Clear all Metatag caches. + cache_clear_all('*', 'cache_metatag', TRUE); + drupal_static_reset('metatag_config_load_with_defaults'); + drupal_static_reset('metatag_entity_supports_metatags'); + drupal_static_reset('metatag_config_instance_info'); + drupal_static_reset('metatag_get_info'); + ctools_include('export'); + ctools_export_load_object_reset('metatag_config'); + + return $message; +} + +/** + * Replace one meta tag with another in the configs. + * + * @param string $meta_tag + * The meta tag that needs its value replaced. + * @param string $old_value + * The meta tag value that is to be replaced. + * @param string $new_value + * The meta tag value that replaces the old one. + */ +function metatag_update_replace_config_value($meta_tag, $old_value, $new_value) { + // Find all {metatag_config} records that contained an entry for the old meta + // tag. + $db_and = db_and(); + $db_and->condition('m.config', '%' . db_like('"' . $meta_tag . '"') . '%', 'LIKE'); + $db_and->condition('m.config', '%' . db_like('"' . $old_value . '"') . '%', 'LIKE'); + $records = db_select('metatag_config', 'm') + ->fields('m', array('cid', 'config')) + ->condition($db_and) + ->execute(); + // This message will be returned if nothing needed to be updated. + $none_message = t('No Metatag configuration records needed to have the "@tag" meta tag values updated. That said, there may be other configurations elsewhere that do need updating.', array('@tag' => $meta_tag)); + + // Loop over the values and correct them. + if ($records->rowCount() == 0) { + $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[$meta_tag])) { + $record->config[$meta_tag]['value'] = str_replace($old_value, $new_value, $record->config[$meta_tag]['value']); + drupal_write_record('metatag_config', $record, $keys); + $counter++; + } + } + if ($counter == 0) { + $message = $none_message; + } + else { + $message = t('Replaced the value of @count entity records for the "@meta_tag" meta tag.', array('@meta_tag' => $meta_tag, '@count' => $counter)); + } + } + + // Clear all Metatag caches. + cache_clear_all('*', 'cache_metatag', TRUE); + drupal_static_reset('metatag_config_load_with_defaults'); + drupal_static_reset('metatag_entity_supports_metatags'); + drupal_static_reset('metatag_config_instance_info'); + drupal_static_reset('metatag_get_info'); + ctools_include('export'); + ctools_export_load_object_reset('metatag_config'); + + return $message; +} + +/** + * Remove a specific meta tag from all configs. + * + * @param string $$tag_name + * The meta tag that is to be removed. */ -// function metatag_disable() { -// } +function metatag_update_delete_config($tag_name) { + // Find all {metatag_config} records that contained an entry for the meta tag. + $records = db_select('metatag_config', 'm') + ->fields('m', array('cid', 'config')) + ->condition('m.config', '%' . db_like('"' . $tag_name . '"') . '%', 'LIKE') + ->execute(); + // This message will be returned if nothing needed to be updated. + $none_message = t('No Metatag configuration records needed to have the "@tag" meta tag removed.', array('@tag' => $tag_name)); + + // Loop over the values and correct them. + if ($records->rowCount() == 0) { + drupal_set_message($none_message); + } + else { + // Loop over the values and correct them. + $counter = 0; + foreach ($records as $record) { + $record->config = unserialize($record->config); + if (isset($record->config[$tag_name])) { + unset($record->config[$tag_name]); + drupal_write_record('metatag_config', $record, array('cid')); + $counter++; + } + } + if ($counter == 0) { + drupal_set_message($none_message); + } + else { + drupal_set_message(t('Removed the "@tag" meta tag for @count configurations.', array('@tag' => $tag_name, '@count' => $counter))); + } + } + + // Clear all Metatag caches. + cache_clear_all('*', 'cache_metatag', TRUE); + drupal_static_reset('metatag_config_load_with_defaults'); + drupal_static_reset('metatag_entity_supports_metatags'); + drupal_static_reset('metatag_config_instance_info'); + drupal_static_reset('metatag_get_info'); + ctools_include('export'); + ctools_export_load_object_reset('metatag_config'); +} /** - * Disable the deprecated metatag_ui module which has been merged into metatag. + * Disable the deprecated metatag_ui module, which has been merged into metatag. */ function metatag_update_7000() { if (module_exists('metatag_ui')) { @@ -644,7 +1183,12 @@ function metatag_update_7011(&$sandbox) { // 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['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } if ($sandbox['#finished']) { // Clear all caches so the fixed data will be reloaded. @@ -658,7 +1202,7 @@ function metatag_update_7011(&$sandbox) { // hook_update_N() may optionally return a string which will be displayed // to the user. - return t('Fixed the Metatag language values for @count nodes.', array('!count' => $sandbox['progress'])); + return t('Fixed the Metatag language values for @count nodes.', array('@count' => $sandbox['progress'])); } } @@ -802,7 +1346,12 @@ function metatag_update_7013(&$sandbox) { // 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['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } if ($sandbox['#finished']) { // Clear all caches so the fixed data will be reloaded. @@ -1166,6 +1715,13 @@ function metatag_update_7018(&$sandbox) { } $records = entity_load($entity_type, array($entity_id), $conditions); + // Try to fallback to default language if no record was found. This may + // happen when using entity_translation as the parent entity table only + // contains one record. + if (!empty($conditions) && empty($records)) { + $records = entity_load($entity_type, array($entity_id)); + } + // Fix this record. if (!empty($records)) { $entity = reset($records); @@ -1280,9 +1836,14 @@ function metatag_update_7018(&$sandbox) { // 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']) { + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } + + if ($sandbox['#finished']) { // Clear all caches so the fixed data will be reloaded. cache_clear_all('*', 'cache_metatag', TRUE); @@ -1348,204 +1909,706 @@ function metatag_update_7023() { } /** - * Rename the 'twitter:image' meta tag to 'twitter:image:src', part 1. + * No-op update. Renaming twitter:image to twitter:image:src no longer needed. */ 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.'); + // Do nothing. +} - if ($records->rowCount() == 0) { - drupal_set_message($none_message); +/** + * Replaced by update 7030. + */ +function metatag_update_7025() { + // Do nothing. +} + +/** + * Rename the 'copyright' meta tag to 'rights', part 1. + */ +function metatag_update_7026(&$sandbox) { + $old_tag = 'copyright'; + $new_tag = 'rights'; + return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); +} + +/** + * Replaced by update 7031. + */ +function metatag_update_7027() { + // Do nothing. +} + +/** + * Clear the menu cache so the new 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() { + if (!db_index_exists('metatag', 'type_revision')) { + db_add_index('metatag', 'type_revision', array('entity_type', 'revision_id')); + return t('Added an index to the main Metatag table that will hopefully improve performance a little.'); } else { - $keys = array('entity_type', 'entity_id', 'revision_id', 'language'); + return t('Did not add the index, it already existed.'); + } +} - // 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++; - } +/** + * No-op update. Renaming twitter:image to twitter:image:src no longer needed. + */ +function metatag_update_7030() { + // Do nothing. +} + +/** + * Rename the 'copyright' meta tag to 'rights', part 2. + */ +function metatag_update_7031() { + $old_tag = 'copyright'; + $new_tag = 'rights'; + return metatag_update_replace_config_tag($old_tag, $new_tag); +} + +/** + * 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() { +} + +/** + * Update variables to indicate which entities should be supported. + */ +function metatag_update_7036() { + foreach (entity_get_info() as $entity_type => $entity_info) { + $variable_name = 'metatag_enable_' . $entity_type; + + // Configuration entities are skipped. + if (isset($entity_info['configuration']) && $entity_info['configuration'] == TRUE) { + continue; } - if ($counter == 0) { - drupal_set_message($none_message); + + // Entities without view modes are skipped. + elseif (empty($entity_info['view modes'])) { + continue; } + + // Basic core entities or "normal" entities that have been enabled via the + // API. + elseif (in_array($entity_type, array('node', 'taxonomy_term', 'user')) || + !empty($entity_info['metatag']) || !empty($entity_info['metatags'])) { + // Check if the entity type has been enabled or disabled previously; if + // the variable equals a junk value then it was not previously set, + // therefore we'll set a default. + if (variable_get($variable_name, 'monkey') == 'monkey') { + // By default these entity types are enabled. + variable_set($variable_name, TRUE); + // Check each entity bundle. + if (!empty($entity_info['bundles'])) { + foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { + $variable_name = 'metatag_enable_' . $entity_type . '__' . $bundle_name; + // Check if the bundle has been enabled or disabled previously; if + // the variable equals a junk value then it was not previously set, + // therefore we'll set a default. + if (variable_get($variable_name, 'monkey') == 'monkey') { + if (!empty($bundle_info['metatag']) || !empty($bundle_info['metatags'])) { + variable_set($variable_name, TRUE); + } + else { + variable_set($variable_name, FALSE); + } + } + // This variable was set before. + else { + // Do nothing. + } + } + } + } + // This variable was set before. + else { + // Do nothing. + } + } + + // Disable this entity type. 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))); + variable_set($variable_name, FALSE); } } + + // Clear the caches. + cache_clear_all('*', 'cache_metatag', TRUE); + drupal_static_reset('metatag_config_load_with_defaults'); + drupal_static_reset('metatag_entity_supports_metatags'); + ctools_include('export'); + ctools_export_load_object_reset('metatag_config'); + + drupal_set_message(t('The way that Metatag tracks which entity types are compatible has changed. Please review the Settings page to ensure that all of the entity types are enabled correctly.', array('@url' => 'admin/config/search/metatags/settings'))); } /** - * Replaced by update 7030. + * Clear the menu cache so the renamed Settings page will be picked up. */ -function metatag_update_7025() { - // Do nothing. +function metatag_update_7037() { + variable_set('menu_rebuild_needed', TRUE); } /** - * Rename the 'copyright' meta tag to 'rights', part 1. + * Manually enable all content types, vocabularies and the user entity to help + * resolve issues from 1.5's architecture change. */ -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.'); +function metatag_update_7038() { + foreach (array('node', 'taxonomy_term', 'user') as $entity_type) { + // Enable the main entity type. + $variable_name = 'metatag_enable_' . $entity_type; + variable_set($variable_name, TRUE); + + // Update each entity bundle too. + $entity_info = entity_get_info($entity_type); + if (!empty($entity_info['bundles'])) { + foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { + $variable_name = 'metatag_enable_' . $entity_type . '__' . $bundle_name; + variable_set($variable_name, TRUE); + } + } + } +} - if ($records->rowCount() == 0) { - drupal_set_message($none_message); +/** + * Reload some meta tag caches. + */ +function metatag_update_7039() { + foreach (language_list() as $langcode => $language) { + cache_clear_all('info:' . $langcode, 'cache_metatag'); } - 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++; +/** + * Fix robots meta tags that might have been broken when they were imported + * from Nodewords. + */ +function metatag_update_7040(&$sandbox) { + // Process records by groups of 10 (arbitrary value). + // When a group is processed, the batch update engine determines whether it + // should continue processing in the same request or provide progress + // 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 count of {metatag} records that have a robots meta tag definition + // that is not in the correct format. + $records = db_select('metatag', 'm') + ->fields('m') + ->condition('m.data', '%:6:"robots";%', 'LIKE') + ->condition('m.data', '%:6:"robots";a:1:{s:5:"value";%', 'NOT LIKE') + ->countQuery() + ->execute() + ->fetchField(); + + // If there's no data, don't bother with the extra work. + if (empty($records)) { + watchdog('metatag', 'Update 7040: No robots meta tags need to be fixed.', array(), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7040: No robots meta tags need to be fixed.')); } + return t('No robots meta tags need to be fixed.'); } - if ($counter == 0) { - drupal_set_message($none_message); + + // Total records that must be visited. + $sandbox['max'] = $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 7040: !count records to examine.', array('!count' => $sandbox['max']), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7040: !count records to examine.', array('!count' => $sandbox['max']))); } - else { - drupal_set_message(t('Converted the "copyright" meta tag for @count entity records to the correct "rights" meta tag.', array('@count' => $counter))); + + // Log how many records are fixed. + $sandbox['fixed'] = 0; + + // Because a lot of other processing happens on the first iteration, just do + // ten. + $limit = 10; + } + + // Get a list of records that need to be fixed. + $records = db_select('metatag', 'm') + ->fields('m') + ->condition('m.data', '%:6:"robots";%', 'LIKE') + ->condition('m.data', '%:6:"robots";a:1:{s:5:"value";%', 'NOT LIKE') + ->range(0, $limit) + ->execute(); + + // Set default values. + foreach ($records as $record) { + // Extract the record. + $record->data = unserialize($record->data); + + // See if the record needs to be fixed. + if (!empty($record->data['robots']) && empty($record->data['robots']['value'])) { + // Fix the record. + $robots = $record->data['robots']; + $record->data['robots'] = array( + 'value' => $robots, + ); + + // Update the database. + db_update('metatag') + ->fields(array('data' => serialize($record->data))) + ->condition('entity_type', $record->entity_type) + ->condition('entity_id', $record->entity_id) + ->condition('revision_id', $record->revision_id) + ->condition('language', $record->language) + ->execute(); + + // Clear the cache for this entity. + entity_get_controller($record->entity_type)->resetCache(array($record->entity_id)); + + // Update our progress information. + $sandbox['fixed']++; + } + + // 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. + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } + + // Only display a status message if process finished. + if ($sandbox['#finished'] === TRUE) { + // 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 7040: !count records were fixed.', array('!count' => $sandbox['fixed']), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7040: !count records were fixed.', array('!count' => $sandbox['fixed']))); } + + // hook_update_N() may optionally return a string which will be displayed + // to the user. + return t('Fixed the Metatag robots values for @count nodes.', array('@count' => $sandbox['fixed'])); } } /** - * Replaced by update 7031. + * Rerun update 7018 that was fixed to run correctly when using Entity + * Translation. This may take some time. */ -function metatag_update_7027() { - // Do nothing. +function metatag_update_7041(&$sandbox) { + metatag_update_7018($sandbox); } /** - * Clear the menu cache so the new Advanced Settings page will be picked up. + * Delete a deprecated variable and clear all Metatag caches. */ -function metatag_update_7028() { - variable_set('menu_rebuild_needed', TRUE); +function metatag_update_7100() { + variable_del('metatag_translate_final_values'); + + // Clear all caches so that i18n support can be activated, if necessary. + cache_clear_all('*', 'cache_metatag', TRUE); } /** - * Add an index to the {metatag} table to speed up some queries. + * Update i18n strings for all meta tags to use the new format. */ -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.')); +function metatag_update_7101() { + if (!module_exists('locale') || !db_table_exists('locales_source')) { + return t('No translations to fix as the locale system is not enabled.'); + } + + // Loop through each entity type. Not going to bother filtering this list, + // it'll only be a difference of a few entities anyway and the queries + // should be fairly quick. + foreach (entity_get_info() as $entity_type => $entity_info) { + // Entities must have bundles. + if (empty($entity_info['bundles'])) { + $entity_info['bundles'] = array( + $entity_type => $entity_type, + ); + } + foreach ($entity_info['bundles'] as $bundle_type => $bundle_info) { + // Update {locales_source}, replace 'metatag:ENTITYTYPE:BUNDLE:tag' with + // 'metatag:metatag_config:ENTITYTYPE:BUNDLE:tag'. + db_query("UPDATE {locales_source} + SET location = REPLACE(location, 'metatag:{$entity_type}:{$bundle_type}:', 'metatag:metatag_config:{$entity_type}:{$bundle_type}:'), + context = REPLACE(context, '{$entity_type}:{$bundle_type}:', 'metatag_config:{$entity_type}:{$bundle_type}:') + WHERE textgroup = 'metatag' + AND location LIKE 'metatag:{$entity_type}:{$bundle_type}:%'"); + + // Update {locales_source}, replace 'metatag:ENTITYTYPE:tag' with + // 'metatag:metatag_config:ENTITYTYPE:tag'. + db_query("UPDATE {locales_source} + SET location = REPLACE(location, 'metatag:{$entity_type}:', 'metatag:metatag_config:{$entity_type}:'), + context = REPLACE(context, '{$entity_type}:', 'metatag_config:{$entity_type}:') + WHERE textgroup = 'metatag' + AND location LIKE 'metatag:{$entity_type}:%'"); + } + } + // Update {locales_source}, replace 'metatag:metatag:' with + // 'metatag:output:'. + db_query("UPDATE {locales_source} + SET location = REPLACE(location, 'metatag:metatag:', 'metatag:output:'), + context = REPLACE(context, 'metatag:', 'output:') + WHERE textgroup = 'metatag' + AND location LIKE 'metatag:metatag:%'"); } /** - * Rename the 'twitter:image' meta tag to 'twitter:image:src', part 2. + * Re-run update 7101. */ -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.'); +function metatag_update_7102() { + metatag_update_7101(); +} - // Loop over the values and correct them. - if ($records->rowCount() == 0) { - drupal_set_message($none_message); +/** + * Clear all metatag caches so the new entity caching structure takes over. + */ +function metatag_update_7103() { + cache_clear_all('*', 'cache_metatag', TRUE); +} + +/** + * Remove the entity revision ID from the translation strings. + */ +function metatag_update_7104(&$sandbox) { + // Verify that locales are being used in the first place. + if (!module_exists('locale') || !db_table_exists('locales_source')) { + return t('Metatag: No translations to fix as the locale system is not enabled.'); } - 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++; + // No need to do anything if output translation is disabled. + if (!variable_get('metatag_i18n_translate_output', FALSE)) { + return t('Metatag: Output translation is disabled, so no need to update anything.'); + } + + // Process records by groups of 10 (arbitrary value). + // When a group is processed, the batch update engine determines whether it + // should continue processing in the same request or provide progress + // 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; + + // Total records that must be visited. + $sandbox['max'] = db_query("SELECT COUNT(lid) + FROM {locales_source} + WHERE textgroup = 'metatag' + AND context LIKE 'output:%:%:%:%'")->fetchField(); + + // If there's no data, don't bother with the extra work. + if (empty($sandbox['max'])) { + watchdog('metatag', 'Update 7104: No nodes need the translation entity string fixed.', array(), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7104: No nodes need the translation entity string fixed.')); } + return t('No nodes need the Metatag language values fixed.'); } - 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))); + + // 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 7104: !count records to update.', array('!count' => $sandbox['max']), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7104: !count records to update.', array('!count' => $sandbox['max']))); } } + + // Get a batch of records that need to be fixed. + $records = db_query_range("SELECT lid, location, context + FROM {locales_source} + WHERE textgroup = 'metatag' + AND context LIKE 'output:%:%:%:%'", 0, $limit); + + // Update each of the records. + foreach ($records as $record) { + $old_location = '/metatag:output:([^:]*):([^:]*):([^:]*):([^:]*)/'; + $new_location = 'metatag:output:$1:$2:$4'; + $location = preg_replace($old_location, $new_location, $record->location); + $old_context = '/output:([^:]*):([^:]*):([^:]*):([^:]*)/'; + $new_context = 'output:$1:$2:$4'; + $context = preg_replace($old_context, $new_context, $record->context); + drupal_set_message($location); + drupal_set_message($context); + db_update('locales_source') + ->fields(array( + 'location' => $location, + 'context' => $context, + )) + ->condition('lid', $record->lid) + ->execute(); + + // 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. + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } + + if ($sandbox['#finished']) { + // Clear all caches so the fixed data will be reloaded. + cache_clear_all('*', 'cache_metatag', TRUE); + + // hook_update_N() may optionally return a string which will be displayed + // to the user. + return t('Fixed the Metatag language values for @count nodes.', array('@count' => $sandbox['progress'])); + } } /** - * Rename the 'copyright' meta tag to 'rights', part 2. + * Fix the output translation strings. */ -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.'); +function metatag_update_7105() { + if (!module_exists('locale') || !db_table_exists('locales_source')) { + return t('No translations to fix as the locale system is not enabled.'); + } - // Loop over the values and correct them. - if ($records->rowCount() == 0) { - drupal_set_message($none_message); + db_query("UPDATE {locales_source} + SET location = REPLACE(location, 'metatag:metatag:', 'metatag:output:'), + context = REPLACE(context, 'metatag:', 'output:') + WHERE textgroup = 'metatag' + AND location LIKE 'metatag:metatag:%'"); + + return t('Fixed the Metatag output strings.'); +} + + +/** + * The output translation strings were renamed to something shorter, so rerun + * update 7105. + */ +function metatag_update_7106() { + return metatag_update_7105(); +} + +/** + * Fix the global config translation strings. + */ +function metatag_update_7107() { + if (!module_exists('locale') || !db_table_exists('locales_source')) { + return t('No translations to fix as the locale system is not enabled.'); } - 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++; + db_query("UPDATE {locales_source} + SET location = REPLACE(location, 'metatag:global:', 'metatag:metatag_config:global:'), + context = REPLACE(context, 'global:', 'metatag_config:global:') + WHERE textgroup = 'metatag' + AND location LIKE 'metatag:global:%'"); + + return t('Fixed the Metatag global config string translations.'); +} + +/** + * Delete output translations if it's disabled. + */ +function metatag_update_7108(&$sandbox) { + if (!module_exists('locale') || !db_table_exists('locales_source')) { + return t('No translations to fix as the locale system is not enabled.'); + } + + // If the output-translation option is enabled then don't delete anything. + if (variable_get('metatag_i18n_translate_output', FALSE)) { + return t("Metatag: Not deleting output translations because that option is enabled."); + } + + $limit = 100; + + // When ran through Drush it's Ok to process a larger number of objects at a + // time. + if (drupal_is_cli()) { + $limit = 500; + } + + // 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; + + $sandbox['max'] = db_query("SELECT COUNT(lid) + FROM {locales_source} + WHERE textgroup = 'metatag' + AND context LIKE 'output:%'")->fetchField(); + + // If there's no data, don't bother with the extra work. + if (empty($sandbox['max'])) { + watchdog('metatag', 'Update 7108: No nodes need the translation entity string fixed.', array(), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7108: No nodes need the translation entity string fixed.')); } + return t('No nodes need the Metatag language values fixed.'); } - 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))); + + // 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 7108: !count records to update.', array('!count' => $sandbox['max']), WATCHDOG_INFO); + if (drupal_is_cli()) { + drupal_set_message(t('Update 7108: !count records to update.', array('!count' => $sandbox['max']))); } } + + // Get a batch of records that need to be fixed. + $records = db_query_range("SELECT lid + FROM {locales_source} + WHERE textgroup = 'metatag' + AND context LIKE 'output:%'", 0, $limit); + + $lids = $records->fetchCol(); + $count = count($lids); + // Delete records in the tables in reverse order, so that if the query fails + // and has to be reran it'll still find records. But it should be ok. + if (db_table_exists('i18n_string')) { + db_delete('i18n_string') + ->condition('lid', $lids, 'IN') + ->execute(); + } + db_delete('locales_target') + ->condition('lid', $lids, 'IN') + ->execute(); + db_delete('locales_source') + ->condition('lid', $lids, 'IN') + ->execute(); + + $sandbox['progress'] = $sandbox['progress'] + $count; + + // 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. + if ($sandbox['progress'] >= $sandbox['max']) { + $sandbox['#finished'] = TRUE; + } + else { + $sandbox['#finished'] = $sandbox['progress'] / $sandbox['max']; + } + + if ($sandbox['#finished']) { + // Clear all caches so the fixed data will be reloaded. + cache_clear_all('*', 'cache_metatag', TRUE); + + // hook_update_N() may optionally return a string which will be displayed + // to the user. + return t('Deleted output translation if disabled for @count items.', array('@count' => $sandbox['progress'])); + } } /** - * Clear the Metatag cache. + * Rename the 'icon_any' meta tag to 'mask-icon' in the entity records. */ -function metatag_update_7032() { +function metatag_update_7109(&$sandbox) { + module_load_include('install', 'metatag'); + $old_tag = 'icon_any'; + $new_tag = 'mask-icon'; + return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); +} + +/** + * Rename the 'icon_any' meta tag to 'mask-icon' in the configs. + */ +function metatag_update_7110() { + module_load_include('install', 'metatag'); + $old_tag = 'icon_any'; + $new_tag = 'mask-icon'; + return metatag_update_replace_config_tag($old_tag, $new_tag); +} + +/** + * Remove the "metatag_ui" record from the {system} table. + */ +function metatag_update_7111() { + db_delete('system') + ->condition('name', 'metatag_ui') + ->execute(); +} + +/** + * The Publisher meta tag is now part of the Google Plus submodule. + */ +function metatag_update_7112() { cache_clear_all('*', 'cache_metatag', TRUE); - return t('All Metatag caches cleared.'); + drupal_set_message(t('The Publisher meta tag is now part of the Google Plus submodule.')); } /** - * 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 + * Clear all metatag output caches if output caching is disabled. */ -function metatag_update_7033() { +function metatag_update_7113() { + if (variable_get('metatag_cache_output', TRUE) == FALSE) { + cache_clear_all('output:', 'cache_metatag', TRUE); + } } -function metatag_update_7034() { + +/** + * Disable output caching. + */ +function metatag_update_7114() { + variable_del('metatag_cache_output'); + drupal_set_message(t('Note: Output caching of meta tags has been disabled, it may be reenabled from the Metatag settings page if needed.')); } -function metatag_update_7035() { + +/** + * Clear all metatag output caches, it will be rebuild if needed. + */ +function metatag_update_7115() { + cache_clear_all('output:', 'cache_metatag', TRUE); } diff --git a/sites/all/modules/contrib/metatag/metatag.metatag.inc b/sites/all/modules/contrib/metatag/metatag.metatag.inc index 340960a7..5b67115f 100644 --- a/sites/all/modules/contrib/metatag/metatag.metatag.inc +++ b/sites/all/modules/contrib/metatag/metatag.metatag.inc @@ -1,9 +1,19 @@ api_version = 1; $config->disabled = FALSE; $config->config = array( - 'title' => array('value' => '[current-page:title] | [site:name]'), - 'generator' => array('value' => 'Drupal 7 (http://drupal.org)'), + 'title' => array('value' => '[current-page:title] | [current-page:pager][site:name]'), + 'generator' => array('value' => 'Drupal 7 (https://www.drupal.org)'), 'canonical' => array('value' => '[current-page:url:absolute]'), 'shortlink' => array('value' => '[current-page:url:unaliased]'), ); @@ -23,7 +33,7 @@ function metatag_metatag_config_default() { $config->api_version = 1; $config->disabled = FALSE; $config->config = array( - 'title' => array('value' => variable_get('site_slogan') ? '[site:name] | [site:slogan]' : '[site:name]'), + 'title' => array('value' => variable_get('site_slogan') ? '[site:name] | [current-page:pager][site:slogan]' : '[site:name] | [current-page:pager]'), 'canonical' => array('value' => '[site:url]'), 'shortlink' => array('value' => '[site:url]'), ); @@ -54,7 +64,7 @@ function metatag_metatag_config_default() { $config->api_version = 1; $config->disabled = FALSE; $config->config = array( - 'title' => array('value' => '[node:title] | [site:name]'), + 'title' => array('value' => '[node:title] | [current-page:pager][site:name]'), 'description' => array('value' => '[node:summary]'), ); $configs[$config->instance] = $config; @@ -65,7 +75,7 @@ function metatag_metatag_config_default() { $config->api_version = 1; $config->disabled = FALSE; $config->config = array( - 'title' => array('value' => '[term:name] | [site:name]'), + 'title' => array('value' => '[term:name] | [current-page:pager][site:name]'), 'description' => array('value' => '[term:description]'), ); $configs[$config->instance] = $config; @@ -78,6 +88,9 @@ function metatag_metatag_config_default() { $config->config = array( 'title' => array('value' => '[user:name] | [site:name]'), ); + if (variable_get('user_pictures')) { + $config->config['image_src'] = array('value' => '[user:picture:url]'); + } $configs[$config->instance] = $config; // Before returning these, allow the bundled submodules to override them, thus @@ -104,7 +117,7 @@ function metatag_metatag_config_instance_info() { if (metatag_entity_supports_metatags($entity_type)) { $info[$entity_type] = array('label' => $entity_info['label']); foreach ($entity_info['bundles'] as $bundle => $bundle_info) { - if (count($entity_info['bundles'] == 1) && $bundle == $entity_type) { + if (count($entity_info['bundles']) == 1 && $bundle == $entity_type) { // Skip default bundles (entities that do not really have bundles). continue; } @@ -122,10 +135,17 @@ function metatag_metatag_config_instance_info() { * Implements hook_metatag_info(). */ function metatag_metatag_info() { + $info['groups']['basic'] = array( + 'label' => t('Basic tags'), + 'form' => array( + '#weight' => 1, + '#collapsed' => FALSE, + ), + ); $info['groups']['advanced'] = array( - 'label' => t('Advanced'), + 'label' => t('Advanced tags'), 'form' => array( - '#weight' => 100, + '#weight' => 2, ), ); @@ -135,14 +155,18 @@ function metatag_metatag_info() { $info['tags']['title'] = array( 'label' => t('Page title'), 'description' => t("The text to display in the title bar of a visitor's web browser when they view this page. This meta tag may also be used as the title of the page when a visitor bookmarks or favorites this page."), + 'maxlength' => 0, 'class' => 'DrupalTitleMetaTag', + 'group' => 'basic', 'weight' => ++$weight, ); $info['tags']['description'] = array( 'label' => t('Description'), - 'description' => t("A brief and concise summary of the page's content, preferably 150 characters or less. The description meta tag may be used by search engines to display a snippet about the page in search results."), + 'description' => t("A brief and concise summary of the page's content, preferably 320 characters or less. The description meta tag may be used by search engines to display a snippet about the page in search results."), + 'maxlength' => 380, 'class' => 'DrupalTextMetaTag', + 'group' => 'basic', 'weight' => ++$weight, 'form' => array( '#type' => 'textarea', @@ -153,8 +177,10 @@ function metatag_metatag_info() { $info['tags']['abstract'] = array( 'label' => t('Abstract'), - 'description' => t("A brief and concise summary of the page's content, preferably 150 characters or less. The abstract meta tag may be used by search engines for archiving purposes."), + 'description' => t("A brief and concise summary of the page's content, preferably 150 characters or less. Where as the description meta tag may be used by search engines to display a snippet about the page in search results, the abstract tag may be used to archive a summary about the page. This meta tag is no longer supported by major search engines."), + 'maxlength' => 0, 'class' => 'DrupalTextMetaTag', + 'group' => 'basic', 'weight' => ++$weight, 'form' => array( '#type' => 'textarea', @@ -165,8 +191,10 @@ 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 not supported by most search engines."), + 'description' => t("A comma-separated list of keywords about the page. This meta tag is not supported by most search engines anymore."), + 'maxlength' => 0, 'class' => 'DrupalTextMetaTag', + 'group' => 'basic', 'weight' => ++$weight, ); @@ -185,10 +213,10 @@ function metatag_metatag_info() { '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/'))), + 'noodp' => t('Blocks the Open Directory Project description from appearing in search results.', array('!opendirectory' => 'http://www.dmoz.org/')), 'noydir' => t('Prevents Yahoo! from listing this page in the Yahoo! Directory.', 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.'), + 'notranslate' => t('Prevent search engines from offering to translate this page in search results.'), ), ), ); @@ -196,6 +224,7 @@ function metatag_metatag_info() { $info['tags']['news_keywords'] = array( 'label' => t('Google News Keywords'), 'description' => t('A comma-separated list of keywords about the page. This meta tag is used as an indicator in Google News.', array('@google_news' => 'http://support.google.com/news/publisher/bin/answer.py?hl=en&answer=68297')), + 'maxlength' => 0, 'class' => 'DrupalTextMetaTag', 'group' => 'advanced', 'weight' => ++$weight, @@ -209,6 +238,46 @@ function metatag_metatag_info() { 'weight' => ++$weight, ); + $info['tags']['rating'] = array( + 'label' => t('Content rating'), + 'description' => t('Used to indicate the intended audience for the content.'), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'select_or_other' => TRUE, + 'form' => array( + '#type' => 'select', + '#options' => array( + 'general' => t('General'), + 'mature' => t("Mature"), + 'restricted' => t("Restricted"), + '14 years' => t("14 years or Older"), + 'safe for kids' => t("Safe for kids"), + ), + '#empty_option' => t('- None -'), + ), + 'weight' => ++$weight, + ); + + $info['tags']['referrer'] = array( + 'label' => t('Referrer policy'), + 'description' => t('Indicate to search engines and other page scrapers whether or not links should be followed. See the W3C specifications for further details.'), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'select_or_other' => TRUE, + 'form' => array( + '#type' => 'select', + '#options' => array( + 'no-referrer' => t('No Referrer'), + 'origin' => t('Origin'), + 'no-referrer-when-downgrade' => t('No Referrer When Downgrade'), + 'origin-when-cross-origin' => t('Origin When Cross-Origin'), + 'unsafe-url' => t('Unsafe URL'), + ), + '#empty_option' => t('- None -'), + ), + 'weight' => ++$weight, + ); + $info['tags']['generator'] = array( 'label' => t('Generator'), 'description' => t("Describes the name and version number of the software or publishing tool used to create the page."), @@ -236,6 +305,7 @@ function metatag_metatag_info() { 'class' => 'DrupalLinkMetaTag', 'group' => 'advanced', 'weight' => ++$weight, + 'image' => TRUE, 'devel_generate' => array( 'type' => 'image', ), @@ -252,20 +322,47 @@ function metatag_metatag_info() { ), ); + $info['tags']['set_cookie'] = array( + 'label' => t('Set cookie'), + 'description' => t('Sets a cookie on the visitor\'s browser. Can be in either NAME=VALUE format, or a more verbose format including the path and expiration date; see the link for full details on the syntax.'), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'weight' => ++$weight, + 'is_language' => TRUE, + 'element' => array( + '#theme' => 'metatag_http_equiv', + ), + ); + $info['tags']['shortlink'] = array( 'label' => t('Shortlink URL'), 'description' => t('A brief URL, often created by a URL shortening service.'), 'class' => 'DrupalLinkMetaTag', 'group' => 'advanced', 'weight' => ++$weight, + 'replaces' => array( + 'shorturl', + ), 'devel_generate' => array( 'type' => 'shortlink', ), ); - $info['tags']['publisher'] = array( - 'label' => t('Publisher URL'), + $info['tags']['original-source'] = array( + 'label' => t('Original Source'), 'description' => '', + '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']['prev'] = array( + 'label' => t('Previous page URL'), + 'description' => t('Used for paginated content. Meet Google recommendations to indicate paginated content by providing URL with rel="prev" link.', array('@google_pagination' => 'https://support.google.com/webmasters/answer/1663744')), 'class' => 'DrupalLinkMetaTag', 'group' => 'advanced', 'weight' => ++$weight, @@ -274,9 +371,9 @@ function metatag_metatag_info() { ), ); - $info['tags']['author'] = array( - 'label' => t('Author URL'), - '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."), + $info['tags']['next'] = array( + 'label' => t('Next page URL'), + 'description' => t('Used for paginated content. Meet Google recommendations to indicate paginated content by providing URL with rel="next" link.', array('@google_pagination' => 'https://support.google.com/webmasters/answer/1663744')), 'class' => 'DrupalLinkMetaTag', 'group' => 'advanced', 'weight' => ++$weight, @@ -285,39 +382,104 @@ function metatag_metatag_info() { ), ); - $info['tags']['original-source'] = array( - 'label' => t('Original Source'), - 'description' => '', + $info['tags']['content-language'] = array( + 'label' => t('Content language'), + 'description' => t("Used to define this page's language code. May be the two letter language code, e.g. \"de\" for German, or the two letter code with a dash and the two letter ISO country code, e.g. \"de-AT\" for German in Austria. Still used by Bing."), '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, + 'is_language' => TRUE, + 'element' => array( + '#theme' => 'metatag_http_equiv', + ), + ); + + $info['tags']['geo.position'] = array( + 'label' => t('Geo position'), + 'description' => t('Geo-spatial information in "latitude;longitude" format, e.g. "50.167958;-97.133185"; see Wikipedia for details.'), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'weight' => ++$weight, + ); + + $info['tags']['geo.placename'] = array( + 'label' => t('Geo place name'), + 'description' => t("A location's formal name."), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'weight' => ++$weight, + ); + + $info['tags']['geo.region'] = array( + 'label' => t('Geo region'), + 'description' => t("A location's two-letter international country code, with an optional two-letter region, e.g. \"US-NH\" for New Hampshire in the USA."), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'weight' => ++$weight, + ); + + $info['tags']['icbm'] = array( + 'label' => t('ICBM'), + 'description' => t('Geo-spatial information in "latitude, longitude" format, e.g. "50.167958, -97.133185"; see Wikipedia for details.'), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'weight' => ++$weight, + ); + + $info['tags']['refresh'] = array( + 'label' => t('Refresh'), + 'description' => t('The number of seconds to wait before refreshing the page. May also force redirect to another page using the format "5; url=http://example.com/", which would be triggered after five seconds.'), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_http_equiv', + ), + ); + + $info['tags']['revisit-after'] = array( + 'label' => t('Revisit After'), + '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 XML Sitemap file.', array('@xmlsitemap' => 'https://www.drupal.org/project/xmlsitemap')), + 'class' => 'DrupalDateIntervalMetaTag', + 'group' => 'advanced', 'weight' => ++$weight, 'devel_generate' => array( - 'type' => 'url', + 'type' => 'date', + ), + ); + + $info['tags']['pragma'] = array( + 'label' => t('Pragma'), + 'description' => t('Used to control whether a browser caches a specific page locally. Little used today. Should be used in conjunction with the Cache-Control meta tag.'), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_http_equiv', ), ); - $info['tags']['revisit-after'] = array( - 'label' => t('Revisit After'), - '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 XML Sitemap 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', - ), - ); + $info['tags']['cache-control'] = array( + 'label' => t('Cache-Control'), + 'description' => t('Used to control whether a browser caches a specific page locally. Little used today. Should be used in conjunction with the Pragma meta tag.'), + 'class' => 'DrupalTextMetaTag', + 'group' => 'advanced', + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_http_equiv', + ), + ); + + $info['tags']['expires'] = array( + 'label' => t('Expires'), + 'description' => t("Control when the browser's internal cache of the current page should expire. The date must to be an RFC-1123-compliant date string that is represented in Greenwich Mean Time (GMT), e.g. 'Thu, 01 Sep 2016 00:12:56 GMT'. Set to '0' to stop the page being cached entirely.", array('@rfc' => 'http://www.csgnetwork.com/timerfc1123calc.html')), + 'class' => 'DrupalTextMetaTag', + 'weight' => ++$weight, + 'group' => 'advanced', + 'devel_generate' => array( + 'type' => 'date', + ), + ); return $info; } diff --git a/sites/all/modules/contrib/metatag/metatag.migrate.inc b/sites/all/modules/contrib/metatag/metatag.migrate.inc index a4ef0105..f2c6c383 100644 --- a/sites/all/modules/contrib/metatag/metatag.migrate.inc +++ b/sites/all/modules/contrib/metatag/metatag.migrate.inc @@ -5,20 +5,24 @@ * Metatag support for Migrate. */ +if (!class_exists('MigrateDestinationHandler')) { + return; +} + /** * Basic usage of the Migrate integration. * * This example assumes the custom module's name is "example_migrate". - * + * * example_migrate.inc: - * + * * class MetatagTestMigration extends DynamicMigration { - * + * * public function __construct() { * parent::__construct(); - * + * * $this->description = t('Migrate test.'); - * + * * $this->map = new MigrateSQLMap( * $this->machineName, * array( @@ -31,22 +35,22 @@ * ), * MigrateDestinationNode::getKeySchema() * ); - * + * * $this->source = new MigrateSourceCSV( * drupal_get_path('module', 'example_migrate') . '/sample.csv', * array(), * array('header_rows' => TRUE) * ); - * + * * $this->destination = new MigrateDestinationNode('article'); - * + * * $this->addFieldMapping('metatag_description', 'description'); * $this->addFieldMapping('metatag_keywords', 'keywords'); * } * } - * + * * example_migrate.migrate.inc: - * + * * /** * * Implements hook_migrate_api(). * * / @@ -57,7 +61,7 @@ * 'MetatagTest' => array('class_name' => 'MetatagTestMigration'), * ), * ); - * + * * return $api; * } */ @@ -81,13 +85,13 @@ function metatag_migrate_api() { */ class MigrateMetatagHandler extends MigrateDestinationHandler { + /** + * Identify a list of supported entity types. + */ public function __construct() { - $entity_types = array(); - foreach (entity_get_info() as $entity_type => $entity_info) { - if (isset($entity_info['metatags']) && $entity_info['metatags']) { - $entity_types[] = $entity_type; - } - } + $entity_types = metatag_entity_supports_metatags(); + $entity_types = array_filter($entity_types); + $entity_types = array_keys($entity_types); $this->registerTypes($entity_types); } @@ -116,9 +120,11 @@ class MigrateMetatagHandler extends MigrateDestinationHandler { foreach ($elements['tags'] as $value) { $metatag_field = 'metatag_' . $value['name']; if (isset($entity->$metatag_field)) { - $entity->metatags[$value['name']]['value'] = $entity->$metatag_field; + $language = isset($entity->language) ? $entity->language : LANGUAGE_NONE; + $entity->metatags[$language][$value['name']]['value'] = $entity->$metatag_field; unset($entity->$metatag_field); } } } + } diff --git a/sites/all/modules/contrib/metatag/metatag.module b/sites/all/modules/contrib/metatag/metatag.module index 7f2edd6e..aef85fb7 100644 --- a/sites/all/modules/contrib/metatag/metatag.module +++ b/sites/all/modules/contrib/metatag/metatag.module @@ -1,4 +1,5 @@ -10, ); $items['admin/config/search/metatags/config/add'] = array( - 'title' => 'Add a Metatag default', + 'title' => 'Add default meta tags', 'page callback' => 'drupal_get_form', 'page arguments' => array('metatag_config_add_form'), 'access arguments' => array('administer meta tags'), @@ -186,7 +196,7 @@ function metatag_menu() { 'weight' => 10, ); $items['admin/config/search/metatags/settings'] = array( - 'title' => 'Advanced settings', + 'title' => 'Settings', 'page callback' => 'drupal_get_form', 'page arguments' => array('metatag_admin_settings_form'), 'access arguments' => array('administer meta tags'), @@ -204,6 +214,29 @@ function metatag_menu() { 'file' => 'metatag.admin.inc', ); + // Optional integration with the i18n_string module for translating the + // configurations. Note: this should also check for 'metatag_i18n_disabled' + // but doing so would require rebuilding the menu cache every time the Metatag + // settings page was saved, which may not be advised. Instead the links to + // these pages on the config pages *do* check the variable, which is close + // enough. + if (module_exists('i18n_string')) { + $items['admin/config/search/metatags/config/%metatag_config/translate'] = array( + 'title' => 'Translate', + 'access arguments' => array('administer meta tags'), + 'page callback' => 'i18n_string_object_translate_page', + 'page arguments' => array('metatag_config', 5), + 'type' => MENU_LOCAL_TASK, + ); + $items['admin/config/search/metatags/config/%metatag_config/translate/%i18n_language'] = array( + 'title' => 'Translate', + 'access arguments' => array('administer meta tags'), + 'page callback' => 'i18n_string_object_translate_page', + 'page arguments' => array('metatag_config', 5, 7), + 'type' => MENU_CALLBACK, + ); + } + return $items; } @@ -214,6 +247,147 @@ function metatag_flush_caches() { return array('cache_metatag'); } +/** + * Implements hook_action_info(). + * Provides integration with Views bulk operations. + */ +function metatag_action_info() { + return array( + 'metatag_modify_metatags_action' => array( + 'type' => 'entity', + 'label' => t('Modify entity metatags'), + 'configurable' => FALSE, + 'vbo_configurable' => TRUE, + 'behavior' => array('changes_property'), + 'triggers' => array('any'), + 'permissions' => array('edit meta tags'), + ), + ); +} + +/** + * Updates entity metatags with values from the action form. + * + * @param object $entity + * The entity housing the metatags to modify. + * @param array $context + * Contextual information passed from the View bulk operation configuration + * form. The updated metatag values for the entity are stored in + * $context['updates']. + */ +function metatag_modify_metatags_action($entity, $context) { + if (empty($entity)) { + drupal_set_message(t("Error while trying to update an entity's metatags."), + 'warning', FALSE); + return; + } + + $updates = $context['updates']; + $language = $entity->language; + + // Reset metatags to the entity default configs. + if ($context['reset_default']) { + $instance = $context['entity_type'] . ':' . $entity->type; + $entity_defaults = metatag_config_load_with_defaults($instance); + + // Clean up empty values. + foreach ($entity_defaults as $name => $tag) { + if (empty($tag['value'])) { + unset($entity_defaults[$name]); + } + } + + $entity->metatags[$language] = $entity_defaults; + } + // Otherwise, we're updating existing values. Ensure that the entity has any + // metatags already set. If so then merge the updates to avoid overwriting + // existing values that may exist as an array. E.g. robots. + elseif (!empty($entity->metatags) && !empty($entity->metatags[$language])) { + foreach ($updates as $tag => $value_array) { + if (is_array($updates[$tag]['value']) && !empty($entity->metatags[$language][$tag]['value'])) { + $entity->metatags[$language][$tag]['value'] = array_merge($entity->metatags[$language][$tag]['value'], + array_filter($updates[$tag]['value'])); + } + elseif (!empty($updates[$tag]['value'])) { + $entity->metatags[$language][$tag]['value'] = $updates[$tag]['value']; + } + } + } + // Otherwise just set the net new tags. + else { + $entity->metatags[$language] = $updates; + } + + entity_save($context['entity_type'], $entity); +} + +/** + * The Views bulk operation configuration form for modifying metatags. + * + * @param array $context + * Contextual information passed from the View bulk operation configuration + * form. + * + * @return array + * A form API compatible array. + */ +function metatag_modify_metatags_action_form($context) { + $form = array( + '#entity_type' => $context['entity_type'], + ); + + // There can be multiple instances being edited here. So the 2nd param passed + // here is as generic as possible. + metatag_metatags_form($form, 'global'); + + // Force the metatags tab to be fully visible and save a click from the user. + $form['metatags']['#collapsed'] = FALSE; + $form['metatags']['#collapsible'] = FALSE; + + // If we're reseting to the entity default, then we don't need to show the + // form fields. + $form['metatags']['#states'] = array( + 'visible' => array( + ':input[name="reset_default"]' => array('checked' => FALSE), + ), + ); + + // Add an option to reset selected entities to the default configuration. + $form['reset_default'] = array( + '#type' => 'checkbox', + '#title' => t('Reset to metatag defaults'), + '#default_value' => FALSE, + '#description' => t('Check to fully reset all metatags on + the entities being modified to their default + configuration.', array( + '@settings' => url('admin/config/search/metatags'), + )), + ); + + return $form; +} + +/** + * Submit handler for metatag_modify_metatags_action_form(). Filters out + * the user entered values from the defaults and returns the updated values to + * the $context array. + * + * @return array + * The updated metatag values that is ultimately keyed at $context['updates']. + */ +function metatag_modify_metatags_action_submit($form, &$form_state) { + $updates = $form_state['values']['metatags'][LANGUAGE_NONE]; + $defaults = metatag_config_load_with_defaults($form['#entity_type']); + + // Filter out the true updates. + metatag_filter_values_from_defaults($updates, $defaults); + + return array( + 'updates' => $updates, + 'reset_default' => $form_state['values']['reset_default'], + ); +} + /** * Load a metatag configuration record with all the defaults merged in. * @@ -227,8 +401,12 @@ function metatag_flush_caches() { function metatag_config_load_with_defaults($instance, $include_global = TRUE) { $defaults = &drupal_static(__FUNCTION__, array()); + // Use the current page's locale. + $langcode = $GLOBALS['language_content']->language; + // Statically cache defaults since they can include multiple levels. - $cid = "config:{$instance}" . ($include_global ? ':withglobal' : ':withoutglobal'); + $cid = "config:{$instance}:{$langcode}" . ($include_global ? ':withglobal' : ':withoutglobal'); + if (!isset($defaults[$cid])) { if ($cache = metatag_cache_get($cid)) { $defaults[$cid] = $cache->data; @@ -275,7 +453,7 @@ function metatag_config_load_multiple(array $instances) { // "Fix" any records that might be using old values. Ideally these will be // permanently fixed by being re-saved or re-exported. foreach (metatag_config_get_replacements() as $old_tag => $new_tag) { - foreach ($configs as $config_name => $config) { + foreach ($configs as $instance => $config) { if (isset($config->config[$old_tag])) { $config->config[$new_tag] = $config->config[$old_tag]; unset($config->config[$old_tag]); @@ -283,6 +461,29 @@ function metatag_config_load_multiple(array $instances) { } } + // Translate the configuration. + if (module_exists('i18n_string') && !variable_get('metatag_i18n_disabled', FALSE)) { + $options = array(); + + // By default disable the watchdog logging of translation messages. + $options['watchdog'] = variable_get('metatag_i18n_enable_watchdog', FALSE); + + foreach ($configs as $instance => &$config) { + foreach ($config->config as $tag => &$value) { + if (isset($value['value']) && is_string($value['value'])) { + $value['value'] = i18n_string_translate(array( + 'metatag', + 'metatag_config', + $instance, + $tag, + ), + $value['value'], + $options); + } + } + } + } + return $configs; } @@ -320,16 +521,6 @@ function metatag_config_save($config) { // hook_metatag_config_presave(). module_invoke_all('metatag_config_presave', $config); - // Update the i18n string - if (function_exists('i18n_string_update')) { - $instance = $config->instance; - - foreach ($config->config as $field => $item) { - $name = "metatag:" . $instance . ":" . $field; - i18n_string_update($name, $item['value']); - } - } - if ($config->is_new) { drupal_write_record('metatag_config', $config); @@ -354,11 +545,15 @@ function metatag_config_save($config) { /** * Delete a metatag configuration record. */ -function metatag_config_delete($instance) { +function metatag_config_delete($config) { db_delete('metatag_config') - ->condition('instance', $instance) + ->condition('instance', $config->instance) ->execute(); + // Allow modules to act upon the record deletion using + // hook_metatag_config_delete(). + module_invoke_all('metatag_config_delete', $config); + // Clear any caches. metatag_config_cache_clear(); } @@ -369,8 +564,9 @@ function metatag_config_delete($instance) { function metatag_config_cache_clear() { cache_clear_all('*', 'cache_metatag', TRUE); drupal_static_reset('metatag_config_load_with_defaults'); - drupal_static_reset('metatag_entity_has_metatags'); drupal_static_reset('metatag_entity_supports_metatags'); + drupal_static_reset('metatag_config_instance_info'); + drupal_static_reset('metatag_get_info'); ctools_include('export'); ctools_export_load_object_reset('metatag_config'); } @@ -378,37 +574,72 @@ function metatag_config_cache_clear() { /** * Load an entity's tags. * - * @param $entity_type + * @param string $entity_type * The entity type to load. - * @param $entity_id + * @param int $entity_id * The ID of the entity to load. + * @param mixed $revision_id + * Optional revision ID to load instead of the entity ID. * - * @return - * An array of tag data keyed by revision ID and language. + * @return array + * An array of tag data keyed by language for the entity's current active + * revision. */ -function metatag_metatags_load($entity_type, $entity_id) { - $metatags = metatag_metatags_load_multiple($entity_type, array($entity_id)); - return !empty($metatags) ? reset($metatags) : array(); +function metatag_metatags_load($entity_type, $entity_id, $revision_id = NULL) { + // A specific revision ID was not requested, so get the active revision ID. + if (is_null($revision_id)) { + // Unfortunately, the only way of getting the active revision ID is to + // first load the entity, and then extract the ID. This is a bit + // performance intensive, but it seems to be the only way of doing it. + $entities = entity_load($entity_type, array($entity_id)); + if (!empty($entities[$entity_id])) { + // We only care about the revision_id. + list(, $revision_id,) = entity_extract_ids($entity_type, $entities[$entity_id]); + } + } + + // This returns an array nested by the entity ID, the revision ID and the + // langcode. + $metatags = metatag_metatags_load_multiple($entity_type, array($entity_id), array($revision_id)); + + // Look for records for the requested revision ID. + if (isset($metatags[$entity_id][$revision_id])) { + return $metatags[$entity_id][$revision_id]; + } + + // Getting to this point means that no meta tags were identified earlier, so + // return an empty array. + return array(); } /** * Load tags for multiple entities. * - * @param $entity_type + * @param string $entity_type * The entity type to load. - * @param $entity_ids + * @param array $entity_ids * The list of entity IDs. + * @param array $revision_ids + * Optional revision ID to load instead of the entity ID. * - * @return + * @return array * An array of tag data, keyed by entity ID, revision ID and language. */ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $revision_ids = array()) { - // Double check entity IDs are numeric thanks to Entity API module. + // Double check entity IDs are all numeric. $entity_ids = array_filter($entity_ids, 'is_numeric'); if (empty($entity_ids)) { return array(); } + // Ensure that the revision IDs are all numeric too. + $revision_ids = array_filter($revision_ids, 'is_numeric'); + + // Verify that there aren't any empty values copied in from + // metatag_metatags_load(). Note: a zero indicates that the entity record does + // not support revisions, so this is ok to do. + $revision_ids = array_filter($revision_ids); + // Also need to check if the metatag table exists since this condition could // fire before the table has been installed yet. if (!variable_get('metatag_schema_installed', FALSE)) { @@ -436,9 +667,7 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $ // Get all translations of tag data for this entity. $query = db_select('metatag', 'm') ->fields('m', array('entity_id', 'revision_id', 'language', 'data')) - ->condition('m.entity_type', $entity_type) - ->orderBy('entity_id') - ->orderBy('revision_id'); + ->condition('m.entity_type', $entity_type); // Filter by revision_ids if they are available. If not, filter by entity_ids. if (!empty($revision_ids)) { $query->condition('m.revision_id', $revision_ids, 'IN'); @@ -472,41 +701,67 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $ /** * Save an entity's tags. * - * @param $entity_type - * The entity type to load - * @param $entity_id - * The entity's ID - * @param $revision_id - * The entity's VID. - * @param $metatags - * All of the tag information - * @param $language - * The language of the translation set - */ -function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $langcode, $old_vid = NULL) { - // If no language assigned, or the language doesn't exist, use the - // has-no-language language. - $languages = language_list(); - if (empty($langcode) || !isset($languages[$langcode])) { - $langcode = LANGUAGE_NONE; - } - + * @param string $entity_type + * The entity type to load. + * @param int $entity_id + * The entity's primary ID. + * @param int $revision_id + * The entity's revision ID. + * @param array $metatags + * All of the tag information, keyed by the language code. Most meta tags use + * the 'value' element, so the structure should look like: + * array( + * LANGUAGE_NONE => array( + * 'title' => array( + * 'value' => "This node's title!", + * ), + * 'og:title' => array( + * 'value' => "This node's title for Open Graph!", + * ), + * 'og:image' => array( + * 'value' => "[node:field_thumbnail]", + * ), + * ), + * ); + * @param string|null $bundle + * The bundle of the entity that is being saved. Optional. + */ +function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $bundle = NULL) { // Check that $entity_id is numeric because of Entity API and string IDs. if (!is_numeric($entity_id)) { return; } + // Don't do anything if the entity type is not supported. + if (!metatag_entity_supports_metatags($entity_type)) { + return; + } + + // Verify the entity bundle is supported, if not available just check the + // entity type. + if (!empty($bundle)) { + if (!metatag_entity_supports_metatags($entity_type, $bundle)) { + return; + } + } + else { + if (!metatag_entity_supports_metatags($entity_type)) { + return; + } + } + // The revision_id must be a numeric value; some entities use NULL for the // revision so change that to a zero. if (is_null($revision_id)) { $revision_id = 0; } - // Handle scenarios where the metatags are completely empty. + // Handle scenarios where the metatags are completely empty, this will have + // the effect of erasing the meta tags for those this entity. if (empty($metatags)) { $metatags = array(); // Add an empty array record for each language. - $languages = db_query("SELECT language, '' + $languages = db_query("SELECT language FROM {metatag} WHERE (entity_type = :type) AND (entity_id = :id) @@ -515,8 +770,8 @@ function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags ':type' => $entity_type, ':id' => $entity_id, ':revision' => $revision_id, - ))->fetchAllKeyed(); - foreach ($languages as $oldlang => $empty) { + ))->fetchCol(); + foreach ($languages as $oldlang) { $metatags[$oldlang] = array(); } } @@ -558,18 +813,21 @@ function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags // Clear cached data. metatag_metatags_cache_clear($entity_type, $entity_id); + + // Clear the entity cache. + entity_get_controller($entity_type)->resetCache(array($entity_id)); } /** * Delete an entity's tags. * - * @param $entity_type - * The entity type - * @param $entity_id - * The entity's ID - * @param $revision_id + * @param string $entity_type + * The entity type. + * @param int $entity_id + * The entity's ID. + * @param int $revision_id * The entity's VID. - * @param $langcode + * @param string $langcode * The language ID of the entry to delete. If left blank, all language * entries for this entity will be deleted. */ @@ -584,21 +842,25 @@ function metatag_metatags_delete($entity_type, $entity_id, $revision_id = NULL, /** * Delete multiple entities' tags. * - * @param $entity_type - * The entity type - * @param $entity_ids - * The list of IDs - * @param $revision_id - * An optional list of VIDs, if omitted all revisions will be deleted. - * @param $langcode + * @param string $entity_type + * The entity type. + * @param array $entity_ids + * The list of IDs. + * @param array $revision_ids + * An optional list of revision IDs; if omitted all revisions will be deleted. + * @param string $langcode * The language ID of the entities to delete. If left blank, all language * entries for the enities will be deleted. + * + * @return bool + * If any problems were encountered will return FALSE, otherwise TRUE. */ function metatag_metatags_delete_multiple($entity_type, array $entity_ids, array $revision_ids = array(), $langcode = NULL) { - // Double check entity IDs are numeric thanks to Entity API module. + // Double check entity IDs and revision IDs are numeric. $entity_ids = array_filter($entity_ids, 'is_numeric'); + $revision_ids = array_filter($revision_ids, 'is_numeric'); - if ($metatags = metatag_metatags_load_multiple($entity_type, $entity_ids, $revision_ids)) { + if (!empty($entity_ids) || !empty($revision_ids)) { $transaction = db_transaction(); try { // Let other modules know about the records being deleted using @@ -607,15 +869,18 @@ function metatag_metatags_delete_multiple($entity_type, array $entity_ids, array // Set the entity to delete. $query = db_delete('metatag') - ->condition('entity_type', $entity_type) - ->condition('entity_id', $entity_ids, 'IN'); + ->condition('entity_type', $entity_type); - // Optionally delete a specific revision. + // If revision IDs were specified then just use those in the query. if (!empty($revision_ids)) { $query->condition('revision_id', $revision_ids, 'IN'); } + // No revision IDs were specified, so work from the entity IDs. + else { + $query->condition('entity_id', $entity_ids, 'IN'); + } - // Specify a language if there is one. + // Limit to a language if one was specified. if (!empty($langcode)) { $query->condition('language', $langcode); } @@ -625,6 +890,11 @@ function metatag_metatags_delete_multiple($entity_type, array $entity_ids, array // Clear cached data. metatag_metatags_cache_clear($entity_type, $entity_ids); + + // Clear the caches for these entities. + entity_get_controller($entity_type)->resetCache($entity_ids); + + return TRUE; } catch (Exception $e) { $transaction->rollback(); @@ -632,6 +902,11 @@ function metatag_metatags_delete_multiple($entity_type, array $entity_ids, array throw $e; } } + else { + watchdog('metatag', 'No entity IDs or revision IDs were submitted to metatag_metatags_delete_multiple().'); + } + + return FALSE; } /** @@ -649,7 +924,7 @@ function metatag_metatags_cache_clear($entity_type, $entity_ids = NULL) { $entity_ids = array($entity_ids); } foreach ($entity_ids as $entity_id) { - cache_clear_all("output:$entity_type:$entity_id", 'cache_metatag', TRUE); + cache_clear_all("output:$entity_type:$entity_id", 'cache_metatag'); } } } @@ -658,32 +933,60 @@ function metatag_metatags_cache_clear($entity_type, $entity_ids = NULL) { * Implements hook_entity_load(). */ function metatag_entity_load($entities, $entity_type) { - // Get the revision_ids. - $revision_ids = array(); - foreach ($entities as $key => $entity) { - list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); - $revision_id = intval($revision_id); - if (!empty($revision_id)) { - $revision_ids[] = $revision_id; - } - } - // Wrap this in a try-catch block to work around occasions when the schema // hasn't been updated yet. try { if (metatag_entity_supports_metatags($entity_type)) { - $metatags = metatag_metatags_load_multiple($entity_type, array_keys($entities), $revision_ids); + // Get the revision_ids. + $revision_ids = array(); + + // Track the entity IDs for values to load. + $entity_ids = array(); + + // Some entities don't support revisions. + $supports_revisions = TRUE; + + // Extract the revision ID and verify the entity's bundle is supported. + foreach ($entities as $key => $entity) { + list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); + + // Verify that each entity bundle supports Metatag. + if (metatag_entity_supports_metatags($entity_type, $bundle)) { + $entity_ids[] = $entity_id; + + if (!empty($revision_id)) { + $revision_ids[] = $revision_id; + } + } + } - // Assign the metatag records for the correct revision ID. - foreach ($entities as $entity_id => $entity) { - list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); - $revision_id = intval($revision_id); - $entities[$entity_id]->metatags = isset($metatags[$entity_id][$revision_id]) ? $metatags[$entity_id][$revision_id] : array(); + // Only proceed if either there were revision IDs identified, or the + // entity doesn't support revisions anyway. + if (!empty($entity_ids)) { + // Load all meta tags for these entities. + $metatags = metatag_metatags_load_multiple($entity_type, $entity_ids, $revision_ids); + + // Assign the metatag records for the correct revision ID. + if (!empty($metatags)) { + foreach ($entities as $entity_id => $entity) { + list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); + $revision_id = intval($revision_id); + $entities[$entity_id]->metatags = isset($metatags[$entity_id][$revision_id]) ? $metatags[$entity_id][$revision_id] : array(); + } + } } } } catch (Exception $e) { - watchdog('metatag', 'Error loading meta tag data, do the database updates need to be run? The error occurred when loading record(s) %ids for the %type entity type. The error message was: %error', array('@update' => base_path() . 'update.php', '%ids' => implode(', ', array_keys($entities)), '%type' => $entity_type, '%error' => $e->getMessage()), WATCHDOG_WARNING); + watchdog('metatag', 'Error loading meta tag data, do the database updates need to be run? The error occurred when loading record(s) %ids for the %type entity type. The error message was: %error', + array( + '@update' => base_path() . 'update.php', + '%ids' => implode(', ', array_keys($entities)), + '%type' => $entity_type, + '%error' => $e->getMessage(), + ), + WATCHDOG_WARNING); + // Don't display the same message twice for Drush. if (drupal_is_cli()) { drupal_set_message(t('Run your updates, like drush updb.')); @@ -700,7 +1003,13 @@ function metatag_entity_load($entities, $entity_type) { */ function metatag_entity_insert($entity, $entity_type) { if (isset($entity->metatags)) { - list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); + list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); + + // Verify that this entity type / bundle is supported. + if (!metatag_entity_supports_metatags($entity_type, $bundle)) { + return; + } + $revision_id = intval($revision_id); // Determine the entity's language. @@ -725,12 +1034,12 @@ function metatag_entity_insert($entity, $entity_type) { unset($entity->metatags[LANGUAGE_NONE]); } - // Support for Workbench Moderation v1. + // Support for Workbench Moderation. if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) { return; } - metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $langcode); + metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle); } } @@ -738,11 +1047,13 @@ function metatag_entity_insert($entity, $entity_type) { * Implements hook_entity_update(). */ function metatag_entity_update($entity, $entity_type) { - if (!metatag_entity_supports_metatags($entity_type)) { + list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); + + // If this entity object isn't allowed meta tags, don't continue. + if (!metatag_entity_supports_metatags($entity_type, $bundle)) { return; } - list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); $revision_id = intval($revision_id); if (isset($entity->metatags)) { @@ -783,14 +1094,13 @@ function metatag_entity_update($entity, $entity_type) { } } - // Support for Workbench Moderation v1. + // Support for Workbench Moderation. if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) { return; } // Save the record. - $old_vid = isset($entity->old_vid) ? $entity->old_vid : NULL; - metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $new_language, $old_vid); + metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle); } else { // Still ensure the meta tag output is cached. @@ -815,6 +1125,25 @@ function metatag_field_attach_delete_revision($entity_type, $entity) { metatag_metatags_delete($entity_type, $entity_id, $revision_id); } +/** + * Build and alter metatag instance name. + * + * @param object $entity + * The entity object to generate the metatags instance name for. + * @param string $entity_type + * The entity type of the entity. + * @param string $bundle + * The bundle of the entity. + * + * @return string + * The resulting name of the config instance. + */ +function metatag_get_entity_metatags_instance($entity, $entity_type, $bundle) { + $instance = "{$entity_type}:{$bundle}"; + drupal_alter('metatag_get_entity_metatags_instance', $instance, $entity, $entity_type, $bundle); + return $instance; +} + /** * Implements hook_entity_view(). * @@ -822,11 +1151,20 @@ function metatag_field_attach_delete_revision($entity_type, $entity) { * around problems elsewhere in the APIs. */ function metatag_entity_view($entity, $entity_type, $view_mode, $langcode, $force = FALSE) { - // Only run this function once per page load. + // Only run this function once per page load, for an entity which is allowed + // metatags. static $i_will_say_this_only_once = FALSE; // Only proceed if this entity object is the page being viewed. if (_metatag_entity_is_page($entity_type, $entity)) { + // Get the entity's extra information. + list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); + + // If this entity object isn't allowed meta tags, don't continue. + if (!metatag_entity_supports_metatags($entity_type, $bundle)) { + return; + } + // Some API calls need to force the data loading. if (!$force) { // Only run this function once per page load. @@ -844,8 +1182,7 @@ function metatag_entity_view($entity, $entity_type, $view_mode, $langcode, $forc // Generate metatags output. if ($output = metatag_generate_entity_metatags($entity, $entity_type, $langcode, $view_mode)) { - list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); - $instance = "{$entity_type}:{$bundle}"; + $instance = metatag_get_entity_metatags_instance($entity, $entity_type, $bundle); // We need to register the term's metatags, so we can later fetch them. // @see metatag_page_build(). metatag_page_set_metatags($instance, $output); @@ -868,22 +1205,24 @@ function metatag_entity_view($entity, $entity_type, $view_mode, $langcode, $forc * TRUE if metatags can be loaded from and saved to the cache. FALSE if the * cache should be bypassed. * - * @return array + * @return mixed * A renderable array of metatags for the given entity. + * If this entity object isn't allowed meta tags, return FALSE (empty). */ function metatag_generate_entity_metatags($entity, $entity_type, $langcode = NULL, $view_mode = 'full', $cached = TRUE) { + // Obtain some details of the entity that are needed elsewhere. + list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); + // If this entity object isn't allowed meta tags, don't continue. - if (!metatag_entity_has_metatags($entity_type, $entity)) { - return array(); + if (!metatag_entity_supports_metatags($entity_type, $bundle)) { + return; } - // Obtain some details of the entity that are needed elsewhere. - list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); $revision_id = intval($revision_id); // Check if a specific metatag config exists, otherwise just use the global // one, stripping out the bundle. - $instance = "{$entity_type}:{$bundle}"; + $instance = metatag_get_entity_metatags_instance($entity, $entity_type, $bundle); if (!metatag_config_load_with_defaults($instance, FALSE)) { $instance = "{$entity_type}"; } @@ -920,9 +1259,17 @@ function metatag_generate_entity_metatags($entity, $entity_type, $langcode = NUL } $cid = FALSE; - if ($cached) { + $key = FALSE; + $metatag_variants = array(); + + // Caching is enabled. + if ($cached && variable_get('metatag_cache_output', FALSE)) { + // All possible variants of the metatags for this entity are stored in a + // single cache entry. + $cid = "output:$entity_type:$entity_id"; + // All applicable pieces for this current page. - $cid_parts = array( + $key_parts = array( 'entity_type' => $entity_type, 'bundle' => $bundle, 'entity_id' => $entity_id, @@ -933,12 +1280,19 @@ function metatag_generate_entity_metatags($entity, $entity_type, $langcode = NUL 'language_content' => $GLOBALS['language_content']->language, 'view_mode' => $view_mode, ); - $cid = metatag_cache_default_cid_parts($cid_parts); + $key = metatag_cache_default_cid_parts($key_parts); + + if ($cache = metatag_cache_get($cid)) { + $metatag_variants = $cache->data; + } } - if ($cid && $cache = metatag_cache_get($cid)) { - $output = $cache->data; + // If a cached object exists for this key, return it. + if (!empty($key) && isset($metatag_variants[$key])) { + $output = $metatag_variants[$key]; } + + // Otherwise, generate the output tags. else { // Separate the meta tags. $metatags = isset($entity->metatags) ? $entity->metatags : array(); @@ -949,22 +1303,27 @@ function metatag_generate_entity_metatags($entity, $entity_type, $langcode = NUL 'entity_type' => $entity_type, 'view_mode' => $view_mode, ); + // Ensure we actually pass a language object rather than language code. $languages = language_list(); if (isset($languages[$langcode])) { $options['language'] = $languages[$langcode]; } - // Reload the entity object from cache as it may have been altered. - $token_type = token_get_entity_mapping('entity', $entity_type); - $entities = entity_load($entity_type, array($entity_id)); - $options['token data'][$token_type] = $entities[$entity_id]; - $options['entity'] = $entities[$entity_id]; + // Include token replacement data. Don't reload the entity object as doing + // so would conflict with content editorial workflows. + if (!empty($entity_id)) { + $token_type = token_get_entity_mapping('entity', $entity_type); + $options['token data'][$token_type] = $entity; + } // Render the metatags and save to the cache. $output = metatag_metatags_view($instance, $metatags, $options); - if ($cid) { - metatag_cache_set($cid, $output); + + // If output caching is enabled, store the data for later. + if (!empty($key) && !empty($cid)) { + $metatag_variants[$key] = $output; + metatag_cache_set($cid, $metatag_variants); } } @@ -1013,6 +1372,10 @@ function metatag_metatags_view($instance, array $metatags = array(), array $opti $options['language'] = isset($languages[$options['language']]) ? $languages[$options['language']] : NULL; } + if (empty($options['language'])) { + $options['language'] = $GLOBALS['language_content']; + } + // If there are any tags, determine the translation to display. if (!empty($metatags)) { // Get the display language; default to the entity's language. @@ -1033,10 +1396,17 @@ function metatag_metatags_view($instance, array $metatags = array(), array $opti $options['instance'] = $instance; + // Don't output meta tags that only contain the pager. + $current_pager = metatag_get_current_pager(); + foreach ($metatags as $metatag => $data) { if ((!empty($data['value']) || (isset($data['value']) && is_numeric($data['value']))) && $metatag_instance = metatag_get_instance($metatag, $data)) { - $output[$metatag] = $metatag_instance->getElement($options); + $tag_output = $metatag_instance->getElement($options); + // Don't output the pager if that's all there is. + if ($tag_output != $current_pager) { + $output[$metatag] = $tag_output; + } } } @@ -1047,6 +1417,26 @@ function metatag_metatags_view($instance, array $metatags = array(), array $opti return $output; } +/** + * Get the pager string for the current page. + * + * @return string + * Returns a string based upon the 'metatag_pager_string' variable and the + * current page number. + */ +function metatag_get_current_pager() { + if (isset($_GET['page']) && !empty($_GET['page']) && is_numeric($_GET['page'])) { + $page = intval($_GET['page']) + 1; + if ($page > 1) { + $pager = variable_get('metatag_pager_string', 'Page PAGER | '); + return str_replace('PAGER', $page, $pager); + } + } +} + +/** + * Returns metatags values. + */ function metatag_metatags_values($instance, array $metatags = array(), array $options = array()) { $values = array(); @@ -1095,8 +1485,19 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( // Work out the language code to use, default to NONE. $langcode = LANGUAGE_NONE; - if (isset($form['#entity_type']) && isset($form['#entity'])) { - $langcode = metatag_entity_get_language($form['#entity_type'], $form['#entity']); + if (!empty($form['#entity_type'])) { + if (!empty($form['#entity'])) { + $langcode = metatag_entity_get_language($form['#entity_type'], $form['#entity']); + } + else { + $entity_info = entity_get_info($form['#entity_type']); + if (!empty($entity_info['token type'])) { + $entity_key = '#' . $entity_info['token type']; + if (!empty($form[$entity_key])) { + $langcode = metatag_entity_get_language($form['#entity_type'], $form[$entity_key]); + } + } + } } // Merge in the default options. @@ -1106,6 +1507,10 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( 'instance' => $instance, ); + // Trigger hook_metatag_token_types_alter(). + // Allow the defined tokens to be modified. + drupal_alter('metatag_token_types', $options); + $form['metatags'] = array( '#type' => 'fieldset', '#title' => t('Meta tags'), @@ -1128,13 +1533,13 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( ); // Show a different intro message for entity pages vs config pages. if (isset($form['#entity'])) { - $form['metatags'][$langcode]['intro_text'] = array( + $form['metatags']['intro_text'] = array( '#markup' => '

' . t('Configure the meta tags below. Tokens, e.g. "[node:summary]", automatically insert the corresponding information from that field or value, which helps to avoid redundant meta data and possible search engine penalization; see the "Browse available tokens" popup for more details.') . '

', '#weight' => -10, ); } else { - $form['metatags'][$langcode]['intro_text'] = array( + $form['metatags']['intro_text'] = array( '#markup' => '

' . t('Configure the meta tags below. Use tokens (see the "Browse available tokens" popup) to avoid redundant meta data and search engine penalization. For example, a \'keyword\' value of "example" will be shown on all content using this configuration, whereas using the [node:field_keywords] automatically inserts the "keywords" values from the current entity (node, term, etc).') . '

', '#weight' => -10, ); @@ -1171,9 +1576,16 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( // Get the form element from the meta tag class. $metatag_form = $metatag_instance->getForm($options); + if (isset($metatag_form['value']['#default_value']) && is_array($metatag_form['value']['#default_value'])) { + $metatag_form['value']['#default_value'] = array_filter($metatag_form['value']['#default_value']); + } // Add a default value form element. if (isset($options['defaults'][$metatag]['value'])) { + if (is_array($options['defaults'][$metatag]['value'])) { + $options['defaults'][$metatag]['value'] = array_filter($options['defaults'][$metatag]['value']); + } + $metatag_form['default'] = array( '#type' => 'hidden', '#value' => $options['defaults'][$metatag]['value'], @@ -1194,13 +1606,15 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( $group = $info['groups'][$group_key] + array('form' => array(), 'description' => NULL); $form['metatags'][$langcode][$group_key] = $group['form'] + array( '#type' => 'fieldset', - '#title' => check_plain($group['label']), - '#description' => filter_xss($group['description']), + '#title' => $group['label'], + '#description' => !empty($group['description']) ? $group['description'] : '', '#collapsible' => TRUE, '#collapsed' => TRUE, ); } - $form['metatags'][$langcode][$group_key][$metatag] = $metatag_form + array('#parents' => array('metatags', $langcode, $metatag)); + $form['metatags'][$langcode][$group_key][$metatag] = $metatag_form + array( + '#parents' => array('metatags', $langcode, $metatag), + ); // Hide the fieldset itself if there is not at least one of the meta tag // fields visible. @@ -1229,14 +1643,20 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( // Check the #access of each group. If it passed, we display options for // tokens. By this we update the #description of each group. if ($form['metatags']['#access']) { - // Built the token list. - $token_listing_link = theme('token_tree', array('token_types' => $options['token types'], 'dialog' => TRUE)); - - // Add the token list to the top of the fieldset. - $form['metatags'][$langcode]['#description'] = $token_listing_link; - // Check if each meta tag group is being displayed. if (!empty($group_metatag_access)) { + // Built the token browser link. For value "all" theme_token_tree() + // compares with string, not array. + if (in_array('all', $options['token types'])) { + $options['token types'] = 'all'; + } + $token_listing_link = theme('token_tree', + array( + 'token_types' => $options['token types'], + 'dialog' => TRUE, + ) + ); + foreach ($group_metatag_access as $group_key => $token_access) { if ($token_access) { // Update the description. @@ -1246,16 +1666,23 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array( else { $form['metatags'][$langcode][$group_key]['#description'] = ''; } + + // Add the token browser popup link. $form['metatags'][$langcode][$group_key]['#description'] .= $token_listing_link; } } } } - // Add a submit handler to compare the submitted values against the deafult + // Add a submit handler to compare the submitted values against the default // values. $form += array('#submit' => array()); - array_unshift($form['#submit'], 'metatag_metatags_form_submit'); + if (module_exists('commerce') && isset($form['#entity_type']) && $form['#entity_type'] == 'commerce_product') { + $form['actions']['submit']['#submit'][] = 'metatag_commerce_product_form_submit'; + } + else { + array_unshift($form['#submit'], 'metatag_metatags_form_submit'); + } } /** @@ -1288,191 +1715,193 @@ function metatag_metatags_form_submit($form, &$form_state) { } } +/** + * Form API submission callback for Commerce product. + * + * Unlike metatag_metatags_form_submit. + * + * @see metatag_metatags_save() + */ +function metatag_commerce_product_form_submit($form, &$form_state) { + // Trigger the normal meta tag form submission. + metatag_metatags_form_submit($form, $form_state); + + // The entity being saved. + $entity_type = 'commerce_product'; + $product = $form_state[$entity_type]; + $entity_id = $product->product_id; + $revision_id = $product->revision_id; + + // Get the full entity details. + list(, , $bundle) = entity_extract_ids($entity_type, $product); + + // Update the meta tags for this entity type. + metatag_metatags_save($entity_type, $entity_id, $revision_id, $form_state['values']['metatags'], $bundle); +} + /** * Implements hook_field_extra_fields(). */ function metatag_field_extra_fields() { $extra = array(); foreach (entity_get_info() as $entity_type => $entity_info) { - foreach (array_keys($entity_info['bundles']) as $bundle) { - if (metatag_entity_supports_metatags($entity_type, $bundle)) { - $extra[$entity_type][$bundle]['form']['metatags'] = array( - 'label' => t('Meta tags'), - 'description' => t('Meta tag module form elements.'), - 'weight' => 40, - ); + if (!empty($entity_info['bundles'])) { + foreach (array_keys($entity_info['bundles']) as $bundle) { + if (metatag_entity_supports_metatags($entity_type, $bundle)) { + $extra[$entity_type][$bundle]['form']['metatags'] = array( + 'label' => t('Meta tags'), + 'description' => t('Meta tag module form elements.'), + 'weight' => 40, + ); + } } } } return $extra; } -/** - * Check if an individual entity has meta tags defined, or has defaults. - * - * @param string $entity_type - * An entity type. - * @param object $entity - * An entity object. - * - * @return boolean - * TRUE or FALSE if the entity should have a form for or process meta tags. - */ -function metatag_entity_has_metatags($entity_type, $entity) { - // If an entity has custom meta tags assigned, then we should return TRUE. - if (!empty($entity->metatags)) { - return TRUE; - } - - // Otherwise, check to see if there exists any enabed configuration for - // either the entity type, or bundle (even if the configuration is empty). - // If no configuration exists, then we should not be displaying the meta tag - // forms or processing meta tags on entity view. - $config_exists = &drupal_static(__FUNCTION__, array()); - list( , , $bundle) = entity_extract_ids($entity_type, $entity); - // Do not pretend to have metatags when the bundle does not support them. - if (!metatag_entity_supports_metatags($entity_type, $bundle)) { - return FALSE; - } - $instance = "{$entity_type}:{$bundle}"; - if (!isset($config_exists[$instance])) { - // Check if the intstance or its parents (excluding global) are enabled. - $config_exists[$instance] = metatag_config_is_enabled($instance, TRUE, FALSE); - } - - return !empty($config_exists[$instance]); -} - /** * Check whether the requested entity type (and bundle) support metatag. * - * By default this will be FALSE, support has to be specifically enabled by - * assigning 'metatag' => TRUE within the hook_entity_info() definition for the - * entity. + * By default the entities are disabled, only certain entities will have been + * enabled during installation. If an entity type is enabled it is assumed that + * the entity bundles will also be enabled by default. + * + * @see metatag_entity_type_is_suitable() */ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) { $entity_types = &drupal_static(__FUNCTION__); + // Identify which entities & bundles are supported the first time the + // function is called. if (!isset($entity_types)) { - $entity_types = array(); - foreach (entity_get_info() as $entity_type_key => $entity_info) { - if (empty($entity_info['metatags'])) { - $entity_types[$entity_type_key] = FALSE; - continue; - } - $entity_types[$entity_type_key] = array(); - foreach ($entity_info['bundles'] as $bundle_key => $bundle_info) { - $entity_types[$entity_type_key][$bundle_key] = !isset($bundle_info['metatags']) || !empty($bundle_info['metatags']); - } + foreach (entity_get_info() as $entity_name => $entity_info) { + // Verify that this entity type is suitable. + $entity_types[$entity_name] = metatag_entity_type_is_suitable($entity_name, $entity_info); + + // The entity type technically supports entities. + if (!empty($entity_types[$entity_name])) { + // Entiy types are enabled by default. + // Allow entities to be disabled by assigning a variable + // 'metatag_enable_{$entity_type}' the value FALSE, e.g.: + // + // // Disable metatags for file_entity. + // $conf['metatag_enable_file'] = FALSE; + // + // @see Settings page. + if (variable_get('metatag_enable_' . $entity_name, FALSE) == FALSE) { + $entity_types[$entity_name] = FALSE; + } + + // Check each bundle. + else { + $entity_types[$entity_name] = array(); + foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) { + // If only one bundle exists, take configuration for entity, to + // reflect options as they are available in the UI. + if (count($entity_info['bundles']) === 1) { + $entity_types[$entity_name][$bundle_name] = variable_get('metatag_enable_' . $entity_name, FALSE) == TRUE; + continue; + } + + // Allow bundles to be disabled by assigning a variable + // 'metatag_enable_{$entity_type}__{$bundle}' the value FALSE, e.g.: + // + // // Disable metatags for carousel nodes. + // $conf['metatag_enable_node__carousel'] = FALSE; + // + // @see Settings page. + if (variable_get('metatag_enable_' . $entity_name . '__' . $bundle_name, TRUE) == FALSE) { + $entity_types[$entity_name][$bundle_name] = FALSE; + } + else { + $entity_types[$entity_name][$bundle_name] = TRUE; + } + } + } + } } } - if (isset($entity_type) && isset($bundle)) { - // Allow entities to be disabled by assigning a variable - // 'metatag_enable_{$entity_type}__{$bundle}' the value FALSE, e.g.: - // - // // Disable metatags for carousel nodes. - // $conf['metatag_enable_node__carousel'] = FALSE; - // - // @see Advanced settings page. - if (variable_get('metatag_enable_' . $entity_type . '__' . $bundle, 'monkey') == FALSE) { - return FALSE; + // It was requested to check a specific entity. + if (isset($entity_type)) { + // It was also requested to check a specific bundle for this entity. + if (isset($bundle)) { + $supported = !empty($entity_types[$entity_type][$bundle]); } - return isset($entity_types[$entity_type][$bundle]) ? $entity_types[$entity_type][$bundle] : FALSE; - } - elseif (isset($entity_type)) { - // Allow entities to be disabled by assigning a variable - // 'metatag_enable_{$entity_type}' the value FALSE, e.g.: - // - // // Disable metatags for file_entity. - // $conf['metatag_enable_file'] = FALSE; - // - // @see Advanced settings page. - if (variable_get('metatag_enable_' . $entity_type, 'monkey') == FALSE) { - return FALSE; + // Check the entity. + else { + $supported = !empty($entity_types[$entity_type]); } - return isset($entity_types[$entity_type]) ? ($entity_types[$entity_type] !== FALSE) : FALSE; + return $supported; } + // If nothing specific was requested, return the complete list of supported + // entities & bundles. return $entity_types; } /** - * Implements hook_entity_info_alter(). + * Enable support for a specific entity type if setting does not exist. * - * Enables Metatag support for the core entities. + * @param string $entity_type + * The entity type. + * @param string $bundle + * The bundle of the entity. + * @param bool $force_enable + * If TRUE, then the type is enabled regardless of any stored variables. + * + * @return bool + * TRUE if either the bundle or entity type was enabled by this function. */ -function metatag_entity_info_alter(&$info) { - $defaults['node'] = array( - 'path' => 'node/%node', - 'metatags' => TRUE, - ); - $defaults['user'] = array( - 'path' => 'user/%user', - 'metatags' => TRUE, - ); - $defaults['taxonomy_term'] = array( - 'path' => 'taxonomy/term/%taxonomy_term', - 'metatags' => TRUE, - ); - - // Just running taxonomy_vocabulary_load() here would cause problems for - // EntityCache in certain circumstances, so instead the query is executed - // directly instead. - if (module_exists('forum') && ($vocab_id = variable_get('forum_nav_vocabulary', 0))) { - $vocab_name = db_query("SELECT machine_name FROM {taxonomy_vocabulary} WHERE vid = :vid", array(':vid' => $vocab_id))->fetchField(); - if (!empty($vocab_name)) { - $defaults['taxonomy_term']['bundles'][$vocab_name]['path'] = 'forum/%taxonomy_term'; +function metatag_entity_type_enable($entity_type, $bundle = NULL, $force_enable = FALSE) { + // The bundle was defined. + $bundle_set = FALSE; + if (isset($bundle)) { + $stored_bundle = variable_get('metatag_enable_' . $entity_type . '__' . $bundle, NULL); + if ($force_enable || !isset($stored_bundle)) { + variable_set('metatag_enable_' . $entity_type . '__' . $bundle, TRUE); + $bundle_set = TRUE; } } - foreach ($defaults as $key => $entity_defaults) { - if (isset($info[$key])) { - $info[$key] = drupal_array_merge_deep($entity_defaults, $info[$key]); - } + // Always enable the entity type, because otherwise there's no point in + // enabling the bundle. + $entity_type_set = FALSE; + $stored_entity_type = variable_get('metatag_enable_' . $entity_type, NULL); + if ($force_enable || !isset($stored_entity_type)) { + variable_set('metatag_enable_' . $entity_type, TRUE); + $entity_type_set = TRUE; } + + // Clear the static cache so that the entity type / bundle will work. + drupal_static_reset('metatag_entity_supports_metatags'); + + return $bundle_set || $entity_type_set; } /** - * Given a path determine if it is an entity default path. + * Disable support for a specific entity type. * - * @param $path - * The internal path. The id of the entity should be in the string as '[id]'. - * @return - * An array with the entity type and the loaded entity object. + * @param string $entity_type + * The entity type. + * @param string $bundle + * The bundle of the entity. */ -function metatag_load_entity_from_path($path) { - $entity_paths = &drupal_static(__FUNCTION__); - $result = FALSE; - - if (!isset($entity_paths)) { - $entity_paths = array(); - foreach (entity_get_info() as $entity_type => $entity_info) { - if (isset($entity_info['default path'])) { - $default_path = $entity_info['default path']; - $default_path = preg_quote($default_path, '/'); - $default_path = str_replace('\[id\]', '(\d+)', $default_path); - $entity_paths[$entity_type] = $default_path; - } - } +function metatag_entity_type_disable($entity_type, $bundle = NULL) { + // The bundle was defined. + if (isset($bundle)) { + variable_set('metatag_enable_' . $entity_type . '__' . $bundle, FALSE); } - - foreach ($entity_paths as $entity_type => $default_path) { - if (preg_match("/^{$default_path}$/", $path, $matches)) { - if ($entity = entity_load($entity_type, array($matches[1]))) { - $result = array('entity_type' => $entity_type, 'entity' => reset($entity)); - } - break; - } + // The bundle was not defined. + else { + variable_set('metatag_enable_' . $entity_type, FALSE); } - // Allow other modules to customize the data using - // hook_metatag_load_entity_from_path_alter(). - drupal_alter('metatag_load_entity_from_path', $path, $result); - - return $result; + // Clear the static cache so that the entity type / bundle will work. + drupal_static_reset('metatag_entity_supports_metatags'); } /** @@ -1506,12 +1935,21 @@ function metatag_page_build(&$page) { return; } + // Special consideration for the Me module, which uses the "user/me" path and + // will cause problems. + if (arg(0) == 'user' && arg(1) == 'me' && function_exists('me_menu_alter')) { + return; + } + + // The page region can be changed. + $region = variable_get('metatag_page_region', 'content'); + // Ensure these arrays exist, otherwise several use cases will fail. - if (!isset($page['content']) || !is_array($page['content'])) { - $page['content'] = array(); + if (!isset($page[$region]) || !is_array($page[$region])) { + $page[$region] = array(); } - if (!isset($page['content']['metatags']) || !is_array($page['content']['metatags'])) { - $page['content']['metatags'] = array(); + if (!isset($page[$region]['metatags']) || !is_array($page[$region]['metatags'])) { + $page[$region]['metatags'] = array(); } // The front page has special consideration. Also, check if this is an error @@ -1531,21 +1969,24 @@ function metatag_page_build(&$page) { } else { $metatags = metatag_metatags_view($instance, array()); - metatag_cache_set($cid, $metatags); + // If output caching is enabled, save this for later. + if (variable_get('metatag_cache_output', FALSE)) { + metatag_cache_set($cid, $metatags); + } } - $page['content']['metatags'][$instance] = $metatags; + $page[$region]['metatags'][$instance] = $metatags; } // Load any meta tags assigned via metatag_page_set_metatags(). Note: this // must include the necessary defaults. else { - $page['content']['metatags'] += metatag_page_get_metatags(); + $page[$region]['metatags'] += metatag_page_get_metatags(); } // If no meta tags were loaded at least load the global defaults. This may be // disabled, see README.txt for details. - if (empty($page['content']['metatags']) && variable_get('metatag_load_all_pages', TRUE)) { + if (empty($page[$region]['metatags']) && variable_get('metatag_load_all_pages', TRUE)) { $instance = 'global'; // Generate the cache ID. @@ -1560,23 +2001,26 @@ function metatag_page_build(&$page) { } else { $metatags = metatag_metatags_view($instance, array()); - metatag_cache_set($cid, $metatags); + // If output caching is enabled, save this for later. + if (variable_get('metatag_cache_output', FALSE)) { + metatag_cache_set($cid, $metatags); + } } - $page['content']['metatags'][$instance] = $metatags; + $page[$region]['metatags'][$instance] = $metatags; } } /** * Returns whether the current page is the page of the passed in entity. * - * @param $entity_type + * @param string $entity_type * The entity type; e.g. 'node' or 'user'. - * @param $entity + * @param object $entity * The entity object. * - * @return + * @return mixed * TRUE if the current page is the page of the specified entity, or FALSE - * otherwise. + * otherwise. If $entity_type == 'comment' return empty (FALSE). */ function _metatag_entity_is_page($entity_type, $entity) { // Exclude comment entities as this conflicts with comment_fragment.module. @@ -1587,8 +2031,8 @@ function _metatag_entity_is_page($entity_type, $entity) { $uri = entity_uri($entity_type, $entity); $current_path = current_path(); - // Support for Workbench Moderation v1 - if this is a node, check if the - // content type supports moderation. + // Support for Workbench Moderation - if this is a node, check if the content + // type supports moderation. if ($entity_type == 'node' && function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) { return !empty($uri['path']) && ($current_path == $uri['path'] || $current_path == $uri['path'] . '/draft'); } @@ -1613,7 +2057,8 @@ function metatag_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_n if ($config = metatag_config_load($instance_old)) { $config->instance = $instance_new; metatag_config_save($config); - metatag_config_delete($instance_old); + $config->instance = $instance_old; + metatag_config_delete($config); } } @@ -1622,23 +2067,27 @@ function metatag_field_attach_rename_bundle($entity_type, $bundle_old, $bundle_n */ function metatag_field_attach_delete_bundle($entity_type, $bundle) { $instance = $entity_type . ':' . $bundle; - metatag_config_delete($instance); + if ($config = metatag_config_load($instance)) { + metatag_config_delete($config); + } } /** * Implements hook_field_attach_form(). */ function metatag_field_attach_form($entity_type, $entity, &$form, &$form_state, $langcode) { - if (!metatag_entity_has_metatags($entity_type, $entity)) { - return; - } // Entity_Translation will trigger this hook again, skip it. if (!empty($form_state['entity_translation']['is_translation'])) { return; } list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity); - $instance = "{$entity_type}:{$bundle}"; + + if (!metatag_entity_supports_metatags($entity_type, $bundle)) { + return; + } + + $instance = metatag_get_entity_metatags_instance($entity, $entity_type, $bundle); // Grab the meta tags for display in the form if there are any. if (!empty($entity->metatags)) { @@ -1672,14 +2121,18 @@ function metatag_field_attach_form($entity_type, $entity, &$form, &$form_state, $metatags = array(); } - $options['token types'] = array(token_get_entity_mapping('entity', $entity_type)); - $options['context'] = $entity_type; - // Allow hook_metatag_token_types_alter() to modify the defined tokens. - drupal_alter('metatag_token_types', $options); + // Certain circumstances can result in $metatags not being an array. + if (!is_array($metatags)) { + $metatags = array(); + } - // @todo Remove metatag_form_alter() when http://drupal.org/node/1284642 is fixed in core. - //metatag_metatags_form($form, $instance, $metatags, $options); + $options['token types'] = array( + token_get_entity_mapping('entity', $entity_type), + ); + $options['context'] = $entity_type; + // @todo Remove metatag_form_alter() when https://www.drupal.org/node/1284642 is fixed in core. + // metatag_metatags_form($form, $instance, $metatags, $options); $form['#metatags'] = array( 'instance' => $instance, 'metatags' => $metatags, @@ -1690,7 +2143,7 @@ function metatag_field_attach_form($entity_type, $entity, &$form, &$form_state, /** * Implements hook_form_alter(). * - * @todo Remove this when http://drupal.org/node/1284642 is fixed in core. + * @todo Remove this when https://www.drupal.org/node/1284642 is fixed in core. */ function metatag_form_alter(&$form, $form_state, $form_id) { if (!empty($form['#metatags']) && !isset($form['metatags'])) { @@ -1703,7 +2156,7 @@ function metatag_form_alter(&$form, $form_state, $form_id) { /** * Get the meta tag information array of a meta tag. * - * @param $metatag + * @param string $name * The meta tag name, e.g. description, for which the info shall be returned, * or NULL to return an array with info about all meta tags. */ @@ -1717,8 +2170,8 @@ function metatag_get_info($type = NULL, $name = NULL) { global $language; if (!isset($info)) { - // hook_metatag_info() includes translated strings, so each language is cached - // separately. + // hook_metatag_info() includes translated strings, so each language is + // cached separately. $cid = 'info:' . $language->language; if ($cache = metatag_cache_get($cid)) { @@ -1758,6 +2211,9 @@ function metatag_get_info($type = NULL, $name = NULL) { } } +/** + * Return instance of metatag. + */ function metatag_get_instance($metatag, array $data = array()) { $info = metatag_get_info('tags', $metatag); if (!empty($info['class']) && class_exists($info['class'])) { @@ -1769,16 +2225,16 @@ function metatag_get_instance($metatag, array $data = array()) { /** * Return the string value of a meta tag. * - * @param $metatag + * @param string $metatag * The meta tag string. - * @param $data + * @param array $data * The array of data for the meta tag class instance. - * @param $options + * @param array $options * An optional array of additional options to pass to the getValue() method * of the meta tag class instance. * - raw: A boolean if TRUE will not perform token replacement. * - * @return + * @return string * A string value. */ function metatag_get_value($metatag, array $data, array $options = array()) { @@ -1786,6 +2242,9 @@ function metatag_get_value($metatag, array $data, array $options = array()) { if ($metatag_instance = metatag_get_instance($metatag, $data)) { $options["instance"] = $metatag; $value = $metatag_instance->getValue($options); + if (is_array($value)) { + $value = implode(', ', $value); + } } return $value; } @@ -1834,31 +2293,95 @@ function metatag_preprocess_maintenance_page(&$variables) { /** * Implements hook_html_head_alter(). + * + * Hide tags added by core that are now handled by metatag. */ function metatag_html_head_alter(&$elements) { - // Remove duplicate link tags if found. - $metatags = metatag_get_info('tags'); - foreach (array_keys($metatags) as $name) { - if (!isset($elements['metatag_' . $name]) || $elements['metatag_' . $name]['#tag'] != 'link') { - // Only check for link tags added by the metatags module. - continue; + $metatags = array(); + $other_tags = array(); + foreach ($elements as $key => $data) { + // Identify meta tags added by the Metatag module. + if (strpos($key, 'metatag_') === 0) { + $metatags[] = $key; + } + // Identify meta tags added by other modules. + else { + $other_tags[] = $key; } - foreach (array_keys($elements) as $key) { - if (strpos($key, 'drupal_add_html_head_link:' . $name . ':') === 0) { - unset($elements[$key]); + } + + // The meta tag keys to look for. + $metatag_keys = array('name', 'property'); + + // Attributes to look for. + $attributes = array('name', 'rel'); + + // Look for meta tags that were added by other modules and hide them. + foreach ($metatags as $metatag_name) { + $metatag = &$elements[$metatag_name]; + + // Setting the #access attribute to these will stop them from being output + // but still leave the tags present for other modules to interact with. + foreach ($other_tags as $other_tag) { + $other = &$elements[$other_tag]; + + // Look for other meta tags that have one of the defined attributes which + // matches one of the values from Metatag's tag. + foreach ($attributes as $attribute) { + if (isset($other['#attributes'], $other['#attributes'][$attribute]) && is_string($other['#attributes'][$attribute])) { + foreach ($metatag_keys as $metatag_key) { + if (isset($metatag[$metatag_key])) { + if (strtolower($other['#attributes'][$attribute]) == $metatag[$metatag_key]) { + $other['#access'] = FALSE; + } + } + } + } } } } - // Remove the default generator meta tag. - unset($elements['system_meta_generator']); + // If the 'leave core tags' option is disabled then the following meta tags + // will be removed if they're provided by core. + if (!variable_get('metatag_leave_core_tags', FALSE)) { + $core_tags = array( + 'generator', + 'canonical', + 'shortlink', + // Leave the shortcut icon, that's more of a theming thing. + // 'shortcut icon',. + ); + foreach ($elements as $name => &$element) { + // Ignore meta tags provided by Metatag. + if (strpos($name, 'metatag_') === 0) { + continue; + } + + // Setting the #access attribute to these will stop them from being output + // but still leave the tags present for other modules to interact with. + foreach ($core_tags as $tag) { + if (!empty($element['#attributes']['rel']) && $element['#attributes']['rel'] == $tag) { + $element['#access'] = FALSE; + } + elseif (!empty($element['#attributes']['name']) && strtolower($element['#attributes']['name']) == $tag) { + $element['#access'] = FALSE; + } + } + } + } } +/** + * Implements hook_get_form(). + */ function metatag_metatag_get_form($metatag, array $data = array(), array $options = array()) { $instance = metatag_get_instance($metatag, $data); return $instance->getForm($options); } +/** + * Returns Instance info if exists otherwise return FALSE. + */ function metatag_config_instance_info($instance = NULL) { global $language; @@ -1919,10 +2442,10 @@ function metatag_filter_values_from_defaults(array &$values, array $defaults = a /** * Return all the parents of a given configuration instance. * - * @param $instance + * @param string $instance * A meta tag configuration instance. * - * @return + * @return array * An array of instances starting with the $instance parameter, with the end * of the array being the global instance. */ @@ -1943,7 +2466,7 @@ function metatag_config_get_parent_instances($instance, $include_global = TRUE) /** * Get the proper label of a configuration instance. * - * @param $instance + * @param string $instance * A meta tag configuration instance. */ function metatag_config_instance_label($instance) { @@ -2012,7 +2535,18 @@ function metatag_config_access($op, $config = NULL) { */ function metatag_config_is_enabled($instance, $include_defaults = FALSE, $include_global = TRUE) { if ($include_defaults) { - return (bool) metatag_config_load_with_defaults($instance, $include_global); + $instances = metatag_config_get_parent_instances($instance, $include_global); + $configs = metatag_config_load_multiple($instances); + + // Check if one of the configs is enabled. + foreach ($configs as $config) { + if (empty($config->disabled)) { + return TRUE; + } + } + + // No enabled configs found. + return FALSE; } else { $config = metatag_config_load($instance); @@ -2021,20 +2555,20 @@ function metatag_config_is_enabled($instance, $include_defaults = FALSE, $includ } /** - * Wrapper around entity_language() to use LANGUAGE_NONE if the entity does not - * have a language assigned. + * Wrapper around entity_language(). * - * @param $entity_type + * @param mixed $entity_type * An entity type's machine name. - * @param $entity - * The entity to review; + * @param object $entity + * The entity to review; will be typecast to an object if an array is passed. * - * @return - * A string indicating the language code to be used. + * @return string + * A string indicating the language code to be used; returns LANGUAGE_NONE if + * the entity does not have a language assigned. */ function metatag_entity_get_language($entity_type, $entity) { - // Determine the entity's language. - $langcode = entity_language($entity_type, $entity); + // Determine the entity's language, af. + $langcode = entity_language($entity_type, (object) $entity); // If no matching language was found, which will happen for e.g. terms and // users, it is normally recommended to use the system default language. @@ -2066,36 +2600,80 @@ function metatag_features_api() { /** * Implements hook_views_post_render(). + * + * Try loading meta tags from a Views page display. */ function metatag_views_post_render(&$view, &$output, &$cache) { + // By default do not add meta tags to admin pages. To enable meta tags on + // admin pages set the 'metatag_tag_admin_pages' variable to TRUE. + if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) { + return; + } + + // If display is not set for some reason, get out to prevent PHP notices. + if (!isset($view->display[$view->current_display])) { + return; + } + // Build a shortcut to the current display object. $display = $view->display[$view->current_display]; - // Only proceed if this view is a full page, don't process block or other - // Views display objects. - if ($display->display_plugin == 'page' && isset($display->display_options['path'])) { - // Check if this is an entity display page, if so trigger - // hook_entity_view(). - foreach (entity_get_info() as $entity_type => $entity_info) { - // Entity paths will include an auto-loader that matches the entity's - // name, thus the path will be 'some/path/%entity_name'. - if (isset($entity_info['path']) && ($display->display_options['path'] . $entity_type) == $entity_info['path']) { - // Only proceed if this entity type supports meta tags. - if (metatag_entity_supports_metatags($entity_type)) { - // There must be at least one argument and the first argument must be - // numerical. - if (!empty($view->args) && is_numeric($view->args[0])) { - // Only the first argument is used. - $entities = entity_load($entity_type, array($view->args[0])); - // Only if the entity actually exists. - if (!empty($entities)) { - $entity = array_pop($entities); - metatag_entity_view($entity, $entity_type, 'full', NULL, TRUE); - } + // Only proceed if this view is a full page and has a valid path, don't + // process block or other Views display objects. + if ($display->display_plugin == 'page' && !empty($display->display_options['path'])) { + // Try to work out what entity type this is. + $entity_type = ''; + + // All paths must have a placeholder. + $placeholder_pos = strpos($display->display_options['path'], '%'); + if ($placeholder_pos !== FALSE) { + // The first argument must be a numeric entity ID. + if (!empty($view->args) && is_numeric($view->args[0])) { + // The first argument should be an entity ID. + $id = $view->args[0]; + + // Taxonomy terms are the most commonly used item, so check that first. + if ($display->display_options['path'] == 'taxonomy/term/%' || $display->display_options['path'] == 'taxonomy/term/%/%') { + $entity_type = 'taxonomy_term'; + } + // Node pages. + elseif ($display->display_options['path'] == 'node/%') { + $entity_type = 'node'; + } + // User pages. + elseif ($display->display_options['path'] == 'user/%') { + $entity_type = 'user'; + } + } + } + + // Check for other types of entities. + if (empty($entity_type)) { + // Trigger hook_metatag_views_post_render_get_entity(). + $hook = 'metatag_views_post_render_get_entity'; + foreach (module_implements($hook) as $module) { + $function = $module . '_' . $hook; + if (function_exists($function)) { + $entity_type = call_user_func($function, $view); + // If an entity type was identified, stop checking. + if (!empty($entity_type)) { + break; } } } } + + // If an entity type was identified, try loading the entity. + if (!empty($entity_type)) { + // Try loading the requested entity. + $entities = entity_load($entity_type, array($id)); + if (!empty($entities)) { + $entity = array_pop($entities); + + // Trigger our hook_entity_view(). + metatag_entity_view($entity, $entity_type, 'full', NULL, TRUE); + } + } } } @@ -2106,27 +2684,32 @@ function metatag_views_post_render(&$view, &$output, &$cache) { * CTools display handlers. */ function metatag_ctools_render_alter(&$info, $page, $context) { + // By default do not add meta tags to admin pages. To enable meta tags on + // admin pages set the 'metatag_tag_admin_pages' variable to TRUE. + if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) { + return; + } + // Only proceed if this is a full page (don't process individual panes) and // there's an 'admin path' for the current task. if ($page && !empty($context['task']['admin path'])) { - // Check if this is an entity display page, if so trigger - // hook_entity_view(). - foreach (entity_get_info() as $entity_type => $entity_info) { - // Entity paths will include an auto-loader that matches the entity's - // name, thus the path will be 'some/path/%entity_name'. - if (isset($entity_info['path']) && $context['task']['admin path'] == $entity_info['path']) { - // Only proceed if this entity type supports meta tags. - if (metatag_entity_supports_metatags($entity_type)) { - // There must be at least one argument and the first argument must be - // numerical. - if (!empty($context['args']) && is_numeric($context['args'][0])) { - // We need to pop entity from contexts array. - $first_context = array_pop($context['contexts']); - // Only if the context actually exists, which would be an entity. - if (!empty($first_context->data)) { - $langcode = $GLOBALS['language_content']->language; - metatag_entity_view($first_context->data, $entity_type, 'full', $langcode, TRUE); - } + // Loop over each context. + foreach ($context['contexts'] as $context_argument) { + if (is_array($context_argument->type) && !empty($context_argument->data)) { + if (in_array('entity', $context_argument->type)) { + $entity = $context_argument->data; + $entity_type = str_replace('entity:', '', $context_argument->plugin); + + // Verify this is an appropriate entity. + $entity_info = entity_get_info($entity_type); + if (!empty($entity_info) && _metatag_entity_is_page($entity_type, $entity)) { + // Load the meta tags for this entity. + global $language; + metatag_entity_view($entity, $entity_type, 'full', $language->language, TRUE); + + // Don't bother looping over any more contexts, an entity has been + // found. + break; } } } @@ -2134,47 +2717,11 @@ function metatag_ctools_render_alter(&$info, $page, $context) { } } -/** - * Implements hook_entity_translation_delete(). - * - * Required for content translations being handled via Entity_Translation to - * remove the appropriate record when a translation is removed without the - * corresponding entity record also being removed. - */ -function metatag_entity_translation_delete($entity_type, $entity, $langcode) { - // Get the entity's ID. - list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); - $revision_id = intval($revision_id); - - // Delete the translation. - metatag_metatags_delete($entity_type, $entity_id, $revision_id, $langcode); -} - -/** - * Translates the metatag if i18n_string is enabled. - * @param $name - * Array or string concatenated with ':' that contains textgroup and string context - * @param string $string - * String in default language or array of strings to be translated - * @param $options - * An associative array of additional options. @see i18n_string_translate() - */ -function metatag_translate($name, $string, $langcode = NULL, $update = FALSE) { - if (function_exists('i18n_string_translate')) { - $options = array( - 'langcode' => $langcode, - 'update' => $update, - ); - return i18n_string_translate($name, $string, $options); - } - else { - return $string; - } -} - /** * Checks if this entity is the default revision (published). * + * Only needed when running Workbench Moderation v1; v3 is skipped. + * * @param object $entity * The entity object, e.g., $node. * @@ -2194,18 +2741,22 @@ function _metatag_isdefaultrevision($entity) { // // This behaviour will change in D8 where $node->isDefaultRevision has been // introduced. See below links for more details. - // - http://drupal.org/node/1879482 - // - http://drupal.org/node/218755 - // - http://drupal.org/node/1522154 + // - https://www.drupal.org/node/1879482 + // - https://www.drupal.org/node/218755 + // - https://www.drupal.org/node/1522154 // // Every moderation module saving a forward revision needs to return FALSE. // @todo: Refactor this workaround under D8. - - // Support for Workbench Moderation v1 - if this is a node, check if the - // content type supports moderation. - if (function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) { - return !empty($entity->workbench_moderation['updating_live_revision']); + // Workbench Moderation v1 uses the hook_node_presave() for some custom logic. + // This was replaced with hook_entity_presave() in v3, so only proceed if the + // old hook implementation is present. + if (function_exists('workbench_moderation_node_presave')) { + // If this is a node, check if the content type supports moderation. + if (function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) { + return !empty($entity->workbench_moderation['updating_live_revision']); + } } + return FALSE; } @@ -2243,8 +2794,8 @@ function metatag_cache_default_cid_parts(array $cid_parts = array()) { } // Allow each page in a sequence to have different values. - if (isset($_GET['page'])) { - $cid_parts['page'] = $_GET['page']; + if (isset($_GET['page']) && is_numeric($_GET['page'])) { + $cid_parts['page'] = intval($_GET['page']); } // Allow other modules to customize the data using @@ -2254,24 +2805,28 @@ function metatag_cache_default_cid_parts(array $cid_parts = array()) { // Remove empty parts. $cid_parts = array_filter($cid_parts); - // Concatenate the cache ID parts, trim the results to 128 chars. - return substr(implode(':', $cid_parts), 0, 128); + // Concatenate the cache ID parts, trim the results to 255 chars. + return substr(implode(':', $cid_parts), 0, 255); } /** * Wrapper for cache_set. * - * @see cache_set(). + * @see cache_set() */ function metatag_cache_set($cid, $data) { - // Cache the data for later. - return cache_set($cid, $data, 'cache_metatag'); + // By default the cached data will not expire. + $expire = CACHE_PERMANENT; + + // Triggers hook_metatag_cache_set_expire_alter(). + drupal_alter("metatag_cache_set_expire", $expire, $cid, $data); + return cache_set($cid, $data, 'cache_metatag', $expire); } /** * Wrapper for cache_get. * - * @see cache_get(). + * @see cache_get() */ function metatag_cache_get($cid) { // Try to load the object. @@ -2282,6 +2837,7 @@ function metatag_cache_get($cid) { * Determines if we are in an error page and return the appropriate instance. * * @return string + * String of error. */ function metatag_is_error_page() { $known_errors = array( @@ -2298,3 +2854,434 @@ function metatag_is_error_page() { } return ''; } + +/** + * Implements hook_admin_menu_cache_info(). + */ +function metatag_admin_menu_cache_info() { + $caches['metatag'] = array( + 'title' => t('Metatag'), + 'callback' => 'metatag_config_cache_clear', + ); + return $caches; +} + +/** + * Identify whether an entity type is technically capable of having meta tags. + * + * In order to be capable of having meta tags, an entity type must have view + * modes, must be fieldable, and may not be a configuration entity. + * + * @param string $entity_type + * The entity type. + * @param array $entity_info + * Entity information. + * + * @return bool + * Return TRUE if suitable. + */ +function metatag_entity_type_is_suitable($entity_type, $entity_info = array()) { + $suitable = TRUE; + + // If the entity info was not passed along, load it. + if (empty($entity_info)) { + $entity_info = entity_get_info($entity_type); + } + + // Configuration entities may not have meta tags. + if (isset($entity_info['configuration']) && $entity_info['configuration'] == TRUE) { + $suitable = FALSE; + } + + // Entities must have bundles. + elseif (empty($entity_info['bundles'])) { + $suitable = FALSE; + } + + // The entity type must be fieldable. + elseif (empty($entity_info['fieldable'])) { + $suitable = FALSE; + } + + else { + // Ignore some view modes that are automatically added by certain modules. + unset($entity_info['view modes']['ical']); + unset($entity_info['view modes']['diff_standard']); + unset($entity_info['view modes']['token']); + + // There must be view modes. + if (empty($entity_info['view modes'])) { + $suitable = FALSE; + } + + else { + // Specifically disable some entity types. + $excluded = array( + // Comment module. + 'comment', + // Field Collection module. + 'field_collection_item', + // Paragraphs module. + 'paragraphs_item', + ); + if (in_array($entity_type, $excluded)) { + $suitable = FALSE; + } + } + } + + // Trigger hook_metatag_entity_type_is_supported_alter() to allow other + // modules to either enable or disable certain entity types. + drupal_alter('metatag_entity_type_is_supported', $suitable, $entity_type, $entity_info); + + return $suitable; +} + +/** + * Implements hook_node_type_insert(). + * + * When a content type is created, enable it for use with Metatag. + */ +function metatag_node_type_insert($info) { + if (metatag_entity_supports_metatags('node')) { + if (metatag_entity_type_enable('node', $info->type)) { + drupal_set_message(t('Metatag support has been enabled for the @label content type.', array('@label' => $info->name))); + } + } +} + +/** + * Implements hook_node_type_delete(). + * + * When a content type is deleted, remove the corresponding Metatag variable. + */ +function metatag_node_type_delete($info) { + variable_del('metatag_enable_node__' . $info->type); +} + +/** + * Implements hook_taxonomy_vocabulary_insert(). + * + * When a vocabulary is created, enable it for use with Metatag. + */ +function metatag_taxonomy_vocabulary_insert($vocabulary) { + if (metatag_entity_supports_metatags('taxonomy_term')) { + if (metatag_entity_type_enable('taxonomy_term', $vocabulary->machine_name)) { + drupal_set_message(t('Metatag support has been enabled for the @label vocabulary.', array('@label' => $vocabulary->name))); + } + } +} + +/** + * Implements hook_taxonomy_vocabulary_delete(). + * + * When a vocabulary is deleted, remove the corresponding Metatag variable. + */ +function metatag_taxonomy_vocabulary_delete($info) { + variable_del('metatag_enable_taxonomy_term__' . $info->machine_name); +} + +/** + * Implements hook_workbench_moderation_transition(). + * + * Clear a node's caches when its Workbench Moderation state is changed. + */ +function metatag_workbench_moderation_transition($node, $previous_state, $new_state) { + metatag_metatags_cache_clear('node', array($node->nid)); +} + +/** + * Sort callback for sorting by metatag instance string values. + */ +function _metatag_config_instance_sort($a, $b) { + $a_contexts = explode(':', $a); + $b_contexts = explode(':', $b); + + // Global config always comes first. + if ($a_contexts[0] == 'global' && $b_contexts[0] != 'global') { + return -1; + } + elseif ($b_contexts[0] == 'global' && $a_contexts[0] != 'global') { + return 1; + } + + for ($i = 0; $i < max(count($a_contexts), count($b_contexts)); $i++) { + $a_context = isset($a_contexts[$i]) ? $a_contexts[$i] : ''; + $b_context = isset($b_contexts[$i]) ? $b_contexts[$i] : ''; + if ($a_context == $b_context) { + continue; + } + else { + return strcmp($a_context, $b_context); + } + } +} + +/** + * Translations & internationalization (i18n). + */ + +/** + * Implements hook_entity_translation_delete(). + * + * Required for content translations being handled via Entity_Translation to + * remove the appropriate record when a translation is removed without the + * corresponding entity record also being removed. + */ +function metatag_entity_translation_delete($entity_type, $entity, $langcode) { + // Get the entity's ID. + list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); + $revision_id = intval($revision_id); + + // Delete the translation. + metatag_metatags_delete($entity_type, $entity_id, $revision_id, $langcode); +} + +/** + * Translates the metatag if i18n_string integration is enabled. + * + * @param string $string + * String in default language or array of strings to be translated. + * @param string $tag_name + * The internal name of the meta tag being translated. + * @param mixed $context + * A context string to use with i18n, or the $options array from a Metatag:: + * getValue() method; if the latter it will be used to generate the full + * context. + * @param string $langcode + * The language code to submit instead of the current page's language. + * @param bool $update + * Whether or not to create/update records in {locales_source}. + * + * @return string + * The translated string if i18n_string is enabled, otherwise just returns the + * original string. + * + * @see i18n_string_translate() + */ +function metatag_translate_metatag($string, $tag_name, $context, $langcode = NULL, $update = TRUE) { + if (module_exists('i18n_string') && !variable_get('metatag_i18n_disabled', FALSE)) { + // By default do not add meta tags to admin pages. To enable meta tags on + // admin pages set the 'metatag_tag_admin_pages' variable to TRUE. + static $page_is_admin; + if (is_null($page_is_admin)) { + $page_is_admin = FALSE; + if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) { + $page_is_admin = TRUE; + } + } + if ($page_is_admin) { + return $string; + } + + // If the context is an array then it is the $options from the meta tag + // generator and needs some custom tailoring. Doing it this way to avoid an + // unnecessary entity_extract_ids() call when i18n isn't being used. + if (is_array($context)) { + // Optionally disable output generation. + if (!variable_get('metatag_i18n_translate_output', FALSE)) { + return $string; + } + + // Output generation was enabled, so continue as normal. + $new_context = 'output:'; + if (drupal_is_front_page()) { + $new_context .= 'frontpage'; + } + // If this is an entity page, use the entity as the context. + elseif (!empty($context['entity_type']) && !empty($context['entity'])) { + list($entity_id, $revision_id, $bundle) = entity_extract_ids($context['entity_type'], $context['entity']); + $new_context .= $context['entity_type'] . ':' . $entity_id; + } + // Otherwise, use the page URL. + else { + // Trim this to avoid SQL errors on the {locales_source} table. + // length = 255 - strlen('metatag:output:page:') - strlen(metatag); + $strlen = 255 - strlen('metatag:output:page:' . $tag_name); + $new_context .= 'page:' . drupal_substr(current_path(), 0, $strlen); + } + $context = $new_context; + } + + $options = array( + // Automatically create/update the {locales_source} record if one wasn't + // found. + 'update' => $update, + // Translate the string. + 'translate' => TRUE, + ); + + // If the langcode was passed in, add it to the options passed to i18n. + if (!empty($langcode)) { + $options['langcode'] = $langcode; + } + + // By default disable the watchdog logging of translation messages. + $options['watchdog'] = variable_get('metatag_i18n_enable_watchdog', FALSE); + + // Triggers hook_metatag_i18n_context_alter() - allows the i18n string to + // be altered before being used. + drupal_alter('metatag_i18n_context', $context, $tag_name); + + // If the context was erased just send back the original string - it's + // unlikely, but it could happen. + if (empty($context)) { + return $string; + } + + // The 'name' is split up by i18n_string into two components - the textgroup + // is the first item, the others are joined together with a ':' separator + // to make the context. In order to have the contexts show with "metatag" as + // the first part of the context, it has to be added twice to the name. + $name = array( + 'metatag', + $context, + $tag_name, + ); + + // Notify i18n of the string, and obtain a translation if one is available. + return i18n_string($name, $string, $options); + } + + // If the i18n_string module isn't enabled then just pass back the string + // as-is. + else { + return $string; + } +} + +/** + * Translate a set of metatags to the current language. + * + * @param array $metatags + * List of meta tags to be translated. + * @param string $context + * An optional context to use with i18n. + * @param string $langcode + * The language code to submit instead of the current page's language. + * @param bool $update + * Whether or not to create/update records in {locales_source}. + */ +function metatag_translate_metatags(&$metatags, $context = NULL, $langcode = NULL, $update = TRUE) { + if (!empty($metatags)) { + foreach ($metatags as $key => $data) { + if (!empty($data['value']) && is_string($data['value'])) { + $metatags[$key] = array( + 'value' => metatag_translate_metatag($data['value'], $key, $context, $langcode, $update), + ); + } + } + } +} + +/** + * Update the translated definitions of meta tags. + * + * @param array $metatags + * List of meta tags to have their translations updated. + * @param string $context + * The string that will be used to group strings in the translation UI. + */ +function metatag_translations_update($metatags, $context) { + // Store the context as it was originally provided. + $original_context = $context; + + // Update the i18n string. + if (module_exists('i18n_string') && !variable_get('metatag_i18n_disabled', FALSE)) { + $options = array(); + + // By default disable the watchdog logging of translation messages. + $options['watchdog'] = variable_get('metatag_i18n_enable_watchdog', FALSE); + + foreach ($metatags as $tag_name => $data) { + // Revert the context, so that it can be changed if needed. + $context = $original_context; + + if (!empty($data['value']) && is_string($data['value'])) { + // Triggers hook_metatag_i18n_context_alter() - allows the i18n string + // to be altered before being used. + drupal_alter('metatag_i18n_context', $context, $tag_name); + + // Don't do anything if the context was erased - it's unlikely, but it + // could happen. + if (empty($context)) { + continue; + } + + // The textgroup is the first part of the string. + i18n_string_update("metatag:{$context}:{$tag_name}", $data['value'], $options); + } + } + } +} + +/** + * Remove the translated definitions of meta tags. + * + * @param array $metatags + * List of meta tags to have their translations updated. + * @param string $context + * The string that will be used to group strings in the translation UI. + */ +function metatag_translations_delete($metatags, $context) { + // Store the context as it was originally provided. + $original_context = $context; + + // Update the i18n string. + if (module_exists('i18n_string') && !variable_get('metatag_i18n_disabled', FALSE)) { + $options = array(); + + // By default disable the watchdog logging of translation messages. + $options['watchdog'] = variable_get('metatag_i18n_enable_watchdog', FALSE); + + foreach ($metatags as $tag_name => $data) { + // Revert the context, so that it can be changed if needed. + $context = $original_context; + + if (!empty($data['value']) && is_string($data['value'])) { + // Triggers hook_metatag_i18n_context_alter() - allows the i18n string + // to be altered before being used. + drupal_alter('metatag_i18n_context', $context, $tag_name); + + // Don't do anything if the context was erased - it's unlikely, but it + // could happen. + if (empty($context)) { + continue; + } + + // The textgroup is the first part of the string. + i18n_string_remove("metatag:{$context}:{$tag_name}", $data['value'], $options); + } + } + } +} + +/** + * Implements hook_config_insert(). + * + * Implements hook_metatag_config_insert() on behalf of i18n_string. + */ +function i18n_string_metatag_config_insert($config) { + $context = 'metatag_config:' . $config->instance; + metatag_translations_update($config->config, $context); +} + +/** + * Implements hook_config_update(). + * + * Implements hook_metatag_config_update() on behalf of i18n_string. + */ +function i18n_string_metatag_config_update($config) { + // Defer to the 'insert' function. + i18n_string_metatag_config_insert($config); +} + +/** + * Implements hook_config_delete(). + * + * Implements hook_metatag_config_delete() on behalf of i18n_string. + */ +function i18n_string_metatag_config_delete($config) { + $context = 'metatag_config:' . $config->instance; + metatag_translations_delete($config->config, $context); +} diff --git a/sites/all/modules/contrib/metatag/metatag.search_api.inc b/sites/all/modules/contrib/metatag/metatag.search_api.inc new file mode 100644 index 00000000..91c85467 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag.search_api.inc @@ -0,0 +1,85 @@ + array( + 'name' => t('Meta tags'), + 'description' => t("Adds the item's meta tags to the indexed data."), + 'class' => 'MetatagSearchAlterCallback', + ), + ); +} + +/** + * Only add the class if Search API is installed. + */ +if (class_exists('SearchApiAbstractAlterCallback')) { + + /** + * Adds meta tag values to the indexed items. + */ + class MetatagSearchAlterCallback extends SearchApiAbstractAlterCallback { + + /** + * {@inheritdoc} + */ + public function supportsIndex(SearchApiIndex $index) { + // Only works on entities. + return (bool) $index->getEntityType(); + } + + /** + * {@inheritdoc} + */ + public function alterItems(array &$items) { + $entity_type = $this->index->getEntityType(); + $tags = metatag_get_info('tags'); + foreach ($items as $id => $item) { + foreach (array_keys($tags) as $tag) { + $items[$id]->{'metatag_' . $tag} = NULL; + if (isset($item->language) && isset($item->metatags[$item->language][$tag])) { + $instance = metatag_get_instance($tag, $item->metatags[$item->language][$tag]); + $items[$id]->{'metatag_' . $tag} = $instance->getValue(array('token data' => array($entity_type => $item))); + } + } + } + } + + /** + * {@inheritdoc} + */ + public function propertyInfo() { + $properties = array(); + + // Get available meta tags. + $tags = metatag_get_info('tags'); + foreach ($tags as $id => $tag) { + switch ($tag['class']) { + case 'DrupalLinkMetaTag': + $type = 'uri'; + break; + + default: + $type = 'text'; + break; + } + $properties['metatag_' . $id] = array( + 'label' => t('Meta tag: @label', array('@label' => $tag['label'])), + 'description' => t('@label meta tag attached to an item.', array('@label' => $tag['label'])), + 'type' => $type, + ); + } + + return $properties; + } + + } +} diff --git a/sites/all/modules/contrib/metatag/metatag.test b/sites/all/modules/contrib/metatag/metatag.test deleted file mode 100644 index bc44e159..00000000 --- a/sites/all/modules/contrib/metatag/metatag.test +++ /dev/null @@ -1,261 +0,0 @@ - 'Meta tag unit tests', - 'description' => 'Test basic meta tag functionality.', - 'group' => 'Metatag', - ); - } - - /** - * Test the metatag_config_load_with_defaults() function. - */ - public function testConfigLoadDefaults() { - $defaults = metatag_config_load_with_defaults('test:foo'); - $this->assertEqual($defaults, array( - 'description' => array('value' => 'Test foo description'), - 'abstract' => array('value' => 'Test foo abstract'), - 'title' => array('value' => 'Test altered title'), - 'test:foo' => array('value' => 'foobar'), - 'generator' => array('value' => 'Drupal 7 (http://drupal.org)'), - 'canonical' => array('value' => '[current-page:url:absolute]'), - 'shortlink' => array('value' => '[current-page:url:unaliased]'), - )); - } - - public function testEntitySupport() { - $test_cases[1] = array('type' => 'node', 'bundle' => 'article', 'expected' => TRUE); - $test_cases[2] = array('type' => 'node', 'bundle' => 'page', 'expected' => TRUE); - $test_cases[3] = array('type' => 'node', 'bundle' => 'invalid-bundle', 'expected' => FALSE); - $test_cases[4] = array('type' => 'user', 'expected' => TRUE); - foreach ($test_cases as $test_case) { - $test_case += array('bundle' => NULL); - $this->assertMetatagEntityHasMetatags($test_case['type'], $test_case['bundle'], $test_case['expected']); - } - - variable_set('metatag_test_entity_info_disable', TRUE); - drupal_static_reset('metatag_entity_has_metatags'); - drupal_static_reset('metatag_entity_supports_metatags'); - entity_info_cache_clear(); - - $test_cases[2]['expected'] = FALSE; - $test_cases[4]['expected'] = FALSE; - foreach ($test_cases as $test_case) { - $test_case += array('bundle' => NULL); - $this->assertMetatagEntityHasMetatags($test_case['type'], $test_case['bundle'], $test_case['expected']); - } - } - - function assertMetatagEntityHasMetatags($entity_type, $bundle, $expected) { - $entity = entity_create_stub_entity($entity_type, array(0, NULL, $bundle)); - return $this->assertEqual( - metatag_entity_has_metatags($entity_type, $entity), - $expected, - t("metatag_entity_has_metatags(:type, :entity) is :expected", array( - ':type' => var_export($entity_type, TRUE), - ':entity' => var_export($entity, TRUE), - ':expected' => var_export($expected, TRUE), - )) - ); - } - - /** - * Test the metatag_config_instance_label() function. - */ - public function testConfigLabels() { - $test_cases = array( - 'node' => 'Node', - 'node:article' => 'Node: Article', - 'node:article:c' => 'Node: Article: Unknown (c)', - 'node:b' => 'Node: Unknown (b)', - 'node:b:c' => 'Node: Unknown (b): Unknown (c)', - 'a' => 'Unknown (a)', - 'a:b' => 'Unknown (a): Unknown (b)', - 'a:b:c' => 'Unknown (a): Unknown (b): Unknown (c)', - 'a:b:c:d' => 'Unknown (a): Unknown (b): Unknown (c): Unknown (d)', - ); - - foreach ($test_cases as $input => $expected_output) { - drupal_static_reset('metatag_config_instance_label'); - $actual_output = metatag_config_instance_label($input); - $this->assertEqual($actual_output, $expected_output); - } - } -} - - -// 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. diff --git a/sites/all/modules/contrib/metatag/metatag.theme.inc b/sites/all/modules/contrib/metatag/metatag.theme.inc index 7b495ed6..81920078 100644 --- a/sites/all/modules/contrib/metatag/metatag.theme.inc +++ b/sites/all/modules/contrib/metatag/metatag.theme.inc @@ -13,7 +13,11 @@ */ function theme_metatag($variables) { $element = &$variables['element']; - element_set_attributes($element, array('name', '#value' => 'content')); + $args = array( + '#name' => 'name', + '#value' => 'content', + ); + element_set_attributes($element, $args); unset($element['#value']); return theme('html_tag', $variables); } @@ -26,7 +30,11 @@ function theme_metatag($variables) { */ function theme_metatag_http_equiv($variables) { $element = &$variables['element']; - element_set_attributes($element, array('#name' => 'http-equiv', '#value' => 'content')); + $args = array( + '#name' => 'http-equiv', + '#value' => 'content', + ); + element_set_attributes($element, $args); unset($element['#value']); return theme('html_tag', $variables); } @@ -39,7 +47,11 @@ function theme_metatag_http_equiv($variables) { */ function theme_metatag_link_rel($variables) { $element = &$variables['element']; - element_set_attributes($element, array('#name' => 'rel', '#value' => 'href')); + $args = array( + '#name' => 'rel', + '#value' => 'href', + ); + element_set_attributes($element, $args); unset($element['#value']); return theme('html_tag', $variables); } @@ -52,7 +64,11 @@ function theme_metatag_link_rel($variables) { */ function theme_metatag_link_rev($variables) { $element = &$variables['element']; - element_set_attributes($element, array('#name' => 'rev', '#value' => 'href')); + $args = array( + '#name' => 'rev', + '#value' => 'href', + ); + element_set_attributes($element, $args); unset($element['#value']); return theme('html_tag', $variables); } @@ -65,7 +81,11 @@ function theme_metatag_link_rev($variables) { */ function theme_metatag_property($variables) { $element = &$variables['element']; - element_set_attributes($element, array('#name' => 'property', '#value' => 'content')); + $args = array( + '#name' => 'property', + '#value' => 'content', + ); + element_set_attributes($element, $args); unset($element['#value']); return theme('html_tag', $variables); } diff --git a/sites/all/modules/contrib/metatag/metatag.tokens.inc b/sites/all/modules/contrib/metatag/metatag.tokens.inc index 4fbf0522..80310c32 100644 --- a/sites/all/modules/contrib/metatag/metatag.tokens.inc +++ b/sites/all/modules/contrib/metatag/metatag.tokens.inc @@ -1,4 +1,5 @@ $value['label'], - 'description' => $value['description'] + 'name' => $label, + 'description' => isset($value['description']) ? $value['description'] : '', ); } if (module_exists('taxonomy')) { $info['tokens']['term']['metatag'] = array( - 'name' => t('Metatag.'), - 'description' => t('Metatag.'), - 'type' => 'metatag' + 'name' => t('Meta tags'), + 'description' => t('Meta tags for this taxonomy term.'), + 'type' => 'metatag', ); } if (module_exists('node')) { $info['tokens']['node']['metatag'] = array( - 'name' => t('Metatag.'), - 'description' => t('Metatag.'), - 'type' => 'metatag' + 'name' => t('Meta tags'), + 'description' => t('Meta tags for this node.'), + 'type' => 'metatag', + ); + } + + if (module_exists('user')) { + $info['tokens']['user']['metatag'] = array( + 'name' => t('Meta tags'), + 'description' => t('Meta tags for this user.'), + 'type' => 'metatag', ); } + // A custom pager. + $pager = variable_get('metatag_pager_string', 'Page PAGER | '); + $page = str_replace('PAGER', 12, $pager); + $info['tokens']['current-page']['pager'] = array( + 'name' => t('Custom pager'), + 'description' => t('A custom pager (from the Metatag module). Currently set to "@pager" which would be output as e.g. "@page".', array('@pager' => $pager, '@page' => $page)), + ); + return $info; } @@ -55,7 +78,7 @@ function metatag_tokens($type, $tokens, array $data = array(), array $options = if ($type == 'metatag' && !empty($data['metatag'])) { $metatag = $data['metatag']; foreach ($tokens as $name => $original) { - if(isset($metatag[$name])){ + if (isset($metatag[$name])) { $replacements[$original] = $sanitize ? filter_xss($metatag[$name]) : $metatag[$name]; } } @@ -81,6 +104,30 @@ function metatag_tokens($type, $tokens, array $data = array(), array $options = } } + // User tokens. + if ($type == 'user' && !empty($data['user'])) { + $account = $data['user']; + + if ($metatag_tokens = token_find_with_prefix($tokens, 'metatag')) { + $result = metatag_token_generate_array($account, 'user', 'user'); + $replacements += token_generate('metatag', $metatag_tokens, array('metatag' => $result), $options); + } + } + + // Custom pager. + if ($type == 'current-page') { + foreach ($tokens as $name => $original) { + switch ($name) { + case 'pager': + $pager = metatag_get_current_pager(); + if (!empty($pager)) { + $replacements[$original] = $pager; + } + break; + } + } + } + return $replacements; } @@ -91,7 +138,7 @@ function metatag_token_generate_array($entity, $entity_type, $bundle) { if (metatag_entity_supports_metatags($entity_type, $bundle)) { $token_type = token_get_entity_mapping('entity', $entity_type); - $instance = "{$entity_type}:{$bundle}"; + $instance = metatag_get_entity_metatags_instance($entity, $entity_type, $bundle); $options = array(); $options['token data'][$token_type] = $entity; $options['entity'] = $entity; @@ -104,6 +151,8 @@ function metatag_token_generate_array($entity, $entity_type, $bundle) { } } $metatags += metatag_config_load_with_defaults($instance); + // Process it for entity metatag replacement to avoid infinite recursion. + $metatags = _metatag_token_process_metatag($metatags, $token_type); $result = array(); foreach ($metatags as $metatag => $data) { @@ -116,3 +165,87 @@ function metatag_token_generate_array($entity, $entity_type, $bundle) { return NULL; } + +/** + * Loop through metatags to avoid recursion on entity tokens. It will replace + * entity metatag token to its actual entity metatag field value. + * + * @param array $metatags + * An array of entity metatag tokens. + * @param string $token_type + * The entity token type, such as 'node' or 'term'. + * + * @return array + * Return metatags array with entity metatag tokens replaced. + */ +function _metatag_token_process_metatag($metatags, $token_type) { + foreach ($metatags as $metatag => $data) { + // Skip values that are not strings. + if (!is_string($data['value'])) { + continue; + } + + // Explode all metatag token in field. + $data_tokens = token_scan($data['value']); + if (isset($data_tokens[$token_type])) { + foreach ($data_tokens[$token_type] as $key => $value) { + $metatag_parts = explode(':', $key); + // Check entity metatag token. Like [:metatag:]. + if ($metatag_parts[0] == 'metatag') { + $entity_field = implode(':', array_slice($metatag_parts, 1)); + // If a value is not set here it will trigger an infinite loop. + $metatags[$metatag]['value'] = ''; + + // If the meta tag was defined then try parsing it. + if (!empty($metatags[$entity_field]['value'])) { + // Entity metatag field may contain other entity metatag token + // that need to be replaced too. + $replaced_value = metatag_token_entitymetatagtoken_replace($metatags, $metatags[$entity_field]['value'], $token_type); + $metatags[$metatag]['value'] = str_replace($value, $replaced_value, $metatags[$metatag]['value']); + } + } + } + } + } + + return $metatags; +} + +/** + * Replace entity metatag token with actual entity metatag field value. + * + * @param array $metatags + * An array entity metatag tokens. + * @param string $token + * A token to be replaced. + * @param string $token_type + * The entity token type, such as 'node' or 'term'. + * @param array $search_tokens + * An array of tokens to search for. + * @param array $replace_tokens + * An array of tokens to be replaced. + * + * @return string + * The replaced value of $token. + */ +function metatag_token_entitymetatagtoken_replace($metatags, $token, $token_type, $search_tokens = array(), $replace_tokens = array()) { + $data_tokens = token_scan($token); + // Check field has tokens. + if (isset($data_tokens[$token_type])) { + // Go through each token in field and find entity metatag tokens. + foreach ($data_tokens[$token_type] as $key => $value) { + $metatag_parts = explode(':', $key); + if ($metatag_parts[0] == 'metatag' && !in_array($value, $search_tokens)) { + // Entity metatag field value. + $entity_field = implode(':', array_slice($metatag_parts, 1)); + $replaced_value = metatag_token_entitymetatagtoken_replace($metatags, $metatags[$entity_field]['value'], $token_type, $replace_tokens, $search_tokens); + $replace_tokens[] = $replaced_value; + $search_tokens[] = $value; + } + } + return str_replace($search_tokens, $replace_tokens, $token); + } + else { + return $token; + } +} diff --git a/sites/all/modules/contrib/metatag/metatag.variable.inc b/sites/all/modules/contrib/metatag/metatag.variable.inc new file mode 100644 index 00000000..25ad21f4 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag.variable.inc @@ -0,0 +1,60 @@ + t('Custom pager string', array(), $options), + 'type' => 'string', + 'description' => t('When the current page includes a pager, e.g. the URL contains "?page=42", the [current-page:pager] token may be added to a meta tag to differentiate between two pages that would otherwise have the same meta tags. The value "PAGER" (must be in uppercase) will be replaced by the actual page count. Note: the pager will only output if the page number is 2 or above and the string "page=NUMBER" is in the URL.
For best use, it may be worthwhile to add the [current-page:pager] to the page title to the left of the site name, to the start of description tags, etc.', array(), $options), + 'default' => 'Page PAGER | ', + 'group' => 'metatag', + 'localize' => TRUE, + 'multidomain' => TRUE, + ); + + $info = metatag_get_info(); + $groups = $info['groups']; + $tags = $info['tags']; + foreach ($tags as $tag => $info) { + if (isset($info['maxlength'])) { + $default = $info['maxlength']; + $var_name = 'metatag_maxlength_' . $tag; + $title = $info['label']; + if (!empty($info['group']) && isset($groups[$info['group']])) { + $title = $groups[$info['group']]['label'] . ': ' . $title; + } + $variables[$var_name] = array( + 'title' => t('Maximum length for @tag', array('@tag' => $title), $options), + 'type' => 'string', + 'description' => t('Controls the maximum length of the @tag meta tag, values longer than this will be truncated. If set to "0" the maximum length will be ignored.', array('@tag' => $title), $options), + 'default' => intval(variable_get($var_name, $default)), + 'group' => 'metatag', + 'localize' => TRUE, + 'multidomain' => TRUE, + ); + } + } + + return $variables; +} + +/** + * Implements hook_variable_group_info(). + */ +function metatag_variable_group_info() { + $groups['metatag'] = array( + 'title' => t('Metatag'), + 'description' => t('Configure meta tags on your website.'), + 'access' => 'administer meta tags', + 'path' => array('admin/config/search/metatags/settings'), + ); + + return $groups; +} diff --git a/sites/all/modules/contrib/metatag/metatag.vertical-tabs.js b/sites/all/modules/contrib/metatag/metatag.vertical-tabs.js index 242cf615..d14f375d 100644 --- a/sites/all/modules/contrib/metatag/metatag.vertical-tabs.js +++ b/sites/all/modules/contrib/metatag/metatag.vertical-tabs.js @@ -6,52 +6,53 @@ (function ($) { 'use strict'; -Drupal.behaviors.metatagFieldsetSummaries = { - attach: function (context) { - $('fieldset.metatags-form', context).drupalSetSummary(function (context) { - var vals = []; - $("input[type='text'], select, textarea", context).each(function() { - var input_field = $(this).attr('name'); - // Verify the field exists before proceeding. - if (input_field === undefined) { - return false; + Drupal.behaviors.metatagFieldsetSummaries = { + attach: function (context) { + $('fieldset.metatags-form', context).drupalSetSummary(function (context) { + var vals = []; + $("input[type='text'], select, textarea", context).each(function() { + var input_field = $(this).attr('name'); + // Verify the field exists before proceeding. + if (input_field === undefined) { + return false; + } + var default_name = input_field.replace(/\[value\]/, '[default]'); + var default_value = $("input[type='hidden'][name='" + default_name + "']", context); + if (default_value.length && default_value.val() === $(this).val()) { + // Meta tag has a default value and form value matches default + // value. + return true; + } + else if (!default_value.length && !$(this).val().length) { + // Meta tag has no default value and form value is empty. + return true; + } + var label = $("label[for='" + $(this).attr('id') + "']").text(); + vals.push(Drupal.t('@label: @value', { + '@label': $.trim(label), + '@value': Drupal.truncate($(this).val(), 25) || Drupal.t('None') + })); + }); + if (vals.length === 0) { + return Drupal.t('Using defaults'); } - var default_name = input_field.replace(/\[value\]/, '[default]'); - var default_value = $("input[type='hidden'][name='" + default_name + "']", context); - if (default_value.length && default_value.val() === $(this).val()) { - // Meta tag has a default value and form value matches default value. - return true; + else { + return vals.join('
'); } - else if (!default_value.length && !$(this).val().length) { - // Meta tag has no default value and form value is empty. - return true; - } - var label = $("label[for='" + $(this).attr('id') + "']").text(); - vals.push(Drupal.t('@label: @value', { - '@label': $.trim(label), - '@value': Drupal.truncate($(this).val(), 25) || Drupal.t('None') - })); }); - if (vals.length === 0) { - return Drupal.t('Using defaults'); - } - else { - return vals.join('
'); - } - }); - } -}; + } + }; -/** - * Encode special characters in a plain-text string for display as HTML. - */ -Drupal.truncate = function (str, limit) { - if (str.length > limit) { - return str.substr(0, limit) + '...'; - } - else { - return str; - } -}; + /** + * Encode special characters in a plain-text string for display as HTML. + */ + Drupal.truncate = function (str, limit) { + if (str.length > limit) { + return str.substr(0, limit) + '...'; + } + else { + return str; + } + }; })(jQuery); diff --git a/sites/all/modules/contrib/metatag/metatag_app_links/README.txt b/sites/all/modules/contrib/metatag/metatag_app_links/README.txt new file mode 100644 index 00000000..653e74b9 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_app_links/README.txt @@ -0,0 +1,40 @@ +Metatag: App Links +------------------ +This module adds the App Links meta tags, provided by the applinks.org [1]. + +The following tags are provided: +* al:android:package +* al:android:url +* al:android:class +* al:android:app_name +* al:ios:url +* al:ios:app_store_id +* al:ios:app_name +* al:ipad:url +* al:ipad:app_store_id +* al:ipad:app_name +* al:iphone:url +* al:iphone:app_store_id +* al:iphone:app_name +* al:windows_phone:url +* al:windows_phone:app_id +* al:windows_phone:app_name +* al:windows:url +* al:windows:app_id +* al:windows:app_name +* al:windows_universal:url +* al:windows_universal:app_id +* al:windows_universal:app_name +* al:web:url +* al:web:should_fallback + + +Credits +------------------------------------------------------------------------------ +The initial development was by Andrew Berry [2]. + + +References +------------------------------------------------------------------------------ +1: http://applinks.org/ +2: https://www.drupal.org/u/deviantintegral diff --git a/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info b/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info new file mode 100644 index 00000000..d30bc86f --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.info @@ -0,0 +1,15 @@ +name = Metatag: App Links +description = "Provides support for applinks.org meta tags." +package = SEO +core = 7.x +dependencies[] = metatag:metatag + +; Tests. +files[] = tests/metatag_app_links.test +files[] = tests/metatag_app_links.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.metatag.inc b/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.metatag.inc new file mode 100644 index 00000000..8f1a4cb3 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.metatag.inc @@ -0,0 +1,163 @@ + t('App Links'), + 'description' => t('Meta tags used to expose app Links for app deep linking. See applinks.org for details and documentation.', array('@url' => 'http://applinks.org')), + 'form' => array( + '#weight' => 90, + ), + ); + + // Default values for each meta tag. + $defaults = array( + 'description' => '', + 'class' => 'DrupalTextMetaTag', + 'group' => 'app_links', + 'element' => array( + '#theme' => 'metatag_property', + ), + ); + // Stack these codes after most others. + $weight = 80; + + $info['tags']['al:android:package'] = array( + 'label' => t('Android app package ID'), + 'description' => t('A fully-qualified package name for intent generation. This attribute is required by the app Links specification.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['al:android:url'] = array( + 'label' => t('Android app URL scheme'), + 'description' => t('A custom scheme for the Android app.'), + ) + $defaults; + + $info['tags']['al:android:class'] = array( + 'label' => t('Android app Activity Class'), + 'description' => t('A fully-qualified Activity class name for intent generation.'), + ) + $defaults; + + $info['tags']['al:android:app_name'] = array( + 'label' => t('Android app name'), + 'description' => t('The name of the app (suitable for display)'), + ) + $defaults; + + $info['tags']['al:ios:url'] = array( + 'label' => t('iOS app URL scheme'), + 'description' => t('A custom scheme for the iOS app. This attribute is required by the app Links specification.'), + ) + $defaults; + + $info['tags']['al:ios:app_store_id'] = array( + 'label' => t('iOS app store ID'), + 'description' => t('The app ID for the app Store.'), + 'devel_generate' => array( + 'type' => 'integer', + ), + ) + $defaults; + + $info['tags']['al:ios:app_name'] = array( + 'label' => t('iOS app name'), + 'description' => t('The name of the app (suitable for display)'), + ) + $defaults; + + $info['tags']['al:ipad:url'] = array( + 'label' => t('iPad app URL scheme'), + 'description' => t('A custom scheme for the iPad app. This attribute is required by the app Links specification.'), + ) + $defaults; + + $info['tags']['al:ipad:app_store_id'] = array( + 'label' => t('iPad app store ID'), + 'description' => t('The app ID for the app Store.'), + 'devel_generate' => array( + 'type' => 'integer', + ), + ) + $defaults; + + $info['tags']['al:ipad:app_name'] = array( + 'label' => t('iPad app name'), + 'description' => t('The name of the app (suitable for display)'), + ) + $defaults; + + $info['tags']['al:iphone:url'] = array( + 'label' => t('iPhone app URL'), + 'description' => t('A custom scheme for the iPhone app. This attribute is required by the app Links specification.'), + ) + $defaults; + + $info['tags']['al:iphone:app_store_id'] = array( + 'label' => t('iPhone app store ID'), + 'description' => t('The app ID for the app Store.'), + 'devel_generate' => array( + 'type' => 'integer', + ), + ) + $defaults; + + $info['tags']['al:iphone:app_name'] = array( + 'label' => t('iPhone app name'), + 'description' => t('The name of the app (suitable for display)'), + ) + $defaults; + + $info['tags']['al:windows_phone:url'] = array( + 'label' => t('Windows Phone app URL scheme'), + 'description' => t('A custom scheme for the Windows Phone app. This attribute is required by the app Links specification.'), + ) + $defaults; + + $info['tags']['al:windows_phone:app_id'] = array( + 'label' => t('Windows Phone app GUID'), + 'description' => t('The app ID (a GUID) for app store.'), + ) + $defaults; + + $info['tags']['al:windows_phone:app_name'] = array( + 'label' => t('Windows Phone app name'), + 'description' => t('The name of the app (suitable for display)'), + ) + $defaults; + + $info['tags']['al:windows:url'] = array( + 'label' => t('Windows app URL scheme'), + 'description' => t('A custom scheme for the Windows app. This attribute is required by the app Links specification.'), + ) + $defaults; + + $info['tags']['al:windows:app_id'] = array( + 'label' => t('Windows app GUID'), + 'description' => t('The app ID (a GUID) for app store.'), + ) + $defaults; + + $info['tags']['al:windows:app_name'] = array( + 'label' => t('Windows app name'), + 'description' => t('The name of the app (suitable for display)'), + ) + $defaults; + + $info['tags']['al:windows_universal:url'] = array( + 'label' => t('Windows Universal app URL scheme'), + 'description' => t('A custom scheme for the Windows Universal app. This attribute is required by the app Links specification.'), + ) + $defaults; + + $info['tags']['al:windows_universal:app_id'] = array( + 'label' => t('Windows Universal app GUID'), + 'description' => t('The app ID (a GUID) for app store.'), + ) + $defaults; + + $info['tags']['al:windows_universal:app_name'] = array( + 'label' => t('Windows Universal app name'), + 'description' => t('The name of the app (suitable for display)'), + ) + $defaults; + + $info['tags']['al:web:url'] = array( + 'label' => t('Web URL'), + 'description' => t('The web URL; defaults to the URL for the content that contains this tag.'), + ) + $defaults; + + $info['tags']['al:web:should_fallback'] = array( + 'label' => t('Should fallback'), + 'description' => t('Indicates if the web URL should be used as a fallback; defaults to "true".'), + ) + $defaults; + + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.module b/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.module new file mode 100644 index 00000000..f5b6961e --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_app_links/metatag_app_links.module @@ -0,0 +1,15 @@ + 1); + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test b/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test new file mode 100644 index 00000000..6cb5bc68 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.tags.test @@ -0,0 +1,89 @@ + 'Metatag tags: App Links', + 'description' => 'Test the App Links meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'al:android:app_name', + 'al:android:class', + 'al:android:package', + 'al:android:url', + 'al:ios:app_name', + 'al:ios:app_store_id', + 'al:ios:url', + 'al:ipad:app_name', + 'al:ipad:app_store_id', + 'al:ipad:url', + 'al:iphone:app_name', + 'al:iphone:app_store_id', + 'al:iphone:url', + 'al:web:should_fallback', + 'al:web:url', + 'al:windows:app_id', + 'al:windows:app_name', + 'al:windows:url', + 'al:windows_phone:app_id', + 'al:windows_phone:app_name', + 'al:windows_phone:url', + 'al:windows_universal:app_id', + 'al:windows_universal:app_name', + 'al:windows_universal:url', + ); + + /** + * {@inheritdoc} + */ + public $test_name_attribute = 'property'; + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_app_links'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + // All of the tags have their underlines replaced with colons. + // Start with the beginning of the string. + $tag_name = str_replace('al_', 'al:', $tag_name); + + // The three-ish standard tag names. + $tag_name = str_replace('_app_id', ':app_id', $tag_name); + $tag_name = str_replace('_app_name', ':app_name', $tag_name); + $tag_name = str_replace('_app_store_id', ':app_store_id', $tag_name); + $tag_name = str_replace('_url', ':url', $tag_name); + + // One-offs. + $tag_name = str_replace('_class', ':class', $tag_name); + $tag_name = str_replace('_package', ':package', $tag_name); + $tag_name = str_replace('_should_fallback', ':should_fallback', $tag_name); + + return $tag_name; + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.test b/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.test new file mode 100644 index 00000000..c6e2c5a6 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_app_links/tests/metatag_app_links.test @@ -0,0 +1,48 @@ + 'Metatag AppLinks tests', + 'description' => 'Test the Metatag:AppLinks module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_app_links'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_context/README.txt b/sites/all/modules/contrib/metatag/metatag_context/README.txt index e8d8eae5..5ddf0db7 100644 --- a/sites/all/modules/contrib/metatag/metatag_context/README.txt +++ b/sites/all/modules/contrib/metatag/metatag_context/README.txt @@ -25,7 +25,7 @@ development was by Marcin Pajdzik [3] (sponsored by Dennis Publishing [4]). References ------------------------------------------------------------------------------ -1: http://drupal.org/project/context -2: http://drupal.org/project/context_metadata -3: http://drupal.org/user/160555 +1: https://www.drupal.org/project/context +2: https://www.drupal.org/project/context_metadata +3: https://www.drupal.org/u/marcin-pajdzik 4: http://www.dennis.co.uk/ diff --git a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.admin.inc b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.admin.inc index 2ca07ce9..3e8ba628 100644 --- a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.admin.inc +++ b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.admin.inc @@ -1,4 +1,5 @@ global defaults and will override any other meta tags assigned elsewhere.', array('@url' => url('admin/config/search/metatags/config/global'))); + $header = array(t('Name'), t('Paths'), t('Weight'), t('Operations')); $rows = array(); + + $caption = t('Values assigned here inherit from the global defaults. Use the weight to specify the order the context meta tags run.', array('@url' => url('admin/config/search/metatags/config/global'))); foreach ($contexts as $name => $context) { // Only show context items that are specifically selected to be "Shown on @@ -23,12 +24,15 @@ function metatag_context_context_overview() { l(t('Delete'), 'admin/config/search/metatags/context/' . $context->name . '/delete', array('query' => array('destination' => 'admin/config/search/metatags/context'))), ); $rows[] = array( - $context->name, - isset($context->conditions['path']) ? htmlspecialchars(implode(', ', $context->conditions['path']['values'])) : t('No path condition.'), - implode(' | ', $ops), + 'name' => $context->name, + 'path' => isset($context->conditions['path']) ? htmlspecialchars(implode(', ', $context->conditions['path']['values'])) : t('No path condition.'), + 'weight' => isset($context->reactions['metatag_context_reaction']['weight']) ? $context->reactions['metatag_context_reaction']['weight'] : 0, + 'ops' => implode(' | ', $ops), ); } } + uasort($rows, 'drupal_sort_weight'); + return theme('table', array('header' => $header, 'rows' => $rows, 'caption' => $caption)); } @@ -85,6 +89,12 @@ function metatag_context_config_add_form_submit($form, &$form_state) { $context = metatag_context_load_default_context(); $context->name = $form_state['values']['name']; context_save($context); + + // Update the i18n strings. + if (!empty($context->reactions['metatag_context_reaction']['metatags'][LANGUAGE_NONE])) { + metatag_translations_update($context->reactions['metatag_context_reaction']['metatags'][LANGUAGE_NONE], 'metatag_context:' . $context->name); + } + $form_state['redirect'] = 'admin/config/search/metatags/context/' . $context->name; } @@ -99,7 +109,9 @@ function metatag_context_config_edit_form($form, &$form_state, $context) { // Don't care about the instance name, the data is being managed by Context // and not Metatag. $instance = ""; - $options = array(); + $options = array( + 'token types' => array('node', 'term', 'user'), + ); $metatags = $context->reactions['metatag_context_reaction']['metatags']; if (!isset($metatags[LANGUAGE_NONE])) { @@ -138,14 +150,11 @@ function metatag_context_config_edit_form($form, &$form_state, $context) { $form['help'] = array( '#prefix' => '

', - '#markup' => t('Values assigned here inherit from the global defaults and will override any other meta tags assigned elsewhere.', array('@url' => url('admin/config/search/metatags/config/global'))), + '#markup' => t('Values assigned here inherit from the global defaults.', array('@url' => url('admin/config/search/metatags/config/global'))), '#suffix' => '

', '#weight' => -99, ); - // Show all tokens. - $form['metatags']['tokens']['#token_types'] = 'all'; - $form['metatags']['#type'] = 'container'; unset($form['metatags']['#collapsed']); unset($form['metatags']['#collapsible']); @@ -175,6 +184,12 @@ function metatag_context_config_edit_form_submit($form, &$form_state) { $paths = array_combine($paths, $paths); $context->conditions['path']['values'] = $paths; context_save($context); + + // Update the i18n strings. + if (!empty($context->reactions['metatag_context_reaction']['metatags'][LANGUAGE_NONE])) { + metatag_translations_update($context->reactions['metatag_context_reaction']['metatags'][LANGUAGE_NONE], 'metatag_context:' . $context->name); + } + $form_state['redirect'] = 'admin/config/search/metatags/context'; } @@ -185,7 +200,7 @@ function metatag_context_delete_form($form, &$form_state, $context) { $form_state['metatag_context']['context'] = $context; $form['delete'] = array( - '#value' => 'This action will permanently remove this item from your database.' + '#value' => 'This action will permanently remove this item from your database.', ); $form['actions']['#type'] = 'actions'; @@ -227,8 +242,7 @@ function metatag_context_load_default_context() { $context->metatag = TRUE; $context->conditions = array( 'path' => array( - 'values' => array( - ), + 'values' => array(), ), ); $context->reactions = array( diff --git a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.context.inc b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.context.inc index 9a0822fb..c3d2bca4 100644 --- a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.context.inc +++ b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.context.inc @@ -1,9 +1,13 @@ array('node', 'term', 'user'), + ); $form['help'] = array( '#prefix' => '

', @@ -52,9 +58,9 @@ 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', 'twitter-cards') as $fieldset) { - if (isset($form['metatags'][LANGUAGE_NONE][$fieldset])) { + foreach (element_children($form['metatags'][LANGUAGE_NONE]) as $fieldset) { + $child = $form['metatags'][LANGUAGE_NONE][$fieldset]; + if (isset($child['#type']) && $child['#type'] == 'fieldset') { $form['metatags'][LANGUAGE_NONE][$fieldset . '_heading'] = array( '#prefix' => '


', '#markup' => $form['metatags'][LANGUAGE_NONE][$fieldset]['#title'], @@ -90,6 +96,20 @@ class metatag_context_reaction extends context_reaction { '#default_value' => isset($data['metatag_admin']) ? $data['metatag_admin'] : '', ); + // Add weight for current metatag_context. + $default_weight = 0; + if (!empty($context->reactions['metatag_context_reaction']['weight'])) { + $default_weight = (int) $context->reactions['metatag_context_reaction']['weight']; + } + $form['weight'] = array( + '#type' => 'textfield', + '#title' => t('Weight'), + '#size' => 2, + '#default_value' => $default_weight, + '#description' => t('A higher weight will make this context be executed later, overriding other context meta tags.'), + '#weight' => -99, + ); + return $form; } @@ -112,14 +132,23 @@ class metatag_context_reaction extends context_reaction { 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'])); + + // Translate all of the meta tags using i18n, but don't update the + // strings. + metatag_translate_metatags($metadata_array, 'metatag_context:' . $context->name, NULL, FALSE); + + // Add the meta tags to the output. + foreach ($metadata_array as $langcode => $tags) { + foreach ($tags as $name => $value) { + $metatags[$langcode][$name] = $value; } } // Add this context to the list of instances. - $instance_names[] = $context->name; + $weight = isset($context->reactions['metatag_context_reaction']['weight']) + ? $context->reactions['metatag_context_reaction']['weight'] + : 0; + $instance_names[] = array('name' => $context->name, 'weight' => $weight); } } @@ -128,15 +157,37 @@ class metatag_context_reaction extends context_reaction { // Load the global defaults. $metatags += metatag_config_load_with_defaults(''); + // Sort by weight. + uasort($instance_names, 'drupal_sort_weight'); + + // Keep names only. + $instance_names = array_map('current', $instance_names); + // Compile the identifier for this combination based on the context // names. - asort($instance_names); $instance = 'context:' . implode(',', $instance_names); $options['instance'] = $instance; + // If an entity & entity type were saved elsewhere, grab them for later. + // @see hook_entity_prepare_view(). + $entities = drupal_static('metatag_context_entities'); + if (!empty($entities) && (count($entities[1]) == 1)) { + $data = array_values($entities[1]); + $options['entity'] = $data[0]; + $options['entity_type'] = $entities[0]; + $options['token data'] = array($entities[0] => $data[0]); + } + + // Don't output meta tags that only contain the pager. + $current_pager = metatag_get_current_pager(); + foreach ($metatags as $metatag => $data) { if ($metatag_instance = metatag_get_instance($metatag, $data)) { - $output[$metatag] = $metatag_instance->getElement($options); + $tag_output = $metatag_instance->getElement($options); + // Don't output the pager if that's all there is. + if ($tag_output != $current_pager) { + $output[$metatag] = $tag_output; + } } } @@ -146,6 +197,7 @@ class metatag_context_reaction extends context_reaction { } } } + } /** @@ -157,7 +209,7 @@ function metatag_context_context_default_contexts() { $context = new stdClass(); $context->disabled = TRUE; /* Edit this to true to make a default context disabled initially */ $context->api_version = 3; - $context->name = 'user_login'; + $context->name = 'metatag_context_user_login'; $context->description = 'A default Metatag:Context definition for the user login page. This needs to be enabled and then it can be customized as needed.'; $context->tag = 'Metatag'; $context->conditions = array( @@ -176,9 +228,11 @@ function metatag_context_context_default_contexts() { $context->reactions = array( 'metatag_context_reaction' => array( 'metatags' => array( - 'title' => array( - 'value' => '[current-page:title] | [site:name]', - 'default' => '[current-page:title] | [site:name]', + 'und' => array( + 'title' => array( + 'value' => '[current-page:title] | [site:name]', + 'default' => '[current-page:title] | [site:name]', + ), ), ), 'metatag_admin' => 1, @@ -190,7 +244,7 @@ function metatag_context_context_default_contexts() { $context = new stdClass(); $context->disabled = TRUE; /* Edit this to true to make a default context disabled initially */ $context->api_version = 3; - $context->name = 'user_register'; + $context->name = 'metatag_context_user_register'; $context->description = 'A default Metatag:Context definition for the user registration page. This needs to be enabled and then it can be customized as needed.'; $context->tag = 'Metatag'; $context->conditions = array( @@ -208,9 +262,11 @@ function metatag_context_context_default_contexts() { $context->reactions = array( 'metatag_context_reaction' => array( 'metatags' => array( - 'title' => array( - 'value' => '[current-page:title] | [site:name]', - 'default' => '[current-page:title] | [site:name]', + 'und' => array( + 'title' => array( + 'value' => '[current-page:title] | [site:name]', + 'default' => '[current-page:title] | [site:name]', + ), ), ), 'metatag_admin' => 1, @@ -223,7 +279,7 @@ function metatag_context_context_default_contexts() { $context = new stdClass(); $context->disabled = TRUE; /* Edit this to true to make a default context disabled initially */ $context->api_version = 3; - $context->name = 'forum'; + $context->name = 'metatag_context_forum'; $context->description = 'A default Metatag:Context definition for the main forum page. This needs to be enabled and then it can be customized as needed.'; $context->tag = 'Metatag'; $context->conditions = array( @@ -236,9 +292,11 @@ function metatag_context_context_default_contexts() { $context->reactions = array( 'metatag_context_reaction' => array( 'metatags' => array( - 'title' => array( - 'value' => '[current-page:title] | [site:name]', - 'default' => '[current-page:title] | [site:name]', + 'und' => array( + 'title' => array( + 'value' => '[current-page:title] | [site:name]', + 'default' => '[current-page:title] | [site:name]', + ), ), ), 'metatag_admin' => 1, @@ -252,7 +310,7 @@ function metatag_context_context_default_contexts() { $context = new stdClass(); $context->disabled = TRUE; /* Edit this to true to make a default context disabled initially */ $context->api_version = 3; - $context->name = 'blog'; + $context->name = 'metatag_context_blog'; $context->description = 'A default Metatag:Context definition for the main blog page. This needs to be enabled and then it can be customized as needed. Note: this does not cover the individual user blog pages, only the main blog page.'; $context->tag = 'Metatag'; $context->conditions = array( @@ -265,9 +323,11 @@ function metatag_context_context_default_contexts() { $context->reactions = array( 'metatag_context_reaction' => array( 'metatags' => array( - 'title' => array( - 'value' => '[current-page:title] | [site:name]', - 'default' => '[current-page:title] | [site:name]', + 'und' => array( + 'title' => array( + 'value' => '[current-page:title] | [site:name]', + 'default' => '[current-page:title] | [site:name]', + ), ), ), 'metatag_admin' => 1, diff --git a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.i18n.inc b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.i18n.inc new file mode 100644 index 00000000..df8bfd9e --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.i18n.inc @@ -0,0 +1,132 @@ + t('Metatag:Context configurations'), + // Callback to load all config objects. + 'list callback' => 'metatag_context_i18n_list_contexts', + // The object load callback. + // 'load callback' => 'metatag_context_i18n_load', + // @todo Custom i18n object overrides. + // 'class' => 'metatag_context_i18n_metatag', + // @todo Is this needed? What does it do? + // 'translation set' => TRUE, + + // The object key field. + 'key' => 'name', + // Placeholders for automatic paths. This connects the 'key' to strings in + // the paths listed below. + // 'placeholders' => array( + // '%name' => 'name', + // ), + // To produce edit links automatically. + // 'edit path' => 'admin/config/search/metatags/config/%instance', + // Auto-generate a 'translate' tab. + // 'translate tab' => 'admin/config/search/metatags/config/%instance/translate', + + // Properties for string translation. + 'string translation' => array( + // The textgroup, type and (below) name will be concatenated into a single + // string as the {locales_source} context. + 'textgroup' => 'metatag', + 'type' => 'metatag_context', + // Table where the object is stored, to automate string lists. + 'table' => 'context', + // Translatable properties of these objects, this will be added later. + 'properties' => array(), + // The path to translate individual strings. + // 'translate path' => 'admin/config/search/metatags/config/%instance/translate/%i18n_language', + ), + ); + + // Compile all of the tags to add to the translation stack. + $meta_tag_info = metatag_get_info(); + $groups = $meta_tag_info['groups']; + foreach ($meta_tag_info['tags'] as $tag_info) { + // Ignore certain field types that aren't translatable, mostly fields that + // list predetermined options in various forms. + if (!empty($tag_info['class']) && $tag_info['class'] == 'DrupalListMetaTag') { + continue; + } + elseif (!empty($tag_info['form']['#type']) && $tag_info['form']['#type'] == 'select') { + continue; + } + elseif (!empty($tag_info['form']['#options'])) { + continue; + } + + // Build a suitable structure for this meta tag. + $tag_name = $tag_info['name']; + $title = $tag_info['label']; + if (!empty($tag_info['group'])) { + $tag_group = $tag_info['group']; + $group_label = !empty($groups[$tag_group]['label']) ? $groups[$tag_group]['label'] : $tag_group; + $title = $group_label . ': ' . $title; + } + + $info['metatag_context']['string translation']['properties'][$tag_name] = array( + 'title' => $title, + 'field' => "reactions.metatag_context_reaction.und.{$tag_name}.value", + ); + } + + return $info; +} + +/** + * Implements hook_i18n_string_list(). + * + * @todo Functionality to delete translation records when Panels are deleted. + */ +function metatag_context_i18n_string_list($group) { + if ($group == 'metatag' || $group == 'all') { + $strings = array(); + + foreach (context_context_list() as $context_name) { + $context = context_load($context_name); + if (!empty($context->reactions['metatag_context_reaction']['metatags'][LANGUAGE_NONE])) { + $new_strings = array(); + foreach ($context->reactions['metatag_context_reaction']['metatags'][LANGUAGE_NONE] as $name => $value) { + if (isset($value['value'])) { + // Don't translate meta tags that are arrays. + if (is_array($value['value'])) { + continue; + } + // Collapse the array down one level. + else { + $new_strings[$name] = $value['value']; + } + } + } + $strings['metatag']['metatag_context'][$context->name] = $new_strings; + } + } + + return $strings; + } +} + +/** + * List callback. + */ +function metatag_context_i18n_list_contexts() { + ctools_include('export'); + $configs = ctools_export_crud_load_all('metatag_config'); + if (!empty($configs)) { + // Unserialize the config array. + foreach ($configs as &$config) { + if (is_string($config->config)) { + $config->config = unserialize($config->config); + } + } + return $configs; + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info index 757ded83..62b620b7 100644 --- a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info +++ b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.info @@ -2,14 +2,18 @@ name = Metatag: Context description = "Assigned Metatag using Context definitions, allowing them to be assigned by path and other criteria." package = SEO 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 2014-10-10 -version = "7.x-1.4" +dependencies[] = metatag:metatag +dependencies[] = context:context + +; Tests. +files[] = tests/metatag_context.test +files[] = tests/metatag_context.i18n.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.install b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.install index 78415ce6..b4229853 100644 --- a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.install +++ b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.install @@ -1,4 +1,5 @@ t('Context')); + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.module b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.module index 8e7bd91a..f70ab655 100644 --- a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.module +++ b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.module @@ -1,4 +1,5 @@ "3"); } } + +/** + * Implements hook_module_implements_alter(). + */ +function metatag_context_module_implements_alter(&$implementations, $hook) { + if ($hook == 'page_alter') { + // Run metatag_context_page_alter() last. + $group = $implementations['metatag_context']; + unset($implementations['metatag_context']); + $implementations['metatag_context'] = $group; + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.test b/sites/all/modules/contrib/metatag/metatag_context/metatag_context.test deleted file mode 100644 index 7dfc963f..00000000 --- a/sites/all/modules/contrib/metatag/metatag_context/metatag_context.test +++ /dev/null @@ -1,145 +0,0 @@ - 'Meta tag context tests', - 'description' => 'Test basic meta tag context functionality.', - 'group' => 'Metatag', - ); - } - - /** - * Prepares the testing environment - */ - public function setUp(array $modules = array()) { - $modules[] = 'metatag'; - $modules[] = 'metatag_context'; - parent::setUp($modules); - // Create user. - $this->privileged_user = $this->drupalCreateUser(array( - 'bypass node access', - 'administer content types', - 'administer meta tags', - )); - $this->drupalLogin($this->privileged_user); - // Create content type, with underscores. - $type_name = strtolower($this->randomName(8)) . '_test'; - $type = $this->drupalCreateContentType(array('name' => $type_name, 'type' => $type_name)); - $this->type = $type->type; - // Store a valid URL name, with hyphens instead of underscores. - $this->hyphen_type = str_replace('_', '-', $this->type); - } - - /** - * Performs the basic tests. - */ - public function testMetatagContextBasic() { - // Create content type node. - $this->drupalPost('node/add/' . $this->hyphen_type, array('title' => $this->randomName(8)), t('Save')); - $this->context_name = drupal_strtolower($this->randomName(8)); - - // Generate metatags and check content. - $this->metatag_pages['node'] = $this->createMetatagObject('node/1', 'node_metatags'); - $this->metatag_pages['page'] = $this->createMetatagObject('', 'frontpage_metatags'); - foreach ($this->metatag_pages as $page) { - $this->generateMetatag($page); - $this->checkMetatags($page); - } - - // Edit metatag and check content. - $this->metatag_pages['node']->title = 'New title'; - $this->metatag_pages['node']->description = ''; - $this->editMetatag($this->metatag_pages['node']); - $this->checkMetatags($this->metatag_pages['node']); - - } - - /** - * Creates a metatag object which can be used for generate and check - * the metatag_context module behavior. - * - * @param $path - * Path where generate metatags. - * @param $identifier - * Custom test to identify metatags in source code. - * - * @return $metatag_object - * Metatag mapping object. - */ - function createMetatagObject($path, $identifier) { - $metatag_object = new stdClass(); - $metatag_object->name = drupal_strtolower($this->randomName(10)); - $metatag_object->path = $path; - $metatag_object->title = "My $identifier title"; - $metatag_object->description = "My $identifier description"; - $metatag_object->abstract = "My $identifier abstract"; - $metatag_object->keywords = "My $identifier keywords"; - - return $metatag_object; - } - - /** - * Generates metatags by path from a metatag_object instance. - * - * @return $metatag_object - * Metatag mapping object. - */ - function generateMetatag($metatag_object) { - //Add new Metatag object by path. - $edit = array( - 'name' => $metatag_object->name, - ); - $this->drupalPost('admin/config/search/metatags/context/add', $edit, t('Add and configure')); - $this->editMetatag($metatag_object); - } - - /** - * Edits metatags by path from a metatag_object instance. - * - * @return $metatag_object - * Metatag mapping object. - */ - function editMetatag($metatag_object) { - $edit_metatag = array( - 'paths' => $metatag_object->path, - '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')); - } - - /** - * Checks if metatags has been added correctly from a metatag_object instance. - * - * @return $metatag_object - * Metatag mapping object. - */ - function checkMetatags($metatag_object) { - $options = array('description', 'abstract', 'keywords'); - $this->drupalGet($metatag_object->path); - - foreach ($options as $option) { - if (!empty($metatag_object->{$option})) { - $this->assertRaw($metatag_object->{$option}, $option . ' found in ' . $metatag_object->path); - } - else { - $this->assertNoRaw('saveTranslationString($lid, $i18n_context, 'fr', $object_en->$tag, $object_fr->$tag); + } + + // Confirm the configuration still works. + $this->checkByPathConfig($object_en); + + // Confirm the French configuration works too. + $this->checkByPathConfig($object_fr); + } + + /** + * Test the Metatag:Context translations for an exported configuration. + */ + public function testExportedContext() { + // Plan out the different translation string tests. + $string_en = 'Metatag:Context test description tag.'; + $string_fr = 'French page description'; + $config_name = 'metatag_context:metatag_context_test:description'; + $path = 'metatag-context-test'; + + // Confirm the string is present as it has been grabbed by the string- + // refresh triggered in $this->setUp(). + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the generator tag. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the description tag.'); + + // Save the translation string. + $this->saveTranslationString($lid, $config_name, 'fr', $string_en, $string_fr); + + // Load the English page again. + $this->drupalGet($path); + $this->assertResponse(200, 'Loaded the default test page again.'); + + // Confirm the page's description is what we set it to. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_en); + $this->assertNotEqual($xpath[0]['content'], $string_fr); + + // Load the French page. + $this->drupalGet('fr/' . $path); + $this->assertResponse(200, 'Loaded the French test page.'); + + // Confirm the generator string was translated. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_fr); + $this->assertNotEqual($xpath[0]['content'], $string_en); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.test b/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.test new file mode 100644 index 00000000..f8517306 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context.test @@ -0,0 +1,114 @@ + 'Metatag:Context tests', + 'description' => 'Test basic Metatag:Context functionality.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'context'), + ); + } + + /** + * {@inheritdoc} + */ + public function setUp(array $modules = array()) { + $modules[] = 'context'; + $modules[] = 'metatag_context'; + + // Enable the hidden submodule to manage some default configs. + $modules[] = 'metatag_context_tests'; + + parent::setUp($modules); + + // Create user. + $perms = array( + 'bypass node access', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Create a content type, with underscores. + $type_name = strtolower($this->randomName(8)) . '_test'; + $type = $this->createContentType($type_name, $type_name); + $this->type = $type->type; + + // Store a valid URL name, with hyphens instead of underscores. + $this->hyphen_type = str_replace('_', '-', $this->type); + } + + /** + * Test handling a node. + */ + public function testNode() { + // Create a node. + $this->drupalPost('node/add/' . $this->hyphen_type, array('title' => $this->randomName(8)), t('Save')); + $this->assertResponse(200); + + // Generate metatags and check content. + $test_object = $this->createTestObject('node_metatags', 'node/1'); + $this->generateByPathConfig($test_object); + $this->editByPathConfig($test_object); + $this->checkByPathConfig($test_object); + + // Edit metatag and check content. + $test_object->title = 'New title'; + $test_object->description = ''; + $this->editByPathConfig($test_object); + $this->checkByPathConfig($test_object); + } + + /** + * Test handling the front page. + */ + public function testFrontPage() { + // Generate metatags and check content. + $test_object = $this->createTestObject('frontpage_metatags', ''); + $this->generateByPathConfig($test_object); + $this->editByPathConfig($test_object); + $this->checkByPathConfig($test_object); + + // Edit metatag and check content. + $test_object->title = 'A different title'; + $test_object->description = ''; + $this->editByPathConfig($test_object); + $this->checkByPathConfig($test_object); + } + + /** + * Test the Context integration. + */ + public function testExportedPage() { + $this->drupalGet('metatag-context-test'); + $this->assertResponse(200); + + // Test the page title. + $this->assertTitle('Metatag:Context test page title tag'); + + // Test the description meta tag. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Metatag:Context test description tag.'); + + // Test the keywords meta tag. + $xpath = $this->xpath("//meta[@name='keywords']"); + $this->assertEqual(count($xpath), 1, 'Exactly one keywords meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Test, page, keywords'); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.context.inc b/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.context.inc new file mode 100644 index 00000000..57d127f9 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.context.inc @@ -0,0 +1,57 @@ +disabled = FALSE; /* Edit this to true to make a default context disabled initially */ + $context->api_version = 3; + $context->name = 'metatag_context_test'; + $context->description = 'A default Metatag:Context definition for a test page.'; + $context->tag = 'Metatag'; + $context->conditions = array( + 'path' => array( + 'values' => array( + 'metatag-context-test' => 'metatag-context-test', + ), + ), + ); + $context->reactions = array( + 'metatag_context_reaction' => array( + 'metatags' => array( + 'und' => array( + 'title' => array( + 'value' => 'Metatag:Context test page title tag', + ), + 'description' => array( + 'value' => 'Metatag:Context test description tag.', + ), + 'abstract' => array( + 'value' => '', + ), + 'keywords' => array( + 'value' => 'Test, page, keywords', + ), + ), + ), + 'metatag_admin' => 1, + ), + ); + $context->condition_mode = 1; + $defaults[$context->name] = $context; + + // Translatables + // Included for use with string extractors like potx. + t('A default Metatag:Context definition for a test page.'); + t('Metatag'); + + return $defaults; +} diff --git a/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info b/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info new file mode 100644 index 00000000..5ac2b9b3 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.info @@ -0,0 +1,16 @@ +name = Metatag:Context Tests +description = Helper module for testing metatag_context.module. +core = 7.x + +; Don't show this on the modules admin page. +hidden = TRUE + +dependencies[] = context:context +dependencies[] = metatag:metatag +dependencies[] = metatag:metatag_context + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.module b/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.module new file mode 100644 index 00000000..86dfa768 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_context/tests/metatag_context_tests.module @@ -0,0 +1,36 @@ + "3"); + } +} + +/** + * Implements hook_menu(). + */ +function metatag_context_tests_menu() { + $items['metatag-context-test'] = array( + 'title' => t('Metatag:Context test page'), + 'page callback' => 'metatag_context_tests_test_page', + 'access callback' => TRUE, + ); + + return $items; +} + +/** + * Menu callback for displaying the test page. + */ +function metatag_context_tests_test_page() { + return t('Hello'); +} diff --git a/sites/all/modules/contrib/metatag/metatag_dc/README.txt b/sites/all/modules/contrib/metatag/metatag_dc/README.txt index fb0b0a6c..ffa30ecb 100644 --- a/sites/all/modules/contrib/metatag/metatag_dc/README.txt +++ b/sites/all/modules/contrib/metatag/metatag_dc/README.txt @@ -1,7 +1,8 @@ Metatag: Dublin Core -------------------- -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]. +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]. Forty +additional tags may be added via the Metatag: Dublin Core Advanced submodule. The following tags are provided: * dcterms.contributor @@ -12,7 +13,6 @@ 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 @@ -30,8 +30,8 @@ Haag. [4]), with contributions by many in the community [5]. References ------------------------------------------------------------------------------ -1: http://dublincore.org/documents/dces/ +1: http://www.dublincore.org/documents/dces/ 2: http://www.dublincore.org/ -3: http://drupal.org/user/960720 +3: https://www.drupal.org/u/marty2081 4: http://www.gemeentemuseum.nl/ -5: http://drupal.org/node/1491616 +5: https://www.drupal.org/node/1491616 diff --git a/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info b/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info index 266a8c47..f4820e12 100644 --- a/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info +++ b/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.info @@ -2,11 +2,14 @@ name = Metatag: Dublin Core description = Provides the fifteen Dublin Core Metadata Element Set 1.1 meta tags from the Dublin Core Metadata Institute. package = SEO core = 7.x -dependencies[] = metatag +dependencies[] = metatag:metatag -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +; Tests. +files[] = tests/metatag_dc.test +files[] = tests/metatag_dc.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.install b/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.install new file mode 100644 index 00000000..dbad1e57 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.install @@ -0,0 +1,22 @@ +config += array( '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]'), @@ -71,8 +71,8 @@ function metatag_dc_metatag_bundled_config_alter(array &$configs) { */ function metatag_dc_metatag_info() { $info['groups']['dublin-core'] = array( - 'label' => t('Dublin Core'), - 'description' => t('The Dublin Core Metadata Element Set, aka "Dublin Core meta tags", are a set of internationally standardized metadata tags used to describe content to make identification and classification of content easier; the standards are controlled by the Dublin Core Metadata Initiative (DCMI).'), + 'label' => t('Dublin Core Basic Tags'), + 'description' => t('The Dublin Core Metadata Element Set, aka "Dublin Core meta tags", are a set of internationally standardized metadata tags used to describe content to make identification and classification of content easier; the standards are controlled by the Dublin Core Metadata Initiative (DCMI).', array('@url' => 'http://dublincore.org/')), 'form' => array( '#weight' => 70, ), @@ -81,190 +81,119 @@ function metatag_dc_metatag_info() { // 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.'), + // Basic tags. + $defaults = array( 'class' => 'DrupalTextMetaTag', 'group' => 'dublin-core', 'element' => array( '#type' => 'term', '#theme' => 'metatag_dc', ), - 'weight' => ++$weight, ); - $info['tags']['dcterms.creator'] = array( - 'label' => t('Dublin Core Creator'), - 'description' => t('An entity primarily responsible for making the resource. Examples of a Creator include a person, an organization, or a service. Typically, the name of a Creator should be used to indicate the entity.'), - 'group' => 'dublin-core', - 'class' => 'DrupalTextMetaTag', + + $info['tags']['dcterms.title'] = array( + 'label' => t('Title'), + 'description' => t('The name given to the resource.'), 'element' => array( + '#type' => 'term', '#theme' => 'metatag_dc', ), 'weight' => ++$weight, - ); + ) + $defaults; + $info['tags']['dcterms.creator'] = array( + 'label' => t('Creator'), + 'description' => t('An entity primarily responsible for making the resource. Examples of a Creator include a person, an organization, or a service. Typically, the name of a Creator should be used to indicate the entity.'), + 'weight' => ++$weight, + ) + $defaults; $info['tags']['dcterms.subject'] = array( - 'label' => t('Dublin Core Subject'), + 'label' => t('Subject'), 'description' => t('The topic of the resource. Typically, the subject will be represented using keywords, key phrases, or classification codes. Recommended best practice is to use a controlled vocabulary. To describe the spatial or temporal topic of the resource, use the Coverage element.'), - 'class' => 'DrupalTextMetaTag', - 'group' => 'dublin-core', - 'element' => array( - '#theme' => 'metatag_dc', - ), + 'maxlength' => 0, 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.description'] = array( - 'label' => t('Dublin Core Description'), + 'label' => t('Description'), 'description' => t('An account of the resource. Description may include but is not limited to: an abstract, a table of contents, a graphical representation, or a free-text account of the resource.'), - 'group' => 'dublin-core', - 'class' => 'DrupalTextMetaTag', - 'element' => array( - '#theme' => 'metatag_dc', - ), + 'maxlength' => 0, 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.publisher'] = array( - 'label' => t('Dublin Core Publisher'), + 'label' => t('Publisher'), 'description' => t('An entity responsible for making the resource available. Examples of a Publisher include a person, an organization, or a service. Typically, the name of a Publisher should be used to indicate the entity.'), - 'group' => 'dublin-core', - 'class' => 'DrupalTextMetaTag', - 'element' => array( - '#theme' => 'metatag_dc', - ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.contributor'] = array( - 'label' => t('Dublin Core Contributor'), + 'label' => t('Contributor'), 'description' => t('An entity responsible for making contributions to the resource. Examples of a Contributor include a person, an organization, or a service. Typically, the name of a Contributor should be used to indicate the entity.'), - 'group' => 'dublin-core', - 'class' => 'DrupalTextMetaTag', - 'element' => array( - '#theme' => 'metatag_dc', - ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.date'] = array( - 'label' => t('Dublin Core Date'), + 'label' => t('Date'), 'description' => t('A point or period of time associated with an event in the lifecycle of the resource. Date may be used to express temporal information at any level of granularity. Recommended best practice is to use an encoding scheme, such as the W3CDTF profile of ISO 8601 [W3CDTF].'), - 'class' => 'DrupalTextMetaTag', - 'group' => 'dublin-core', - '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', ), - ); + ) + $defaults; $info['tags']['dcterms.type'] = array( - 'label' => t('Dublin Core Type'), + 'label' => t('Type'), 'description' => t('The nature or genre of the resource. Recommended best practice is to use a controlled vocabulary such as the DCMI Type Vocabulary [DCMITYPE]. To describe the file format, physical medium, or dimensions of the resource, use the Format element.'), - 'class' => 'DrupalTextMetaTag', - 'group' => 'dublin-core', 'form' => array( '#type' => 'select', '#options' => _metatag_dc_dcmi_type_vocabulary_options(), '#empty_option' => t('- None -'), ), - 'element' => array( - '#theme' => 'metatag_dc', - ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.format'] = array( - 'label' => t('Dublin Core Format'), + 'label' => t('Format'), 'description' => t('The file format, physical medium, or dimensions of the resource. Examples of dimensions include size and duration. Recommended best practice is to use a controlled vocabulary such as the list of Internet Media Types [MIME].'), - 'class' => 'DrupalTextMetaTag', - 'group' => 'dublin-core', - 'element' => array( - '#theme' => 'metatag_dc', - ), 'devel_generate' => array( 'maxlength' => 1, ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.identifier'] = array( - 'label' => t('Dublin Core Identifier'), + 'label' => t('Identifier'), 'description' => t('An unambiguous reference to the resource within a given context. Recommended best practice is to identify the resource by means of a string conforming to a formal identification system.'), - 'class' => 'DrupalTextMetaTag', - 'group' => 'dublin-core', - 'element' => array( - '#theme' => 'metatag_dc', - ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.source'] = array( - 'label' => t('Dublin Core Source'), + 'label' => t('Source'), 'description' => t('A related resource from which the described resource is derived. The described resource may be derived from the related resource in whole or in part. Recommended best practice is to identify the related resource by means of a string conforming to a formal identification system.'), - 'group' => 'dublin-core', - 'class' => 'DrupalTextMetaTag', - 'element' => array( - '#theme' => 'metatag_dc', - ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.language'] = array( - 'label' => t('Dublin Core Language'), + 'label' => t('Language'), 'description' => t('A language of the resource. Recommended best practice is to use a controlled vocabulary such as RFC 4646 [RFC4646].'), - 'class' => 'DrupalTextMetaTag', - 'group' => 'dublin-core', - 'element' => array( - '#theme' => 'metatag_dc', - ), + 'is_language' => TRUE, 'devel_generate' => array( 'maxlength' => 1, ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.relation'] = array( - 'label' => t('Dublin Core Relation'), + 'label' => t('Relation'), 'description' => t('A related resource. Recommended best practice is to identify the related resource by means of a string conforming to a formal identification system.'), - 'group' => 'dublin-core', - 'class' => 'DrupalTextMetaTag', - 'element' => array( - '#theme' => 'metatag_dc', - ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.coverage'] = array( - 'label' => t('Dublin Core Coverage'), + 'label' => t('Coverage'), 'description' => t('The spatial or temporal topic of the resource, the spatial applicability of the resource, or the jurisdiction under which the resource is relevant. Spatial topic and spatial applicability may be a named place or a location specified by its geographic coordinates. Temporal topic may be a named period, date, or date range. A jurisdiction may be a named administrative entity or a geographic place to which the resource applies. Recommended best practice is to use a controlled vocabulary such as the Thesaurus of Geographic Names [TGN]. Where appropriate, named places or time periods can be used in preference to numeric identifiers such as sets of coordinates or date ranges.'), - 'group' => 'dublin-core', - 'class' => 'DrupalTextMetaTag', - 'element' => array( - '#theme' => 'metatag_dc', - ), 'weight' => ++$weight, - ); + ) + $defaults; $info['tags']['dcterms.rights'] = array( - 'label' => t('Dublin Core Rights'), + 'label' => t('Rights'), 'description' => t('Information about rights held in and over the resource. Typically, rights information includes a statement about various property rights associated with the resource, including intellectual property rights.'), - 'group' => 'dublin-core', - 'class' => 'DrupalTextMetaTag', - 'element' => array( - '#theme' => 'metatag_dc', - ), 'weight' => ++$weight, - ); + ) + $defaults; return $info; } /** - * Function that returns the DCMI type options. + * List the DCMI 'type' options. + * * Types taken from http://dublincore.org/documents/dcmi-type-vocabulary/. */ function _metatag_dc_dcmi_type_vocabulary_options() { diff --git a/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.module b/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.module index 8c150709..e6676671 100644 --- a/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.module +++ b/sites/all/modules/contrib/metatag/metatag_dc/metatag_dc.module @@ -1,4 +1,5 @@ 'name', '#schema' => 'schema', - '#value' => 'content') + '#value' => 'content', ); + element_set_attributes($element, $args); unset($element['#value']); return theme('html_tag', $variables); } diff --git a/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.tags.test b/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.tags.test new file mode 100644 index 00000000..526af3f3 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.tags.test @@ -0,0 +1,81 @@ + 'Metatag tags: Dublin Core', + 'description' => 'Test the Dublin Core meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'dcterms.contributor', + 'dcterms.coverage', + 'dcterms.creator', + 'dcterms.date', + 'dcterms.description', + 'dcterms.format', + 'dcterms.identifier', + 'dcterms.language', + 'dcterms.publisher', + 'dcterms.relation', + 'dcterms.rights', + 'dcterms.source', + 'dcterms.subject', + 'dcterms.title', + 'dcterms.type', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_dc'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + return str_replace('dcterms_', 'dcterms.', $tag_name); + } + + /** + * Implements {meta_tag_name}_test_key() for 'dcterms.type'. + */ + public function dcterms_type_test_key() { + return 'metatags[und][dcterms.type][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'dcterms.type'. + */ + public function dcterms_type_test_value() { + return 'Text'; + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'dcterms.type'. + */ + public function dcterms_type_test_field_xpath() { + return "//select[@name='metatags[und][dcterms.type][value]']"; + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.test b/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.test new file mode 100644 index 00000000..e4b8581b --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc/tests/metatag_dc.test @@ -0,0 +1,48 @@ + 'Metatag DC tests', + 'description' => 'Test the Metatag:DC module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_dc'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_dc_advanced/README.txt b/sites/all/modules/contrib/metatag/metatag_dc_advanced/README.txt new file mode 100644 index 00000000..a6dc051b --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc_advanced/README.txt @@ -0,0 +1,52 @@ +Metatag: Dublin Core Advanced +----------------------------- +This module adds the forty additional Dublin Core Metadata tags to the available +meta tags, as defined by the Dublin Core Metadata Institute [1]; it also adds +forty tags which may be useful for certain sites. + +Additional DCMI Metadata Terms meta tags: +* dcterms.abstract +* dcterms.accessRights +* dcterms.accrualMethod +* dcterms.accrualPeriodicity +* dcterms.accrualPolicy +* dcterms.alternative +* dcterms.audience +* dcterms.available +* dcterms.bibliographicCitation +* dcterms.conformsTo +* dcterms.created +* dcterms.dateAccepted +* dcterms.dateCopyrighted +* dcterms.dateSubmitted +* dcterms.educationLevel +* dcterms.extent +* dcterms.hasFormat +* dcterms.hasPart +* dcterms.hasVersion +* dcterms.instructionalMethod +* dcterms.isFormatOf +* dcterms.isPartOf +* dcterms.isReferencedBy +* dcterms.isReplacedBy +* dcterms.isRequiredBy +* dcterms.isVersionOf +* dcterms.issued +* dcterms.license +* dcterms.mediator +* dcterms.medium +* dcterms.modified +* dcterms.provenance +* dcterms.references +* dcterms.replaces +* dcterms.requires +* dcterms.rightsHolder +* dcterms.spatial +* dcterms.tableOfContents +* dcterms.temporal +* dcterms.valid + + +References +------------------------------------------------------------------------------ +1: http://www.dublincore.org/ diff --git a/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info b/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info new file mode 100644 index 00000000..c02a390f --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.info @@ -0,0 +1,16 @@ +name = Metatag: Dublin Core Advanced +description = Provides forty additional meta tags from the Dublin Core Metadata Institute. +package = SEO +core = 7.x +dependencies[] = metatag:metatag +dependencies[] = metatag:metatag_dc + +; Tests. +files[] = tests/metatag_dc_advanced.test +files[] = tests/metatag_dc_advanced.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.metatag.inc b/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.metatag.inc new file mode 100644 index 00000000..106bda8f --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.metatag.inc @@ -0,0 +1,271 @@ +instance) { + case 'node': + $config->config += array( + 'dcterms.modified' => array('value' => '[node:changed:custom:Y-m-d\TH:iP]'), + ); + break; + } + } +} + +/** + * Implements hook_metatag_info(). + * Dublin Core Elements taken from http://purl.org/dc/elements/1.1/. + */ +function metatag_dc_advanced_metatag_info() { + $info['groups']['dublin-core-additional'] = array( + 'label' => t('Dublin Core Additional Tags'), + 'description' => t('These tags are not part of the Metadata Element Set but may be useful for certain scenarios.'), + 'form' => array( + '#weight' => 71, + ), + ); + + // Dublin Core meta tags stack after the Twitter Cards tags. + $weight = 80; + + // Additional tags. + $defaults = array( + 'class' => 'DrupalTextMetaTag', + 'group' => 'dublin-core-additional', + 'element' => array( + '#type' => 'term', + '#theme' => 'metatag_dc', + ), + ); + + $info['tags']['dcterms.abstract'] = array( + 'label' => t('Abstract'), + 'description' => t('A summary of the resource.'), + 'maxlength' => 0, + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.accessRights'] = array( + 'label' => t('Access rights'), + 'description' => t('Information about who can access the resource or an indication of its security status.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.accrualMethod'] = array( + 'label' => t('Accrual Method'), + 'description' => t('The method by which items are added to a collection.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.accrualPeriodicity'] = array( + 'label' => t('Accrual Periodicity'), + 'description' => t('The frequency with which items are added to a collection.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.accrualPolicy'] = array( + 'label' => t('Accrual Policy'), + 'description' => t('The policy governing the addition of items to a collection.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.alternative'] = array( + 'label' => t('Alternative Title'), + 'description' => t('An alternative name for the resource.'), + 'maxlength' => 0, + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.audience'] = array( + 'label' => t('Audience'), + 'description' => t('A class of entity for whom the resource is intended or useful.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.available'] = array( + 'label' => t('Date Available'), + 'description' => t('Date (often a range) that the resource became or will become available.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'date', + ), + ) + $defaults; + $info['tags']['dcterms.bibliographicCitation'] = array( + 'label' => t('Bibliographic Citation'), + 'description' => t('A bibliographic reference for the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.conformsTo'] = array( + 'label' => t('Conforms To'), + 'description' => t('An established standard to which the described resource conforms.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.created'] = array( + 'label' => t('Date Created'), + 'description' => t('Date of creation of the resource.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'date', + ), + ) + $defaults; + $info['tags']['dcterms.dateAccepted'] = array( + 'label' => t('Date Accepted'), + 'description' => t('Date of acceptance of the resource.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'date', + ), + ) + $defaults; + $info['tags']['dcterms.dateCopyrighted'] = array( + 'label' => t('Date Copyrighted'), + 'description' => t('Date of copyright.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'date', + ), + ) + $defaults; + $info['tags']['dcterms.dateSubmitted'] = array( + 'label' => t('Date Submitted'), + 'description' => t('Date of submission of the resource.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'date', + ), + ) + $defaults; + $info['tags']['dcterms.educationLevel'] = array( + 'label' => t('Audience Education Level'), + 'description' => t('A class of entity, defined in terms of progression through an educational or training context, for which the described resource is intended.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.extent'] = array( + 'label' => t('Extent'), + 'description' => t('The size or duration of the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.hasFormat'] = array( + 'label' => t('Has Format'), + 'description' => t('A related resource that is substantially the same as the pre-existing described resource, but in another format.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.hasPart'] = array( + 'label' => t('Has Part'), + 'description' => t('A related resource that is included either physically or logically in the described resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.hasVersion'] = array( + 'label' => t('Has Version'), + 'description' => t('A related resource that is a version, edition, or adaptation of the described resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.instructionalMethod'] = array( + 'label' => t('Instructional Method'), + 'description' => t('A process, used to engender knowledge, attitudes and skills, that the described resource is designed to support.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.isFormatOf'] = array( + 'label' => t('Is Format Of'), + 'description' => t('A related resource that is substantially the same as the described resource, but in another format.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.isPartOf'] = array( + 'label' => t('Is Part Of'), + 'description' => t('A related resource in which the described resource is physically or logically included.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.isReferencedBy'] = array( + 'label' => t('Is Referenced By'), + 'description' => t('A related resource that references, cites, or otherwise points to the described resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.isReplacedBy'] = array( + 'label' => t('Is Replaced by'), + 'description' => t('A related resource that supplants, displaces, or supersedes the described resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.isRequiredBy'] = array( + 'label' => t('Is Required By'), + 'description' => t('A related resource that requires the described resource to support its function, delivery, or coherence.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.isVersionOf'] = array( + 'label' => t('Is Version Of'), + 'description' => t('A related resource of which the described resource is a version, edition, or adaptation.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.issued'] = array( + 'label' => t('Date Issued'), + 'description' => t('Date of formal issuance (e.g., publication) of the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.license'] = array( + 'label' => t('License'), + 'description' => t('A legal document giving official permission to do something with the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.mediator'] = array( + 'label' => t('Mediator'), + 'description' => t('An entity that mediates access to the resource and for whom the resource is intended or useful.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.medium'] = array( + 'label' => t('Medium'), + 'description' => t('The material or physical carrier of the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.modified'] = array( + 'label' => t('Modified Date'), + 'description' => t('Date on which the resource was changed.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'date', + ), + ) + $defaults; + $info['tags']['dcterms.provenance'] = array( + 'label' => t('Provenance'), + 'description' => t('A statement of any changes in ownership and custody of the resource since its creation that are significant for its authenticity, integrity, and interpretation.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.references'] = array( + 'label' => t('References'), + 'description' => t('A related resource that is referenced, cited, or otherwise pointed to by the described resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.replaces'] = array( + 'label' => t('Replaces'), + 'description' => t('A related resource that is supplanted, displaced, or superseded by the described resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.requires'] = array( + 'label' => t('Requires'), + 'description' => t('A related resource that is required by the described resource to support its function, delivery, or coherence.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.rightsHolder'] = array( + 'label' => t('Rights Holder'), + 'description' => t('A person or organization owning or managing rights over the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.spatial'] = array( + 'label' => t('Spatial'), + 'description' => t('Spatial characteristics of the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.tableOfContents'] = array( + 'label' => t('Table Of Contents'), + 'description' => t('A list of subunits of the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.temporal'] = array( + 'label' => t('Temporal'), + 'description' => t('Temporal characteristics of the resource.'), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['dcterms.valid'] = array( + 'label' => t('Valid'), + 'description' => t('Date (often a range) of validity of a resource.'), + 'weight' => ++$weight, + ) + $defaults; + + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.module b/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.module new file mode 100644 index 00000000..ee4e7c2f --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc_advanced/metatag_dc_advanced.module @@ -0,0 +1,15 @@ + 1); + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.tags.test b/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.tags.test new file mode 100644 index 00000000..1bfff027 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.tags.test @@ -0,0 +1,85 @@ + 'Metatag tags: Dublin Core Advanced', + 'description' => 'Test the Advanced Dublin Core meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'dcterms.abstract', + 'dcterms.accessRights', + 'dcterms.accrualMethod', + 'dcterms.accrualPeriodicity', + 'dcterms.accrualPolicy', + 'dcterms.alternative', + 'dcterms.audience', + 'dcterms.available', + 'dcterms.bibliographicCitation', + 'dcterms.conformsTo', + 'dcterms.created', + 'dcterms.dateAccepted', + 'dcterms.dateCopyrighted', + 'dcterms.dateSubmitted', + 'dcterms.educationLevel', + 'dcterms.extent', + 'dcterms.hasFormat', + 'dcterms.hasPart', + 'dcterms.hasVersion', + 'dcterms.instructionalMethod', + 'dcterms.isFormatOf', + 'dcterms.isPartOf', + 'dcterms.isReferencedBy', + 'dcterms.isReplacedBy', + 'dcterms.isRequiredBy', + 'dcterms.isVersionOf', + 'dcterms.issued', + 'dcterms.license', + 'dcterms.mediator', + 'dcterms.medium', + 'dcterms.modified', + 'dcterms.provenance', + 'dcterms.references', + 'dcterms.replaces', + 'dcterms.requires', + 'dcterms.rightsHolder', + 'dcterms.spatial', + 'dcterms.tableOfContents', + 'dcterms.temporal', + 'dcterms.valid', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_dc_advanced'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + return str_replace('dcterms_', 'dcterms.', $tag_name); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.test b/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.test new file mode 100644 index 00000000..dc55f94a --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_dc_advanced/tests/metatag_dc_advanced.test @@ -0,0 +1,48 @@ + 'Metatag DC Advanced tests', + 'description' => 'Test the Metatag:DC Advanced module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_dc_advanced'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info b/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info index 1f212800..9af3d42e 100644 --- a/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info +++ b/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.info @@ -1,13 +1,15 @@ -name = Metatag:Devel +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 +dependencies[] = metatag:metatag -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +; Tests. +files[] = tests/metatag_devel.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.module b/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.module index 4d61fd39..8cf04c12 100644 --- a/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.module +++ b/sites/all/modules/contrib/metatag/metatag_devel/metatag_devel.module @@ -1,4 +1,5 @@ language => $metatags, + ); + // Save the meta tags. - metatag_metatags_save('node', $node->nid, $node->vid, $metatags, $node->language); + metatag_metatags_save('node', $node->nid, $node->vid, $metatags); } } diff --git a/sites/all/modules/contrib/metatag/metatag_devel/tests/metatag_devel.test b/sites/all/modules/contrib/metatag/metatag_devel/tests/metatag_devel.test new file mode 100644 index 00000000..a2019867 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_devel/tests/metatag_devel.test @@ -0,0 +1,48 @@ + 'Metatag Devel tests', + 'description' => 'Test the Metatag:Devel module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_devel'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info b/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info index f0491440..16eaff32 100644 --- a/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info +++ b/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.info @@ -2,11 +2,14 @@ name = Metatag: Facebook description = "Provides support for Facebook's custom meta tags." package = SEO core = 7.x -dependencies[] = metatag +dependencies[] = metatag:metatag -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +; Tests. +files[] = tests/metatag_facebook.test +files[] = tests/metatag_facebook.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.install b/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.install index 61561de7..2a25e262 100644 --- a/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.install +++ b/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.install @@ -1,4 +1,5 @@ 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, + 'multiple' => TRUE, ) + $tag_info_defaults; $info['tags']['fb:app_id'] = array( @@ -47,8 +49,17 @@ function metatag_facebook_metatag_info() { // 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 FB_Social settings page to customize it.', array('!fb_social' => url('admin/config/user-interface/fb_social'))); + $info['tags']['fb:app_id']['form']['#description'] = t('The FB_Social module will automatically output this meta tag, go to the FB_Social settings page to customize it.', array('!fb_social' => url('admin/structure/fbsocial'))); } + $info['tags']['fb:pages'] = array( + 'label' => t('Pages'), + 'description' => t('Facebook Instant Articles claim URL token.'), + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'integer', + ), + ) + $tag_info_defaults; + return $info; } diff --git a/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.module b/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.module index d4942cb6..fcc8ad60 100644 --- a/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.module +++ b/sites/all/modules/contrib/metatag/metatag_facebook/metatag_facebook.module @@ -1,4 +1,5 @@ 'http://ogp.me/ns/fb#'); +} diff --git a/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.tags.test b/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.tags.test new file mode 100644 index 00000000..97e75a37 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.tags.test @@ -0,0 +1,53 @@ + 'Metatag tags: Facebook', + 'description' => 'Test the Facebook meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_facebook'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'fb:admins', + 'fb:app_id', + 'fb:pages', + ); + + /** + * {@inheritdoc} + */ + public $test_name_attribute = 'property'; + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + return str_replace('fb_', 'fb:', $tag_name); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.test b/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.test new file mode 100644 index 00000000..386a6a34 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_facebook/tests/metatag_facebook.test @@ -0,0 +1,48 @@ + 'Metatag Facebook tests', + 'description' => 'Test the Metatag:Facebook module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_facebook'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info b/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info new file mode 100644 index 00000000..e2f69a08 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.info @@ -0,0 +1,18 @@ +name = Metatag: favicons +description = "Provides support for many different favicons." +package = SEO +core = 7.x +dependencies[] = metatag:metatag + +; Custom class for mask-icon. +files[] = metatag_favicons.mask-icon.class.inc + +; Tests. +files[] = tests/metatag_favicons.test +files[] = tests/metatag_favicons.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.install b/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.install new file mode 100644 index 00000000..14ecbcb5 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.install @@ -0,0 +1,17 @@ + 'textfield', + '#title' => $this->info['label'], + '#default_value' => isset($this->data['value']) ? $this->data['value'] : '', + '#description' => isset($this->info['description']) ? $this->info['description'] : '', + '#maxlength' => 1024, + '#weight' => $this->getWeight(), + ); + $form['color'] = array( + '#type' => 'textfield', + '#title' => t('Icon: SVG color'), + '#default_value' => isset($this->data['color']) ? $this->data['color'] : '', + '#description' => t('Provides a color for the SVG icon. Per Apple\'s specifications, it may be a hexadecimal value (e.g. "#990000"), an RGB value (e.g. "rgb(153, 0, 0)"), or a recognized color-keyword (e.g. "red", "lime", "navy", etc). Will only be output if the SVG icon meta tag has a value.', array('@specs_url' => 'https://developer.apple.com/library/mac/releasenotes/General/WhatsNewInSafari/Articles/Safari_9_0.html#//apple_ref/doc/uid/TP40014305-CH9-SW20')), + '#maxlength' => 10, + '#weight' => $form['value']['#weight'] + 0.01, + ); + + return $form; + } + + /** + * {@inheritdoc} + */ + public function getValue(array $options = array()) { + $value = array( + 'value' => '', + 'color' => NULL, + ); + + // The 'color' attribute will only be output if the 'value' is present. + if (!empty($this->data['value'])) { + // Pass the 'value' through the parent logic. + $value['value'] = parent::getValue($options); + + // Get the optional 'color' attribute. + if (!empty($this->data['color'])) { + $value['color'] = check_plain($this->tidyValue($this->data['color'])); + } + } + + return $value; + } + + /** + * {@inheritdoc} + */ + public function getElement(array $options = array()) { + $value = $this->getValue($options); + + // This meta tag has two separate values. + $color = $value['color']; + $value = $value['value']; + + // Don't bother proceeding if the 'value' is empty. + if (strlen($value) === 0) { + return array(); + } + + // The stack of elements that will be output. + $elements = array(); + + // Dynamically add each option to this setting. + $base_element = isset($this->info['element']) ? $this->info['element'] : array(); + + // Combine the base configuration for this meta tag with the value. + $element = $base_element + array( + '#theme' => 'metatag', + '#tag' => 'link', + '#id' => 'metatag_' . $this->info['name'] . '_' . 1, + '#rel' => $this->info['name'], + '#name' => $this->info['name'], + '#value' => $value, + '#color' => $color, + '#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']); + + return array( + '#attached' => array('drupal_add_html_head' => $elements), + ); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.metatag.inc b/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.metatag.inc new file mode 100644 index 00000000..759ac3a4 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.metatag.inc @@ -0,0 +1,282 @@ +config['shortcut icon'] = array('value' => $favicon); + } +} + +/** + * Implements hook_metatag_info(). + */ +function metatag_favicons_metatag_info() { + $info['groups']['favicons'] = array( + 'label' => t('Favicons & touch icons'), + 'description' => t('Meta tags for displaying favicons of various sizes and types. All values should be either absolute or relative URLs. No effects are added to the "precomposed" icons.'), + 'form' => array( + '#weight' => 100, + ), + ); + + // favicons meta tags stack after the simple tags. + $weight = 100; + + // Default values for each meta tag. + $favicon_defaults = array( + 'description' => '', + 'class' => 'DrupalLinkMetaTag', + 'group' => 'favicons', + 'url' => TRUE, + 'context' => array('global'), + ); + + $info['tags']['shortcut icon'] = array( + 'label' => t('Default shortcut icon'), + 'description' => t('The traditional favicon, must be either a GIF, ICO, JPG/JPEG or PNG image.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'shortcut icon', + '#theme' => 'metatag_shortcut_icon', + ), + ) + $favicon_defaults; + + $info['tags']['mask-icon'] = array( + 'label' => t('Icon: SVG'), + 'description' => t('A grayscale scalable vector graphic (SVG) file.'), + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_mask_icon', + ), + 'class' => 'DrupalMaskIconMetaTag', + 'replaces' => array('icon_any'), + ) + $favicon_defaults; + + $info['tags']['icon_16x16'] = array( + 'label' => t('Icon: 16px x 16px'), + 'description' => t('A PNG image that is 16px wide by 16px high.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'icon', + '#sizes' => '16x16', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['icon_32x32'] = array( + 'label' => t('Icon: 32px x 32px'), + 'description' => t('A PNG image that is 32px wide by 32px high.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'icon', + '#sizes' => '32x32', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['icon_96x96'] = array( + 'label' => t('Icon: 96px x 96px'), + 'description' => t('A PNG image that is 96px wide by 96px high.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'icon', + '#sizes' => '96x96', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['icon_192x192'] = array( + 'label' => t('Icon: 192px x 192px'), + 'description' => t('A PNG image that is 192px wide by 192px high.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'icon', + '#sizes' => '192x192', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon'] = array( + 'label' => t('Apple touch icon: 60px x 60px'), + 'description' => t('A PNG image that is 60px wide by 60px high. Used with the non-Retina iPhone, iPod Touch, and Android 2.1+ devices.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon_72x72'] = array( + 'label' => t('Apple touch icon: 72px x 72px'), + 'description' => t('A PNG image that is 72px wide by 72px high. Used with the iPad mini and the first- and second-generation iPad (@1x display) on iOS <= 6.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon', + '#sizes' => '72x72', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon_76x76'] = array( + 'label' => t('Apple touch icon: 76px x 76px'), + 'description' => t('A PNG image that is 76px wide by 76px high. Used with the iPad mini and the second-generation iPad (@1x display) on iOS >= 7.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon', + '#sizes' => '76x76', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon_114x114'] = array( + 'label' => t('Apple touch icon: 114px x 114px'), + 'description' => t('A PNG image that is 114px wide by 114px high. Used with iPhone with @2x display running iOS <= 6.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon', + '#sizes' => '114x114', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon_120x120'] = array( + 'label' => t('Apple touch icon: 120px x 120px'), + 'description' => t('A PNG image that is 120px wide by 120px high. Used with iPhone with @2x display running iOS >= 7.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon', + '#sizes' => '120x120', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon_144x144'] = array( + 'label' => t('Apple touch icon: 144px x 144px'), + 'description' => t('A PNG image that is 144px wide by 144px high. Used with iPad with @2x display running iOS <= 6.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon', + '#sizes' => '144x144', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon_152x152'] = array( + 'label' => t('Apple touch icon: 152px x 152px'), + 'description' => t('A PNG image that is 152px wide by 152px high. Used with iPad with @2x display running iOS >= 7.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon', + '#sizes' => '152x152', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon_180x180'] = array( + 'label' => t('Apple touch icon: 180px x 180px'), + 'description' => t('A PNG image that is 180px wide by 180px high. Used with iPhone 6 Plus with @3x display.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon', + '#sizes' => '180x180', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon-precomposed'] = array( + 'label' => t('Apple touch icon (precomposed): 57px x 57px'), + 'description' => t('A PNG image that is 57px wide by 57px high. Used with the non-Retina iPhone, iPod Touch, and Android 2.1+ devices.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon-precomposed', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon-precomposed_72x72'] = array( + 'label' => t('Apple touch icon (precomposed): 72px x 72px'), + 'description' => t('A PNG image that is 72px wide by 72px high. Used with the iPad mini and the first- and second-generation iPad (@1x display) on iOS <= 6.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon-precomposed', + '#sizes' => '72x72', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon-precomposed_76x76'] = array( + 'label' => t('Apple touch icon (precomposed): 76px x 76px'), + 'description' => t('A PNG image that is 76px wide by 76px high. Used with the iPad mini and the second-generation iPad (@1x display) on iOS >= 7.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon-precomposed', + '#sizes' => '76x76', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon-precomposed_114x114'] = array( + 'label' => t('Apple touch icon (precomposed): 114px x 114px'), + 'description' => t('A PNG image that is 114px wide by 114px high. Used with iPhone with @2x display running iOS <= 6.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon-precomposed', + '#sizes' => '114x114', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon-precomposed_120x120'] = array( + 'label' => t('Apple touch icon (precomposed): 120px x 120px'), + 'description' => t('A PNG image that is 120px wide by 120px high. Used with iPhone with @2x display running iOS >= 7.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon-precomposed', + '#sizes' => '120x120', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon-precomposed_144x144'] = array( + 'label' => t('Apple touch icon (precomposed): 144px x 144px'), + 'description' => t('A PNG image that is 144px wide by 144px high. Used with iPad with @2x display running iOS <= 6.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon-precomposed', + '#sizes' => '144x144', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon-precomposed_152x152'] = array( + 'label' => t('Apple touch icon (precomposed): 152px x 152px'), + 'description' => t('A PNG image that is 152px wide by 152px high. Used with iPad with @2x display running iOS >= 7.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon-precomposed', + '#sizes' => '152x152', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + $info['tags']['apple-touch-icon-precomposed_180x180'] = array( + 'label' => t('Apple touch icon (precomposed): 180px x 180px'), + 'description' => t('A PNG image that is 180px wide by 180px high. Used with iPhone 6 Plus with @3x display.'), + 'weight' => ++$weight, + 'element' => array( + '#rel' => 'apple-touch-icon-precomposed', + '#sizes' => '180x180', + '#theme' => 'metatag_favicon', + ), + ) + $favicon_defaults; + + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.module b/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.module new file mode 100644 index 00000000..a3ed5759 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_favicons/metatag_favicons.module @@ -0,0 +1,168 @@ + 1); + } +} + +/** + * Implements hook_theme(). + */ +function metatag_favicons_theme() { + $info['metatag_favicon'] = array( + 'render element' => 'element', + ); + + $info['metatag_mask_icon'] = array( + 'render element' => 'element', + ); + + $info['metatag_shortcut_icon'] = array( + 'render element' => 'element', + ); + return $info; +} + +/** + * Implements hoko_html_head_alter(). + * + * Remove the default shortcut icon if one was set by Metatag. + */ +function metatag_favicons_html_head_alter(&$elements) { + if (isset($elements['metatag_shortcut icon'])) { + foreach ($elements as $key => $element) { + if (isset($element['#tag']) && $element['#tag'] == 'link') { + if (isset($element['#attributes']) && is_array($element['#attributes'])) { + if (isset($element['#attributes']['rel'])) { + if ($element['#attributes']['rel'] == 'shortcut icon') { + unset($elements[$key]); + } + } + } + } + } + } +} + +/** + * Theme callback for a favicon meta tag. + * + * The format is: + * + */ +function theme_metatag_favicon($variables) { + $element = &$variables['element']; + $args = array( + '#rel' => 'rel', + '#value' => 'href', + '#sizes' => 'sizes', + '#mask' => 'mask', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} + +/** + * Theme callback for the mask-icon meta tag. + * + * The format is: + * + */ +function theme_metatag_mask_icon($variables) { + $element = &$variables['element']; + + $args = array( + '#rel' => 'rel', + '#value' => 'href', + '#color' => 'color', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} + +/** + * Theme callback for a shortcut icon meta tag. + * + * The format is: + * + */ +function theme_metatag_shortcut_icon($variables) { + $element = &$variables['element']; + + // Extract the MIME type. + $element['#type'] = metatag_favicons_get_mime_type($element['#value']); + + $args = array( + '#rel' => 'rel', + '#value' => 'href', + '#type' => 'type', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} + +/** + * Helper function to get the theme's favicon URL. + * + * @return string + * The absolute URL to the favicon, empty string if not found. + */ +function metatag_favicons_get_theme_favicon() { + $favicon_url = ''; + + // Is the favicon enabled? + if (theme_get_setting('toggle_favicon')) { + $favicon_url = theme_get_setting('favicon'); + } + + return $favicon_url; +} + +/** + * Returns the correct MIME type for favicons. + * + * @param string $uri + * The URI, or URL, of the favicon to be checked. + * + * @return string + * The MIME type on success, an empty string on failure. + */ +function metatag_favicons_get_mime_type($uri) { + // URLs must have a file extension in order for this to work. + $extension_dot = strrpos($uri, '.'); + if (!$extension_dot) { + return ''; + } + // Return the proper MIME type based on the extension. + $extension = strtolower(substr($uri, $extension_dot + 1)); + switch ($extension) { + case 'ico': + return 'image/vnd.microsoft.icon'; + + case 'jpg': + case 'jpeg': + return 'image/jpeg'; + + case 'svg': + return 'image/svg+xml'; + + case 'gif': + case 'png': + return 'image/' . $extension; + + default: + return ''; + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_favicons/tests/druplicon-vector.svg b/sites/all/modules/contrib/metatag/metatag_favicons/tests/druplicon-vector.svg new file mode 100644 index 00000000..e40a814a --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_favicons/tests/druplicon-vector.svg @@ -0,0 +1,109 @@ + + + + + + + + 2005-04-19T17:04:57Z + 2005-04-19T18:04:24Z + Illustrator + + + + 224 + 256 + JPEG + /9j/4AAQSkZJRgABAgEASABIAAD/7QAsUGhvdG9zaG9wIDMuMAA4QklNA+0AAAAAABAASAAAAAEA AQBIAAAAAQAB/+4ADkFkb2JlAGTAAAAAAf/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoK DBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8f Hx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f/8AAEQgBAADgAwER AAIRAQMRAf/EAaIAAAAHAQEBAQEAAAAAAAAAAAQFAwIGAQAHCAkKCwEAAgIDAQEBAQEAAAAAAAAA AQACAwQFBgcICQoLEAACAQMDAgQCBgcDBAIGAnMBAgMRBAAFIRIxQVEGE2EicYEUMpGhBxWxQiPB UtHhMxZi8CRygvElQzRTkqKyY3PCNUQnk6OzNhdUZHTD0uIIJoMJChgZhJRFRqS0VtNVKBry4/PE 1OT0ZXWFlaW1xdXl9WZ2hpamtsbW5vY3R1dnd4eXp7fH1+f3OEhYaHiImKi4yNjo+Ck5SVlpeYmZ qbnJ2en5KjpKWmp6ipqqusra6voRAAICAQIDBQUEBQYECAMDbQEAAhEDBCESMUEFURNhIgZxgZEy obHwFMHR4SNCFVJicvEzJDRDghaSUyWiY7LCB3PSNeJEgxdUkwgJChgZJjZFGidkdFU38qOzwygp 0+PzhJSktMTU5PRldYWVpbXF1eX1RlZmdoaWprbG1ub2R1dnd4eXp7fH1+f3OEhYaHiImKi4yNjo +DlJWWl5iZmpucnZ6fkqOkpaanqKmqq6ytrq+v/aAAwDAQACEQMRAD8A9U4q7FXYq7FXYq7FXYq7 FXYq7FXYq7FWA/npcMn5a6jaxScLvUJbWzswKgtLJcxniCP8hWOZWjH7wHutw9cf3RHfX3pd+Un5 kzalPdeTPMcoXzXoryW5kYn/AEyOBihkUnrIvH4x1P2v5uM9XpuH1x+k/pa9HquL0S+qO3vr9L0/ MJ2DsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirsVea/mXL+lvP PkfypEQ3+nHWr5R9pIrFSYuXbjIxdfmMzNP6YSl5V83B1J4skIed/L8F5D+dNld6V+Z93qGnSta3 ytDe2dwmzK5Ran/g1ObzRQGXTgHpYef18zh1RI5Gi9r/ACm/NKx876SYp+Nt5isVA1Kx6V7evFXr Gx6/ynY/sltDqtKcUvJ6LR6sZo/0vxuz3MVzHYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7F XYq7FXYq7FXYq7FXYqo317aWNnPe3kqwWltG0s8zmioiDkzH5AYYxJNBEpACzyebflXDeeZfMWs/ mRfRvFDqI+oeXoJKhk0+Ft34ksB6jqCaftcqbHMzUkQiMY6c/e4OlBnI5T12Hued/wDOQXA+elIN WFpErD5FiP15vOx/7n4vP9t/3/wDzWxvtU0jVLfWdGnNrqlm3KKVejDoUYHYqw2IOxGZmp04yBwd LqTilb6l/K780tK88aWacbTXLVR+kNOJ3Hb1Yq7tGT/wJ2PYnk9TpjiPk9lpNXHLH+kzjMZy3Yq7 FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYqg9X1jS9H06fUtUuY7Oxt15TTymi geHuT0AG5OwyUIGRoc2M5iIsmg8yePW/zauovUim0r8t4XEhR6x3OrOhqtQN0twRUePXrThmXHAO /J934/Hng1LUHux/7r9n493SLy803QtMjRUWGCBBFa2sYCiiCioqjoAPuzFhAzk5eTJHHF8peftf bXfNF3fc+aA+nGw6EKTWntyJp7Z2Okw+HjAeH1ufxMhkx7MlxW7S51DTtRg1XSbl7HVLVuUFzGaH pQhuxBGxB2I2O2Y+fTxyCi5On1MsZsPe/wAvP+chdI1IRaX5vCaRq1OK3x2s5zUAHkf7ljXfl8O3 2hsuc3qezpQPp5fj5vU6TtOGQVLY9/45PYo5I5I1kjYPG4DI6moIO4II6g5rXagt4q7FXYq7FXYq 7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYqwvzN+aOlabqB0PRLeTzF5nNQuk2JB9Mg0JuZt0hVT 9qu47im+ZGPTEjil6Y97i5NUAeGPql3D9KW6X+W+ra7qEOu/mLdJqV1F8dloEFRptofEoSfWfxZv l8W1Jy1AiOHHsO/qWENMZHiyGz3dAyvzDrN9pkI+q2lY6AfWDT017AcV3++mQwYhM7lsz5pQGweM fmjqnmKbTPrMc5MLHhfPWjhGoFVewQk0NP65vdBjgJVXued7RyZDG726vIs3Lo3Yq7FVkkUcqlJF DKexyMog7FMZEGwnvlLz7528nOBod+ZbAGraVd1ltz1J4ioKVJ/YK175r9R2dCbs9L2pPHt0+z8e 57V5P/5yN8qaoyWnmGJ9A1BqLzkrJaOSQNpVFUqST8a8QP2s0efs6cOW70Gn7Uxz57fc9Wtbq1u7 eO5tZkuLaZQ8U0TB0dT0KspII+WYBBBouyBBFhVwJdirsVdirsVdirsVdirsVdirsVdirsVdirsV Yn5r/M3yx5duV05nk1LXZTxg0TT1+sXbMQCAyLsmxr8ZG3SuX49PKQvlHvLj5dTGBrnLuDHzoP5m +dW5eYLz/CXl9+ui6dIHvpUI+zPdAUQGvRO2xWu+W8ePH9I4pd55fJp8PLl+o8Ee4c/mzXyz5S8u eWLAWOh2MdnBt6hQVkkI/akkNXc/6xzHyZZTNyLlY8UYCoik3ytsSHzlfxQaS1sTWa5IVV/yVILH +GZOlgTK+5xdXMCFd7w38zdWjg0lNOU1mu2DMvhHGeVT82Ap9OdBocdy4u55rtDJUeHveYZtXTux V2KuxV2KrXjSReLqGU9jvgIB5pEiOSYeW/Mvmryrcev5c1KS0UnlLZOfUtpO3xRNVa070r4EZg59 BCYc/T9ozxnm9w8if85FaJqkkeneaoV0TUn+FbqpNlIf9diTF/siV/ys0Op7OnDlv+Ptej0vakMn 1bfd+x7Ajq6h0IZGAKsDUEHoQc1ztG8VdirsVdirsVdirsVdirsVdirsVQWs61pOi6dNqWq3UdnY wDlLPKaD5DuzHso3J2GShAyNDmwnMRFk0Hmo13z/APmPJw8uer5W8nE/Frkq0vrte/1VP91qez19 +XVczODHi+r1T7ugcLjyZvp9EO/qWa+TvIHlfyjamLR7QLPL/vTfSn1LmY+Mkp3678RRfbMbLnlM 7uVh08MY9IZFlTc7FUHquq2um2pnnO/SOMfaZvAZZjxmZoNeXKICy8r80+Z0ijn1XUXoBtHGO/8A LGg/z8c3GnwcoxdHqdRVyk8N1jVrrVdQlvbk/HIfhQdEUfZUewzfY8YhGg85lyGcrKCyxrdirsVd irsVdirsVWSxRyoUkUMp7HIyiCKKYyINhlXkP80/NfkZ0ghY6r5fB+PS52NYgTyLW77lD12+zudq 75qtX2bGe45/j5u50XakobHl+Pk+mvJ3nfy55v0sajolz6qCgnt3os0LkfYlSp4nbr0PYnOdy4ZY zRenw545BcU+ypudirsVdirsVdirsVdirsVY753886R5R01Lm953F7dN6OmaZAOVxdTGlEjQVPUj k1KCo7kA3YcJmduXUtOfOMY35nkO9imjfl/rPmnUYfM35jcZZI/i0vyuhraWineswqRLKf2q/TUU C3TziA4cfxPe48NPLIePL8I9A9NACgKooBsAOgGYbnOxV2KoDWNatNLg9SY8pG/uoR9pj/Ae+WYs RmdmrLmEBu8x8y+ZlCS6nqkoSJBRVHQeCIvic2+DB/DF0uo1H8UninmXzJea5e+rL+7t46i3twdl B7nxY9zm9wYRjFdXns+c5DZ5JRlzQ7FXYq7FXYq7FXYq7FXYq7FVfRdY1vy5qyaz5fuTaX6Aq6je OZCatHIh2ZTTv336gHMPU6SOQcnN0uslilzfUP5Yfmpo/njT2VQLPXLVa3+mM1WUVp6kZNOcZJ6/ snY9ieW1OlliPk9fpdXHMNubN8xnLdirsVdirsVdirsVY356872XlTTI5mha+1W9f0NJ0qHea5nP RVAqeK1HNqbfMgG7DhMz3Acy0Z84xjvJ5BJvIvkLUIdQk83ecJFvvN96tFUbwWEJ6W9sNwKV+Jh9 53Zp5swI4IbRH2teDAQeOe8z9jPcxnLdirsVY/rvmy2seUFrSe7Gx/kQ+5HU+wzJw6Yy3OwcTNqh HYbl5r5l8021jG99qc5knk+xHsXc+CjwH3DNrgwGW0Q6fUakR9Uju8f8w+Y7/W7v1rg8IV/uLdSe CD+LeJzdYcIxig6HPnlkNlKsuaXYq7FXYq7FXYq7FXYq7FXYq7FXYq3aXepaZqVvq+kXDWeq2bc7 e4T7irA7MrDYg7EbHbMfUacZBRcnTamWOQIL6o/Kz8zLDzxoplKi21qzCpqliK0Vz0kjqSfTehpX cdD4nktVpjilXR7PSaoZo31ZtmM5bsVdirsVdiqU+afM+leWdDuNY1NytvAKJGorJLI2yRRr+07n YfedqnLMWMzlQa8uUY48RYv5B8q6jdag/nnzWofzJfpxsrU7pp1o1SkEVf2yG+Nvc+JrfnyADgj9 I+0uPp8RJ8Sf1H7Az7MRzHYqhr/UrKwh9W6lEa/sr1Zj4KOpycIGRoMJ5IxFlhWs+bry95Q21ba2 OxofjYe5HT5DM/FphHc7l1ubVGWw2DzXzN59sdMDW1lxur4VBANY4z/lEdT7DNrg0hnudg6fUa2M No7yeYahqN7qF011eStNM/Vj2HgB0A9hm0hARFB1E5mRs80Pk2DsVdirsVdirsVdirsVdirsVdir sVdirsVV9H8w6t5X1y18w6O/C7tmpNGa8Joj9qKQDqrf2jcDMHW6cZI7ufoNTLHLZ9feTfNulebP L1rremPWG4FJIiQXilXZ4nHZlP3ihGxGcnlxmEqL2eHKMkeIJ1lba7FXYq7FXi8OuW/5gfmFDeu3 PyloVyINKjagjubsf3t038yj7MftvsSc2kcRxYz/ADiHUSyjNlH8wF7RmrduhrzUrCzXldTpF7E/ Efko3OTjCUuQYTyRjzLGdT887GPTo6dvXlH/ABFf6/dmXj0n85wsmt/msH1/zLaWSm71W7/eN9lW PKR6dlXr/AZsMOAy2iHW59QI7yLzHzH+YGo6lyt7KtnZHY0P71x/lMOnyH45tMOkjHc7l0+fWyns NgxXMxwnYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYqpXK8oHHsT92+QmNizgakGVfkr+YzeTf NC297KV8v6syxXoP2YZekdwPDj0f/J8aDNHrtNxxscw9B2fquCVH6S+us0D0jsVdiryj/nIPz2+h +Wk0DT5Aura8GhalC0VpSkznuOdeC7fzU3XM/s/T8c77vvdb2lqfDhXU/d+1j/kyzt7PytpkFv8A YECOSP5pBzf/AIZjmxzCpEOtwG4AslOr6qUCG8m4AU4+o3T78x/Cj3ByPFn3lKNT1nTtPjM1/cpC DuOZqzfJRVm+jLoY5S2iGjJljHeRYLrn5nTPyh0eL0l6fWpQC3zVOg+mvyzYYtCOcnW5u0CdoMIu bq5upmnuZWmmfdpHJYn6TmdGIAoOulIk2VLJIdirsVdirsVdirsVdirsVdirsVdirsVdirsVdirs VWS/3T/6p/VkZckx5hJmUMpU9DmCRbsAafU3/OPfnxvMPlL9D3snLVdCCwMSd5LYgiB/9iF4H5An rnPa7BwTvoXp+z9Rxwo8w9VzCc9xIUEk0A3JPQDFXxt5281SebvOepa8WLWZf6tpaGtFtYiQlASe PP7bD+YnOt7P0/BB4vtPU+JP8fBW0fznrulW4treVXt1rwilXkFruaHY/jmTk00JmzzcXFqpwFDk q3nn7zPcqV+tCBT1EKhT/wAFuw+/BHSYx0TPWZD1pIZppppGlmkaWRt2dyWY/MnMgADk4xJO5WYU OxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KqN03G3c+Ip9+2QyH0lnjFyCVZhuayr8 rfN58p+etO1SR+FhM31TUt6D6vMQCzdf7tuL/wCxzE1mHjge9zdDn8OYPR9oZzb1Tz/89fMz6D+X GoGElbvVCum2xAB3uAfUr4fuVkofGmZeix8WQeW7h6/LwYj57fj4PlyCIRQpGOiin0987GEaFPDT lxElUyTF2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KoPUXoip4mp+jKMx2 pvwDe0BmO5K115IV8cBFhINF9ifkv5pPmP8ALvS7qV+d5aJ9RvDuT6lvRQWJ6s8fBz885nVY+DIQ 9Zo8vHjB7tnlv/OS+sG6816Hoa0MdhbPey0NfjnfgoYdiohqP9bNp2Pi5n8bf2uo7by1UfL7/wCx 5VnRPMuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2KpTdS+pMzDoNl+Qz DySsubjjQUsgzdir3T/nFjXWS+17y87MVkSPULdK/CpU+lMaeLc4/uzTdp4+Une9k5OcWD/mdqQ1 T80fMt2BxWG4WyUVr/vKghb72jrm17LhWMe7793T9r5OLKff92zHs2bqnYq7FXYq7FXYq7FXYq7F XYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYqhr2f04+A+2/4DKss6FNuKFm0tzFct2KuxVnP5HaqNN/ NTRmZykN561nLT9r1Ym9Nf8AkaEzB18Lxl2HZs6yhIJb+XUtS1LU5TWW/vJ7mQ7btK5Y9AB1ObPS Q4YU6rWz4slt5lOI7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYq7FXYqsllWJC7dug 8TkZSoWyjEk0lMkjSOXbqcw5GzbmxjQpbgS7FXYqmXle/XTvNeh6gwqtnqFrMw6VWOZWI6HsMp1E bgQ5GmlwzB81ul/7wxnuSxP/AARzP0/0B12o+sovLmh2KuxV2KuxV2KuxV2KuxV2KuxV2KuxV2Ku xV2KuxV2KuxV2KrXdUUsxoBgJpIBJSu4naZ6nZR9kZiTnxFzIQ4QpZBm7FXYq7FVkrFFDjqrBhT2 ORnyZw5pnpX+8EX+y/4kcy9P9AcLUfWUXlzS7FXYq7FXYq7FXYqitM0nU9Vu0s9NtZbu6f7MUKl2 p4mnQe5yGTJGAuRoM8eOUzURZeo+Xv8AnHbzBdosut3sWmqdzbxj6xL8mIKxj6GbNRm7ZgNoDi+x 3WDsLJLeZ4ftZrZf849eR4U/0ia9unpuWlRBX2CIv6zmDLtnMeVB2MOw8I5mRRc35C/l5ItEt7iI 0pVJ2Jr4/Hy3yA7Xz94+TM9i6c9D80g1b/nG7R5FZtJ1ae3fqEukSZT7VT0iPuOZGPtuX8UQfd+C 4uXsCB+iRHv3/U848y/k/wCeNBVppLP69aLubiyJlAH+UlBIPnxpm0wdpYcm10fN1Oo7LzYt64h5 fi2FZnuudirsVdirsVdiqySRI15OaDBKQHNMYknZLLi4eZt9lHRcxJzMnMhARUsgzdiqc6D5N81a /U6NpVzeoDRpY4z6QPgZDRAfmcqyZoQ+o03Y8E5/SCUXrX5b+etFga41LRLqG3QVknCepGo8WePm q/ScjDU45bAhlk0uWAsxLG8vcdTuP7pvo/XkZ8mcOabWUTwrLbuKPBLJGw8Crb5laY3FxNUKmicv cd2KuxV2KuxV2Ksz/Ln8stV843nME2ujwNS6viK1PX04gftP+C9T2Bwdbro4B3y7nYaDs+WoPdAc z+p9K+WfKmg+WrAWWkWqwJQerL1llYftSP1Y/q7ZyufUTyyuRew0+mhhjwwFJvlLe7FXYq7FXYqw vzp+U3lXzQrzvD9Q1RqkX9uoDFv+LU2WT6fi98z9L2hkxbc49xddq+zMWbeuGXeP0975786/l15k 8pXFL+H1bJzSDUIatC/gCf2G/wAlvornSaXW48w9PPueV1egyYD6ht39GMZluG7FXYqpT3EcK77s ei5CcxFnCBklk0zytyY/IdhmLKRLlxiI8lmRZJjoPl3Wtf1FNO0e0kvLuTcJGNlHdnY0VVHixpkM mSMBcjQbMeKUzURZfQ3kD/nHbRNKEd95oZNV1AUYWa1+qRnwYGhlP+tRfY9c02o7RlLaGw+13um7 LjHefqP2ftewQwwwRJDCixRRgLHGgCqqjoABsBmtJt2oFL+uxwJfPP5//lXY6fAfNuhwCC3LhNVt YxRFaRqLOo/Z5MQrAdyD45uez9WZeiXwdF2noxEeJH4/reEtGZSkQFTI6qB7k0zZzOzqMY3Zp55s JdO/MPzRZSoIz+kJbhEGw9O5YzR0H+o4yXZs7xj4I7Uhw5T7ylGbB1rsVdirsVdiqfeSPKV75q8w 2+k21URv3l1PSoihUjm/40HuRmNqtQMMDI/guTo9Mc2QQHx9z610bR9O0bTLfTdOhEFpbKEjRfxY nuzHcnuc47LklORlLmXusWKOOIjEUAjMrbHYq7FXYq7FXYq7FVK6tLW7tpLa6hSe3lHGWGRQ6Mp7 FTscMZGJsbFjKIkKIsPDvzD/ACGlh9XU/KamWLdpdJY1de59Bj9of5B38CemdBo+1gfTk+f63m9d 2KR6sX+l/U8YljkikaOVTHIhKujAhlI2IIPTN4Dbz5FbIG4vlWqxbt/N2GVTy1yboYb5oFmZiSxq T1JzHJtyQKawK9J/Lj8kPMXmsxX99y0vQmowuZF/ezL1/cIex/nbbw5dMwdTro49hvJ2Gl7Pnl3O 0fxyfTHlXyf5f8raaun6LarbxbGWU/FLK380jndj+A7UGaPLmlkNyL0OHBDGKiE5ypudirsVS7zH o8OtaBqOkzAFL63kgqexdSFb/YnfJ458MhLua8sOOJj3h8X+TNP+u+ePL+nyoeM2pWyTJ0IQTLz6 +C1zpNTKoE+TyuljeQDzD0X/AJyG0Y6f+ZEGpKjCDWrJC0h+yZ7f92yqf8mNY6/PKex8u1fjvcjt vFUuLv8A7P1PPM3rzzsVdirsVdir6N/5x/8ALEdh5Wk1qRP9L1aQ8GPUW8JKKPpcMffbOY7Yz8WT g6R+963sTT8OLjPOX3B6lmod07FXYq7FXYq7FXYq7FXYq7FWF+ffyn8secYmkuUNlqdKJqNuAHNO glX7Mg+e/gRmZp9bkxbA3HucLU6DHl3IqXe8C8y/kB+YGkTObO2XWLMH4J7Rhzp25QsQ9f8AV5D3 za4u0McuZouly9m5Y8hxDyQeh/kd+ZOrSqv6LOnwk0a4vmEKrv8AyfFKfoTJ5Ndij1v3McfZ+aXS ve9r8h/kB5X8vPHe6sRrOqJRlMq0t42G/wAEW/IjxevsBmq1HaE57D0h2+m7NhDeXqP2PUumwzAd k7FXYq7FXYq7FXyp+SWlDU/zmFwkY+r6aLy9ZG3Cg1hTr3V5lIze66dYq9zzvZ0LzX3W9Q/5yU8v G+8kwa1CtbnQrlZWPf0JyIpAB/r+mfkDmF2dl4cld/6HYdqYePHfd+n8B88qwZQy7qwqD7HOtBt4 sil2FDsVdirsVfZHk+ySx8qaPaIABDZQKadz6a8j26nfOH1MuLJI+ZfQNLDhxRH9EJvlLe7FXYq7 FXYq7FXYq7FXYq7FXYq07oil3YKo3LE0A+k4qst7m2uY/Ut5UmjrTnGwZaj3FcJBHNAIPJUwJdir sVdirsVdiqB17UV0zQ9R1JjRbK2muCf+MUZfv8snjjxSA7ywyT4Yk9weLf8AOLPl/hputeYpFHK6 mSytmIPIJCvqSEduLtIv0rmw7SyXIRdZ2ViqJl8Htuq6baappl3pt4pe0vYZLe4UGhMcqlGoe2xz XRkYkEdHaTiJAg9Xxbe6Te6Hq1/oN8P9L0ud4HahAdQfgkXkAeLr8S+xGdjo8onAU8NrcJxzIKzM tw3Yq7FXYq+zvLcyT+XdKnjNY5bO3dD7NEpHTOGzipyHmX0HTm8cT/RH3JjlTc7FXYq7FXYq7FXY q7FXYqhdU1XTdKspL7UrqO0s4hWSeZgij2qe57DvkowMjQFljOYiLJoPD/PH/OSyIz2flC2ElKqd Tu1PE+8UOx+l/wDgc2uDszrP5Om1Ha3TGPiXiuvebPMvmCczazqU965NQsrn01/1IxRE+SgZtMeK MPpFOoyZpzNyNqWheY9d0C9W90e9lsrhSCWiYgMB2dfsuPZgRhyY4zFSFox5ZQNxNPpT8qfzv0/z T6Wka1wsdf8AsxsPhhuT/wAV1Pwyf5Hft4DR6vQnH6o7x+56DR9oDJ6ZbS+96rmvdm7FXYq7FXYq 84/P/XTpn5cXltCSbzV5I7C2Rd2YyNycAe8aMPpzL0ULyX3OF2hOsRHfsyfyB5YTyv5O0rQxT1bS AfWSDUGeQmSYg7beozU9spzZOOZLfgxcEBFkGVNzwP8A5yS8mNDPZ+drKIlAFs9ZCD9kmkEzUHif TJJ/kGbjsvU8J4T+PxzdH2vpeIcQ/Hd+r5PGwQQCDUHcHOmeUbxV2KuxV9Qfkj5hj1byJa25at1p RNpMvfivxRGnh6ZA+YOcl2ph4MxPSW72fZGfjwAdY7fqZ/mudo7FXYq7FXYq7FXYq7pucVeW/mB+ fnlry76tjo/HWNXWqkRt/o0Tf8WSD7RH8qfIkZn6fQSnvL0h1up7Shj2j6pfY+dPNnnbzL5rvvre tXjT8SfRtx8MMQPaOMbD59T3ObvDgjjFRDoc2onlNyKRZa0OxV2Kto7o6ujFXUhlZTQgjcEEYpfS n5LfnSdcMXlzzHKq6sqhbG+Y0+sgbcHr/u3wP7Xz66PW6Lg9UeX3PQaDX8fon9XQ9/7Xsuax2zsV dirsVeUXHHzz+ckEUZ9TQPIg9WZgapJqcp+FdiP7opX2KEftZmj93i/pT+515/e5v6MPver5hOwd iqF1bS7DVtNudM1CIT2V5G0M8TdCjih+R8COmSjIxNhjOIkKPIvjTzf5b1LyT5nuvL99WWGM+pY3 JFPWtnJ9OQfdRh2YEds6nR6viiHj9dojCZQUc0UgqjA+3fNiJA8nWSiRzX5Ji7FWU/l156u/J+vL eoplsZwIr+2H7cda8lr+2nVfu75h63SDNCuvRzdDrDgnxdDzD6o0TXNK1zTYtR0u4W5tJh8Lr1B7 qwO6sO4OcjlxSxy4ZCi9rhzRyR4omwjsrbXYq7FXYq7FWFedfzd8meVEkjubsXmpLULp1qRJLyHa Qj4Y/wDZGvgDmVg0c8nIUO9w9RrseLmbPcHz158/Orzb5sElqr/ozR3qPqFuxq6ntNLsz/LZfbNz p9FDHvzk6LU6/Jl25R7nn+ZjgvVvyy/IfVvM0cWq6276Zor0aJQALidfFA1Qin+Zhv2BG+a/Va8Q 2jvJ2ek7Olk9Uto/aXveiflf5A0aER2eh2rMOs1xGLiUn/Xl5sPo2zUT1WSXORd3j0eKHKI+9Mjo nlK5/cmwsJu/p+jC/T2ocr45jqWzw8Z6BIfMf5Ofl7rttJG+kw2NwwPC7sVFu6sf2qIAjf7JTl2P WZIHnfvaMuhxTHKvc+VvOvlHUfKfmK60W++J4TyhnAossLbpIvzHUdjUds6DBmGSIkHmtRgOKZiU kR3R1dGKupDKymhBG4IIy1qfSn5NfnZFrKQeXfMkwTWRSOzvn2W58Ec9pf8AiX+t10et0PD6o/T9 z0Gg7Q4/RP6u/v8A2vZc1jtnYq89/N78xn8saZFpWjg3HmvWSLfS7WMc3QyHh6xX5miDu3sDmVpc HGbP0hw9XqeAcMfrPJOfy28lx+UPKltpjMJtQkJudUualjLdS0MjVO5AoFB8BXrlefLxyvp0bdNh 8OFderKcpb3Yq7FWCfm9+Wtv538u+nDxi1yx5S6XcHYFj9qFz/JJT6DQ+IOTpdQccvJxNXphlj5j k+Q54Lq1uprS7ia3vLZ2iuIHBV0dDRlIPQgjOkhMSFh5acDE0Vy3VwvRz9O/68tGSQ6tJxxPRd9e uf5vwGHxZI8GLje3J/bp9Ax8WS+FFNfLfnbzR5bvfrej38ls5p6kezRSAdnjaqt923bKM2OOUVLd yMGWWI3A09e0P/nKOVY1TXdEDuPtXFlJxB/55S8v+TmavJ2X/NPzdvj7Y/nR+TJ4P+cl/wAv5FBk t9RhboVaGI/TVZW2yg9mZPJyB2ti7pfj4omT/nI78t0Qsr3kh/lW33/4ZlGR/k3L5Mj2rh8/kx3W f+co9KRGXRdFnncj4ZLyRIQD4lI/Vr/wQy6HZZ/iPyaMnbEf4Y/N5j5p/On8wPMSvDNf/ULN6g2t iDCpB7M9TIw9i1Mz8Wixw6WfN12bX5cnM0PJgvXc5luE7FXsX/OPn5c6R5gurrXtXRbm202RYray ahR5ivLnKp6qopQdCflmt7Q1MoARj1dt2ZpYzJlLcDo9R/NH85dI8nRNp9iEv/MDL8NrX93ACNmn K/eEG59hvmv0uill3O0XY6zXxxbDeX45vmjzH5381+Y7h5tY1Oe5Dmog5FYV9liWiL92b3HghAek PPZdRPIfUbSNWKkMpoRuCOoOWtT2H8k/zc1bT9dttA1y8e60i/YQ28s7F2t5m2jo7VPpsfhIOw67 b11uu0YMeKI3DtOz9bKMhGRuJ+xk/wDzlHpNgdK0bV+SrqCTtaBP2pIXQyE/KNk/4bKOy5mzHo5P bEBwxl15PnfNy6F3TcYq9e8jf85Fa/otqlhr1udZtYwFiuefC5VR2ZiGEn00Puc1ufs6MjcfS7XT 9qSgKkOIfanevf8AOUkjWjpomjejcMpAubuUOEPiIkA5fS30ZVDssDeR2bsna5IqMd/NMvyO8j6v qmoyfmR5taS41K8BOkLP9oIw4m4K9qr8MQ6cdwKFTlGszADw4cg36HASfEnuTy/X+p7fmudq7FXY q7FXYq8j/O38nB5oibzBoUap5jt0pNCKKLyNBQKT09RQKKe4+E9qZ+j1fhmj9LrtdovEHFH6vvfM LLIkjxSo0U0TFJYnBVlZTQqwO4IOb6MgQ83KJBouyTF2KuxV2KuxV2KuxV2KuxV2Kpv5f83+ZvLw uRomoy2IvFCXHpEDkFrQ7g0IqaMN8ryYYT+oXTbizzx3wmrSqaaWaV5pnaSWQlpJHJZmYmpJJ3JO WAU1k2txQ7FXdNxiqO1bXda1idJ9Wvp7+aNQkclxI0hVR2BYmgyEMcY8hTOeSUzcjaBybB2KtEgC p6Ypeo/kr+UM3m29TXdaiZPLNq/7qJgQbyVD9kf8VKftt3+yO/HWa3WcPpjzdroNFxnil9P3vqlE REVEUKigBVAoABsAAM0b0LeKuxV2KuxV2KuxV5N+cH5I2vmoSa3oIS18yIKyIaLFdhR9l+yyfyv0 7N4rnaXWHHsfpdfrNCMm8fq+98x3tne2F7NYahbvaX1u3Ce2lUq6t7g5voZBIWHnMmMxNFSybW7F XYq7FXYq7FWU/l9+XWued9TktNOKQwWwV7y8lrwiVyQuw3Zm4niPbtmPqNTHELLk6bSyzGgyDz1+ RPmzyxALy1/3M6eFrNNbRsJIiOvOKrNxp+0K+9Mpwa+GTY+kt+p7OnjFj1B5tmc692KuxV2KuxVd HHJJIscal5HIVEUEkk9AAMUgPU/IX/OP/mfXZY7rXVfRtJ2LCQUupB1okZ+x836eBzX6jtCENo+o /Y7LTdmTnvL0x+1i35o+TrLyj5wudGsZ5Li0jjiliaYqZQJEBKuVCqTX2G2ZGlzHJDiPNxtZgGLI YjkxJmVRUmgy8mnGAt6v+Uf5H33meSDW/MUb2nlwUkgtjVJbzuPdIj3bqR9n+YazV63h9MebttF2 eZeqX0/e+n7W1trS2itbWJILaBFjhhjUKiIooqqo2AAzSkkmy78AAUFXAl2KuxV2KuxV2KuxV2Ks O/MP8rPLXnizAv4/q2pxLxtNUhA9aPuFbp6iV/Zb3oQd8vwaiWM7cnG1GljlG/PvfL3nr8tfNnkm 5K6rb+tpzNxt9VgBaB69Axp8D/5LfRUb5vcGrjkHm89qdFPGfJiwIIqNxmW4beKHYq7FXYq9C/J3 8zk8katcreQtPpOpemt36f8AeRtGW4SKD1oHbkvf6Mw9ZpfFG3MOfodX4Mjf0l9UaF5h0TXrBL/R 7yK9tX/biapU/wArr9pW9mFc5/JjlA1IU9JjyxmLibCR+Y/yq8g+YZHm1HSIfrT7tdQVglLH9pmi K8z/AK1ctx6vJDkWnLo8U+Y3YRe/84w+TpW5WepX9sD+y5ilA+XwIfxzLj2pPqA4cuyMfQlLf+hW LD/qYpf+kVf+qmT/AJVP837Wv+Rx/O+xfF/zizpQesuvzungluin7y7fqwHtU/zUjseP877E90z/ AJxt/Ly1YNdNe6gR1SaYIh/5ErE3/DZVLtLKeVBuh2ViHOyzKy0DyH5Msmu7e0sdHt4xR7x+CNQ9 mmk+M/ItmNLJkymiTJy44sWIWAIvMfPv/OSNhbxyWPlCL6zcmqnVJ1Kwp7xRt8Tn3ag9jmdp+zSd 5/J12p7VA2x/N4NXzB5n11liSfV9av3LMFBkkdj1Jp0AH0AeAzamUcce4B1AhPJLvJe+fll/zjtZ 6c0Wr+chHfagKPDpS0e2hPX96ekrDw+x/rZp9TrzLaPLvd3pezhHefPue3AU2HTNa7V2KuxV2Kux V2KuxV2KuxV2KuxVTubW2ureS2uoknt5lKSwyqHR1OxVlaoIPvhBI3CCARReM+d/+caNE1BpL3yp c/oi8b4jYzcns2O32SOUkXc/tDsAM2GDtCUdpbus1HZkZbx2eFeaPI/m/wAqy8Ne0yW1iJ4pdqPU t3J6cZU5JX2rX2zbYtTCfIumzaSePmEjVlYVBrl4LjEU3hQ7FXYqjdJ1rV9Huhd6VezWNyP92wSN GxHgeJFR7HIzhGQoi2cMkom4mnoej/8AORf5i2CBLp7XU1G3K5h4vT/WgMX3kHMKfZ2I8rDnw7Uy x50WS23/ADlPqCgfWfLsUp/a9O5aOvy5RyZQeyh0l9jkDtg9Y/art/zlU3E8fLADU2Jvqivy+rjB /JX9L7P2p/ln+j9v7EFcf85Sa4w/0bQraM06ySySb/7ER5IdlR6yLE9sS6RDH9X/AOci/wAxr5GS 3ltdNU7crWGrU/1pzN94y6HZ2Ic7LRPtTNLlQ9zA7rVPM/mnU0SWa81zUpKiGIGS4k8SEUcqD2UZ kgwxjagHEIyZTvZL0zyZ/wA42eZtUMd15nuBo1iaE2cRWW7ddjQkVjjqD1JYjuuYGbtEDaO7stP2 XI7y2+9775S8jeV/KVj9U0KxS2DAevOfjmlI7ySNVm8adB2AzU5M0pm5F3OLBHGKiE+yttdirsVd irsVdirsVdirsVdirsVdirsVdiq2WKKaJ4pUWSKRSkkbgMrKwoQQdiCMQVIt555m/IL8t9cZ5UsW 0m7c1M+nN6Ir/wAYiGhp8kB98y8etyR624eXQYp9K9zzPW/+cXPMcBLaHrVtfRgE+leI9u9R0UFP WVj7njmbDtMdQ6/J2Sf4SwXVPye/NHTAGuPL08yE0DWjJdV/2MLSMPpGZcNdjPVwp9n5Y9P0sav9 I1vTnKajpl3ZOOq3EEkRHTs4Hjl8c0TyLjywTjzCB9eMGhNCOxByfGGHAXfWIv5vwOPGF4CrW8N1 cuEtreadz0WKNnJr7AYDkASMUiyHT/y1/MXUZEjtfLWofvKcHnha3jNeh9SYIlPeuUS1mMdQ3x0W U9Cy/Rv+cbfzGvqNfvZ6THUBlll9aWniqwiRD9LjMafaUBy3cvH2VM89nonl7/nGHyfZMsut31zr MineIf6LAR7pGWk+6TMPJ2jM8tnPxdmY489/sepaH5a8v6DbfVdG0+CwhIAZYI1Qtx2Bdh8Tn3Yk 5hTySlzNufDHGAqIpMsgzdirsVdirsVdirsVdir/AP/Z + + + + image/svg+xml + + 755.000000 + 826.000000 + Points + + 1 + False + False + + + Cyan + Magenta + Yellow + Black + + + + + + Default Swatch Group + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test b/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test new file mode 100644 index 00000000..0462895c --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.tags.test @@ -0,0 +1,251 @@ + 'Metatag tags: Favicons', + 'description' => 'Test the Favicons meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'apple-touch-icon', + 'apple-touch-icon-precomposed', + 'apple-touch-icon-precomposed_114x114', + 'apple-touch-icon-precomposed_120x120', + 'apple-touch-icon-precomposed_144x144', + 'apple-touch-icon-precomposed_152x152', + 'apple-touch-icon-precomposed_180x180', + 'apple-touch-icon-precomposed_72x72', + 'apple-touch-icon-precomposed_76x76', + 'apple-touch-icon_114x114', + 'apple-touch-icon_120x120', + 'apple-touch-icon_144x144', + 'apple-touch-icon_152x152', + 'apple-touch-icon_180x180', + 'apple-touch-icon_72x72', + 'apple-touch-icon_76x76', + 'icon_16x16', + 'icon_192x192', + 'icon_32x32', + 'icon_96x96', + 'mask-icon', + 'shortcut icon', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_favicons'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public $test_tag = 'link'; + + /** + * {@inheritdoc} + */ + public $test_name_attribute = 'rel'; + + /** + * {@inheritdoc} + */ + public $test_value_attribute = 'href'; + + /** + * {@inheritdoc} + */ + public function getTestTagValue() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'icon_16x16'. + */ + public function icon_16x16_test_output_xpath() { + return "//link[@rel='icon' and @sizes='16x16']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'icon_192x192'. + */ + public function icon_192x192_test_output_xpath() { + return "//link[@rel='icon' and @sizes='192x192']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'icon_32x32'. + */ + public function icon_32x32_test_output_xpath() { + return "//link[@rel='icon' and @sizes='32x32']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'icon_96x96'. + */ + public function icon_96x96_test_output_xpath() { + return "//link[@rel='icon' and @sizes='96x96']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed'. + */ + public function apple_touch_icon_precomposed_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and not(@sizes)]"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_114x114'. + */ + public function apple_touch_icon_precomposed_114x114_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='114x114']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_120x120'. + */ + public function apple_touch_icon_precomposed_120x120_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='120x120']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_144x144'. + */ + public function apple_touch_icon_precomposed_144x144_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='144x144']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_152x152'. + */ + public function apple_touch_icon_precomposed_152x152_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='152x152']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_180x180'. + */ + public function apple_touch_icon_precomposed_180x180_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='180x180']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_72x72'. + */ + public function apple_touch_icon_precomposed_72x72_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='72x72']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_precomposed_76x76'. + */ + public function apple_touch_icon_precomposed_76x76_test_output_xpath() { + return "//link[@rel='apple-touch-icon-precomposed' and @sizes='76x76']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'apple_touch_icon'. + */ + public function apple_touch_icon_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and not(@sizes)]"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_114x114'. + */ + public function apple_touch_icon_114x114_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='114x114']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_120x120'. + */ + public function apple_touch_icon_120x120_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='120x120']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_144x144'. + */ + public function apple_touch_icon_144x144_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='144x144']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_152x152'. + */ + public function apple_touch_icon_152x152_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='152x152']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_180x180'. + */ + public function apple_touch_icon_180x180_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='180x180']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_72x72'. + */ + public function apple_touch_icon_72x72_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='72x72']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'apple_touch_icon_76x76'. + */ + public function apple_touch_icon_76x76_test_output_xpath() { + return "//link[@rel='apple-touch-icon' and @sizes='76x76']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath for 'mask-icon'. + */ + public function mask_icon_test_tag_name() { + return 'mask-icon'; + } + + /** + * Implements {meta_tag_name}_test_tag_name for 'shortcut icon'. + */ + public function shortcut_icon_test_tag_name() { + return 'shortcut icon'; + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.test b/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.test new file mode 100644 index 00000000..eaa94a2b --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_favicons/tests/metatag_favicons.test @@ -0,0 +1,233 @@ + 'Metatag Favicons tests', + 'description' => 'Test the Metatag:Favicons module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_favicons'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + + /** + * Confirm the mask-icon meta tag works correctly. + */ + public function testMaskIconValue() { + // The SVG image is copied from the archive obtained from + // https://www.drupal.org/about/media-kit/logos on 6/20/2016. + $svg_path = drupal_get_path('module', 'metatag_favicons') . '/tests/druplicon-vector.svg'; + $relative_path = url($svg_path, array('absolute' => FALSE)); + $absolute_path = url($svg_path, array('absolute' => TRUE)); + + // Testbot doesn't have "clean_url" enabled. + $relative_path = str_replace('?q=', '', $relative_path); + $absolute_path = str_replace('?q=', '', $absolute_path); + + // Try filling in a path relative to the Drupal installation. + $config = metatag_config_load('global'); + $config->config['mask-icon']['value'] = $svg_path; + metatag_config_save($config); + + // Load the config page. + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the meta tag's value is on the page. + $this->assertText(t('Icon: SVG') . ':'); + $this->assertText($absolute_path); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm the meta tag is present. + $xpath = $this->xpath("//link[@rel='mask-icon']"); + $this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.'); + $this->assertNotEqual((string) $xpath[0]['href'], $svg_path); + $this->assertEqual((string) $xpath[0]['href'], $absolute_path); + + // Before proceeding, clear the site's caches. + drupal_flush_all_caches(); + + // Try filling in a relative path. + $config = metatag_config_load('global'); + $config->config['mask-icon']['value'] = $relative_path; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm the meta tag is present. + $xpath = $this->xpath("//link[@rel='mask-icon']"); + $this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.'); + $this->assertNotEqual((string) $xpath[0]['href'], $svg_path); + $this->assertNotEqual((string) $xpath[0]['href'], $relative_path); + + // Before proceeding, clear the site's caches. + drupal_flush_all_caches(); + + // Test filling in an absolute path. + $config = metatag_config_load('global'); + $config->config['mask-icon']['value'] = $absolute_path; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm the meta tag is present. + $xpath = $this->xpath("//link[@rel='mask-icon']"); + $this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.'); + $this->assertNotEqual((string) $xpath[0]['href'], $svg_path); + $this->assertEqual((string) $xpath[0]['href'], $absolute_path); + + // Before proceeding, clear the site's caches. + drupal_flush_all_caches(); + + // Test filling in an absolute path for an external file. + $path = 'https://www.example.com/example.svg'; + $config = metatag_config_load('global'); + $config->config['mask-icon']['value'] = $path; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm the meta tag is present. + $xpath = $this->xpath("//link[@rel='mask-icon']"); + $this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.'); + $this->assertNotEqual((string) $xpath[0]['href'], $absolute_path); + $this->assertEqual((string) $xpath[0]['href'], $path); + } + + /** + * Confirm the mask-icon meta tag 'color' attribute works correctly. + */ + public function testMaskIconColor() { + // The SVG image is copied from the archive obtained from + // https://www.drupal.org/about/media-kit/logos on 6/20/2016. + $svg_path = drupal_get_path('module', 'metatag_favicons') . '/tests/druplicon-vector.svg'; + $absolute_path = url($svg_path, array('absolute' => TRUE)); + + // Testbot doesn't have "clean_url" enabled. + $absolute_path = str_replace('?q=', '', $absolute_path); + + // Try a color string. + $color = 'red'; + + // Update the global config. + $config = metatag_config_load('global'); + $config->config['mask-icon']['value'] = $svg_path; + $config->config['mask-icon']['color'] = $color; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm the meta tag is present. + $xpath = $this->xpath("//link[@rel='mask-icon']"); + $this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.'); + $this->assertEqual((string) $xpath[0]['href'], $absolute_path); + $this->assertEqual((string) $xpath[0]['color'], $color); + + // Before proceeding, clear the site's caches. + drupal_flush_all_caches(); + + // Try a color hex code. + $color = '#990000'; + + // Update the global config. + $config = metatag_config_load('global'); + $config->config['mask-icon']['value'] = $svg_path; + $config->config['mask-icon']['color'] = $color; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm the meta tag is present. + $xpath = $this->xpath("//link[@rel='mask-icon']"); + $this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.'); + $this->assertEqual((string) $xpath[0]['href'], $absolute_path); + $this->assertEqual((string) $xpath[0]['color'], $color); + + // Try a color RGB value. + $color = 'rgb(153, 0, 0)'; + + // Update the global config. + $config = metatag_config_load('global'); + $config->config['mask-icon']['value'] = $svg_path; + $config->config['mask-icon']['color'] = $color; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm the meta tag is present. + $xpath = $this->xpath("//link[@rel='mask-icon']"); + $this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.'); + $this->assertEqual((string) $xpath[0]['href'], $absolute_path); + $this->assertEqual((string) $xpath[0]['color'], $color); + + // Try empty color. + $color = ''; + + // Update the global config. + $config = metatag_config_load('global'); + $config->config['mask-icon']['value'] = $svg_path; + $config->config['mask-icon']['color'] = $color; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm the meta tag is present. + $xpath = $this->xpath("//link[@rel='mask-icon']"); + $this->assertEqual(count($xpath), 1, 'One mask-icon meta tag found.'); + $this->assertEqual((string) $xpath[0]['href'], $absolute_path); + $this->assertFalse(isset($xpath[0]['color'])); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_google_cse/README.txt b/sites/all/modules/contrib/metatag/metatag_google_cse/README.txt new file mode 100644 index 00000000..4884d60f --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_cse/README.txt @@ -0,0 +1,22 @@ +Metatag: Google Custom Search Engine (CSE) +------------------------------------------ +This module adds certain meta tags that are primarily used by Google's Custom +Search Engine aka "CSE". + +The following meta tags are provided: +* thumbnail +* department +* audience +* doc_status +* rating + + +Credits +------------------------------------------------------------------------------ +The initial development was by Carlos E Basqueira [3]. + + +References +------------------------------------------------------------------------------ +1: http://www.dublincore.org/documents/dces/ +2: https://www.drupal.org/u/cebasqueira diff --git a/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info b/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info new file mode 100644 index 00000000..6c71f245 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.info @@ -0,0 +1,15 @@ +name = "Metatag: Google Custom Search Engine (CSE)" +description = "Provides support for meta tags used for Google Custom Search Engine." +package = SEO +core = 7.x +dependencies[] = metatag:metatag + +; Tests. +files[] = tests/metatag_google_cse.test +files[] = tests/metatag_google_cse.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.install b/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.install new file mode 100644 index 00000000..db1dd118 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.install @@ -0,0 +1,6 @@ + t('Google Custom Search Engine (CSE)'), + 'description' => t("Meta tags used to control the mobile browser experience. Some of these meta tags have been replaced by newer mobile browsers. These meta tags usually only need to be set globally, rather than per-page."), + 'form' => array( + '#weight' => 80, + ), + ); + + $weight = 80; + + // Default values for each meta tag. + $tag_info_defaults = array( + 'class' => 'DrupalTextMetaTag', + 'group' => 'google_cse', + 'element' => array( + '#theme' => 'metatag_google_cse', + ), + ); + + $info['tags']['thumbnail'] = array( + 'label' => t('Thumbnail'), + 'description' => t('Use a url of a valid image.'), + 'image' => TRUE, + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['department'] = array( + 'label' => t('Department'), + 'description' => t('Department tag.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['audience'] = array( + 'label' => t('Content audience'), + 'description' => t('The content audience, e.g. "all".'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['doc_status'] = array( + 'label' => t('Document status'), + 'description' => t('The document status, e.g. "draft".'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + $info['tags']['google_rating'] = array( + 'label' => t('Results sorting'), + 'description' => t('Works only with numeric values.'), + 'weight' => ++$weight, + ) + $tag_info_defaults; + + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.module b/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.module new file mode 100644 index 00000000..9110e8ef --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_cse/metatag_google_cse.module @@ -0,0 +1,48 @@ + 1); + } +} + +/** + * Implements hook_theme(). + */ +function metatag_google_cse_theme() { + $info['metatag_google_cse'] = array( + 'render element' => 'element', + ); + + return $info; +} + +/** + * Theme callback for a normal meta tag. + * + * The format is: + * + */ +function theme_metatag_google_cse($variables) { + $element = &$variables['element']; + + if ($element['#name'] === 'google_rating') { + $element['#name'] = 'rating'; + } + + $args = array( + '#name' => 'name', + '#value' => 'content', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} diff --git a/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test b/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test new file mode 100644 index 00000000..3aff8ad7 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.tags.test @@ -0,0 +1,57 @@ + 'Metatag tags: Google CSE', + 'description' => 'Test the Metatag:Google CSE meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'audience', + 'department', + 'doc_status', + 'google_rating', + 'thumbnail', + ); + + /** + * {@inheritdoc} + */ + public function setUp(array $modules = array()) { + $modules[] = 'metatag_google_cse'; + parent::setUp($modules); + } + + /** + * Implements {meta_tag_name}_test_tag_name() for 'google_rating'. + */ + public function google_rating_test_tag_name() { + return 'rating'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'thumbnail'. + */ + public function thumbnail_test_value() { + return $this->randomImageUrl(); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test b/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test new file mode 100644 index 00000000..5698be6f --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_cse/tests/metatag_google_cse.test @@ -0,0 +1,48 @@ + 'Metatag Google CSE tests', + 'description' => 'Test the Metatag:Google CSE module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public function setUp(array $modules = array()) { + $modules[] = 'metatag_google_cse'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_google_plus/README.txt b/sites/all/modules/contrib/metatag/metatag_google_plus/README.txt index 5a9951c4..cf7b2ed0 100644 --- a/sites/all/modules/contrib/metatag/metatag_google_plus/README.txt +++ b/sites/all/modules/contrib/metatag/metatag_google_plus/README.txt @@ -1,5 +1,5 @@ Metatag: Google+ ------------------ +---------------- This module adds support for meta tag configuration for Google+ Snippet [1]. The following Google+ tags are provided: @@ -7,6 +7,8 @@ The following Google+ tags are provided: * itemprop:name * itemprop:description * itemprop:image +* author +* publisher Also itemtype is provided to add schema in the HTML markup as follows: @@ -20,31 +22,15 @@ Page type (itemtype) provides default type options from the Google+ Snippet page Metatag hooks (see metatag.api.php). -Known Issues +Installation -------------------------------------------------------------------------------- -- 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']}"; - } -} +The $schemaorg variable must be appended to the tag in the html.tpl.php +file being used on the site, and it must be added after the $rdf_namespaces +variable, e.g.: + +> Credits / Contact diff --git a/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.inc b/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.inc index c5d81de9..3aef2081 100644 --- a/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.inc +++ b/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.inc @@ -1,4 +1,5 @@ getValue($options); $element['#attached']['metatag_set_preprocess_variable'][] = array('html', 'itemtype', $value); return $element; } + } diff --git a/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info b/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info index 5092fa6f..e25160fb 100644 --- a/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info +++ b/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.info @@ -1,15 +1,18 @@ name = Metatag: Google+ -description = "Provides support for Google+ 'itemscope' meta tags." +description = "Provides support for Google+ 'itemscope', 'author' and 'publisher' meta tags." package = SEO core = 7.x -dependencies[] = metatag +dependencies[] = metatag:metatag files[] = metatag_google_plus.inc -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +; Tests. +files[] = tests/metatag_google_plus.test +files[] = tests/metatag_google_plus.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.install b/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.install new file mode 100644 index 00000000..26987531 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.install @@ -0,0 +1,33 @@ +config += array( - 'itemprop:name' => array('value' => '[current-page:title]'), + 'itemprop:name' => array('value' => '[site:name]'), + 'itemprop:description' => array('value' => '[site:slogan]'), ); break; @@ -26,14 +28,15 @@ function metatag_google_plus_metatag_bundled_config_alter(array &$configs) { case 'global:403': case 'global:404': $config->config += array( - 'itemprop:name' => array('value' => '[current-page:title]'), + 'itemprop:name' => array('value' => '[site:name]'), ); break; case 'node': $config->config += array( 'itemprop:description' => array('value' => '[node:summary]'), - 'itemprop:name' => array('value' => '[current-page:title]'), + 'itemprop:name' => array('value' => '[node:title]'), + 'itemtype' => array('value' => 'Article'), ); break; @@ -47,6 +50,7 @@ function metatag_google_plus_metatag_bundled_config_alter(array &$configs) { case 'user': $config->config += array( 'itemprop:name' => array('value' => '[user:name]'), + 'itemtype' => array('value' => 'Person'), ); if (variable_get('user_pictures')) { $config->config += array( @@ -66,7 +70,7 @@ function metatag_google_plus_metatag_info() { 'label' => t('Google+'), 'description' => t('A set of meta tags specially for controlling the summaries displayed when content is shared on Google+.', array('!url' => 'https://plus.google.com/')), 'form' => array( - '#weight' => 70, + '#weight' => 80, ), ); @@ -87,6 +91,7 @@ function metatag_google_plus_metatag_info() { 'description' => t('Schema type. More schema info. If your page type does not exist in options above, please install select_or_other 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, + 'select_or_other' => TRUE, 'form' => array( '#type' => 'select', '#options' => array( @@ -104,32 +109,48 @@ function metatag_google_plus_metatag_info() { ), ) + $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.'), + 'maxlength' => 0, 'weight' => ++$weight, ) + $defaults; $info['tags']['itemprop:description'] = array( 'label' => t('Description'), 'description' => t('Longer form description, you’ve 200 words here that can specifically reference your presence on Google+'), + 'maxlength' => 0, 'weight' => ++$weight, ) + $defaults; $info['tags']['itemprop:image'] = array( '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. '), + '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, + 'image' => TRUE, 'devel_generate' => array( 'type' => 'image', ), ) + $defaults; + $info['tags']['author'] = array( + 'label' => t('Author URL'), + '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', + 'weight' => ++$weight, + 'element' => array(), + 'devel_generate' => array( + 'type' => 'url', + ), + ) + $defaults; + $info['tags']['publisher'] = array( + 'label' => t('Publisher URL'), + 'description' => t("Used by some search engines to confirm publication of the content on a page. Should be the full URL for the publication's Google+ profile page."), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + 'element' => array(), + 'devel_generate' => array( + 'type' => 'url', + ), + ) + $defaults; + return $info; } diff --git a/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.module b/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.module index 8b257580..a015a7cb 100644 --- a/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.module +++ b/sites/all/modules/contrib/metatag/metatag_google_plus/metatag_google_plus.module @@ -1,4 +1,5 @@ 'itemprop', '#value' => 'content')); + $args = array( + '#itemprop' => 'itemprop', + '#value' => 'content', + ); + element_set_attributes($element, $args); unset($element['#value']); return theme('html_tag', $variables); @@ -47,14 +52,16 @@ function theme_metatag_google_plus($variables) { * * 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() + * Note: The $schemaorg variable must be added to the html tag of the + * html.tpl.php template after the $rdf_namespaces variable, see README.txt + * for details. */ function metatag_google_plus_preprocess_html(&$variables) { + if (!isset($variables['schemaorg'])) { + $variables['schemaorg'] = ''; + } + if (isset($variables['itemtype']) && !function_exists('zen_preprocess_html')) { - $variables['rdf_namespaces'] .= "\n itemscope itemtype= \"http://schema.org/{$variables['itemtype']}\""; + $variables['schemaorg'] .= " itemscope itemtype=\"http://schema.org/{$variables['itemtype']}\""; } } diff --git a/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test b/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test new file mode 100644 index 00000000..d228a4a9 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.tags.test @@ -0,0 +1,123 @@ + 'Metatag tags: GooglePlus', + 'description' => 'Test the Google Plus meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + // @todo Can't test the output of this tag, it depends upon changes to the + // html.tpl.php file. + // 'itemtype', + 'itemprop:name', + 'itemprop:description', + 'itemprop:image', + 'author', + 'publisher', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_google_plus'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + // The itemprop meta tags don't have 'itemprop' in their attribute value, + // 'itemprop' is the name of the attribute itself. + return str_replace('itemprop_', '', $tag_name); + } + + /** + * {@inheritdoc} + */ + public $test_name_attribute = 'itemprop'; + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'author'. + */ + public function author_test_output_xpath() { + return "//link[@rel='author']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'author'. + */ + public function author_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_key() for 'itemtype'. + */ + public function itemtype_test_key() { + return 'metatags[und][itemtype][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'itemtype'. + */ + public function itemtype_test_value() { + return 'Article'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'itemprop_image'. + */ + public function itemprop_image_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'itemtype'. + */ + public function itemtype_test_field_xpath() { + return "//select[@name='metatags[und][itemtype][value]']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'itemtype'. + */ + public function itemtype_test_output_xpath() { + return "//html[@rel='itemtype']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'publisher'. + */ + public function publisher_test_output_xpath() { + return "//link[@rel='publisher']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'publisher'. + */ + public function publisher_test_value_attribute() { + return 'href'; + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.test b/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.test new file mode 100644 index 00000000..78818d90 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_google_plus/tests/metatag_google_plus.test @@ -0,0 +1,48 @@ + 'Metatag GooglePlus tests', + 'description' => 'Test the Metatag:GooglePlus module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_google_plus'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/README.txt b/sites/all/modules/contrib/metatag/metatag_hreflang/README.txt new file mode 100644 index 00000000..89855028 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/README.txt @@ -0,0 +1,39 @@ +Metatag: hreflang +----------------- +This module automatically adds hreflang meta tags for each locale currently +enabled on the site. It also provides support for the hreflang=x-default meta +tag. + +This is similar to the Alternative hreflang [1] module. That module +automatically adds the hreflang tag to every page for every enabled locale, +which may not be what a site needs. This module allows the site builder control +over what tags are shown. + +The module also provides new tokens to output the URLs of each of the current +node's translations, and assigns these as the defaults for the meta tags. As +such, this module may not need additional configuration once it is enabled, but +it's always worth confirming the output is as expected. + +This module works best when the Translation or Entity Translation modules are +enabled and configured. + + +Configuration +-------------------------------------------------------------------------------- + 1. By default if the hreflang="x-default" meta tag matches one of the + hreflang="LANGCODE" meta tags that hreflang="LANGCODE" meta tag will be + removed. It is possible to change this so that the meta tag is not removed + by enabling the "Allow hreflang tag that matches the x-default tag" option + on the main Metatag settings page: + admin/config/search/metatags/settings + + +Credits / Contact +-------------------------------------------------------------------------------- +Originally developed by Damien McKenna [2]. + + +References +-------------------------------------------------------------------------------- +1: https://www.drupal.org/project/hreflang +2: https://www.drupal.org/u/damienmckenna. diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info new file mode 100644 index 00000000..d0752ae4 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.info @@ -0,0 +1,24 @@ +name = Metatag: hreflang +description = Provides support for the hreflang meta tag with some extra logic to simplify it. +package = SEO +core = 7.x + +dependencies[] = metatag:metatag + +; The locale module is required in order to have multiple languages/locales. +dependencies[] = drupal:locale + +; Tests. +files[] = tests/metatag_hreflang.test +files[] = tests/metatag_hreflang.tags.test + +; Entity Translation integration. +test_dependencies[] = devel:devel +test_dependencies[] = entity_translation:entity_translation +files[] = tests/metatag_hreflang.with_entity_translation.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.install b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.install new file mode 100644 index 00000000..555b7433 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.install @@ -0,0 +1,71 @@ + REQUIREMENT_ERROR, + 'title' => 'Metatag', + 'value' => $t('The Metatag:hreflang module should not be used at the same time as the hreflang module.'), + 'description' => $t('If both the Metatag:hreflang module and the Alternative Hreflang (hreflang) module are used at the same time it is likely that they will output duplicate meta tags. As a result, it is recommended to only use one at a time.'), + ); + } + } + + return $requirements; +} + +/** + * Implements hook_uninstall(). + */ +function metatag_hreflang_uninstall() { + // Delete any custom variables that are used. + variable_del('metatag_hreflang_allow_dupe'); +} + +/** + * Implementations of hook_update_N(). + */ + +/** + * Clear the Metatag cache so the updated hreflang default is caught. + */ +function metatag_hreflang_update_7101() { + cache_clear_all('*', 'cache_metatag', TRUE); + return t('All Metatag caches cleared.'); +} + +/** + * Fix hreflang=xdefault for config definitions. + */ +function metatag_hreflang_update_7102() { + module_load_include('install', 'metatag'); + $meta_tag = 'hreflang_xdefault'; + $old_value = '[node:source:url]'; + $new_value = '[node:url-original]'; + return metatag_update_replace_config_value($meta_tag, $old_value, $new_value); +} + +/** + * Fix hreflang=xdefault for all entities. + */ +function metatag_hreflang_update_7103() { + module_load_include('install', 'metatag'); + $meta_tag = 'hreflang_xdefault'; + $old_value = '[node:source:url]'; + $new_value = '[node:url-original]'; + return metatag_update_replace_entity_value($sandbox, $meta_tag, $old_value, $new_value); +} diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.metatag.inc b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.metatag.inc new file mode 100644 index 00000000..55387c23 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.metatag.inc @@ -0,0 +1,97 @@ +instance) { + case 'node': + // The x-default should default to the source language. + $config->config += array( + 'hreflang_xdefault' => array('value' => '[node:url-original]'), + ); + + // Add all of the other hreflang values. + $languages = language_list('enabled'); + if (!empty($languages[1])) { + foreach (array_keys($languages[1]) as $langcode) { + $config->config += array( + 'hreflang_' . $langcode => array('value' => '[node:url-' . $langcode . ']'), + ); + } + } + break; + } + } +} + +/** + * Implements hook_metatag_info(). + */ +function metatag_hreflang_metatag_info() { + $info['groups']['hreflang'] = array( + 'label' => t('Alternative language links (hreflang)'), + 'description' => t('These meta tags are designed to point visitors to versions of the current page in other languages. It is recommended to use the default "[node:url-LANGCODE]" tokens for the hreflang values, they will only be output if a translation exists for that locale. Also, it is suggested to use the "[node:source:url]" token for the default locale.'), + 'form' => array( + '#weight' => 60, + ), + ); + + $weight = 100; + + // Default values for each meta tag. + $tag_info_defaults = array( + 'description' => '', + 'class' => 'DrupalLinkMetaTag', + 'group' => 'hreflang', + ); + + $info['tags']['hreflang_xdefault'] = array( + 'label' => t('Default locale (x-default)'), + 'description' => t('This should point to the version of the page that is for the main or primary locale, e.g. the original version of an article that is translated into other languages.'), + 'weight' => $weight, + 'element' => array( + '#theme' => 'metatag_link_hreflang', + '#hreflang' => 'x-default', + ), + ) + $tag_info_defaults; + if (variable_get('metatag_hreflang_allow_dupe', FALSE)) { + $info['tags']['hreflang_xdefault']['description'] .= ' ' . t('If this string matches one of the values below the other value will not be removed.'); + } + else { + $info['tags']['hreflang_xdefault']['description'] .= ' ' . t('If this string matches one of the values below that other tag will be removed, thus ensuring that there is only one hreflang meta tag for each possible variation of this page.'); + } + + // Add a meta tag for each locale enabled. + $languages = language_list('enabled'); + if (!empty($languages[1])) { + foreach ($languages[1] as $langcode => $locale) { + // Getting granular with these so they're all grouped together. + $weight += 0.01; + $info['tags']['hreflang_' . $langcode] = array( + 'label' => t('hreflang value for :language (:native)', array(':language' => t($locale->name), ':native' => $locale->native)), + 'weight' => $weight, + 'element' => array( + '#theme' => 'metatag_link_hreflang', + '#hreflang' => $langcode, + ), + ) + $tag_info_defaults; + } + } + + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.module b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.module new file mode 100644 index 00000000..ac32a693 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.module @@ -0,0 +1,86 @@ + 1); + } +} + +/** + * Implements hook_theme(). + */ +function metatag_hreflang_theme() { + $info['metatag_link_hreflang'] = array( + 'render element' => 'element', + ); + return $info; +} + +/** + * Theme callback for a rel link tag with the hreflang. + * + * The format is: + * + */ +function theme_metatag_link_hreflang($variables) { + $element = &$variables['element']; + $element['#name'] = 'alternate'; + $args = array( + '#name' => 'rel', + '#hreflang' => 'hreflang', + '#value' => 'href', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} + +/** + * Implements hook_form_FORM_ID_alter for metatag_admin_settings_form(). + */ +function metatag_hreflang_form_metatag_admin_settings_form_alter(&$form, &$form_state, $form_id) { + $form['advanced']['metatag_hreflang_allow_dupe'] = array( + '#type' => 'checkbox', + '#title' => t('Allow hreflang tag that matches the x-default tag'), + '#description' => t('It is recommended to not have hreflang="x-default" and hreflang="SOMELANGCODE" meta tags pointing at the same URL. By default if there is a hreflang="SOMELANGCODE" meta tag with the same URL as the hreflang="x-default" meta tag then the hreflang="SOMELANGCODE" tag will be removed. Checking '), + '#default_value' => variable_get('metatag_hreflang_allow_dupe', FALSE), + ); +} + +/** + * Implements hook_metatag_metatags_view_alter(). + * + * Remove any hreflang="LANGCODE" values that match hreflang="x-default". Using + * this hook instead of hook_html_head_alter() as it gets closer to Metatag's + * data structures, and the results are cached so this won't be executed on + * every page request. + */ +function metatag_hreflang_metatag_metatags_view_alter(&$output, $instance, $options) { + // This behaviour may be disabled from the Metatag settings page. + if (!variable_get('metatag_hreflang_allow_dupe', FALSE)) { + if (!empty($output['hreflang_xdefault'])) { + $default = $output['hreflang_xdefault']['#attached']['drupal_add_html_head'][0][0]['#value']; + foreach ($output as $tag_name => &$tag) { + // Skip the x-default tag. + if ($tag_name == 'hreflang_xdefault') { + continue; + } + if (strpos($tag_name, 'hreflang_') === 0) { + if ($tag['#attached']['drupal_add_html_head'][0][0]['#value'] == $default) { + $tag['#attached']['drupal_add_html_head'][0][0]['#access'] = FALSE; + } + } + } + } + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.test b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.test new file mode 100644 index 00000000..ef7fa945 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.test @@ -0,0 +1,31 @@ + 'Metatag core tests for hreflang', + 'description' => 'Test Metatag integration with the locale module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need Locale for the multiple languages. + $modules[] = 'locale'; + + parent::setUp($modules); + } + + // @todo Make sure the hreflang meta tag is added for each enabled language. +} diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.tokens.inc b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.tokens.inc new file mode 100644 index 00000000..e3bafb52 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/metatag_hreflang.tokens.inc @@ -0,0 +1,118 @@ + 1) { + if (module_exists('node')) { + foreach ($languages[1] as $langcode => $language) { + $info['tokens']['node']['url-' . $langcode] = array( + 'name' => t('URL (@lang translation)', array('@lang' => $language->name)), + 'description' => t('The URL for the %lang translation of the node, if available.', array('%lang' => $language->name)), + ); + } + } + } + + $info['tokens']['node']['url-original'] = array( + 'name' => t('URL (original language)'), + 'description' => t("The URL for the node that is the original source for the current node's translation."), + ); + + return $info; +} + +/** + * Implements hook_tokens(). + */ +function metatag_hreflang_tokens($type, $tokens, array $data = array(), array $options = array()) { + $replacements = array(); + + $sanitize = !empty($options['sanitize']); + + // Node tokens. + if ($type == 'node' && !empty($data['node'])) { + // Shortcuts. + $node = $data['node']; + + $languages = language_list('enabled'); + if (!empty($languages[1]) && is_array($languages[1]) && count($languages[1]) > 1) { + foreach ($tokens as $name => $original) { + // The original entity's URL. + if ($name == 'url-original') { + // Basic options regardless of the translation mechanism used. + $url_options = $options; + $url_options['absolute'] = TRUE; + + // Core's content translation. + if (!empty($node->tnid)) { + $node_original = node_load($node->tnid); + // Only deal with published nodes. + if ($node_original->status) { + $url_options['language'] = $languages[1][$node_original->language]; + $replacements[$original] = url('node/' . $node_original->nid, $url_options); + } + } + // Entity Translation stores the translation data differently to core. + elseif (isset($node->translations, $node->translations->original, $languages[1][$node->translations->original])) { + $url_options['language'] = $languages[1][$node->translations->original]; + $replacements[$original] = url('node/' . $node->nid, $url_options); + } + } + + // Separate URLs for each translation. + // Core's content translation. + if (!empty($node->tnid)) { + $translations = translation_node_get_translations($node->tnid); + foreach ($translations as $langcode => $translation) { + // Only deal with published nodes. + if ($translation->status && $name == 'url-' . $langcode) { + $url_options = $options; + $url_options['absolute'] = TRUE; + $url_options['language'] = $languages[1][$langcode]; + $replacements[$original] = url('node/' . $translation->nid, $url_options); + } + } + } + // Entity Translation. + elseif (isset($node->translations, $node->translations->data)) { + foreach ($node->translations->data as $langcode => $translation) { + // Only deal with published nodes. + if ($translation['status'] && $name == 'url-' . $langcode) { + $url_options = $options; + $url_options['absolute'] = TRUE; + $url_options['language'] = $languages[1][$langcode]; + $replacements[$original] = url('node/' . $node->nid, $url_options); + } + } + } + } + } + } + + return $replacements; +} diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.tags.test b/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.tags.test new file mode 100644 index 00000000..2a7d07ab --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.tags.test @@ -0,0 +1,113 @@ + 'Metatag tags: Hreflang', + 'description' => 'Test the Hreflang meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'hreflang_xdefault', + // Additional meta tags added at the end of setUp(). + // @see setUp() + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_hreflang'; + parent::setUp($modules); + + // Create an admin user that can also manage locales. + $perms = array( + // For Locale, so languages can be added. + 'administer languages', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Add some new languages. + foreach ($this->supportedLocales() as $langcode) { + if ($langcode != 'en') { + $this->addSiteLanguage($langcode); + } + } + + // Clear all the caches so that all of the various hooks are activated and + // the appropriate tokens, fields, meta tags, etc are available. + drupal_flush_all_caches(); + + // Additional meta tags that will be available. + foreach ($this->supportedLocales() as $langcode) { + $this->tags[] = 'hreflang_' . $langcode; + } + } + + /** + * The list of locales that are being tested. + * + * @return array + * A simple list of language codes. + */ + private function supportedLocales() { + return array( + 'de', + 'fr', + 'es', + // English is automatic, so remember to not try enabling it. + 'en', + ); + } + + /** + * {@inheritdoc} + */ + public $test_tag = 'link'; + + /** + * {@inheritdoc} + */ + public $test_name_attribute = 'hreflang'; + + /** + * {@inheritdoc} + */ + public $test_value_attribute = 'href'; + + /** + * {@inheritdoc} + */ + public function getTestTagValue() { + return base_path() . $this->randomMachineName() . '/' . $this->randomMachineName(); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + $tag_name = str_replace('xdefault', 'x-default', $tag_name); + return str_replace('hreflang_', '', $tag_name); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.test b/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.test new file mode 100644 index 00000000..8c6e5325 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.test @@ -0,0 +1,48 @@ + 'Metatag Hreflang tests', + 'description' => 'Test the Metatag:Hreflang module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_hreflang'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.with_entity_translation.test b/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.with_entity_translation.test new file mode 100644 index 00000000..ac2b4eed --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_hreflang/tests/metatag_hreflang.with_entity_translation.test @@ -0,0 +1,283 @@ + 'Metatag tests for hreflang with Entity Translation', + 'description' => 'Test Metatag:hreflang with the Entity Translation module.', + 'group' => 'Metatag', + 'dependencies' => array('devel', 'entity_translation'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Used for debugging some token values. + $modules[] = 'devel'; + + // Need Locale for the multiple languages. + $modules[] = 'locale'; + + // Need Entity Translation for the tokens to work. + $modules[] = 'entity_translation'; + + // This module. + $modules[] = 'metatag_hreflang'; + + // Enable all of the modules & install the site. + parent::setUp($modules); + + // Add some new languages. + $this->setupLocales($this->supportedLocales()); + + // The content that will be used. + $content_type = 'page'; + + // Create an admin user that can also manage locales. + $perms = array( + // For Locale, so languages can be added. + 'administer languages', + + // For Entity Translation, so content can be translated. + 'translate any entity', + + // For Devel, for access to the node's "devel" tab. + 'access devel information', + + // For Field UI, so field settings can be changed. + 'administer fields', + + // For Node, so content type settings can be changed. + 'administer content types', + + // For Node, so content can be created and edited. + 'create ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Enable translation support for the content type. + variable_set('language_content_type_' . $content_type, ENTITY_TRANSLATION_ENABLED); + + // Allow the body field to be translated. + $this->drupalGet('admin/structure/types/manage/' . $content_type . '/fields/body'); + $this->assertResponse(200); + $this->assertFieldByName('field[translatable]'); + $edit = array( + 'field[translatable]' => TRUE, + ); + $this->drupalPost(NULL, $edit, t('Save settings')); + + // Clear all the caches so that all of the various hooks are activated and + // the appropriate tokens, fields, meta tags, etc are available. + drupal_flush_all_caches(); + } + + /** + * The list of locales that are being tested. + * + * @return array + * A simple list of language codes. + */ + private function supportedLocales() { + return array( + 'de', + 'fr', + 'es', + 'en', + ); + } + + /** + * Assert that the appropriate hreflang meta tag fields are present. + * + * @param string $form_langcode + * The langcode of the current form. Defaults to LANGUAGE_NONE, which is + * what is used on an empty node/add form. + */ + private function assertHreflangFields($form_langcode = LANGUAGE_NONE) { + // The x-default field has a specific default. + $this->assertFieldByName("metatags[{$form_langcode}][hreflang_xdefault][value]", "[node:url-original]", 'Found the hreflang=x-default meta tag and it has the correct default value.'); + + // Confirm each of the support locales has its own field and the appropriate + // default value. + foreach ($this->supportedLocales() as $langcode) { + $this->assertFieldByName("metatags[{$form_langcode}][hreflang_{$langcode}][default]", "[node:url-{$langcode}]", format_string('Found the hreflang field for the "%lang" locale and it has the correct default value.', array('%lang' => $langcode))); + } + } + + /** + * Confirm that each locale has a field added and shows the appropriate + * default value. + */ + function testFormFields() { + $this->drupalGet('node/add/page'); + $this->assertResponse(200); + + // Confirm the fields exist. + $this->assertHreflangFields('en'); + } + + /** + * Confirm that the meta tags output are correct. + */ + function testOutput() { + // All of the locales we're supporting in these tests. The languages have + // been enabled already, so this gets a list of language objects. + $languages = language_list('enabled'); + $locales = $languages[1]; + + // Identify the site's default language. + $default_language = language_default('language'); + + // Create an English node so it can be translated. + $args = array( + 'language' => $default_language, + ); + $node = $this->drupalCreateNode($args); + $this->verbose($node); + + // Load the translation page. + $this->drupalGet('node/' . $node->nid . '/translate'); + $this->assertResponse(200); + $this->assertText(t('Not translated')); + + // Confirm that there are links to translate the node. + $urls = array(); + foreach ($locales as $langcode => $locale) { + // There won't be a link to translate to English, that's the default + // language for thos node. + if ($langcode == $default_language) { + continue; + } + + // Confirm that a link to translate the node into each locale exists. + $url = 'node/' . $node->nid . '/edit/add/' . $node->language . '/' . $langcode; + $urls[$langcode] = $url; + // @todo This fails in testbot. + // $this->assertLinkbyHref(url($url)); + } + + // Check each of the 'translate' pages loads properly. + foreach ($urls as $langcode => $url) { + // Confirm the 'translate' page loads. + $this->drupalGet($url); + $this->assertResponse(200); + + // Confirm all of the hreflang fields exist. + $this->assertHreflangFields($langcode); + + // Save the translation. + $edit = array( + // Add a custom title. + "metatags[{$langcode}][title][value]" => "Tranlation for {$langcode}", + ); + $this->drupalPost(NULL, $edit, t('Save')); + } + + // Load the translation page again to confirm everything was translated. + $this->drupalGet('node/' . $node->nid . '/translate'); + $this->assertResponse(200); + $this->assertNoText(t('Not translated')); + + // Load the node's devel page to see the translations data. + $this->drupalGet('node/' . $node->nid . '/devel'); + $this->assertResponse(200); + + // Load the node's devel page and confirm each of the tokens is available. + $this->drupalGet('node/' . $node->nid . '/devel/token'); + $this->assertResponse(200); + foreach ($locales as $langcode => $locale) { + $this->assertText("[node:url-{$langcode}]"); + } + + // Load the node page again, confirm each hreflang meta tag. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + $xpath = $this->xpath("//link[@rel='alternate']"); + $this->verbose($xpath); + $this->assertEqual(count($xpath), count($locales), 'The correct number of hreflang meta tags was found'); + + // Try to find the position of the xdefault value in the $xpath structure. + $xdefault_pos = NULL; + // This is slightly messy logic as the sort order of $locales may be + // different to the meta tags. + foreach ($locales as $langcode => $locale) { + $found = FALSE; + foreach ($xpath as $ctr => $item) { + if ($item['hreflang'] == 'x-default') { + $xdefault_pos = $ctr; + } + elseif ($item['hreflang'] == $langcode) { + $found = TRUE; + $this->assertEqual($xpath[$ctr]['hreflang'], $langcode); + // @todo Fix this. Not sure why, but the url() call returns the URL + // without the language prefix. + // $url_options = array( + // 'language' => $locale, + // 'absolute' => TRUE, + // ); + // $this->assertEqual($xpath[$ctr]['href'], url('node/' . $node->nid, $url_options)); + } + } + + // The node's default language should not have been found, it should have + // been turned into an xdefault. + if ($langcode == $node->language) { + $this->assertFalse((bool) $found, format_string("A regular hreflang meta tag for the node's default language (%lang) was not found.", array('%lang' => $langcode))); + } + + // Translations should have been found. + else { + $this->assertTrue((bool) $found, format_string('The hreflang meta tag for %lang was found.', array('%lang' => $langcode))); + } + } + + // Confirm the hreflang=xdefault meta tag was found. + $this->assertNotNull($xdefault_pos, 'The hreflang=xdefault meta tag was found.'); + if (!is_null($xdefault_pos)) { + $this->assertEqual($xpath[$xdefault_pos]['href'], url('node/' . $node->nid, array('absolute' => TRUE)), 'Found the x-default value.'); + } + + // Enable the xdefault-dupe option. + variable_set('metatag_hreflang_allow_dupe', TRUE); + metatag_config_cache_clear(); + + // Load the node page again. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Confirm there are now more meta tags. + $xpath = $this->xpath("//link[@rel='alternate']"); + $this->verbose($xpath); + $this->assertEqual(count($xpath), count($locales) + 1, 'The correct number of hreflang meta tags was found.'); + $found = FALSE; + foreach ($xpath as $ctr => $item) { + if ($item['hreflang'] == $node->language) { + $found = $ctr; + } + } + $this->assertTrue((bool) $found, "Found an hreflang meta tag for the node's default locale."); + if ($found) { + $this->assertEqual($xpath[$found]['hreflang'], $node->language); + } + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_importer/README.txt b/sites/all/modules/contrib/metatag/metatag_importer/README.txt new file mode 100644 index 00000000..07c4e898 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/README.txt @@ -0,0 +1,51 @@ +Metatag: Importer +----------------- +This module imports data from other modules. An administrative interface is +provided (admin/config/search/metatags/importer), as well as a series of Drush +commands: + +* metatag-convert-metatags-quick / mtcmq + Convert data from the Metatags Quick module. + +* metatag-convert-nodewords / mtcnw + Convert data from the Nodewords module. + +* metatag-convert-page-title / mtcpt + Convert data from the Page Title module. + + +Known Issues +-------------------------------------------------------------------------------- +- The admin page (currently) only supports migrating data from Nodewords and + Page Title. +- Only entities are currently supported, other configuration types will be + supported soon. + + +Credits / Contact +-------------------------------------------------------------------------------- +Currently maintained by Damien McKenna [1]. Originally developed by Jon Antoine +[2] with contributions by Jay Callicott [3], Stuart Crouch [4], Subhojit Paul +[5], Karl Shea [6], Stefan Ruijsenaars [7], HyperGlide [8], Jen Lampton [9], +Eric Peterson [10], Lars Schröter [11], Victoria Chan [12], Malcolm Young [13], +Alexey Korepov [14], klokie [15] and Dan Ficker [16]. + + +References +-------------------------------------------------------------------------------- +1: https://www.drupal.org/u/damienmckenna +2: https://www.drupal.org/u/jantoine +3: https://www.drupal.org/u/drupalninja99 +4: https://www.drupal.org/u/stuart.crouch +5: https://www.drupal.org/u/subhojit777 +6: https://www.drupal.org/u/karlshea +7: https://www.drupal.org/u/stefan.r +8: https://www.drupal.org/u/hyperglide +9: https://www.drupal.org/u/jenlampton +10: https://www.drupal.org/u/iameap +11: https://www.drupal.org/u/osopolar +12: https://www.drupal.org/u/victoriachan +13: https://www.drupal.org/u/malcomio +14: https://www.drupal.org/u/murz +15: https://www.drupal.org/u/klokie +16: https://www.drupal.org/u/dandaman diff --git a/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.admin.inc b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.admin.inc new file mode 100644 index 00000000..11fb9041 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.admin.inc @@ -0,0 +1,19 @@ + 'markup', + '#markup' => t('Use the links above to import data from another module.'), + '#prefix' => '

', + '#suffix' => '

', + ); + return $output; +} diff --git a/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.drush.inc b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.drush.inc new file mode 100644 index 00000000..883f6cba --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.drush.inc @@ -0,0 +1,94 @@ + dt('Convert data from Metatags Quick into Metatag'), + 'drupal dependencies' => array('metatag', 'metatag_importer'), + 'aliases' => array('mtcmq'), + ); + + $items['metatag-convert-nodewords'] = array( + 'description' => dt('Convert data from Nodewords into Metatag.'), + 'drupal dependencies' => array('metatag', 'metatag_importer'), + 'aliases' => array('mtcnw'), + ); + + $items['metatag-convert-page-title'] = array( + 'description' => dt('Convert data from Page Title into Metatag.'), + 'drupal dependencies' => array('metatag', 'metatag_importer'), + 'aliases' => array('mtcpt'), + ); + + return $items; +} + +/** + * Callback to convert all Metatags Quick data. + */ +function drush_metatag_importer_metatag_convert_metatags_quick() { + if (!drush_confirm(dt('Ready to convert all data from Metatags Quick?'))) { + return; + } + + include 'metatag_importer.metatags_quick.inc'; + metatag_importer_metatags_quick_import(); +} + +/** + * Callback to convert all Nodewords data. + */ +function drush_metatag_importer_metatag_convert_nodewords() { + if (!drush_confirm(dt('Ready to convert all data from Nodewords?'))) { + return; + } + + // Need to make sure the Nodewords table actually exists. + if (!db_table_exists('nodewords')) { + drush_set_error('metatag_importer', dt('Could not find the nodewords table!')); + return; + } + + // Offload all of the logic to the code contained in the admin file. + include 'metatag_importer.nodewords.inc'; + + // Start the import. + $types = array_keys(_metatag_importer_list_nodewords()); + _metatag_importer_import($types); + + drush_print(dt('Data converesion finished.')); +} + +/** + * Callback to convert Page Title data. + */ +function drush_metatag_importer_metatag_convert_page_title() { + if (!db_table_exists('page_title')) { + drush_set_error('metatag_importer', dt('Could not find the page_title table!')); + return; + } + + $records = db_query("SELECT COUNT(id) FROM {page_title} WHERE type IN ('node', 'taxonomy_term', 'user')")->fetchField(); + + if (empty($records)) { + return dt('There are no page_title records to convert!'); + } + + if (!drush_confirm(dt('Ready to convert !count record(s) from Page Title?', array('!count' => $records)))) { + return; + } + + include 'metatag_importer.page_title.inc'; + + // Start the importer. + $count = metatag_importer_for_page_title(); + + drush_print(dt('Converted !count record(s) from the Page Title module.', array('!count' => $count))); +} diff --git a/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info new file mode 100644 index 00000000..2eda31c8 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.info @@ -0,0 +1,16 @@ +name = Metatag Importer +description = Import data from other modules into Metatag. +core = 7.x +package = SEO + +; Need Metatag. +dependencies[] = metatag:metatag + +; Tests. +files[] = tests/metatag_importer.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.metatags_quick.inc b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.metatags_quick.inc new file mode 100644 index 00000000..7b5b5066 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.metatags_quick.inc @@ -0,0 +1,225 @@ + count($data)); + if (drupal_is_cli() && function_exists('drush_print')) { + drush_print(dt($message, $vars)); + } + else { + drupal_set_message(t($message, $vars)); + } + + // Get all of the data for these fields. + $data = metatag_importer_get_quick_data($fields); + + // Process the data. + foreach ($data as $quick) { + $message = 'Converting @count records from Metatags Quick..'; + $vars = array('@count' => count($quick)); + if (drupal_is_cli() && function_exists('drush_print')) { + drush_print(dt($message, $vars)); + } + else { + drupal_set_message(t($message, $vars)); + } + + metatag_importer_metatags_quick_process($quick); + } + + if (drupal_is_cli() && function_exists('drush_print')) { + drush_print(dt('All done!')); + } + else { + drupal_set_message(t('All done!')); + } +} + +/** + * Process a row from Metatags Quick. + * + * Imports data into metatag structure, and deletes Metatags Quick data. + * + * @param array $quick + * Row of data from Metatags Quick. + */ +function metatag_importer_metatags_quick_process(array $quick) { + // Identify which Metatag meta tags will be filled by Metatags Quick values. + $tag_map = array( + 'title' => 'title', + 'keywords' => 'keywords', + 'abstract' => 'abstract', + 'description' => 'description', + 'canonical' => 'canonical', + ); + if (module_exists('metatag_opengraph')) { + $tag_map['og:title'] = 'title'; + $tag_map['og:description'] = 'description'; + } + if (module_exists('metatag_twitter_cards')) { + $tag_map['twitter:title'] = 'title'; + $tag_map['twitter:description'] = 'description'; + } + + $entity_type = $quick['entity_type']; + $entity_id = $quick['entity_id']; + $revision_id = $quick['revision_id']; + $langcode = $quick['language']; + + // Fallback to entity language if no field language is set. + if (LANGUAGE_NONE == $langcode) { + $entities = entity_load($entity_type, array($entity_id)); + if (!empty($entities[$entity_id])) { + $langcode = entity_language($entity_type, $entities[$entity_id]); + } + } + + // Check for an existing record. + $data = metatag_metatags_load($entity_type, $entity_id); + + // Drop back one level because the results will be keyed by revision_id. + if (!empty($data)) { + $data = reset($data); + } + + // Map the Quick meta tags. + foreach ($tag_map as $dest => $source) { + if (!empty($quick['fields'][$source]['value'])) { + $data[$langcode][$dest] = array('value' => $quick['fields'][$source]['value']); + // Add the default suffix to the page title. + if ($dest == 'title') { + $data[$langcode][$dest]['value'] .= ' | [site:name]'; + } + } + } + + // Create or update the {metatag} record. + if (!empty($data)) { + metatag_metatags_save($entity_type, $entity_id, $revision_id, $data); + } + + if (!empty($quick['fields'])) { + metatag_importer_delete_quick_data($quick['fields']); + } + + // Reset the entity cache. If entitycache module is used, this also resets + // its permanent cache. + entity_get_controller($entity_type)->resetCache(array($entity_id)); +} + +/** + * Get all fields from Metatags Quick. + * + * @return array + * Array of field names, keyed by name. + */ +function metatag_importer_get_quick_fields() { + $fields = array(); + + // Get a list of all entities that use a Metatags Quick field. + foreach (field_info_instances() as $entity_type => $bundles) { + // Skip the custon entity type provided by Metatags Quick. + if ($entity_type == 'metatags_path_based') { + continue; + } + foreach ($bundles as $bundle_name => $bundle) { + foreach ($bundle as $field_name => $field) { + if ($field['widget']['module'] == 'metatags_quick') { + $fields[$field_name] = $field_name; + } + } + } + } + + return $fields; +} + +/** + * Get metatags_quick data from the database. + * + * @param array $fields + * Array of field names. + * + * @return array + * Metadata + */ +function metatag_importer_get_quick_data(array $fields) { + $data = array(); + foreach ($fields as $field_name) { + $meta_tag = str_replace('meta_', '', str_replace('field_', '', $field_name)); + $results = db_select('field_data_' . $field_name, 'f') + ->fields('f', array( + 'entity_type', + 'bundle', + 'entity_id', + 'revision_id', + 'language', + $field_name . '_metatags_quick', + )) + ->condition('f.entity_type', array('metatags_path_based'), '<>') + ->orderBy('f.entity_type', 'ASC') + ->orderBy('f.entity_id', 'ASC') + ->orderBy('f.revision_id', 'ASC') + ->execute(); + + foreach ($results as $result) { + $id = implode(':', array( + $result->entity_type, + $result->entity_id, + $result->revision_id, + $result->language, + )); + + if (!isset($data[$id])) { + $data[$id] = array( + 'entity_type' => $result->entity_type, + 'bundle' => $result->bundle, + 'entity_id' => $result->entity_id, + 'revision_id' => $result->revision_id, + 'language' => $result->language, + 'fields' => array(), + ); + } + $data[$id]['fields'][$meta_tag] = array( + 'field_name' => $field_name, + 'value' => $result->{$field_name . '_metatags_quick'}, + 'meta_tag' => $meta_tag, + ); + } + } + + return $data; +} + +/** + * Delete the old metatags_quick records. + * + * @param array $quick + * Records to delete. + */ +function metatag_importer_delete_quick_data(array $quick) { + foreach ($quick as $field) { + db_delete('field_data_' . $field['field_name']) + ->condition('entity_type', $quick['entity_type']) + ->condition('entity_id', $quick['entity_id']) + ->condition('language', $quick['language']) + ->execute(); + + db_delete('field_revision_' . $field['field_name']) + ->condition('entity_type', $quick['entity_type']) + ->condition('entity_id', $quick['entity_id']) + ->condition('language', $quick['language']) + ->execute(); + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.module b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.module new file mode 100644 index 00000000..31d0ef6b --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.module @@ -0,0 +1,42 @@ + 'Importer', + 'description' => 'Migrate settings and data from various modules to the Metatag module.', + 'page callback' => 'metatag_importer_admin_page', + 'access arguments' => array('administer meta tags'), + 'file' => 'metatag_importer.admin.inc', + 'type' => MENU_LOCAL_TASK, + ); + + $items['admin/config/search/metatags/importer/nodewords'] = array( + 'title' => 'Import from Nodewords', + 'description' => 'Migrate settings and data from the Drupal 6 Nodewords module to the Drupal 7 Metatag module.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('metatag_importer_nodewords_form'), + 'access arguments' => array('administer meta tags'), + 'file' => 'metatag_importer.nodewords.inc', + 'type' => MENU_LOCAL_ACTION, + ); + + $items['admin/config/search/metatags/importer/page-title'] = array( + 'title' => 'Import from Page Title', + 'description' => 'Migrate settings and data from the Drupal 6 Nodewords module to the Drupal 7 Metatag module.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('metatag_importer_page_title_form'), + 'access arguments' => array('administer meta tags'), + 'file' => 'metatag_importer.page_title.inc', + 'type' => MENU_LOCAL_ACTION, + ); + + return $items; +} diff --git a/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.nodewords.inc b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.nodewords.inc new file mode 100644 index 00000000..93ae682c --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.nodewords.inc @@ -0,0 +1,581 @@ + 'checkboxes', + '#title' => t('Records to import'), + '#options' => $types, + ); + + $form['notes'] = array( + '#markup' => '

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

' + . '
    ' + . '
  • ' . t('All compatible records will be imported.') . '
  • ' + . '
  • ' . t('Records will be removed from the {nodewords} table upon completion, make sure to keep a backup of the table in case needed.') . '
  • ' + . '
  • ' . t('The import process may take some time, please be patient.') . '
  • ' + . '
  • ' . t('Nodewords stored each meta tag as a separate record, so there were many records for each entity or configuration.') . '
  • ' + . '
  • ' . t('Empty values will be removed, no additional logic is added to verify them.') . '
  • ' + . '
  • ' . t('Only node, taxonomy term, user, global, front page and error page records will be converted.') . '
  • ' + . '
  • ' . t('Custom paths, trackers, pagers and vocabularies are not supported yet.') . '
  • ' + . '
', + ); + + $form['actions']['migrate'] = array( + '#type' => 'submit', + '#value' => t('Migrate all records'), + ); + } + else { + $form['ohbother'] = array( + '#markup' => t('Nothing has been found that needs to be imported.'), + '#prefix' => '

', + '#suffix' => '

', + ); + } + + return $form; +} + +/** + * Handles submission of the Nodewords migration form. + */ +function metatag_importer_nodewords_form_submit($form, &$form_state) { + $types = array_filter($form_state['values']['types']); + _metatag_importer_import($types); +} + +function _metatag_importer_list_nodewords() { + $keys = array( + NODEWORDS_TYPE_DEFAULT => t('Default'), + NODEWORDS_TYPE_ERRORPAGE => t('Error page'), + NODEWORDS_TYPE_FRONTPAGE => t('Front page'), + NODEWORDS_TYPE_NONE => t('None'), + NODEWORDS_TYPE_NODE => t('Node'), + NODEWORDS_TYPE_PAGE => t('Page'), + NODEWORDS_TYPE_PAGER => t('Pager'), + NODEWORDS_TYPE_TERM => t('Taxonomy term'), + NODEWORDS_TYPE_TRACKER => t('Tracker'), + NODEWORDS_TYPE_USER => t('User'), + NODEWORDS_TYPE_VOCABULARY => t('Vocabulary'), + ); + + // Get a list of all records grouped by type. + $query = db_select('nodewords', 'nw') + ->fields('nw', array('type')) + ->orderBy('nw.type') + ->orderBy('nw.id') + // Exclude records that are empty. + ->condition('nw.content', 'a:1:{s:5:"value";s:0:"";}', '<>') + ->groupBy('nw.type'); + // Group-by. + $query->addExpression('COUNT(nw.id)', 'id_count'); + $filtered = $query->execute(); + + // Get a list of all records grouped by type. + $query = db_select('nodewords', 'nw') + ->fields('nw', array('type')) + ->orderBy('nw.type') + ->orderBy('nw.id') + ->groupBy('nw.type'); + // Group-by. + $query->addExpression('COUNT(nw.id)', 'id_count'); + $all = $query->execute()->fetchAllKeyed(); + + $types = array(); + foreach ($filtered as $record) { + $types['nodewords:' . $record->type] = t('Nodewords: @type - @non_empty records with values, @total total.', + array( + '@type' => $keys[$record->type], + '@non_empty' => $record->id_count, + '@total' => $all[$record->type], + )); + } + + return $types; +} + +/** + * Migrates Nodewords data to the Metatag module. + */ +function _metatag_importer_import(array $types = array()) { + $batch = array( + 'title' => t('Importing Nodewords data..'), + 'init_message' => t('Nodewords import is starting.'), + 'progress_message' => t('Processed @current out of @total.'), + 'error_message' => t('Nodewords import has encountered an error.'), + 'operations' => array( + array('_metatag_importer_migrate', array($types)), + ), + 'finished' => '_metatag_importer_finished', + 'file' => drupal_get_path('module', 'metatag_importer') . '/metatag_importer.nodewords.inc', + ); + + // Kick off the batch, using Drush if available. + if (drupal_is_cli() && function_exists('drush_backend_batch_process')) { + // Add some special magic for CLI before setting the batch. + $batch['progressive'] = FALSE; + batch_set($batch); + // Process the batch. + drush_backend_batch_process(); + } + else { + batch_set($batch); + batch_process(); + } +} + +/** + * Migrates Nodewords data to the Metatag module. + */ +function _metatag_importer_migrate(array $types = array(), &$context = array()) { + // Process this number of {nodewords} records at a time. + $limit = 50; + + if (empty($context['sandbox'])) { + // @todo Expand this so it can handle other types of things. + foreach ($types as $key => $val) { + $types[$key] = str_replace('nodewords:', '', $val); + } + + $context['sandbox']['progress'] = 0; + $context['sandbox']['current'] = 0; + $query = db_select('nodewords', 'nw') + ->fields('nw', array('mtid')) + ->orderBy('nw.mtid'); + if (!empty($types)) { + $query->condition('nw.type', $types, 'IN'); + } + $context['sandbox']['dataset'] = array_keys($query->execute()->fetchAllAssoc('mtid', PDO::FETCH_ASSOC)); + $context['sandbox']['max'] = count($context['sandbox']['dataset']); + + // Track all of the entities that could not be loaded. + $context['sandbox']['skipped'] = array(); + } + + // Retrieve Nodewords data. + $query = db_select('nodewords', 'nw') + ->fields('nw', array('mtid', 'type', 'id', 'name', 'content')) + // Continue on from the last record that was processed. + ->condition('nw.mtid', $context['sandbox']['current'], '>') + ->orderBy('nw.mtid'); + // @todo Finish off / test the $types handling. + // if (!empty($types)) { + // $query->condition('nw.type', $types, 'IN'); + // } + $query->range(0, $limit); + $results = $query->execute(); + + // Records that are being converted. + $records = array(); + + // Track records that are converted and will be ready to be deleted. + $to_delete = array(); + + // Convert Nodewords data into the Metatag format. + foreach ($results as $result) { + // Log the progress. + $context['sandbox']['current'] = $result->mtid; + $context['sandbox']['progress']++; + + // Convert the Nodewords record 'type' into something Metatag can use. + $type = _metatag_importer_convert_type($result->type); + + // Skip record types we're not handling just yet. + if (empty($type)) { + continue; + } + + // This could be an entity ID, but also possibly just a placeholder integer. + $record_id = $result->id; + + // Check if this record was skipped previously. + if (isset($context['sandbox']['skipped'][$type][$record_id])) { + // Delete this record anyway. + $to_delete[] = $result->mtid; + continue; + } + + // If this record is for an entity, verify that the entity exists. + if (in_array($type, array('node', 'taxonomy_term', 'user'))) { + $entity = entity_load($type, array($record_id)); + if (empty($entity)) { + $context['sandbox']['skipped'][$type][$record_id] = $record_id; + watchdog('metatag_importer', 'Unable to load @entity_type ID @id', array('@entity_type' => $type, '@id' => $record_id), WATCHDOG_WARNING); + + // Delete this record anyway. + $to_delete[] = $result->mtid; + continue; + } + } + + // Process the meta tag value, possibly also rename the meta tag name + // itself. + list($meta_tag, $value) = _metatag_importer_convert_data($result->name, unserialize($result->content)); + // Don't import empty values. + if (!empty($value)) { + // Add the value to the stack. + $records[$type][$record_id][$meta_tag] = $value; + } + + // Note that this record is ready to be deleted. + $to_delete[] = $result->mtid; + } + + // Update or create Metatag records. + foreach ($records as $type => $data) { + foreach ($data as $record_id => $values) { + switch ($type) { + // Standard D7 entities are converted to {metatag} records using + // metatag_metatags_save(). + case 'node': + case 'taxonomy_term': + case 'user': + // watchdog('metatag_importer', 'Importing meta tags for @entity_type ID @id..', array('@entity_type' => $type, '@id' => $record_id), WATCHDOG_INFO); + $entity = entity_load($type, array($record_id)); + $entity = reset($entity); + $langcode = metatag_entity_get_language($type, $entity); + list($entity_id, $revision_id, $bundle) = entity_extract_ids($type, $entity); + + // Add these meta tags to the entity, overwriting anything that's + // already there. + foreach ($values as $name => $value) { + $entity->metatags[$langcode][$name] = $value; + } + + metatag_metatags_save($type, $entity_id, $revision_id, $entity->metatags); + // watchdog('metatag_importer', 'Imported meta tags for @entity_type ID @id.', array('@entity_type' => $type, '@id' => $record_id), WATCHDOG_INFO); + break; + + // Other Nodewords settings are converted to {metatag_config} records + // using metatag_config_save(). + case 'global': + case 'global:frontpage': + case 'global:404': + $config = metatag_config_load($type); + + // If a configuration was not found create a config object. + if (empty($config)) { + $config = (object) array( + 'instance' => $type, + ); + } + + // Add these meta tags to the configuration, overwriting anything + // that's already there. + foreach ($values as $name => $value) { + $config->config[$name] = $value; + } + + // Save the configuration. + metatag_config_save($config); + break; + + // @todo: A 'vocabulary' setting becomes a default configuration? + case 'vocabulary': + // $metatags = metatag_metatags_load($record->entity_type, $record->entity_id); + // $metatags = array_merge($metatags, $record->data); + // $vocabulary = taxonomy_vocabulary_load($record->entity_id); + // metatag_metatags_save($record->entity_type, $record->entity_id, $vocabulary->vid, $metatags); + break; + } + } + } + + // Delete some records. + if (!empty($to_delete)) { + db_delete('nodewords') + ->condition('mtid', $to_delete) + ->execute(); + } + + $context['finished'] = (empty($context['sandbox']['max']) || $context['sandbox']['progress'] >= $context['sandbox']['max']) ? TRUE : ($context['sandbox']['progress'] / $context['sandbox']['max']); + + if ($context['finished'] === TRUE) { + $message = 'Imported @imported Nodewords records.'; + $vars = array('@imported' => $context['sandbox']['progress']); + + if (drupal_is_cli() && function_exists('drush_print')) { + drush_print(dt($message, $vars)); + } + else { + drupal_set_message(t($message, $vars)); + } + + if (!empty($context['sandbox']['skipped'])) { + $message = '@skipped records were skipped because the corresponding entities were previously deleted.'; + $vars = array('@skipped' => count($context['sandbox']['skipped'])); + + if (drupal_is_cli() && function_exists('drush_print')) { + drush_print(dt($message, $vars)); + } + else { + drupal_set_message(t($message, $vars)); + } + } + } +} + +/** + * BatchAPI callback for when the import finishes. + */ +function _metatag_importer_finished($success, $results, $operations) { + if ($success) { + if (drupal_is_cli() && function_exists('drush_print')) { + // Make a bulleted list of messages for the command line. + foreach ($results as $result) { + drush_print(dt('* ' . $result)); + } + } + else { + // Make a bulleted list of messages for the browser. + $message = theme('item_list', array('items' => $results)); + drupal_set_message(t($message)); + } + } + else { + // An error occurred. + // $operations contains the operations that remained unprocessed. + $error_operation = reset($operations); + $message = 'An error occurred while processing %error_operation'; + $vars = array( + '%error_operation' => $error_operation[0], + ); + + if (drupal_is_cli() && function_exists('drush_print')) { + drush_set_error('metatag_importer', dt($message, $vars)); + } + else { + $message .= ' with arguments: @arguments'; + $vars[] = array('@arguments' => print_r($error_operation[1], TRUE)); + drupal_set_message(t($message, $vars), 'error'); + } + } +} + +/** + * Converts the Nodewords type to a Metatag entity or Metatag config instance. + * + * @param $type + * Nodewords type. + * + * @return + * Metatag entity type or configuration instance. + */ +function _metatag_importer_convert_type($type) { + // define('NODEWORDS_TYPE_DEFAULT', 1); + // define('NODEWORDS_TYPE_ERRORPAGE', 2); + // define('NODEWORDS_TYPE_FRONTPAGE', 3); + // define('NODEWORDS_TYPE_NONE', 0); + // define('NODEWORDS_TYPE_NODE', 5); + // define('NODEWORDS_TYPE_PAGE', 10); + // define('NODEWORDS_TYPE_PAGER', 4); + // define('NODEWORDS_TYPE_TERM', 6); + // define('NODEWORDS_TYPE_TRACKER', 7); + // define('NODEWORDS_TYPE_USER', 8); + // define('NODEWORDS_TYPE_VOCABULARY', 9); + switch ($type) { + case 1: + return 'global'; + + case 2: + return 'global:404'; + + case 3: + return 'global:frontpage'; + + // @todo Not yet sure how to handle pager items? + // case 4: + // return 'pager'; + + case 5: + return 'node'; + + case 6: + return 'taxonomy_term'; + + // @todo Not sure what to do with tracker pages. + // case 7: + // return 'tracker'; + + case 8: + return 'user'; + + // Vocabulary records convert into a config for that entity bundle. + case 9: + return 'vocabulary'; + + // @todo Page records need to be converted to Context definitions. + // case 10: + // return 'page'; + } + + return FALSE; +} + +/** + * Converts a meta tag's name and value from Nodewords to Metatag format. + * + * @param $name + * Meta tag name. + * @param $value + * Meta tag value in Nodewords format. + * + * @return + * The two arguments returned after being converted, in an array. + */ +function _metatag_importer_convert_data($name, $value) { + // Initial simplification of simple values. + if (is_array($value) && isset($value['value']) && count($value) === 1 && empty($value['value'])) { + $value = FALSE; + } + + // Reformat the meta tag data, and possibly name. + switch ($name) { + // The Dublin Core date value was stored as three separarate strings. + case 'dcterms.date': + // Skip this value if it doesn't contain an array of three values. + if (!is_array($value) || empty($value['month']) || empty($value['day']) || empty($value['year'])) { + $value = FALSE; + } + else { + $date = mktime(0, 0, 0, $value['month'], $value['day'], $value['year']); + $value = date('Y-m-d\TH:iP', $date); + } + break; + + // The location meta tag gets renamed and converted to a semi-colon + // -separated string. + case 'location': + // Catch empty values. + if (!is_array($value) || empty($value['latitutde']) || empty($value['longitude'])) { + $value = FALSE; + } + else { + $name = 'geo.position'; + $value = implode(';', $value); + } + break; + + // These values always seem to be wrong, just use the Metatag defaults. + case 'og:type': + $value = FALSE; + break; + + // Nodewords handle the title tag differently. + case 'page_title': + $name = 'title'; + // Remove two options that are no longer used. + unset($value['append']); + unset($value['divider']); + break; + + // A bug in Nodewords resulted in lots of junk data for this meta tag. + case 'revisit-after': + if (isset($value['value']) && intval($value['value']) === 1) { + $value = FALSE; + } + + // Robots needs some extra processing. + case 'robots': + // The value didn't exist or it was set to use the defaults. + if (!is_array($value) || empty($value['value']) || !empty($value['use_default'])) { + $value = FALSE; + } + // Try parsing the data. + else { + $robot_data = array(); + + // Convert each value to display the name if it is "on" and 0 if it is + // off. + $found = FALSE; + foreach ($value['value'] as $robot_key => $robot_val) { + // Ignore junk values. + if ($robot_key == 'value') { + continue; + } + + // Only keep non-empty values. + elseif (!empty($robot_val)) { + $robot_data[$robot_key] = $robot_key; + $found = TRUE; + } + } + + // Catch empty values. + if (empty($robot_data)) { + $value = FALSE; + } + + // Return any data that's remaining. The data must be stored in an + // array with a single item named 'value'. + else { + $value = array( + 'value' => $robot_data, + ); + } + } + break; + + // This meta tag was renamed. + case 'shorturl': + $name = 'shortlink'; + break; + + // Everything else should be ok. + default: + // Nothing to see here. + } + + // A final tidy-up. + if (is_array($value)) { + foreach ($value as $key => $val) { + $value[$key] = trim($val); + } + $value = array_filter($value); + } + + return array($name, $value); +} + + +/** + * The following will not be converted because they refer to site-wide defaults + * that should be customized appropriately based on the D7 site's content type + * architecture. + */ + +// 'nodewords_metatags_generation_method_' . $type: +// 0 - NODEWORDS_GENERATION_NEVER - never auto-generate the string. +// 1 - NODEWORDS_GENERATION_WHEN_EMPTY - when the field is empty. Default. +// 2 - NODEWORDS_GENERATION_ALWAYS - always use the generated string. +// 'nodewords_metatags_generation_method_' . $type: +// 1 - NODEWORDS_GENERATION_BODY - use the body field. +// 2 - NODEWORDS_GENERATION_TEASER - use the node teaser. Default. +// 3 - NODEWORDS_GENERATION_TEASER_BODY - use teaser, failover to body if empty. diff --git a/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.page_title.inc b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.page_title.inc new file mode 100644 index 00000000..d7451c79 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/metatag_importer.page_title.inc @@ -0,0 +1,140 @@ + t('To migrate data from Page Title it is necessary to use Drush. See "drush metatag-convert-page-title" for details.'), + '#prefix' => '

', + '#suffix' => '

', + ); + return $form; +} + +/** + * Migrate data from the page_title table, if available. + * + * @return int + * The number of records that were converted. + */ +function metatag_importer_for_page_title() { + $converted = 0; + $page_titles = db_select('page_title', 'pt') + ->fields('pt', array('type', 'id', 'page_title')) + ->execute(); + + // Get general metatag config settings. + $metatag_config_global = metatag_config_load('global'); + $metatag_config_node = metatag_config_load('node'); + $metatag_config_taxonomy_term = metatag_config_load('taxonomy_term'); + $metatag_config_user = metatag_config_load('user'); + + // Track any records that are skipped. + $skipped = array(); + + // Loop over each of the page_title records. + $entity_info = entity_get_info(); + while ($pt_data = $page_titles->fetchObject()) { + $entity_type = $pt_data->type; + $entity_id = $pt_data->id; + + if ($entity_type == 'term') { + // Use the proper class name instead of what's in the page_title table. + $entity_type = 'taxonomy_term'; + } + + $entity = array(); + if (array_key_exists($entity_type, $entity_info)) { + $entity = entity_load($entity_type, array($entity_id)); + } + if (empty($entity)) { + $skipped[] = $entity_type . ':' . $entity_id; + continue; + } + + $entity = reset($entity); + + // Extract additional values from the entity. + $langcode = metatag_entity_get_language($entity_type, $entity); + list($entity_id, $revision_id) = entity_extract_ids($entity_type, $entity); + + // Load any possible existing meta tags for this object. + $data = metatag_metatags_load($entity_type, $entity_id); + + // Drop back one level because the results will be keyed by revision_id. + if (!empty($data)) { + $data = reset($data); + } + + switch ($entity_type) { + case 'node': + $metatag_config_node_type = metatag_config_load('node:' . $entity->type); + + if (!empty($metatag_config_node_type) && isset($metatag_config_node_type->config['title'])) { + $title_setting = $metatag_config_node_type->config['title']['value']; + } + elseif (isset($metatag_config_node->config['title'])) { + $title_setting = $metatag_config_node->config['title']['value']; + } + else { + $title_setting = $metatag_config_global->config['title']['value']; + } + $metatag_title = str_replace('[current-page:title]', trim($pt_data->page_title), $title_setting); + $metatag_title = str_replace('[node:title]', trim($pt_data->page_title), $metatag_title); + break; + + case 'taxonomy_term': + $metatag_config_vocabulary_type = metatag_config_load('taxonomy_term:' . $entity->vocabulary_machine_name); + + if (!empty($metatag_config_vocabulary_type) && isset($metatag_config_vocabulary_type->config['title'])) { + $title_setting = $metatag_config_vocabulary_type->config['title']['value']; + } + elseif (isset($metatag_config_taxonomy_term->config['title'])) { + $title_setting = $metatag_config_taxonomy_term->config['title']['value']; + } + else { + $title_setting = $metatag_config_global->config['title']['value']; + } + $metatag_title = str_replace('[current-page:title]', trim($pt_data->page_title), $title_setting); + $metatag_title = str_replace('[term:name]', trim($pt_data->page_title), $metatag_title); + break; + + case 'user': + if (isset($metatag_config_user->config['title'])) { + $title_setting = $metatag_config_user->config['title']['value']; + } + else { + $title_setting = $metatag_config_global->config['title']['value']; + } + $metatag_title = str_replace('[current-page:title]', trim($pt_data->page_title), $title_setting); + $metatag_title = str_replace('[user:name]', trim($pt_data->page_title), $metatag_title); + break; + + // Something else? Leave such records for another time. + default: + $skipped[] = $entity_type . ':' . $entity_id; + // Jump back to the outer for() loop. + continue 2; + } + $data[$langcode]['title']['value'] = $metatag_title; + + metatag_metatags_save($entity_type, $entity_id, $revision_id, $data); + $converted += db_delete('page_title') + ->condition('type', $entity_type) + ->condition('id', $entity_id) + ->execute(); + } + + // Log any records that were skipped. + if (!empty($skipped)) { + watchdog('metatag_importer', "Failed to convert the following page_title records: :records", array(':records' => implode(', ', $skipped))); + } + + return $converted; +} diff --git a/sites/all/modules/contrib/metatag/metatag_importer/tests/metatag_importer.test b/sites/all/modules/contrib/metatag/metatag_importer/tests/metatag_importer.test new file mode 100644 index 00000000..a13afa37 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_importer/tests/metatag_importer.test @@ -0,0 +1,48 @@ + 'Metatag Importer tests', + 'description' => 'Test the Metatag:Importer module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_importer'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the importer admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags/importer'); + $this->assertResponse(200); + + // Confirm the page is loaded. + $this->assertText(t('Use the links above to import data from another module.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_mobile/README.txt b/sites/all/modules/contrib/metatag/metatag_mobile/README.txt new file mode 100644 index 00000000..01274436 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_mobile/README.txt @@ -0,0 +1,91 @@ +Metatag: Mobile +--------------- +This submodule of Metatag adds a number of new meta tags commonly used for +tailoring the experience of people using mobile devices. + +Mobile: + + + + + + + +iOS: + + + + + + + +Android: + + + +Windows: + + + + + + + + + + + + + + + + + + + + + +Configuration +-------------------------------------------------------------------------------- +By default the two link alternate meta tags include a prefix - "android-app://" and "ios-app://". To remove this prefix just change the theme +functions, e.g.: + +/** + * Implements theme_metatag_mobile_android_app(). + * + * Remove the default prefix. + */ +function MYTHEME_metatag_mobile_android_app($variables) { + // Pass everything through to the normal 'link' tag theme. + $variables['element']['#name'] = 'alternate'; + + // Don't actually want this. + // $variables['element']['#value'] = 'android-app://' . $variables['element']['#value']; + + return theme('metatag_link_rel', $variables); +} + +/** + * Implements theme_metatag_mobile_ios_app(). + * + * Remove the default prefix. + */ +function MYTHEME_metatag_mobile_ios_app($variables) { + // Pass everything through to the normal 'link' tag theme. + $variables['element']['#name'] = 'alternate'; + + // Don't actually want this. + // $variables['element']['#value'] = 'ios-app://' . $variables['element']['#value']; + + return theme('metatag_link_rel', $variables); +} + + +Credits / Contact +-------------------------------------------------------------------------------- +Originally developed by Damien McKenna [1]. + + +References +-------------------------------------------------------------------------------- +1: https://www.drupal.org/u/damienmckenna. diff --git a/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info b/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info new file mode 100644 index 00000000..f7146e06 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.info @@ -0,0 +1,15 @@ +name = "Metatag: Mobile & UI Adjustments" +description = "Provides support for meta tags used to control the mobile browser experience." +package = SEO +core = 7.x +dependencies[] = metatag:metatag + +; Tests. +files[] = tests/metatag_mobile.test +files[] = tests/metatag_mobile.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc b/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc new file mode 100644 index 00000000..835655ec --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.metatag.inc @@ -0,0 +1,310 @@ + t('Mobile & UI Adjustments'), + 'description' => t('Meta tags used to control the mobile browser experience. Some of these meta tags have been replaced by newer mobile browsers. These meta tags usually only need to be set globally, rather than per-page.'), + 'form' => array( + '#weight' => 80, + ), + ); + $info['groups']['apple_mobile'] = array( + 'label' => t('Apple & iOS'), + 'description' => t("Custom meta tags used by Apple's software, iOS, Safari, etc."), + 'form' => array( + '#weight' => 81, + ), + ); + $info['groups']['android_mobile'] = array( + 'label' => t('Android'), + 'description' => t('Custom meta tags used by the Android OS, browser, etc.'), + 'form' => array( + '#weight' => 82, + ), + ); + $info['groups']['windows_mobile'] = array( + 'label' => t('Windows & Windows Mobile'), + 'description' => t('Custom meta tags used by the Windows and Windows Mobile OSes, IE browser, etc.'), + 'form' => array( + '#weight' => 83, + ), + ); + + $weight = 80; + + // Default values for each meta tag. + $defaults = array( + 'description' => '', + 'class' => 'DrupalTextMetaTag', + 'group' => 'mobile', + ); + + $info['tags']['theme-color'] = array( + 'label' => t('Theme Color'), + 'description' => t('A color in hexidecimal format, e.g. "#0000ff" for blue; must include the "#" symbol. Used by some browsers to control the background color of the toolbar, the color used with an icon, etc.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['MobileOptimized'] = array( + 'label' => t('Mobile Optimized'), + 'description' => t('Using the value "width" tells certain mobile Internet Explorer browsers to display as-is, without being resized. Alternatively a numerical width may be used to indicate the desired page width the page should be rendered in: "240" is the suggested default, "176" for older browsers or "480" for newer devices with high DPI screens.'), + 'weight' => ++$weight, + 'multiple' => TRUE, + ) + $defaults; + + $info['tags']['HandheldFriendly'] = array( + 'label' => t('Handheld-Friendly'), + 'description' => t('Some older mobile browsers will expect this meta tag to be set to "true" to indicate that the site has been designed with mobile browsers in mind.'), + 'weight' => ++$weight, + 'multiple' => TRUE, + ) + $defaults; + + $info['tags']['viewport'] = array( + 'label' => t('Viewport'), + 'description' => t('Used by most contemporary browsers to control the display for mobile browsers. Please read a guide on responsive web design for details of what values to use.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['cleartype'] = array( + 'label' => t('Cleartype'), + 'description' => t('A legacy meta tag for older versions of Internet Explorer on Windows, use the value "on" to enable it; this tag is ignored by all other browsers.'), + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_http_equiv', + ), + ) + $defaults; + + $info['tags']['amphtml'] = array( + 'label' => t('AMP URL'), + 'description' => t('Provides an absolute URL to an AMP-formatted version of the current page. See the official AMP specifications for details on how the page should be formatted.', array('@url' => 'https://www.ampproject.org/')), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['alternate_handheld'] = array( + 'label' => t('Handheld URL'), + 'description' => t('Provides an absolute URL to a specially formatted version of the current page designed for "feature phones", mobile phones that do not support modern browser standards. See the official Google Mobile SEO Guide for details on how the page should be formatted.', array('@url' => 'https://developers.google.com/webmasters/mobile-sites/mobile-seo/other-devices?hl=en#feature_phones')), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_mobile_alt_handheld', + '#name' => 'alternate', + '#media' => 'handheld', + ), + ) + $defaults; + + // Default values for each meta tag. + $defaults = array( + 'description' => '', + 'class' => 'DrupalTextMetaTag', + 'group' => 'apple_mobile', + ); + + $info['tags']['apple-itunes-app'] = array( + 'label' => t('iTunes App details'), + 'description' => t('This informs iOS devices to display a banner to a specific app. If used, it must provide the "app-id" value, the "affiliate-data" and "app-argument" values are optional.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['apple-mobile-web-app-capable'] = array( + 'label' => t('Web app capable?'), + 'description' => t('If set to "yes", the application will run in full-screen mode; the default behavior is to use Safari to display web content.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['apple-mobile-web-app-status-bar-style'] = array( + 'label' => t('Status bar color'), + 'description' => t('Requires the "Web app capable" meta tag to be set to "yes". May be set to "default", "black", or "black-translucent".'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['apple-mobile-web-app-title'] = array( + 'label' => t('Apple Mobile Web App Title'), + 'description' => t('Overrides the long site title when using the Apple Add to Home Screen.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['format-detection'] = array( + 'label' => t('Format detection'), + 'description' => t('If set to "telephone=no" the page will not be checked for phone numbers, which would be presented.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['ios-app-link-alternative'] = array( + 'label' => t('iOS app link alternative'), + 'description' => t('A custom string for deeplinking to an iOS mobile app. Should be in the format "itunes_id/scheme/host_path", e.g. 123456/example/hello-screen". The "ios-app://" prefix will be included automatically.'), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_mobile_ios_app', + ), + 'header' => FALSE, + ) + $defaults; + + // Default values for each meta tag. + $defaults = array( + 'description' => '', + 'class' => 'DrupalTextMetaTag', + 'group' => 'android_mobile', + ); + + $info['tags']['android-app-link-alternative'] = array( + 'label' => t('Android app link alternative'), + 'description' => t('A custom string for deeplinking to an Android mobile app. Should be in the format "package_name/host_path", e.g. "com.example.android/example/hello-screen". The "android-app://" prefix will be included automatically.'), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_mobile_android_app', + ), + 'header' => FALSE, + ) + $defaults; + + $info['tags']['android-manifest'] = array( + 'label' => t('Manifest'), + 'description' => t('A URL to a manifest.json file that describes the application. The JSON-based manifest provides developers with a centralized place to put metadata associated with a web application.'), + 'class' => 'DrupalLinkMetaTag', + 'weight' => ++$weight, + 'element' => array( + '#name' => 'manifest', + ), + ) + $defaults; + + // Default values for each meta tag. + $defaults = array( + 'description' => '', + 'class' => 'DrupalTextMetaTag', + 'group' => 'windows_mobile', + ); + + $info['tags']['x-ua-compatible'] = array( + 'label' => t('X-UA-Compatible'), + 'description' => t('Indicates to IE which rendering engine should be used for the current page.'), + 'weight' => ++$weight, + 'element' => array( + '#theme' => 'metatag_http_equiv', + ), + ) + $defaults; + + $info['tags']['application-name'] = array( + 'label' => t('Application name'), + 'description' => t('The default name displayed with the pinned sites tile (or icon). Set the content attribute to the desired name.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-allowDomainApiCalls'] = array( + 'label' => t('MSApplication - Allow domain API calls'), + 'description' => t('Allows tasks to be defined on child domains of the fully qualified domain name associated with the pinned site. Should be either "true" or "false".'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-allowDomainMetaTags'] = array( + 'label' => t('MSApplication - Allow domain meta tags'), + 'description' => t('Allows tasks to be defined on child domains of the fully qualified domain name associated with the pinned site. Should be either "true" or "false".'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-badge'] = array( + 'label' => t('MSApplication - Badge'), + 'description' => t('A semi-colon -separated string that must contain the "polling-uri=" value with the full URL to a Badge Schema XML file. May also contain "frequency=" value set to either 30, 60, 360, 720 or 1440 (default) which specifies (in minutes) how often the URL should be polled.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-config'] = array( + 'label' => t('MSApplication - Config'), + 'description' => t('Should contain the full URL to a Browser configuration schema file that further controls tile customizations.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-navbutton-color'] = array( + 'label' => t('MSApplication - Nav button color'), + 'description' => t('Controls the color of the Back and Forward buttons in the pinned site browser window.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-notification'] = array( + 'label' => t('MSApplication - Notification'), + 'description' => t('A semi-colon -separated string containing "polling-uri=" (required), "polling-uri2=", "polling-uri3=", "polling-uri4=" and "polling-uri5=" to indicate the URLs for notifications. May also contain a "frequency=" value to specify how often (in minutes) the URLs will be polled; limited to 30, 60, 360, 720 or 1440 (default). May also contain the value "cycle=" to control the notifications cycle.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-square150x150logo'] = array( + 'label' => t('MSApplication - Square logo, 150px x 150px'), + 'description' => t('The URL to a logo file that is 150px by 150px.'), + 'image' => TRUE, + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-square310x310logo'] = array( + 'label' => t('MSApplication - Square logo, 310px x 310px'), + 'description' => t('The URL to a logo file that is 310px by 310px.'), + 'image' => TRUE, + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-square70x70logo'] = array( + 'label' => t('MSApplication - Square logo, 70px x 70px'), + 'description' => t('The URL to a logo file that is 70px by 70px.'), + 'image' => TRUE, + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-wide310x150logo'] = array( + 'label' => t('MSApplication - Wide logo, 310px x 150px'), + 'description' => t('The URL to a logo file that is 310px by 150px.'), + 'image' => TRUE, + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-starturl'] = array( + 'label' => t('MSApplication - Start URL'), + 'description' => t('The URL to the root page of the site.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-task'] = array( + 'label' => t('MSApplication - Task'), + 'description' => t('A semi-colon -separated string defining the "jump" list task. Should contain the "name=" value to specify the task\'s name, the "action-uri=" value to set the URL to load when the jump list is clicked, the "icon-uri=" value to set the URL to an icon file to be displayed, and "window-type=" set to either "tab" (default), "self" or "window" to control how the link opens in the browser.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-task-separator'] = array( + 'label' => t('MSApplication - Task separator'), + 'description' => t(''), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-tilecolor'] = array( + 'label' => t('MSApplication - Tile color'), + 'description' => t('The HTML color to use as the background color for the live tile.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-tileimage'] = array( + 'label' => t('MSApplication - Tile image'), + 'description' => t('The URL to an image to use as the background for the live tile.'), + 'image' => TRUE, + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-tooltip'] = array( + 'label' => t('MSApplication - Tooltip'), + 'description' => t('Controls the text shown in the tooltip for the pinned site\'s shortcut.'), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['msapplication-window'] = array( + 'label' => t('MSApplication - Window'), + 'description' => t('A semi-colon -separated value that controls the dimensions of the initial window. Should contain the values "width=" and "height=" to control the width and height respectively.'), + 'weight' => ++$weight, + ) + $defaults; + + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module b/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module new file mode 100644 index 00000000..5cb3a4a1 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_mobile/metatag_mobile.module @@ -0,0 +1,91 @@ + 1); + } +} + +/** + * Implements hook_theme(). + */ +function metatag_mobile_theme() { + $info['metatag_mobile_android_app'] = array( + 'render element' => 'element', + ); + $info['metatag_mobile_ios_app'] = array( + 'render element' => 'element', + ); + $info['metatag_mobile_alt_handheld'] = array( + 'render element' => 'element', + ); + + return $info; +} + +/** + * Theme callback for an Android app link meta tag. + * + * The format is: + * + */ +function theme_metatag_mobile_android_app($variables) { + // Pass everything through to the normal 'link' tag theme. + $variables['element']['#name'] = 'alternate'; + $variables['element']['#value'] = 'android-app://' . $variables['element']['#value']; + + return theme('metatag_link_rel', $variables); +} + +/** + * Theme callback for an iOS app link meta tag. + * + * The format is: + * + */ +function theme_metatag_mobile_ios_app($variables) { + // Pass everything through to the normal 'link' tag theme. + $variables['element']['#name'] = 'alternate'; + $variables['element']['#value'] = 'ios-app://' . $variables['element']['#value']; + + return theme('metatag_link_rel', $variables); +} + + +/** + * Theme callback for a handheld-formatted alternative URL. + * + * The format is: + * + */ +function theme_metatag_mobile_alt_handheld($variables) { + $element = &$variables['element']; + $args = array( + '#name' => 'rel', + '#media' => 'media', + '#value' => 'href', + ); + element_set_attributes($element, $args); + unset($element['#value']); + return theme('html_tag', $variables); +} + +/* + * theme-color + * MobileOptimized + * HandheldFriendly + * viewport + * cleartype + * apple-mobile-web-app-capable + * apple-mobile-web-app-status-bar-style + * format-detection + * android-app + */ diff --git a/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test b/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test new file mode 100644 index 00000000..238f960e --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.tags.test @@ -0,0 +1,225 @@ + 'Metatag tags: Mobile', + 'description' => 'Test the mobile meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'alternate_handheld', + 'amphtml', + 'android-app-link-alternative', + 'android-manifest', + 'apple-itunes-app', + 'apple-mobile-web-app-capable', + 'apple-mobile-web-app-status-bar-style', + 'apple-mobile-web-app-title', + 'application-name', + 'cleartype', + 'format-detection', + 'HandheldFriendly', + 'ios-app-link-alternative', + 'MobileOptimized', + 'msapplication-allowDomainApiCalls', + 'msapplication-allowDomainMetaTags', + 'msapplication-badge', + 'msapplication-config', + 'msapplication-navbutton-color', + 'msapplication-notification', + 'msapplication-square150x150logo', + 'msapplication-square310x310logo', + 'msapplication-square70x70logo', + 'msapplication-starturl', + 'msapplication-task', + 'msapplication-task-separator', + 'msapplication-tilecolor', + 'msapplication-tileimage', + 'msapplication-tooltip', + 'msapplication-wide310x150logo', + 'msapplication-window', + 'theme-color', + 'viewport', + 'x-ua-compatible', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_mobile'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + // These tags all use dashes instead of underlines. + $tag_name = str_replace('_', '-', $tag_name); + + // Fix a few specific tags. + $tag_name = str_replace('mobileoptimized', 'MobileOptimized', $tag_name); + $tag_name = str_replace('handheldfriendly', 'HandheldFriendly', $tag_name); + + return $tag_name; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'alternate-handheld'. + */ + public function alternate_handheld_test_output_xpath() { + return "//link[@rel='alternate' and @media='handheld']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'alternate-handheld'. + */ + public function alternate_handheld_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'amphtml'. + */ + public function amphtml_test_output_xpath() { + return "//link[@rel='amphtml']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'amphtml'. + */ + public function amphtml_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'android-app-link-alternative'. + */ + public function android_app_link_alternative_test_output_xpath() { + return "//link[@rel='alternate' and starts-with(@href, 'android-app:')]"; + } + + /** + * Implements {meta_tag_name}_test_preprocess_output() for + * 'android-app-link-alternative'. + */ + public function android_app_link_alternative_test_preprocess_output($string) { + return 'android-app://' . $string; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for + * 'android-app-link-alternative'. + */ + public function android_app_link_alternative_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'android_manifest'. + */ + public function android_manifest_test_output_xpath() { + return "//link[@rel='manifest']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'android_manifest'. + */ + public function android_manifest_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_name_attribute() for 'cleartype'. + */ + public function cleartype_test_name_attribute() { + return 'http-equiv'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for + * 'ios_app_link_alternative'. + */ + public function ios_app_link_alternative_test_output_xpath() { + return "//link[@rel='alternate' and starts-with(@href, 'ios-app:')]"; + } + + /** + * Implements {meta_tag_name}_test_output_prefix() for + * 'ios_app_link_alternative'. + */ + public function ios_app_link_alternative_test_preprocess_output($string) { + return 'ios-app://' . $string; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for + * 'ios_app_link_alternative'. + */ + public function ios_app_link_alternative_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-square150x150logo'. + */ + public function msapplication_square150x150logo_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-square310x310logo'. + */ + public function msapplication_square310x310logo_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-square70x70logo'. + */ + public function msapplication_square70x70logo_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-tileimage'. + */ + public function msapplication_tileimage_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'msapplication-wide310x150logo'. + */ + public function msapplication_wide310x150logo_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_name_attribute() for 'x-ua-compatible'. + */ + public function x_ua_compatible_test_name_attribute() { + return 'http-equiv'; + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.test b/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.test new file mode 100644 index 00000000..7f4ca0ff --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_mobile/tests/metatag_mobile.test @@ -0,0 +1,48 @@ + 'Metatag Mobile tests', + 'description' => 'Test the Metatag:Mobile module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_mobile'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info b/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info index e431b728..fb0e9245 100644 --- a/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info +++ b/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.info @@ -1,12 +1,15 @@ -name = Metatag:OpenGraph +name = Metatag: OpenGraph description = Provides support for Open Graph Protocol meta tags. package = SEO core = 7.x -dependencies[] = metatag +dependencies[] = metatag:metatag -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +; Tests. +files[] = tests/metatag_opengraph.test +files[] = tests/metatag_opengraph.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.install b/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.install index 1d3813e7..9654e327 100644 --- a/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.install +++ b/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.install @@ -1,4 +1,5 @@ REQUIREMENT_WARNING, - 'title' => 'Metatag:OpenGraph', - 'value' => $t('Possible conflict with the RDF module'), - 'description' => $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."), - ); + // 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". + if (strpos('-', $minor)) { + list($minor, $suffix) = explode('-', $minor); + } + + if ($minor < 33) { + $requirements['metatag_og_rdf'] = array( + 'severity' => REQUIREMENT_WARNING, + 'title' => 'Metatag:OpenGraph', + 'value' => $t('RDF problems with Drupal core releases before v7.33'), + 'description' => $t('The core RDF module in Drupal before v7.33 caused validation problems for Open Graph meta tags. The solution is to update to v7.33 or newer.'), + ); + } } } @@ -27,13 +37,24 @@ function metatag_opengraph_requirements($phase) { } /** - * Implements hook_install(). + * Implements hook_update_dependencies(). */ -function metatag_opengraph_install() { - // Display a warning about possible conflicts with the RDF module. - if (module_exists('rdf')) { - 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.')); - } +function metatag_opengraph_update_dependencies() { + // OpenGraph update 7103 requires the complete Metatag schema, so lets wait + // for Metatag update 7100 just to be sure. + $dependencies['metatag_opengraph'][7103] = array( + 'metatag' => 7100, + ); + return $dependencies; +} + +/** + * Implements hook_uninstall(). + */ +function metatag_opengraph_uninstall() { + // Remove all of the maxlength variables. + variable_del('metatag_maxlength_og:title'); + variable_del('metatag_maxlength_og:description'); } /** @@ -54,3 +75,46 @@ function metatag_opengraph_update_7100() { 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.')); } + +/** + * The Open Graph Products meta tags are now in a new submodule. + */ +function metatag_opengraph_update_7102() { + drupal_set_message(t('The Open Graph Products meta tags have been moved into the new "Metatag: Open Graph Products" submodule.')); +} + +/** + * Change og:video to og:video:url in all metatags. + */ +function metatag_opengraph_update_7103(&$sandbox) { + module_load_include('install', 'metatag'); + $old_tag = 'og:video'; + $new_tag = 'og:video:url'; + return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); +} + +/** + * Rename the 'og:video' meta tag to 'og:video:url' in the configs. + */ +function metatag_opengraph_update_7104() { + module_load_include('install', 'metatag'); + $old_tag = 'og:video'; + $new_tag = 'og:video:url'; + return metatag_update_replace_config_tag($old_tag, $new_tag); +} + +/** + * Clear the Metatag cache to pick up changes to og:video. + */ +function metatag_opengraph_update_7105() { + cache_clear_all('*', 'cache_metatag', TRUE); + return t('All Metatag caches cleared.'); +} + +/** + * Clear the Metatag cache to pick up changes to og:audio:secure_url. + */ +function metatag_opengraph_update_7106() { + cache_clear_all('*', 'cache_metatag', TRUE); + return t('All Metatag caches cleared.'); +} diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.metatag.inc b/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.metatag.inc index bd092ae6..ee2d4500 100644 --- a/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.metatag.inc +++ b/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.metatag.inc @@ -1,4 +1,5 @@ config += array( 'og:image' => array('value' => '[user:picture:url]'), + // For now keep the old default. + // 'og:image:url' => array('value' => '[user:picture:url]'), ); } break; @@ -77,7 +80,7 @@ function metatag_opengraph_metatag_bundled_config_alter(array &$configs) { function metatag_opengraph_metatag_info() { $info['groups']['open-graph'] = array( 'label' => t('Open Graph'), - 'description' => t("The Open Graph meta tags are used control how Facebook, LinkedIn an other social networking sites interpret the site's content.", array('@ogp' => 'http://ogp.me/')), + 'description' => t("The Open Graph meta tags are used control how Facebook, Pinterest, LinkedIn and other social networking sites interpret the site's content.", array('@ogp' => 'http://ogp.me/')), 'form' => array( '#weight' => 50, ), @@ -107,6 +110,7 @@ function metatag_opengraph_metatag_info() { 'label' => t('Content type'), 'description' => t('The type of the content, e.g., movie.'), 'weight' => ++$weight, + 'select_or_other' => TRUE, 'form' => array( '#type' => 'select', '#options' => _metatag_opengraph_type_options(), @@ -126,18 +130,10 @@ function metatag_opengraph_metatag_info() { ), ) + $og_defaults; - if (module_exists('select_or_other')) { - // Enhance the og:type field to support custom types. - $info['tags']['og:type']['form']['#type'] = 'select_or_other'; - $info['tags']['og:type']['form']['#other'] = t('Other (please type a value)'); - $info['tags']['og:type']['form']['#other_unknown_defaults'] = 'other'; - $info['tags']['og:type']['form']['#theme'] = 'select_or_other'; - $info['tags']['og:type']['form']['#element_validate'] = array('select_or_other_element_validate'); - } - $info['tags']['og:title'] = array( 'label' => t('Content title'), 'description' => t('The title of the content, e.g., The Rock.'), + 'maxlength' => 0, 'weight' => ++$weight, ) + $og_defaults; @@ -163,6 +159,7 @@ function metatag_opengraph_metatag_info() { $info['tags']['og:description'] = array( 'label' => t('Content description'), 'description' => t('A one to two sentence description of the content.'), + 'maxlength' => 0, 'weight' => ++$weight, ) + $og_defaults; @@ -181,9 +178,20 @@ function metatag_opengraph_metatag_info() { ) + $og_defaults; $info['tags']['og:image'] = array( + 'label' => t('Image'), + 'description' => t('The URL of an image which should represent the content. The image must be at least 200 x 200 pixels in size; 600 x 316 pixels is a recommended minimum size, and for best results use an image least 1200 x 630 pixels in size. Supports PNG, JPEG and GIF formats. Should not be used if og:image:url is used. Note: if multiple images are added many services (e.g. Facebook) will default to the largest image, not specifically the first one.'), + 'multiple' => TRUE, + 'image' => TRUE, + 'weight' => ++$weight, + 'devel_generate' => array( + 'type' => 'image', + ), + ) + $og_defaults; + $info['tags']['og:image:url'] = 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.'), + 'description' => t('A alternative version of og:image and has exactly the same requirements; only one needs to be used. Note: some services do not accept this tag and will only accept the "image" tag above.'), 'multiple' => TRUE, + 'image' => TRUE, 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'image', @@ -191,9 +199,10 @@ function metatag_opengraph_metatag_info() { ) + $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://".'), + '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://". Note: if multiple images are added many services (e.g. Facebook) will default to the largest image, not the first one.'), 'multiple' => TRUE, 'secure' => TRUE, + 'image' => TRUE, 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'image', @@ -201,7 +210,7 @@ function metatag_opengraph_metatag_info() { ) + $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.'), + '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. Note: there should be one value for each image, and having more than there are images may cause problems.'), 'multiple' => TRUE, 'weight' => ++$weight, ) + $og_defaults; @@ -239,9 +248,12 @@ function metatag_opengraph_metatag_info() { ), ) + $og_defaults; - $info['tags']['og:street-address'] = array( + $info['tags']['og:street_address'] = array( 'label' => t('Street address'), 'weight' => ++$weight, + 'replaces' => array( + 'og:street-address', + ), ) + $og_defaults; $info['tags']['og:locality'] = array( 'label' => t('Locality'), @@ -251,13 +263,19 @@ function metatag_opengraph_metatag_info() { 'label' => t('Region'), 'weight' => ++$weight, ) + $og_defaults; - $info['tags']['og:postal-code'] = array( + $info['tags']['og:postal_code'] = array( 'label' => t('Postal/ZIP code'), 'weight' => ++$weight, + 'replaces' => array( + 'og:postal-code', + ), ) + $og_defaults; - $info['tags']['og:country-name'] = array( + $info['tags']['og:country_name'] = array( 'label' => t('Country name'), 'weight' => ++$weight, + 'replaces' => array( + 'og:country-name', + ), ) + $og_defaults; $info['tags']['og:email'] = array( @@ -286,6 +304,7 @@ function metatag_opengraph_metatag_info() { '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, + 'is_language' => TRUE, 'devel_generate' => array( 'maxlength' => 1, ), @@ -295,6 +314,7 @@ function metatag_opengraph_metatag_info() { 'description' => 'Other locales this content is available in, must be in the format language_TERRITORY, e.g. "fr_FR".', 'weight' => ++$weight, 'multiple' => TRUE, + 'is_language' => TRUE, 'devel_generate' => array( 'maxlength' => 1, ), @@ -393,6 +413,7 @@ function metatag_opengraph_metatag_info() { $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://".'), + 'secure' => TRUE, 'weight' => ++$weight, 'devel_generate' => array( 'type' => 'url', @@ -449,10 +470,13 @@ function metatag_opengraph_metatag_info() { // ), // ), // ); - $info['tags']['og:video'] = array( + $info['tags']['og:video:url'] = array( 'label' => t('Video URL'), 'description' => t('The URL to a video file that complements this object.'), 'weight' => ++$weight, + 'replaces' => array( + 'og:video', + ), 'devel_generate' => array( 'type' => 'url', ), @@ -507,7 +531,6 @@ function metatag_opengraph_metatag_info() { $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; @@ -583,6 +606,7 @@ function _metatag_opengraph_type_options() { 'city' => t('City'), 'country' => t('Country'), 'landmark' => t('Landmark'), + 'place' => t('Place'), 'state_province' => t('State or province'), ), t('Products and Entertainment') => array( @@ -592,6 +616,7 @@ function _metatag_opengraph_type_options() { 'food' => t('Food'), 'game' => t('Game'), 'product' => t('Product'), + 'product.group' => t('Product group'), 'song' => t('Song'), 'video.movie' => t('Movie'), 'video.tv_show' => t('TV show'), @@ -599,9 +624,8 @@ function _metatag_opengraph_type_options() { 'video.other' => t('Miscellaneous video'), ), t('Websites') => array( - 'blog' => t('Blog'), 'website' => t('Website'), - 'article' => t('Article'), + 'article' => t('Article (inc blog)'), ), ); diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.module b/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.module index 26520a31..25532af0 100644 --- a/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.module +++ b/sites/all/modules/contrib/metatag/metatag_opengraph/metatag_opengraph.module @@ -1,18 +1,24 @@ 'http://ogp.me/ns#', + 'article' => 'http://ogp.me/ns/article#', + 'book' => 'http://ogp.me/ns/book#', + 'profile' => 'http://ogp.me/ns/profile#', + 'video' => 'http://ogp.me/ns/video#', + 'product' => 'http://ogp.me/ns/product#', + ); } /** @@ -52,7 +74,8 @@ og:email og:phone_number og:fax_number -og:video +og:video:url +og:video:secure_url og:video:height og:video:width og:video:type @@ -65,4 +88,4 @@ og:audio:type og:upc og:isbn -*/ + */ diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test b/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test new file mode 100644 index 00000000..df93a651 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.tags.test @@ -0,0 +1,183 @@ + 'Metatag tags: OpenGraph', + 'description' => 'Test the OpenGraph meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'article:author', + 'article:expiration_time', + 'article:modified_time', + 'article:published_time', + 'article:publisher', + 'article:section', + 'article:tag', + 'book:author', + 'book:isbn', + 'book:release_date', + 'book:tag', + 'og:audio', + 'og:audio:secure_url', + 'og:audio:type', + 'og:country_name', + 'og:description', + 'og:determiner', + 'og:email', + 'og:fax_number', + 'og:image', + 'og:image:height', + 'og:image:secure_url', + 'og:image:type', + 'og:image:url', + 'og:image:width', + 'og:latitude', + 'og:locale', + 'og:locale:alternate', + 'og:locality', + 'og:longitude', + 'og:phone_number', + 'og:postal_code', + 'og:region', + 'og:see_also', + 'og:site_name', + 'og:street_address', + 'og:title', + 'og:type', + 'og:updated_time', + 'og:url', + 'og:video:height', + 'og:video:secure_url', + 'og:video:type', + 'og:video:url', + 'og:video:width', + 'profile:first_name', + 'profile:gender', + 'profile:last_name', + 'profile:username', + 'video:actor', + 'video:actor:role', + 'video:director', + 'video:duration', + 'video:release_date', + 'video:series', + 'video:tag', + 'video:writer', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_opengraph'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public $test_name_attribute = 'property'; + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + // All OG tags use colons to separate levels. + $tag_name = str_replace('_', ':', $tag_name); + + // Fix a few specific tags. + $tag_name = str_replace('secure:url', 'secure_url', $tag_name); + $tag_name = str_replace(':time', '_time', $tag_name); + $tag_name = str_replace(':date', '_date', $tag_name); + $tag_name = str_replace(':name', '_name', $tag_name); + $tag_name = str_replace(':address', '_address', $tag_name); + $tag_name = str_replace('see:also', 'see_also', $tag_name); + $tag_name = str_replace(':number', '_number', $tag_name); + $tag_name = str_replace(':code', '_code', $tag_name); + + return $tag_name; + } + + /** + * Implements {meta_tag_name}_test_key() for 'og:type'. + */ + public function og_type_test_key() { + return 'metatags[und][og:type][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:type'. + */ + public function og_type_test_value() { + return 'article'; + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'og:type'. + */ + public function og_type_test_field_xpath() { + return "//select[@name='metatags[und][og:type][value]']"; + } + + /** + * Implements {meta_tag_name}_test_key() for 'og:determiner'. + */ + public function og_determiner_test_key() { + return 'metatags[und][og:determiner][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:determiner'. + */ + public function og_determiner_test_value() { + return 'a'; + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'og:determiner'. + */ + public function og_determiner_test_field_xpath() { + return "//select[@name='metatags[und][og:determiner][value]']"; + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:image'. + */ + public function og_image_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:image:url'. + */ + public function og_image_url_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'og:image:secure_url'. + */ + public function og_image_secure_url_test_value() { + return str_replace('http://', 'https://', $this->randomImageUrl()); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.test b/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.test new file mode 100644 index 00000000..875e7902 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_opengraph/tests/metatag_opengraph.test @@ -0,0 +1,48 @@ + 'Metatag OpenGraph tests', + 'description' => 'Test the Metatag:OpenGraph module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_opengraph'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info b/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info new file mode 100644 index 00000000..590293bf --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.info @@ -0,0 +1,16 @@ +name = Metatag: OpenGraph Products +description = Provides additional Open Graph Protocol meta tags for describing products. +package = SEO +core = 7.x +dependencies[] = metatag:metatag +dependencies[] = metatag:metatag_opengraph + +; Tests. +files[] = tests/metatag_opengraph_products.test +files[] = tests/metatag_opengraph_products.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.metatag.inc b/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.metatag.inc new file mode 100644 index 00000000..d162ea51 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.metatag.inc @@ -0,0 +1,165 @@ + t('Open Graph - Products'), + 'description' => t("These Open Graph meta tags for describing products."), + 'form' => array( + '#weight' => 51, + ), + ); + + // Default values for each meta tag. + $defaults = array( + 'description' => '', + 'class' => 'DrupalTextMetaTag', + 'group' => 'open-graph-products', + 'element' => array( + '#theme' => 'metatag_property', + ), + ); + + $weight = 50; + + $info['tags']['product:price:amount'] = array( + 'label' => t('Price'), + 'description' => t("The numeric price with decimal point, without currency indicator. Values below 0.01 may not be supported by clients."), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:price:currency'] = array( + 'label' => t('Currency'), + 'description' => t("The currency for the price (if any)."), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:availability'] = array( + 'label' => t('Availability'), + 'description' => t('Case-insensitive string, possible values: "instock", "pending", "oos"; per Facebook\' documentation.', array('@url' => 'https://developers.facebook.com/docs/reference/opengraph/object-type/product')), + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:brand'] = array( + 'label' => t('Brand'), + 'description' => '', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:upc'] = array( + 'label' => t('UPC'), + 'description' => '', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:ean'] = array( + 'label' => t('EAN'), + 'description' => '', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:isbn'] = array( + 'label' => t('ISBN'), + 'description' => '', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:plural_title'] = array( + 'label' => t('Plural Title'), + 'description' => 'A title to be used to describe multiple items of this product', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:retailer'] = array( + 'label' => t('Retailer ID'), + 'description' => 'A Facebook ID (or reference to the profile) of the retailer.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:retailer_title'] = array( + 'label' => t('Retailer Name'), + 'description' => 'The name of the retailer.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:retailer_part_no'] = array( + 'label' => t('Retailer SKU/Product Number'), + 'description' => 'A retailer part number.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:mfr_part_no'] = array( + 'label' => t('Manufacturer SKU/Part Number'), + 'description' => 'A manufacturer part number.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:size'] = array( + 'label' => t('Size'), + 'description' => 'A size describing the product, such as S, M, L.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:product_link'] = array( + 'label' => t('Product Link'), + 'description' => 'A link to find out more about the product', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:category'] = array( + 'label' => t('Category'), + // 'description' => 'A category', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:color'] = array( + 'label' => t('Color'), + // 'description' => 'The product\'s color.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:material'] = array( + 'label' => t('Material'), + 'description' => 'A description of the material used to make the product.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:pattern'] = array( + 'label' => t('Pattern'), + 'description' => 'A description of the pattern used.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:shipping_cost:amount'] = array( + 'label' => t('Shipping Cost Amount'), + 'description' => 'The shipping costs.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:shipping_cost:currency'] = array( + 'label' => t('Shipping Cost Currency'), + 'description' => 'The shipping cost currency.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:weight:value'] = array( + 'label' => t('Product Weight'), + 'description' => 'The weight, without shipping materials.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:weight:units'] = array( + 'label' => t('Product Weight Units'), + 'description' => 'The unit of weight.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:shipping_weight:value'] = array( + 'label' => t('Shipping Weight'), + 'description' => 'The shipping weight.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:shipping_weight:units'] = array( + 'label' => t('Shipping Weight Units'), + 'description' => 'The unit of shipping weight.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:expiration_time'] = array( + 'label' => t('Expiration'), + 'description' => 'A time representing when the product expired, or will expire.', + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['product:condition'] = array( + 'label' => t('Condition'), + 'description' => 'The condition of the product.', + 'weight' => ++$weight, + ) + $defaults; + + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.module b/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.module new file mode 100644 index 00000000..5c9b3aea --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_opengraph_products/metatag_opengraph_products.module @@ -0,0 +1,15 @@ + 1); + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test b/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test new file mode 100644 index 00000000..c22783f5 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.tags.test @@ -0,0 +1,88 @@ + 'Metatag tags: OpenGraph Products', + 'description' => 'Test the OpenGraph Products meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'product:availability', + 'product:brand', + 'product:category', + 'product:color', + 'product:condition', + 'product:ean', + 'product:expiration_time', + 'product:isbn', + 'product:material', + 'product:mfr_part_no', + 'product:pattern', + 'product:plural_title', + 'product:price:amount', + 'product:price:currency', + 'product:product_link', + 'product:retailer', + 'product:retailer_part_no', + 'product:retailer_title', + 'product:shipping_cost:amount', + 'product:shipping_cost:currency', + 'product:shipping_weight:units', + 'product:shipping_weight:value', + 'product:size', + 'product:upc', + 'product:weight:units', + 'product:weight:value', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_opengraph_products'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public $test_name_attribute = 'property'; + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + // All OG tags use colons to separate levels. + $tag_name = str_replace('_', ':', $tag_name); + + // Fix a few specific tags. + $tag_name = str_replace(':weight', '_weight', $tag_name); + $tag_name = str_replace('product_weight', 'product:weight', $tag_name); + $tag_name = str_replace(':cost', '_cost', $tag_name); + $tag_name = str_replace(':part:no', '_part_no', $tag_name); + $tag_name = str_replace(':title', '_title', $tag_name); + $tag_name = str_replace(':link', '_link', $tag_name); + $tag_name = str_replace(':time', '_time', $tag_name); + + return $tag_name; + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.test b/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.test new file mode 100644 index 00000000..14ebb6a2 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_opengraph_products/tests/metatag_opengraph_products.test @@ -0,0 +1,48 @@ + 'Metatag OpenGraph products tests', + 'description' => 'Test the Metatag:OpenGraph Products module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_opengraph_products'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_panels/README.txt b/sites/all/modules/contrib/metatag/metatag_panels/README.txt index 57fefd01..58f9b6c5 100644 --- a/sites/all/modules/contrib/metatag/metatag_panels/README.txt +++ b/sites/all/modules/contrib/metatag/metatag_panels/README.txt @@ -2,7 +2,7 @@ Metatag: Panels ----------------- This module adds support for meta tag configuration for Panels pages. -Configuration is done within the "Metatag" tab existant in the Page Manager +Configuration is done within the "Metatag" tab existent in the Page Manager variant configuration page. @@ -22,6 +22,6 @@ This module is based on Panels Breadcrumbs [3] and the Meta tag: Context module. References -------------------------------------------------------------------------------- -1: http://drupal.org/user/887060 +1: https://www.drupal.org/u/devuo 2: http://dri-global.com -3: http://drupal.org/project/panels_breadcrumbs +3: https://www.drupal.org/project/panels_breadcrumbs diff --git a/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.i18n.inc b/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.i18n.inc new file mode 100644 index 00000000..6fef736d --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.i18n.inc @@ -0,0 +1,127 @@ + $title, + 'field' => "conf.metatag_panels.metatags.{$tag_name}.value", + ); + } + + $info['metatag_panels'] = array( + 'title' => t('Metatag:Panels configurations'), + // Callback to load all config objects. + 'list callback' => 'metatag_panels_i18n_list_panels', + // The object load callback. + // 'load callback' => 'metatag_panels_i18n_load', + // @todo Custom i18n object overrides. + // 'class' => 'metatag_panels_i18n_metatag', + // @todo Is this needed? What does it do? + // 'translation set' => TRUE, + // The object's "key" field, this tells i18n_string to use the $panel->name + // attribute. + 'key' => 'name', + // Placeholders for automatic paths. This connects the 'key' to strings in + // the paths listed below. + // 'placeholders' => array( + // '%did' => 'did', + // ), + // To produce edit links automatically. + // 'edit path' => 'admin/config/search/metatags/config/%instance', + // Auto-generate a 'translate' tab. + // 'translate tab' => 'admin/config/search/metatags/config/%instance/translate', + // Properties for string translation. + 'string translation' => array( + // The textgroup, type and (below) name will be concatenated into a single + // string as the {locales_source} context. + 'textgroup' => 'metatag', + 'type' => 'metatag_panels', + // Table where the object is stored, to automate string lists. + // 'table' => 'page_manager_handlers', + // Translatable properties of these objects, this will be added later. + 'properties' => $properties, + // The path to translate individual strings. + // 'translate path' => 'admin/config/search/metatags/config/%instance/translate/%i18n_language', + ), + ); + + return $info; +} + +/** + * List callback. + */ +function metatag_panels_i18n_list_panels() { + // Load all of the CTools objects. + ctools_include('export'); + $all_objects = array(); + + // Load the handlers first. + $handlers = ctools_export_crud_load_all('page_manager_handlers'); + if (!empty($handlers)) { + // Unserialize the config array. + foreach ($handlers as $name => $handler) { + if (!empty($handler)) { + if (is_string($handler->conf)) { + $handler->conf = unserialize($handler->conf); + } + if (!empty($handler->conf['metatag_panels']['enabled']) && !empty($handler->conf['metatag_panels']['metatags'])) { + $all_objects[$name] = $handler; + } + } + } + } + + // Load the pages next, they need extra "handling". + $pages = ctools_export_crud_load_all('page_manager_pages'); + if (!empty($pages)) { + // Unserialize the config array. + foreach ($pages as $key => $page) { + if (!empty($page) && !empty($page->default_handlers)) { + foreach ($page->default_handlers as $name => $handler) { + if (is_string($handler->conf)) { + $handler->conf = unserialize($handler->conf); + } + if (!empty($handler->conf['metatag_panels']['enabled']) && !empty($handler->conf['metatag_panels']['metatags'])) { + $all_objects[$name] = $handler; + } + } + } + } + } + + return $all_objects; +} diff --git a/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info b/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info index d2b6dd7b..ae4af7f5 100644 --- a/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info +++ b/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.info @@ -3,14 +3,15 @@ description = Provides Metatag integration within the Panels interface. package = SEO core = 7.x -dependencies[] = ctools -dependencies[] = metatag -dependencies[] = panels -dependencies[] = token +dependencies[] = metatag:metatag +dependencies[] = panels:panels -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +; Tests. +files[] = tests/metatag_panels.test +files[] = tests/metatag_panels.i18n.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.metatag.inc b/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.metatag.inc new file mode 100644 index 00000000..01471944 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.metatag.inc @@ -0,0 +1,14 @@ + t('Panels')); + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.module b/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.module index 89e2844a..6b7ba95f 100644 --- a/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.module +++ b/sites/all/modules/contrib/metatag/metatag_panels/metatag_panels.module @@ -1,4 +1,5 @@ $value) { $children_operations[$key] = $value; if ($key == 'context') { $children_operations['meta'] = array( @@ -30,7 +31,7 @@ function metatag_panels_page_manager_variant_operations_alter(&$operations, $han function metatag_panels_form($form, $form_state) { $handler = $form_state['handler']; - // Load available contexts + // Load available contexts. ctools_include('context-task-handler'); $contexts = ctools_context_handler_get_all_contexts($form_state['task'], $form_state['subtask'], $handler); @@ -53,7 +54,8 @@ function metatag_panels_form($form, $form_state) { '#default_value' => isset($handler->conf['metatag_panels']['enabled']) ? $handler->conf['metatag_panels']['enabled'] : FALSE, ); - // Don't set any metatag instance name as the configuration data is managed locally within panels. + // Don't set any metatag instance name as the configuration data is managed + // locally within panels. $instance = ''; $options = array('token types' => $token_types); $metatags = empty($handler->conf['metatag_panels']) ? array() : $handler->conf['metatag_panels']['metatags']; @@ -66,6 +68,34 @@ function metatag_panels_form($form, $form_state) { // Load the metatag form (passed by reference). metatag_metatags_form($form, $instance, $metatags[LANGUAGE_NONE], $options); + // Add CTools substitutions list to the form. + $rows = array(); + foreach ($contexts as $context) { + foreach (ctools_context_get_converters('%' . check_plain($context->keyword) . ':', $context) as $keyword => $title) { + $rows[] = array( + check_plain($keyword), + t('@identifier: @title', array('@title' => $title, '@identifier' => $context->identifier)), + ); + } + } + if (!empty($rows)) { + $form['contexts'] = array( + '#title' => t('Substitutions'), + '#type' => 'fieldset', + '#collapsible' => TRUE, + '#collapsed' => TRUE, + ); + $header = array(t('Keyword'), t('Value')); + $form['contexts']['context'] = array( + '#markup' => theme('table', array('header' => $header, 'rows' => $rows)), + ); + $form['contexts']['#states'] = array( + 'visible' => array( + ':input[name="metatags_enabled"]' => array('checked' => TRUE), + ), + ); + } + // Modify metatag form defaults. $form['metatags']['#collapsible'] = FALSE; $form['metatags']['#collapsed'] = FALSE; @@ -86,9 +116,18 @@ 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'][LANGUAGE_NONE], + 'metatags' => array(), ); + // Only bother saving the meta tags if they were enabled. + if ($conf['enabled']) { + $conf['metatags'] = $form_state['values']['metatags'][LANGUAGE_NONE]; + + // Translate the meta tags. + metatag_translations_update($conf['metatags'], 'metatag_panels:' . $form_state['handler']->name); + } + + // Save the values for later. $form_state['handler']->conf['metatag_panels'] = $conf; } @@ -96,6 +135,12 @@ function metatag_panels_form_submit($form, $form_state) { * Implements hook_ctools_render_alter(). */ function metatag_panels_ctools_render_alter($info, $page, $context) { + // By default do not add meta tags to admin pages. To enable meta tags on + // admin pages set the 'metatag_tag_admin_pages' variable to TRUE. + if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) { + return; + } + $output = &drupal_static('metatag_panels'); $handler = $context['handler']; @@ -104,7 +149,6 @@ 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']; if (!is_array($metatags) || empty($metatags)) { $metatags = array(); @@ -116,6 +160,9 @@ function metatag_panels_ctools_render_alter($info, $page, $context) { $metatags = array(LANGUAGE_NONE => $metatags); } + // Translate all of the meta tags using i18n. + metatag_translate_metatags($metatags[LANGUAGE_NONE], 'metatag_panels:' . $handler->name, NULL, FALSE); + // Append global defaults. $all_metatags = array(); foreach ($metatags as $langcode => $values) { @@ -129,6 +176,13 @@ function metatag_panels_ctools_render_alter($info, $page, $context) { return; } + // Substitute Panels context variables. + foreach ($metatags as $metatag => $data) { + if (is_string($data['value']) && strpos($data['value'], '%') !== FALSE) { + $metatags[$metatag]['value'] = check_plain(urldecode(ctools_context_keyword_substitute($data['value'], array(), $context['handler']->conf['display']->context))); + } + } + // Get the contexts that exist within this panel. ctools_include('context-task-handler'); $task_object = ctools_context_handler_get_task_object($context['task'], $context['subtask'], $context['handler']); @@ -147,20 +201,33 @@ function metatag_panels_ctools_render_alter($info, $page, $context) { drupal_set_title($info['title'], PASS_THROUGH); } + // Don't output meta tags that only contain the pager. + $current_pager = metatag_get_current_pager(); + // Build the Metatag. $options = array( 'instance' => 'panels:' . $handler->name, 'token data' => $tokens, ); foreach ($metatags as $metatag => $data) { + // Render CTools context substitution values prior to rendering the meta + // tag. + if (is_string($data['value'])) { + $data['value'] = check_plain(urldecode(ctools_context_keyword_substitute(trim($data['value']), array(), $task_contexts))); + } $metatag_instance = metatag_get_instance($metatag, $data); if ($metatag_instance) { - $output[$metatag] = $metatag_instance->getElement($options); + $tag_output = $metatag_instance->getElement($options); + // Don't output the pager if that's all there is. + if ($tag_output != $current_pager) { + $output[$metatag] = $tag_output; + } } } - // Give third-parties the opportunity to alter the metatag for a given instance. + // Give third-parties the opportunity to alter the metatag for a given + // instance. drupal_alter('metatag_metatags_view', $output, $options['instance']); } @@ -170,9 +237,17 @@ function metatag_panels_ctools_render_alter($info, $page, $context) { * @see metatag_panels_ctools_render_alter() */ function metatag_panels_page_build(&$page) { + // By default do not add meta tags to admin pages. To enable meta tags on + // admin pages set the 'metatag_tag_admin_pages' variable to TRUE. + if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) { + return; + } + $metatags = drupal_static('metatag_panels'); if (!empty($metatags)) { - $page['content']['metatags']['global'] = $metatags; + // The page region can be changed. + $region = variable_get('metatag_page_region', 'content'); + $page[$region]['metatags']['global'] = $metatags; } } diff --git a/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.i18n.test b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.i18n.test new file mode 100644 index 00000000..4a96223a --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.i18n.test @@ -0,0 +1,110 @@ + 'Metatag:Panels i18n tests', + 'description' => 'Test Metatag integration via the Metatag:Panels module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'panels', 'page_manager', 'i18n'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'panels'; + $modules[] = 'metatag_panels'; + + // Can't really do anything without Page Manager. + $modules[] = 'page_manager'; + + // Needed for translations. + $modules[] = 'locale'; + $modules[] = 'i18n'; + $modules[] = 'i18n_string'; + + // Enable the hidden submodule to manage some default configs. + $modules[] = 'metatag_panels_tests'; + + parent::setUp($modules); + + // Add more locales. + $this->setupLocales(); + + // Set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + // From i18n. + 'translate admin strings', + 'translate user-defined strings', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Reload the translations. + drupal_flush_all_caches(); + module_load_include('admin.inc', 'i18n_string'); + i18n_string_refresh_group('metatag'); + } + + /** + * Test the Metatag:Panels translations. + */ + public function testExportedPage() { + // Plan out the different translation string tests. + $string_en = 'Test page description.'; + $string_fr = 'French page description'; + $config_name = 'metatag_panels:page_metatag_panels_test__default:description'; + $path = 'metatag-panels-test'; + + // Confirm the string is present as it has been grabbed by the string- + // refresh triggered in $this->setUp(). + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the generator tag. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the description tag.'); + + // Save the translation string. + $this->saveTranslationString($lid, $config_name, 'fr', $string_en, $string_fr); + + // Load the English page again. + $this->drupalGet($path); + $this->assertResponse(200, 'Loaded the default test page again.'); + + // Confirm the page's description is what we set it to. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_en); + $this->assertNotEqual($xpath[0]['content'], $string_fr); + + // Load the French page. + $this->drupalGet('fr/' . $path); + $this->assertResponse(200, 'Loaded the French test page.'); + + // Confirm the generator string was translated. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_fr); + $this->assertNotEqual($xpath[0]['content'], $string_en); + } + + // @todo Test translations on an in-db page. +} diff --git a/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.test b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.test new file mode 100644 index 00000000..cd305ee9 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels.test @@ -0,0 +1,67 @@ + 'Metatag:Panels tests', + 'description' => 'Test Metatag integration via the Metatag:Panels module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'panels', 'page_manager'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'panels'; + + // Can't really do anything without Page Manager. + $modules[] = 'page_manager'; + + // Enable the hidden submodule to manage some default configs. + $modules[] = 'metatag_panels_tests'; + + parent::setUp($modules); + } + + /** + * Test the Panels integration. + */ + public function testExportedPage() { + $this->drupalGet('metatag-panels-test'); + $this->assertResponse(200); + + // Test the page title. + $this->assertTitle('Test page title'); + + // Test the description meta tag. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Test page description.'); + + // Test the keywords meta tag. + $xpath = $this->xpath("//meta[@name='keywords']"); + $this->assertEqual(count($xpath), 1, 'Exactly one keywords meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Test, page, keywords'); + + // Test the abstract meta tag. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'http://www.example.com/user/1/full-bio-(1).pdf'); + } + + // @todo Test an in-db page. +} diff --git a/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info new file mode 100644 index 00000000..08421805 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.info @@ -0,0 +1,17 @@ +name = Metatag:Panels Tests +description = Helper module for testing metatag_panels.module. +core = 7.x + +; Don't show this on the modules admin page. +hidden = TRUE + +dependencies[] = ctools:ctools +dependencies[] = ctools:page_manager +dependencies[] = metatag:metatag +dependencies[] = metatag:metatag_panels + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.module b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.module new file mode 100644 index 00000000..7bb77132 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.module @@ -0,0 +1,15 @@ + "1"); + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.pages_default.inc b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.pages_default.inc new file mode 100644 index 00000000..fbbb66c2 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_panels/tests/metatag_panels_tests.pages_default.inc @@ -0,0 +1,130 @@ +disabled = FALSE; /* Edit this to true to make a default page disabled initially */ + $page->api_version = 1; + $page->name = 'metatag_panels_test'; + $page->task = 'page'; + $page->admin_title = 'Metatag:Panels test'; + $page->admin_description = ''; + $page->path = 'metatag-panels-test'; + $page->access = array(); + $page->menu = array( + 'type' => 'none', + 'title' => '', + 'weight' => '0', + 'name' => 'navigation', + 'parent' => array( + 'type' => 'none', + 'title' => '', + 'weight' => 0, + 'name' => 'navigation', + ), + ); + $page->arguments = array(); + $page->conf = array( + 'admin_paths' => FALSE, + ); + $page->default_handlers = array(); + $handler = new stdClass(); + $handler->disabled = FALSE; /* Edit this to true to make a default handler disabled initially */ + $handler->api_version = 1; + $handler->name = 'page_metatag_panels_test__default'; + $handler->task = 'page'; + $handler->subtask = 'metatag_panels_test'; + $handler->handler = 'panel_context'; + $handler->weight = 0; + $handler->conf = array( + 'title' => 'Page', + 'no_blocks' => 0, + 'pipeline' => 'standard', + 'body_classes_to_remove' => '', + 'body_classes_to_add' => '', + 'css_id' => '', + 'css' => '', + 'contexts' => array( + 0 => array( + 'identifier' => 'User', + 'keyword' => 'user', + 'name' => 'user', + 'type' => 'select', + 'uid' => '1', + 'id' => 1, + ), + ), + 'relationships' => array(), + 'name' => '', + 'metatag_panels' => array( + 'enabled' => 1, + 'metatags' => array( + 'title' => array( + 'value' => 'Test page title', + ), + 'description' => array( + 'value' => 'Test page description.', + ), + 'keywords' => array( + 'value' => 'Test, page, keywords', + ), + 'abstract' => array( + 'value' => 'http://www.example.com/user/%user:uid/full-bio-%281%29.pdf', + ), + ), + ), + ); + $display = new panels_display(); + $display->layout = 'onecol'; + $display->layout_settings = array(); + $display->panel_settings = array( + 'style_settings' => array( + 'default' => NULL, + 'middle' => NULL, + ), + ); + $display->cache = array(); + $display->title = 'Testing'; + $display->uuid = '14a1dc5e-6abd-41d5-a361-56c1c5404f32'; + $display->content = array(); + $display->panels = array(); + $pane = new stdClass(); + $pane->pid = 'new-8537d8cc-5b2d-4eac-b093-6b62f3fdc38a'; + $pane->panel = 'middle'; + $pane->type = 'custom'; + $pane->subtype = 'custom'; + $pane->shown = TRUE; + $pane->access = array(); + $pane->configuration = array( + 'admin_title' => 'Hello', + 'title' => 'Hello there', + 'body' => 'Hi.', + 'format' => 'filtered_html', + 'substitute' => TRUE, + ); + $pane->cache = array(); + $pane->style = array( + 'settings' => NULL, + ); + $pane->css = array(); + $pane->extras = array(); + $pane->position = 0; + $pane->locks = array(); + $pane->uuid = '8537d8cc-5b2d-4eac-b093-6b62f3fdc38a'; + $display->content['new-8537d8cc-5b2d-4eac-b093-6b62f3fdc38a'] = $pane; + $display->panels['middle'][0] = 'new-8537d8cc-5b2d-4eac-b093-6b62f3fdc38a'; + $display->hide_title = PANELS_TITLE_FIXED; + $display->title_pane = 'new-8537d8cc-5b2d-4eac-b093-6b62f3fdc38a'; + $handler->conf['display'] = $display; + $page->default_handlers[$handler->name] = $handler; + $pages['metatag_panels_test'] = $page; + + return $pages; +} diff --git a/sites/all/modules/contrib/metatag/metatag_twitter_cards/README.txt b/sites/all/modules/contrib/metatag/metatag_twitter_cards/README.txt index c4d1e40e..a1a9e7d4 100644 --- a/sites/all/modules/contrib/metatag/metatag_twitter_cards/README.txt +++ b/sites/all/modules/contrib/metatag/metatag_twitter_cards/README.txt @@ -9,9 +9,11 @@ tags are provided: * twitter:url * twitter:title * twitter:description -* twitter:image:src +* twitter:dnt +* twitter:image * twitter:image:width * twitter:image:height +* twitter:image:alt * twitter:player * twitter:player:width * twitter:player:height @@ -39,6 +41,6 @@ References ------------------------------------------------------------------------------ 1: https://dev.twitter.com/docs/cards 2: https://dev.twitter.com/docs/cards/preview -3: http://drupal.org/user/960720 +3: https://www.drupal.org/u/marty2081 4: http://www.gemeentemuseum.nl/ -5: http://drupal.org/node/1664322 +5: https://www.drupal.org/node/1664322 diff --git a/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info b/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info index 59362f5a..f0215520 100644 --- a/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info +++ b/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.info @@ -2,10 +2,14 @@ name = Metatag: Twitter Cards description = "Provides support for Twitter's Card 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" +dependencies[] = metatag:metatag + +; Tests. +files[] = tests/metatag_twitter_cards.test +files[] = tests/metatag_twitter_cards.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.install b/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.install new file mode 100644 index 00000000..cf306b8d --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.install @@ -0,0 +1,59 @@ + 7100, + ); + return $dependencies; +} + +/** + * Implements hook_uninstall(). + */ +function metatag_twitter_cards_uninstall() { + // Remove all of the maxlength variables. + variable_del('metatag_maxlength_twitter:title'); + variable_del('metatag_maxlength_twitter:description'); +} + +/** + * Implementations of hook_update_N(). + */ + +/** + * Rename the 'twitter:image:src' meta tag back to 'twitter:image'. Sorry. + */ +function metatag_twitter_cards_update_7100(&$sandbox) { + module_load_include('install', 'metatag'); + $old_tag = 'twitter:image:src'; + $new_tag = 'twitter:image'; + return metatag_update_replace_entity_tag($sandbox, $old_tag, $new_tag); +} + +/** + * Rename the 'twitter:image:src' meta tag back to 'twitter:image', part 2. + */ +function metatag_twitter_cards_update_7101() { + module_load_include('install', 'metatag'); + $old_tag = 'twitter:image:src'; + $new_tag = 'twitter:image'; + return metatag_update_replace_config_tag($old_tag, $new_tag); +} + +/** + * Clear the Metatag cache. + */ +function metatag_twitter_cards_update_7102() { + cache_clear_all('*', 'cache_metatag', TRUE); + return t('All Metatag caches cleared.'); +} diff --git a/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.metatag.inc b/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.metatag.inc index 24cdfb27..a6165236 100644 --- a/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.metatag.inc +++ b/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.metatag.inc @@ -1,7 +1,8 @@ config += array( - 'twitter:image:src' => array('value' => '[user:picture:url]'), + 'twitter:image' => array('value' => '[user:picture:url]'), ); } break; @@ -69,7 +70,7 @@ function metatag_twitter_cards_metatag_bundled_config_alter(array &$configs) { function metatag_twitter_cards_metatag_info() { $info['groups']['twitter-cards'] = array( 'label' => t('Twitter card'), - 'description' => t('A set of meta tags specially for controlling the summaries displayed when content is shared on Twitter.', array('!url' => 'http://twitter.com/')), + 'description' => t('A set of meta tags specially for controlling the summaries displayed when content is shared on Twitter.', array('!url' => 'https://twitter.com/')), 'form' => array( '#weight' => 60, ), @@ -150,19 +151,27 @@ function metatag_twitter_cards_metatag_info() { $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".'), + 'maxlength' => 70, '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.'), + 'maxlength' => 200, + 'weight' => ++$weight, + ) + $defaults; + $info['tags']['twitter:dnt'] = array( + 'label' => t('Do Not Track'), + 'description' => t('By default Twitter tracks visitors when a tweet is embedded on a page using the official APIs. Setting this to "on" will stop Twitter from tracking visitors.', array('@url' => 'https://dev.twitter.com/web/overview/privacy#what-privacy-options-do-website-publishers-have')), 'weight' => ++$weight, ) + $defaults; - $info['tags']['twitter:image:src'] = array( + $info['tags']['twitter: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. 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 Photo then the image must be at least 280x150px.'), + 'image' => TRUE, 'weight' => ++$weight, 'replaces' => array( - 'twitter:image', + 'twitter:image:src', ), 'devel_generate' => array( 'type' => 'image', @@ -174,7 +183,7 @@ function metatag_twitter_cards_metatag_info() { 'weight' => ++$weight, 'dependencies' => array( array( - 'dependency' => 'twitter:image:src', + 'dependency' => 'twitter:image', 'attribute' => 'value', 'condition' => 'filled', 'value' => TRUE, @@ -190,7 +199,7 @@ function metatag_twitter_cards_metatag_info() { 'weight' => ++$weight, 'dependencies' => array( array( - 'dependency' => 'twitter:image:src', + 'dependency' => 'twitter:image', 'attribute' => 'value', 'condition' => 'filled', 'value' => TRUE, @@ -200,9 +209,23 @@ function metatag_twitter_cards_metatag_info() { 'type' => 'integer', ), ) + $defaults; + $info['tags']['twitter:image:alt'] = array( + 'label' => 'Image alternative text', + 'description' => 'The alternative text of the image being linked to. Limited to 420 characters.', + 'weight' => ++$weight, + 'dependencies' => array( + array( + 'dependency' => 'twitter:image', + 'attribute' => 'value', + 'condition' => 'filled', + 'value' => TRUE, + ), + ), + ) + $defaults; // 'gallery' cards. $gallery_defaults = array( + 'image' => TRUE, 'dependencies' => array( array( 'dependency' => 'twitter:card', @@ -286,96 +309,86 @@ function metatag_twitter_cards_metatag_info() { ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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."), + 'description' => t("Your app ID in the Google Play Store (i.e. \"com.android.app\")."), 'weight' => ++$weight, 'element' => array( - '#theme' => 'metatag_twitter_cards' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $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' + '#theme' => 'metatag_twitter_cards', ), - ) + $app_defaults; + ) + $defaults; // 'product' cards. $product_defaults = array( @@ -393,7 +406,7 @@ function metatag_twitter_cards_metatag_info() { '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' + '#theme' => 'metatag_twitter_cards', ), ) + $product_defaults; $info['tags']['twitter:data1'] = array( @@ -401,7 +414,7 @@ function metatag_twitter_cards_metatag_info() { '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' + '#theme' => 'metatag_twitter_cards', ), ) + $product_defaults; $info['tags']['twitter:label2'] = array( @@ -409,7 +422,7 @@ function metatag_twitter_cards_metatag_info() { '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' + '#theme' => 'metatag_twitter_cards', ), ) + $product_defaults; $info['tags']['twitter:data2'] = array( @@ -417,7 +430,7 @@ function metatag_twitter_cards_metatag_info() { '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' + '#theme' => 'metatag_twitter_cards', ), ) + $product_defaults; diff --git a/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.module b/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.module index e848fac7..f7a87d63 100644 --- a/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.module +++ b/sites/all/modules/contrib/metatag/metatag_twitter_cards/metatag_twitter_cards.module @@ -1,4 +1,5 @@ 'name', '#value' => 'content')); + $args = array( + '#name' => 'name', + '#value' => 'content', + ); + element_set_attributes($element, $args); unset($element['#value']); return theme('html_tag', $variables); } diff --git a/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.tags.test b/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.tags.test new file mode 100644 index 00000000..46c1c64b --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.tags.test @@ -0,0 +1,143 @@ + 'Metatag tags: Twitter Cards', + 'description' => 'Test the Twitter Cards meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'twitter:app:country', + 'twitter:app:id:googleplay', + 'twitter:app:id:ipad', + 'twitter:app:id:iphone', + 'twitter:app:name:googleplay', + 'twitter:app:name:ipad', + 'twitter:app:name:iphone', + 'twitter:app:url:googleplay', + 'twitter:app:url:ipad', + 'twitter:app:url:iphone', + 'twitter:card', + 'twitter:creator', + 'twitter:creator:id', + 'twitter:data1', + 'twitter:data2', + 'twitter:description', + 'twitter:dnt', + 'twitter:image', + 'twitter:image0', + 'twitter:image1', + 'twitter:image2', + 'twitter:image3', + 'twitter:image:alt', + 'twitter:image:height', + 'twitter:image:width', + 'twitter:label1', + 'twitter:label2', + 'twitter:player', + 'twitter:player:height', + 'twitter:player:stream', + 'twitter:player:stream:content_type', + 'twitter:player:width', + 'twitter:site', + 'twitter:site:id', + 'twitter:title', + 'twitter:url', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_twitter_cards'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + // All OG tags use colons to separate levels. + $tag_name = str_replace('_', ':', $tag_name); + + // Fix a few specific tags. + $tag_name = str_replace('content:type', 'content_type', $tag_name); + + return $tag_name; + } + + /** + * Implements {meta_tag_name}_test_key() for 'twitter:card'. + */ + public function twitter_card_test_key() { + return 'metatags[und][twitter:card][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:card'. + */ + public function twitter_card_test_value() { + return 'summary'; + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'twitter:card'. + */ + public function twitter_card_test_field_xpath() { + return "//select[@name='metatags[und][twitter:card][value]']"; + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image'. + */ + public function twitter_image_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image0'. + */ + public function twitter_image0_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image1'. + */ + public function twitter_image1_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image2'. + */ + public function twitter_image2_test_value() { + return $this->randomImageUrl(); + } + + /** + * Implements {meta_tag_name}_test_value() for 'twitter:image3'. + */ + public function twitter_image3_test_value() { + return $this->randomImageUrl(); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.test b/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.test new file mode 100644 index 00000000..7aeaf226 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_twitter_cards/tests/metatag_twitter_cards.test @@ -0,0 +1,48 @@ + 'Metatag Twitter Cards tests', + 'description' => 'Test the Metatag:Twitter Cards module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_twitter_cards'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_verification/README.txt b/sites/all/modules/contrib/metatag/metatag_verification/README.txt new file mode 100644 index 00000000..f1cd7987 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_verification/README.txt @@ -0,0 +1,16 @@ +Metatag: Verification +--------------------- +This module adds meta tags used to confirm ownership of the site with various +search engines and online services. + + +Usage +------------------------------------------------------------------------------ +These tags are only available on the Global configuration section of the main +settings interface at admin/config/search/metatag as they affect the site as a +whole rather than portions of it. + + +Credits +------------------------------------------------------------------------------ +Development and maintenance by Damien McKenna. diff --git a/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info b/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info new file mode 100644 index 00000000..9f8a4480 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.info @@ -0,0 +1,15 @@ +name = Metatag: Verification +description = "Various meta tags for verifying ownership of a site." +package = SEO +core = 7.x +dependencies[] = metatag:metatag + +; Tests. +files[] = tests/metatag_verification.test +files[] = tests/metatag_verification.tags.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.install b/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.install new file mode 100644 index 00000000..22a80898 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.install @@ -0,0 +1,26 @@ + t('Site verification'), + 'description' => t('These meta tags are used to confirm site ownership with search engines and other services.'), + 'form' => array( + '#weight' => 110, + ), + ); + + // Stack the verification codes after most others. + $weight = 100; + + // Defaults used for all meta tags. + $defaults = array( + 'class' => 'DrupalTextMetaTag', + 'context' => array('global'), + 'group' => 'verification', + ); + + $info['tags']['msvalidate.01'] = array( + 'label' => t('Bing'), + 'description' => t('A string provided by Bing, full details are available from the Bing online help.', array('@bing' => 'http://www.bing.com/', '@verify_url' => 'http://www.bing.com/webmaster/help/how-to-verify-ownership-of-your-site-afcfefc6')), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['baidu-site-verification'] = array( + 'label' => t('Baidu'), + 'description' => t('A string provided by Baidu.', array('@baidu' => 'http://www.baidu.com/')), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['google-site-verification'] = array( + 'label' => t('Google'), + 'description' => t('A string provided by Google, full details are available from the Google online help.', array('@google' => 'https://www.google.com/', '@verify_url' => 'https://support.google.com/webmasters/answer/35179?hl=en')), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['norton-safeweb-site-verification'] = array( + 'label' => t('Norton Safe Web'), + 'description' => t('A string provided by Norton Safe Web, full details are available from the Norton Safe Web online help.', array('@norton' => 'https://safeweb.norton.com/', '@verify_url' => 'https://safeweb.norton.com/help/site_owners')), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['p:domain_verify'] = array( + 'label' => t('Pinterest'), + 'description' => t('A string provided by Pinterest, full details are available from the Pinterest online help.', array('@pinterest' => 'https://www.pinterest.com/', '@verify_url' => 'https://help.pinterest.com/en/articles/verify-your-website')), + 'weight' => ++$weight, + ) + $defaults; + + $info['tags']['yandex-verification'] = array( + 'label' => t('Yandex'), + 'description' => t('A string provided by Yandex, full details are available from the Yandex online help.', array('@yandex' => 'http://www.yandex.com/', '@verify_url' => 'http://api.yandex.com/webmaster/doc/dg/reference/hosts-type.xml')), + 'weight' => ++$weight, + ) + $defaults; + + return $info; +} diff --git a/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.module b/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.module new file mode 100644 index 00000000..74dc523f --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_verification/metatag_verification.module @@ -0,0 +1,15 @@ + 1); + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.tags.test b/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.tags.test new file mode 100644 index 00000000..655aad68 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.tags.test @@ -0,0 +1,54 @@ + 'Metatag tags: Verification', + 'description' => 'Test the Verification meta tags.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'baidu-site-verification', + 'google-site-verification', + 'msvalidate.01', + 'norton-safeweb-site-verification', + 'p:domain_verify', + 'yandex-verification', + ); + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_verification'; + parent::setUp($modules); + } + + /** + * {@inheritdoc} + */ + public function getTestTagName($tag_name) { + $tag_name = str_replace('_', '-', $tag_name); + $tag_name = str_replace('msvalidate-01', 'msvalidate.01', $tag_name); + $tag_name = str_replace('p-domain-verify', 'p:domain_verify', $tag_name); + return $tag_name; + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.test b/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.test new file mode 100644 index 00000000..b97a1eb6 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_verification/tests/metatag_verification.test @@ -0,0 +1,48 @@ + 'Metatag Verification tests', + 'description' => 'Test the Metatag:Verification module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'metatag_verification'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + } + + /** + * Confirm that it's possible to load the main admin page. + */ + public function testAdminPage() { + $this->drupalGet('admin/config/search/metatags'); + $this->assertResponse(200); + + // Confirm the page is correct. + $this->assertText(t('To view a summary of the default meta tags and the inheritance, click on a meta tag type.')); + } + +} diff --git a/sites/all/modules/contrib/metatag/metatag_views/README.txt b/sites/all/modules/contrib/metatag/metatag_views/README.txt index 56c95d87..4398edc3 100644 --- a/sites/all/modules/contrib/metatag/metatag_views/README.txt +++ b/sites/all/modules/contrib/metatag/metatag_views/README.txt @@ -13,4 +13,4 @@ Originally developed by Dave Reid [1]. References -------------------------------------------------------------------------------- -1: http://drupal.org/user/53892 +1: https://www.drupal.org/u/dave-reid diff --git a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.i18n.inc b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.i18n.inc new file mode 100644 index 00000000..70c0e44d --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.i18n.inc @@ -0,0 +1,101 @@ + t('Metatag:Views configurations'), + // Callback to load all config objects. + 'list callback' => 'metatag_views_i18n_list_displays', + // The object load callback. + // 'load callback' => 'metatag_views_i18n_load', + // Custom i18n object overrides. Right now this avoids problems with the + // object ID as defined by get_string_context(). + 'class' => 'metatag_views_i18n_metatag', + // @todo Is this needed? What does it do? + // 'translation set' => TRUE, + // The object key field; multiple values will be concatenated with ":" as + // the separator. + 'key' => array('vid', 'id'), + // Placeholders for automatic paths. This connects the 'key' to strings in + // the paths listed below. + // 'placeholders' => array( + // '%did' => 'did', + // ), + // To produce edit links automatically. + // 'edit path' => 'admin/config/search/metatags/config/%instance', + // Auto-generate a 'translate' tab. + // 'translate tab' => 'admin/config/search/metatags/config/%instance/translate', + // Properties for string translation. + 'string translation' => array( + // The textgroup, type and (below) name will be concatenated into a single + // string as the {locales_source} context. + 'textgroup' => 'metatag', + 'type' => 'metatag_views', + // Table where the object is stored, to automate string lists. + // 'table' => 'views_display', + // Translatable properties of these objects, this will be added later. + 'properties' => array(), + // The path to translate individual strings. + // 'translate path' => 'admin/config/search/metatags/config/%instance/translate/%i18n_language', + ), + ); + + // Compile all of the tags to add to the translation stack. + $meta_tag_info = metatag_get_info(); + $groups = $meta_tag_info['groups']; + foreach ($meta_tag_info['tags'] as $tag_info) { + // Ignore certain field types that aren't translatable, mostly fields that + // list predetermined options in various forms. + if (!empty($tag_info['class']) && $tag_info['class'] == 'DrupalListMetaTag') { + continue; + } + elseif (!empty($tag_info['form']['#type']) && $tag_info['form']['#type'] == 'select') { + continue; + } + elseif (!empty($tag_info['form']['#options'])) { + continue; + } + + // Build a suitable structure for this meta tag. + $tag_name = $tag_info['name']; + $title = $tag_info['label']; + if (!empty($tag_info['group'])) { + $tag_group = $tag_info['group']; + $group_label = !empty($groups[$tag_group]['label']) ? $groups[$tag_group]['label'] : $tag_group; + $title = $group_label . ': ' . $title; + } + + $info['metatag_views']['string translation']['properties'][$tag_name] = array( + 'title' => $title, + 'field' => "display_options.metatags.und.{$tag_name}.value", + ); + } + + return $info; +} + +/** + * List callback. + */ +function metatag_views_i18n_list_displays() { + $displays = array(); + + foreach (views_get_all_views() as $view_id => $view) { + foreach ($view->display as $display) { + if (!empty($display->display_options['metatags'][LANGUAGE_NONE])) { + // Need to rig i18n_string's ability to find the record. + $display->view_id = $view_id; + $displays[$display->view_id . METATAG_VIEWS_CONTEXT_SEPARATOR . $display->id] = $display; + } + } + } + + return $displays; +} diff --git a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.inc b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.inc new file mode 100644 index 00000000..dcb399e3 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.inc @@ -0,0 +1,26 @@ +object->view_id . METATAG_VIEWS_CONTEXT_SEPARATOR . $this->object->id); + } + + } +} diff --git a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info index 742ba87c..a5b282a7 100644 --- a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info +++ b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.info @@ -3,14 +3,18 @@ description = Provides Metatag integration within the Views interface. package = SEO core = 7.x -dependencies[] = metatag -dependencies[] = views +dependencies[] = metatag:metatag +dependencies[] = views:views +files[] = metatag_views.inc files[] = metatag_views_plugin_display_extender_metatags.inc -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +; Tests. +files[] = tests/metatag_views.test +files[] = tests/metatag_views.i18n.test + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.install b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.install new file mode 100644 index 00000000..77733c10 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.install @@ -0,0 +1,15 @@ +api_version = 1; $config->disabled = FALSE; $config->config = array( - 'title' => array('value' => '[view:title] | [site:name]'), + 'title' => array('value' => '[view:title] | [current-page:pager][site:name]'), 'description' => array('value' => '[view:description]'), 'canonical' => array('value' => '[view:url]'), ); diff --git a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.module b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.module index bb595836..6fa1a9c2 100644 --- a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.module +++ b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.module @@ -5,6 +5,10 @@ * Provides native meta tag integration with Views. */ +// This is used to join the view name and the display name when building the +// context string. +define('METATAG_VIEWS_CONTEXT_SEPARATOR', '__'); + /** * Implements hook_views_api(). */ @@ -46,8 +50,13 @@ function metatag_views_views_preview_info_alter(&$rows, $view) { $instance = 'view:' . $view->name; $options['token data']['view'] = $view; $values = metatag_metatags_values($instance, $metatags, $options); + $use_views_tokens = $view->display_handler->get_option('metatags_tokenize'); foreach ($values as $metatag => $value) { $metatag_info = metatag_get_info('tags', $metatag); + // If enabled, use replacement tokens from the first Views result row. + if ($value && $use_views_tokens) { + $value = $view->style_plugin->tokenize_value($value, 0); + } $values[$metatag] = check_plain($metatag_info['label']) . ': ' . check_plain($value); } if (!empty($values)) { @@ -65,10 +74,18 @@ function metatag_views_views_preview_info_alter(&$rows, $view) { * Implements hook_page_alter(). */ function metatag_views_page_alter(&$page) { + // By default do not add meta tags to admin pages. To enable meta tags on + // admin pages set the 'metatag_tag_admin_pages' variable to TRUE. + if (path_is_admin(current_path()) && !variable_get('metatag_tag_admin_pages', FALSE)) { + return; + } + $view = views_get_page_view(); // Check if Views metatags are enabled. if (!empty($view) && metatag_config_is_enabled('view')) { + global $language; + // 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')) { @@ -80,24 +97,76 @@ function metatag_views_page_alter(&$page) { return; } + // Include only view name by default. + $instance = 'view:' . $view->name; + + // Include display name if option is overridden. + if (!$view->display_handler->is_defaulted('metatags')) { + $instance = 'view:' . $view->name . ':' . $view->current_display; + } + // 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); - } + // Only proceed if there's something to work with. + if (!empty($metatags) && is_array($metatags)) { + // 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 (!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; + // Translate all of the meta tags using i18n, but don't update the + // strings. + metatag_translate_metatags($metatags[LANGUAGE_NONE], 'metatag_views:' . $view->name . METATAG_VIEWS_CONTEXT_SEPARATOR . $view->current_display, NULL, FALSE); + + // If enabled, use replacement tokens from the first Views result row. + if ($view->display_handler->get_option('metatags_tokenize')) { + // If the Views output was loaded from the Views output cache, the + // fields won't have been rendered and thus the first row tokens would + // be empty. Therefore, in this case, we manually trigger rendering of + // the first row. + _metatag_views_render_first_row($view); + + foreach ($metatags as $langcode => $values) { + foreach ($values as $metatag => $config) { + if (!empty($config['value']) && is_scalar($config['value'])) { + $metatags[$langcode][$metatag]['value'] = $view->style_plugin->tokenize_value($config['value'], 0); + } + } + } + } + + // Build options for meta tag rendering. + $options = array(); + $options['token data']['view'] = $view; + $options['language'] = $language->language; + + // The page region can be changed. + $region = variable_get('metatag_page_region', 'content'); + + // Add the metatags. + $page[$region]['metatags'][$instance] = metatag_metatags_view($instance, $metatags, $options); + } + } +} - // Add the metatags. - $page['content']['metatags'][$instance] = metatag_metatags_view($instance, $metatags, $options); +/** + * Triggers rendering of the first row of the Views result set. + * + * This is used as a helper function in metatag_views_page_alter() to have the + * necessary field tokens available. + * + * @param view $view + * The view for which result fields should be rendered. + */ +function _metatag_views_render_first_row(view $view) { + $result = $view->result; + if (!$result) { + return; } + // We only need the first row of the results. + $result = array_intersect_key($result, array(0 => TRUE)); + $view->style_plugin->render_fields($result); } diff --git a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.tokens.inc b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.tokens.inc index 2db1deb6..0ebc7d12 100644 --- a/sites/all/modules/contrib/metatag/metatag_views/metatag_views.tokens.inc +++ b/sites/all/modules/contrib/metatag/metatag_views/metatag_views.tokens.inc @@ -1,4 +1,5 @@ ''); + $options['metatags_tokenize'] = array('bool' => TRUE, 'default' => FALSE); return $options; } + + /** + * {@inheritdoc} + */ function options_definition_alter(&$options) { $options['metatags'] = array('default' => array()); + $options['metatags_tokenize'] = array('bool' => TRUE, 'default' => FALSE); } /** - * Defines where within the Views admin UI the new settings will be visible. + * {@inheritdoc} */ function options_summary(&$categories, &$options) { + // Defines where within the Views admin UI the new settings will be visible. $categories['metatags'] = array( 'title' => t('Meta tags'), 'column' => 'second', @@ -34,9 +45,10 @@ class metatag_views_plugin_display_extender_metatags extends views_plugin_displa } /** - * Defines the form. + * {@inheritdoc} */ function options_form(&$form, &$form_state) { + // Defines the form. if ($form_state['section'] == 'metatags') { $form['#title'] .= t('The meta tags for this display'); $metatags = $this->get_metatags(); @@ -48,13 +60,72 @@ class metatag_views_plugin_display_extender_metatags extends views_plugin_displa metatag_metatags_form($form, $instance, $metatags[LANGUAGE_NONE], $options); $form['metatags']['#type'] = 'container'; + + // Code for replacement tokens from first row taken from + // views_handler_area_text::options_form(). + $form['tokenize'] = array( + '#type' => 'checkbox', + '#title' => t('Use replacement tokens from the first row'), + '#default_value' => $this->display->get_option('metatags_tokenize'), + '#weight' => 50, + ); + + // Get a list of the available fields and arguments for token replacement. + $options = array(); + foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) { + $options[t('Fields')]["[$field]"] = $handler->ui_name(); + } + + $count = 0; + // This lets us prepare the key as we want it printed. + foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) { + $options[t('Arguments')]['%' . ++$count] = t('@argument title', array('@argument' => $handler->ui_name())); + $options[t('Arguments')]['!' . $count] = t('@argument input', array('@argument' => $handler->ui_name())); + } + + if (!empty($options)) { + $output = '

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

'); + foreach (array_keys($options) as $type) { + if (!empty($options[$type])) { + $items = array(); + foreach ($options[$type] as $key => $value) { + $items[] = $key . ' == ' . check_plain($value); + } + $output .= theme('item_list', + array( + 'items' => $items, + 'type' => $type, + )); + } + } + + $form['token_help'] = array( + '#type' => 'fieldset', + '#title' => t('Replacement patterns'), + '#collapsible' => TRUE, + '#collapsed' => TRUE, + '#value' => $output, + '#id' => 'edit-options-token-help', + '#dependency' => array( + 'edit-options-tokenize' => array(1), + ), + '#prefix' => '
', + '#suffix' => '
', + '#weight' => 51, + ); + } + // Basic tags fieldset should not collapse to display in a larger popup. + // @see https://www.drupal.org/node/1294478 + // @see https://www.drupal.org/node/2624020 + $form['metatags'][LANGUAGE_NONE]['basic']['#collapsible'] = FALSE; } } /** - * Saves the form values. + * {@inheritdoc} */ function options_submit(&$form, &$form_state) { + // Save the form values. if ($form_state['section'] == 'metatags') { $metatags = $form_state['values']['metatags']; @@ -66,11 +137,20 @@ class metatag_views_plugin_display_extender_metatags extends views_plugin_displa } $this->display->set_option('metatags', $metatags); + $this->display->set_option('metatags_tokenize', $form_state['values']['tokenize']); + + // Update the i18n strings. + if (!empty($metatags[LANGUAGE_NONE]) && $this->definition['enabled'] && module_exists('i18n_string') && !variable_get('metatag_i18n_disabled', FALSE)) { + metatag_translations_update($metatags[LANGUAGE_NONE], 'metatag_views:' . $this->view->name . '_' . $this->display->plugin_name); + } } } /** * Identify whether or not the current display has custom meta tags defined. + * + * @return bool + * Indicates whether the current display has custom meta tags defined. */ protected function has_metatags() { $metatags = $this->get_metatags(); @@ -96,4 +176,5 @@ class metatag_views_plugin_display_extender_metatags extends views_plugin_displa return $metatags; } + } diff --git a/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.i18n.test b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.i18n.test new file mode 100644 index 00000000..7c7f8f48 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.i18n.test @@ -0,0 +1,106 @@ + 'Metatag:Views i18n tests', + 'description' => 'Test Metatag integration via the Metatag:Views module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'views'; + $modules[] = 'metatag_views'; + + // Needed for translations. + $modules[] = 'locale'; + $modules[] = 'i18n'; + $modules[] = 'i18n_string'; + + // Enable the hidden submodule to manage some default configs. + $modules[] = 'metatag_views_tests'; + + parent::setUp($modules); + + // Add more locales. + $this->setupLocales(); + + // Set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + // From i18n. + 'translate admin strings', + 'translate user-defined strings', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Reload the translations. + drupal_flush_all_caches(); + module_load_include('admin.inc', 'i18n_string'); + i18n_string_refresh_group('metatag'); + } + + /** + * Test the Metatag:Views translations. + */ + public function testExportedPage() { + // Plan out the different translation string tests. + $string_en = 'Testing Metatag:Views.'; + $string_fr = 'French page description.'; + $config_name = 'metatag_views:metatag_views_test' . METATAG_VIEWS_CONTEXT_SEPARATOR . 'page:description'; + $path = 'metatag-views-test'; + + // Confirm the string is present as it has been grabbed by the string- + // refresh triggered in $this->setUp(). + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the generator tag. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the description tag.'); + + // Save the translation string. + $this->saveTranslationString($lid, $config_name, 'fr', $string_en, $string_fr); + + // Load the English page again. + $this->drupalGet($path); + $this->assertResponse(200, 'Loaded the default test page again.'); + + // Confirm the page's description is what we set it to. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_en); + $this->assertNotEqual($xpath[0]['content'], $string_fr); + + // Load the French page. + $this->drupalGet('fr/' . $path); + $this->assertResponse(200, 'Loaded the French test page.'); + + // Confirm the generator string was translated. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_fr); + $this->assertNotEqual($xpath[0]['content'], $string_en); + } + + // @todo Test translations on an in-db display. +} diff --git a/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.test b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.test new file mode 100644 index 00000000..82695125 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views.test @@ -0,0 +1,60 @@ + 'Metatag:Views tests', + 'description' => 'Test Metatag integration via the Metatag:Views module.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'views'; + + // Enable the hidden submodule to manage some default configs. + $modules[] = 'metatag_views_tests'; + + parent::setUp($modules); + } + + /** + * Test the Metatag:Views translations on an exported page. + */ + public function testExportedPage() { + $this->drupalGet('metatag-views-test'); + $this->assertResponse(200); + + // Test the page title. + $this->assertTitle('Test Views page title'); + + // Test the description meta tag. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Testing Metatag:Views.'); + + // Test the keywords meta tag. + $xpath = $this->xpath("//meta[@name='keywords']"); + $this->assertEqual(count($xpath), 1, 'Exactly one keywords meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Test, page, keywords'); + } + + // @todo Test an in-db display. + // @todo Test the master display. + // @todo Test separate displays. +} diff --git a/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info new file mode 100644 index 00000000..e1c11ba6 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.info @@ -0,0 +1,16 @@ +name = Metatag:Views Tests +description = Helper module for testing metatag_views.module. +core = 7.x + +; Don't show this on the modules admin page. +hidden = TRUE + +dependencies[] = metatag:metatag +dependencies[] = metatag:metatag_views +dependencies[] = views:views + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.module b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.module new file mode 100644 index 00000000..80d54287 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.module @@ -0,0 +1,13 @@ + '3.0'); +} diff --git a/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.views_default.inc b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.views_default.inc new file mode 100644 index 00000000..96bb5222 --- /dev/null +++ b/sites/all/modules/contrib/metatag/metatag_views/tests/metatag_views_tests.views_default.inc @@ -0,0 +1,453 @@ +name = 'metatag_views_test'; + $view->description = ''; + $view->tag = 'default'; + $view->base_table = 'node'; + $view->human_name = 'Metatag Views test'; + $view->core = 7; + $view->api_version = '3.0'; + $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */ + + /* Display: Master */ + $handler = $view->new_display('default', 'Master', 'default'); + $handler->display->display_options['title'] = 'Metatag Views test'; + $handler->display->display_options['use_more_always'] = FALSE; + $handler->display->display_options['access']['type'] = 'perm'; + $handler->display->display_options['cache']['type'] = 'none'; + $handler->display->display_options['query']['type'] = 'views_query'; + $handler->display->display_options['exposed_form']['type'] = 'basic'; + $handler->display->display_options['pager']['type'] = 'full'; + $handler->display->display_options['pager']['options']['items_per_page'] = '5'; + $handler->display->display_options['style_plugin'] = 'default'; + $handler->display->display_options['row_plugin'] = 'node'; + $handler->display->display_options['row_options']['links'] = FALSE; + /* Field: Content: Title */ + $handler->display->display_options['fields']['title']['id'] = 'title'; + $handler->display->display_options['fields']['title']['table'] = 'node'; + $handler->display->display_options['fields']['title']['field'] = 'title'; + $handler->display->display_options['fields']['title']['label'] = ''; + $handler->display->display_options['fields']['title']['alter']['word_boundary'] = FALSE; + $handler->display->display_options['fields']['title']['alter']['ellipsis'] = FALSE; + /* Sort criterion: Content: Post date */ + $handler->display->display_options['sorts']['created']['id'] = 'created'; + $handler->display->display_options['sorts']['created']['table'] = 'node'; + $handler->display->display_options['sorts']['created']['field'] = 'created'; + $handler->display->display_options['sorts']['created']['order'] = 'DESC'; + /* Filter criterion: Content: Published */ + $handler->display->display_options['filters']['status']['id'] = 'status'; + $handler->display->display_options['filters']['status']['table'] = 'node'; + $handler->display->display_options['filters']['status']['field'] = 'status'; + $handler->display->display_options['filters']['status']['value'] = 1; + $handler->display->display_options['filters']['status']['group'] = 1; + $handler->display->display_options['filters']['status']['expose']['operator'] = FALSE; + + /* Display: Page */ + $handler = $view->new_display('page', 'Page', 'page'); + $handler->display->display_options['metatags'] = array( + 'und' => array( + 'title' => array( + 'value' => 'Test Views page title', + 'default' => '[view:title] | [current-page:pager][site:name]', + ), + 'description' => array( + 'value' => 'Testing Metatag:Views.', + 'default' => '[view:description]', + ), + 'abstract' => array( + 'value' => '', + ), + 'keywords' => array( + 'value' => 'Test, page, keywords', + ), + 'robots' => array( + 'value' => array( + 'index' => 0, + 'follow' => 0, + 'noindex' => 0, + 'nofollow' => 0, + 'noarchive' => 0, + 'nosnippet' => 0, + 'noodp' => 0, + 'noydir' => 0, + 'noimageindex' => 0, + 'notranslate' => 0, + ), + ), + 'news_keywords' => array( + 'value' => '', + ), + 'standout' => array( + 'value' => '', + ), + 'rating' => array( + 'value' => '', + ), + 'referrer' => array( + 'value' => '', + ), + 'rights' => array( + 'value' => '', + ), + 'image_src' => array( + 'value' => '', + ), + 'canonical' => array( + 'value' => '[view:url]', + 'default' => '[view:url]', + ), + 'shortlink' => array( + 'value' => '[current-page:url:unaliased]', + 'default' => '[current-page:url:unaliased]', + ), + 'publisher' => array( + 'value' => '', + ), + 'author' => array( + 'value' => '', + ), + 'original-source' => array( + 'value' => '', + ), + 'prev' => array( + 'value' => '', + ), + 'next' => array( + 'value' => '', + ), + 'revisit-after' => array( + 'value' => '', + 'period' => '', + ), + 'content-language' => array( + 'value' => '', + ), + 'geo.position' => array( + 'value' => '', + ), + 'geo.placename' => array( + 'value' => '', + ), + 'geo.region' => array( + 'value' => '', + ), + 'icbm' => array( + 'value' => '', + ), + 'refresh' => array( + 'value' => '', + ), + 'itemtype' => array( + 'value' => '', + ), + 'itemprop:name' => array( + 'value' => '[current-page:title]', + 'default' => '[current-page:title]', + ), + 'itemprop:description' => array( + 'value' => '', + ), + 'itemprop:image' => array( + 'value' => '', + ), + 'theme-color' => array( + 'value' => '', + ), + 'MobileOptimized' => array( + 'value' => '', + ), + 'HandheldFriendly' => array( + 'value' => '', + ), + 'viewport' => array( + 'value' => '', + ), + 'cleartype' => array( + 'value' => '', + ), + 'apple-itunes-app' => array( + 'value' => '', + ), + 'apple-mobile-web-app-capable' => array( + 'value' => '', + ), + 'apple-mobile-web-app-status-bar-style' => array( + 'value' => '', + ), + 'format-detection' => array( + 'value' => '', + ), + 'ios-app-link-alternative' => array( + 'value' => '', + ), + 'android-app-link-alternative' => array( + 'value' => '', + ), + 'android-manifest' => array( + 'value' => '', + ), + 'x-ua-compatible' => array( + 'value' => '', + ), + 'application-name' => array( + 'value' => '', + ), + 'msapplication-allowDomainApiCalls' => array( + 'value' => '', + ), + 'msapplication-allowDomainMetaTags' => array( + 'value' => '', + ), + 'msapplication-badge' => array( + 'value' => '', + ), + 'msapplication-config' => array( + 'value' => '', + ), + 'msapplication-navbutton-color' => array( + 'value' => '', + ), + 'msapplication-notification' => array( + 'value' => '', + ), + 'msapplication-square150x150logo' => array( + 'value' => '', + ), + 'msapplication-square310x310logo' => array( + 'value' => '', + ), + 'msapplication-square70x70logo' => array( + 'value' => '', + ), + 'msapplication-wide310x150logo' => array( + 'value' => '', + ), + 'msapplication-starturl' => array( + 'value' => '', + ), + 'msapplication-task' => array( + 'value' => '', + ), + 'msapplication-task-separator' => array( + 'value' => '', + ), + 'msapplication-tilecolor' => array( + 'value' => '', + ), + 'msapplication-tileimage' => array( + 'value' => '', + ), + 'msapplication-tooltip' => array( + 'value' => '', + ), + 'msapplication-window' => array( + 'value' => '', + ), + 'og:type' => array( + 'value' => 'article', + 'default' => 'article', + ), + 'og:url' => array( + 'value' => '[current-page:url:absolute]', + 'default' => '[current-page:url:absolute]', + ), + 'og:title' => array( + 'value' => '[current-page:title]', + 'default' => '[current-page:title]', + ), + 'og:determiner' => array( + 'value' => '', + ), + 'og:description' => array( + 'value' => '', + ), + 'og:updated_time' => array( + 'value' => '', + ), + 'og:see_also' => array( + 'value' => '', + ), + 'og:image' => array( + 'value' => '', + ), + 'og:image:url' => array( + 'value' => '', + ), + 'og:image:secure_url' => array( + 'value' => '', + ), + 'og:image:type' => array( + 'value' => '', + ), + 'og:image:width' => array( + 'value' => '', + ), + 'og:image:height' => array( + 'value' => '', + ), + 'og:latitude' => array( + 'value' => '', + ), + 'og:longitude' => array( + 'value' => '', + ), + 'og:street_address' => array( + 'value' => '', + ), + 'og:locality' => array( + 'value' => '', + ), + 'og:region' => array( + 'value' => '', + ), + 'og:postal_code' => array( + 'value' => '', + ), + 'og:country_name' => array( + 'value' => '', + ), + 'og:email' => array( + 'value' => '', + ), + 'og:phone_number' => array( + 'value' => '', + ), + 'og:fax_number' => array( + 'value' => '', + ), + 'og:locale' => array( + 'value' => '', + ), + 'og:locale:alternate' => array( + 'value' => '', + ), + 'article:author' => array( + 'value' => '', + ), + 'article:publisher' => array( + 'value' => '', + ), + 'article:section' => array( + 'value' => '', + ), + 'article:tag' => array( + 'value' => '', + ), + 'article:published_time' => array( + 'value' => '', + ), + 'article:modified_time' => array( + 'value' => '', + ), + 'article:expiration_time' => array( + 'value' => '', + ), + 'profile:first_name' => array( + 'value' => '', + ), + 'profile:last_name' => array( + 'value' => '', + ), + 'profile:username' => array( + 'value' => '', + ), + 'profile:gender' => array( + 'value' => '', + ), + 'og:audio' => array( + 'value' => '', + ), + 'og:audio:secure_url' => array( + 'value' => '', + ), + 'og:audio:type' => array( + 'value' => '', + ), + 'book:author' => array( + 'value' => '', + ), + 'book:isbn' => array( + 'value' => '', + ), + 'book:release_date' => array( + 'value' => '', + ), + 'book:tag' => array( + 'value' => '', + ), + 'og:video:url' => array( + 'value' => '', + ), + 'og:video:secure_url' => array( + 'value' => '', + ), + 'og:video:width' => array( + 'value' => '', + ), + 'og:video:height' => array( + 'value' => '', + ), + 'og:video:type' => array( + 'value' => '', + ), + 'video:actor' => array( + 'value' => '', + ), + 'video:actor:role' => array( + 'value' => '', + ), + 'video:director' => array( + 'value' => '', + ), + 'video:writer' => array( + 'value' => '', + ), + 'video:duration' => array( + 'value' => '', + ), + 'video:release_date' => array( + 'value' => '', + ), + 'video:tag' => array( + 'value' => '', + ), + 'video:series' => array( + 'value' => '', + ), + ), + ); + $handler->display->display_options['path'] = 'metatag-views-test'; + $translatables['metatag_views_test'] = array( + t('Master'), + t('Metatag Views i18n test'), + t('more'), + t('Apply'), + t('Reset'), + t('Sort by'), + t('Asc'), + t('Desc'), + t('Items per page'), + t('- All -'), + t('Offset'), + t('« first'), + t('‹ previous'), + t('next ›'), + t('last »'), + t('Page'), + ); + $export['metatag_views_test'] = $view; + + return $export; +} diff --git a/sites/all/modules/contrib/metatag/plugins/content_types/node_form_metatags.inc b/sites/all/modules/contrib/metatag/plugins/content_types/node_form_metatags.inc new file mode 100644 index 00000000..5439f042 --- /dev/null +++ b/sites/all/modules/contrib/metatag/plugins/content_types/node_form_metatags.inc @@ -0,0 +1,75 @@ + TRUE, + 'title' => t('Node form meta tags'), + 'icon' => 'icon_node_form.png', + 'description' => t('Meta tags on the node form.'), + 'required context' => new ctools_context_required(t('Form'), 'node_form'), + 'category' => t('Form'), +); + +/** + * CTools content type callback to output this pane. + */ +function metatag_node_form_metatags_content_type_render($subtype, $conf, $panel_args, &$context) { + $block = new stdClass(); + + $block->title = t('Meta tags'); + $block->module = 'metatag'; + $block->delta = 'metatag'; + + if (isset($context->form)) { + if (isset($context->form['metatags'])) { + $block->content['metatags'] = $context->form['metatags']; + unset($block->content['metatags']['#pre_render']); + unset($block->content['metatags']['#theme_wrappers']); + $block->content['metatags']['#type'] = ''; + + // Set access to false on the original rather than removing so that + // vertical tabs doesn't clone it. I think this is due to references. + $context->form['metatags']['#access'] = FALSE; + } + } + else { + $block->content = t('Meta tags options.'); + } + return $block; +} + +/** + * CTools content type callback to get the title of this pane. + */ +function metatag_node_form_metatags_content_type_admin_title($subtype, $conf, $context) { + if (isset($context->identifier)) { + $message = t('"@s" node form meta tags', array('@s' => $context->identifier)); + } + else { + $message = t('Node form meta tags'); + } + return $message; +} + +/** + * CTools content type callback to display an edit form for this pane. + */ +function metatag_node_form_metatags_content_type_edit_form($form, &$form_state) { + // Provide a blank form so we have a place to have context setting. + return $form; +} + +/** + * CTools content type callback to provide extra information about this pane. + */ +function metatag_node_form_metatags_content_type_admin_info($type, $subtype, $conf, $context = NULL) { + $output = new stdClass(); + $output->title = t('Metatag form'); + $output->content = t('Shows the meta tag fields on this node form if the user has the appropriate permissions.'); + + return $output; +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.bulk_revert.test b/sites/all/modules/contrib/metatag/tests/metatag.bulk_revert.test new file mode 100644 index 00000000..8dfb01f3 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.bulk_revert.test @@ -0,0 +1,56 @@ + 'Metatag bulk revert', + 'description' => 'Test the Metatag bulk revert functionality.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * Test the Bulk Revert functionality works. + */ + function testBulkRevertPageLoads() { + $this->adminUser = $this->createAdminUser(); + $this->drupalLogin($this->adminUser); + + $this->drupalGet('admin/config/search/metatags/bulk-revert'); + $this->assertResponse(200); + + // Confirm each of the entity checkboxes is present. + foreach (entity_get_info() as $entity_type => $entity_info) { + foreach (array_keys($entity_info['bundles']) as $bundle) { + if (metatag_entity_supports_metatags($entity_type, $bundle)) { + $this->assertFieldByName("update[{$entity_type}:{$bundle}]"); + } + } + } + + // Confirm each of the meta tags is available as a checkbox. + foreach (metatag_get_info('tags') as $tag_name => $tag) { + $this->assertFieldByName("tags[{$tag_name}]"); + } + + // Confirm each of the languages has a checkbox. + $this->assertFieldByName("languages[" . LANGUAGE_NONE . "]"); + foreach (language_list() as $language) { + $this->assertFieldByName("languages[{$language->language}]"); + } + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.core_tag_removal.test b/sites/all/modules/contrib/metatag/tests/metatag.core_tag_removal.test new file mode 100644 index 00000000..d2d7ed7b --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.core_tag_removal.test @@ -0,0 +1,78 @@ + 'Metatag core tag handling', + 'description' => 'Test Metatag integration with the locale module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * Test that the core meta tags work correctly. + */ + function testCoreTagRemoval() { + // The default generator strings from core and Metatag. + $generator_core = 'Drupal 7 (http://drupal.org)'; + $generator_metatag = 'Drupal 7 (https://www.drupal.org)'; + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the Generator tag is the default. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 1, 'Exactly one generator meta tag found.'); + $this->assertEqual($xpath[0]['content'], $generator_metatag); + + // Update the global config to remove the 'generator' value. + $config = metatag_config_load('global'); + unset($config->config['generator']); + metatag_config_save($config); + // Dump out the current config, to aid with debugging. + $this->verbose($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the Generator tag no longer exists. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 0, 'No generator meta tag found.'); + + // Tell Metatag to leave core's meta tags in place. + variable_set('metatag_leave_core_tags', TRUE); + + // Clear the Metatag caches. + metatag_flush_caches(); + + // Clear the page caches. + drupal_flush_all_caches(); + + // Load the front page again. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the Generator tag is using core's default again, i.e. core + // is responsible for adding it. Also, core uses the meta tag name + // "Generator" instead of 'generator' like Metatag uses. + $xpath = $this->xpath("//meta[@name='Generator']"); + $this->assertEqual(count($xpath), 1, 'Exactly one generator meta tag found.'); + $this->assertEqual($xpath[0]['content'], $generator_core); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.helper.test b/sites/all/modules/contrib/metatag/tests/metatag.helper.test new file mode 100644 index 00000000..b4a82f5c --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.helper.test @@ -0,0 +1,772 @@ +\n" . print_r($message, TRUE) . "\n\n"; + } + + // Optional title to go before the output. + if (!empty($title)) { + $title = '

' . check_plain($title) . "

\n"; + } + + parent::verbose($title . $message); + } + + /** + * Load the Performance admin page and clear all caches. + */ + public function clearAllCaches() { + $this->drupalGet('admin/config/development/performance'); + $this->assertResponse(200); + $this->assertText(t('Performance')); + $this->assertText(t('Clear cache')); + $this->drupalPost(NULL, array(), t('Clear all caches')); + $this->assertResponse(200); + $this->assertText(t('Caches cleared')); + } + + /** + * Create a content type for the tests. + */ + function createContentType($machine_name, $label) { + // Create a content type. + $content_type = $this->drupalCreateContentType(array( + 'type' => $machine_name, + 'name' => $label, + )); + + // Enable meta tags for this new content type. + metatag_entity_type_enable('node', $machine_name, TRUE); + + return $content_type; + } + + /** + * Create an admin user for the tests. + * + * @param array $extra_permissions + * An array of permission strings to be added to the user. + * + * @return object + * A user object. + */ + function createAdminUser($extra_permissions = array()) { + $permissions = array( + // Basic permissions for the module. + 'administer meta tags', + 'edit meta tags', + + // General admin access. + 'access administration pages', + ); + + // Reset the static variable used to identify permissions, otherwise it's + // possible the permissions check in drupalCreateUser will fail. + $this->checkPermissions(array(), TRUE); + cache_clear_all(); + + return $this->drupalCreateUser(array_merge($permissions, $extra_permissions)); + } + + /** + * Create a normal user for the tests. + * + * @param array $extra_permissions + * An array of permission strings to be added to the user. + * + * @return object + * A user object. + */ + function createUser($extra_permissions) { + // Basic permissions for the module. + $permissions = array( + 'edit meta tags', + ); + + // Reset the static variable used to identify permissions, otherwise it's + // possible the permissions check in drupalCreateUser will fail. + $this->checkPermissions(array(), TRUE); + cache_clear_all(); + + return $this->drupalCreateUser(array_merge($permissions, $extra_permissions)); + } + + /** + * Returns a new vocabulary with random properties. + * + * @param $vocab_name + * If empty a random string will be used. + * @param $content_type + * Any content types listed will have a Taxonomy Term reference field added + * that points to the new vocabulary. + * + * @return object + * A vocabulary object. + */ + function createVocabulary($vocab_name = NULL, $content_type = NULL) { + if (empty($vocab_name)) { + $vocab_name = $this->randomName(); + } + + // Create a vocabulary. + $vocabulary = new stdClass(); + $vocabulary->name = $vocab_name; + $vocabulary->description = $vocab_name; + $vocabulary->machine_name = drupal_strtolower($vocab_name); + $vocabulary->help = ''; + $vocabulary->weight = mt_rand(0, 10); + if (!empty($content_type)) { + $vocabulary->nodes = array($content_type => $content_type); + } + taxonomy_vocabulary_save($vocabulary); + + // Enable meta tags for this new vocabulary. + metatag_entity_type_enable('taxonomy_term', $vocab_name, TRUE); + + return $vocabulary; + } + + /** + * Returns a new taxonomy term in a specific vocabulary. + * + * @param object $vocabulary + * The vocabulary to add the term to. + * @param string $term_name + * The name to use for the new vocabulary. If none is provided one will be + * generated randomly. + * + * @return object + * A taxonomy term object. + */ + function createTerm($vocabulary, $term_name = NULL) { + if (empty($term_name)) { + $term_name = $this->randomName(); + } + + // Create an object to save. + $term = new stdClass(); + $term->name = $term_name; + $term->description = $term_name; + // Use the first available text format. + $term->format = db_query_range('SELECT format FROM {filter_format}', 0, 1)->fetchField(); + $term->vid = $vocabulary->vid; + + // Save the term. + taxonomy_term_save($term); + + return $term; + } + + /** + * Return an list of default values. + * + * This should cover all of the default meta tags provided for a test:foo + * entity. + * + * @todo Expand to cover more meta tags. + * + * @see metatag_test_metatag_config_default() + */ + function getTestDefaults() { + return array( + // Basic meta tags. + 'title' => array('value' => 'Test altered title'), + 'description' => array('value' => 'Test foo description'), + 'abstract' => array('value' => 'Test foo abstract'), + // 'keywords' => array('value' => ''), + // Advanced meta tags. + // 'robots' => array('value' => ''), + // 'news_keywords' => array('value' => ''), + // 'standout' => array('value' => ''), + // 'robots' => array('value' => ''), + // 'standout' => array('value' => ''), + 'generator' => array('value' => 'Drupal 7 (https://www.drupal.org)'), + // 'standout' => array('value' => ''), + // 'image_src' => array('value' => ''), + 'canonical' => array('value' => '[current-page:url:absolute]'), + 'shortlink' => array('value' => '[current-page:url:unaliased]'), + // 'publisher' => array('value' => ''), + // 'author' => array('value' => ''), + // 'original-source' => array('value' => ''), + // 'revisit-after' => array('value' => ''), + // 'content-language' => array('value' => ''),' + ); + } + + /** + * Add a locale to the site. + * + * This assumes the Locale module is enabled. + */ + public function addSiteLanguage($langcode) { + // Load the language-add page. + $this->drupalGet('admin/config/regional/language/add'); + $this->assertResponse(200, 'Loaded the language-add admin page.'); + + // Submit the language-add form. + $args = array( + 'langcode' => $langcode, + ); + $this->drupalPost(NULL, $args, t('Add language')); + $this->assertResponse(200); + + // Verify that the browser was returned to the main languages admin page. + $this->assertEqual($this->getUrl(), url('admin/config/regional/language', array('absolute' => TRUE)), 'Redirected back to the main languages admin page.'); + + // Clear the language list cache so it can be reloaded. + drupal_static_reset('language_list'); + + // Get all language definitions. + $languages = language_list(); + $language = $languages[$langcode]->name; + $this->assertText(strip_tags(t('The language %language has been created and can now be used. More information is available on the help screen.', array('%language' => t($language), '@locale-help' => url('admin/help/locale')))), 'A new language has been added.'); + } + + /** + * Set up a basic starting point for the locales. + * + * This assumes the Locale module is enabled. This also must be done before + * other user accounts are logged in. + * + * @param array $locales + * A list of locales to be enabled, in langcode format. + */ + public function setupLocales(array $locales = array()) { + // If no locales were requested, add Spanish and French. + if (empty($locales)) { + $locales[] = 'es'; + $locales[] = 'fr'; + } + + // Log in as an admin user with privs to just set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + 'access administration pages', + ); + $admin_user = $this->drupalCreateUser($perms); + $this->drupalLogin($admin_user); + + // Load the admin page, just to have a point of reference. + $this->drupalGet('admin'); + $this->assertResponse(200, 'Loaded the main admin page.'); + + // Identify the site's default language. + $default_language = language_default('language'); + + // Add the locales. + foreach ($locales as $langcode) { + // Don't create the default language, it's already present. + if ($langcode != $default_language) { + $this->addSiteLanguage($langcode); + } + } + + // Enable URL language detection and selection. + $this->drupalGet('admin/config/regional/language/configure'); + $this->assertResponse(200); + $edit = array( + 'language[enabled][locale-url]' => TRUE, + ); + // Also enable path handling for Entity Translation if it is installed. + if (module_exists('entity_translation')) { + $edit['language_content[enabled][locale-url]'] = TRUE; + } + $this->drupalPost(NULL, $edit, t('Save settings')); + $this->assertResponse(200); + + // Once all the setup is done, log out the user. + $this->drupalLogout(); + } + + /** + * Get the {locales_source} lid value for a specific context. + * + * @param string $context + * The context string to search for. + * @param string $textgroup + * This string's textgroup; defaults to 'metatag'. + * + * @return integer + * The {locales_source}.lid value for this string. + */ + function getTranslationLidByContext($context, $textgroup = 'metatag') { + // Extra debug output. + $this->debugLocalesSourcesByContext($context); + + // Look for the string that's actually being requested. + return (int) db_query("SELECT lid + FROM {locales_source} + WHERE textgroup = :textgroup + AND context = :context", + array( + ':textgroup' => $textgroup, + ':context' => $context, + )) + ->fetchField(); + } + + /** + * Get the {locales_source} lid value for a specific source. + * + * @param string $string + * The translation string to search for. + * @param string $textgroup + * This string's textgroup; defaults to 'metatag'. + * + * @return integer + * The {locales_source}.lid value for this string. + */ + function getTranslationLidBySource($string, $textgroup = 'metatag') { + // Extra debug output. + $this->debugLocalesSourcesByContext('', $textgroup); + + // Look for the string that's actually being requested. + return (int) db_query("SELECT lid + FROM {locales_source} + WHERE textgroup = :textgroup + AND source = :source", + array( + ':textgroup' => $textgroup, + ':source' => $string, + )) + ->fetchField(); + } + + /** + * Get the {locales_source} lid values for a specific context. + * + * @param string $context + * The context string to search for. + * @param string $textgroup + * This string's textgroup; defaults to 'metatag'. + * + * @return integer + * The {locales_source}.lid value for this string. + */ + function getTranslationsByContext($context, $textgroup = 'metatag') { + return db_query("SELECT lid + FROM {locales_source} + WHERE textgroup = :textgroup + AND context = :context", + array( + ':textgroup' => $textgroup, + ':context' => $context, + )) + ->fetchCol(); + } + + /** + * Generate a debug dump of the {locales_source} records for a specific context. + * + * @param string $context + * The translation context to search against. + * @param string $textgroup + * This string's textgroup; defaults to 'metatag'. + */ + function debugLocalesSourcesByContext($context, $textgroup = 'metatag') { + // Get a dump of all i18n strings for Metatag. + $records = db_query("SELECT lid, location, textgroup, source, context, version + FROM {locales_source} + WHERE textgroup = :textgroup", + array( + ':textgroup' => $textgroup, + )) + ->fetchAllAssoc('lid'); + foreach ($records as $key => $record) { + $records[$key] = (array) $record; + } + $args = array( + 'caption' => 'i18n source check for . ' . $context, + 'header' => array( + 'lid', + 'location', + 'textgroup', + 'source', + 'context', + 'version', + ), + 'rows' => $records, + ); + $this->verbose(theme('table', $args)); + } + + /** + * Save a {locales_target} translation string to the database. + * + * @param int $lid + * The {locales_source}.lid primary key. + * @param string $context + * The {locales_source}.context value for this string. + * @param string $langcode + * The language the string is being translated into. + * @param string $string_source + * The string that is being translated. + * @param string $string_target + * The destination string. + */ + function saveTranslationString($lid, $context, $langcode, $string_source, $string_target) { + // Load the translation page for the front page's title tag. + $this->drupalGet('admin/config/regional/translate/edit/' . $lid); + $this->assertResponse(200, 'Loaded the front page title tag string translation page.'); + $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/edit/' . $lid, array('absolute' => TRUE))); + + // Confirm that the permission-check text is not found. + $this->assertNoText(t('This is a user-defined string. You are not allowed to translate these strings.')); + + // Look for the existing string. The string gets mungled by the Locale + // module, so need to replicate its behaviour. + $this->assertText(check_plain(wordwrap($string_source, 0))); + + // Look for the context value; the context value is empty for all default + // i.e. interface strings, so don't test this when the context is empty. + if (!empty($context)) { + $this->assertText($context); + } + + // Confirm that the destination strings exist. + $source_locale = language_default('language'); + if (function_exists('i18n_string_source_language')) { + $source_locale = i18n_string_source_language(); + } + if ($source_locale != 'en') { + $this->assertField('translations[en]', 'Found the English translation string field.'); + } + if ($source_locale != 'fr') { + $this->assertField('translations[fr]', 'Found the French translation string field.'); + } + if ($source_locale != 'es') { + $this->assertField('translations[es]', 'Found the Spanish translation string field.'); + } + + // Translate the string. + $edit = array( + "translations[{$langcode}]" => $string_target, + ); + $this->drupalPost(NULL, $edit, t('Save translations')); + $this->assertResponse(200); + + // Confirm the save worked. + $this->assertText(t('The string has been saved.')); + $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/translate', array('absolute' => TRUE))); + + // Debug output. + $this->debugLocalesTargetsByContext($context); + + // Clear the Metatag caches. + metatag_flush_caches(); + } + + /** + * Generate a debug dump of the {locales_target} records for a specific context. + * + * @param string $context + * The translation context to search against. + */ + function debugLocalesTargetsByContext($context) { + // , lt.i18n_status + $records = db_query("SELECT lt.lid, lt.translation, lt.language, lt.plid, lt.plural + FROM {locales_target} lt + INNER JOIN {locales_source} ls + ON lt.lid = ls.lid + WHERE ls.textgroup = 'metatag' + AND ls.context = :context", + array(':context' => $context)) + ->fetchAllAssoc('lid'); + foreach ($records as $key => $record) { + $records[$key] = (array) $record; + } + $args = array( + 'caption' => 'Locale target check for . ' . $context, + 'header' => array( + 'lid', + 'translation', + 'language', + 'plid', + 'plural', + // 'i18n_status', + ), + 'rows' => $records, + ); + $this->verbose(theme('table', $args)); + } + + /** + * Creates an object which can be used for generating and checking behavior. + * + * @param string $identifier + * The machine name to identify this object in source code. + * @param string $path + * Path where generate metatags. + * + * @return object + * A mapping object. + */ + function createTestObject($identifier, $path) { + $test_object = new stdClass(); + $test_object->name = $identifier; + $test_object->path = $path; + $test_object->title = "My $identifier title"; + $test_object->description = "My $identifier description"; + $test_object->abstract = "My $identifier abstract"; + $test_object->keywords = "My $identifier keywords"; + + return $test_object; + } + + /** + * Generates meta tags by path from a test_object. + * + * @return $test_object + * Metatag mapping object. + */ + function generateByPathConfig($test_object) { + // Verify the "add context" page works. + $this->drupalGet('admin/config/search/metatags/context'); + $this->assertResponse(200); + $this->assertText(t('Add a meta tag by path')); + + // Verify the "add context" page works. + $this->drupalGet('admin/config/search/metatags/context/add'); + $this->assertResponse(200); + $this->assertText(t('The unique ID for this metatag path context rule. This must contain only lower case letters, numbers and underscores.')); + + // Add new Metatag object for this configuration. + $values = array( + 'name' => $test_object->name, + ); + + $this->drupalPost('admin/config/search/metatags/context/add', $values, t('Add and configure')); + $this->assertResponse(200); + } + + /** + * Edits meta tags by path from a test_object. + * + * @return $test_object + * Metatag mapping object. + */ + function editByPathConfig($test_object) { + $edit = array( + 'paths' => $test_object->path, + 'metatags[und][title][value]' => $test_object->title, + 'metatags[und][description][value]' => $test_object->description, + 'metatags[und][abstract][value]' => $test_object->abstract, + 'metatags[und][keywords][value]' => $test_object->keywords, + ); + $this->drupalPost('admin/config/search/metatags/context/' . $test_object->name, $edit, t('Save')); + $this->assertResponse(200); + } + + /** + * Checks if meta tags have been added correctly from a test_object. + * + * @return $test_object + * Metatag mapping object. + */ + function checkByPathConfig($test_object) { + $this->drupalGet($test_object->path); + $this->assertResponse(200); + + // Manually test the page title. + if (!empty($test_object->title)) { + $this->assertTitle($test_object->title, 'Title found in ' . $test_object->path); + } + + // Test the other meta tags. + $tags = array('description', 'abstract', 'keywords'); + foreach ($tags as $tag) { + if (!empty($test_object->{$tag})) { + $this->assertRaw($test_object->{$tag}, $tag . ' found in ' . $test_object->path); + } + else { + $this->assertNoRaw('assertTrue($count >= 1, 'Found Metatag strings to translate.'); + $this->assertNoText(t('No strings available.')); + $xpath = $this->xpath("//body//div[@class='content']//table//tbody//tr"); + $this->verbose("Found {$count} items to translate."); + if (!empty($string)) { + $this->assertText($context); + $this->assertText('metatag:' . $context); + } + } + // If the string is not supposed to be found, then confirm the context is + // not available. + else { + $this->assertNoText($context); + $this->assertNoText('metatag:' . $context); + } + } + + /** + * Create an image of a specific size & type. + * + * @param string $image_size + * The size of the requested image in 'XxY' format; defaults to '200x200'. + * @param string $format + * The image format to use, defaults to 'png'. + * + * @return string + * The URL to a public file. + */ + function generateImage($image_size = '200x200', $format = 'png') { + // Only proceed if the Devel Generate module is installed. + if (module_exists('devel_generate')) { + // Load the Devel Generate image generator logic. + module_load_include('inc', 'devel_generate', 'image.devel_generate'); + + $image_format = 'png'; + $image_size = '200x200'; + $temp_image = devel_generate_image($image_format, $image_size, $image_size); + + return file_unmanaged_move($temp_image, 'public://'); + } + else { + $this->error('The Devel Generate module is not enabled, it must be added to the $modules array in the setUp() method for this test class.'); + } + } + + /** + * Create an image file object of a specific size & type. + * + * @param string + * The size of the requested image in 'XxY' format; defaults to '200x200'. + * @param string + * The image format to use, defaults to 'png'. + * + * @return object + * The file object for the generated image. + */ + function generateImageFile($image_size = '200x200', $format = 'png') { + // Generate a test image. + $image_uri = $this->generateImage(); + + // Create a file object for this image. + $file = new StdClass(); + $file->fid = NULL; + $file->uid = 1; + $file->uri = $image_uri; + $file->filemime = file_get_mimetype($image_uri); + $file->filesize = filesize($image_uri); + $file->status = 1; + $file->timestamp = filemtime($image_uri); + $saved_file = file_save($file); + + return $saved_file; + } + + /** + * Verify a user entity's meta tags load correctly. + * + * @param object $user + * A user object that is to be tested. + */ + function assertUserEntityTags($user) { + // Load the user's profile page. + $this->drupalGet('user/' . $user->uid); + $this->assertResponse(200); + + // Verify the title is using the custom default for this vocabulary. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], $user->name . " ponies"); + } + + /** + * Generate a string that is allowable as a machine name. + * + * @param int $length + * How long the machine name will be, defaults to eight characters. + * + * @return string + * A string that contains lowercase letters and numbers, with a letter as + * the first character. + */ + function randomMachineName($length = 8) { + return strtolower($this->randomName($length)); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.image.test b/sites/all/modules/contrib/metatag/tests/metatag.image.test new file mode 100644 index 00000000..bdf8ad75 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.image.test @@ -0,0 +1,491 @@ + 'Metatag core tests for images', + 'description' => 'Test Metatag integration with image files.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'devel_generate'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Needs the OpenGraph submodule because of testNodeFieldValueMultiple(). + $modules[] = 'metatag_opengraph'; + + // Need image handling. + $modules[] = 'image'; + + // Need the Devel Generate image generator. + $modules[] = 'devel_generate'; + + parent::setUp($modules); + } + + /** + * Confirm that an image can be added to a global configuration using the + * image's absolute URL. + */ + function testConfigAbsoluteURL() { + // Generate a test image. + $image_uri = $this->generateImage(); + $this->verbose($image_uri); + + // Work out the web-accessible URL for this image. + $image_url = file_create_url($image_uri); + + // Update the global config to add an image meta tag. + $config = metatag_config_load('global'); + $config->config['image_src']['value'] = $image_url; + metatag_config_save($config); + + // Dump out the current config, to aid with debugging. + $this->verbose($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual($xpath[0]['href'], $image_url, 'The image_src meta tag with an absolute URL is being output correctly.'); + + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['href']); + $this->assertResponse(200, "The image_src meta tag's value could be loaded."); + } + + /** + * Confirm that an image can be added to a global configuration using the + * image's relative URL. + */ + function testConfigDrupalRelativeURL() { + // Generate a test image. + $image_uri = $this->generateImage(); + $this->verbose($image_uri); + + // Work out the web-accessible URL for this image. + $image_url = file_create_url($image_uri); + + // Extract the relative URL version of the absolute URL. + $url_length = strlen($GLOBALS['base_url']); + + // Need to increase the length by 1 as the base_url does not include a + // trailing slash. + $relative_url = substr($image_url, $url_length + 1); + + // Update the global config to add an image meta tag. + $config = metatag_config_load('global'); + $config->config['image_src']['value'] = $relative_url; + metatag_config_save($config); + + // Dump out the current config, to aid with debugging. + $this->verbose($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual((string) $xpath[0]['href'], $image_url); + // , 'The image_src meta tag with a URL relative to the Drupal root is being output as an absolute URL.'); + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['href']); + $this->assertResponse(200, "The image_src meta tag's value could be loaded."); + } + + /** + * Confirm that an image can be added to a global configuration using the + * image's relative URL. + */ + function testConfigRelativeURL() { + // Generate a test image. + $image_uri = $this->generateImage(); + $this->verbose($image_uri); + + // Work out the web-accessible URL for this image. + $image_url = file_create_url($image_uri); + + // Extract the relative URL version of the absolute URL. + $url_length = drupal_strlen($GLOBALS['base_url']); + + // Need to increase the length by 1 as the base_url does not include a + // trailing slash. + $relative_url = drupal_substr($image_url, $url_length + 1); + + // Update the global config to add an image meta tag. + $config = metatag_config_load('global'); + $config->config['image_src']['value'] = $relative_url; + metatag_config_save($config); + + // Dump out the current config, to aid with debugging. + $this->verbose($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual((string) $xpath[0]['href'], $image_url); + // , 'The image_src meta tag with an internal URI is being output as an absolute URL.'); + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['href']); + $this->assertResponse(200, "The image_src meta tag's value could be loaded."); + } + + /** + * Confirm that an image can be added to a global configuration using the + * image's protocol-relative URL. + */ + function testConfigProtocolRelativeURL() { + // Generate a test image. + $image_uri = $this->generateImage(); + $this->verbose($image_uri); + + // Work out the web-accessible URL for this image. + $image_url = file_create_url($image_uri); + + // Make the URL protocol-relative. + $relative_url = str_replace('http://', '//', $image_url); + + // Update the global config to add an image meta tag. + $config = metatag_config_load('global'); + $config->config['image_src']['value'] = $relative_url; + metatag_config_save($config); + + // Dump out the current config, to aid with debugging. + $this->verbose($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual($xpath[0]['href'], $relative_url, 'The image_src meta tag with a protocol-relative URL is being output correctly.'); + $this->assertNotEqual($xpath[0]['href'], $image_url, 'The image_src meta tag does not contain the absolute URL.'); + } + + /** + * Confirm that an image can be added to a global configuration using the + * image's internal URI. + */ + function testConfigInternalURL() { + // Generate a test image. + $image_uri = $this->generateImage(); + $this->verbose($image_uri); + + // Work out the web-accessible URL for this image. + $image_url = file_create_url($image_uri); + + // Confirm the file could be loaded. + $this->drupalGet($image_url); + $this->assertResponse(200, 'The image could be loaded.'); + + // Update the global config to add an image meta tag. + $config = metatag_config_load('global'); + $config->config['image_src']['value'] = $image_uri; + metatag_config_save($config); + + // Dump out the current config, to aid with debugging. + $this->verbose($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the image URL can be found in the raw HTML. + $this->assertRaw($image_url, 'Found the image URL in the raw HTML.'); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual($xpath[0]['href'], $image_url, 'The image_src meta tag with an internal URI is being output correctly.'); + + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['href']); + $this->assertResponse(200, "The image_src meta tag's value could be loaded."); + } + + /** + * Confirm that an image with a space in its URL will be handled properly. + */ + function testConfigImageWithSpaceInURL() { + // Generate a test image. + $image_uri = $this->generateImage(); + $this->verbose($image_uri); + + // Rename the file so it has a space in the filename. + $image_uri = file_unmanaged_move($image_uri, str_replace('_', ' ', $image_uri)); + $this->verbose($image_uri); + + // Work out the web-accessible URL for this image. + $image_url = file_create_url($image_uri); + + // Confirm the file could be loaded. + $this->drupalGet($image_url); + $this->assertResponse(200, 'The image could be loaded.'); + + // After processing the image's URL will have "%20" instead of spaces. + $image_url_friendly = str_replace(' ', '%20', $image_url); + + // Confirm the file's friendly URL could be loaded. + $this->drupalGet($image_url_friendly); + $this->assertResponse(200, 'The friendly image could be loaded.'); + + // Update the global config to add an image meta tag. + $config = metatag_config_load('global'); + $config->config['image_src']['value'] = $image_uri; + metatag_config_save($config); + + // Dump out the current config, to aid with debugging. + $this->verbose($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // Confirm that the image's friendly URL can be found in the raw HTML. + $this->assertRaw($image_url_friendly, 'Found the friendly image URL in the raw HTML.'); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual($xpath[0]['href'], $image_url_friendly, 'The image had its spaces replaces with "%20".'); + + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['href']); + $this->assertResponse(200, "The image_src meta tag's value could be loaded."); + } + + /** + * Confirm that a default value on an image field will be output correctly. + */ + function testNodeFieldDefault() { + // Generate a test image file object. + $image = $this->generateImageFile(); + $image_url = file_create_url($image->uri); + + // Dump out the file object, to aid with debugging. + $this->verbose($image); + + // Update the article-image default settings to use the new image field. + $entity_type = 'node'; + $bundle = 'article'; + $field_name = 'field_image'; + $instance = field_info_instance($entity_type, $field_name, $bundle); + $instance['settings']['default_image'] = $image->fid; + field_update_instance($instance); + + // Create an example node. + $args = array( + 'type' => 'article', + ); + $node = $this->drupalCreateNode($args); + + // Update the config. + $config = metatag_config_load('node'); + $config->config['image_src']['value'] = '[node:field_image]'; + metatag_config_save($config); + + // Load the node page. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual($xpath[0]['href'], $image_url, "The image_src meta tag was found with the field's default image."); + + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['href']); + $this->assertResponse(200, "The image_src meta tag's value could be loaded."); + } + + /** + * Confirm that a file on an image field will be output correctly. + */ + function testNodeFieldValue() { + // Update the 'content' config to use the field_image field as the + // image_src meta tag. + $config = metatag_config_load('node'); + $config->config['image_src']['value'] = '[node:field_image]'; + metatag_config_save($config); + + // Generate a test image file object. + $image = $this->generateImageFile(); + $image_url = file_create_url($image->uri); + + // Dump out the file object, to aid with debugging. + $this->verbose($image); + + // Create an example node. + $args = array( + 'type' => 'article', + 'field_image' => array( + LANGUAGE_NONE => array( + array('fid' => $image->fid), + ), + ), + ); + $node = $this->drupalCreateNode($args); + + // Forcibly reload the node, to avoid working with a cached version. + $node = node_load($node->nid, NULL, TRUE); + $this->verbose($node, 'Node'); + + // Load the node page. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'One image_src meta tag found.'); + $this->assertEqual($xpath[0]['href'], $image_url, "The image_src meta tag was found with the node's image field's value."); + + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['href']); + $this->assertResponse(200, "The image_src meta tag's value could be loaded."); + } + + /** + * Confirm that when using a file field that allows multiple values, only the + * first item will be used when outputting a single meta tag. + */ + function testNodeFieldValueNotMultiple() { + // Update the 'content' config to use the field_image field as the + // image_src meta tag. + $config = metatag_config_load('node'); + $config->config['image_src']['value'] = '[node:field_image]'; + metatag_config_save($config); + + // Update the image field to allow unlimited items. + $field_name = 'field_image'; + $field = field_info_field($field_name); + $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED; + field_update_field($field); + + // Generate a test image file object. + $image1 = $this->generateImageFile(); + $image1_url = file_create_url($image1->uri); + $image2 = $this->generateImageFile(); + $image2_url = file_create_url($image2->uri); + + // Dump out the file objects, to aid with debugging. + $this->verbose($image1, 'Image #1'); + $this->verbose($image2, 'Image #2'); + + // Create an example node. + $args = array( + 'type' => 'article', + 'field_image' => array( + LANGUAGE_NONE => array( + array('fid' => $image1->fid), + array('fid' => $image2->fid), + ), + ), + ); + $node = $this->drupalCreateNode($args); + + // Forcibly reload the node, to avoid working with a cached version. + $node = node_load($node->nid, NULL, TRUE); + $this->verbose($node, 'Node'); + + // Load the node page. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Confirm that the image_src meta tag has the expected values. + $xpath = $this->xpath("//link[@rel='image_src']"); + $this->assertEqual(count($xpath), 1, 'Only one image_src meta tag found.'); + $this->assertEqual($xpath[0]['href'], $image1_url, "The image_src meta tag was found with the node's image field's first value."); + $this->assertNotEqual($xpath[0]['href'], $image2_url, "The image_src meta tag does not contain the node's image field's second value."); + + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['href']); + $this->assertResponse(200, "The image_src meta tag's value could be loaded."); + } + + /** + * Confirm that when using a file field that allows multiple values, that + * multiple images can be used and then it will result in multiple meta tags. + */ + function testNodeFieldValueMultiple() { + // Update the 'content' config to use the field_image field as the + // image_src meta tag. + $config = metatag_config_load('node'); + $config->config['og:image']['value'] = '[node:field_image]'; + metatag_config_save($config); + + // Update the image field to allow unlimited items. + $field_name = 'field_image'; + $field = field_info_field($field_name); + $field['cardinality'] = FIELD_CARDINALITY_UNLIMITED; + field_update_field($field); + + // Generate a test image file object. + $image1 = $this->generateImageFile(); + $image1_url = file_create_url($image1->uri); + $image2 = $this->generateImageFile(); + $image2_url = file_create_url($image2->uri); + + // Dump out the file objects, to aid with debugging. + $this->verbose($image1, 'Image #1'); + $this->verbose($image2, 'Image #2'); + + // Create an example node. + $args = array( + 'type' => 'article', + 'field_image' => array( + LANGUAGE_NONE => array( + array('fid' => $image1->fid), + array('fid' => $image2->fid), + ), + ), + ); + $node = $this->drupalCreateNode($args); + + // Forcibly reload the node, to avoid working with a cached version. + $node = node_load($node->nid, NULL, TRUE); + $this->verbose($node, 'Node'); + + // Load the node page. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Confirm that the og:image meta tags have the expected values. + $xpath = $this->xpath("//meta[@property='og:image']"); + $this->assertEqual(count($xpath), 2, 'Two og:image meta tags were found.'); + $this->assertEqual($xpath[0]['content'], $image1_url, "The first og:image meta tag has the correct image."); + $this->assertEqual($xpath[1]['content'], $image2_url, "The second og:image meta tag has the correct image."); + + // Confirm the file could be loaded. + $this->drupalGet($xpath[0]['content']); + $this->assertResponse(200, "The first og:image meta tag's value could be loaded."); + $this->drupalGet($xpath[1]['content']); + $this->assertResponse(200, "The second og:image meta tag's value could be loaded."); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.locale.test b/sites/all/modules/contrib/metatag/tests/metatag.locale.test new file mode 100644 index 00000000..8f2352a1 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.locale.test @@ -0,0 +1,157 @@ + 'Metatag core tests for Locale', + 'description' => 'Test Metatag integration with the locale module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need Locale for the multiple languages. + $modules[] = 'locale'; + + parent::setUp($modules); + } + + /** + * Test that the node form meta tag fields are translated correctly. + */ + function testNodeFormTranslations() { + $content_type = 'metatag_test'; + $content_type_path = str_replace('_', '-', $content_type); + $label = 'Test'; + + // Create a content type. + $this->createContentType($content_type, $label); + + // Add more locales. + $this->setupLocales(); + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'delete any ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // Locale items. + 'administer languages', + 'translate interface', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Load the node form in each locale, confirm it has the fields. This also + // preloads the field labels into the locale system. + foreach (array('French' => 'fr', 'English' => '') as $lang => $langcode) { + $path = 'node/add/' . $content_type_path; + if (!empty($langcode)) { + $path = $langcode . '/' . $path; + } + + // Load the node form in French to prep the translation strings. + $this->drupalGet($path); + $this->assertResponse(200); + + // Verify the page loaded correctly. + // @todo Update this to extract the page title. + $this->assertText(strip_tags(t('Create @name', array('@name' => $label)))); + + // Confirm the Metatag fields are present. + $this->assertField('edit-metatags-und-title-value', 'Found the page title meta tag'); + $xpath = $this->xpath("//label[@for='edit-metatags-und-title-value']"); + $this->assertEqual(count($xpath), 1, 'Exactly one page title field found.'); + // Need to trim() the xpath results because Field API adds a space after + // every field's label. + $this->assertEqual(trim((string) $xpath[0]), 'Page title'); + + $this->assertField('edit-metatags-und-description-value', 'Found the description meta tag'); + $xpath = $this->xpath("//label[@for='edit-metatags-und-description-value']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description field found.'); + // Need to trim() the xpath results because Field API adds a space after + // every field's label. + $this->assertEqual(trim((string) $xpath[0]), 'Description'); + } + + // Translate the page title and description fields. + $textgroup = 'default'; + $context = ''; + $langcode = 'fr'; + $title_source = 'Page title'; + $title_target = 'Le page title'; + $lid = $this->getTranslationLidBySource($title_source, $textgroup); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the page title tag.'); + $this->saveTranslationString($lid, $context, $langcode, $title_source, $title_target); + $desc_source = 'Description'; + $desc_target = 'Le description'; + $lid = $this->getTranslationLidBySource($desc_source, $textgroup); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the description tag.'); + $this->saveTranslationString($lid, $context, $langcode, $desc_source, $desc_target); + + // Clear the metatag_get_info() cache since translated strings have changed. + metatag_config_cache_clear(); + + // Load the French node form again. + $this->drupalGet('fr/node/add/' . $content_type_path); + $this->assertResponse(200); + + // Verify the title field's label was translated. + $xpath = $this->xpath("//label[@for='edit-metatags-und-title-value']"); + $this->assertEqual(count($xpath), 1, 'Exactly one page title field found.'); + // Need to trim() the xpath results because Field API adds a space after + // every field's label. + $this->assertEqual(trim((string) $xpath[0]), $title_target); + + // Verify the description field's label was translated. + $xpath = $this->xpath("//label[@for='edit-metatags-und-description-value']"); + $this->assertEqual(count($xpath), 1, 'Exactly one description field found.'); + // Need to trim() the xpath results because Field API adds a space after + // every field's label. + $this->assertEqual(trim((string) $xpath[0]), $desc_target); + } + + /** + * Verify language meta tags don't output LANGUAGE_NONE / 'und'. + */ + function testLanguageNone() { + // Set the global node defaults to set "content-language" to the node's + // language. + $config = metatag_config_load('node'); + $config->config['content-language']['value'] = '[node:language]'; + metatag_config_save($config); + + // Create a test node. + $node = $this->drupalCreateNode(); + $this->assertEqual($node->language, LANGUAGE_NONE); + + // Load the node page, confirm that the "content-language" meta tag is not + // output. + $this->drupalGet('node/' . $node->nid); + $xpath = $this->xpath("//meta[@http-equiv='content-language']"); + $this->assertEqual(count($xpath), 0, 'The content-language meta tag was not found.'); + } + + // @todo Make sure the meta tag fields are displayed in the correct locale. + // @todo Make sure the node records are stored with the correct language. +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.node.test b/sites/all/modules/contrib/metatag/tests/metatag.node.test new file mode 100644 index 00000000..bb35310c --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.node.test @@ -0,0 +1,450 @@ + 'Metatag core tests for nodes', + 'description' => 'Test Metatag edit functionality for nodes.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * Tests creation of a standard entity. + */ + public function testEntityCreationWorkflow() { + $content_type = 'metatag_test'; + $content_type_path = str_replace('_', '-', $content_type); + $label = 'Test'; + + // Create a content type. + $this->createContentType($content_type, $label); + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'delete any ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // Used later for revision handling. + 'view revisions', + 'revert revisions', + 'delete revisions', + + // This permission is required in order to create new revisions. + 'administer nodes', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Assign default values for the new content type. + // Load the "add default configuration" page. + $this->drupalGet('admin/config/search/metatags/config/add'); + $this->assertResponse(200); + + // Verify the page loaded correct. + $this->assertText(t('Select the type of default meta tags you would like to add.')); + + // Submit the initial form to select an entity bundle. + $this->drupalPost(NULL, array( + 'instance' => 'node:' . $content_type, + ), t('Add and configure')); + $this->assertResponse(200); + + // Verify the page loaded correct. + $this->assertText('Node: ' . $label); + + // Submit the form with some values. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[node:title]', + ), t('Save')); + $this->assertResponse(200); + + // Verify the page loaded correct. + $this->assertText(strip_tags(t('The meta tag defaults for @label have been saved.', array('@label' => 'Node: ' . $label)))); + + // Verify that the user was redirected to the settings page again. + $this->assertEqual($this->getUrl(), url('admin/config/search/metatags', array('absolute' => TRUE))); + + // Create a test node. + // Load the node form. + $this->drupalGet('node/add/' . $content_type_path); + $this->assertResponse(200); + + // Verify the page loaded correctly. + // @todo Update this to extract the page title. + $this->assertText(strip_tags(t('Create @name', array('@name' => $label)))); + + // Verify that it's possible to submit values to the form. + module_load_include('inc', 'devel_generate'); + $body = devel_create_para(200); + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[node:title] ponies', + 'title' => 'Who likes magic', + 'body[und][0][value]' => $body, + ), t('Save')); + $this->assertResponse(200); + + // The meta tags that will be checked for. + $expected = array( + 'und' => array( + 'abstract' => array( + 'value' => '[node:title] ponies', + ), + ), + ); + + // Verify that the node saved correctly. + // $xpath = $this->xpath("//h1"); + $t_args = array('@type' => 'Test', '%title' => 'Who likes magic'); + // This doesn't work for some reason, it seems the HTML is stripped off + // during output so the %title's standard Drupal wrappers don't match. + // $this->assertText(t('@type %title has been created.', $t_args)); + // .. so this has to be done instead. + $this->assertText(strip_tags(t('@type %title has been created.', $t_args))); + + // Verify the node data saved correctly. + $matches = array(); + $nid = 0; + if (preg_match('@node/(\d+)$@', $this->getUrl(), $matches)) { + $nid = end($matches); + $node = node_load($nid); + $this->verbose($node, 'node_load(' . $nid . ')'); + + // Only the non-default values are stored. + $this->assertEqual($expected, $node->metatags); + + // Confirm the APIs can load the data for this node. + $metatags = metatag_metatags_load('node', $node->nid); + $this->verbose($metatags, 'metatag_metatags_load("node", ' . $node->nid . ')'); + $this->assertEqual($expected, $metatags); + $metatags = metatag_metatags_load_multiple('node', array($node->nid)); + $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $node->nid . '))'); + $this->assertEqual(array($node->nid => array($node->vid => $expected)), $metatags); + + // Confirm the APIs can load the data for this node revision. + $metatags = metatag_metatags_load('node', $node->nid, $node->vid); + $this->verbose($metatags, 'metatag_metatags_load("node", ' . $node->nid . ', ' . $node->vid . ')'); + $this->assertEqual($expected, $metatags); + $metatags = metatag_metatags_load_multiple('node', array($node->nid), array($node->vid)); + $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $node->nid . '), array(' . $node->vid . '))'); + $this->assertEqual(array($node->nid => array($node->vid => $expected)), $metatags); + } + + // This shouldn't happen, it indicates a problem. + else { + $this->fail(t('Could not determine the ID for the created node.')); + } + + // Verify the title is using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); + + // Verify the node summary is being used correctly. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1); + $this->assertEqual($xpath[0]['content'], DrupalDefaultMetaTag::text_summary($body, 380)); + + // Verify the maxlength functionality is working correctly. + $maxlength = 10; + variable_set('metatag_maxlength_description', $maxlength); + metatag_config_cache_clear(); + $this->drupalGet('node/' . $nid); + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual(count($xpath), 1); + $this->assertEqual($xpath[0]['content'], trim(substr($xpath[0]['content'], 0, $maxlength))); + // Delete the variable so it goes back to the default. + variable_del('metatag_maxlength_description'); + metatag_config_cache_clear(); + + // Core's canonical tag is a relative URL, whereas Metatag outputs an + // absolute URL. + $old_canonical = url('node/' . $node->nid); + $new_canonical = url('node/' . $node->nid, array('absolute' => TRUE)); + + // Confirm that the canonical tag is in the correct format. + $xpath = $this->xpath("//link[@rel='canonical']"); + $this->assertEqual(count($xpath), 1, 'Exactly one canonical meta tag found.'); + $this->assertEqual($xpath[0]['href'], $new_canonical); + $this->assertNotEqual($xpath[0]['href'], $old_canonical); + + // Try loading the node revisions page. + $this->drupalGet('node/' . $node->nid . '/revisions'); + // Verify the page did not load correctly. This is because the revisions + // page can't be loaded if there's only one revision. + $this->assertResponse(403); + + // Try creating a revision of the node. + $old_title = $node->title; + $old_vid = $node->vid; + $new_title = 'Who still likes magic'; + // Load the node-edit page. + $this->drupalGet('node/' . $node->nid . '/edit'); + // Verify the page loaded correctly. + $this->assertResponse(200); + // Try submitting text to the page. + $args = array( + 'metatags[und][abstract][value]' => '[node:title] kittens', + 'title' => $new_title, + 'revision' => 1, + 'log' => 'Creating a new revision', + ); + $this->drupalPost(NULL, $args, t('Save')); + // Verify the page submission loaded correctly. + $this->assertResponse(200); + + // A new version of the expected results. + $expected_updated = array( + 'und' => array( + 'abstract' => array( + 'value' => '[node:title] kittens', + ), + ), + ); + + // Verify that the node saved correctly. + // $xpath = $this->xpath("//h1"); + $t_args = array('@type' => 'Test', '%title' => $new_title); + // This doesn't work for some reason, it seems the HTML is stripped off + // during output so the %title's standard Drupal wrappers don't match. + // $this->assertText(t('@type %title has been updated.', $t_args)); + // .. so this has to be done instead. + $this->assertText(strip_tags(t('@type %title has been updated.', $t_args))); + + // Verify the title is still using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $old_title . ' ponies', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $new_title . ' kittens', 'Found the old abstract meta tag.'); + + // Load the node revisions page. + $this->drupalGet('node/' . $node->nid . '/revisions'); + // Verify the page loaded correctly. + $this->assertResponse(200, 'Loaded the revisions page for this node.'); + + // Confirm there are two revisions. + $xpath = $this->xpath("//body//div[@class='content']//table//tbody//tr"); + $this->assertEqual(count($xpath), 2, 'There are two revisions of this node.'); + + // Load the previous revision. + $this->drupalGet('node/' . $node->nid . '/revisions/' . $old_vid . '/view'); + // Verify the page loaded correctly. + $this->assertResponse(200, 'Loaded the original revision of this node.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old abstract meta tag.'); + + // Load the updated node; force-load it to make sure it's loaded properly. + $updated_node = node_load($node->nid, NULL, TRUE); + $updated_vid = $updated_node->vid; + $this->verbose($updated_node, 'node_load(' . $node->nid . ', NULL, TRUE)'); + + // Confirm the APIs can load the data for this node. + $metatags = metatag_metatags_load('node', $updated_node->nid); + $this->verbose($metatags, 'metatag_metatags_load("node", ' . $updated_node->nid . ')'); + $this->assertEqual($expected_updated, $metatags); + $this->assertNotEqual($expected, $metatags); + // This one is complicated. If only the entity id is passed in it will load + // the {metatag} records for *all* of the entity's revisions. + $metatags = metatag_metatags_load_multiple('node', array($updated_node->nid)); + $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $updated_node->nid . '))'); + $this->assertEqual(array($updated_node->nid => array($node->vid => $expected, $updated_node->vid => $expected_updated)), $metatags); + + // Confirm the APIs can load the data for this node revision. + $metatags = metatag_metatags_load('node', $updated_node->nid, $updated_vid); + $this->verbose($metatags, 'metatag_metatags_load("node", ' . $updated_node->nid . ', ' . $updated_node->vid . ')'); + $this->assertEqual($expected_updated, $metatags); + $this->assertNotEqual($expected, $metatags); + $metatags = metatag_metatags_load_multiple('node', array($updated_node->nid), array($updated_node->vid)); + $this->verbose($metatags, 'metatag_metatags_load_multiple("node", array(' . $updated_node->nid . '), array(' . $updated_node->vid . '))'); + $this->assertEqual(array($updated_node->nid => array($updated_node->vid => $expected_updated)), $metatags); + + // Load the current revision again. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200, 'Loaded the current revision of this node.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $old_title . ' ponies', 'Did not find the old abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $new_title . ' kittens', 'Found the new abstract meta tag.'); + + // Revert to the original revision. + $this->drupalGet('node/' . $node->nid . '/revisions/' . $old_vid . '/revert'); + // Verify the page loaded correctly. + $this->assertResponse(200, 'Loaded the form to revert to the original revision of this node.'); + // Try submitting the form. + $this->drupalPost(NULL, array(), t('Revert')); + // Verify the page submission loaded correctly. + $this->assertResponse(200); + // Confirm there are now three revisions. + $xpath = $this->xpath("//body//div[@class='content']//table//tbody//tr"); + $this->assertEqual(count($xpath), 3, 'There are now three revisions of this node.'); + + // Load the current revision, which will now have the old meta tags. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200, 'Loaded the current revision of this node.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old abstract meta tag again.'); + + // Delete the original revision. + $this->drupalGet('node/' . $node->nid . '/revisions/' . $old_vid . '/delete'); + // Verify the page loaded correctly. + $this->assertResponse(200, 'Loaded the form to delete the original revision of this node.'); + // Try submitting the form. + $this->drupalPost(NULL, array(), t('Delete')); + // Verify the page submission loaded correctly. + $this->assertResponse(200); + // Confirm there are now two revisions again. + $xpath = $this->xpath("//body//div[@class='content']//table//tbody//tr"); + $this->assertEqual(count($xpath), 2, 'There are two revisions of this node again.'); + + // Clear the caches and then load the current revision, just to confirm + // that the page is still loading correctly. + metatag_config_cache_clear(); + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200, 'Loaded the current revision of this node again.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old abstract meta tag again.'); + + // Delete the second revision. + $this->drupalGet('node/' . $node->nid . '/revisions/' . $updated_vid . '/delete'); + // Verify the page loaded correctly. + $this->assertResponse(200, 'Loaded the form to delete the second revision of this node.'); + // Try submitting the form. + $this->drupalPost(NULL, array(), t('Delete')); + $this->assertResponse(200); + // Verify that the revisions page no longer loads because there's only one + // revision now. + $this->drupalGet('node/' . $node->nid . '/revisions'); + $this->assertResponse(403, 'No longer able to load the node revisions page.'); + + // Clear the caches and then load the current revision, just to confirm + // that the page is still loading correctly. + metatag_config_cache_clear(); + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200, 'Loaded the current revision of this node again.'); + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertNotEqual($xpath[0]['content'], $new_title . ' kittens', 'Did not find the new abstract meta tag.'); + $this->assertEqual($xpath[0]['content'], $old_title . ' ponies', 'Found the old abstract meta tag again.'); + } + + /** + * Tests different 'preview' options. #1: Disabled. + */ + public function testNodePreviewOption0() { + $this->checkNodePreviewOption(0); + } + + /** + * Tests different 'preview' options. #2: Optional, without preview. + */ + public function testNodePreviewOption1NoPreview() { + $this->checkNodePreviewOption(1, FALSE); + } + + /** + * Tests different 'preview' options. #2: Optional, with preview. + */ + public function testNodePreviewOption1Preview() { + $this->checkNodePreviewOption(1, TRUE); + } + + /** + * Tests different 'preview' options. #3: Preview required. + */ + public function testNodePreviewOption2() { + $this->checkNodePreviewOption(2); + } + + /** + * Change the node preview option at the content type level, confirm meta tags + * still save correctly. + * + * @param int $option + * A suitable value for the 'node_preview' option for a content type, must + * be either 0, 1 or 2. + * @param bool $preview + * Whether to perform a preview. Has the following implications: + * - if $option === 0, $preview is ignored, no preview is performed. + * - if $option === 1, $preview is considered, a preview may be performed. + * - if $option === 2, $preview is ignored, a preview is performed. + */ + function checkNodePreviewOption($option, $preview = FALSE) { + $content_type = 'article'; + $label = 'Test'; + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // Required for customizing the node preview option. + 'administer content types', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Set the node preview mode. + $this->drupalGet('admin/structure/types/manage/' . $content_type); + $this->assertResponse(200); + $edit = array( + 'node_preview' => $option, + ); + $this->drupalPost(NULL, $edit, t('Save content type')); + $this->assertText(strip_tags(t('The content type %name has been updated.', array('%name' => t('Article'))))); + + // Create a test node. + $this->drupalGet('node/add/' . $content_type); + $this->assertResponse(200); + + // Save a custom meta tag. + $edit = array( + 'metatags[und][abstract][value]' => '[node:title] ponies', + 'title' => 'Who likes magic', + ); + + // A preview may be optionally performed. Core allows three combinations: + // * 0 = Disallowed. + // * 1 = Optional. + // * 2 = Required. + if (($option === 1 && $preview) || $option === 2) { + $this->drupalPost(NULL, $edit, t('Preview')); + $this->drupalPost(NULL, array(), t('Save')); + } + else { + $this->drupalPost(NULL, $edit, t('Save')); + } + $this->assertResponse(200); + + // Verify the title is using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.node.with_i18n.test b/sites/all/modules/contrib/metatag/tests/metatag.node.with_i18n.test new file mode 100644 index 00000000..11effe1a --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.node.with_i18n.test @@ -0,0 +1,118 @@ + 'Metatag core node tests with i18n', + 'description' => 'Test Metatag node config integration with the i18n module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need the i18n and i18n_strings modules. + $modules[] = 'i18n'; + $modules[] = 'i18n_string'; + + // Enable all of the modules that are needed. + parent::setUp($modules); + + // Add more locales. + $this->setupLocales(); + + // Set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + // From i18n. + 'translate admin strings', + 'translate user-defined strings', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Reload the translations. + drupal_flush_all_caches(); + module_load_include('admin.inc', 'i18n_string'); + i18n_string_refresh_group('metatag'); + } + + /** + * Test translations of the main node configuration. + */ + public function testI18nNodeConfig() { + // Plan out the different translation string tests. + $string_en = 'It is a node page!'; + $config_name = 'metatag_config:node:title'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Load the meta tags. + $instance = 'node'; + $config = metatag_config_load($instance); + + // Set something specific as the homepage. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the node's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the node title tag.'); + } + + /** + * Test translations of the 'page' content type configuration. + */ + public function testI18nNodePageConfig() { + // Plan out the different translation string tests. + $string_en = 'It is a node page page!'; + $config_name = 'metatag_config:node:page:title'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Create a new config object for the node:page structure. + $config = new StdClass(); + $config->instance = 'node:page'; + + // Set an example tag. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the node's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the node title tag.'); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.output_caching.test b/sites/all/modules/contrib/metatag/tests/metatag.output_caching.test new file mode 100644 index 00000000..f29f37d1 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.output_caching.test @@ -0,0 +1,127 @@ + 'Metatag: output caching', + 'description' => 'Test the output caching functionality in Metatag.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * Test how user tokens are handled when cache is enabled. + */ + public function testUserTokensCacheEnabled() { + // Enable output caching. + variable_set('metatag_cache_output', TRUE); + + // Create two user accounts. + $account1 = $this->drupalCreateUser(); + $account2 = $this->drupalCreateUser(); + + // Log in the first account. + $this->drupalLogin($account1); + + // Load the test page. + $this->drupalGet('account-test-page'); + $this->assertResponse(200); + + // Verify the page loaded correctly and has the correct title. + $this->assertText('Test page for user tokens.'); + $this->assertText('Hello ' . $account1->name); + $xpath = $this->xpath("//h1"); + $this->verbose($xpath); + $this->assertEqual(trim((string) $xpath[0]), 'Hello ' . $account1->name); + + // Confirm the page title itself. + $this->assertTitle('Hello ' . $account1->name . ' | Drupal'); + + // Log out the user. + $this->drupalLogout() . + // Log in the second account. + $this->drupalLogin($account2); + + // Load the test page. + $this->drupalGet('account-test-page'); + $this->assertResponse(200); + + // Verify the page loaded correctly and now shows the second user account's + // name on the page. + $this->assertText('Test page for user tokens.'); + $this->assertText('Hello ' . $account2->name); + $xpath = $this->xpath("//h1"); + $this->verbose($xpath); + $this->assertEqual(trim((string) $xpath[0]), 'Hello ' . $account2->name); + + // Confirm the page title has not been updated, which is as designed. + $this->assertTitle('Hello ' . $account1->name . ' | Drupal'); + $this->assertNoTitle('Hello ' . $account2->name . ' | Drupal'); + } + + /** + * Test how user tokens are handled when cache is Disabled. + */ + public function testUserTokensCacheDisabled() { + // Disable output caching. + variable_set('metatag_cache_output', FALSE); + + // Create two user accounts. + $account1 = $this->drupalCreateUser(); + $account2 = $this->drupalCreateUser(); + + // Log in the first account. + $this->drupalLogin($account1); + + // Load the test page. + $this->drupalGet('account-test-page'); + $this->assertResponse(200); + + // Verify the page loaded correctly and has the correct title. + $this->assertText('Test page for user tokens.'); + $this->assertText('Hello ' . $account1->name); + $xpath = $this->xpath("//h1"); + $this->verbose($xpath); + $this->assertEqual(trim((string) $xpath[0]), 'Hello ' . $account1->name); + + // Confirm the page title itself. + $this->assertTitle('Hello ' . $account1->name . ' | Drupal'); + + // Log out the user. + $this->drupalLogout(); + + // Log in the second account. + $this->drupalLogin($account2); + + // Load the test page. + $this->drupalGet('account-test-page'); + $this->assertResponse(200); + + // Verify the page loaded correctly and now shows the second user account's + // name on the page. + $this->assertText('Test page for user tokens.'); + $this->assertText('Hello ' . $account2->name); + $xpath = $this->xpath("//h1"); + $this->verbose($xpath); + $this->assertEqual(trim((string) $xpath[0]), 'Hello ' . $account2->name); + + // Confirm the page title has changed, i.e. it shows the second account name + // rather than the first. + $this->assertNoTitle('Hello ' . $account1->name . ' | Drupal'); + $this->assertTitle('Hello ' . $account2->name . ' | Drupal'); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.string_handling.test b/sites/all/modules/contrib/metatag/tests/metatag.string_handling.test new file mode 100644 index 00000000..77754a6f --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.string_handling.test @@ -0,0 +1,276 @@ + 'Metatag core tests for string handling', + 'description' => "Tests Metatag's string handling.", + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + parent::setUp($modules); + + $content_type = 'page'; + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'delete any ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // This permission is required in order to create new revisions. + 'administer nodes', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + } + + /** + * Tests that a meta tag with single quote is not double escaped. + */ + function testSingleQuote() { + $this->_testAString("bla'bleblu"); + } + + /** + * Tests that a meta tag with a double quote is not double escaped. + */ + function testDoubleQuote() { + $this->_testAString('bla"bleblu'); + } + + /** + * Tests that a meta tag with an ampersand is not double escaped. + */ + function testAmpersand() { + $this->_testAString("blable&blu"); + } + + /** + * Tests that specific strings are not double escaped. + */ + function _testAString($string) { + $this->_testConfig($string); + $this->_testNode($string); + $this->_testEncodedField($string); + } + + /** + * Tests that a specific config string is not double encoded. + */ + function _testConfig($string) { + // The original strings. + $title_original = 'Title: ' . $string; + $desc_original = 'Description: ' . $string; + // The strings after they're encoded, but quotes will not be encoded. + $title_encoded = htmlentities($title_original, ENT_QUOTES); + $desc_encoded = htmlentities($desc_original, ENT_QUOTES); + // The strings double-encoded, to make sure the tags aren't broken. + $title_encodeded = htmlentities($title_encoded, ENT_QUOTES); + $desc_encodeded = htmlentities($desc_encoded, ENT_QUOTES); + + // Test the front page. + $instance = 'global:frontpage'; + + // Save the main node configuration form to assign the description tag. + $edit = array( + // Just use [node:title] to avoid problems with the default suffix. + 'metatags[und][title][value]' => $title_original, + // Save the original string. + 'metatags[und][description][value]' => $desc_original, + ); + $this->drupalPost('admin/config/search/metatags/config/' . $instance, $edit, 'Save'); + $this->assertResponse(200); + + // Load the configuration object. + $result = db_select('metatag_config', 'mc') + ->fields('mc', array('config')) + ->condition('mc.instance', $instance) + ->execute() + ->fetchAssoc(); + + // Unserialize the configuration. + $config = unserialize($result['config']); + + // Make sure the title tag is stored correctly. + $this->assertEqual($title_original, $config['title']['value'], 'The title tag was stored in its original format.'); + $this->assertNotEqual($title_encoded, $config['title']['value'], 'The title tag was not stored in an encoded format.'); + $this->assertNotEqual($title_encodeded, $config['title']['value'], 'The title tag was not stored in a double-encoded format.'); + + // Make sure the description tag is stored correctly. + $this->assertEqual($desc_original, $config['description']['value'], 'The description tag was stored in its original format.'); + $this->assertNotEqual($desc_encoded, $config['description']['value'], 'The description tag was not stored in an encoded format.'); + $this->assertNotEqual($desc_encodeded, $config['description']['value'], 'The description tag was not stored in a double-encoded format.'); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200); + + // assertTitle() uses xpath, which parses the HTML, so all of the HTML + // entities will be converted automagically. + $this->assertTitle($title_original, 'Confirmed the node title tag is available in its original format.'); + $this->assertNoTitle($title_encoded, 'Confirmed the node title tag is not double-encoded.'); + $this->assertNoTitle($title_encodeded, 'Confirmed the node title tag is not double-double-encoded?'); + + // The page title should be HTML encoded; have to do this check manually + // because assertRaw() checks the raw HTML, not the parsed strings like + // xpath does. + $this->assertRaw('' . $title_original . '', 'Confirmed the node title tag is available in its original format.'); + $this->assertNoRaw('' . $title_encoded . '', 'Confirmed the node title tag is not double-encoded.'); + $this->assertNoRaw('' . $title_encodeded . '', 'Confirmed the node title tag is not double-double-encoded?'); + + // Again, with xpath the HTML entities will be parsed automagically. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual($xpath[0]['content'], $desc_original); + $this->assertNotEqual($xpath[0]['content'], $desc_encoded); + $this->assertNotEqual($xpath[0]['content'], $desc_encodeded); + } + + /** + * Tests that a specific node string is not double escaped. + */ + function _testNode($string) { + // The original strings. + $title_original = 'Title: ' . $string; + $desc_original = 'Description: ' . $string; + + // The strings after they're encoded, but quotes will not be encoded. + $title_encoded = htmlentities($title_original, ENT_QUOTES); + $desc_encoded = htmlentities($desc_original, ENT_QUOTES); + + // The strings double-encoded, to make sure the tags aren't broken. + $title_encodeded = htmlentities($title_encoded, ENT_QUOTES); + $desc_encodeded = htmlentities($desc_encoded, ENT_QUOTES); + + // Create a node and check how the meta tag is displayed. + $node = $this->drupalCreateNode(array( + 'title' => $title_original, + 'body' => array( + LANGUAGE_NONE => array( + array( + 'value' => $desc_original, + 'format' => filter_default_format(), + ), + ), + ), + 'metatags' => array( + LANGUAGE_NONE => array( + 'abstract' => array('value' => '[node:title]'), + ), + ), + )); + + // Page titles have a suffix added automatically. + $suffix = ' | ' . variable_get('site_name', 'Drupal'); + + // Load the node page. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // assertTitle() uses xpath, which parses the HTML, so all of the HTML + // entities will be converted automagically. + $this->assertTitle($title_original . $suffix, 'Confirmed the node title tag is available in its original format.'); + $this->assertNoTitle($title_encoded . $suffix, 'Confirmed the node title tag is not double-encoded.'); + $this->assertNoTitle($title_encodeded . $suffix, 'Confirmed the node title tag is not double-double-encoded?'); + + // The page title should be HTML encoded; have to do this check manually + // because assertRaw() checks the raw HTML, not the parsed strings like + // xpath does. + $this->assertRaw('' . $title_original . $suffix . '', 'Confirmed the node title tag is encoded.'); + + // Test a few other versions of the title, to ensure it isn't broken + // on another tag. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual($xpath[0]['content'], $title_original); + $this->assertNotEqual($xpath[0]['content'], $title_encoded); + $this->assertNotEqual($xpath[0]['content'], $title_encodeded); + + // Again, with xpath the HTML entities will be parsed automagically. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual($xpath[0]['content'], $desc_original); + $this->assertNotEqual($xpath[0]['content'], $desc_encoded); + $this->assertNotEqual($xpath[0]['content'], $desc_encodeded); + + // Normal meta tags should be encoded properly. + $this->assertRaw('"' . $desc_encoded . '"', 'Confirmed the node "description" meta tag string was encoded properly.'); + // Normal meta tags with HTML entities should be displayed in their original + // format. + $this->assertNoRaw('"' . $desc_original . '"', 'Confirmed the node "description" meta tag string does not show in its original form.'); + // Normal meta tags should not be double-encoded. + $this->assertNoRaw('"' . $desc_encodeded . '"', 'Confirmed the node "description" meta tag string was not double-encoded.'); + } + + /** + * Tests that fields with encoded HTML entities will not be double-encoded. + */ + function _testEncodedField($string) { + // The original strings. + $title_original = 'Title: ' . $string; + $desc_original = 'Description: ' . $string; + + // The strings after they're encoded, but quotes will not be encoded. + $desc_encoded = htmlentities($desc_original, ENT_QUOTES); + + // The strings double-encoded, to make sure the tags aren't broken. + $desc_encodeded = htmlentities($desc_encoded, ENT_QUOTES); + + // Create a node and check how the meta tag is displayed. + $node = $this->drupalCreateNode(array( + 'title' => $title_original, + 'body' => array( + LANGUAGE_NONE => array( + array( + 'value' => $desc_encoded, + 'format' => filter_default_format(), + ), + ), + ), + )); + + // Load the node page. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // With xpath the HTML entities will be parsed automagically. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual($xpath[0]['content'], $desc_original); + $this->assertNotEqual($xpath[0]['content'], $desc_encoded); + $this->assertNotEqual($xpath[0]['content'], $desc_encodeded); + + // Normal meta tags should be encoded properly. + $this->assertRaw('"' . $desc_encoded . '"', 'Confirmed the node "description" meta tag string was encoded properly.'); + // Normal meta tags with HTML entities should be displayed in their original + // format. + $this->assertNoRaw('"' . $desc_original . '"', 'Confirmed the node "description" meta tag string does not show in its original form.'); + // Normal meta tags should not be double-encoded. + $this->assertNoRaw('"' . $desc_encodeded . '"', 'Confirmed the node "description" meta tag string was not double-encoded.'); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.string_handling_with_i18n.test b/sites/all/modules/contrib/metatag/tests/metatag.string_handling_with_i18n.test new file mode 100644 index 00000000..602d2286 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.string_handling_with_i18n.test @@ -0,0 +1,32 @@ + 'Metatag core tests for string handling w i18n', + 'description' => "Tests Metatag's string handling when i18n is enabled.", + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + parent::setUp(array('i18n', 'i18n_string')); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.tags.test b/sites/all/modules/contrib/metatag/tests/metatag.tags.test new file mode 100644 index 00000000..81bb325a --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.tags.test @@ -0,0 +1,297 @@ + 'Metatag tags: Basic', + 'description' => 'Test the basic meta tags.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * {@inheritdoc} + */ + public $tags = array( + 'abstract', + 'cache-control', + 'canonical', + 'content-language', + 'description', + 'expires', + 'generator', + 'geo.placename', + 'geo.position', + 'geo.region', + 'icbm', + 'image_src', + 'keywords', + 'news_keywords', + 'next', + 'original-source', + 'pragma', + 'prev', + 'rating', + 'referrer', + 'refresh', + // @todo 'revisit-after', + 'rights', + 'robots', + // 'set_cookie', + 'shortlink', + 'standout', + 'title', + ); + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'abstract'. + */ + public function abstract_test_field_xpath() { + return "//textarea[@name='metatags[und][abstract][value]']"; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'cache_control'. + */ + public function cache_control_test_output_xpath() { + return "//meta[@http-equiv='cache-control']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'canonical'. + */ + public function canonical_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'canonical'. + */ + public function canonical_test_output_xpath() { + return "//link[@rel='canonical']"; + } + + /** + * Implements {meta_tag_name}_test_name_attribute() for 'content_language'. + */ + public function content_language_test_name_attribute() { + return 'http-equiv'; + } + + /** + * Implements {meta_tag_name}_test_tag_name() for 'content_language'. + */ + public function content_language_test_tag_name() { + return 'content-language'; + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'description'. + */ + public function description_test_field_xpath() { + return "//textarea[@name='metatags[und][description][value]']"; + } + + /** + * Implements {meta_tag_name}_test_tag_name() for 'geo_placename'. + */ + public function geo_placename_test_tag_name() { + return 'geo.placename'; + } + + /** + * Implements {meta_tag_name}_test_tag_name() for 'geo_position'. + */ + public function geo_position_test_tag_name() { + return 'geo.position'; + } + + /** + * Implements {meta_tag_name}_test_tag_name() for 'geo_region'. + */ + public function geo_region_test_tag_name() { + return 'geo.region'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'image_src'. + */ + public function image_src_test_output_xpath() { + return "//link[@rel='image_src']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'image_src'. + */ + public function image_src_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'image_src'. + */ + public function image_src_test_value() { + return 'http://example.com/images/test-image.gif'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'next'. + */ + public function next_test_output_xpath() { + return "//link[@rel='next']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'next'. + */ + public function next_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_tag_name() for 'original-source'. + */ + public function original_source_test_tag_name() { + return 'original-source'; + } + + /** + * Implements {meta_tag_name}_test_name_attribute() for 'pragma'. + */ + public function pragma_test_name_attribute() { + return 'http-equiv'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'prev'. + */ + public function prev_test_output_xpath() { + return "//link[@rel='prev']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'prev'. + */ + public function prev_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_key() for 'rating'. + */ + public function rating_test_key() { + return 'metatags[und][rating][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'general'. + */ + public function rating_test_value() { + return 'general'; + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'rating'. + */ + public function rating_test_field_xpath() { + return "//select[@name='metatags[und][rating][value]']"; + } + + /** + * Implements {meta_tag_name}_test_key() for 'referrer'. + */ + public function referrer_test_key() { + return 'metatags[und][referrer][value]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'referrer'. + */ + public function referrer_test_value() { + return 'origin'; + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'referrer'. + */ + public function referrer_test_field_xpath() { + return "//select[@name='metatags[und][referrer][value]']"; + } + + /** + * Implements {meta_tag_name}_test_name_attribute() for 'refresh'. + */ + public function refresh_test_name_attribute() { + return 'http-equiv'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'robots'. + */ + public function robots_test_key() { + return 'metatags[und][robots][value][index]'; + } + + /** + * Implements {meta_tag_name}_test_value() for 'robots'. + */ + public function robots_test_value() { + return TRUE; + } + + /** + * Implements {meta_tag_name}_test_field_xpath() for 'robots'. + */ + public function robots_test_field_xpath() { + return "//input[@name='metatags[und][robots][value][index]' and @type='checkbox']"; + } + + /** + * Implements {meta_tag_name}_test_value() for 'revisit-after'. + */ + public function revisit_after_test_value() { + return 2; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'shortlink'. + */ + public function shortlink_test_output_xpath() { + return "//link[@rel='shortlink']"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'shortlink'. + */ + public function shortlink_test_value_attribute() { + return 'href'; + } + + /** + * Implements {meta_tag_name}_test_output_xpath() for 'title'. + */ + public function title_test_output_xpath() { + return "//title"; + } + + /** + * Implements {meta_tag_name}_test_value_attribute() for 'title'. + */ + public function title_test_value_attribute() { + return ''; + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.tags_helper.test b/sites/all/modules/contrib/metatag/tests/metatag.tags_helper.test new file mode 100644 index 00000000..c2d22e9f --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.tags_helper.test @@ -0,0 +1,267 @@ +createAdminUser(); + $this->drupalLogin($account); + } + + /** + * Tests that this module's tags are available. + */ + function testTagsArePresent() { + // Load the global config. + $this->drupalGet('admin/config/search/metatags/config/global'); + $this->assertResponse(200); + + // Confirm the various meta tags are available. + foreach ($this->tags as $tag) { + // Convert tag names to something more suitable for a function name. + $tag_name = str_replace(array('.', '-', ':'), '_', $tag); + + // Look for a custom method named "{$tag_name}_test_field_xpath", if found + // use that method to get the xpath definition for this meta tag, + // otherwise it defaults to just looking for a text input field. + $method = "{$tag_name}_test_field_xpath"; + if (method_exists($this, $method)) { + $xpath = $this->$method(); + } + else { + $xpath = "//input[@name='metatags[und][{$tag}][value]' and @type='text']"; + } + $this->assertFieldByXPath($xpath, NULL, format_string('The "%tag" tag field was found.', array('%tag' => $tag))); + } + } + + /** + * Confirm that each tag can be saved and that the output of each tag is + * correct. + */ + function testTagsInputOutput() { + // Load the global config. + $this->drupalGet('admin/config/search/metatags/config/global'); + $this->assertResponse(200); + + // Update the Global defaults and test them. + $all_values = $values = array(); + foreach ($this->tags as $tag_raw) { + // Convert tag names to something more suitable for a function name. + $tag_name = str_replace(array('.', '-', ':', ' '), '_', $tag_raw); + + // Look for a custom method named "{$tag_name}_test_key", if found use + // that method to get the test string for this meta tag, otherwise it + // defaults to the meta tag's name. + $method = "{$tag_name}_test_key"; + if (method_exists($this, $method)) { + $test_key = $this->$method(); + } + else { + $test_key = "metatags[und][{$tag_raw}][value]"; + } + + // Look for a custom method named "{$tag_name}_test_value", if found use + // that method to get the test string for this meta tag, otherwise it + // defaults to just generating a random string. + $method = "{$tag_name}_test_value"; + if (method_exists($this, $method)) { + $test_value = $this->$method(); + } + else { + // Generate a random string. + $test_value = $this->getTestTagValue(); + } + + $values[$test_key] = $test_value; + + // Look for a custom method named "{$tag_name}_test_preprocess_output", if + // found use that method provide any additional processing on the value + // e.g. adding a prefix. + $method = "{$tag_name}_test_preprocess_output"; + if (method_exists($this, $method)) { + $test_value = $this->$method($test_value); + } + + $all_values[$tag_name] = $test_value; + } + $this->drupalPost(NULL, $values, 'Save'); + $this->assertText(strip_tags(t('The meta tag defaults for @label have been saved.', array('@label' => 'Global')))); + + // Load the test page. + $this->drupalGet('moosqueakoinkmeow'); + $this->assertResponse(200); + $this->assertText(t('Test page.')); + + // Look for the values. + foreach ($this->tags as $tag_raw) { + // Convert tag names to something more suitable for a function name. + $tag_name = str_replace(array('.', '-', ':', ' '), '_', $tag_raw); + + // Verify this meta tag was output. + $this->assertTrue(!empty($all_values[$tag_name])); + + // Look for a custom method named "{$tag_name}_test_output_xpath", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to just looking for a meta tag matching: + // <$test_tag $test_name_attribute=$tag_name $test_value_attribute=$value /> + $method = "{$tag_name}_test_output_xpath"; + if (method_exists($this, $method)) { + $xpath_string = $this->$method(); + } + else { + // Look for a custom method named "{$tag_name}_test_tag", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to $this->test_tag. + $method = "{$tag_name}_test_tag"; + if (method_exists($this, $method)) { + $xpath_tag = $this->$method(); + } + else { + $xpath_tag = $this->test_tag; + } + + // Look for a custom method named "{$tag_name}_test_name_attribute", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to $this->test_name_attribute. + $method = "{$tag_name}_test_name_attribute"; + if (method_exists($this, $method)) { + $xpath_name_attribute = $this->$method(); + } + else { + $xpath_name_attribute = $this->test_name_attribute; + } + + // Look for a custom method named "{$tag_name}_test_tag_name", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to $tag_name. + $method = "{$tag_name}_test_tag_name"; + if (method_exists($this, $method)) { + $xpath_name_tag = $this->$method(); + } + else { + $xpath_name_tag = $this->getTestTagName($tag_name); + } + + // Compile the xpath. + $xpath_string = "//{$xpath_tag}[@{$xpath_name_attribute}='{$xpath_name_tag}']"; + } + + // Something should have been found. + $this->assertTrue(!empty($xpath_string)); + + // Look for a custom method named "{$tag_name}_test_value_attribute", if + // found use that method to get the xpath definition for this meta tag, + // otherwise it defaults to $this->test_value_attribute. + $method = "{$tag_name}_test_value_attribute"; + if (method_exists($this, $method)) { + $xpath_value_attribute = $this->$method(); + } + else { + $xpath_value_attribute = $this->test_value_attribute; + } + + // Extract the meta tag from the HTML. + $xpath = $this->xpath($xpath_string); + $this->assertEqual(count($xpath), 1, format_string('One @name tag found.', array('@name' => $tag_name))); + + // Most meta tags have an attribute, but some don't. + if (!empty($xpath_value_attribute)) { + $this->assertTrue($xpath_value_attribute); + $this->assertTrue(isset($xpath[0][$xpath_value_attribute])); + // Help with debugging. + if (!isset($xpath[0][$xpath_value_attribute])) { + $this->verbose($xpath, $tag_name . ': ' . $xpath_string); + } + else { + if ((string) $xpath[0][$xpath_value_attribute] != $all_values[$tag_name]) { + $this->verbose($xpath, $tag_name . ': ' . $xpath_string); + } + $this->assertTrue($xpath[0][$xpath_value_attribute]); + $this->assertEqual($xpath[0][$xpath_value_attribute], $all_values[$tag_name]); + // , "The meta tag was found with the expected value."); + } + } + else { + $this->verbose($xpath, $tag_name . ': ' . $xpath_string); + $this->assertTrue((string) $xpath[0]); + $this->assertEqual((string) $xpath[0], $all_values[$tag_name], "The meta tag was found with the expected value."); + } + } + } + + /** + * Convert a tag's internal name to the string which is actually used in HTML. + * + * The meta tag internal name will be machine names, i.e. only contain a-z, + * A-Z, 0-9 and the underline character. Meta tag names will actually contain + * any possible character. + * + * @param string $tag_name + * The tag name to be converted. + * + * @return string + * The converted tag name. + */ + public function getTestTagName($tag_name) { + return $tag_name; + } + + /** + * Generate a random value for testing meta tag fields. + * + * As a reasonable default, this will generating two words of 8 characters + * each with simple machine name -style strings. + * + * @return string + * A normal string. + */ + public function getTestTagValue() { + return $this->randomMachineName() . ' ' . $this->randomMachineName(); + } + + /** + * Generate a URL for an image. + * + * @return string + * An absolute URL to a non-existant image. + */ + public function randomImageUrl() { + return 'http://www.example.com/images/' . $this->randomMachineName() . '.png'; + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.term.test b/sites/all/modules/contrib/metatag/tests/metatag.term.test new file mode 100644 index 00000000..993b7255 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.term.test @@ -0,0 +1,169 @@ + 'Metatag core tests for terms', + 'description' => 'Test Metatag edit functionality for terms.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need the Path module to set a alias which can then be loaded. + $modules[] = 'path'; + parent::setUp($modules); + } + + /** + * Tests creation of a standard entity. + */ + public function testEntityCreationWorkflow() { + $content_type = 'metatag_test'; + $content_type_path = str_replace('_', '-', $content_type); + $content_type_label = 'Test'; + $vocab_name = 'test_vocab'; + $term_name = 'Who likes magic'; + $term_path = 'term-test'; + + // Create a content type. + $this->createContentType($content_type, $content_type_label); + + // Create a vocabulary. + $vocabulary = $this->createVocabulary($vocab_name, $content_type); + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'delete any ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // Needed for the vocabulary. + 'administer taxonomy', + 'edit terms in ' . $vocabulary->vid, + 'delete terms in ' . $vocabulary->vid, + + // Needed for the Path module. + 'create url aliases', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Assign default values for the new vocabulary. + // Load the "add default configuration" page. + $this->drupalGet('admin/config/search/metatags/config/add'); + $this->assertResponse(200); + + // Verify the page loaded correct. + $this->assertText(t('Select the type of default meta tags you would like to add.')); + + // Submit the initial form to select an entity bundle. + $this->drupalPost(NULL, array( + 'instance' => 'taxonomy_term:' . $vocabulary->name, + ), t('Add and configure')); + $this->assertResponse(200); + + // @todo Update this to extract the H1 tag. + $this->assertText(strip_tags('Taxonomy term: ' . $vocabulary->name)); + + // Submit the form with some values. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[term:name]', + ), t('Save')); + $this->assertResponse(200); + + // Verify the page loaded correct. + $this->assertText(strip_tags(t('The meta tag defaults for @label have been saved.', array('@label' => 'Taxonomy term: ' . $vocabulary->name)))); + + // Verify that the user was redirected to the settings page again. + $this->assertEqual($this->getUrl(), url('admin/config/search/metatags', array('absolute' => TRUE))); + + // Create a test term. + // Load the term form. + $this->drupalGet('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add'); + $this->assertResponse(200); + + // Verify the page loaded correctly. + // @todo Update this to extract the H1 tag. + // $this->assertText(strip_tags(t('Create @name', array('@name' => $vocabulary->name)))); + // Verify that it's possible to submit values to the form. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[term:name] ponies', + 'name' => $term_name, + 'path[alias]' => $term_path, + ), t('Save')); + $this->assertResponse(200); + + // Verify that the node saved correctly. + $t_args = array('%name' => $term_name); + // This doesn't work for some reason, it seems the HTML is stripped off + // during output so the %name's standard Drupal wrappers don't match. + // $this->assertText(t('Created new term %name.', $t_args)); + // .. so this has to be done instead. + $this->assertText(strip_tags(t('Created new term %name.', $t_args))); + + // Verify the term data saved correctly. + $this->drupalGet($term_path); + $this->assertResponse(200); + + // Try to extract the 'edit' link. + $xpaths = $this->xpath("//ul/li/a"); + $matches = array(); + $tid = 0; + if (!empty($xpaths)) { + foreach ($xpaths as $xpath) { + $attributes = $xpath->attributes(); + if (!empty($attributes['href'])) { + if (preg_match('@taxonomy/term/(\d+)/edit$@', $attributes['href'], $matches)) { + $tid = $matches[1]; + } + } + } + } + + // Presuing a term ID was found, load the term. + if (!empty($tid)) { + $term = taxonomy_term_load($tid); + + // Only the non-default values are stored. + $expected = array( + 'und' => array( + 'abstract' => array( + 'value' => '[term:name] ponies', + ), + ), + ); + $this->assertEqual($expected, $term->metatags); + } + + // This shouldn't happen, it indicates a problem. + else { + $this->fail(t('Could not determine the ID for created term.')); + } + + // Verify the title is using the custom default for this vocabulary. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], "Who likes magic ponies"); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.term.with_i18n.test b/sites/all/modules/contrib/metatag/tests/metatag.term.with_i18n.test new file mode 100644 index 00000000..b4736c69 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.term.with_i18n.test @@ -0,0 +1,118 @@ + 'Metatag core term tests with i18n', + 'description' => 'Test Metatag taxonomy config integration with the i18n module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need the i18n and i18n_strings modules. + $modules[] = 'i18n'; + $modules[] = 'i18n_string'; + + // Enable all of the modules that are needed. + parent::setUp($modules); + + // Add more locales. + $this->setupLocales(); + + // Set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + // From i18n. + 'translate admin strings', + 'translate user-defined strings', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Reload the translations. + drupal_flush_all_caches(); + module_load_include('admin.inc', 'i18n_string'); + i18n_string_refresh_group('metatag'); + } + + /** + * Test translations of the main taxonomy term configuration. + */ + public function testI18nTermConfig() { + // Plan out the different translation string tests. + $string_en = 'It is a term page!'; + $config_name = 'metatag_config:taxonomy_term:title'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Load the meta tags. + $instance = 'taxonomy_term'; + $config = metatag_config_load($instance); + + // Set something specific as the homepage. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the term's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the taxonomy term title tag.'); + } + + /** + * Test translations of the 'tags' vocabulary configuration. + */ + public function testI18nTermTagsConfig() { + // Plan out the different translation string tests. + $string_en = 'It is a taxonomy term Tags page!'; + $config_name = 'metatag_config:taxonomy_term:tags:title'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Create a new config object for the taxonomy_term:tags structure. + $config = new StdClass(); + $config->instance = 'taxonomy_term:tags'; + + // Set an example tag. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the term's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the taxonomy term title tag.'); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.unit.test b/sites/all/modules/contrib/metatag/tests/metatag.unit.test new file mode 100644 index 00000000..9c6ed01b --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.unit.test @@ -0,0 +1,147 @@ + 'Metatag unit tests', + 'description' => 'Test basic meta tag functionality for entities.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * Test the metatag_config_load_with_defaults() function. + */ + public function testConfigLoadDefaults() { + // Load the global defaults, inc the fake entity. + $defaults = metatag_config_load_with_defaults('test:foo'); + + // Load the example values and verify they're the same as the globals. + $extra_tags = array( + // Fake meta tag. + 'test:foo' => array('value' => 'foobar'), + ); + $new_values = array_merge($extra_tags, $this->getTestDefaults()); + + // Confirm that the values are equal. + $this->assertEqual($defaults, $new_values); + } + + /** + * Test the basic entity handling. + */ + public function testEntitySupport() { + $test_cases[1] = array('type' => 'node', 'bundle' => 'article', 'expected' => TRUE); + $test_cases[2] = array('type' => 'node', 'bundle' => 'page', 'expected' => TRUE); + $test_cases[3] = array('type' => 'node', 'bundle' => 'invalid-bundle', 'expected' => FALSE); + $test_cases[4] = array('type' => 'user', 'expected' => TRUE); + $test_cases[5] = array('type' => 'taxonomy_term', 'bundle' => 'tags', 'expected' => TRUE); + $test_cases[6] = array('type' => 'taxonomy_term', 'bundle' => 'invalid-bundle', 'expected' => FALSE); + foreach ($test_cases as $test_case) { + $test_case += array('bundle' => NULL); + $this->assertMetatagEntitySupportsMetatags($test_case['type'], $test_case['bundle'], $test_case['expected']); + } + + // Disable meta tags for these. + metatag_entity_type_disable('node', 'page'); + metatag_entity_type_disable('user'); + + $test_cases[2]['expected'] = FALSE; + $test_cases[4]['expected'] = FALSE; + $test_cases[6]['expected'] = FALSE; + foreach ($test_cases as $test_case) { + $test_case += array('bundle' => NULL); + $this->assertMetatagEntitySupportsMetatags($test_case['type'], $test_case['bundle'], $test_case['expected']); + } + } + + /** + * Confirm an entity supports meta tags. + * + * @param string $entity_type + * The name of the entity type to test. + * @param string $bundle + * The name of the entity bundle to test. + * @param array $expected + * The expected results. + * + * @return object + * An assertion. + */ + function assertMetatagEntitySupportsMetatags($entity_type, $bundle, $expected) { + $entity = entity_create_stub_entity($entity_type, array(0, NULL, $bundle)); + return $this->assertEqual( + metatag_entity_supports_metatags($entity_type, $bundle), + $expected, + t("metatag_entity_supports_metatags(:type, :bundle) is :expected", array( + ':type' => var_export($entity_type, TRUE), + ':bundle' => var_export($bundle, TRUE), + ':expected' => var_export($expected, TRUE), + )) + ); + } + + /** + * Test the metatag_config_instance_label() function. + */ + public function testConfigLabels() { + $test_cases = array( + 'node' => 'Node', + 'node:article' => 'Node: Article', + 'node:article:c' => 'Node: Article: Unknown (c)', + 'node:b' => 'Node: Unknown (b)', + 'node:b:c' => 'Node: Unknown (b): Unknown (c)', + 'a' => 'Unknown (a)', + 'a:b' => 'Unknown (a): Unknown (b)', + 'a:b:c' => 'Unknown (a): Unknown (b): Unknown (c)', + 'a:b:c:d' => 'Unknown (a): Unknown (b): Unknown (c): Unknown (d)', + ); + + foreach ($test_cases as $input => $expected_output) { + drupal_static_reset('metatag_config_instance_label'); + $actual_output = metatag_config_instance_label($input); + $this->assertEqual($actual_output, $expected_output); + } + } + + /** + * Test the _metatag_config_instance_sort() function. + */ + public function testConfigInstanceSort() { + $input = array( + 'node:article', + 'global:frontpage', + 'file', + 'node:page', + 'global', + 'node', + 'global:404', + ); + usort($input, '_metatag_config_instance_sort'); + $this->assertIdentical($input, array( + 'global', + 'global:404', + 'global:frontpage', + 'file', + 'node', + 'node:article', + 'node:page', + )); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.user.test b/sites/all/modules/contrib/metatag/tests/metatag.user.test new file mode 100644 index 00000000..b2471e07 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.user.test @@ -0,0 +1,94 @@ + 'Metatag core tests for users', + 'description' => 'Test Metatag edit functionality for users.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token'), + ); + } + + /** + * Tests creation of a standard entity. + */ + public function testEntityCreationWorkflow() { + // Create an admin user and log them in. + if (!isset($this->adminUser)) { + $this->adminUser = $this->createAdminUser(); + } + $this->drupalLogin($this->adminUser); + + // Assign default values for the new vocabulary. + // Load the page for overriding the User configuration. + $this->drupalGet('admin/config/search/metatags/config/user'); + $this->assertResponse(200); + + // Verify the page loaded correct. + // @todo Update this to extract the H1 tag. + $this->assertText(strip_tags('User')); + + // Submit the form with some values. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[user:name]', + ), t('Save')); + $this->assertResponse(200); + + // Verify the page loaded correct. + $this->assertText(strip_tags(t('The meta tag defaults for @label have been saved.', array('@label' => 'User')))); + + // Verify that the user was redirected to the settings page again. + $this->assertEqual($this->getUrl(), url('admin/config/search/metatags', array('absolute' => TRUE))); + + // Load the user's edit form. + $this->drupalGet('user/' . $this->adminUser->uid . '/edit'); + $this->assertResponse(200); + + // Verify the page loaded correctly. + // @todo Update this to extract the H1 tag. + // $this->assertText(strip_tags(t('Create @name', array('@name' => $vocabulary->name)))); + // Verify that it's possible to submit values to the form. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[user:name] ponies', + ), t('Save')); + $this->assertResponse(200); + + // Verify that the user object saved correctly. + // $t_args = array('%name' => $this->adminUser->name); + // This doesn't work for some reason, it seems the HTML is stripped off + // during output so the %name's standard Drupal wrappers don't match. + // $this->assertText(t('The changes have been saved.')); + // .. so this has to be done instead. + $this->assertText(strip_tags(t('The changes have been saved.'))); + + // Manually load the admin account. + $account = user_load($this->adminUser->uid); + + // Only the non-default values are stored. + $expected = array( + 'und' => array( + 'abstract' => array( + 'value' => '[user:name] ponies', + ), + ), + ); + $this->assertEqual($expected, $account->metatags); + + // Confirm the user profile tags work correctly. + $this->assertUserEntityTags($this->adminUser); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_config.test b/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_config.test new file mode 100644 index 00000000..26c9fad8 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_config.test @@ -0,0 +1,331 @@ + 'Metatag core tests with i18n: configs', + 'description' => 'Test Metatag configuration integration with the i18n module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need the i18n and i18n_strings modules. + $modules[] = 'i18n'; + $modules[] = 'i18n_string'; + + // Enable all of the modules that are needed. + parent::setUp($modules); + + // Add more locales. + $this->setupLocales(); + + // Set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + // From i18n. + 'translate admin strings', + 'translate user-defined strings', + // Needed for content type management. + 'bypass node access', + 'administer content types', + 'administer nodes', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Reload the translations. + drupal_flush_all_caches(); + module_load_include('admin.inc', 'i18n_string'); + i18n_string_refresh_group('metatag'); + } + + /** + * Test translation functionality with i18n on config defaults. + */ + public function testI18nDefaultConfig() { + // Plan out the different translation string tests. + $string_en = 'Drupal 7 (https://www.drupal.org)'; + $string_fr = 'French Drupal'; + $config_name = 'metatag_config:global:generator'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the homepage.'); + + // Confirm the page's title is what we set it to. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 1, 'Exactly one generator meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_en); + + // Confirm the string is present. + $this->searchTranslationPage($string_en, $config_name); + + // Get the translation string lid for the generator tag. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the generator tag.'); + + // Save the translation string. + $this->saveTranslationString($lid, $config_name, 'fr', $string_en, $string_fr); + + // Load the English front page again. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the default homepage.'); + + // Confirm the page's generator tag is what we set it to. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 1, 'Exactly one generator meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_en); + + // Load the French front page. + $this->drupalGet('fr'); + $this->assertResponse(200, 'Loaded the French homepage.'); + + // Confirm the generator string was translated. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 1, 'Exactly one generator meta tag found.'); + $this->assertEqual($xpath[0]['content'], $string_fr); + } + + /** + * Test translations of the custom configurations. + */ + public function testI18nCustomConfig() { + // Plan out the different translation string tests. + $string_en = 'Welcome to the homepage!'; + $string_fr = 'Bonjour pour le homepage!'; + $config_name = 'metatag_config:global:frontpage:title'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Load the front page's meta tags. + $instance = 'global:frontpage'; + $config = metatag_config_load($instance); + + // Set something specific as the homepage. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_en); + + // Get the translation string lid for the front page's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the front page title tag.'); + + // Save the translation string. + $this->saveTranslationString($lid, $config_name, 'fr', $string_en, $string_fr); + + // Load the English front page again. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the default homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_en); + + // Load the French front page. + $this->drupalGet('fr'); + $this->assertResponse(200, 'Loaded the French homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_fr); + } + + /** + * Confirm that translations will be deleted when configs are deleted. + */ + public function testI18nDeleteConfig() { + // Plan out the different translation string tests. + $string_en = 'Hey, an article!'; + $string_fr = 'Alors! Un article!'; + $config_name = 'metatag_config:node:article:title'; + + // Create a config for the 'article' content type's meta tags. + $instance = 'node:article'; + $label = t('Node: Article'); + $config = new StdClass(); + $config->instance = $instance; + $config->api_version = 1; + $config->disabled = FALSE; + $config->export_module = 'metatag'; + $config->config = array(); + + // Set something specific as the page title. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Load the 'delete' page. + $this->drupalGet('admin/config/search/metatags/config/' . $instance . '/delete'); + $this->assertResponse(200); + + // Confirm this is the correct page. + $this->assertText(t('Are you sure you want to delete the meta tag defaults for @label?', array('@label' => $label))); + $this->assertText(t('This action cannot be undone.')); + $this->assertFieldByName('op'); + $this->assertFieldByName('op', t('Confirm')); + + // Submit the form. + $this->drupalPost(NULL, array(), t('Confirm')); + $this->assertResponse(200); + $this->assertText(t('The meta tag defaults for @label have been deleted.', array('@label' => $label))); + + // Confirm the string has been removed. + $this->searchTranslationPage($string_en, $config_name, FALSE); + } + + /** + * Confirm that translations will be deleted when entity bundles are deleted. + */ + public function testI18nDeleteEntityBundle() { + // Plan out the different translation string tests. + $string_en = 'Hey, an article!'; + $string_fr = 'Alors! Un article!'; + $config_name = 'metatag_config:node:article:title'; + + // Create a config for the 'article' content type's meta tags. + $content_type = 'article'; + $content_type_label = t('Article'); + $instance = 'node:article'; + $instance_label = t('Node: Article'); + $config = new StdClass(); + $config->instance = $instance; + $config->api_version = 1; + $config->disabled = FALSE; + $config->export_module = 'metatag'; + $config->config = array(); + + // Set something specific as the page title. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_en, $config_name); + + // Load the 'delete' page. + $this->drupalGet('admin/structure/types/manage/' . $content_type); + $this->assertResponse(200); + + // Confirm this is the correct page. + $this->assertFieldByName('op', t('Delete content type')); + + // Submit the form. + $this->drupalPost(NULL, array(), t('Delete content type')); + $this->assertResponse(200); + + // Confirm this is the correct page. + $this->assertText(t('Are you sure you want to delete the content type @label?', array('@label' => $content_type_label))); + $this->assertText(t('This action cannot be undone.')); + $this->assertFieldByName('op'); + $this->assertFieldByName('op', t('Delete')); + + // Submit the form. + $this->drupalPost(NULL, array(), t('Delete')); + $this->assertResponse(200); + $this->assertText(t('The content type @label has been deleted.', array('@label' => $content_type_label))); + + // Confirm the config was deleted. + $config = metatag_config_load($instance); + $this->assertEqual($config, array()); + + // Confirm the string has been removed. + $this->searchTranslationPage($string_en, $config_name, FALSE); + } + + /** + * Test translations of the custom configurations. + */ + public function testI18nDifferentSourceLanguage() { + // Make French the default source locale. + variable_set('i18n_string_source_language', 'fr'); + + // Verify that the default language and source language are different. + $this->assertNotEqual(i18n_string_source_language(), language_default('language')); + + // Plan out the different translation string tests. + $string_en = 'Welcome to the homepage!'; + $string_fr = 'Bonjour pour le homepage!'; + $config_name = 'metatag_config:global:frontpage:title'; + + // Confirm the translation page exists and has some Metatag strings. + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Load the front page's meta tags. + $instance = 'global:frontpage'; + $config = metatag_config_load($instance); + + // Set something specific as the homepage. + $config->config['title']['value'] = $string_fr; + metatag_config_save($config); + + // Confirm the string is present now. + $this->searchTranslationPage($string_fr, $config_name); + + // Load the front page. + $this->drupalGet('fr'); + $this->assertResponse(200, 'Loaded the homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_fr); + + // Get the translation string lid for the front page's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the front page title tag.'); + + // Save the translation string. + $this->saveTranslationString($lid, $config_name, 'en', $string_fr, $string_en); + + // Load the English front page again. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the default homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_en); + + // Load the French front page. + $this->drupalGet('fr'); + $this->assertResponse(200, 'Loaded the French homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_fr); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_disabled.test b/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_disabled.test new file mode 100644 index 00000000..65e400ac --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_disabled.test @@ -0,0 +1,105 @@ + 'Metatag core tests with i18n disabled', + 'description' => 'Test Metatag integration with the i18n module enabled but the integration disabled.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need the i18n and i18n_strings modules. + $modules[] = 'i18n'; + $modules[] = 'i18n_string'; + + // Enable all of the modules that are needed. + parent::setUp($modules); + + // Add more locales. + $this->setupLocales(); + + // Set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + // From i18n. + 'translate admin strings', + 'translate user-defined strings', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Turn off i18n integration. + variable_set('metatag_i18n_disabled', TRUE); + + // Reload the translations. + drupal_flush_all_caches(); + module_load_include('admin.inc', 'i18n_string'); + i18n_string_refresh_group('metatag'); + } + + /** + * Test translations of the output tags. + */ + public function testI18nOutput() { + // Plan out the different translation string tests. + $string_en = 'Welcome to the homepage!'; + $string_fr = 'Bonjour pour le homepage!'; + $config_name = 'metatag:frontpage:title'; + + $this->searchTranslationPage('', $config_name); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Load the front page's meta tags. + $instance = 'global:frontpage'; + $config = metatag_config_load($instance); + + // Set something specific as the homepage. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_en); + + // Confirm the string is still not translatable. + $this->searchTranslationPage($string_en, $config_name, FALSE); + + // Get the translation string lid for the front page's title. + $lid = $this->getTranslationLidByContext($config_name); + $this->assertEqual($lid, 0, 'Did not find a locales_source string for the front page output title tag.'); + + // Load the French front page. + $this->drupalGet('fr'); + $this->assertResponse(200, 'Loaded the French homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_en); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_output.test b/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_output.test new file mode 100644 index 00000000..9f3bb3ae --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_i18n_output.test @@ -0,0 +1,185 @@ + 'Metatag core tests with i18n: output', + 'description' => 'Test Metatag integration with the i18n module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'i18n'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Need the i18n and i18n_strings modules. + $modules[] = 'i18n'; + $modules[] = 'i18n_string'; + + // Enable all of the modules that are needed. + parent::setUp($modules); + + // Add more locales. + $this->setupLocales(); + + // Set up the locales. + $perms = array( + 'administer languages', + 'translate interface', + // From i18n. + 'translate admin strings', + 'translate user-defined strings', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + } + + /** + * Test translations of the output tags. + */ + public function testI18nOutputTranslationsEnabled() { + // Enable output translations. + $this->toggleOutputTranslations(TRUE); + + // Plan out the different translation string tests. + $string_en = 'Welcome to the homepage!'; + $string_fr = 'Bonjour pour le homepage!'; + $string_context = 'output:frontpage:title'; + + $this->searchTranslationPage('', $string_context); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $string_context, FALSE); + + // Load the front page's meta tags. + $instance = 'global:frontpage'; + $config = metatag_config_load($instance); + + // Set something specific as the homepage. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_en); + + // Confirm the string is translatable. + $this->searchTranslationPage($string_en, $string_context); + + // Get the translation string lid for the front page's title. + $lid = $this->getTranslationLidByContext($string_context); + $this->assertNotEqual($lid, 0, 'Found the locales_source string for the front page output title tag.'); + + // Save the translation string. + $this->saveTranslationString($lid, $string_context, 'fr', $string_en, $string_fr); + + // Load the English front page again. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the default homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_en); + + // Load the French front page. + $this->drupalGet('fr'); + $this->assertResponse(200, 'Loaded the French homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_fr); + + // Make doubly sure there are output translations. + $lids = $this->getTranslationsByContext($string_context); + $this->assertNotEqual($lids, array()); + } + + /** + * Verify that no output translation records are generated when it's disabled. + */ + public function testI18nOutputTranslationsDisabled() { + // Make sure output translations are disabled. + $this->toggleOutputTranslations(FALSE); + + // Plan out the different translation string tests. + $string_en = 'Welcome to the homepage!'; + $string_fr = 'Bonjour pour le homepage!'; + $string_context = 'output:frontpage:title'; + + $this->searchTranslationPage('', $string_context); + + // Confirm the string is not present yet. + $this->searchTranslationPage($string_en, $string_context, FALSE); + + // Load the front page's meta tags. + $instance = 'global:frontpage'; + $config = metatag_config_load($instance); + + // Set something specific as the homepage. + $config->config['title']['value'] = $string_en; + metatag_config_save($config); + + // Load the front page. + $this->drupalGet(''); + $this->assertResponse(200, 'Loaded the homepage.'); + + // Confirm the page's title is what we set it to. + $this->assertTitle($string_en); + + // Confirm the string is still not translatable. + $this->searchTranslationPage($string_en, $string_context, FALSE); + + // Make doubly sure there are no output translations. + $lids = $this->getTranslationsByContext($string_context); + $this->assertEqual($lids, array()); + } + + /** + * + */ + public function testMenuPaths() { + $paths = metatag_test_menu(); + $test_string = 'read-more-books-every-day'; + foreach ($paths as $path => $menu_item) { + if (substr($path, -1) == '%') { + $path = substr($path, 0, -1) . $test_string; + } + $this->drupalGet($path); + $this->assertResponse(200, 'Loaded a page: ' . $path); + } + } + + /** + * Enable or disable output translations. + * + * @param bool $enable + * Whether or not to enable translations; defaults to TRUE. + */ + private function toggleOutputTranslations($enable = TRUE) { + // Enable output translation. + variable_set('metatag_i18n_translate_output', $enable); + + // Reload the translations. + drupal_flush_all_caches(); + module_load_include('admin.inc', 'i18n_string'); + i18n_string_refresh_group('metatag'); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_me.test b/sites/all/modules/contrib/metatag/tests/metatag.with_me.test new file mode 100644 index 00000000..8a6bceb5 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_me.test @@ -0,0 +1,73 @@ + 'Metatag core tests with Me', + 'description' => 'Test Metatag integration with the Me module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'me'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'me'; + + parent::setUp($modules); + } + + /** + * Make sure the /user/me path doesn't load any meta tags. + */ + public function testMePath() { + // Create an admin user and log them in. + if (!isset($this->adminUser)) { + $this->adminUser = $this->createAdminUser(); + } + $this->drupalLogin($this->adminUser); + + // Load the user's profile page. + // Load the 'me' page. + $this->drupalGet('user/' . $this->adminUser->uid); + $this->assertResponse(200); + + // Look for some meta tags that should exist. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 1, 'Exactly one generator meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Drupal 7 (https://www.drupal.org)'); + $xpath = $this->xpath("//link[@rel='canonical']"); + $this->assertEqual(count($xpath), 1, 'Exactly one canonical meta tag found.'); + $this->assertEqual($xpath[0]['href'], url('user/' . $this->adminUser->uid, array('absolute' => TRUE))); + $xpath = $this->xpath("//link[@rel='shortlink']"); + $this->assertEqual(count($xpath), 1, 'Exactly one shortlink meta tag found.'); + $this->assertEqual($xpath[0]['href'], url('user/' . $this->adminUser->uid, array('absolute' => TRUE))); + + // Load the 'me' page. + $this->drupalGet('user/me'); + $this->assertResponse(200); + + // Confirm the meta tags defined above don't exist. + $xpath = $this->xpath("//meta[@name='generator']"); + $this->assertEqual(count($xpath), 0, 'Did not find the generator meta tag.'); + $xpath = $this->xpath("//link[@rel='canonical']"); + $this->assertEqual(count($xpath), 0, 'Did not find the canonical meta tag.'); + $xpath = $this->xpath("//link[@rel='shortlink']"); + $this->assertEqual(count($xpath), 0, 'Did not find the shortlink meta tag.'); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_media.test b/sites/all/modules/contrib/metatag/tests/metatag.with_media.test new file mode 100644 index 00000000..0fc52676 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_media.test @@ -0,0 +1,64 @@ + 'Metatag core tests with Media', + 'description' => 'Test Metatag integration with the Media module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'file_entity', 'media'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'file_entity'; + $modules[] = 'media'; + // The filter is in the WYSIWYG submodule. + $modules[] = 'media_wysiwyg'; + + parent::setUp($modules); + } + + /** + * Make sure the media filter is enabled. + */ + public function testMediaFilter() { + $desc = 'The description.'; + + // Create a node and check how the meta tag is displayed. + $node = $this->drupalCreateNode(array( + 'body' => array( + LANGUAGE_NONE => array( + array( + 'value' => $desc . '[[{"fid":"1","view_mode":"default","type":"media","attributes":{"height":"100","width":"100","class":"media-element file-default"}}]]', + 'format' => filter_default_format(), + ), + ), + ), + )); + + // Load the node page. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Check the 'description' tag to make sure the Media string was filtered. + $xpath = $this->xpath("//meta[@name='description']"); + $this->assertEqual($xpath[0]['content'], $desc); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_panels.test b/sites/all/modules/contrib/metatag/tests/metatag.with_panels.test new file mode 100644 index 00000000..de36a262 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_panels.test @@ -0,0 +1,183 @@ + 'Metatag core tests with Panels', + 'description' => 'Test Metatag integration with the Panels module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'panels', 'page_manager'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // We'll be using Panels but most of the work is actually in Page Manager. + $modules[] = 'page_manager'; + $modules[] = 'panels'; + + parent::setUp($modules); + } + + /** + * Test out a node_view Panels display with Metatag. + */ + public function testPanelsNodeView() { + $content_type = 'metatag_test'; + $content_type_path = str_replace('_', '-', $content_type); + $label = 'Test'; + + // Create a content type. + $this->createContentType($content_type, $label); + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'delete any ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // Needed for Panels et al. + 'use page manager', + 'administer page manager', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Create a test node. + + // Load the node form. + $this->drupalGet('node/add/' . $content_type_path); + $this->assertResponse(200); + + // Verify the page loaded correctly. + // @todo Update this to extract the page title. + $this->assertText(strip_tags(t('Create @name', array('@name' => $label)))); + + // Verify that it's possible to submit values to the form. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[node:title] ponies', + 'title' => 'Who likes magic', + ), t('Save')); + $this->assertResponse(200); + + // Verify that the node saved correctly. + // $xpath = $this->xpath("//h1"); + $t_args = array('@type' => 'Test', '%title' => 'Who likes magic'); + // This doesn't work for some reason, it seems the HTML is stripped off + // during output so the %title's standard Drupal wrappers don't match. + // $this->assertText(t('@type %title has been created.', $t_args)); + // .. so this has to be done instead. + $this->assertText(strip_tags(t('@type %title has been created.', $t_args))); + + // Save the node URL for later. + $node_url = $this->getUrl(); + + // Confirm the tags load correctly. + $this->confirmNodeTags(); + + // Enable the Page Manager display for nodes. + variable_set('page_manager_node_view_disabled', FALSE); + + // Confirm that the main Panels page loads correctly. + $this->drupalGet('admin/structure/pages'); + $this->assertResponse(200); + + // Confirm that the Panels node_view page loads. + $this->drupalGet('admin/structure/pages/edit/node_view'); + $this->assertResponse(200); + + // Confirm that a new variant can be added. + $this->drupalGet('admin/structure/pages/nojs/operation/node_view/actions/add'); + $this->assertResponse(200); + + // Create a variant. This is done as a series of form submissions. + $args = array( + 'title' => 'Test', + 'name' => 'test', + 'handler' => 'panel_context', + ); + $this->drupalPost('admin/structure/pages/nojs/operation/node_view/actions/add', $args, t('Create variant')); + $this->assertResponse(200); + $args = array( + 'layout' => 'flexible', + ); + $this->drupalPost(NULL, $args, t('Continue')); + $this->assertResponse(200); + $args = array(); + $this->drupalPost(NULL, $args, t('Continue')); + $this->assertResponse(200); + $args = array(); + $this->drupalPost(NULL, $args, t('Create variant')); + $this->assertResponse(200); + $this->assertText(t('The page has been updated. Changes will not be permanent until you save.')); + $args = array(); + $this->drupalPost(NULL, $args, t('Save')); + $this->assertResponse(200); + + // Confirm the process completed successfully. + $this->assertEqual($this->getUrl(), url('admin/structure/pages/edit/node_view', array('absolute' => TRUE))); + $this->assertText(t('Panel') . ': Test'); + + // Clear all caches, so we can start off properly. + drupal_flush_all_caches(); + + // Load the node page again. + $this->confirmNodeTags($node_url); + } + + /** + * Confirm that the meta tags for the requested node load properly. + * + * @param string $path + * Optional path to load, if not present the current path will be used. + */ + function confirmNodeTags($path = NULL) { + if (!empty($path)) { + $this->drupalGet($path); + $this->assertResponse(200); + } + + // Verify the title is using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); + } + + /** + * Test out a term_view Panels display with Metatag. + * + * @todo Write this. + */ + // public function testPanelsTermView() { + // // Enable the Page Manager display for terms. + // variable_set('page_manager_term_view_disabled', FALSE); + // } + + /** + * Test out a user_view Panels display with Metatag. + * + * @todo Write this. + */ + // public function testPanelsUserView() { + // // Enable the Page Manager display for users. + // variable_set('page_manager_user_view_disabled', FALSE); + // } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_profile2.test b/sites/all/modules/contrib/metatag/tests/metatag.with_profile2.test new file mode 100644 index 00000000..5855753d --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_profile2.test @@ -0,0 +1,133 @@ + 'Metatag core tests with Profile2', + 'description' => 'Test Metatag integration with the Profile2 module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'profile2'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'profile2'; + + parent::setUp($modules); + + // Add extra permissions for the admin user, this way it can be ready for + // use by the other user tests. + $perms = array( + // Let the user edit & view their own profile. + 'edit own main profile', + 'view own main profile', + // Manage profile entity definitions. + 'administer profile types', + // Need this permission to access the Field UI pages for Profile2. + 'administer site configuration', + 'administer fields', + 'administer profiles', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + } + + /** + * Make sure that the Profile2 entity doesn't interfere with the user entity. + */ + public function testUserProfilePage() { + // Add a custom meta tag to the user's profile. + $this->drupalGet('user/' . $this->adminUser->uid . '/edit'); + $this->assertResponse(200); + + // Verify that it's possible to submit values to the form. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[user:name] ponies', + ), t('Save')); + $this->assertResponse(200); + + // Verify that the user object saved correctly. + $this->assertText(strip_tags(t('The changes have been saved.'))); + + // Confirm the user profile tags work correctly. + $this->assertUserEntityTags($this->adminUser); + + // Load the 'main' Profile2 fields admin page. + $this->drupalGet('admin/structure/profiles'); + $this->assertResponse(200); + // Load the 'main' Profile2 fields admin page. + $this->drupalGet('admin/structure/profiles/manage/main'); + $this->assertResponse(200); + // Load the 'main' Profile2 fields admin page. + $this->drupalGet('admin/structure/profiles/manage/main/fields'); + $this->assertResponse(200); + + // Verify that the page loaded correctly. + $this->assertFieldByName('fields[_add_new_field][label]'); + $this->assertFieldByName('fields[_add_new_field][field_name]'); + $this->assertFieldByName('fields[_add_new_field][type]'); + $this->assertFieldByName('fields[_add_new_field][widget_type]'); + + // Add a text field to the Main profile. + $edit = array( + 'fields[_add_new_field][label]' => 'Test field', + 'fields[_add_new_field][field_name]' => 'test', + 'fields[_add_new_field][type]' => 'text', + 'fields[_add_new_field][widget_type]' => 'text_textfield', + ); + $this->drupalPost(NULL, $edit, t('Save')); + $this->drupalPost(NULL, array(), t('Save field settings')); + $this->drupalPost(NULL, array(), t('Save settings')); + $this->assertText(strip_tags(t('Saved %label configuration.', array('%label' => 'Test field')))); + + // Edit the user's Profile2 entity. + $this->drupalGet('user/' . $this->adminUser->uid . '/edit/main'); + $this->assertResponse(200); + $this->assertFieldByName('profile_main[field_test][und][0][value]'); + $edit = array( + 'profile_main[field_test][und][0][value]' => 'test string', + ); + $this->drupalPost(NULL, $edit, t('Save')); + + // Add a custom meta tag to the user's profile. + $this->drupalGet('user/' . $this->adminUser->uid . '/edit'); + $this->assertResponse(200); + + // Verify that it's possible to submit values to the form. + $edit = array( + 'metatags[und][abstract][value]' => '[user:name] ponies', + ); + $this->drupalPost(NULL, $edit, t('Save')); + $this->assertResponse(200); + + // Verify that the user object saved correctly. + $this->assertText(strip_tags(t('The changes have been saved.'))); + + // Clear all caches. + drupal_flush_all_caches(); + + // Confirm the user profile tags still work correctly. + $this->assertUserEntityTags($this->adminUser); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_search_api.test b/sites/all/modules/contrib/metatag/tests/metatag.with_search_api.test new file mode 100644 index 00000000..36a810ee --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_search_api.test @@ -0,0 +1,139 @@ + 'Metatag Search API tests', + 'description' => 'Tests the Metatag Search API integration.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'entity', 'search_api'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + // Needed for Search API. + $modules[] = 'entity'; + // The module. + $modules[] = 'search_api'; + // Used to help test the integration. + $modules[] = 'metatag_search_test'; + + parent::setUp($modules); + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'edit any page content', + + // Needed for Search API. + 'administer search_api', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Create an index. + $this->indexId = 'test_index'; + $this->index = entity_create('search_api_index', array( + 'id' => $this->indexId, + 'name' => 'test', + 'machine_name' => 'test_index', + 'enabled' => 1, + 'item_type' => 'node', + 'options' => array( + 'data_alter_callbacks' => array( + 'search_api_metatag_alter_callback' => array( + 'status' => 1, + ), + ), + 'fields' => array( + 'metatag_keywords' => array( + 'type' => 'text', + ), + ), + ), + )); + $this->index->save(); + + // Set up a Search API server. + $this->serverId = 'test_server'; + $values = array( + 'name' => 'Search API test server', + 'machine_name' => $this->serverId, + 'enabled' => 1, + 'description' => 'A server used for testing.', + 'class' => 'metatag_search_test_service', + ); + $this->drupalPost('admin/config/search/search_api/add_server', $values, 'Create server'); + + // Configure the server. + $this->drupalPost(NULL, array(), 'Create server'); + $this->assertText(t('The server was successfully created.')); + $this->drupalGet('admin/config/search/search_api'); + $values = array( + 'server' => $this->serverId, + ); + $this->drupalPost("admin/config/search/search_api/index/{$this->indexId}/edit", $values, 'Save settings'); + $this->clickLink(t('enable')); + + // Enable meta tags for the 'page' content type. + metatag_entity_type_enable('node', 'page'); + } + + /** + * Test that the alter callback indexes the keywords. + */ + public function testAlter() { + // Add a node with keywords. + $node = $this->drupalCreateNode(); + $keywords = 'puppies, rainbows'; + $values = array( + 'metatags[' . LANGUAGE_NONE . '][keywords][value]' => $keywords, + ); + $this->drupalPost('node/' . $node->nid . '/edit', $values, 'Save'); + + // Index the node. + $this->drupalPost("admin/config/search/search_api/index/{$this->indexId}", array(), 'Index now'); + + // Check whether the keywords have been indexed. + $this->assertIdentical(variable_get('metatag_search_test_keywords', FALSE), $keywords); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_views.test b/sites/all/modules/contrib/metatag/tests/metatag.with_views.test new file mode 100644 index 00000000..dacb4344 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_views.test @@ -0,0 +1,191 @@ + 'Metatag core tests with Views', + 'description' => 'Test Metatag integration with the Views module.', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'views'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'views'; + $modules[] = 'views_ui'; + + // Need the Path module to set a alias which can then be loaded. + $modules[] = 'path'; + + parent::setUp($modules); + } + + /** + * Test the taxonomy term page still works when displayed via Views. + */ + public function testTermViews() { + $vocab_name = 'test_vocab'; + $term_name = 'Who likes magic'; + $term_path = 'term-test'; + + // Create a vocabulary. + $vocabulary = $this->createVocabulary($vocab_name); + + // Create an admin user and log them in. + $perms = array( + // Global admin access. + 'administer site configuration', + + // Needed for the vocabulary. + 'administer taxonomy', + 'edit terms in ' . $vocabulary->vid, + 'delete terms in ' . $vocabulary->vid, + + // Needed for the Path module. + 'create url aliases', + + // Needed for Views. + 'administer views', + ); + $this->adminUser = $this->createAdminUser($perms); + + // Log in the admin user. + $this->drupalLogin($this->adminUser); + + // Load the "add default configuration" page. + $this->drupalGet('admin/config/search/metatags/config/add'); + $this->assertResponse(200); + + // Verify the page loaded correct. + $this->assertText(t('Select the type of default meta tags you would like to add.')); + + // Submit the initial form to select an entity bundle. + $this->drupalPost(NULL, array( + 'instance' => 'taxonomy_term:' . $vocabulary->name, + ), t('Add and configure')); + $this->assertResponse(200); + + // @todo Update this to extract the H1 tag. + $this->assertText(strip_tags('Taxonomy term: ' . $vocabulary->name)); + + // Submit the form with some values. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[term:name]', + ), t('Save')); + $this->assertResponse(200); + + // Verify the page loaded correct. + $this->assertText(strip_tags(t('The meta tag defaults for @label have been saved.', array('@label' => 'Taxonomy term: ' . $vocabulary->name)))); + + // Verify that the user was redirected to the settings page again. + $this->assertEqual($this->getUrl(), url('admin/config/search/metatags', array('absolute' => TRUE))); + + // Create a test term. + // Load the term form. + $this->drupalGet('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add'); + $this->assertResponse(200); + + // Verify the page loaded correctly. + // @todo Update this to extract the H1 tag. + // $this->assertText(strip_tags(t('Create @name', array('@name' => $vocabulary->name)))); + // Verify that it's possible to submit values to the form. + $this->drupalPost(NULL, array( + 'metatags[und][abstract][value]' => '[term:name] ponies', + 'name' => $term_name, + 'path[alias]' => $term_path, + ), t('Save')); + $this->assertResponse(200); + + // Verify that the node saved correctly. + $t_args = array('%name' => $term_name); + // This doesn't work for some reason, it seems the HTML is stripped off + // during output so the %name's standard Drupal wrappers don't match. + // $this->assertText(t('Created new term %name.', $t_args)); + // .. so this has to be done instead. + $this->assertText(strip_tags(t('Created new term %name.', $t_args))); + + // Verify the term data saved correctly. + $this->drupalGet($term_path); + $this->assertResponse(200); + + // Confirm the page is managed by the default taxonomy term page. + $this->assertText(t('There is currently no content classified with this term.')); + + // Enable the taxonomy_term default display. + $view = views_get_view('taxonomy_term'); + ctools_include('export'); + ctools_export_set_object_status($view, 0); + $this->clearAllCaches(); + + $this->drupalGet('admin/structure/views'); + $this->assertResponse(200); + + $vars = variable_get('views_defaults'); + $this->verbose($vars); + $this->assertFalse($vars['taxonomy_term'], 'Taxonomy term page is enabled.'); + + // Load the page again. + $this->drupalGet($term_path); + $this->assertResponse(200); + + // Confirm this page is managed by Views - if it's managed by the default + // taxonomy term page this text will show. + $this->assertNoText(t('There is currently no content classified with this term.')); + + // Try to extract the 'edit' link. + $xpaths = $this->xpath("//ul/li/a"); + $matches = array(); + $tid = 0; + if (!empty($xpaths)) { + foreach ($xpaths as $xpath) { + $attributes = $xpath->attributes(); + if (!empty($attributes['href'])) { + if (preg_match('@taxonomy/term/(\d+)/edit$@', $attributes['href'], $matches)) { + $tid = $matches[1]; + } + } + } + } + + // Presuing a term ID was found, load the term. + if (!empty($tid)) { + $term = taxonomy_term_load($tid); + + // Only the non-default values are stored. + $expected = array( + 'und' => array( + 'abstract' => array( + 'value' => '[term:name] ponies', + ), + ), + ); + $this->assertEqual($expected, $term->metatags); + } + + // This shouldn't happen, it indicates a problem. + else { + $this->fail(t('Could not determine the ID for created term.')); + } + + // Verify the title is using the custom default for this vocabulary. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], "Who likes magic ponies"); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test b/sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test new file mode 100644 index 00000000..2cbc5e90 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.with_workbench_moderation.test @@ -0,0 +1,117 @@ + 'Metatag core tests with Workbench Moderation v3', + 'description' => 'Test Metatag integration with the Workbench Moderation module (v3).', + 'group' => 'Metatag', + 'dependencies' => array('ctools', 'token', 'workbench_moderation'), + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + $modules[] = 'workbench_moderation'; + + parent::setUp($modules); + } + + /** + * Confirm that WM-based node edit workflows work properly. + */ + public function testNodeEdit() { + // Create a new content type and enable moderation on it. + $content_type = 'metatag_test'; + $content_type_path = str_replace('_', '-', $content_type); + $label = 'Test'; + $this->createContentType($content_type, $label); + variable_set('node_options_' . $content_type, array('revision', 'moderation')); + + // Create a brand new unpublished node programmatically. + $settings = array( + 'title' => 'Who likes magic', + 'type' => $content_type, + 'metatags' => array( + LANGUAGE_NONE => array( + 'abstract' => array('value' => '[node:title] ponies'), + ), + ), + 'status' => NODE_NOT_PUBLISHED, + ); + $node = $this->drupalCreateNode($settings); + + // Check that page is not published. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(403); + + // Create and login user. + $moderator_user = $this->drupalCreateUser(array( + 'access content', + 'view revisions', + 'view all unpublished content', + 'view moderation history', + 'view moderation messages', + 'bypass workbench moderation', + "create {$content_type} content", + "edit any {$content_type} content", + )); + $this->drupalLogin($moderator_user); + + // Publish the node via the moderation form. + $moderate = array('state' => workbench_moderation_state_published()); + $this->drupalPost("node/{$node->nid}/moderation", $moderate, t('Apply')); + + // Create draft with different node title. + $edit = array( + 'title' => 'I like magic', + ); + $this->drupalPost("node/{$node->nid}/edit", $edit, t('Save')); + + // Logout user. + $this->drupalLogout(); + + // Check that page is already published. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Verify the title is using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'Who likes magic ponies'); + + // Login user again. + $this->drupalLogin($moderator_user); + + // Publish draft via the moderation form. + $moderate = array('state' => workbench_moderation_state_published()); + $this->drupalPost("node/{$node->nid}/moderation", $moderate, t('Apply')); + + // Logout user. + $this->drupalLogout(); + + // Check that page is already published. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200); + + // Verify the title is using the custom default for this content type. + $xpath = $this->xpath("//meta[@name='abstract']"); + $this->assertEqual(count($xpath), 1, 'Exactly one abstract meta tag found.'); + $this->assertEqual($xpath[0]['content'], 'I like magic ponies'); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag.xss.test b/sites/all/modules/contrib/metatag/tests/metatag.xss.test new file mode 100644 index 00000000..6e8a7aee --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag.xss.test @@ -0,0 +1,209 @@ +alert("xss");'; + + /** + * String that causes an alert when metatags aren't filtered for xss. + * + * @var string + */ + private $xssString = '"> 'Metatag core tests for XSS.', + 'description' => 'Test Metatag for XSS vulnerabilities.', + 'group' => 'Metatag', + ); + } + + /** + * {@inheritdoc} + */ + function setUp(array $modules = array()) { + parent::setUp($modules); + + $content_type = 'page'; + + // Create an admin user and log them in. + $perms = array( + // Needed for the content type. + 'create ' . $content_type . ' content', + 'delete any ' . $content_type . ' content', + 'edit any ' . $content_type . ' content', + + // This permission is required in order to create new revisions. + 'administer nodes', + ); + $this->adminUser = $this->createAdminUser($perms); + $this->drupalLogin($this->adminUser); + + // Generate the encoded version of $xssImageString. + // '' + $prefix = ''; + $this->escapedXssImageTag = $prefix . $url . $value . $suffix; + } + + /** + * Verify XSS injected in global Node config is not rendered. + */ + function testXssMetatagConfig() { + // Submit the form with some example XSS values. + $this->drupalGet('admin/config/search/metatags/config/global'); + $this->assertResponse(200); + $edit = array( + 'metatags[und][title][value]' => $this->xssTitleString, + 'metatags[und][abstract][value]' => $this->xssString, + 'metatags[und][image_src][value]' => $this->xssImageString, + ); + $this->drupalPost(NULL, $edit, t('Save')); + $this->assertResponse(200); + + // Use front page to test. + $this->drupalGet(''); + + // Verify title is clean. + $this->assertNoTitle($this->xssTitleString); + $this->assertNoRaw($this->xssTitleString); + + // Verify the abstract is clean. + $this->assertRaw($this->escapedXssTag); + $this->assertNoRaw($this->xssString); + + // Verify the image_src is clean. + $this->assertRaw($this->escapedXssImageTag); + $this->assertNoRaw($this->xssImageString); + } + + /** + * Verify XSS injected in the entity metatag override field is not rendered. + */ + public function testXssEntityOverride() { + $title = 'Test Page'; + + // Load a page node. + $this->drupalGet('node/add/page'); + $this->assertResponse(200); + + // Submit the node with some example XSS values. + $edit = array( + 'title' => $title, + 'metatags[und][title][value]' => $this->xssTitleString, + 'metatags[und][description][value]' => $this->xssString, + 'metatags[und][abstract][value]' => $this->xssString, + ); + $this->drupalPost(NULL, $edit, t('Save')); + + // Verify the page saved. + $this->assertResponse(200); + $this->assertText(t('Basic page @title has been created.', array('@title' => $title))); + + // Verify title is not the injected string and thus cleaned. + $this->assertNoTitle($this->xssTitleString); + $this->assertNoRaw($this->xssTitleString); + + // Verify the description and abstract are clean. + $this->assertRaw($this->escapedXssTag); + $this->assertNoRaw($this->xssString); + } + + /** + * Verify XSS injected in the entity titles are not rendered. + */ + public function testXssEntityTitle() { + // Load a page node. + $this->drupalGet('node/add/page'); + $this->assertResponse(200); + + // Submit the node with some example XSS values. + $edit = array( + 'title' => $this->xssTitleString, + 'body[und][0][value]' => 'hello world', + ); + $this->drupalPost(NULL, $edit, t('Save')); + + // Verify the page saved. + $this->assertResponse(200); + $this->assertText(t('has been created.')); + + // Verify title is not the injected string and thus cleaned. + $this->assertNoRaw($this->xssTitleString); + } + + /** + * Verify XSS injected in the body field is not rendered. + */ + public function testXssEntityBody() { + $title = 'Hello World'; + + // Load a page node. + $this->drupalGet('node/add/page'); + $this->assertResponse(200); + + // Submit the node with a test body value. + $edit = array( + 'title' => $title, + 'body[und][0][value]' => $this->xssString, + ); + $this->drupalPost(NULL, $edit, t('Save')); + + // Verify the page saved. + $this->assertResponse(200); + $this->assertText(t('Basic page @title has been created.', array('@title' => $title))); + + // Verify body field is clean. + $this->assertNoRaw($this->xssString); + } + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag_search_test.info b/sites/all/modules/contrib/metatag/tests/metatag_search_test.info new file mode 100644 index 00000000..915ac633 --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag_search_test.info @@ -0,0 +1,15 @@ +name = Metatag Search API test +description = "Test module for the Metatag Search API integration." +core = 7.x +package = Metatag + +dependencies[] = metatag:metatag +dependencies[] = search_api:search_api + +hidden = TRUE + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" +core = "7.x" +project = "metatag" +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/tests/metatag_search_test.module b/sites/all/modules/contrib/metatag/tests/metatag_search_test.module new file mode 100644 index 00000000..bed7ddac --- /dev/null +++ b/sites/all/modules/contrib/metatag/tests/metatag_search_test.module @@ -0,0 +1,48 @@ + 'metatag_search_test_service', + 'description' => 'metatag_search_test_service description', + 'class' => 'MetatagSearchTestSearchApiService', + ); + return $services; +} + +/** + * Dummy Search API service class. + */ +class MetatagSearchTestSearchApiService extends SearchApiAbstractService { + + /** + * @inheritdoc + */ + public function indexItems(SearchApiIndex $index, array $items) { + variable_set('metatag_search_test_keywords', FALSE); + foreach (array_values($items) as $item) { + if (isset($item['metatag_keywords']['value'])) { + variable_set('metatag_search_test_keywords', $item['metatag_keywords']['value']); + } + } + return array_keys($items); + } + + /** + * @inheritdoc + */ + public function deleteItems($ids = 'all', SearchApiIndex $index = NULL) {} + + /** + * @inheritdoc + */ + public function search(SearchApiQueryInterface $query) {} + +} diff --git a/sites/all/modules/contrib/metatag/tests/metatag_test.info b/sites/all/modules/contrib/metatag/tests/metatag_test.info index cf5584f2..ae10b583 100644 --- a/sites/all/modules/contrib/metatag/tests/metatag_test.info +++ b/sites/all/modules/contrib/metatag/tests/metatag_test.info @@ -1,12 +1,14 @@ name = Meta Tag Test -description = Testing module for metatag.module +description = Helper module for testing metatag.module. core = 7.x -dependencies[] = metatag + +; Don't show this on the modules admin page. hidden = TRUE -; Information added by Drupal.org packaging script on 2014-10-10 -version = "7.x-1.4" +dependencies[] = metatag:metatag + +; Information added by Drupal.org packaging script on 2018-04-04 +version = "7.x-1.25" core = "7.x" project = "metatag" -datestamp = "1412909330" - +datestamp = "1522849089" diff --git a/sites/all/modules/contrib/metatag/tests/metatag_test.metatag.inc b/sites/all/modules/contrib/metatag/tests/metatag_test.metatag.inc index 7525f5aa..b720b348 100644 --- a/sites/all/modules/contrib/metatag/tests/metatag_test.metatag.inc +++ b/sites/all/modules/contrib/metatag/tests/metatag_test.metatag.inc @@ -1,7 +1,16 @@ api_version = 1; $config->disabled = FALSE; $config->config = array( - 'description' => array('value' => 'Test foo description'), - 'abstract' => array('value' => 'Test foo abstract'), 'title' => array('value' => 'Test title'), + 'abstract' => array('value' => 'Test foo abstract'), + 'description' => array('value' => 'Test foo description'), 'test:foo' => array('value' => 'foobar'), ); $configs[$config->instance] = $config; @@ -43,11 +52,18 @@ function metatag_test_metatag_config_default_alter(array &$configs) { * Implements hook_metatag_info(). */ function metatag_test_metatag_info() { + $info['groups']['testing'] = array( + 'label' => t('Testing'), + 'form' => array( + '#weight' => 100, + ), + ); + $info['test:foo'] = array( 'label' => t('Foo meta tag'), 'description' => t('Testing metatag.'), 'class' => 'DrupalTextMetaTag', - 'group' => t('Testing'), + 'group' => 'testing', ); return $info; diff --git a/sites/all/modules/contrib/metatag/tests/metatag_test.module b/sites/all/modules/contrib/metatag/tests/metatag_test.module index aefb329f..53b7dc19 100644 --- a/sites/all/modules/contrib/metatag/tests/metatag_test.module +++ b/sites/all/modules/contrib/metatag/tests/metatag_test.module @@ -1,5 +1,10 @@ 'metatag_test_page_callback', + 'access callback' => TRUE, + 'type' => MENU_NORMAL_ITEM, + ); + + $items[$string] = array( + 'title' => 'Test page', + 'description' => 'An average page.', + ) + $defaults; + + // 255 / 19 chars = 13. + $long_path = implode('/', array_pad(array(), 13, $string)); + $items[$long_path . '/%'] = array( + 'title' => 'Test page with really long URL', + 'description' => 'The URL is really, really, really long.', + 'page arguments' => array(13), + ) + $defaults; + + // User-specific meta tags. + $items['account-test-page'] = array( + 'title' => 'User test page', + 'description' => 'Test how user tokens are handled.', + 'page callback' => 'metatag_test_user_page_callback', + ) + $defaults; + + return $items; +} + +/** + * Simple page callback for test pages. + */ +function metatag_test_page_callback() { + return t('Test page.'); +} + +/** + * Simple page callback for the user test page. + */ +function metatag_test_user_page_callback() { + global $user; + + $username = 'Anonymous visitor'; + if (isset($user->name)) { + $username = $user->name; } + drupal_set_title('Hello ' . $username); + + return t('Test page for user tokens.'); }