Skip to content
Browse files

Introduce Canonical Header Tag Module

Also fixed manufacturers_id omission.
  • Loading branch information...
1 parent e5c1fb4 commit cfa53fae1a757b9e14d3e79c0c68a2469d97a29c @gburton committed Aug 14, 2012
View
15 catalog/includes/languages/english/modules/header_tags/ht_canonical.php
@@ -0,0 +1,15 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2012 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ define('MODULE_HEADER_TAGS_CANONICAL_TITLE', 'Canonical Header Links');
+ define('MODULE_HEADER_TAGS_CANONICAL_DESCRIPTION', 'Add header canonical links to category and product pages');
+?>
View
70 catalog/includes/modules/header_tags/ht_canonical.php
@@ -0,0 +1,70 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2012 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class ht_canonical {
+ var $code = 'ht_canonical';
+ var $group = 'header_tags';
+ var $title;
+ var $description;
+ var $sort_order;
+ var $enabled = false;
+
+ function ht_canonical() {
+ $this->title = MODULE_HEADER_TAGS_CANONICAL_TITLE;
+ $this->description = MODULE_HEADER_TAGS_CANONICAL_DESCRIPTION;
+
+ if ( defined('MODULE_HEADER_TAGS_CANONICAL_STATUS') ) {
+ $this->sort_order = MODULE_HEADER_TAGS_CANONICAL_SORT_ORDER;
+ $this->enabled = (MODULE_HEADER_TAGS_CANONICAL_STATUS == 'True');
+ }
+ }
+
+ function execute() {
+ global $PHP_SELF, $HTTP_GET_VARS, $cPath, $oscTemplate;
+
+ switch (basename($PHP_SELF)) {
+ case FILENAME_PRODUCT_INFO:
+ $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id'], 'NONSSL', false) . '" />' . "\n", $this->group);
+ break;
+ case FILENAME_DEFAULT:
+ if (isset($cPath) && tep_not_null($cPath)) {
+ $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_DEFAULT, 'cPath=' . $cPath, 'NONSSL', false) . '" />' . "\n", $this->group);
+ }
+ if (isset($HTTP_GET_VARS['manufacturers_id']) && tep_not_null($HTTP_GET_VARS['manufacturers_id'])) {
+ $oscTemplate->addBlock('<link rel="canonical" href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' . $HTTP_GET_VARS['manufacturers_id'], 'NONSSL', false) . '" />' . "\n", $this->group);
+ }
+ break;
+ }
+ }
+
+ function isEnabled() {
+ return $this->enabled;
+ }
+
+ function check() {
+ return defined('MODULE_HEADER_TAGS_CANONICAL_STATUS');
+ }
+
+ function install() {
+ tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Canonical Module', 'MODULE_HEADER_TAGS_CANONICAL_STATUS', 'True', 'Do you want to enable the Canonical module?', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
+ tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_HEADER_TAGS_CANONICAL_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
+ }
+
+ function remove() {
+ tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
+ }
+
+ function keys() {
+ return array('MODULE_HEADER_TAGS_CANONICAL_STATUS', 'MODULE_HEADER_TAGS_CANONICAL_SORT_ORDER');
+ }
+ }
+?>

0 comments on commit cfa53fa

Please sign in to comment.
Something went wrong with that request. Please try again.