Exemple #1
0
 /**
  * returns the sections of a page
  *
  * to get all sections of all pages, leave param empty
  *
  * @access public
  * @param  integer  $page_id
  * @return array
  **/
 public static function getSections($page_id = NULL)
 {
     if (!count(self::$pages)) {
         self::getInstance();
     }
     if (!count(self::$pages_sections)) {
         self::$pages_sections = CAT_Sections::getActiveSections();
     }
     if ($page_id) {
         return isset(self::$pages_sections[$page_id]) ? self::$pages_sections[$page_id] : array();
     } else {
         return self::$pages_sections;
     }
 }
Exemple #2
0
 /**
  * get page sections for given block
  *
  * @access public
  * @param  integer $block
  * @return void (direct print to STDOUT)
  **/
 public function getPageContent($block = 1)
 {
     // keep old modules happy
     global $wb, $admin, $database, $page_id, $section_id, $parser;
     // old style language files
     global $TEXT, $HEADING, $MESSAGE;
     $admin =& $wb;
     if ($page_id == '') {
         $page_id = $this->_page_id;
     }
     // check if user is allowed to see this page
     if (!self::$helper->isVisible($this->_page_id) && !CAT_Users::is_root() && (!self::$helper->isMaintenance() || CAT_Registry::get('MAINTENANCE_PAGE') != $this->_page_id)) {
         if (self::$helper->isDeleted($this->_page_id)) {
             return self::print404();
         } else {
             // if Frontend-Login redirect user to login form and after login back to current page
             if (FRONTEND_LOGIN) {
                 header("HTTP/1.1 401 Unauthorized");
                 header("Location: " . LOGIN_URL . '?redirect=' . $_SERVER['PHP_SELF']);
                 exit;
             } else {
                 self::$helper->printFatalError('You are not allowed to view this page!');
             }
         }
     }
     // check if page has active sections
     if (!self::$helper->isActive($this->_page_id)) {
         return self::$helper->lang()->translate('The page does not have any content!');
     }
     // get the page content; if constant PAGE_CONTENT is set, it contains
     // the name of a file to be included
     if (!defined('PAGE_CONTENT') or $block != 1) {
         // get active sections
         $sections = CAT_Sections::getActiveSections($this->_page_id, $block);
         if (is_array($sections) && count($sections)) {
             global $parser, $section_id;
             foreach ($sections as $section) {
                 self::$helper->log()->logDebug('sections for this block', $sections);
                 $section_id = $section['section_id'];
                 $module = $section['module'];
                 // make a anchor for every section.
                 if (defined('SEC_ANCHOR') && SEC_ANCHOR != '') {
                     echo '<a class="section_anchor" id="' . SEC_ANCHOR . $section_id . '"' . (isset($section['name']) && $section['name'] != 'no name' ? 'title="' . $section['name'] . '"' : '') . '></a>';
                 }
                 // check if module exists - feature: write in errorlog
                 if (file_exists(CAT_PATH . '/modules/' . $module . '/view.php')) {
                     // load language file (if any)
                     $langfile = CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/languages/' . LANGUAGE . '.php');
                     if (file_exists($langfile)) {
                         // modern language file
                         if ($this->lang()->checkFile($langfile, 'LANG', true)) {
                             $this->lang()->addFile(LANGUAGE . '.php', CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/languages'));
                         }
                     }
                     // set template path
                     if (file_exists(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/templates'))) {
                         $parser->setPath(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/templates'));
                     }
                     if (file_exists(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/templates/default'))) {
                         $parser->setPath(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/templates/default'));
                     }
                     if (file_exists(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/templates/' . DEFAULT_TEMPLATE))) {
                         $parser->setFallbackPath(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/templates/default'));
                         $parser->setPath(CAT_Helper_Directory::sanitizePath(CAT_PATH . '/modules/' . $module . '/templates/' . DEFAULT_TEMPLATE));
                     }
                     // fetch original content
                     ob_start();
                     require CAT_PATH . '/modules/' . $module . '/view.php';
                     $content = ob_get_clean();
                     echo $content;
                 } else {
                     continue;
                 }
             }
         }
     } else {
         require PAGE_CONTENT;
     }
     if (!CAT_Registry::exists('CAT_PAGE_CONTENT_DONE')) {
         CAT_Registry::register('CAT_PAGE_CONTENT_DONE', true, true);
     }
 }