Пример #1
0
 private function dev_link($die = true, $quick = false)
 {
     $realpages = listFiles(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/", "@^[^_](.*)\\.htm(l?)\$@i");
     $tmp = listFiles(CONS_PATH_PAGES . $_SESSION['CODE'] . "/actions/");
     $pages = array();
     foreach ($realpages as $x => $page) {
         // removes extensions
         $page = explode(".", $page);
         array_pop($page);
         $pages[] = implode(".", $page);
     }
     foreach ($tmp as $x => $page) {
         // adds actions that are not covered in content/template
         $page = explode(".", $page);
         array_pop($page);
         $page = implode(".", $page);
         if (!in_array($page, $pages)) {
             $pages[] = $page;
         }
     }
     if (isset($this->parent->dimconfig['_contentManager'])) {
         // add CMS pages
         if (!is_array($this->parent->dimconfig['_contentManager'])) {
             $this->parent->dimconfig['_contentManager'] = explode(",", $this->parent->dimconfig['_contentManager']);
         }
         foreach ($this->parent->dimconfig['_contentManager'] as $page) {
             $page = substr($page, 1);
             // removes initial /
             if ($page != '' && !in_array($page, $pages)) {
                 $pages[] = $page;
             }
         }
     }
     if (isset($this->parent->dimconfig['_seoManager'])) {
         // add SEO alias
         if (!is_array($this->parent->dimconfig['_seoManager'])) {
             $this->parent->dimconfig['_seoManager'] = explode(",", $this->parent->dimconfig['_seoManager']);
         }
         foreach ($this->parent->dimconfig['_seoManager'] as $page) {
             if ($page != '') {
                 if ($page[0] == '/') {
                     $page = substr($page, 1);
                 }
                 // removes initial /
                 if ($page != '' && !in_array($page, $pages)) {
                     $pages[] = $page;
                 }
             }
         }
     }
     $missingContent = array();
     if (!function_exists('xmlParamsParser')) {
         include CONS_PATH_SYSTEM . "lib/xmlHandler.php";
     }
     foreach ($realpages as $page) {
         $xhtml = new xmlHandler();
         $xhtml->cReadXML(CONS_PATH_PAGES . $_SESSION['CODE'] . "/template/" . $page, array(C_XML_AUTOPARSE => true, C_XML_LAX => true), true);
         $objects = $xhtml->XMLParsedContent();
         foreach ($objects[C_XHTML_LINKS] as $link) {
             $oL = $link;
             if ($link == '') {
                 $missingContent[] = $page . ": Empty link";
             } else {
                 if ($link[0] != "?" && $link[0] != "#" && strpos($link, "javascript:") === false && strpos($link, "mailto:") === false && strpos($link, "http") === false) {
                     if (strpos($link, "{") !== false) {
                         $link = explode("{", $link);
                         $newLink = "";
                         foreach ($link as $part) {
                             $part = explode("}", $part);
                             $part[0] = explode("|", $part[0]);
                             if ($part[0][0] == "seo") {
                                 $part = $part[0][1];
                                 if (strpos($part, ".") !== false) {
                                     $part = explode(".", $part);
                                     array_pop($part);
                                     $part = implode(".", $part);
                                 }
                                 if (strpos($part, "?") !== false) {
                                     $part = explode("?", $part);
                                     array_pop($part);
                                     $part = implode("?", $part);
                                 }
                                 if ($part != '' && $part[0] == '/') {
                                     $part = substr($part, 1);
                                 }
                                 // removes initial /
                                 if (!in_array($part, $pages)) {
                                     $missingContent[] = $page . ": " . $part . " (SEO from {$oL}) ";
                                 }
                             }
                         }
                     } else {
                         if (strpos($link, ".") !== false) {
                             $link = explode(".", $link);
                             array_pop($link);
                             $link = implode(".", $link);
                         }
                         if (strpos($link, "?") !== false) {
                             $link = explode("?", $link);
                             array_pop($link);
                             $link = implode("?", $link);
                         }
                         if ($link != '' && $link[0] == '/') {
                             $link = substr($link, 1);
                         }
                         // removes initial /
                         if (!in_array($link, $pages)) {
                             $missingContent[] = $page . ": " . $link . " ({$oL})";
                         }
                     }
                 }
             }
         }
     }
     if (!$quick) {
         if (count($missingContent) == 0) {
             echo "No link issues on " . count($realpages) . " pages";
         } else {
             echo "<b>" . count($missingContent) . " link issues on " . count($realpages) . " pages:</b><br/>";
             echo implode($missingContent, "<br/>\n");
         }
     }
     if ($die) {
         $this->parent->close(true);
         die;
     }
     return count($missingContent) > 0 ? $missingContent : false;
 }
Пример #2
0
 function buildAdminMenu()
 {
     // this function builds the Ttree object for the menu, but does not handle the HTML. The menu stays in the private var $this->menudata
     if (!isset($_SESSION[CONS_SESSION_ACCESS_USER]['id_group'])) {
         return;
     }
     $file = CONS_PATH_CACHE . $_SESSION['CODE'] . "/admin" . $_SESSION[CONS_SESSION_ACCESS_USER]['id_group'] . ".cache";
     // HTML output with normal menu
     if (!is_file($file) || $this->parent->debugmode || isset($_REQUEST['nocache'])) {
         if (is_file($file)) {
             unlink($file);
         }
         if (!is_file(CONS_PATH_PAGES . $_SESSION['CODE'] . "/_config/admin.xml")) {
             $this->parent->errorControl->raise(517, "buildAdminMenu", "admin");
         }
         if (!defined('C_XHTML_AUTOTAB')) {
             include CONS_PATH_INCLUDE . "xmlHandler.php";
         }
         $xml = new xmlHandler();
         $menuXML = $xml->cReadXML(CONS_PATH_PAGES . $_SESSION['CODE'] . "/_config/admin.xml", array('C_XML_autoparse' => true, 'C_XML_lax' => true), false);
         $menu = array();
         $this->parent->lockPermissions();
         // guarantee permissions are loaded
         $this->addMenuItens($menuXML->getbranch(0), $menu, 0, $this->parent);
         if (!function_exists("mysort")) {
             function mysort($a, $b)
             {
                 if ($a['id_parent'] == $b['id_parent']) {
                     return $a['id'] <= $b['id'] ? -1 : 1;
                     // itens on the same level sorted by id
                 } else {
                     return $a['id_parent'] <= $b['id_parent'] ? -1 : 1;
                 }
                 // menus sorted by ID
             }
         }
         usort($menu, 'mysort');
         $this->menudata = new TTree();
         $this->menudata->arrayToTree($menu, '\\', 'id_parent', 'title');
         // save caches
         cWriteFile($file, serialize($this->menudata));
         // <- ttree object
     } else {
         @($this->menudata = unserialize(cReadFile($file)));
         if ($this->menudata === false || !is_object($this->menudata)) {
             $this->parent->log[] = "Error loading admin menu";
             $this->parent->setLog(CONS_LOGGING_ERROR);
         }
     }
 }