Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Thursday, October 15, 2026

Diff for phpPlatonLib/HTML_Template_Platon/Platon.php between version 1.2 and 1.3

version 1.2, 2003/01/15 22:15:36 version 1.3, 2003/02/09 17:48:22
Line 29  define('HTML_TEMPLATE_PLATON_METHOD_VAR_
Line 29  define('HTML_TEMPLATE_PLATON_METHOD_VAR_
 define('HTML_TEMPLATE_PLATON_SET_VALUE',                0);  define('HTML_TEMPLATE_PLATON_SET_VALUE',                0);
 define('HTML_TEMPLATE_PLATON_SET_CODE',                 1);  define('HTML_TEMPLATE_PLATON_SET_CODE',                 1);
 define('HTML_TEMPLATE_PLATON_SET_PARSE',                2);  define('HTML_TEMPLATE_PLATON_SET_PARSE',                2);
   define('HTML_TEMPLATE_PLATON_SET_VAR',                  3);
   
 class HTML_Template_Platon  class HTML_Template_Platon
 {  {
Line 41  class HTML_Template_Platon
Line 42  class HTML_Template_Platon
   
         var $_tag = array(          var $_tag = array(
                         'begin'   => '<|',                          'begin'   => '<|',
                         //'delim' => ':',  
                         'command' => 'cmd|',                          'command' => 'cmd|',
                         'file'    => 'include|',                          'file'    => 'include|',
                         'start'   => 'start',                          'start'   => 'start',
Line 49  class HTML_Template_Platon
Line 49  class HTML_Template_Platon
                         'end'     => '|>'                          'end'     => '|>'
                         );                          );
   
         var $_cmd = array( /* Both sides must be lowercase. */  
                         'if'    => 'if',  
                         'else'  => 'else',  
                         'endif' => 'endif',  
                         'file'  => 'file'  
                         );  
   
         var $_array     = array();          var $_array     = array();
         var $_vars      = array();          var $_vars      = array();
         var $_set_vars  = null;          var $_set_vars  = null;
Line 232  class HTML_Template_Platon
Line 225  class HTML_Template_Platon
                 $this->set($key, $value, HTML_TEMPLATE_PLATON_SET_CODE);                  $this->set($key, $value, HTML_TEMPLATE_PLATON_SET_CODE);
         }          }
   
           function setVar($key, $value = '')
           {
                   $this->set($key, $value, HTML_TEMPLATE_PLATON_SET_VAR);
           }
   
         function setValue($key, $value = '')          function setValue($key, $value = '')
         {          {
                 $this->set($key, $value);                  $this->set($key, $value);
Line 258  class HTML_Template_Platon
Line 256  class HTML_Template_Platon
                                 $this->_set_vars[$key] = array('ob_start();'.$value.'$'.$key.'=ob_get_contents();ob_end_clean();');                                  $this->_set_vars[$key] = array('ob_start();'.$value.'$'.$key.'=ob_get_contents();ob_end_clean();');
                                 preg_match_all('/\$(\w[\w\d_]*)/', $value, $matches);                                  preg_match_all('/\$(\w[\w\d_]*)/', $value, $matches);
                                 $this->_vars = array_merge($this->_vars, $matches[1]);                                  $this->_vars = array_merge($this->_vars, $matches[1]);
   
                         } elseif ($type == HTML_TEMPLATE_PLATON_SET_PARSE) {                          } elseif ($type == HTML_TEMPLATE_PLATON_SET_PARSE) {
                                 // TODO: lots of work                                  // TODO: lots of work
                                 $ar = $this->_stringTransform($value);                                  $ar = $this->_stringTransform($value);
Line 279  class HTML_Template_Platon
Line 276  class HTML_Template_Platon
                                                 array('$'.$key.'=ob_get_contents();ob_end_clean();'),                                                  array('$'.$key.'=ob_get_contents();ob_end_clean();'),
                                                 $this->_array);                                                  $this->_array);
                                 $this->_prepended += count($ar) + 3;                                  $this->_prepended += count($ar) + 3;
                           } elseif ($type == HTML_TEMPLATE_PLATON_SET_VAR) {
                                   $this->_set_vars[$key] = array('$'.$key.'=$'.$value.';');
                         } else { // HTML_TEMPLATE_PLATON_SET_VALUE                          } else { // HTML_TEMPLATE_PLATON_SET_VALUE
                                 $this->_set_vars[$key] = $value;                                  $this->_set_vars[$key] = $value;
                         }                          }
Line 352  class HTML_Template_Platon
Line 351  class HTML_Template_Platon
                 if ($this->_method & HTML_TEMPLATE_PLATON_METHOD_VAR_KEEP) {                  if ($this->_method & HTML_TEMPLATE_PLATON_METHOD_VAR_KEEP) {
                         foreach ($this->_set_vars as $key => $val) {                          foreach ($this->_set_vars as $key => $val) {
                                 // @ is used, since kept varaible may not exist                                  // @ is used, since kept varaible may not exist
                                 if (is_array($this->_set_vars[$key])) {                                  if (is_array($val)) {
                                         $ret .= '$'.$key.'__HTML_Template_Platon_var_bck=@$'.$key.';';                                          $ret .= '$'.$key.'__HTML_Template_Platon_var_bck=@$'.$key.';'."\n";
                                         $ret .= $val[0];                                          $ret .= $val[0]."\n";
                                 } else {                                  } else {
                                         $ret = '$' . $key . '=\''                                          $ret = '$' . $key . '=\''
                                                 . str_replace('\'', '\\\'', str_replace('\\', '\\\\\\\\', $val))                                                  . str_replace('\'', '\\\'', str_replace('\\', '\\\\\\\\', $val))
Line 365  class HTML_Template_Platon
Line 364  class HTML_Template_Platon
                         }                          }
                 } else {                  } else {
                         foreach ($this->_set_vars as $key => $val) {                          foreach ($this->_set_vars as $key => $val) {
                                 if (is_array($this->_set_vars[$key])) {                                  if (is_array($val)) {
                                         $ret .= $val[0];                                          $ret .= $val[0]."\n";
                                 } else {                                  } else {
                                         $ret = '$' . $key . '=\''                                          $ret = '$' . $key . '=\''
                                                 . str_replace('\'', '\\\'', str_replace('\\', '\\\\\\\\', $val))                                                  . str_replace('\'', '\\\'', str_replace('\\', '\\\\\\\\', $val))

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top