| 1 |
phoenix |
1.1 |
<?php |
| 2 |
phoenix |
1.1 |
/********************************************* |
| 3 |
phoenix |
1.1 |
CPG Dragonfly™ CMS |
| 4 |
phoenix |
1.1 |
******************************************** |
| 5 |
nanocaio |
1.6 |
Copyright © 2004 - 2007 by CPG-Nuke Dev Team |
| 6 |
phoenix |
1.1 |
http://dragonflycms.org |
| 7 |
phoenix |
1.1 |
  |
| 8 |
phoenix |
1.1 |
Dragonfly is released under the terms and conditions |
| 9 |
phoenix |
1.1 |
of the GNU GPL version 2 or any later version |
| 10 |
phoenix |
1.1 |
  |
| 11 |
phoenix |
1.1 |
$Source: /cvs/html/includes/cssmainmenu.php,v $ |
| 12 |
nanocaio |
1.6 |
$Revision: 1.5 $ |
| 13 |
nanocaio |
1.6 |
$Author: phoenix $ |
| 14 |
nanocaio |
1.6 |
$Date: 2007/04/17 12:51:20 $ |
| 15 |
phoenix |
1.1 |
**********************************************/ |
| 16 |
phoenix |
1.1 |
if (!defined('CPG_NUKE')) { exit; } |
| 17 |
phoenix |
1.3 |
global $prefix, $db, $module_name, $language, $currentlang, $mainindex, $userinfo, $adminindex, $MAIN_CFG; |
| 18 |
phoenix |
1.3 |
if (!($MAIN_CFG['global']['admingraphic'] & 4)) return ''; |
| 19 |
phoenix |
1.1 |
  |
| 20 |
phoenix |
1.1 |
$menucats = array(); |
| 21 |
phoenix |
1.1 |
$modquery = $lnkquery = ''; |
| 22 |
phoenix |
1.1 |
$setstatus = 1; |
| 23 |
phoenix |
1.1 |
  |
| 24 |
phoenix |
1.1 |
if (!is_admin()) |
| 25 |
phoenix |
1.1 |
{ |
| 26 |
phoenix |
1.1 |
$modquery = 'WHERE m.active=1 AND m.inmenu=1'; |
| 27 |
phoenix |
1.1 |
$lnkquery = 'WHERE l.active=1'; |
| 28 |
phoenix |
1.1 |
$view[] = 0; |
| 29 |
phoenix |
1.1 |
if (is_user()) { |
| 30 |
phoenix |
1.1 |
$view[] = 1; |
| 31 |
phoenix |
1.1 |
foreach($userinfo['_mem_of_groups'] AS $key => $value) { |
| 32 |
phoenix |
1.1 |
$view[] = $key+3; |
| 33 |
phoenix |
1.1 |
} |
| 34 |
phoenix |
1.1 |
} else { |
| 35 |
phoenix |
1.1 |
$view[] = 3; |
| 36 |
phoenix |
1.1 |
} |
| 37 |
phoenix |
1.1 |
$modquery .= ' AND m.view IN ('.implode(',', $view).')'; |
| 38 |
phoenix |
1.1 |
$lnkquery .= ' AND l.view IN ('.implode(',', $view).')'; |
| 39 |
phoenix |
1.1 |
} |
| 40 |
phoenix |
1.1 |
  |
| 41 |
phoenix |
1.1 |
// Load active modules from database |
| 42 |
phoenix |
1.1 |
$sql = 'SELECT m.title as link, m.custom_title as title, m.view, m.active, m.inmenu, m.cat_id, m.pos AS linkpos, c.name, c.image, c.pos AS catpos, c.link AS catlnk, c.link_type AS cattype FROM '.$prefix.'_modules AS m LEFT JOIN '.$prefix."_modules_cat c ON (c.cid = m.cat_id) $modquery"; |
| 43 |
phoenix |
1.1 |
$result = $db->sql_query($sql); |
| 44 |
phoenix |
1.1 |
while ($row = $db->sql_fetchrow($result)) |
| 45 |
phoenix |
1.1 |
{ |
| 46 |
phoenix |
1.1 |
if ($row['title'] == '') { |
| 47 |
phoenix |
1.1 |
$row['title'] = (defined("_$row[link]LANG")) ? constant("_$row[link]LANG") : ereg_replace('_', ' ', $row['link']); |
| 48 |
phoenix |
1.1 |
} |
| 49 |
phoenix |
1.1 |
$row['link_type'] = -1; |
| 50 |
phoenix |
1.1 |
if (!isset($row['catpos'])) { |
| 51 |
phoenix |
1.1 |
$row['catpos'] = -1; |
| 52 |
phoenix |
1.1 |
} |
| 53 |
phoenix |
1.1 |
$menucats[$row['catpos']][$row['linkpos']] = $row; |
| 54 |
phoenix |
1.1 |
} |
| 55 |
phoenix |
1.1 |
$db->sql_freeresult($result); |
| 56 |
phoenix |
1.1 |
  |
| 57 |
phoenix |
1.1 |
// Load custom links from database |
| 58 |
phoenix |
1.1 |
$sql = "SELECT l.title, l.link, l.link_type, l.view, l.active, l.cat_id, l.pos AS linkpos, c.name, c.image, c.pos AS catpos, c.link AS catlnk, c.link_type AS cattype FROM ".$prefix."_modules_links AS l LEFT JOIN ".$prefix."_modules_cat c ON (c.cid = l.cat_id) $lnkquery"; |
| 59 |
phoenix |
1.1 |
$result = $db->sql_query($sql); |
| 60 |
phoenix |
1.1 |
while ($row = $db->sql_fetchrow($result)) |
| 61 |
phoenix |
1.1 |
{ |
| 62 |
phoenix |
1.1 |
if (defined($row['title'])) { |
| 63 |
phoenix |
1.1 |
$row['title'] = constant($row['title']); |
| 64 |
phoenix |
1.1 |
} |
| 65 |
phoenix |
1.1 |
$link = eregi_replace('&', '&', $row['link']); |
| 66 |
phoenix |
1.1 |
if (get_uri() != '') { |
| 67 |
phoenix |
1.1 |
if (ereg($link, get_uri())) { |
| 68 |
phoenix |
1.1 |
$row['status'] = '<span class="sgreen">•</span>'; |
| 69 |
phoenix |
1.1 |
$setstatus = 0; |
| 70 |
phoenix |
1.1 |
} |
| 71 |
phoenix |
1.1 |
} |
| 72 |
phoenix |
1.1 |
$row['link'] = eregi_replace('&', '&', $link); |
| 73 |
phoenix |
1.1 |
$row['catlnk'] = eregi_replace('&', '&', $row['catlnk']); |
| 74 |
phoenix |
1.1 |
$row['inmenu'] = 1; |
| 75 |
phoenix |
1.1 |
if (!isset($row['catpos'])) { |
| 76 |
phoenix |
1.1 |
$row['catpos'] = -1; |
| 77 |
phoenix |
1.1 |
} |
| 78 |
phoenix |
1.1 |
$menucats[$row['catpos']][$row['linkpos']] = $row; |
| 79 |
phoenix |
1.1 |
} |
| 80 |
phoenix |
1.1 |
$db->sql_freeresult($result); |
| 81 |
phoenix |
1.1 |
  |
| 82 |
phoenix |
1.1 |
$nocatcontent = ''; |
| 83 |
phoenix |
1.1 |
$content = "\n".'<ul id="menuList">'; |
| 84 |
phoenix |
1.1 |
if (defined('ADMIN_PAGES')) |
| 85 |
phoenix |
1.1 |
{ |
| 86 |
phoenix |
1.1 |
$content .= '<li><a href="'.$mainindex.'"><b>»</b> '._HOME.' <b>«</b></a>'."\n <ul>"; |
| 87 |
phoenix |
1.1 |
} |
| 88 |
phoenix |
1.1 |
elseif (!defined('ADMIN_PAGES') && is_admin()) |
| 89 |
phoenix |
1.1 |
{ |
| 90 |
phoenix |
1.2 |
global $CLASS; |
| 91 |
phoenix |
1.1 |
require_once(CORE_PATH.'classes/cpg_adminmenu.php'); |
| 92 |
phoenix |
1.1 |
$content .= '<li><a href="'.$adminindex.'"><b>»</b> '._ADMIN.' <b>«</b></a>'; |
| 93 |
nanocaio |
1.4 |
$content .= $CLASS['adminmenu']->display('all', 'cssmenu'); |
| 94 |
phoenix |
1.1 |
$content .='</li>'; |
| 95 |
phoenix |
1.1 |
} |
| 96 |
phoenix |
1.1 |
  |
| 97 |
phoenix |
1.1 |
ksort($menucats); |
| 98 |
phoenix |
1.2 |
while (list($ccat, $items) = each($menucats)) |
| 99 |
phoenix |
1.1 |
{ |
| 100 |
phoenix |
1.1 |
ksort($items); |
| 101 |
phoenix |
1.1 |
$catcontent = $offcontent = $hidcontent = ''; |
| 102 |
phoenix |
1.1 |
while (list($dummy, $item) = each($items)) |
| 103 |
phoenix |
1.1 |
{ |
| 104 |
phoenix |
1.1 |
$status = '<span class="sblack">•</span>'; |
| 105 |
phoenix |
1.1 |
if ($setstatus && $item['link'] == $module_name) { |
| 106 |
phoenix |
1.1 |
$status = '<span class="sgreen">•</span>'; |
| 107 |
phoenix |
1.1 |
$setstatus = 0; |
| 108 |
phoenix |
1.1 |
} |
| 109 |
phoenix |
1.1 |
if (!$item['active']) { |
| 110 |
phoenix |
1.1 |
$status = '<span class="sred">•</span>'; |
| 111 |
phoenix |
1.1 |
} elseif ($item['active'] && !$item['inmenu']) { |
| 112 |
phoenix |
1.1 |
$status = '<span class="sgray">•</span>'; |
| 113 |
phoenix |
1.1 |
} |
| 114 |
phoenix |
1.1 |
$status = isset($item['status']) ? $item['status'] : $status; |
| 115 |
phoenix |
1.1 |
if ($item['link_type'] <= 0) { |
| 116 |
phoenix |
1.1 |
$item['link'] = getlink($item['link']); |
| 117 |
phoenix |
1.1 |
} elseif ($item['link_type'] == 2) { |
| 118 |
phoenix |
1.1 |
$item['link'] .= '" target="_blank'; |
| 119 |
phoenix |
1.1 |
} |
| 120 |
phoenix |
1.1 |
$tmpcontent = '<li>'.$status.'<a href="'.$item['link'].'">'.$item['title'].'</a></li>'; |
| 121 |
phoenix |
1.1 |
if (!$item['active'] && !$item['inmenu']) { |
| 122 |
phoenix |
1.1 |
$offcontent .= $tmpcontent; |
| 123 |
phoenix |
1.1 |
} elseif (!$item['active']) { |
| 124 |
phoenix |
1.1 |
$hidcontent .= $tmpcontent; |
| 125 |
phoenix |
1.1 |
} else { |
| 126 |
phoenix |
1.1 |
$catcontent .= $tmpcontent; |
| 127 |
phoenix |
1.1 |
} |
| 128 |
phoenix |
1.1 |
$cattitle = $item['name']; |
| 129 |
phoenix |
1.1 |
$catlnk = $item['catlnk']; |
| 130 |
phoenix |
1.1 |
$cattype = $item['cattype']; |
| 131 |
phoenix |
1.1 |
} |
| 132 |
phoenix |
1.1 |
$cattitle = (defined($cattitle) ? constant($cattitle) : $cattitle); |
| 133 |
phoenix |
1.1 |
$catcontent .= $hidcontent.$offcontent; |
| 134 |
phoenix |
1.1 |
if (!empty($catlnk)) { |
| 135 |
phoenix |
1.1 |
if ($cattype <= 0) { |
| 136 |
phoenix |
1.1 |
$catlnk = getlink($catlnk); |
| 137 |
phoenix |
1.1 |
} elseif ($cattype == 2) { |
| 138 |
phoenix |
1.1 |
$catlnk .= '" target="_blank'; |
| 139 |
phoenix |
1.1 |
} |
| 140 |
phoenix |
1.5 |
$cattitlel = defined('ADMIN_PAGES') ? '<a href="'.$catlnk.'">'.$cattitle.'</a>' : '<a href="'.$catlnk.'"><b>•</b> '.$cattitle.'</a>'; |
| 141 |
phoenix |
1.1 |
} else { |
| 142 |
phoenix |
1.1 |
$cattitlel = defined('ADMIN_PAGES') ? '<a>'.$cattitle.'</a>': '<a><b>•</b> '.$cattitle.'</a>'; |
| 143 |
phoenix |
1.1 |
} |
| 144 |
phoenix |
1.2 |
if ($ccat >= 0) { |
| 145 |
phoenix |
1.1 |
$content .= "\n ".'<li>'.(defined('ADMIN_PAGES') ? '<span>»</span>': '').$cattitlel."\n <ul>".$catcontent; |
| 146 |
phoenix |
1.1 |
$content .= "\n </ul></li>"; |
| 147 |
phoenix |
1.1 |
} else { |
| 148 |
phoenix |
1.1 |
$nocatcontent = "\n ".'<li>'.(defined('ADMIN_PAGES') ? '<span>»</span><a>None</a>' : '<a><b>•</b> None</a>')."\n <ul>".$catcontent; |
| 149 |
phoenix |
1.1 |
$nocatcontent .= "\n </ul></li>"; |
| 150 |
phoenix |
1.1 |
} |
| 151 |
phoenix |
1.1 |
} |
| 152 |
phoenix |
1.1 |
$content .= $nocatcontent; |
| 153 |
phoenix |
1.1 |
  |
| 154 |
phoenix |
1.1 |
if (defined('ADMIN_PAGES') && is_admin()) |
| 155 |
phoenix |
1.1 |
{ |
| 156 |
phoenix |
1.1 |
$content .= "\n</ul></li>\n"; |
| 157 |
phoenix |
1.1 |
global $CLASS; |
| 158 |
phoenix |
1.1 |
require_once(CORE_PATH.'classes/cpg_adminmenu.php'); |
| 159 |
phoenix |
1.2 |
$content .= $CLASS['adminmenu']->display($ccat, 'cssmenu'); |
| 160 |
phoenix |
1.1 |
} |
| 161 |
phoenix |
1.1 |
  |
| 162 |
phoenix |
1.1 |
$content .= "\n</ul>\n"; |
| 163 |
phoenix |
1.1 |
$mmcontent = $content; |