public function index($page = "error") { if ($page == "error") { redirect('error'); } else { $cache = $this->cache->get("page_" . $page . "_" . getLang()); if ($cache !== false) { $this->template->setTitle($cache['title']); $out = $cache['content']; if ($cache['permission'] && !hasViewPermission($cache['permission'], "--PAGE--")) { $this->template->showError(lang("permission_denied", "error")); } } else { $page_content = $this->cms_model->getPage($page); if ($page_content == false) { redirect('error'); } else { $this->template->setTitle(langColumn($page_content['name'])); $page_data = array("module" => "default", "headline" => langColumn($page_content['name']), "content" => langColumn($page_content['content'])); $out = $this->template->loadPage("page.tpl", $page_data); $this->cache->save("page_" . $page . "_" . getLang(), array("title" => langColumn($page_content['name']), "content" => $out, "permission" => $page_content['permission'])); if ($page_content['permission'] && !hasViewPermission($page_content['permission'], "--PAGE--")) { $this->template->showError(lang("permission_denied", "error")); } } } } $this->template->view($out); }
/** * Get the menu links * @param Int $side ID of the specific menu */ public function getMenu($side = "top") { $result = array(); // Get the database values $links = $this->CI->cms_model->getLinks($side); foreach ($links as $key => $item) { if (!hasViewPermission($links[$key]['permission'], "--MENU--") && $links[$key]['permission']) { continue; } // Xss protect out names $links[$key]['name'] = $this->format(langColumn($links[$key]['name']), false, false); // Hard coded PM count if ($links[$key]['link'] == "messages") { $count = $this->CI->cms_model->getMessagesCount(); if ($count > 0) { $links[$key]['name'] .= " <b>(" . $count . ")</b>"; } } if (!preg_match("/^\\/|[a-z][a-z0-9+\\-.]*:/i", $links[$key]['link'])) { $links[$key]['link'] = $this->page_url . $links[$key]['link']; } // Append if it's a direct link or not $links[$key]['link'] = 'href="' . $links[$key]['link'] . '" direct="' . $links[$key]['direct_link'] . '"'; array_push($result, $links[$key]); } return $result; }