Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

convert header tag modules to proper modules; these are now loaded on…

… each page request; modules for specific pages need to be developed that way (checking against $PHP_SELF)
  • Loading branch information...
commit eff9b1aabf6cf6558c6a2e900c8fdd71fc9462ad 1 parent d4b584f
@haraldpdl haraldpdl authored
View
1  catalog/admin/includes/boxes/modules.php
@@ -25,6 +25,7 @@
'<a href="' . tep_href_link(FILENAME_MODULES, 'set=shipping', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_SHIPPING . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_MODULES, 'set=ordertotal', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_ORDER_TOTAL . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_MODULES, 'set=actionrecorder', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_ACTION_RECORDER . '</a><br>' .
+ '<a href="' . tep_href_link(FILENAME_MODULES, 'set=header_tags', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_HEADER_TAGS . '</a><br>' .
'<a href="' . tep_href_link(FILENAME_MODULES, 'set=social_bookmarks', 'NONSSL') . '" class="menuBoxContentLink">' . BOX_MODULES_SOCIAL_BOOKMARKS . '</a>');
}
View
1  catalog/admin/includes/languages/english.php
@@ -69,6 +69,7 @@ function tep_date_raw($date, $reverse = false) {
define('BOX_MODULES_SHIPPING', 'Shipping');
define('BOX_MODULES_ORDER_TOTAL', 'Order Total');
define('BOX_MODULES_ACTION_RECORDER', 'Action Recorder');
+define('BOX_MODULES_HEADER_TAGS', 'Header Tags');
define('BOX_MODULES_SOCIAL_BOOKMARKS', 'Social Bookmarks');
// categories box text in includes/boxes/catalog.php
View
1  catalog/admin/includes/languages/english/modules.php
@@ -14,6 +14,7 @@
define('HEADING_TITLE_MODULES_SHIPPING', 'Shipping Modules');
define('HEADING_TITLE_MODULES_ORDER_TOTAL', 'Order Total Modules');
define('HEADING_TITLE_MODULES_ACTION_RECORDER', 'Action Recorder Modules');
+define('HEADING_TITLE_MODULES_HEADER_TAGS', 'Header Tag Modules');
define('HEADING_TITLE_MODULES_SOCIAL_BOOKMARKS', 'Social Bookmark Modules');
define('TABLE_HEADING_MODULES', 'Modules');
View
6 catalog/admin/modules.php
@@ -40,6 +40,12 @@
$module_key = 'MODULE_SOCIAL_BOOKMARKS_INSTALLED';
define('HEADING_TITLE', HEADING_TITLE_MODULES_SOCIAL_BOOKMARKS);
break;
+ case 'header_tags':
+ $module_type = 'header_tags';
+ $module_directory = DIR_FS_CATALOG_MODULES . 'header_tags/';
+ $module_key = 'MODULE_HEADER_TAGS_INSTALLED';
+ define('HEADING_TITLE', HEADING_TITLE_MODULES_HEADER_TAGS);
+ break;
case 'payment':
default:
$module_type = 'payment';
View
59 catalog/includes/classes/osc_template.php
@@ -37,61 +37,26 @@ function getHeaderTags() {
}
function buildHeaderTags() {
- global $PHP_SELF;
+ global $language;
- $modules_array = $this->_loadModules('global');
+ if ( defined('MODULE_HEADER_TAGS_INSTALLED') && tep_not_null(MODULE_HEADER_TAGS_INSTALLED) ) {
+ $htm_array = explode(';', MODULE_HEADER_TAGS_INSTALLED);
- $req_module = substr(basename($PHP_SELF), 0, strpos(basename($PHP_SELF), '.'));
+ foreach ( $htm_array as $htm ) {
+ $class = substr($htm, 0, strrpos($htm, '.'));
- if ($req_module != 'global') {
- $directory = realpath(DIR_FS_CATALOG . DIR_WS_MODULES . 'header_tags/' . $req_module);
-
- if (substr($directory, 0, strlen(realpath(DIR_FS_CATALOG . DIR_WS_MODULES . 'header_tags'))) == realpath(DIR_FS_CATALOG . DIR_WS_MODULES . 'header_tags')) {
- $modules_array = array_merge($modules_array, $this->_loadModules($req_module));
- }
- }
-
- foreach ($modules_array as $module) {
- call_user_func(array($module, 'parse'));
- }
- }
-
- function _loadModules($group) {
- global $PHP_SELF;
-
- $directory = realpath(DIR_FS_CATALOG . DIR_WS_MODULES . 'header_tags/' . $group);
- $directory_array = array();
-
- if (file_exists($directory)) {
- $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
- if ($dir = @dir($directory)) {
- while ($file = $dir->read()) {
- if (!is_dir($directory . '/' . $file)) {
- if (substr($file, strrpos($file, '.')) == $file_extension) {
- $module = 'ht_' . $this->_toCamel($group) . '_' . substr($file, 0, strpos($file, '.'));
+ if ( !class_exists($class) ) {
+ include(DIR_WS_LANGUAGES . $language . '/modules/header_tags/' . $htm);
+ include(DIR_WS_MODULES . 'header_tags/' . $class . '.php');
+ }
- $directory_array[] = $module;
+ $ht = new $class();
- if (!class_exists($module)) {
- include($directory . '/' . $file);
- }
- }
- }
+ if ( $ht->isEnabled() ) {
+ $ht->execute();
}
- sort($directory_array);
- $dir->close();
}
}
-
- return $directory_array;
- }
-
- function _toCamel($string) {
- $parts = explode('_', $string);
- $parts = $parts ? array_map('ucfirst', $parts) : array($string);
- $parts[0] = strtolower(substr($parts[0], 0, 1)) . substr($parts[0], 1);
-
- return implode('', $parts);
}
}
?>
View
15 catalog/includes/languages/english/modules/header_tags/ht_category_title.php
@@ -0,0 +1,15 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ define('MODULE_HEADER_TAGS_CATEGORY_TITLE_TITLE', 'Category Title');
+ define('MODULE_HEADER_TAGS_CATEGORY_TITLE_DESCRIPTION', 'Add the title of the current category to the page title');
+?>
View
15 catalog/includes/languages/english/modules/header_tags/ht_manufacturer_title.php
@@ -0,0 +1,15 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ define('MODULE_HEADER_TAGS_MANUFACTURER_TITLE_TITLE', 'Manufacturer Titel');
+ define('MODULE_HEADER_TAGS_MANUFACTURER_TITLE_DESCRIPTION', 'Add the title of the current manufacturer to the page title');
+?>
View
15 catalog/includes/languages/english/modules/header_tags/ht_opensearch.php
@@ -0,0 +1,15 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ define('MODULE_HEADER_TAGS_OPENSEARCH_TITLE', 'OpenSearch');
+ define('MODULE_HEADER_TAGS_OPENSEARCH_DESCRIPTION', 'Allow the browser to search the shop via OpenSearch');
+?>
View
15 catalog/includes/languages/english/modules/header_tags/ht_product_title.php
@@ -0,0 +1,15 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ define('MODULE_HEADER_TAGS_PRODUCT_TITLE_TITLE', 'Product Title');
+ define('MODULE_HEADER_TAGS_PRODUCT_TITLE_DESCRIPTION', 'Add the title of the current product to the page title');
+?>
View
61 catalog/includes/modules/header_tags/ht_category_title.php
@@ -10,24 +10,63 @@
Released under the GNU General Public License
*/
- class ht_index_category_title {
- function parse() {
- global $oscTemplate, $categories, $current_category_id, $languages_id;
+ class ht_category_title {
+ var $code = 'ht_category_title';
+ var $title;
+ var $description;
+ var $sort_order;
+ var $enabled = false;
+ function ht_category_title() {
+ $this->title = MODULE_HEADER_TAGS_CATEGORY_TITLE_TITLE;
+ $this->description = MODULE_HEADER_TAGS_CATEGORY_TITLE_DESCRIPTION;
+
+ if ( defined('MODULE_HEADER_TAGS_CATEGORY_TITLE_STATUS') ) {
+ $this->sort_order = MODULE_HEADER_TAGS_CATEGORY_TITLE_SORT_ORDER;
+ $this->enabled = (MODULE_HEADER_TAGS_CATEGORY_TITLE_STATUS == 'True');
+ }
+ }
+
+ function execute() {
+ global $PHP_SELF, $oscTemplate, $categories, $current_category_id, $languages_id;
+
+ if (basename($PHP_SELF) == FILENAME_DEFAULT) {
// $categories is set in application_top.php to add the category to the breadcrumb
- if (isset($categories) && (sizeof($categories) == 1) && isset($categories['categories_name'])) {
- $oscTemplate->setTitle($categories['categories_name'] . ', ' . $oscTemplate->getTitle());
- } else {
+ if (isset($categories) && (sizeof($categories) == 1) && isset($categories['categories_name'])) {
+ $oscTemplate->setTitle($categories['categories_name'] . ', ' . $oscTemplate->getTitle());
+ } else {
// $categories is not set so a database query is needed
- if ($current_category_id > 0) {
- $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$current_category_id . "' and language_id = '" . (int)$languages_id . "' limit 1");
- if (tep_db_num_rows($categories_query) > 0) {
- $categories = tep_db_fetch_array($categories_query);
+ if ($current_category_id > 0) {
+ $categories_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$current_category_id . "' and language_id = '" . (int)$languages_id . "' limit 1");
+ if (tep_db_num_rows($categories_query) > 0) {
+ $categories = tep_db_fetch_array($categories_query);
- $oscTemplate->setTitle($categories['categories_name'] . ', ' . $oscTemplate->getTitle());
+ $oscTemplate->setTitle($categories['categories_name'] . ', ' . $oscTemplate->getTitle());
+ }
}
}
}
}
+
+ function isEnabled() {
+ return $this->enabled;
+ }
+
+ function check() {
+ return defined('MODULE_HEADER_TAGS_CATEGORY_TITLE_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 Category Title Module', 'MODULE_HEADER_TAGS_CATEGORY_TITLE_STATUS', 'True', 'Do you want to allow category titles to be added to the page title?', '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_CATEGORY_TITLE_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_CATEGORY_TITLE_STATUS', 'MODULE_HEADER_TAGS_CATEGORY_TITLE_SORT_ORDER');
+ }
}
?>
View
61 catalog/includes/modules/header_tags/ht_manufacturer_title.php
@@ -10,24 +10,63 @@
Released under the GNU General Public License
*/
- class ht_index_manufacturer_title {
- function parse() {
- global $HTTP_GET_VARS, $oscTemplate, $manufacturers, $languages_id;
+ class ht_manufacturer_title {
+ var $code = 'ht_manufacturer_title';
+ var $title;
+ var $description;
+ var $sort_order;
+ var $enabled = false;
- if (isset($HTTP_GET_VARS['manufacturers_id']) && is_numeric($HTTP_GET_VARS['manufacturers_id'])) {
+ function ht_manufacturer_title() {
+ $this->title = MODULE_HEADER_TAGS_MANUFACTURER_TITLE_TITLE;
+ $this->description = MODULE_HEADER_TAGS_MANUFACTURER_TITLE_DESCRIPTION;
+
+ if ( defined('MODULE_HEADER_TAGS_MANUFACTURER_TITLE_STATUS') ) {
+ $this->sort_order = MODULE_HEADER_TAGS_MANUFACTURER_TITLE_SORT_ORDER;
+ $this->enabled = (MODULE_HEADER_TAGS_MANUFACTURER_TITLE_STATUS == 'True');
+ }
+ }
+
+ function execute() {
+ global $PHP_SELF, $HTTP_GET_VARS, $oscTemplate, $manufacturers, $languages_id;
+
+ if (basename($PHP_SELF) == FILENAME_DEFAULT) {
+ if (isset($HTTP_GET_VARS['manufacturers_id']) && is_numeric($HTTP_GET_VARS['manufacturers_id'])) {
// $manufacturers is set in application_top.php to add the manufacturer to the breadcrumb
- if (isset($manufacturers) && (sizeof($manufacturers) == 1) && isset($manufacturers['manufacturers_name'])) {
- $oscTemplate->setTitle($manufacturers['manufacturers_name'] . ', ' . $oscTemplate->getTitle());
- } else {
+ if (isset($manufacturers) && (sizeof($manufacturers) == 1) && isset($manufacturers['manufacturers_name'])) {
+ $oscTemplate->setTitle($manufacturers['manufacturers_name'] . ', ' . $oscTemplate->getTitle());
+ } else {
// $manufacturers is not set so a database query is needed
- $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
- if (tep_db_num_rows($manufacturers_query)) {
- $manufacturers = tep_db_fetch_array($manufacturers_query);
+ $manufacturers_query = tep_db_query("select manufacturers_name from " . TABLE_MANUFACTURERS . " where manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "'");
+ if (tep_db_num_rows($manufacturers_query)) {
+ $manufacturers = tep_db_fetch_array($manufacturers_query);
- $oscTemplate->setTitle($manufacturers['manufacturers_name'] . ', ' . $oscTemplate->getTitle());
+ $oscTemplate->setTitle($manufacturers['manufacturers_name'] . ', ' . $oscTemplate->getTitle());
+ }
}
}
}
}
+
+ function isEnabled() {
+ return $this->enabled;
+ }
+
+ function check() {
+ return defined('MODULE_HEADER_TAGS_MANUFACTURER_TITLE_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 Manufacturer Title Module', 'MODULE_HEADER_TAGS_MANUFACTURER_TITLE_STATUS', 'True', 'Do you want to allow manufacturer titles to be added to the page title?', '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_MANUFACTURER_TITLE_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_MANUFACTURER_TITLE_STATUS', 'MODULE_HEADER_TAGS_MANUFACTURER_TITLE_SORT_ORDER');
+ }
}
?>
View
41 catalog/includes/modules/header_tags/ht_opensearch.php
@@ -10,11 +10,48 @@
Released under the GNU General Public License
*/
- class ht_global_opensearch {
- function parse() {
+ class ht_opensearch {
+ var $code = 'ht_opensearch';
+ var $title;
+ var $description;
+ var $sort_order;
+ var $enabled = false;
+
+ function ht_opensearch() {
+ $this->title = MODULE_HEADER_TAGS_OPENSEARCH_TITLE;
+ $this->description = MODULE_HEADER_TAGS_OPENSEARCH_DESCRIPTION;
+
+ if ( defined('MODULE_HEADER_TAGS_OPENSEARCH_STATUS') ) {
+ $this->sort_order = MODULE_HEADER_TAGS_OPENSEARCH_SORT_ORDER;
+ $this->enabled = (MODULE_HEADER_TAGS_OPENSEARCH_STATUS == 'True');
+ }
+ }
+
+ function execute() {
global $oscTemplate;
$oscTemplate->addHeaderTag('<link rel="search" type="application/opensearchdescription+xml" href="' . tep_href_link('opensearch.php', '', 'NONSSL', false) . '" title="' . tep_output_string(STORE_NAME) . '" />');
}
+
+ function isEnabled() {
+ return $this->enabled;
+ }
+
+ function check() {
+ return defined('MODULE_HEADER_TAGS_OPENSEARCH_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 OpenSearch Module', 'MODULE_HEADER_TAGS_OPENSEARCH_STATUS', 'True', 'Add shop search functionality to the browser?', '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_OPENSEARCH_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_OPENSEARCH_STATUS', 'MODULE_HEADER_TAGS_OPENSEARCH_SORT_ORDER');
+ }
}
?>
View
55 catalog/includes/modules/header_tags/ht_product_title.php
@@ -10,16 +10,57 @@
Released under the GNU General Public License
*/
- class ht_productInfo_title {
- function parse() {
- global $oscTemplate, $HTTP_GET_VARS, $languages_id, $product_check;
+ class ht_product_title {
+ var $code = 'ht_product_title';
+ var $title;
+ var $description;
+ var $sort_order;
+ var $enabled = false;
- if ($product_check['total'] > 0) {
- $product_info_query = tep_db_query("select pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
- $product_info = tep_db_fetch_array($product_info_query);
+ function ht_product_title() {
+ $this->title = MODULE_HEADER_TAGS_PRODUCT_TITLE_TITLE;
+ $this->description = MODULE_HEADER_TAGS_PRODUCT_TITLE_DESCRIPTION;
- $oscTemplate->setTitle($product_info['products_name'] . ', ' . $oscTemplate->getTitle());
+ if ( defined('MODULE_HEADER_TAGS_PRODUCT_TITLE_STATUS') ) {
+ $this->sort_order = MODULE_HEADER_TAGS_PRODUCT_TITLE_SORT_ORDER;
+ $this->enabled = (MODULE_HEADER_TAGS_PRODUCT_TITLE_STATUS == 'True');
}
}
+
+ function execute() {
+ global $PHP_SELF, $oscTemplate, $HTTP_GET_VARS, $languages_id, $product_check;
+
+ if (basename($PHP_SELF) == FILENAME_PRODUCT_INFO) {
+ if (isset($HTTP_GET_VARS['products_id'])) {
+ if ($product_check['total'] > 0) {
+ $product_info_query = tep_db_query("select pd.products_name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_status = '1' and p.products_id = '" . (int)$HTTP_GET_VARS['products_id'] . "' and pd.products_id = p.products_id and pd.language_id = '" . (int)$languages_id . "'");
+ $product_info = tep_db_fetch_array($product_info_query);
+
+ $oscTemplate->setTitle($product_info['products_name'] . ', ' . $oscTemplate->getTitle());
+ }
+ }
+ }
+ }
+
+ function isEnabled() {
+ return $this->enabled;
+ }
+
+ function check() {
+ return defined('MODULE_HEADER_TAGS_PRODUCT_TITLE_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 Category Title Module', 'MODULE_HEADER_TAGS_PRODUCT_TITLE_STATUS', 'True', 'Do you want to allow product titles to be added to the page title?', '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_PRODUCT_TITLE_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_PRODUCT_TITLE_STATUS', 'MODULE_HEADER_TAGS_PRODUCT_TITLE_SORT_ORDER');
+ }
}
?>
Please sign in to comment.
Something went wrong with that request. Please try again.