/
cm_navbar.php
87 lines (66 loc) · 2.85 KB
/
cm_navbar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2016 osCommerce
Released under the GNU General Public License
*/
class cm_navbar {
var $code;
var $group;
var $title;
var $description;
var $sort_order;
var $enabled = false;
function cm_navbar() {
$this->code = get_class($this);
$this->group = basename(dirname(__FILE__));
$this->title = MODULE_CONTENT_NAVBAR_TITLE;
$this->description = MODULE_CONTENT_NAVBAR_DESCRIPTION;
if ( defined('MODULE_CONTENT_NAVBAR_STATUS') ) {
$this->sort_order = MODULE_CONTENT_NAVBAR_SORT_ORDER;
$this->enabled = (MODULE_CONTENT_NAVBAR_STATUS == 'True');
}
}
function execute() {
global $language, $oscTemplate;
if ( defined('MODULE_CONTENT_NAVBAR_INSTALLED') && tep_not_null(MODULE_CONTENT_NAVBAR_INSTALLED) ) {
$nav_array = explode(';', MODULE_CONTENT_NAVBAR_INSTALLED);
$navbar_modules = array();
foreach ( $nav_array as $nbm ) {
$class = substr($nbm, 0, strrpos($nbm, '.'));
if ( !class_exists($class) ) {
include(DIR_WS_LANGUAGES . $language . '/modules/navbar_modules/' . $nbm);
require(DIR_WS_MODULES . 'navbar_modules/' . $class . '.php');
}
$nav = new $class();
if ( $nav->isEnabled() ) {
$navbar_modules[] = $nav->getOutput();
}
}
if ( !empty($navbar_modules) ) {
ob_start();
include(DIR_WS_MODULES . 'content/' . $this->group . '/templates/navbar.php');
$template = ob_get_clean();
$oscTemplate->addContent($template, $this->group);
}
}
}
function isEnabled() {
return $this->enabled;
}
function check() {
return defined('MODULE_CONTENT_NAVBAR_STATUS');
}
function install() {
tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) values ('Enable Navbar Module', 'MODULE_CONTENT_NAVBAR_STATUS', 'True', 'Should the Navbar be shown? ', '6', '1', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
tep_db_query("insert into configuration (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort Order', 'MODULE_CONTENT_NAVBAR_SORT_ORDER', '10', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
}
function remove() {
tep_db_query("delete from configuration where configuration_key in ('" . implode("', '", $this->keys()) . "')");
}
function keys() {
return array('MODULE_CONTENT_NAVBAR_STATUS', 'MODULE_CONTENT_NAVBAR_SORT_ORDER');
}
}