cvs: smarty / NEWS /libs Config_File.class.php

"Messju Mohr" <[email protected]>
Newsgroups gmane.comp.php.cvs.smarty
Message-ID <cvsmessju1074815267@cvsserver>
messju		Thu Jan 22 18:47:47 2004 EDT

  Modified files:              
    /smarty	NEWS 
    /smarty/libs	Config_File.class.php 
  Log:
  fixed handling of hidden sections in Config_File
  
  
  
http://cvs.php.net/diff.php/smarty/NEWS?r1=1.430&r2=1.431&ty=u
Index: smarty/NEWS
diff -u smarty/NEWS:1.430 smarty/NEWS:1.431
--- smarty/NEWS:1.430	Wed Jan 21 12:21:26 2004
+++ smarty/NEWS	Thu Jan 22 18:47:45 2004
@@ -1,3 +1,4 @@
+  - fix handling of hidden sections in Config_File (messju)
   - add handling of resources for {config_load} (messju)
   - fix bug when using arrays with tr_attr and td_attr in {html_table} (messju)
   - add unit testing to cvs core (Monte)
http://cvs.php.net/diff.php/smarty/libs/Config_File.class.php?r1=1.63&r2=1.64&ty=u
Index: smarty/libs/Config_File.class.php
diff -u smarty/libs/Config_File.class.php:1.63 smarty/libs/Config_File.class.php:1.64
--- smarty/libs/Config_File.class.php:1.63	Fri Jan 16 17:12:07 2004
+++ smarty/libs/Config_File.class.php	Thu Jan 22 18:47:46 2004
@@ -31,7 +31,7 @@
  * @package Smarty
  */
 
-/* $Id: Config_File.class.php,v 1.63 2004/01/16 22:12:07 mohrt Exp $ */
+/* $Id: Config_File.class.php,v 1.64 2004/01/22 23:47:46 messju Exp $ */
 
 /**
  * Config file reading class
@@ -289,9 +289,21 @@
         $lines = $match[0];
         for ($i=0, $count=count($lines); $i<$count; $i++) {
             $line = $lines[$i];
-            if ( @($line{0} == '[') && preg_match('!^\[(\w+)\]!', $line, $match) ) {
+            if ( @($line{0} == '[') && preg_match('!^\[(.*?)\]!', $line, $match) ) {
                 /* section found */
-                $section_name = $match[1];
+                if ($match[1]{0} == '.') {
+                    /* hidden section */
+                    if ($this->read_hidden) {
+                        $section_name = substr($match[1], 1);
+                    } else {
+                        /* break reference to $vars to ignore hidden section */
+                        unset($vars);
+                        $vars = array();
+                        continue;
+                    }
+                } else {                    
+                    $section_name = $match[1];
+                }
                 if (!isset($config_data['sections'][$section_name]))
                     $config_data['sections'][$section_name] = array('vars' => array());
                 $vars =& $config_data['sections'][$section_name]['vars'];

-- 
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.