Skip to content
Browse files

Modularize admin module configuration page

  • Loading branch information...
1 parent 773a581 commit ec38914c6853c3169d1f9a820ec09f01a7779e8a @haraldpdl haraldpdl committed Nov 7, 2010
Showing with 410 additions and 110 deletions.
  1. +4 −0 catalog/admin/includes/application_top.php
  2. +7 −42 catalog/admin/includes/boxes/modules.php
  3. +67 −0 catalog/admin/includes/classes/cfg_modules.php
  4. +14 −0 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_action_recorder.php
  5. +14 −0 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_boxes.php
  6. +14 −0 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_dashboard.php
  7. +14 −0 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_header_tags.php
  8. +14 −0 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_order_total.php
  9. +14 −0 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_payment.php
  10. +14 −0 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_shipping.php
  11. +14 −0 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_social_bookmarks.php
  12. +26 −0 catalog/admin/includes/modules/cfg_modules/cfgm_action_recorder.php
  13. +26 −0 catalog/admin/includes/modules/cfg_modules/cfgm_boxes.php
  14. +27 −0 catalog/admin/includes/modules/cfg_modules/cfgm_dashboard.php
  15. +26 −0 catalog/admin/includes/modules/cfg_modules/cfgm_header_tags.php
  16. +26 −0 catalog/admin/includes/modules/cfg_modules/cfgm_order_total.php
  17. +26 −0 catalog/admin/includes/modules/cfg_modules/cfgm_payment.php
  18. +26 −0 catalog/admin/includes/modules/cfg_modules/cfgm_shipping.php
  19. +26 −0 catalog/admin/includes/modules/cfg_modules/cfgm_social_bookmarks.php
  20. +11 −68 catalog/admin/modules.php
View
4 catalog/admin/includes/application_top.php
@@ -217,6 +217,10 @@
$current_category_id = 0;
}
+// initialize configuration modules
+ require(DIR_WS_CLASSES . 'cfg_modules.php');
+ $cfgModules = new cfg_modules();
+
// the following cache blocks are used in the Tools->Cache section
// ('language' in the filename is automatically replaced by available languages)
$cache_blocks = array(array('title' => TEXT_CACHE_CATEGORIES, 'code' => 'categories', 'file' => 'categories_box-language.cache', 'multiple' => true),
View
49 catalog/admin/includes/boxes/modules.php
@@ -12,47 +12,12 @@
$cl_box_groups[] = array(
'heading' => BOX_HEADING_MODULES,
- 'apps' => array(
- array(
- 'code' => FILENAME_MODULES,
- 'title' => BOX_MODULES_PAYMENT,
- 'link' => tep_href_link(FILENAME_MODULES, 'set=payment')
- ),
- array(
- 'code' => FILENAME_MODULES,
- 'title' => BOX_MODULES_SHIPPING,
- 'link' => tep_href_link(FILENAME_MODULES, 'set=shipping')
- ),
- array(
- 'code' => FILENAME_MODULES,
- 'title' => BOX_MODULES_ORDER_TOTAL,
- 'link' => tep_href_link(FILENAME_MODULES, 'set=ordertotal')
- ),
- array(
- 'code' => FILENAME_MODULES,
- 'title' => BOX_MODULES_ACTION_RECORDER,
- 'link' => tep_href_link(FILENAME_MODULES, 'set=actionrecorder')
- ),
- array(
- 'code' => FILENAME_MODULES,
- 'title' => BOX_MODULES_HEADER_TAGS,
- 'link' => tep_href_link(FILENAME_MODULES, 'set=header_tags')
- ),
- array(
- 'code' => FILENAME_MODULES,
- 'title' => BOX_MODULES_BOXES,
- 'link' => tep_href_link(FILENAME_MODULES, 'set=boxes')
- ),
- array(
- 'code' => FILENAME_MODULES,
- 'title' => BOX_MODULES_SOCIAL_BOOKMARKS,
- 'link' => tep_href_link(FILENAME_MODULES, 'set=social_bookmarks')
- ),
- array(
- 'code' => FILENAME_MODULES,
- 'title' => BOX_MODULES_ADMIN_DASHBOARD,
- 'link' => tep_href_link(FILENAME_MODULES, 'set=dashboard')
- )
- )
+ 'apps' => array()
);
+
+ foreach ($cfgModules->getAll() as $m) {
+ $cl_box_groups[sizeof($cl_box_groups)-1]['apps'][] = array('code' => FILENAME_MODULES,
+ 'title' => $m['title'],
+ 'link' => tep_href_link(FILENAME_MODULES, 'set=' . $m['code']));
+ }
?>
View
67 catalog/admin/includes/classes/cfg_modules.php
@@ -0,0 +1,67 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfg_modules {
+ var $_modules = array();
+
+ function cfg_modules() {
+ global $PHP_SELF, $language;
+
+ $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
+ $directory = DIR_WS_MODULES . 'cfg_modules';
+
+ if ($dir = @dir($directory)) {
+ while ($file = $dir->read()) {
+ if (!is_dir($directory . $file)) {
+ if (substr($file, strrpos($file, '.')) == $file_extension) {
+ $class = substr($file, 0, strrpos($file, '.'));
+
+ include(DIR_WS_LANGUAGES . $language . '/modules/cfg_modules/' . $file);
+ include(DIR_WS_MODULES . 'cfg_modules/' . $class . '.php');
+
+ $m = new $class();
+
+ $this->_modules[] = array('code' => $m->code,
+ 'directory' => $m->directory,
+ 'language_directory' => $m->language_directory,
+ 'key' => $m->key,
+ 'title' => $m->title,
+ 'template_integration' => $m->template_integration);
+ }
+ }
+ }
+ }
+ }
+
+ function getAll() {
+ return $this->_modules;
+ }
+
+ function get($code, $key) {
+ foreach ($this->_modules as $m) {
+ if ($m['code'] == $code) {
+ return $m[$key];
+ }
+ }
+ }
+
+ function exists($code) {
+ foreach ($this->_modules as $m) {
+ if ($m['code'] == $code) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+?>
View
14 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_action_recorder.php
@@ -0,0 +1,14 @@
+<?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_CFG_MODULE_ACTION_RECORDER_TITLE', 'Action Recorder');
+?>
View
14 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_boxes.php
@@ -0,0 +1,14 @@
+<?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_CFG_MODULE_BOXES_TITLE', 'Boxes');
+?>
View
14 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_dashboard.php
@@ -0,0 +1,14 @@
+<?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_CFG_MODULE_DASHBOARD_TITLE', 'Dashboard');
+?>
View
14 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_header_tags.php
@@ -0,0 +1,14 @@
+<?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_CFG_MODULE_HEADER_TAGS_TITLE', 'Header Tags');
+?>
View
14 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_order_total.php
@@ -0,0 +1,14 @@
+<?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_CFG_MODULE_ORDER_TOTAL_TITLE', 'Order Total');
+?>
View
14 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_payment.php
@@ -0,0 +1,14 @@
+<?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_CFG_MODULE_PAYMENT_TITLE', 'Payment');
+?>
View
14 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_shipping.php
@@ -0,0 +1,14 @@
+<?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_CFG_MODULE_SHIPPING_TITLE', 'Shipping');
+?>
View
14 catalog/admin/includes/languages/english/modules/cfg_modules/cfgm_social_bookmarks.php
@@ -0,0 +1,14 @@
+<?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_CFG_MODULE_SOCIAL_BOOKMARKS_TITLE', 'Social Bookmarks');
+?>
View
26 catalog/admin/includes/modules/cfg_modules/cfgm_action_recorder.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfgm_action_recorder {
+ var $code = 'action_recorder';
+ var $directory;
+ var $language_directory = DIR_FS_CATALOG_LANGUAGES;
+ var $key = 'MODULE_ACTION_RECORDER_INSTALLED';
+ var $title;
+ var $template_integration = false;
+
+ function cfgm_action_recorder() {
+ $this->directory = DIR_FS_CATALOG_MODULES . 'action_recorder/';
+ $this->title = MODULE_CFG_MODULE_ACTION_RECORDER_TITLE;
+ }
+ }
+?>
View
26 catalog/admin/includes/modules/cfg_modules/cfgm_boxes.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfgm_boxes {
+ var $code = 'boxes';
+ var $directory;
+ var $language_directory = DIR_FS_CATALOG_LANGUAGES;
+ var $key = 'MODULE_BOXES_INSTALLED';
+ var $title;
+ var $template_integration = true;
+
+ function cfgm_boxes() {
+ $this->directory = DIR_FS_CATALOG_MODULES . 'boxes/';
+ $this->title = MODULE_CFG_MODULE_BOXES_TITLE;
+ }
+ }
+?>
View
27 catalog/admin/includes/modules/cfg_modules/cfgm_dashboard.php
@@ -0,0 +1,27 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfgm_dashboard {
+ var $code = 'dashboard';
+ var $directory;
+ var $language_directory;
+ var $key = 'MODULE_ADMIN_DASHBOARD_INSTALLED';
+ var $title;
+ var $template_integration = false;
+
+ function cfgm_dashboard() {
+ $this->directory = DIR_FS_ADMIN . 'includes/modules/dashboard/';
+ $this->language_directory = DIR_FS_ADMIN . 'includes/languages/';
+ $this->title = MODULE_CFG_MODULE_DASHBOARD_TITLE;
+ }
+ }
+?>
View
26 catalog/admin/includes/modules/cfg_modules/cfgm_header_tags.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfgm_header_tags {
+ var $code = 'header_tags';
+ var $directory;
+ var $language_directory = DIR_FS_CATALOG_LANGUAGES;
+ var $key = 'MODULE_HEADER_TAGS_INSTALLED';
+ var $title;
+ var $template_integration = true;
+
+ function cfgm_header_tags() {
+ $this->directory = DIR_FS_CATALOG_MODULES . 'header_tags/';
+ $this->title = MODULE_CFG_MODULE_HEADER_TAGS_TITLE;
+ }
+ }
+?>
View
26 catalog/admin/includes/modules/cfg_modules/cfgm_order_total.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfgm_order_total {
+ var $code = 'order_total';
+ var $directory;
+ var $language_directory = DIR_FS_CATALOG_LANGUAGES;
+ var $key = 'MODULE_ORDER_TOTAL_INSTALLED';
+ var $title;
+ var $template_integration = false;
+
+ function cfgm_order_total() {
+ $this->directory = DIR_FS_CATALOG_MODULES . 'order_total/';
+ $this->title = MODULE_CFG_MODULE_ORDER_TOTAL_TITLE;
+ }
+ }
+?>
View
26 catalog/admin/includes/modules/cfg_modules/cfgm_payment.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfgm_payment {
+ var $code = 'payment';
+ var $directory;
+ var $language_directory = DIR_FS_CATALOG_LANGUAGES;
+ var $key = 'MODULE_PAYMENT_INSTALLED';
+ var $title;
+ var $template_integration = false;
+
+ function cfgm_payment() {
+ $this->directory = DIR_FS_CATALOG_MODULES . 'payment/';
+ $this->title = MODULE_CFG_MODULE_PAYMENT_TITLE;
+ }
+ }
+?>
View
26 catalog/admin/includes/modules/cfg_modules/cfgm_shipping.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfgm_shipping {
+ var $code = 'shipping';
+ var $directory;
+ var $language_directory = DIR_FS_CATALOG_LANGUAGES;
+ var $key = 'MODULE_SHIPPING_INSTALLED';
+ var $title;
+ var $template_integration = false;
+
+ function cfgm_shipping() {
+ $this->directory = DIR_FS_CATALOG_MODULES . 'shipping/';
+ $this->title = MODULE_CFG_MODULE_SHIPPING_TITLE;
+ }
+ }
+?>
View
26 catalog/admin/includes/modules/cfg_modules/cfgm_social_bookmarks.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2010 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ class cfgm_social_bookmarks {
+ var $code = 'social_bookmarks';
+ var $directory;
+ var $language_directory = DIR_FS_CATALOG_LANGUAGES;
+ var $key = 'MODULE_SOCIAL_BOOKMARKS_INSTALLED';
+ var $title;
+ var $template_integration = false;
+
+ function cfgm_social_bookmarks() {
+ $this->directory = DIR_FS_CATALOG_MODULES . 'social_bookmarks/';
+ $this->title = MODULE_CFG_MODULE_SOCIAL_BOOKMARKS_TITLE;
+ }
+ }
+?>
View
79 catalog/admin/modules.php
@@ -14,76 +14,19 @@
$set = (isset($HTTP_GET_VARS['set']) ? $HTTP_GET_VARS['set'] : '');
- if (tep_not_null($set)) {
- switch ($set) {
- case 'shipping':
- $module_type = 'shipping';
- $module_directory = DIR_FS_CATALOG_MODULES . 'shipping/';
- $module_language_directory = DIR_FS_CATALOG_LANGUAGES;
- $module_key = 'MODULE_SHIPPING_INSTALLED';
- define('HEADING_TITLE', HEADING_TITLE_MODULES_SHIPPING);
- $template_integration = false;
- break;
- case 'ordertotal':
- $module_type = 'order_total';
- $module_directory = DIR_FS_CATALOG_MODULES . 'order_total/';
- $module_language_directory = DIR_FS_CATALOG_LANGUAGES;
- $module_key = 'MODULE_ORDER_TOTAL_INSTALLED';
- define('HEADING_TITLE', HEADING_TITLE_MODULES_ORDER_TOTAL);
- $template_integration = false;
- break;
- case 'actionrecorder':
- $module_type = 'action_recorder';
- $module_directory = DIR_FS_CATALOG_MODULES . 'action_recorder/';
- $module_language_directory = DIR_FS_CATALOG_LANGUAGES;
- $module_key = 'MODULE_ACTION_RECORDER_INSTALLED';
- define('HEADING_TITLE', HEADING_TITLE_MODULES_ACTION_RECORDER);
- $template_integration = false;
- break;
- case 'social_bookmarks':
- $module_type = 'social_bookmarks';
- $module_directory = DIR_FS_CATALOG_MODULES . 'social_bookmarks/';
- $module_language_directory = DIR_FS_CATALOG_LANGUAGES;
- $module_key = 'MODULE_SOCIAL_BOOKMARKS_INSTALLED';
- define('HEADING_TITLE', HEADING_TITLE_MODULES_SOCIAL_BOOKMARKS);
- $template_integration = false;
- break;
- case 'header_tags':
- $module_type = 'header_tags';
- $module_directory = DIR_FS_CATALOG_MODULES . 'header_tags/';
- $module_language_directory = DIR_FS_CATALOG_LANGUAGES;
- $module_key = 'MODULE_HEADER_TAGS_INSTALLED';
- define('HEADING_TITLE', HEADING_TITLE_MODULES_HEADER_TAGS);
- $template_integration = true;
- break;
- case 'boxes':
- $module_type = 'boxes';
- $module_directory = DIR_FS_CATALOG_MODULES . 'boxes/';
- $module_language_directory = DIR_FS_CATALOG_LANGUAGES;
- $module_key = 'MODULE_BOXES_INSTALLED';
- define('HEADING_TITLE', HEADING_TITLE_MODULES_BOXES);
- $template_integration = true;
- break;
- case 'dashboard':
- $module_type = 'dashboard';
- $module_directory = DIR_FS_ADMIN . 'includes/modules/dashboard/';
- $module_language_directory = DIR_FS_ADMIN . 'includes/languages/';
- $module_key = 'MODULE_ADMIN_DASHBOARD_INSTALLED';
- define('HEADING_TITLE', HEADING_TITLE_MODULES_ADMIN_DASHBOARD);
- $template_integration = false;
- break;
- case 'payment':
- default:
- $module_type = 'payment';
- $module_directory = DIR_FS_CATALOG_MODULES . 'payment/';
- $module_language_directory = DIR_FS_CATALOG_LANGUAGES;
- $module_key = 'MODULE_PAYMENT_INSTALLED';
- define('HEADING_TITLE', HEADING_TITLE_MODULES_PAYMENT);
- $template_integration = false;
- break;
- }
+ $modules = $cfgModules->getAll();
+
+ if (empty($set) || !$cfgModules->exists($set)) {
+ $set = $modules[0]['code'];
}
+ $module_type = $cfgModules->get($set, 'code');
+ $module_directory = $cfgModules->get($set, 'directory');
+ $module_language_directory = $cfgModules->get($set, 'language_directory');
+ $module_key = $cfgModules->get($set, 'key');;
+ define('HEADING_TITLE', $cfgModules->get($set, 'title'));
+ $template_integration = $cfgModules->get($set, 'template_integration');
+
$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
if (tep_not_null($action)) {

0 comments on commit ec38914

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