# HG changeset patch # User Dan # Date 1215412632 14400 # Node ID c4ae0d8e260fc774f88b4a170497800c768da528 # Parent 82320949a3b5a9f1b5ed5d62e0cb1940535e3f24 Added ability to hide or show sidebar blocks based on a {restrict} or {hideif} conditional in the sidebar script diff -r 82320949a3b5 -r c4ae0d8e260f includes/template.php --- a/includes/template.php Thu Jul 03 15:37:18 2008 -0400 +++ b/includes/template.php Mon Jul 07 02:37:12 2008 -0400 @@ -2079,6 +2079,22 @@ $c = (gettype($this->fetch_block($row['block_content'])) == 'string') ? $this->fetch_block($row['block_content']) : /* This used to say "can't find plugin block" but I think it's more friendly to just silently hide it. */ ''; break; } + // is there a {restrict} or {hideif} block? + if ( preg_match('/\{(restrict|hideif) ([a-z0-9_\(\)\|&! ]+)\}/', $c, $match) ) + { + // we have one, check the condition + $type =& $match[1]; + $cond =& $match[2]; + $result = $this->process_condition($cond); + if ( ( $type == 'restrict' && $result == 1 ) || ( $type == 'hideif' && $result == 2 ) ) + { + // throw out this block, it's hidden for whatever reason by the sidebar script + continue; + } + // didn't get a match, so hide the conditional logic + $c = str_replace_once($match[0], '', $c); + } + $parser->assign_vars(Array( 'TITLE'=>$this->tplWikiFormat($row['block_name']), 'CONTENT'=>$c )); $run = $parser->run(); if ( $row['block_type'] == BLOCK_PLUGIN ) diff -r 82320949a3b5 -r c4ae0d8e260f plugins/SpecialAdmin.php --- a/plugins/SpecialAdmin.php Thu Jul 03 15:37:18 2008 -0400 +++ b/plugins/SpecialAdmin.php Mon Jul 07 02:37:12 2008 -0400 @@ -48,12 +48,12 @@ function SpecialAdmin_include() { - global $paths; + global $db, $session, $paths, $template, $plugins; // Common objects // Admin pages that were too enormous to be in this file were split off into the plugins/admin/ directory in 1.0.1. // Only load these files if we're looking to load the admin panel list($pid, $ns) = RenderMan::strToPageID($paths->get_pageid_from_url()); - if ( $ns == 'Admin' ) + if ( $ns == 'Admin' || ( $pid == 'Administration' && $ns == 'Special' ) ) { require(ENANO_ROOT . '/plugins/admin/PageManager.php'); require(ENANO_ROOT . '/plugins/admin/PageEditor.php'); @@ -65,6 +65,11 @@ require(ENANO_ROOT . '/plugins/admin/LangManager.php'); require(ENANO_ROOT . '/plugins/admin/ThemeManager.php'); require(ENANO_ROOT . '/plugins/admin/PluginManager.php'); + // require(ENANO_ROOT . '/plugins/admin/CacheManager.php'); + + // Set the theme + $session->theme = 'admin'; + $session->style = 'default'; } } @@ -1968,8 +1973,6 @@ else { $template->add_header(''); - $template->load_theme('admin', 'default'); - $template->init_vars(); if( !isset( $_GET['noheaders'] ) ) { $template->header(); @@ -2551,6 +2554,7 @@ $c = ($template->fetch_block($row['block_content'])) ? $template->fetch_block($row['block_content']) : $lang->get('sbedit_msg_plugin_not_loaded'); break; } + $c = preg_replace('/\{(restrict|hideif) ([a-z0-9_\(\)\|&! ]+)\}/', '', $c); die('var status = \'GOOD\'; var content = unescape(\''.hexencode($c).'\');'); break; } @@ -2631,6 +2635,7 @@ $c = ($template->fetch_block($row['block_content'])) ? $template->fetch_block($row['block_content']) : $lang->get('sbedit_msg_plugin_not_loaded'); break; } + $c = preg_replace('/\{(restrict|hideif) ([a-z0-9_\(\)\|&! ]+)\}/', '', $c); $block_name = $row['block_name']; // $template->tplWikiFormat($row['block_name']); if ( empty($block_name) ) $block_name = '<' . $lang->get('sbedit_note_block_unnamed') . '>';