includes/template.php
changeset 856 0b7ff06aad13
parent 848 b33241a7cc28
child 865 7f8262b2004a
equal deleted inserted replaced
855:4f7521dd981f 856:0b7ff06aad13
  1656       $string = $lang->get($string_id);
  1656       $string = $lang->get($string_id);
  1657       $string = str_replace('\\', '\\\\', $string);
  1657       $string = str_replace('\\', '\\\\', $string);
  1658       $string = str_replace('\'', '\\\'', $string);
  1658       $string = str_replace('\'', '\\\'', $string);
  1659       $text = str_replace_once($matches[0][$i], $string, $text);
  1659       $text = str_replace_once($matches[0][$i], $string, $text);
  1660     }
  1660     }
       
  1661     preg_match_all('/\{url:([A-z0-9]+):([\w\.\/:;\(\)@\[\]_=-]+)(?::([^\s\}]+))?(?:\|(escape))?\}/', $text, $matches);
       
  1662     foreach ( $matches[1] as $i => $string_id )
       
  1663     {
       
  1664       $namespace =& $matches[1][$i];
       
  1665       $page_id =& $matches[2][$i];
       
  1666       $params =& $matches[3][$i];
       
  1667       $escape =& $matches[4][$i];
       
  1668       
       
  1669       if ( !$params )
       
  1670         $params = false;
       
  1671       $escape = !empty($escape);
       
  1672       
       
  1673       $result = makeUrlNS($namespace, $page_id, $params, $escape);
       
  1674       
       
  1675       $text = str_replace_once($matches[0][$i], $result, $text);
       
  1676     }
  1661     return $text;
  1677     return $text;
  1662   }
  1678   }
  1663   
  1679   
  1664   // n00bish comments removed from here. 2008-03-13 @ 12:02AM when I had nothing else to do.
  1680   // n00bish comments removed from here. 2008-03-13 @ 12:02AM when I had nothing else to do.
  1665   
  1681   
  2079     if ( $result = $this->fetch_cached_sidebar() )
  2095     if ( $result = $this->fetch_cached_sidebar() )
  2080     {
  2096     {
  2081       return $result;
  2097       return $result;
  2082     }
  2098     }
  2083     
  2099     
       
  2100     require(ENANO_ROOT . "/themes/{$this->theme}/theme.cfg");
       
  2101     
  2084     profiler_log('Started sidebar parsing');
  2102     profiler_log('Started sidebar parsing');
  2085     
  2103     
  2086     // init our block contents
  2104     // init our block contents
  2087     $left = '';
  2105     $left = '';
  2088     $right = '';
  2106     $right = '';
  2113       $db->_die('The sidebar text data could not be selected.');
  2131       $db->_die('The sidebar text data could not be selected.');
  2114     
  2132     
  2115     // explicitly specify $q in case a plugin or PHP block makes a query
  2133     // explicitly specify $q in case a plugin or PHP block makes a query
  2116     while ( $row = $db->fetchrow($q) )
  2134     while ( $row = $db->fetchrow($q) )
  2117     {
  2135     {
       
  2136       // should we skip this block?
       
  2137       if (
       
  2138           ( $row['item_id'] === 2 && !empty($theme['sb_hide_tools']) ) ||
       
  2139           ( $row['item_id'] === 3 && !empty($theme['sb_hide_user']) ) ||
       
  2140           ( $row['item_id'] === 4 && !empty($theme['sb_hide_search']) )
       
  2141         )
       
  2142         continue;
       
  2143       
  2118       // format the block
  2144       // format the block
  2119       $block_content = $this->format_sidebar_block($row, $vars, $parser);
  2145       $block_content = $this->format_sidebar_block($row, $vars, $parser);
  2120       
  2146       
  2121       // is there a {restrict} or {hideif} block?
  2147       // is there a {restrict} or {hideif} block?
  2122       if ( preg_match('/\{(restrict|hideif) ([a-z0-9_\(\)\|&! ]+)\}/', $block_content, $match) )
  2148       if ( preg_match('/\{(restrict|hideif) ([a-z0-9_\(\)\|&! ]+)\}/', $block_content, $match) )