/
functions.php
136 lines (122 loc) · 5.36 KB
/
functions.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/* This array is to add third level to phpList menu, adding orphan items to a menulink */
$GLOBALS['subcat'] = array(
'import' => array ('import1','import2','import3','import4','importsimple'),
'users' => array('user','userhistory'),
'list' => array('members','editlist'),
'usermgt' => array('massremove','usercheck','reconcileusers'),
'messages' => array('message'),
'templates' => array('template'),
'system' => array('converttoutf8'),
'bouncemgt' => array('bounce','bounces','processbounces','generatebouncerules'),
'bouncerules' => array('bouncerule'),
'spage' => array('spageedit'),
'attributes' => array('editattributes','defaults'),
);
/* This function is to add third level to phpList menu */
function pageSubCategory($menulinks = array(), $current) {
foreach ($GLOBALS['subcat'] as $subcategory => $subcat_details) {
if ( !in_array($current, $menulinks) /* <-first check if is not a menulink */
&& in_array($current, $subcat_details) /* then find the menulink in array above */ ) {
return $subcategory;
}
}
return '';
}
/* replace topmenu() function */
function _topMenu()
{
if ( !isset($_GET['page'] ) ) { $_GET['page'] = ''; }
$current_page = htmlentities($_GET['page']);
if (empty($_SESSION['logindetails'])) {
return '';
}
if ($_SESSION['logindetails']['superuser']) { // we don't have a system yet to distinguish access to plugins
if (count($GLOBALS['plugins'])) {
foreach ($GLOBALS['plugins'] as $pluginName => $plugin) {
$menulinks = $plugin->topMenuLinks;
foreach ($menulinks as $link => $linkDetails) {
if (isset($GLOBALS['pagecategories'][$linkDetails['category']])) {
array_push($GLOBALS['pagecategories'][$linkDetails['category']]['menulinks'],
$link . '&pi=' . $pluginName);
}
}
}
}
}
$topmenu = '';
$topmenu .= '<div id="menuTop">';
if (!DEVVERSION) {
unset($GLOBALS['pagecategories']['develop']);
}
foreach ($GLOBALS['pagecategories'] as $category => $categoryDetails) {
if ($category == 'hide') {
continue;
}
$thismenu = '';
$icon = 'glyphicon-plus';
$icontext = "";
$open = '';
switch ($category) {
case "dashboard" : $icon = "glyphicon-home"; break;
case "subscribers" : $icon = "glyphicon-user"; break;
case "campaigns" : $icon = "glyphicon-envelope"; break;
case "statistics" : $icon = "glyphicon-stats"; break;
case "system" : $icon = "glyphicon-wrench"; break;
case "config" : $icon = "glyphicon-cog"; break;
case "info" : $icon = "";$icontext= "<samp style='line-height:0;font-weight:bold;font-size:19px'>i</samp>"; break;
case "develop" : $icon = "glyphicon-console"; break;
}
foreach ($categoryDetails['menulinks'] as $page) {
$title = $GLOBALS['I18N']->pageTitle($page);
$active = '';
if ( isset($_GET['pi']) && $page == $current_page.'&pi='.$_GET['pi']
|| !$_GET['pi'] && $page == $current_page
|| $page == pageSubCategory($categoryDetails['menulinks'], $current_page) ) {
$active = ' class="active"';
}
elseif (!isset($_GET['pi']) && $category == pageCategory($current_page) ){ // third level
$open = ' class="active open"';
}
$link = PageLink2($page, $title, '', true);
if ($link) {
$thismenu .= '<li' . $active . '>' . $link . '</li>';
}
}
$twohomes = array('dashboard','home');
if ( in_array($current_page,$twohomes) && $categoryDetails['toplink'] == 'dashboard' ) { // page 'home' redirect from dashboard
$open = ' class=" active open"';
}
if (!empty($thismenu)) {
$thismenu = '<ul>' . $thismenu . '</ul>';
}
if (!empty($categoryDetails['toplink'])) {
$categoryurl = PageUrl2($categoryDetails['toplink'], '', '', true);
if ($categoryurl) {
$categoryurl = ($thismenu == "") ? $categoryurl : "#";
$topmenu .= '<ul><li '.$open.' id="'.$category.'"><a class="level0" href="' . $categoryurl . '" title="' . $GLOBALS['I18N']->pageTitleHover($category) . '"><span class="glyphicon '.$icon.'">'.$icontext.'</span>' . ucfirst($GLOBALS['I18N']->get($category)) . '</a>' . $thismenu . '</li></ul>';
} else {
$topmenu .= '<ul><li><span>' . $GLOBALS['I18N']->get($category) . $categoryurl . '</span>' . $thismenu . '</li></ul>';
}
}
}
$topmenu .= '</div>';
return $topmenu;
}
## pick up theme_info (name or dir)
function theme_info($data = "dir"){
$thinfo = dirname(__FILE__) . '/theme_info';
if ( is_file($thinfo) ) {
$theme_info = file_get_contents($thinfo);
$lines = explode("\n", $theme_info);
$info = array();
foreach ($lines as $line) {
if (preg_match('/(\w+)=([\p{L}\p{N}&\#; \-\(\)]+)/u', $line, $regs)) {
$info[$regs[1]] = $regs[2];
}
}
$dir = ( !empty($info['dir']) ) ? 'ui/'.$info['dir'] : 'ui/phplist-ui-bootlist';
$return = ($data == 'name') ? $info['name'] : $dir;
return $return;
}
}