Added ability to hide or show sidebar blocks based on a {restrict} or {hideif} conditional in the sidebar script
--- 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 )
--- 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('<script type="text/javascript" src="' . scriptPath . '/includes/clientside/static/admin-menu.js"></script>');
- $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') . '>';