template: added ability for themes to hide user, tools, and search sidebar blocks
authorDan
Fri, 06 Mar 2009 11:19:55 -0500
changeset 856 0b7ff06aad13
parent 855 4f7521dd981f
child 857 f3a5a276208c
template: added ability for themes to hide user, tools, and search sidebar blocks
includes/template.php
--- a/includes/template.php	Fri Mar 06 11:19:29 2009 -0500
+++ b/includes/template.php	Fri Mar 06 11:19:55 2009 -0500
@@ -1658,6 +1658,22 @@
       $string = str_replace('\'', '\\\'', $string);
       $text = str_replace_once($matches[0][$i], $string, $text);
     }
+    preg_match_all('/\{url:([A-z0-9]+):([\w\.\/:;\(\)@\[\]_=-]+)(?::([^\s\}]+))?(?:\|(escape))?\}/', $text, $matches);
+    foreach ( $matches[1] as $i => $string_id )
+    {
+      $namespace =& $matches[1][$i];
+      $page_id =& $matches[2][$i];
+      $params =& $matches[3][$i];
+      $escape =& $matches[4][$i];
+      
+      if ( !$params )
+        $params = false;
+      $escape = !empty($escape);
+      
+      $result = makeUrlNS($namespace, $page_id, $params, $escape);
+      
+      $text = str_replace_once($matches[0][$i], $result, $text);
+    }
     return $text;
   }
   
@@ -2081,6 +2097,8 @@
       return $result;
     }
     
+    require(ENANO_ROOT . "/themes/{$this->theme}/theme.cfg");
+    
     profiler_log('Started sidebar parsing');
     
     // init our block contents
@@ -2115,6 +2133,14 @@
     // explicitly specify $q in case a plugin or PHP block makes a query
     while ( $row = $db->fetchrow($q) )
     {
+      // should we skip this block?
+      if (
+          ( $row['item_id'] === 2 && !empty($theme['sb_hide_tools']) ) ||
+          ( $row['item_id'] === 3 && !empty($theme['sb_hide_user']) ) ||
+          ( $row['item_id'] === 4 && !empty($theme['sb_hide_search']) )
+        )
+        continue;
+      
       // format the block
       $block_content = $this->format_sidebar_block($row, $vars, $parser);