PageRenderTime 69ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 1ms

/web/concrete/helpers/concrete/dashboard.php

https://github.com/glockops/concrete5
PHP | 648 lines | 506 code | 105 blank | 37 comment | 124 complexity | 6ce7842242bfb5ad674099ad843e9205 MD5 | raw file
Possible License(s): MIT, LGPL-2.1, BSD-3-Clause
  1. <?
  2. /**
  3. * @package Helpers
  4. * @category Concrete
  5. * @author Andrew Embler <andrew@concrete5.org>
  6. * @copyright Copyright (c) 2003-2008 Concrete5. (http://www.concrete5.org)
  7. * @license http://www.concrete5.org/license/ MIT License
  8. */
  9. /**
  10. * Functions for use with the C5 dashboard.
  11. * @package Helpers
  12. * @category Concrete
  13. * @author Andrew Embler <andrew@concrete5.org>
  14. * @copyright Copyright (c) 2003-2008 Concrete5. (http://www.concrete5.org)
  15. * @license http://www.concrete5.org/license/ MIT License
  16. */
  17. defined('C5_EXECUTE') or die("Access Denied.");
  18. class ConcreteDashboardHelper {
  19. /**
  20. * Checks to see if a user has access to the C5 dashboard.
  21. */
  22. public function canRead() {
  23. $c = Page::getByPath('/dashboard', 'ACTIVE');
  24. $cp = new Permissions($c);
  25. return $cp->canViewPage();
  26. }
  27. public function canAccessComposer() {
  28. $c = Page::getByPath('/dashboard/composer', 'ACTIVE');
  29. $cp = new Permissions($c);
  30. return $cp->canViewPage();
  31. }
  32. /**
  33. * Test if the current path is within the dashboard.
  34. * Optionally, a Page or path can be passed to test.
  35. *
  36. * @param Page | string $page (optional)
  37. * @return [boolean]
  38. */
  39. public function inDashboard($page = false) {
  40. if ($page instanceof Page && !$page->isError()) {
  41. $path = $page->getCollectionPath();
  42. } elseif (is_string($page)) {
  43. $path = $page;
  44. } else {
  45. $request = Request::get();
  46. $path = $request->getRequestCollectionPath();
  47. }
  48. return strpos($path, '/dashboard') === 0;
  49. }
  50. public function getDashboardPaneFooterWrapper($includeDefaultBody = true) {
  51. $html = '</div></div></div></div>';
  52. if ($includeDefaultBody) {
  53. $html .= '</div>';
  54. }
  55. return $html;
  56. }
  57. public function getDashboardPaneHeaderWrapper($title = false, $help = false, $span = 'span12', $includeDefaultBody = true, $navigatePages = array(), $upToPage = false, $favorites = true) {
  58. $spantotal = 12;
  59. $offset = preg_match('/offset([0-9]+)/i', $span, $offsetmatches);
  60. if ($offset) {
  61. $offsettotal = $offsetmatches[1];
  62. $hasspan = preg_match('/span([0-9]+)/i', $span, $spanmatches);
  63. if ($hasspan) {
  64. $spantotal = $spanmatches[1];
  65. $gridtotal = ($offsettotal * 2) + $spantotal;
  66. }
  67. }
  68. if ($gridtotal > 12) {
  69. // we are working with legacy bootstrap 16-column grid
  70. // we take the offset and then we subtract from the span
  71. $spantotal = $spantotal - ($gridtotal - 12);
  72. $spantotal .= ' offset' . $offsettotal;
  73. $span = 'span' . $spantotal;
  74. }
  75. $html = '<div class="ccm-ui"><div class="row"><div class="' . $span . '"><div class="ccm-pane">';
  76. $html .= self::getDashboardPaneHeader($title, $help, $navigatePages, $upToPage, $favorites);
  77. if ($includeDefaultBody) {
  78. $html .= '<div class="ccm-pane-body ccm-pane-body-footer">';
  79. }
  80. return $html;
  81. }
  82. public function getDashboardPaneHeader($title = false, $help = false, $navigatePages = array(), $upToPage = false, $favorites = true) {
  83. $c = Page::getCurrentPage();
  84. $vt = Loader::helper('validation/token');
  85. $token = $vt->generate('access_quick_nav');
  86. $currentMenu = array();
  87. $nh = Loader::helper('navigation');
  88. $trail = $nh->getTrailToCollection($c);
  89. if (count($trail) > 1 || count($navigatePages) > 1 || is_object($upToPage)) {
  90. $parent = Page::getByID($c->getCollectionParentID());
  91. if (count($trail) > 1 && (!is_object($upToPage))) {
  92. $upToPage = Page::getByID($parent->getCollectionParentID());
  93. }
  94. Loader::block('autonav');
  95. $subpages = array();
  96. if ($navigatePages !== -1) {
  97. if (count($navigatePages) > 0) {
  98. $subpages = $navigatePages;
  99. } else {
  100. $subpages = AutonavBlockController::getChildPages($parent);
  101. }
  102. }
  103. $subpagesP = array();
  104. if(is_array($subpages)) {
  105. foreach($subpages as $sc) {
  106. $cp = new Permissions($sc);
  107. if ($cp->canViewPage()) {
  108. $subpagesP[] = $sc;
  109. }
  110. }
  111. }
  112. if (count($subpagesP) > 0 || is_object($upToPage)) {
  113. $relatedPages = '<ul id="ccm-page-navigate-pages-content" class="dropdown-menu">';
  114. foreach($subpagesP as $sc) {
  115. if ($sc->getAttribute('exclude_nav')) {
  116. continue;
  117. }
  118. if ($c->getCollectionPath() == $sc->getCollectionPath() || (strpos($c->getCollectionPath(), $sc->getCollectionPath()) == 0) && strpos($c->getCollectionPath(), $sc->getCollectionPath()) !== false) {
  119. $class= 'nav-selected';
  120. } else {
  121. $class = '';
  122. }
  123. $relatedPages .= '<li class="' . $class . '"><a href="' . $nh->getLinkToCollection($sc, false, true) . '">' . t($sc->getCollectionName()) . '</a></li>';
  124. }
  125. if ($upToPage) {
  126. $relatedPages .= '<li class="ccm-menu-separator"></li>';
  127. $relatedPages .= '<li><a href="' . $nh->getLinkToCollection($upToPage, false, true) . '">' . t('&lt; Back to %s', t($upToPage->getCollectionName())) . '</a></li>';
  128. }
  129. $relatedPages .= '</ul>';
  130. $navigateTitle = t($parent->getCollectionName());
  131. }
  132. }
  133. $html = '<div class="ccm-pane-header">';
  134. $class = 'ccm-icon-favorite';
  135. $qn = ConcreteDashboardMenu::getMine();
  136. $quicknav = $qn->getItems(false);
  137. if (in_array($c->getCollectionPath(), $quicknav)) {
  138. $class = 'ccm-icon-favorite-selected';
  139. }
  140. $html .= '<ul class="ccm-pane-header-icons">';
  141. if (!$help) {
  142. $ih = Loader::helper('concrete/interface/help');
  143. $pageHelp = $ih->getPages();
  144. if (isset($pageHelp[$c->getCollectionPath()])) {
  145. $help = $pageHelp[$c->getCollectionPath()];
  146. }
  147. }
  148. if (is_array($help)) {
  149. $help = $help[0] . '<br/><br/><a href="' . $help[1] . '" class="btn small" target="_blank">' . t('Learn More') . '</a>';
  150. }
  151. if (isset($relatedPages)) {
  152. $html .= '<li><a href="" class="ccm-icon-navigate-pages" data-toggle="dropdown" title="' . $navigateTitle . '" id="ccm-page-navigate-pages">' . t('Help') . '</a>' . $relatedPages . '</li>';
  153. }
  154. if ($help) {
  155. $html .= '<li><span style="display: none" id="ccm-page-help-content">' . $help . '</span><a href="javascript:void(0)" class="ccm-icon-help" title="' . t('Help') . '" id="ccm-page-help">' . t('Help') . '</a></li>';
  156. }
  157. if ($favorites) {
  158. $html .= '<li><a href="javascript:void(0)" id="ccm-add-to-quick-nav" onclick="ccm_toggleQuickNav(' . $c->getCollectionID() . ',\'' . $token . '\')" class="' . $class . '">' . t('Add to Favorites') . '</a></li>';
  159. }
  160. $html .= '<li><a href="javascript:void(0)" onclick="ccm_closeDashboardPane(this)" class="ccm-icon-close">' . t('Close') . '</a></li>';
  161. $html .= '</ul>';
  162. if (!$title) {
  163. $title = $c->getCollectionName();
  164. }
  165. $html .= '<h3>' . $title . '</h3>';
  166. $html .= '</div>';
  167. return $html;
  168. }
  169. public function getDashboardBackgroundImage() {
  170. $feed = array();
  171. // this feed is an array of standard PHP objects with a SRC, a caption, and a URL
  172. // allow for a custom white-label feed
  173. $filename = date('Ymd') . '.jpg';
  174. $obj = new stdClass;
  175. $obj->checkData = false;
  176. $obj->displayCaption = false;
  177. if (defined('WHITE_LABEL_DASHBOARD_BACKGROUND_FEED') && WHITE_LABEL_DASHBOARD_BACKGROUND_FEED != '') {
  178. $image = WHITE_LABEL_DASHBOARD_BACKGROUND_FEED . '/' . $filename;
  179. } else if (defined('WHITE_LABEL_DASHBOARD_BACKGROUND_SRC') && WHITE_LABEL_DASHBOARD_BACKGROUND_SRC != '') {
  180. $image = WHITE_LABEL_DASHBOARD_BACKGROUND_SRC;
  181. if ($image == 'none') {
  182. $image = '';
  183. }
  184. } else {
  185. $obj->checkData = true;
  186. $imageSetting = Config::get('DASHBOARD_BACKGROUND_IMAGE');
  187. if ($imageSetting == 'custom') {
  188. $fo = File::getByID(Config::get('DASHBOARD_BACKGROUND_IMAGE_CUSTOM_FILE_ID'));
  189. if (is_object($fo)) {
  190. $image = $fo->getRelativePath();
  191. }
  192. } else if ($imageSetting == 'none') {
  193. $image = '';
  194. } else {
  195. if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on')) {
  196. $image = DASHBOARD_BACKGROUND_FEED_SECURE . '/' . $filename;
  197. } else {
  198. $image = DASHBOARD_BACKGROUND_FEED . '/' . $filename;
  199. }
  200. $obj->displayCaption = true;
  201. }
  202. }
  203. $obj->filename = $filename;
  204. $obj->image = $image;
  205. return $obj;
  206. }
  207. public function addQuickNavToMenus($html) {
  208. $recent = '';
  209. ob_start();
  210. $c = Page::getCurrentPage();
  211. if (!is_array($_SESSION['ccmQuickNavRecentPages'])) {
  212. $_SESSION['ccmQuickNavRecentPages'] = array();
  213. }
  214. $session_pages = array_filter($_SESSION['ccmQuickNavRecentPages']);
  215. $session_pages[] = $c->getCollectionID();
  216. // Remove duplicates, making sure the most recent is kept.
  217. $session_pages = array_reverse(array_unique(array_reverse($session_pages)));
  218. // Tidy and eliminate non-existent collections, prep for later
  219. $breadcrumb_map = array();
  220. $last = 0;
  221. if (count($session_pages) > 0) {
  222. foreach($session_pages as $_cID) {
  223. $_c = Page::getByID($_cID);
  224. if ($_c->isError()) {
  225. continue;
  226. }
  227. $breadcrumb_map[$_cID] = $_c;
  228. $last = $_cID;
  229. }
  230. }
  231. // limit size, keeping numeric keys constant
  232. $max_breadcrumb_size = 5;
  233. // (NB - by using the above, the way is kept open for the size to be adjustable in the future)
  234. if (count($breadcrumb_map) > $max_breadcrumb_size) {
  235. $breadcrumb_map = array_slice($breadcrumb_map,-$max_breadcrumb_size, null, true);
  236. }
  237. $_SESSION['ccmQuickNavRecentPages'] = array_keys($breadcrumb_map);
  238. if (count($breadcrumb_map) > 0) { ?>
  239. <ul class="breadcrumb">
  240. <li><strong><?php echo t('Recent')?></strong> <span class="divider">:</span></li>
  241. <?php
  242. // create links
  243. foreach($breadcrumb_map as $_cID=>$_c) {
  244. $name = t('(No Name)');
  245. if ($_c->getCollectionName()) {
  246. $name = $_c->getCollectionName();
  247. }
  248. $divider = '';
  249. if ($_cID != $last) {
  250. $divider = '<span class="divider">/</span>';
  251. }
  252. ?> <li><a id="ccm-recent-page-<?php echo $_c->getCollectionID()?>" href="<?php echo Loader::helper('navigation')->getLinkToCollection($_c)?>"><?php echo t($name)?></a><?php echo $divider?></li>
  253. <?php
  254. }
  255. ?>
  256. </ul>
  257. <?
  258. }
  259. $recent = ob_get_contents();
  260. ob_end_clean();
  261. $html = str_replace("<!--recent-->", $recent, $html);
  262. return str_replace(array("\n", "\r", "\t"), "", $html);
  263. }
  264. public function getDashboardAndSearchMenus() {
  265. if (isset($_SESSION['dashboardMenus'][Localization::activeLocale()])) {
  266. return $_SESSION['dashboardMenus'][Localization::activeLocale()];
  267. }
  268. $d = ConcreteDashboardMenu::getMine();
  269. $items = $d->getItems();
  270. ob_start(); ?>
  271. <div id="ccm-intelligent-search-results">
  272. <?
  273. $page = Page::getByPath('/dashboard');
  274. $children = $page->getCollectionChildrenArray(true);
  275. $packagepages = array();
  276. $corepages = array();
  277. foreach($children as $ch) {
  278. $page = Page::getByID($ch);
  279. $pageP = new Permissions($page);
  280. if ($pageP->canRead()) {
  281. if (!$page->getAttribute("exclude_nav")) {
  282. if ($page->getPackageID() > 0) {
  283. $packagepages[] = $page;
  284. } else {
  285. $corepages[] = $page;
  286. }
  287. }
  288. } else {
  289. continue;
  290. }
  291. if ($page->getAttribute('exclude_search_index')) {
  292. continue;
  293. }
  294. if ($page->getCollectionPath() == '/dashboard/system') {
  295. $ch2 = $page->getCollectionChildrenArray();
  296. } else {
  297. $ch2 = $page->getCollectionChildrenArray(true);
  298. }
  299. ?>
  300. <div class="ccm-intelligent-search-results-module ccm-intelligent-search-results-module-onsite">
  301. <h1><?=t($page->getCollectionName())?></h1>
  302. <ul class="ccm-intelligent-search-results-list">
  303. <? if (count($ch2) == 0) { ?>
  304. <li><a href="<?=Loader::helper('navigation')->getLinkTocollection($page, false, true)?>"><?=t($page->getCollectionName())?></a><span><?=t($page->getCollectionName())?> <?=t($page->getAttribute('meta_keywords'))?></span></li>
  305. <? } ?>
  306. <?
  307. if ($page->getCollectionPath() == '/dashboard/system') { ?>
  308. <li><a href="<?=Loader::helper('navigation')->getLinkTocollection($page, false, true)?>"><?=t('View All')?></a><span><?=t($page->getCollectionName())?> <?=t($page->getAttribute('meta_keywords'))?></span></li>
  309. <?
  310. }
  311. foreach($ch2 as $chi) {
  312. $subpage = Page::getByID($chi);
  313. $subpageP = new Permissions($subpage);
  314. if (!$subpageP->canRead()) {
  315. continue;
  316. }
  317. if ($subpage->getAttribute('exclude_search_index')) {
  318. continue;
  319. }
  320. ?>
  321. <li><a href="<?=Loader::helper('navigation')->getLinkTocollection($subpage, false, true)?>"><?=t($subpage->getCollectionName())?></a><span><? if ($page->getCollectionPath() != '/dashboard/system') { ?><?=t($page->getCollectionName())?> <?=t($page->getAttribute('meta_keywords'))?> <? } ?><?=t($subpage->getCollectionName())?> <?=t($subpage->getAttribute('meta_keywords'))?></span></li>
  322. <?
  323. }
  324. ?>
  325. </ul>
  326. </div>
  327. <? }
  328. $custHome = Page::getByPath('/dashboard/home');
  329. $custHomeP = new Permissions($custHome);
  330. if ($custHomeP->canRead()) {
  331. ?>
  332. <div class="ccm-intelligent-search-results-module ccm-intelligent-search-results-module-onsite">
  333. <h1><?=t('Dashboard Home')?></h1>
  334. <ul class="ccm-intelligent-search-results-list">
  335. <li><a href="<?=View::url('/dashboard/home')?>"><?=t('Customize')?> <span><?=t('Customize Dashboard Home')?></span></a></li>
  336. </ul>
  337. </div>
  338. <? } ?>
  339. <div class="ccm-intelligent-search-results-module ccm-intelligent-search-results-module-loading">
  340. <h1><?=t('Your Site')?></h1>
  341. <ul class="ccm-intelligent-search-results-list" id="ccm-intelligent-search-results-list-your-site">
  342. </ul>
  343. </div>
  344. <? if (ENABLE_INTELLIGENT_SEARCH_HELP) { ?>
  345. <div class="ccm-intelligent-search-results-module ccm-intelligent-search-results-module-offsite ccm-intelligent-search-results-module-loading">
  346. <h1><?=t('Help')?></h1>
  347. <ul class="ccm-intelligent-search-results-list" id="ccm-intelligent-search-results-list-help">
  348. </ul>
  349. </div>
  350. <? } ?>
  351. <? if (ENABLE_INTELLIGENT_SEARCH_MARKETPLACE) { ?>
  352. <div class="ccm-intelligent-search-results-module ccm-intelligent-search-results-module-offsite ccm-intelligent-search-results-module-loading">
  353. <h1><?=t('Add-Ons')?></h1>
  354. <ul class="ccm-intelligent-search-results-list" id="ccm-intelligent-search-results-list-marketplace">
  355. </ul>
  356. </div>
  357. <? } ?>
  358. </div>
  359. <div id="ccm-dashboard-overlay">
  360. <div id="ccm-dashboard-overlay-core">
  361. <div class="ccm-dashboard-overlay-inner" id="ccm-dashboard-overlay-main">
  362. <!--recent-->
  363. <?
  364. $currentHeader = false;
  365. $x = 0;
  366. $itemsChanged = false;
  367. foreach($items as $path) {
  368. $p = Page::getByPath($path, 'ACTIVE');
  369. // If page is not found etc, remove it from items
  370. if ($p->isError()) {
  371. $d->remove($p);
  372. $itemsChanged = true;
  373. continue;
  374. }
  375. $pc = new Permissions($p);
  376. if ($pc->canViewPage()) {
  377. $name = t($p->getCollectionName());
  378. $parent = Page::getByID($p->getCollectionParentID(), 'ACTIVE');
  379. if ($parent->getCollectionPath() == '/dashboard') {
  380. $parent = $p;
  381. $name = t('Home');
  382. }
  383. if ($currentHeader != $parent->getCollectionID()) { ?>
  384. <? if ($currentHeader != false) { ?>
  385. </ul>
  386. </div>
  387. <? $x++; ?>
  388. <? if ($x % 4 == 0) { ?>
  389. <div class="clearfix" style="padding-bottom: 0px"></div>
  390. <? } ?>
  391. <? } ?>
  392. <div class="ccm-dashboard-overlay-module">
  393. <h1><?=t($parent->getCollectionName())?></h1>
  394. <ul>
  395. <? $currentHeader = $parent->getCollectionID(); ?>
  396. <? } ?>
  397. <li><a href="<?=Loader::helper('navigation')->getLinkToCollection($p, false, true)?>"><?=$name?></a></li>
  398. <? } ?>
  399. <? } ?>
  400. <?
  401. if ($itemsChanged) {
  402. $u = new User;
  403. $u->saveConfig('QUICK_NAV_BOOKMARKS', serialize($d));
  404. }
  405. ?>
  406. <? if ($currentHeader != false) { ?>
  407. </ul>
  408. </div>
  409. <? } ?>
  410. </div>
  411. </div>
  412. <div id="ccm-dashboard-overlay-misc" class="ccm-dashboard-overlay-misc-rounded">
  413. <div class="ccm-dashboard-overlay-inner">
  414. <?
  415. // Before we throw in a UL, we check permissions, etc. to see if any of the LI items need to be shown.
  416. $systemNews = Page::getByPath('/dashboard/news');
  417. $systemNewsP = new Permissions($systemNews);
  418. $canAccessNews = $systemNewsP->canRead();
  419. $systemSettings = Page::getByPath('/dashboard/system');
  420. $systemSettingsP = new Permissions($systemSettings);
  421. $canAccessSystem = $systemSettingsP->canRead();
  422. $tpa = new TaskPermission();
  423. $canAccessExtend = $tpa->canInstallPackages();
  424. $systemExtend = Page::getByPath('/dashboard/extend');
  425. $systemExtendP = new Permissions($systemExtend);
  426. $canViewExtend = $systemExtendP->canRead();
  427. // If any need to be shown then we proceed...
  428. if($canAccessNews || $canAccessSystem || ($canAccessExtend && $canViewExtend)){ ?>
  429. <ul>
  430. <? if ($canAccessNews) { ?>
  431. <li><a href="<?=View::url('/dashboard/news')?>"><strong><?=t('News')?></strong></a> <?=t('Learn about your site and concrete5.')?></li>
  432. <? } ?>
  433. <? if ($canAccessSystem) { ?>
  434. <li><a href="<?=View::url('/dashboard/system')?>"><strong><?=t('System &amp; Settings')?></strong></a> <?=t('Secure and setup your site.')?></li>
  435. <? } ?>
  436. <? if ($canAccessExtend && $canViewExtend) { ?>
  437. <li><a href="<?php echo View::url('/dashboard/extend') ?>"><strong><?php echo t("Extend concrete5") ?></strong></a>  
  438. <? if (ENABLE_MARKETPLACE_SUPPORT) { ?>
  439. <?php echo sprintf(t('<a href="%s">Install</a>, <a href="%s">update</a> or download more <a href="%s">themes</a> and <a href="%s">add-ons</a>.'),
  440. View::url('/dashboard/extend/install'),
  441. View::url('/dashboard/extend/update'),
  442. View::url('/dashboard/extend/themes'),
  443. View::url('/dashboard/extend/add-ons')); ?>
  444. <? } else { ?>
  445. <?php echo sprintf(t('<a href="%s">Install</a> or <a href="%s">update</a> packages.'),
  446. View::url('/dashboard/extend/install'),
  447. View::url('/dashboard/extend/update'))?>
  448. <? } ?>
  449. </li>
  450. <? } ?>
  451. </ul>
  452. <? } ?>
  453. </div>
  454. </div>
  455. <div id="ccm-dashboard-overlay-footer">
  456. <div class="ccm-dashboard-overlay-inner">
  457. <a href="<?=View::url('/dashboard')?>"><?=t('View Full Dashboard')?> <i class="icon-arrow-right"></i></a>
  458. </div>
  459. </div>
  460. </div>
  461. <?
  462. $html = ob_get_contents();
  463. ob_end_clean();
  464. return str_replace(array("\n", "\r", "\t"), "", $html);
  465. }
  466. }
  467. class ConcreteDashboardMenu {
  468. protected $items;
  469. public function getItems($sort = true) {
  470. if ($sort) {
  471. usort($this->items, array('ConcreteDashboardMenu', 'sortItems'));
  472. }
  473. return $this->items;
  474. }
  475. protected static function sortItems($a, $b) {
  476. $subpatha = substr($a, 11); // /dashboard
  477. $subpathb = substr($b, 11); // /dashboard
  478. $segmentsa = explode('/', $subpatha);
  479. $segmentsb = explode('/', $subpathb);
  480. $segmenta = substr($subpatha, 0, strpos($subpatha, '/'));
  481. $segmentb = substr($subpathb, 0, strpos($subpathb, '/'));
  482. if (count($segmentsa) == 3 && count($segmentsb) == 3) {
  483. $subpatha = $segmenta[0] . '/' . $segmenta[1];
  484. $subpathb = $segmentb[0] . '/' . $segmentb[1];
  485. $segmenta .= '/' . $segmentsa[1];
  486. $segmentb .= '/' . $segmentsb[1];
  487. }
  488. if (!$segmenta) {
  489. $segmenta = $subpatha;
  490. }
  491. if (!$segmentb) {
  492. $segmentb = $subpathb;
  493. }
  494. $db = Loader::db();
  495. $displayorderA = intval($db->GetOne('select cDisplayOrder from Pages p inner join PagePaths cp on p.cID = cp.cID where cPath = ?', array('/dashboard/' . $segmenta)));
  496. $displayorderB = intval($db->GetOne('select cDisplayOrder from Pages p inner join PagePaths cp on p.cID = cp.cID where cPath = ?', array('/dashboard/' . $segmentb)));
  497. if ($displayorderA > $displayorderB) {
  498. return 1;
  499. } else if ($displayorderA < $displayorderB) {
  500. return -1;
  501. } else {
  502. $displayorderA = intval($db->GetOne('select cDisplayOrder from Pages p inner join PagePaths cp on p.cID = cp.cID where cPath = ?', array('/dashboard/' . $subpatha)));
  503. $displayorderB = intval($db->GetOne('select cDisplayOrder from Pages p inner join PagePaths cp on p.cID = cp.cID where cPath = ?', array('/dashboard/' . $subpathb)));
  504. if ($displayorderA > $displayorderB) {
  505. return 1;
  506. } else if ($displayorderA < $displayorderB) {
  507. return -1;
  508. }
  509. }
  510. }
  511. public function contains($c) {
  512. return in_array($c->getCollectionPath(), $this->items);
  513. }
  514. public function add($c) {
  515. $this->items[] = $c->getCollectionPath();
  516. }
  517. public function remove($c) {
  518. unset($this->items[array_search($c->getCollectionPath(), $this->items)]);
  519. }
  520. public static function getMine() {
  521. $u = new User();
  522. $qn = unserialize($u->config('QUICK_NAV_BOOKMARKS'));
  523. if (is_object($qn)) {
  524. return $qn;
  525. }
  526. $qn = new ConcreteDashboardMenu();
  527. $qnx = new ConcreteDashboardDefaultMenu();
  528. $qn->items = $qnx->items;
  529. return $qn;
  530. }
  531. }
  532. class ConcreteDashboardDefaultMenu extends ConcreteDashboardMenu {
  533. public $items = array(
  534. '/dashboard/composer/write',
  535. '/dashboard/composer/drafts',
  536. '/dashboard/sitemap/full',
  537. '/dashboard/sitemap/search',
  538. '/dashboard/files/search',
  539. '/dashboard/files/sets',
  540. '/dashboard/reports/statistics',
  541. '/dashboard/reports/forms'
  542. );
  543. }