示例#1
0
function Dwoo_plugin_cmsplink(Dwoo $dwoo, $page)
{
    // remove all but numbers
    preg_match('/(\\d+)/', $page, $match);
    if (!count($match)) {
        return '';
    }
    return CAT_Helper_Page::getLink($match[1]);
}
示例#2
0
function cmsplink(&$content)
{
    $regexp = array('/\\[cmsplink([0-9]+)\\]/isU');
    // for backward compatibility with WB
    if (defined('WB_PREPROCESS_PREG')) {
        $regexp[] = WB_PREPROCESS_PREG;
    }
    foreach ($regexp as $preg) {
        if (preg_match_all($preg, $content, $ids)) {
            $new_ids = array_unique($ids[1]);
            foreach ($new_ids as $key => &$page_id) {
                $link = CAT_Helper_Page::properties($page_id, 'link');
                if (!is_null($link)) {
                    $content = str_replace($ids[0][$key], CAT_Helper_Page::getLink($link), $content);
                }
            }
        }
    }
}
示例#3
0
 function page_link($link)
 {
     return CAT_Helper_Page::getLink($link);
 }
示例#4
0
} else {
    $root = "../";
    $level = 1;
    while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
        $root .= "../";
        $level += 1;
    }
    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);
    }
}
if (!file_exists(CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/library.php')) {
    $page_id = CAT_Helper_Validate::get('_REQUEST', 'page_id');
    CAT_Object::printFatalError(CAT_Object::lang()->translate('No search library installed!'), CAT_Helper_Page::getLink($page_id));
}
// Required page details
$page_id = -1;
$page_description = '';
$page_keywords = '';
// load search library
require_once CAT_PATH . '/modules/' . SEARCH_LIBRARY . '/library.php';
$s = new CATSearch();
$page_id = $s->getSearchPageID();
// load droplets extensions
$h = CAT_Helper_Droplet::getInstance();
$h->register_droplet_css('SearchBox', $page_id, '/modules/' . SEARCH_LIBRARY . '/templates/default/', 'search.box.css');
$h->register_droplet_js('SearchBox', $page_id, '/modules/' . SEARCH_LIBRARY . '/templates/default/', 'search.box.js');
if (isset($_GET['string'])) {
    CAT_Helper_Page::addCSS(CAT_URL . '/modules/' . SEARCH_LIBRARY . '/templates/default/frontend.css');
示例#5
0
 /**
  *
  * @access public
  * @return
  **/
 public static function uninstallModule($type, $addon_name)
 {
     // keep old modules happy
     global $wb, $admin, $database;
     switch ($type) {
         case 'languages':
             // is default or used by current user
             if ($addon_name == DEFAULT_LANGUAGE || $addon_name == LANGUAGE) {
                 $temp = array('name' => $addon_name, 'type' => $addon_name == DEFAULT_LANGUAGE ? self::getInstance()->lang()->translate('standard language') : self::getInstance()->lang()->translate('current language'));
                 return self::getInstance()->lang()->translate('Cannot uninstall this language <span class="highlight_text">{{name}}</span> because it is the {{type}}!', $temp);
             }
             // used by other users
             $query_users = self::getInstance()->db()->query("SELECT `user_id` FROM `:prefix:users` WHERE language=:lang LIMIT 1", array('lang' => $addon_name));
             if ($query_users->rowCount() > 0) {
                 return self::getInstance()->lang()->translate('Cannot uninstall this language <span class="highlight_text">{{name}}</span> because it is in use!', array('name' => $addon_name));
             }
             break;
         case 'modules':
             // check if the module is still in use
             $info = self::getInstance()->db()->query("SELECT `section_id`, `page_id` FROM `:prefix:sections` WHERE module=:mod", array('mod' => $addon_name));
             if ($info->rowCount() > 0) {
                 $temp = explode(";", self::getInstance()->lang()->translate('this page;these pages'));
                 $add = $info->rowCount() == 1 ? $temp[0] : $temp[1];
                 $values = array('type' => self::getInstance()->lang()->translate('Module'), 'type_name' => $type, 'pages_string' => $add, 'count' => $info->rowCount(), 'name' => $addon_name);
                 $pages = array();
                 while (false != ($data = $info->fetchRow(MYSQL_ASSOC))) {
                     // skip negative page id's
                     if (substr($data['page_id'], 0, 1) == '-') {
                         continue;
                     }
                     $pages[] = sprintf('<a href="%s">%s</a>', CAT_Helper_Page::getLink($data['page_id']), CAT_Helper_Page::properties($data['page_id'], 'menu_title'));
                 }
                 $values['pages'] = implode('<br />', $pages);
                 return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is in use on {{pages_string}}:<br /><br />{{pages}}', $values);
             }
             //  some modules cannot be removed (used by system)
             if (!self::isRemovable($addon_name)) {
                 return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is marked as mandatory!', array('name' => $addon_name));
             }
             if (defined('WYSIWYG_EDITOR') && $addon_name == WYSIWYG_EDITOR) {
                 return self::getInstance()->lang()->translate('Cannot uninstall module <span class="highlight_text">{{name}}</span> because it is the standard WYSWIWYG editor!', array('name' => $addon_name));
             }
             break;
         case 'templates':
             if ($addon_name == DEFAULT_THEME || $addon_name == DEFAULT_TEMPLATE) {
                 $temp = array('name' => $addon_name, 'type' => $addon_name == DEFAULT_TEMPLATE ? self::getInstance()->lang()->translate('default template') : self::getInstance()->lang()->translate('default backend theme'));
                 return self::getInstance()->lang()->translate('Cannot uninstall template <span class="highlight_text">{{name}}</span> because it is the {{type}}!', $temp);
             }
             $info = self::getInstance()->db()->query("SELECT `page_id`, `page_title` FROM `:prefix:pages` WHERE template=:name order by page_title", array('name' => $addon_name));
             if ($info->rowCount() > 0) {
                 $msg_template_str = 'Cannot uninstall template <span class="highlight_text">{{name}}</span> because it is still in use on {{pages}}:';
                 $temp = explode(';', self::getInstance()->lang()->translate('this page;these pages'));
                 $add = $info->rowCount() == 1 ? $temp[0] : $temp[1];
                 $page_template_str = "<li><a href='../pages/settings.php?page_id={{id}}'>{{title}}</a></li>";
                 $values = array('pages' => $add, 'name' => $addon_name);
                 $msg = self::getInstance()->lang()->translate($msg_template_str, $values);
                 $page_names = '<ul>';
                 while ($data = $info->fetchRow()) {
                     $page_info = array('id' => $data['page_id'], 'title' => $data['page_title']);
                     $page_names .= self::getInstance()->lang()->translate($page_template_str, $page_info);
                 }
                 $page_names .= '</ul>';
                 return $msg . $page_names;
             }
             break;
         default:
             break;
     }
     // end switch
     // all checks succeeded, try to uninstall
     if (file_exists(CAT_PATH . '/' . $type . '/' . $addon_name . '/uninstall.php')) {
         require CAT_PATH . '/' . $type . '/' . $addon_name . '/uninstall.php';
     }
     // Remove entry from DB
     if ($type != 'languages') {
         self::getInstance()->db()->query("DELETE FROM `:prefix:addons` WHERE directory=:dir AND type=:type", array('dir' => $addon_name, 'type' => substr($type, 0, -1)));
         if (self::getInstance()->db()->isError()) {
             return self::getInstance()->db()->getError();
         }
         $stmt = self::getInstance()->db()->query('SELECT * FROM `:prefix:groups` WHERE group_id <> 1');
         if ($stmt->rowCount() > 0) {
             while ($row = $stmt->fetchRow(MYSQL_ASSOC)) {
                 $gid = $row['group_id'];
                 $file = $addon_name;
                 // get current value
                 $permissions = explode(',', $row[substr($type, 0, -1) . '_permissions']);
                 // remove uninstalled module
                 if (in_array($file, $permissions)) {
                     $i = array_search($file, $permissions);
                     array_splice($permissions, $i, 1);
                     $permissions = array_unique($permissions);
                     asort($permissions);
                     // Update the database
                     $addon_permissions = implode(',', $permissions);
                     self::getInstance()->db()->query(sprintf("UPDATE `:prefix:groups` SET %s_permissions=:perm WHERE group_id=:id", substr($type, 0, -1)), array('perm' => $addon_permissions, 'id' => $gid));
                 }
             }
         }
         // Try to delete the module dir
         if (!CAT_Helper_Directory::removeDirectory(CAT_PATH . '/' . $type . '/' . $addon_name)) {
             return self::getInstance()->lang()->translate('Cannot uninstall - unable to delete the directory!');
         }
     } else {
         self::getInstance()->db()->query("DELETE FROM `:prefix:addons` WHERE directory=:dir AND type=:type", array('dir' => $addon_name, 'type' => substr($type, 0, -1)));
         if (self::getInstance()->db()->isError()) {
             return self::getInstance()->db()->getError();
         }
         unlink(CAT_PATH . '/languages/' . $addon_name . '.php');
     }
     return true;
 }
示例#6
0
 /**
  *
  * @access public
  * @return
  **/
 private static function listbuilder($list, $root_id = 0, $type = 'ul', $selected = NULL)
 {
     if (empty($list) || !is_array($list) || !count($list)) {
         return NULL;
     }
     // initialize
     $self = self::getInstance(false);
     $output = array();
     $hidden = isset($self->_config['__hidden_key']) ? $self->_config['__hidden_key'] : '';
     $p_key = $self->_config['__parent_key'];
     $id_key = $self->_config['__id_key'];
     $title_key = $self->_config['__title_key'];
     $level_key = $self->_config['__level_key'];
     $isopen_key = $self->_config['__is_open_key'];
     $link_key = $self->_config['__link_key'];
     $auto_link = $self->_config['__auto_link'];
     $current = $self->_config['__is_current_key'];
     $space = $self->_config['space'];
     $is_first = true;
     $is_last = false;
     $is_open = false;
     // create a list of children for each item
     foreach ($list as $item) {
         // sort out hidden items
         if (isset($item[$hidden])) {
             continue;
         }
         $children[$item[$p_key]][] = $item;
     }
     // loop will be false if the root has no children
     $loop = !empty($children[$root_id]);
     // initializing $parent as the root
     $parent = $root_id;
     $parent_stack = array();
     while ($loop && (($option = each($children[$parent])) || $parent > $root_id)) {
         $is_current = isset($option['value'][$current]) && $option['value'][$current] == true || isset($selected) && $selected == $option['value'][$id_key] ? true : false;
         if ($option === false) {
             $parent = array_pop($parent_stack);
             if ($type != 'select') {
                 // close list item
                 $output[] = str_repeat("\t", (count($parent_stack) + 1) * 2) . $self->closeUL();
                 $output[] = str_repeat("\t", (count($parent_stack) + 1) * 2 - 1) . $self->closeLI();
             }
         } elseif (!empty($children[$option['value'][$id_key]])) {
             $level = isset($option['value'][$level_key]) && $option['value'][$level_key] >= 0 ? $option['value'][$level_key] : 0;
             $tab = str_repeat($space, $level);
             $text = $option['value'][$title_key];
             $is_open = $selected ? $selected : $option['value'][$isopen_key];
             // mark selected
             if ($type == 'select') {
                 $sel = NULL;
                 if (isset($selected) && $selected == $option['value'][$id_key]) {
                     $sel = ' selected="selected"';
                 }
                 $output[] = $self->getOption($option['value'][$id_key], $sel, $tab, $text);
             } else {
                 // HTML for menu item containing children (open)
                 $output[] = $tab . $self->startLI($option['value'][$id_key], $level, true, $is_first, $is_last, $is_open, $is_current) . ($auto_link && $link_key ? '<a href="' . CAT_Helper_Page::getLink($option['value'][$id_key]) . '">' : '') . $text . ($auto_link && $link_key ? '</a>' : '');
                 // open sub list
                 $output[] = $tab . "\t" . $self->startUL($space, '', $option['value'][$level_key]);
                 #$output[] = '-'.$option['value'][$id_key].'-';
             }
             array_push($parent_stack, $option['value'][$p_key]);
             $parent = $option['value'][$id_key];
         } else {
             $level = isset($option['value'][$level_key]) && $option['value'][$level_key] >= 0 ? $option['value'][$level_key] : 0;
             $tab = str_repeat($space, $level);
             $text = $option['value'][$title_key];
             if ($type == 'select') {
                 // mark selected
                 $sel = NULL;
                 if ($is_current) {
                     $sel = ' selected="selected"';
                 }
                 $output[] = $self->getOption($option['value'][$id_key], $sel, $tab, $text);
             } else {
                 $output[] = $tab . $self->startLI($option['value'][$id_key], $level, false, $is_first, $is_last, false, $is_current) . ($auto_link && $link_key ? '<a href="' . CAT_Helper_Page::getLink($option['value'][$id_key]) . '">' : '') . $text . ($auto_link && $link_key ? '</a>' : '') . $self->closeLI();
             }
         }
         $is_first = false;
     }
     // end while
     if (isset($self->_config['__li_last_item_class']) && !empty($self->_config['__li_last_item_class'])) {
         // get the very last element
         $last = array_splice($output, -1, 1);
         // add last item css
         $last = str_ireplace('class="', 'class="' . $self->_config['__li_last_item_class'] . ' ', $last);
         $output[] = is_array($last) && count($last) ? $last[0] : '';
     }
     return $output;
 }
示例#7
0
// ! Get page details
// ====================
$results_array = CAT_Helper_Page::properties($page_id);
// =========================================================
// ! Get display name of person who last modified the page
// =========================================================
$user = CAT_Users::get_user_details($results_array['modified_by']);
global $parser;
$tpl_data = array();
// ============================
// ! Include page info script
// ============================
$tpl_data['PAGE_ID'] = $results_array['page_id'];
$tpl_data['PAGE_TITLE'] = $results_array['page_title'];
$tpl_data['MENU_TITLE'] = $results_array['menu_title'];
$tpl_data['PAGE_LINK'] = CAT_Helper_Page::getLink($results_array['page_id']);
$tpl_data['MODIFIED_BY'] = $user['display_name'];
$tpl_data['MODIFIED_BY_USERNAME'] = $user['username'];
$tpl_data['MODIFIED_WHEN'] = $results_array['modified_when'] != 0 ? $modified_ts = CAT_Helper_DateTime::getDateTime($results_array['modified_when']) : false;
$tpl_data['SECTION_BLOCKS'] = SECTION_BLOCKS;
$tpl_data['SEC_ANCHOR'] = SEC_ANCHOR;
$tpl_data['DATE_FORMAT'] = CAT_DATE_FORMAT;
$tpl_data['CUR_TAB'] = 'modify';
$tpl_data['PAGE_HEADER'] = $backend->lang()->translate('Modify page');
// =========================================================
// ! Work-out if we should show the "manage sections" link
// =========================================================
$section_id = CAT_Sections::getSectionForPage($page_id);
$tpl_data['MANAGE_SECTIONS'] = $section_id || MANAGE_SECTIONS != 'enabled' ? false : true;
// ===========================================================================
// ! get template used for the displayed page (for displaying block details)
示例#8
0
function sm2_recurse(&$rgParent, $aStart, $aStartLevel, $aShowAllLevel, $aMaxLevel, $aFlags, &$aFormatter)
{
    global $wb;
    // on entry to this function we know that there are entries for this
    // parent and all entries for that parent are being displayed. We also
    // need to check if any of the children need to be displayed too.
    $isListOpen = false;
    $currentLevel = $wb->page['level'] == '' ? 0 : $wb->page['level'];
    // get the number of siblings skipping the hidden pages so we can pass
    // this in and check if the item is first or last
    $sibCount = 0;
    foreach ($rgParent[$aStart] as $page) {
        if (!array_key_exists('sm2_hide', $page)) {
            $sibCount++;
        }
    }
    $currSib = 0;
    foreach ($rgParent[$aStart] as $page) {
        // skip all hidden pages
        if (array_key_exists('sm2_hide', $page)) {
            // not set if false, so existence = true
            continue;
        }
        $currSib++;
        // skip any elements that are lower than the maximum level
        $pageLevel = $page['level'];
        if ($pageLevel > $aMaxLevel) {
            continue;
        }
        // this affects ONLY the top level
        if ($aStart == 0 && $aFlags & SM2_CURRTREE) {
            if (!array_key_exists('sm2_on_curr_path', $page)) {
                // not set if false, so existence = true
                continue;
            }
            $sibCount = 1;
        }
        // trim the tree as appropriate
        if ($aFlags & SM2_SIBLING) {
            // parents, and siblings and children of current only
            if (!array_key_exists('sm2_on_curr_path', $page) && !array_key_exists('sm2_is_sibling', $page) && !array_key_exists('sm2_child_level', $page)) {
                // not set if false, so existence = true
                continue;
            }
        } else {
            if ($aFlags & SM2_TRIM) {
                // parents and siblings of parents
                if ($pageLevel > $aShowAllLevel && !array_key_exists('sm2_on_curr_path', $page) && !array_key_exists('sm2_path_sibling', $page)) {
                    // not set if false, so existence = true
                    continue;
                }
            } elseif ($aFlags & SM2_CRUMB) {
                // parents only
                if (!array_key_exists('sm2_on_curr_path', $page) || array_key_exists('sm2_child_level', $page)) {
                    // not set if false, so existence = true
                    continue;
                }
            }
        }
        // depth first traverse
        $nextParent = $page['page_id'];
        // display the current element if we have reached the start level
        if ($pageLevel >= $aStartLevel) {
            //echo INTRO_PAGE;
            // M.f.i. Aldus - it's not clear why the intro-page got another url at this point.
            /*if(!INTRO_PAGE && $page['link'] == $wb->default_link) {
              	//echo $nextParent . ' - ' .$page['link'] . ' - ' . $wb->default_link;
                  $url = CAT_URL;
              }
              else {
                  $url = CAT_Helper_Page::getLink( CAT_Helper_Page::properties($page['page_id'],'link') );
              }*/
            $url = CAT_Helper_Page::getLink(CAT_Helper_Page::properties($page['page_id'], 'link'));
            // we open the list only when we absolutely need to
            if (!$isListOpen) {
                $aFormatter->startList($page, $url);
                $isListOpen = true;
            }
            $aFormatter->startItem($page, $url, $currSib, $sibCount);
        }
        // display children as appropriate
        if ($pageLevel + 1 <= $aMaxLevel && array_key_exists('sm2_has_child', $page)) {
            // not set if false, so existence = true
            sm2_recurse($rgParent, $nextParent, $aStartLevel, $aShowAllLevel, $aMaxLevel, $aFlags, $aFormatter);
        }
        // close the current element if appropriate
        if ($pageLevel >= $aStartLevel) {
            $aFormatter->finishItem($pageLevel, $page);
        }
    }
    // close the list if we opened one
    if ($isListOpen) {
        $aFormatter->finishList();
    }
}
示例#9
0
 /**
  * prints the top of the backend page
  *
  * @access public
  * @return void
  **/
 public static function print_banner()
 {
     global $page_id, $parser;
     $results_array = CAT_Helper_Page::properties($page_id);
     $user = CAT_Users::get_user_details($results_array['modified_by']);
     $tpl_data = array();
     foreach ($results_array as $key => $value) {
         $tpl_data[strtoupper($key)] = $value;
     }
     $tpl_data['MODIFIED_BY'] = $user['display_name'];
     $tpl_data['MODIFIED_BY_USERNAME'] = $user['username'];
     $tpl_data['MODIFIED_WHEN'] = $results_array['modified_when'] != 0 ? $modified_ts = CAT_Helper_DateTime::getDateTime($results_array['modified_when']) : false;
     $tpl_data['PAGE_HEADER'] = self::getInstance('')->lang()->translate('Modify page');
     $tpl_data['CUR_TAB'] = 'modify';
     $tpl_data['PAGE_LINK'] = CAT_Helper_Page::getLink($results_array['page_id']);
     $parser->output('backend_pages_header', $tpl_data);
     $parser->output('backend_pages_banner', $tpl_data);
 }
示例#10
0
$page_id = $val->get('_REQUEST', 'page_id', 'numeric');
if (!$page_id) {
    header("Location: index.php");
    exit(0);
}
$backend = CAT_Backend::getInstance('Pages', 'pages_settings');
$page = CAT_Helper_Page::getPage($page_id);
$user = CAT_Users::get_user_details($page['modified_by']);
$files = CAT_Helper_Page::getExtraHeaderFiles($page_id);
// ==================================
// ! Add globals to the template data
// ==================================
$tpl_data['CUR_TAB'] = 'headers';
$tpl_data['PAGE_HEADER'] = $backend->lang()->translate('Modify header files');
$tpl_data['PAGE_ID'] = $page_id;
$tpl_data['PAGE_LINK'] = CAT_Helper_Page::getLink($page['link']);
$tpl_data['PAGE_TITLE'] = $page['page_title'];
$tpl_data['MODIFIED_BY'] = $user['display_name'];
$tpl_data['MODIFIED_BY_USERNAME'] = $user['username'];
$tpl_data['MODIFIED_WHEN'] = $page['modified_when'] != 0 ? CAT_Helper_DateTime::getDateTime($page['modified_when']) : false;
$tpl_data['page_js'] = isset($files['js']) ? $files['js'] : '';
$tpl_data['page_css'] = isset($files['css']) ? $files['css'] : '';
$tpl_data['use_core'] = isset($files['use_core']) ? $files['use_core'] : NULL;
$tpl_data['use_ui'] = isset($files['use_ui']) ? $files['use_ui'] : NULL;
$tpl_data['jquery_plugins'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(0)->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', false, false, CAT_PATH . '/modules/lib_jquery/plugins/');
$tpl_data['js_files'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('js'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', true, true, CAT_PATH . '/modules/lib_jquery/plugins');
$tpl_data['css_files'] = CAT_Helper_Directory::getInstance()->maxRecursionDepth(5)->setSuffixFilter(array('css'))->scanDirectory(CAT_PATH . '/modules/lib_jquery/plugins', true, true, CAT_PATH . '/modules/lib_jquery/plugins');
$backend->print_header();
// ====================
// ! Parse output tpl
// ====================