PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/manager/frames/menu.php

https://github.com/good-web-master/modx.evo.custom
PHP | 389 lines | 307 code | 31 blank | 51 comment | 68 complexity | 7a4933b386b1d8f817c673c3f063e12a MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0, GPL-2.0, MIT, BSD-3-Clause
  1. <?php
  2. if(IN_MANAGER_MODE!="true") die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the MODx Content Manager instead of accessing this file directly.");
  3. if (!array_key_exists('mail_check_timeperiod', $modx->config) || !is_numeric($modx->config['mail_check_timeperiod'])) {
  4. $modx->config['mail_check_timeperiod'] = 5;
  5. }
  6. if ($manager_theme) $manager_theme .= '/';
  7. $mxla = $modx_lang_attribute ? $modx_lang_attribute : 'en';
  8. ?>
  9. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  10. <html <?php echo ($modx_textdir ? 'dir="rtl" lang="' : 'lang="').$mxla.'" xml:lang="'.$mxla.'"'; ?>>
  11. <head>
  12. <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $modx_manager_charset?>" />
  13. <title>nav</title>
  14. <link rel="stylesheet" type="text/css" href="media/style/<?php echo $manager_theme?>style.css" />
  15. <script src="media/script/mootools/mootools.js" type="text/javascript"></script>
  16. <script src="media/script/mootools/moodx.js" type="text/javascript"></script>
  17. <script type="text/javascript" src="media/script/session.js"></script>
  18. <script type="text/javascript">
  19. // TREE FUNCTIONS - FRAME
  20. // These functions affect the tree frame and any items that may be pointing to the tree.
  21. var currentFrameState = 'open';
  22. var defaultFrameWidth = '<?php echo !$modx_textdir ? '260,*' : '*,260'?>';
  23. var userDefinedFrameWidth = '<?php echo !$modx_textdir ? '260,*' : '*,260'?>';
  24. var workText;
  25. var buildText;
  26. // Create the AJAX mail update object before requesting it
  27. var updateMailerAjx = new Ajax('index.php', {method:'post', postBody:'updateMsgCount=true', onComplete:showResponse});
  28. function updateMail(now) {
  29. try {
  30. // if 'now' is set, runs immediate ajax request (avoids problem on initial loading where periodical waits for time period before making first request)
  31. if (now)
  32. updateMailerAjx.request();
  33. return false;
  34. } catch(oException) {
  35. // Delay first run until we're ready...
  36. xx=updateMail.delay(1000,'',true);
  37. }
  38. };
  39. function showResponse(request) {
  40. var counts = request.split(',');
  41. var elm = $('msgCounter');
  42. if (elm) elm.innerHTML ='(' + counts[0] + ' / ' + counts[1] + ')';
  43. var elm = $('newMail');
  44. if (elm) elm.style.display = counts[0] >0 ? 'inline' : 'none';
  45. }
  46. window.addEvent('load', function() {
  47. updateMail(true); // First run update
  48. updateMail.periodical(<?php echo $modx->config['mail_check_timeperiod'] * 1000 ?>, '', true); // Periodical Updater
  49. if(top.__hideTree) {
  50. // display toc icon
  51. var elm = $('tocText');
  52. if(elm) elm.innerHTML = "<a href='#' onclick='defaultTreeFrame();'><img src='<?php echo $_style['show_tree']?>' alt='<?php echo $_lang['show_tree']?>' width='16' height='16' /></a>";
  53. }
  54. });
  55. function hideTreeFrame() {
  56. userDefinedFrameWidth = parent.document.getElementsByTagName("FRAMESET").item(1).cols;
  57. currentFrameState = 'closed';
  58. try {
  59. var elm = $('tocText');
  60. if(elm) elm.innerHTML = "<a href='#' onclick='defaultTreeFrame();'><img src='<?php echo $_style['show_tree']?>' alt='<?php echo $_lang['show_tree']?>' width='16' height='16' /></a>";
  61. parent.document.getElementsByTagName("FRAMESET").item(1).cols = '<?php echo (!$modx_textdir ? '0,*' : '*,0')?>';
  62. top.__hideTree = true;
  63. } catch(oException) {
  64. x=window.setTimeout('hideTreeFrame()', 1000);
  65. }
  66. }
  67. function defaultTreeFrame() {
  68. userDefinedFrameWidth = defaultFrameWidth;
  69. currentFrameState = 'open';
  70. try {
  71. var elm = $('tocText');
  72. if(elm) elm.innerHTML = "";
  73. parent.document.getElementsByTagName("FRAMESET").item(1).cols = defaultFrameWidth;
  74. top.__hideTree = false;
  75. } catch(oException) {
  76. z=window.setTimeout('defaultTreeFrame()', 1000);
  77. }
  78. }
  79. // TREE FUNCTIONS - Expand/ Collapse
  80. // These functions affect the expanded/collapsed state of the tree and any items that may be pointing to it
  81. function expandTree() {
  82. try {
  83. parent.tree.d.openAll(); // dtree
  84. } catch(oException) {
  85. zz=window.setTimeout('expandTree()', 1000);
  86. }
  87. }
  88. function collapseTree() {
  89. try {
  90. parent.tree.d.closeAll(); // dtree
  91. } catch(oException) {
  92. yy=window.setTimeout('collapseTree()', 1000);
  93. }
  94. }
  95. // GENERAL FUNCTIONS - Refresh
  96. // These functions are used for refreshing the tree or menu
  97. function reloadtree() {
  98. var elm = $('buildText');
  99. if (elm) {
  100. elm.innerHTML = "&nbsp;&nbsp;<img src='<?php echo $_style['icons_loading_doc_tree']?>' width='16' height='16' />&nbsp;<?php echo $_lang['loading_doc_tree']?>";
  101. elm.style.display = 'block';
  102. }
  103. top.tree.saveFolderState(); // save folder state
  104. setTimeout('top.tree.restoreTree()',200);
  105. }
  106. function reloadmenu() {
  107. <?php if($manager_layout==0) { ?>
  108. var elm = $('buildText');
  109. if (elm) {
  110. elm.innerHTML = "&nbsp;&nbsp;<img src='<?php echo $_style['icons_working']?>' width='16' height='16' />&nbsp;<?php echo $_lang['loading_menu']?>";
  111. elm.style.display = 'block';
  112. }
  113. parent.mainMenu.location.reload();
  114. <?php } ?>
  115. }
  116. function startrefresh(rFrame){
  117. if(rFrame==1){
  118. x=window.setTimeout('reloadtree()',500);
  119. }
  120. if(rFrame==2) {
  121. x=window.setTimeout('reloadmenu()',500);
  122. }
  123. if(rFrame==9) {
  124. x=window.setTimeout('reloadmenu()',500);
  125. y=window.setTimeout('reloadtree()',500);
  126. }
  127. if(rFrame==10) {
  128. window.top.location.href = "../manager";
  129. }
  130. }
  131. // GENERAL FUNCTIONS - Work
  132. // These functions are used for showing the user the system is working
  133. function work() {
  134. var elm = $('workText');
  135. if (elm) elm.innerHTML = "&nbsp;<img src='<?php echo $_style['icons_working']?>' width='16' height='16' />&nbsp;<?php echo $_lang['working']?>";
  136. else w=window.setTimeout('work()', 50);
  137. }
  138. function stopWork() {
  139. var elm = $('workText');
  140. if (elm) elm.innerHTML = "";
  141. else ww=window.setTimeout('stopWork()', 50);
  142. }
  143. // GENERAL FUNCTIONS - Remove locks
  144. // This function removes locks on documents, templates, parsers, and snippets
  145. function removeLocks() {
  146. if(confirm("<?php echo $_lang['confirm_remove_locks']?>")==true) {
  147. top.main.document.location.href="index.php?a=67";
  148. }
  149. }
  150. function showWin() {
  151. window.open('../');
  152. }
  153. function stopIt() {
  154. top.mainMenu.stopWork();
  155. }
  156. function openCredits() {
  157. parent.main.document.location.href = "index.php?a=18";
  158. xwwd = window.setTimeout('stopIt()', 2000);
  159. }
  160. function NavToggle(element) {
  161. // This gives the active tab its look
  162. var navid = document.getElementById('nav');
  163. var navs = navid.getElementsByTagName('li');
  164. var navsCount = navs.length;
  165. for(j = 0; j < navsCount; j++) {
  166. active = (navs[j].id == element.parentNode.id) ? "active" : "";
  167. navs[j].className = active;
  168. }
  169. // remove focus from top nav
  170. if(element) element.blur();
  171. }
  172. </script>
  173. <!--[if lt IE 7]>
  174. <style type="text/css">
  175. body { behavior: url(media/script/forIE/htcmime.php?file=csshover.htc) }
  176. img { behavior: url(media/script/forIE/htcmime.php?file=pngbehavior.htc); }
  177. </style>
  178. <![endif]-->
  179. </head>
  180. <body id="topMenu" class="<?php echo $modx_textdir ? 'rtl':'ltr'?>">
  181. <div id="tocText"<?php echo $modx_textdir ? ' class="tocTextRTL"' : '' ?>></div>
  182. <div id="topbar">
  183. <div id="topbar-container">
  184. <div id="statusbar">
  185. <span id="buildText"></span>
  186. <span id="workText"></span>
  187. </div>
  188. <div id="supplementalNav">
  189. <?php echo $modx->getLoginUserName(). ($modx->hasPermission('change_password') ? ': <a onclick="this.blur();" href="index.php?a=28" target="main">'.$_lang['change_password'].'</a>'."\n" : "\n") ?>
  190. <?php if($modx->hasPermission('messages')) { ?>
  191. | <span id="newMail"><a href="index.php?a=10" title="<?php echo $_lang['you_got_mail']?>" target="main"> <img src="<?php echo $_style['icons_mail']?>" width="16" height="16" /></a></span>
  192. <a onclick="this.blur();" href="index.php?a=10" target="main"><?php echo $_lang['messages']?> <span id="msgCounter">( ? / ? )</span></a>
  193. <?php }
  194. if($modx->hasPermission('help')) { ?>
  195. | <a href="index.php?a=9" target="main"><?php echo $_lang['help']?></a>
  196. <?php } ?>
  197. | <a href="index.php?a=8" target="_top"><?php echo $_lang['logout']?></a>
  198. | <span title="<?php echo $site_name ?> &ndash; <?php echo $modx_full_appname ?>"><?php echo $modx_version ?></span>&nbsp;
  199. <!-- close #supplementalNav --></div>
  200. </div>
  201. </div>
  202. <form name="menuForm" action="l4mnu.php" class="clear">
  203. <input name="sessToken" id="sessTokenInput" value="<?php echo md5(session_id());?>" />
  204. <div id="Navcontainer">
  205. <div id="divNav">
  206. <ul id="nav">
  207. <?php
  208. // Concatenate menu items based on permissions
  209. // Site Menu
  210. $sitemenu = array();
  211. // home
  212. $sitemenu[] = '<li><a onclick="this.blur();" href="index.php?a=2" target="main">'.$_lang['home'].'</a></li>';
  213. // preview
  214. $sitemenu[] = '<li><a onclick="this.blur();" href="../" target="_blank">'.$_lang['preview'].'</a></li>';
  215. // clear-cache
  216. $sitemenu[] = '<li><a onclick="this.blur();" href="index.php?a=26" target="main">'.$_lang['refresh_site'].'</a></li>';
  217. // search
  218. $sitemenu[] = '<li><a onclick="this.blur();" href="index.php?a=71" target="main">'.$_lang['search'].'</a></li>';
  219. if ($modx->hasPermission('new_document')) {
  220. // new-document
  221. $sitemenu[] = '<li><a onclick="this.blur();" href="index.php?a=4" target="main">'.$_lang['add_resource'].'</a></li>';
  222. // new-weblink
  223. $sitemenu[] = '<li><a onclick="this.blur();" href="index.php?a=72" target="main">'.$_lang['add_weblink'].'</a></li>';
  224. }
  225. // Elements Menu
  226. $resourcemenu = array();
  227. if($modx->hasPermission('new_template') || $modx->hasPermission('edit_template') || $modx->hasPermission('new_snippet') || $modx->hasPermission('edit_snippet') || $modx->hasPermission('new_chunk') || $modx->hasPermission('edit_chunk') || $modx->hasPermission('new_plugin') || $modx->hasPermission('edit_plugin')) {
  228. // Elements
  229. $resourcemenu[] = '<li><a onclick="this.blur();" href="index.php?a=76" target="main">'.$_lang['element_management'].'</a></li>';
  230. }
  231. if($modx->hasPermission('file_manager')) {
  232. // Manage-Files
  233. $resourcemenu[] = '<li><a onclick="this.blur();" href="index.php?a=31" target="main">'.$_lang['manage_files'].'</a></li>';
  234. }
  235. if($modx->hasPermission('manage_metatags') && $modx->config['show_meta'] == 1) {
  236. // Manage-Metatags
  237. $resourcemenu[] = '<li><a onclick="this.blur();" href="index.php?a=81" target="main">'.$_lang['manage_metatags'].'</a></li>';
  238. }
  239. // Modules Menu Items
  240. $modulemenu = array();
  241. if($modx->hasPermission('new_module') || $modx->hasPermission('edit_module')) {
  242. // manage-modules
  243. $modulemenu[] = '<li><a onclick="this.blur();" href="index.php?a=106" target="main">'.$_lang['module_management'].'</a></li>';
  244. }
  245. if($modx->hasPermission('exec_module')) {
  246. // Each module
  247. if ($_SESSION['mgrRole'] != 1) {
  248. // Display only those modules the user can execute
  249. $rs = $modx->db->query('SELECT DISTINCT sm.id, sm.name, mg.member
  250. FROM '.$modx->getFullTableName('site_modules').' AS sm
  251. LEFT JOIN '.$modx->getFullTableName('site_module_access').' AS sma ON sma.module = sm.id
  252. LEFT JOIN '.$modx->getFullTableName('member_groups').' AS mg ON sma.usergroup = mg.user_group
  253. WHERE (mg.member IS NULL OR mg.member = '.$modx->getLoginUserID().') AND sm.disabled != 1');
  254. } else {
  255. // Admins get the entire list
  256. $rs = $modx->db->select('*', $modx->getFullTableName('site_modules'), 'disabled != 1');
  257. }
  258. while ($content = $modx->db->getRow($rs)) {
  259. $modulemenu[] = '<li><a onclick="this.blur();" href="index.php?a=112&amp;id='.$content['id'].'" target="main">'.$content['name'].'</a></li>';
  260. }
  261. }
  262. // Security menu items (users)
  263. $securitymenu = array();
  264. if($modx->hasPermission('edit_user')) {
  265. // manager-users
  266. $securitymenu[] = '<li><a onclick="this.blur();" href="index.php?a=75" target="main">'.$_lang['user_management_title'].'</a></li>';
  267. }
  268. if($modx->hasPermission('edit_web_user')) {
  269. // web-users
  270. $securitymenu[] = '<li><a onclick="this.blur();" href="index.php?a=99" target="main">'.$_lang['web_user_management_title'].'</a></li>';
  271. }
  272. if($modx->hasPermission('new_role') || $modx->hasPermission('edit_role') || $modx->hasPermission('delete_role')) {
  273. // roles
  274. $securitymenu[] = '<li><a onclick="this.blur();" href="index.php?a=86" target="main">'.$_lang['role_management_title'].'</a></li>';
  275. }
  276. if($modx->hasPermission('access_permissions')) {
  277. // manager-perms
  278. $securitymenu[] = '<li><a onclick="this.blur();" href="index.php?a=40" target="main">'.$_lang['manager_permissions'].'</a></li>';
  279. }
  280. if($modx->hasPermission('web_access_permissions')) {
  281. // web-user-perms
  282. $securitymenu[] = '<li><a onclick="this.blur();" href="index.php?a=91" target="main">'.$_lang['web_permissions'].'</a></li>';
  283. }
  284. // Tools Menu
  285. $toolsmenu = array();
  286. if($modx->hasPermission('bk_manager')) {
  287. // backup-mgr
  288. $toolsmenu[] = '<li><a onclick="this.blur();" href="index.php?a=93" target="main">'.$_lang['bk_manager'].'</a></li>';
  289. }
  290. if($modx->hasPermission('remove_locks')) {
  291. // unlock-pages
  292. $toolsmenu[] = '<li><a onclick="this.blur();" href="javascript:removeLocks();">'.$_lang['remove_locks'].'</a></li>';
  293. }
  294. if($modx->hasPermission('import_static')) {
  295. // import-html
  296. $toolsmenu[] = '<li><a onclick="this.blur();" href="index.php?a=95" target="main">'.$_lang['import_site'].'</a></li>';
  297. }
  298. if($modx->hasPermission('export_static')) {
  299. // export-static-site
  300. $toolsmenu[] = '<li><a onclick="this.blur();" href="index.php?a=83" target="main">'.$_lang['export_site'].'</a></li>';
  301. }
  302. if($modx->hasPermission('settings')) {
  303. // configuration
  304. $toolsmenu[] = '<li><a onclick="this.blur();" href="index.php?a=17" target="main">'.$_lang['edit_settings'].'</a></li>';
  305. }
  306. // Reports Menu
  307. $reportsmenu = array();
  308. // site-sched
  309. $reportsmenu[] = '<li><a onclick="this.blur();" href="index.php?a=70" target="main">'.$_lang['site_schedule'].'</a></li>';
  310. if($modx->hasPermission('view_eventlog')) {
  311. // eventlog
  312. $reportsmenu[] = '<li><a onclick="this.blur();" href="index.php?a=114" target="main">'.$_lang['eventlog_viewer'].'</a></li>';
  313. }
  314. if($modx->hasPermission('logs')) {
  315. // manager-audit-trail
  316. $reportsmenu[] = '<li><a onclick="this.blur();" href="index.php?a=13" target="main">'.$_lang['view_logging'].'</a></li>';
  317. // system-info
  318. $reportsmenu[] = '<li><a onclick="this.blur();" href="index.php?a=53" target="main">'.$_lang['view_sysinfo'].'</a></li>';
  319. }
  320. // Output Menus where there are items to show
  321. if (!empty($sitemenu)) {
  322. echo "\t",'<li id="limenu3" class="active"><a href="#menu3" onclick="new NavToggle(this); return false;">',$_lang['site'],'</a><ul class="subnav" id="menu3">',"\n\t\t",
  323. implode("\n\t\t", $sitemenu),
  324. "\n\t</ul></li>\n";
  325. }
  326. if (!empty($resourcemenu)) {
  327. echo "\t",'<li id="limenu5"><a href="#menu5" onclick="new NavToggle(this); return false;">',$_lang['elements'],'</a><ul class="subnav" id="menu5">',"\n\t\t",
  328. implode("\n\t\t", $resourcemenu),
  329. "\n\t</ul></li>\n";
  330. }
  331. if (!empty($modulemenu)) {
  332. echo "\t",'<li id="limenu9"><a href="#menu9" onclick="new NavToggle(this); return false;">',$_lang['modules'],'</a><ul class="subnav" id="menu9">',"\n\t\t",
  333. implode("\n\t\t", $modulemenu),
  334. "\n\t</ul></li>\n";
  335. }
  336. if (!empty($securitymenu)) {
  337. echo "\t",'<li id="limenu2"><a href="#menu2" onclick="new NavToggle(this); return false;">',$_lang['users'],'</a><ul class="subnav" id="menu2">',"\n\t\t",
  338. implode("\n\t\t", $securitymenu),
  339. "\n\t</ul></li>\n";
  340. }
  341. if (!empty($toolsmenu)) {
  342. echo "\t",'<li id="limenu1-1"><a href="#menu1-1" onclick="new NavToggle(this); return false;">',$_lang['tools'],'</a><ul class="subnav" id="menu1-1">',"\n\t\t",
  343. implode("\n\t\t", $toolsmenu),
  344. "\n\t</ul></li>\n";
  345. }
  346. if (!empty($reportsmenu)) {
  347. echo "\t",'<li id="limenu1-2"><a href="#menu1-2" onclick="new NavToggle(this); return false;">',$_lang['reports'],'</a><ul class="subnav" id="menu1-2">',"\n\t\t",
  348. implode("\n\t\t", $reportsmenu),
  349. "\n\t</ul></li>\n";
  350. }
  351. ?>
  352. </ul>
  353. </div>
  354. </div>
  355. </form>
  356. <div id="menuSplitter"></div>
  357. </body>
  358. </html>