Example #1
0
 /**
  *  Print the admin header
  *
  *  @access public
  *  @return void
  */
 public function print_header()
 {
     global $parser;
     $tpl_data = array();
     $addons = CAT_Helper_Addons::getInstance();
     $user = CAT_Users::getInstance();
     // Connect to database and get website title
     if (!CAT_Registry::exists('WEBSITE_TITLE')) {
         $title = $this->db()->query("SELECT `value` FROM `:prefix:settings` WHERE `name`='website_title'")->fetchColumn();
         CAT_Registry::define('WEBSITE_TITLE', $title, true);
     }
     // check current URL for page tree
     $uri = CAT_Helper_Validate::get('_SERVER', 'SCRIPT_NAME');
     // init template search paths
     self::initPaths();
     // =================================
     // ! Add permissions to $tpl_data
     // =================================
     $tpl_data['permission']['pages'] = $user->checkPermission('pages', 'pages', false);
     $tpl_data['permission']['pages_add'] = $user->checkPermission('pages', 'pages_add', false);
     $tpl_data['permission']['pages_add_l0'] = $user->checkPermission('pages', 'pages_add_l0', false);
     $tpl_data['permission']['pages_modify'] = $user->checkPermission('pages', 'pages_modify', false);
     $tpl_data['permission']['pages_delete'] = $user->checkPermission('pages', 'pages_delete', false);
     $tpl_data['permission']['pages_settings'] = $user->checkPermission('pages', 'pages_settings', false);
     $tpl_data['permission']['pages_intro'] = $user->checkPermission('pages', 'pages_intro', false) != true || INTRO_PAGE != 'enabled' ? false : true;
     if ($tpl_data['permission']['pages'] == true) {
         $tpl_data['DISPLAY_MENU_LIST'] = CAT_Registry::get('MULTIPLE_MENUS') != false ? true : false;
         $tpl_data['DISPLAY_LANGUAGE_LIST'] = CAT_Registry::get('PAGE_LANGUAGES') != false ? true : false;
         $tpl_data['DISPLAY_SEARCHING'] = CAT_Registry::get('SEARCH') != false ? true : false;
         // ==========================
         // ! Get info for pagesTree
         // ==========================
         $pages = CAT_Helper_Page::getPages(true);
         $sections = CAT_Helper_Page::getSections();
         // create LI content for ListBuilder
         foreach ($pages as $i => $page) {
             if (isset($sections[$page['page_id']]) && count($sections[$page['page_id']])) {
                 $page['page_title'] .= "\n" . count($sections[$page['page_id']]) . ' ' . $user->lang()->translate('active sections') . ':';
                 foreach ($sections[$page['page_id']] as $block_id => $section) {
                     foreach ($section as $item) {
                         $page['page_title'] .= "\n" . $item['module'] . ' (ID:' . $item['section_id'] . ')';
                     }
                 }
             }
             $text = $parser->get('backend_pagetree_item', array_merge($page, array('action' => pathinfo($uri, PATHINFO_FILENAME) == 'lang_settings' ? 'lang_settings' : 'modify')));
             $pages[$i]['text'] = $text;
         }
         // list of first level of pages
         $tpl_data['pages'] = CAT_Helper_ListBuilder::getInstance()->config(array('__li_level_css' => true, '__li_id_prefix' => 'pageid_', '__li_css_prefix' => 'fc_page_', '__li_has_child_class' => 'fc_expandable', '__is_open_key' => 'be_tree_is_open', '__li_is_open_class' => 'fc_tree_open', '__li_is_closed_class' => 'fc_tree_close', '__title_key' => 'text'))->tree($pages, 0);
         // number of editable pages (for current user)
         $tpl_data['pages_editable'] = CAT_Helper_Page::getEditable();
         // ==========================================
         // ! Get info for the form to add new pages
         // ==========================================
         $tpl_data['templates'] = $addons->get_addons(CAT_Registry::get('DEFAULT_TEMPLATE'), 'template', 'template');
         $tpl_data['languages'] = $addons->get_addons(CAT_Registry::get('DEFAULT_LANGUAGE'), 'language');
         $tpl_data['modules'] = $addons->get_addons('wysiwyg', 'module', 'page');
         $tpl_data['groups'] = $user->get_groups();
         // ===========================================
         // ! Check and set permissions for templates
         // ===========================================
         foreach ($tpl_data['templates'] as $key => $template) {
             $tpl_data['templates'][$key]['permissions'] = $user->get_permission($template['VALUE'], 'template') ? true : false;
         }
     }
     // =========================
     // ! Add Metadatas to Dwoo
     // =========================
     $tpl_data['META']['CHARSET'] = true === defined('DEFAULT_CHARSET') ? DEFAULT_CHARSET : 'utf-8';
     $tpl_data['META']['LANGUAGE'] = strtolower(CAT_Registry::get('LANGUAGE'));
     $tpl_data['META']['WEBSITE_TITLE'] = WEBSITE_TITLE;
     $tpl_data['CAT_VERSION'] = CAT_Registry::get('CAT_VERSION');
     $tpl_data['CAT_CORE'] = CAT_Registry::get('CAT_CORE');
     $tpl_data['PAGE_EXTENSION'] = CAT_Registry::get('PAGE_EXTENSION');
     $date_search = array('Y', 'j', 'n', 'jS', 'l', 'F');
     $date_replace = array('yy', 'y', 'm', 'd', 'DD', 'MM');
     $tpl_data['DATE_FORMAT'] = str_replace($date_search, $date_replace, CAT_Registry::get('CAT_DATE_FORMAT'));
     $time_search = array('H', 'i', 's', 'g');
     $time_replace = array('hh', 'mm', 'ss', 'h');
     $tpl_data['TIME_FORMAT'] = str_replace($time_search, $time_replace, CAT_Registry::get('TIME_FORMAT'));
     $tpl_data['SESSION'] = session_name();
     $tpl_data['HEAD']['SECTION_NAME'] = $this->lang()->translate(strtoupper(self::$instance->section_name));
     $tpl_data['DISPLAY_NAME'] = $user->get_display_name();
     $tpl_data['USER'] = $user->get_user_details($user->get_user_id());
     // ===================================================================
     // ! Add arrays for main menu, options menu and the Preferences-Button
     // ===================================================================
     $tpl_data['MAIN_MENU'] = array();
     $tpl_data['MAIN_MENU'][0] = array('link' => CAT_ADMIN_URL . '/start/index.php', 'title' => $this->lang()->translate('Start'), 'permission_title' => 'start', 'permission' => $user->checkPermission('start', 'start') ? true : false, 'current' => 'start' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][1] = array('link' => CAT_ADMIN_URL . '/media/index.php', 'title' => $this->lang()->translate('Media'), 'permission_title' => 'media', 'permission' => $user->checkPermission('media', 'media') ? true : false, 'current' => 'media' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][2] = array('link' => CAT_ADMIN_URL . '/settings/index.php', 'title' => $this->lang()->translate('Settings'), 'permission_title' => 'settings', 'permission' => $user->checkPermission('settings', 'settings') ? true : false, 'current' => 'settings' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][3] = array('link' => CAT_ADMIN_URL . '/addons/index.php', 'title' => $this->lang()->translate('Addons'), 'permission_title' => 'addons', 'permission' => $user->checkPermission('addons', 'addons') ? true : false, 'current' => 'addons' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][4] = array('link' => CAT_ADMIN_URL . '/admintools/index.php', 'title' => $this->lang()->translate('Admin-Tools'), 'permission_title' => 'admintools', 'permission' => $user->checkPermission('admintools', 'admintools') ? true : false, 'current' => 'admintools' == strtolower($this->section_name) ? true : false);
     $tpl_data['MAIN_MENU'][5] = array('link' => CAT_ADMIN_URL . '/users/index.php', 'title' => $this->lang()->translate('Access'), 'permission_title' => 'access', 'permission' => $user->checkPermission('access', 'access') ? true : false, 'current' => 'access' == strtolower($this->section_name) ? true : false);
     // =======================================
     // ! Seperate access-link by permissions
     // =======================================
     if ($user->get_permission('users')) {
         $tpl_data['MAIN_MENU'][5]['link'] = CAT_ADMIN_URL . '/users/index.php';
     } elseif ($user->get_permission('groups')) {
         $tpl_data['MAIN_MENU'][5]['link'] = CAT_ADMIN_URL . '/groups/index.php';
     }
     $tpl_data['PREFERENCES'] = array('link' => CAT_ADMIN_URL . '/preferences/index.php', 'title' => $this->lang()->translate('Preferences'), 'permission_title' => 'preferences', 'permission' => $this->get_link_permission('preferences') ? true : false, 'current' => 'preferences' == strtolower($this->section_name) ? true : false);
     $tpl_data['section_name'] = strtolower($this->section_name);
     $tpl_data['page_id'] = CAT_Helper_Validate::sanitizeGet('page_id', 'numeric') && CAT_Helper_Validate::sanitizeGet('page_id') != '' ? CAT_Helper_Validate::sanitizeGet('page_id') : (CAT_Helper_Validate::sanitizePost('page_id', 'numeric') && CAT_Helper_Validate::sanitizePost('page_id') != '' ? CAT_Helper_Validate::sanitizePost('page_id') : false);
     // ====================
     // ! Parse the header
     // ====================
     $parser->output('header', $tpl_data);
 }
Example #2
0
/**
 * init constants needed for module installations etc.
 **/
function init_constants($cat_path)
{
    global $config;
    // avoid to load config.php here
    if (!CAT_Registry::exists('CAT_PATH')) {
        CAT_Registry::define('CAT_PATH', $cat_path);
    }
    if (!CAT_Registry::exists('CAT_URL')) {
        CAT_Registry::define('CAT_URL', $config['cat_url']);
    }
    if (!CAT_Registry::exists('CAT_ADMINS_FOLDER')) {
        CAT_Registry::define('CAT_ADMINS_FOLDER', '/admins');
    }
    if (!CAT_Registry::exists('CAT_BACKEND_FOLDER')) {
        CAT_Registry::define('CAT_BACKEND_FOLDER', '/backend');
    }
    if (!CAT_Registry::exists('CAT_BACKEND_PATH')) {
        CAT_Registry::define('CAT_BACKEND_PATH', CAT_BACKEND_FOLDER);
    }
    if (!CAT_Registry::exists('CAT_ADMIN_PATH')) {
        CAT_Registry::define('CAT_ADMIN_PATH', CAT_PATH . CAT_BACKEND_PATH);
    }
    if (!CAT_Registry::exists('CAT_ADMIN_URL')) {
        CAT_Registry::define('CAT_ADMIN_URL', CAT_URL . CAT_BACKEND_PATH);
    }
    foreach ($config as $key => $value) {
        if (!CAT_Registry::exists(strtoupper($key))) {
            if (!is_scalar($value)) {
                continue;
            }
            CAT_Registry::define(str_replace('DATABASE_', 'CAT_DB_', strtoupper($key)), $value);
        }
    }
    if (!CAT_Registry::exists('CAT_TABLE_PREFIX')) {
        CAT_Registry::define('CAT_TABLE_PREFIX', TABLE_PREFIX);
    }
    // WB compatibility
    if (!CAT_Registry::exists('WB_URL')) {
        CAT_Registry::define('WB_URL', $config['cat_url']);
    }
    if (!CAT_Registry::exists('WB_PATH')) {
        CAT_Registry::define('WB_PATH', $cat_path);
    }
    // LEPTON compatibility
    if (!CAT_Registry::exists('LEPTON_URL')) {
        CAT_Registry::define('LEPTON_URL', $config['cat_url']);
    }
    if (!CAT_Registry::exists('LEPTON_PATH')) {
        CAT_Registry::define('LEPTON_PATH', $cat_path);
    }
    // user id
    $_SESSION['USER_ID'] = 1;
    $_SESSION['GROUP_ID'] = 1;
}
Example #3
0
 /**
  * Accessor to KLogger class; this makes using the class significant faster!
  *
  * @access public
  * @return object
  *
  **/
 public function log()
 {
     // 8 = OFF
     if ($this->debugLevel < 8) {
         if (!is_object($this->logObj)) {
             if (!CAT_Registry::exists('CAT_PATH', false)) {
                 CAT_Registry::define('CAT_PATH', dirname(__FILE__) . '/../..', 1);
             }
             $debug_dir = CAT_PATH . '/temp/logs' . ($this->debugLevel == 7 ? '/debug_' . get_class($this) : '');
             if (get_class($this) != 'CAT_Helper_Directory') {
                 $debug_dir = CAT_Helper_Directory::sanitizePath($debug_dir);
             }
             if (!file_exists($debug_dir)) {
                 if (get_class($this) != 'CAT_Helper_Directory') {
                     CAT_Helper_Directory::createDirectory($debug_dir, 0777);
                 } else {
                     mkdir($debug_dir, 0777);
                 }
             }
             $this->logObj = CAT_Helper_KLogger::instance($debug_dir, $this->debugLevel);
         }
         return $this->logObj;
     }
     return $this;
 }