Exemplo n.º 1
0
/**
 *
 **/
function getPagesList($fieldname, $selected, $add_empty = false)
{
    $pages_list = CAT_Helper_Page::getPages(CAT_Backend::isBackend());
    $deleted = CAT_Helper_Page::getPagesByVisibility('deleted');
    if (count($deleted)) {
        $arrh = CAT_Helper_Array::getInstance();
        foreach ($deleted as $page) {
            $arrh->ArrayRemove($page, $pages_list, 'page_id');
        }
    }
    if ($add_empty) {
        array_unshift($pages_list, array('page_id' => 0, 'parent' => 0, 'level' => 0, 'is_open' => false, 'menu_title' => CAT_Helper_Page::getInstance()->lang()->translate('[none (use internal)]')));
    }
    return CAT_Helper_ListBuilder::getInstance(true)->config(array('space' => '|-- '))->dropdown($fieldname, $pages_list, 0, $selected);
}
Exemplo n.º 2
0
    if (file_exists($root . '/framework/class.secure.php')) {
        include $root . '/framework/class.secure.php';
    } else {
        trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
    }
}
$backend = CAT_Backend::getInstance('Pages', 'pages_add', false);
$users = CAT_Users::getInstance();
header('Content-type: application/json');
if (!$users->checkPermission('Pages', 'pages_add')) {
    $ajax = array('message' => $backend->lang()->translate('You do not have the permission to add a page.'), 'success' => false);
    print json_encode($ajax);
    exit;
}
// note: all pages are listed in the dropdown, even hidden / private AND deleted!
$dropdown_list = CAT_Helper_ListBuilder::sort(CAT_Helper_Page::getPages(1), 0);
// template / variant
$template = CAT_Helper_Page::properties($val->sanitizePost('parent_id', 'numeric'), 'template');
$variant = CAT_Helper_Page::getPageSettings($val->sanitizePost('parent_id', 'numeric'), 'internal', 'template_variant');
$variants = array();
$info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Helper_Page::getPageTemplate($val->sanitizePost('parent_id', 'numeric')));
if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) {
    $variants = $info['module_variants'];
    array_unshift($variants, '');
}
// =============================================
// ! Add result_array to the template variable
// =============================================
$ajax = array('parent_id' => $val->sanitizePost('parent_id', 'numeric'), 'parent_list' => $dropdown_list, 'template' => $template, 'template_variant' => $variant, 'variants' => $variants, 'target' => '_self', 'success' => true);
// ====================
// ! Return values
Exemplo n.º 3
0
 /**
  * creates a full menu with all visible pages (like a sitemap)
  *
  * @access public
  * @return
  **/
 public static function fullMenu(array &$options = array())
 {
     global $page_id;
     $ul_id = self::analyzeOptions($options);
     $self = self::getInstance();
     $pages = self::$menu_no ? CAT_Helper_Page::getPagesForMenu(self::$menu_no) : CAT_Helper_Page::getPages();
     return self::$list->buildList($pages, array('selected' => $page_id, 'ul_id' => $ul_id));
 }
Exemplo n.º 4
0
 /**
  *
  * @access public
  * @return
  **/
 public static function get_init_pages()
 {
     // frontend pages
     $pages = CAT_Helper_Page::getPages();
     $frontend_pages = array();
     foreach ($pages as $page) {
         $frontend_pages[$page['menu_title']] = 'pages/modify.php?page_id=' . $page['page_id'];
     }
     // admin tools
     $tools = CAT_Helper_Addons::get_addons(NULL, 'module', 'tool');
     $admin_tools = array();
     foreach ($tools as $tool) {
         $admin_tools[$tool['name']] = 'admintools/tool.php?tool=' . $tool['directory'];
     }
     // backend pages
     $backend_pages = CAT_Backend::getPages();
     return array('backend_pages' => $backend_pages, 'frontend_pages' => $frontend_pages, 'admin_tools' => $admin_tools);
 }
Exemplo n.º 5
0
global $MOD_MENU_LINK, $TEXT;
$backend = CAT_Backend::getInstance('pages', 'pages_modify');
// get target page_id
$table = CAT_TABLE_PREFIX . 'mod_menu_link';
$sql_result = $backend->db()->query("SELECT * FROM {$table} WHERE section_id = '{$section_id}'");
$sql_row = $sql_result->fetchRow(MYSQL_ASSOC);
$target_page_id = $sql_row['target_page_id'];
$r_type = $sql_row['redirect_type'];
$extern = $sql_row['extern'];
$anchor = $sql_row['anchor'];
$sel = ' selected="selected"';
// Get list of targets (id=... or <a name ...>) from pages in $links
$targets = array();
$table_mw = CAT_TABLE_PREFIX . "mod_wysiwyg";
$table_s = CAT_TABLE_PREFIX . "sections";
$pages = CAT_Helper_Page::getPages();
$links = array();
foreach ($pages as $page) {
    $links[$page['page_id']] = $page['link'];
}
foreach ($links as $pid => $l) {
    if ($query_section = $backend->db()->query("SELECT section_id, module FROM {$table_s} WHERE page_id = '{$pid}' ORDER BY position")) {
        while ($section = $query_section->fetchRow(MYSQL_ASSOC)) {
            // get section-anchor
            if (defined('SEC_ANCHOR') && SEC_ANCHOR != '') {
                $targets[$pid][] = SEC_ANCHOR . $section['section_id'];
            } else {
                $targets[$pid] = array();
            }
            if ($section['module'] == 'wysiwyg') {
                if ($query_page = $backend->db()->query("SELECT content FROM {$table_mw} WHERE section_id = '{$section['section_id']}' LIMIT 1")) {
Exemplo n.º 6
0
// =========================================================
// ! Get display name of person who last modified the page
// =========================================================
$user = $users->get_user_details($results_array['modified_by']);
// =================================
// ! Add permissions to $data_dwoo
// =================================
$permission['pages'] = $users->checkPermission('Pages', 'pages') ? true : false;
$permission['pages_add'] = $users->checkPermission('Pages', 'pages_add') ? true : false;
$permission['pages_add_l0'] = $users->checkPermission('Pages', 'pages_add_l0') ? true : false;
$permission['pages_modify'] = $users->checkPermission('Pages', 'pages_modify') ? true : false;
$permission['pages_delete'] = $users->checkPermission('Pages', 'pages_delete') ? true : false;
$permission['pages_settings'] = $users->checkPermission('Pages', 'pages_settings') ? true : false;
$permission['pages_intro'] = $users->checkPermission('Pages', 'pages_intro') != true || INTRO_PAGE != 'enabled' ? false : true;
// list of all pages for dropdown, sorted by parent->child
$pages = CAT_Helper_ListBuilder::sort(CAT_Helper_Page::getPages(CAT_Backend::isBackend()), 0);
// =============================================
// ! Add result_array to the template variable
// =============================================
$ajax = array('description' => $results_array['description'], 'keywords' => $results_array['keywords'], 'language' => $results_array['language'], 'level' => $results_array['level'], 'menu' => $results_array['menu'], 'menu_title' => htmlspecialchars_decode($results_array['menu_title'], ENT_QUOTES), 'modified_when' => $results_array['modified_when'] != 0 ? CAT_Helper_DateTime::getDate($results_array['modified_when']) : 'Unknown', 'page_id' => $results_array['page_id'], 'page_title' => htmlspecialchars_decode($results_array['page_title'], ENT_QUOTES), 'parent' => $results_array['parent'], 'searching' => $results_array['searching'] == 0 ? false : true, 'short_link' => substr($results_array['link'], strripos($results_array['link'], '/') + 1), 'target' => $results_array['target'], 'template' => $results_array['template'], 'visibility' => $results_array['visibility'], 'display_name' => $user['display_name'], 'username' => $user['username'], 'DISPLAY_MENU_LIST' => MULTIPLE_MENUS != false ? true : false, 'DISPLAY_LANGUAGE_LIST' => PAGE_LANGUAGES != false ? true : false, 'DISPLAY_SEARCHING' => SEARCH != false ? true : false, 'admin_groups' => explode(',', str_replace('_', '', $results_array['admin_groups'])), 'viewing_groups' => explode(',', str_replace('_', '', $results_array['viewing_groups'])), 'parent_list' => $pages, 'PAGE_EXTENSION' => $backend->db()->query("SELECT `value` FROM `:prefix:settings` WHERE name = 'page_extension'")->fetchColumn());
$ajax['variants'] = array();
$info = CAT_Helper_Addons::checkInfo(CAT_PATH . '/templates/' . CAT_Helper_Page::getPageTemplate($results_array['page_id']));
if (isset($info['module_variants']) && is_array($info['module_variants']) && count($info['module_variants'])) {
    $ajax['variants'] = $info['module_variants'];
    array_unshift($ajax['variants'], '');
}
$ajax['template_variant'] = CAT_Helper_Page::getPageSettings($results_array['page_id'], 'internal', 'template_variant');
// ====================
// ! Return values
// ====================
print json_encode($ajax);
Exemplo n.º 7
0
 /**
  * uses ListBuilder to create a dropdown list of pages
  *
  * @access public
  * @return HTML
  **/
 public static function getPageSelect($as_array = false)
 {
     $pages = CAT_Helper_Page::getPages(CAT_Backend::isBackend());
     if ($as_array) {
         $opt = array();
         foreach ($pages as $pg) {
             $opt[$pg['page_id']] = $pg['menu_title'];
         }
         return $opt;
     } else {
         return 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', '__title_key' => 'menu_title'))->tree($pages, 0);
     }
 }
Exemplo n.º 8
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);
 }
Exemplo n.º 9
0
foreach ($avail as $i => &$l) {
    if ($l['VALUE'] == $page['language']) {
        unset($avail[$i]);
        break;
    }
}
// remove already linked languages
if (is_array($items) && count($items)) {
    foreach ($items as $item) {
        $arrh->ArrayRemove($item['lang'], $avail, 'VALUE');
    }
}
// ===========
// ! get pages
// ===========
$pages_list = CAT_Helper_Page::getPages(CAT_Backend::isBackend());
// skip current page
$arrh->ArrayRemove($page_id, $pages_list, 'page_id');
// skip already linked pages
if (is_array($items) && count($items)) {
    foreach ($items as $item) {
        $arrh->ArrayRemove($item['link_page_id'], $pages_list, 'page_id');
    }
}
// skip deleted pages
$deleted = CAT_Helper_Page::getPagesByVisibility('deleted');
foreach ($deleted as $item) {
    $arrh->ArrayRemove($item['page_id'], $pages_list, 'page_id');
}
// =========================================================
// ! Get display name of person who last modified the page