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

Diff for phpPlatonLib/templateSystems/ObjTemplate/Attic/ObjTemplate.class.php between version 1.5 and 1.6

version 1.5, 2001/11/10 23:35:54 version 1.6, 2001/11/13 00:12:44
Line 105  class ObjTemplate
Line 105  class ObjTemplate
                                 elseif (! strcmp($this->cmd['if'], $ar[$i]['key'])) {                                  elseif (! strcmp($this->cmd['if'], $ar[$i]['key'])) {
   
                                         if (is_array($ar[$i]['conditions'])) {                                          if (is_array($ar[$i]['conditions'])) {
                                                 if (true == $this->_is_key($key, $ar[$i]['conditions']))                                                  if (is_array($ar[$i]['conditions']['key'])) {
                                                         return true;                                                          if (true == $this->_is_key($key, $ar[$i]['conditions']['key']))
                                         }                                                                  return true;
                                         else {                                                  }
                                                 if (! strcmp($key, $ar[$i]['conditions']))                                                  else {
                                                         return true;                                                          if (! strcmp($key, $ar[$i]['conditions']['key']))
                                                                   return true;
                                                   }
                                         }                                          }
   
                                         if (is_array($ar[$i]['true'])) {                                          if (is_array($ar[$i]['true'])) {
Line 158  class ObjTemplate
Line 160  class ObjTemplate
                                 if (isset($ar[$i]['key'])) {                                  if (isset($ar[$i]['key'])) {
                                         if (is_array($ar[$i]['key']))                                          if (is_array($ar[$i]['key']))
                                                 $this->_set($key, $value, $ar[$i]['key']);                                                  $this->_set($key, $value, $ar[$i]['key']);
                                         else                                          elseif (! strcmp($this->cmd['if'], $ar[$i]['key'])) {
                                                   if (is_array($ar[$i]['conditions'])) {
                                                           if (is_array($ar[$i]['conditions']['key'])) {
                                                                   $this->_set($key, $value, $ar[$i]['conditions']['key']);
                                                           }
                                                           else {
                                                                   if (! strcmp($key, $ar[$i]['conditions']['key']))
                                                                           $ar[$i]['conditions'] = $value;
                                                           }
                                                   }
   
                                                   if (is_array($ar[$i]['true']))
                                                           $this->_set($key, $value, $ar[$i]['true']);
                                                   if (is_array($ar[$i]['false']))
                                                           $this->_set($key, $value, $ar[$i]['false']);
                                           }
                                           else {
                                                 if (! strcmp($key, $ar[$i]['key']))                                                  if (! strcmp($key, $ar[$i]['key']))
                                                         $ar[$i] = $value;                                                          $ar[$i] = $value;
                                 }                                          }
                                 elseif (! strcmp($this->cmd['if'], $ar[$i]['key'])) {  
                                         if (is_array($ar[$i]['conditions']))  
                                                 $this->_set($key, $value, $ar[$i]['conditions']);  
                                         else  
                                                 if (! strcmp($key, $ar[$i]['conditions']))  
                                                         $ar[$i] = $value;  
   
                                         if (is_array($ar[$i]['true']))  
                                                 $this->_set($key, $value, $ar[$i]['true']);  
                                         if (is_array($ar[$i]['false']))  
                                                 $this->_set($key, $value, $ar[$i]['false']);  
                                 }                                  }
                                 else {                                  else {
                                         $this->_set($key, $value, $ar[$i]);                                          $this->_set($key, $value, $ar[$i]);
Line 183  class ObjTemplate
Line 190  class ObjTemplate
                 return;                  return;
         }          }
   
           /* TODO: fix conditions in IF */
   
         function get_keys()          function get_keys()
         {          {
                 return array_unique($this->_get_keys($this->array));                  return array_unique($this->_get_keys($this->array));
Line 238  class ObjTemplate
Line 247  class ObjTemplate
   
         function _get_content($ar, $mode)          function _get_content($ar, $mode)
         {          {
   
                 $string = '';                  $string = '';
   
                 for ($i = 0; $i < count($ar); $i++) {                  for ($i = 0; $i < count($ar); $i++) {
                         if (is_array($ar[$i])) {                          if (is_array($ar[$i])) {
                                 if (! strcmp($this->cmd['if'], $ar[$i]['key'])) {                                  if (! strcmp($this->cmd['if'], $ar[$i]['key'])) {
                                         /* TODO: :) */                                          if (is_array($ar[$i]['conditions']))
                                         echo "IF conditions: [".$ar[$i]['conditions']."] -- ";                                                  $evalstr = $this->_final_join($ar[$i]['conditions']['key']);
                                         if (eval("return (".$this->_final_join($ar[$i]['conditions']).");")) {                                          else
                                                 echo "returned true<br>";                                                  $evalstr = '"' . $ar[$i]['conditions'] . '"';
                                                 if (is_array($ar[$i]['true']))  
                                                         $string .= $this->_get_content($ar[$i]['true'], $mode);                                          $evalcode = "return ($evalstr);";
                                           print "evalcode = $evalcode<br>";
                                           if (eval($evalcode)) {
                                                   echo "- returned true<br>";
                                                   if (isset($ar[$i]['true'])) {
                                                           if (is_array($ar[$i]['true']))
                                                                   $string .= $this->_get_content($ar[$i]['true'], $mode);
                                                           else
                                                                   $string .= $ar[$i]['true'];
                                                   }
                                         }                                          }
                                         else {                                          else {
                                                 echo "returned false<br>";                                                  echo "- returned false<br>";
                                                 if (is_array($ar[$i]['false']))                                                  if (isset($ar[$i]['false'])) {
                                                         $string .= $this->_get_content($ar[$i]['false'], $mode);                                                          if (is_array($ar[$i]['false']))
                                                                   $string .= $this->_get_content($ar[$i]['false'], $mode);
                                                           else
                                                                   $string .= $ar[$i]['false'];
                                                   }
                                         }                                          }
                                 }                                  }
                                 elseif (isset($ar[$i]['key'])) {                                  elseif (isset($ar[$i]['key'])) {
Line 307  class ObjTemplate
Line 328  class ObjTemplate
         }          }
   
         function _start_explode($str) {          function _start_explode($str) {
                 $char = '[\w\d_:]';  
                 $neg_char = '[^\w\d_:]';  
   
                 if (preg_match("/^$char+$/", $str))                  if (preg_match("/^[\w:]+$/", $str))
                         return $str;                          return strtolower($str);
   
                 $out_ar = array();                  $out_ar = array();
                 $tmpstr = '';                  $tmpstr = '';
   
                 if (preg_match("/^$char$/", $str[$i])) $type = 1;                  if (preg_match("/^[a-zA-Z]$/", $str[0])) $type = 1;
                 else $type = 0;                  else $type = 0;
   
                 for ($i = 0; $i < strlen($str); $i++) {                  for ($i = 0; $i < strlen($str); $i++) {
                         if ($type == 1) {                          if ($type == 1) {
                                 if (preg_match("/^$char$/", $str[$i])) {                                  if (preg_match("/^[\w:]$/", $str[$i])) {
                                         $tmpstr .= $str[$i];                                          $tmpstr .= $str[$i];
                                 }                                  }
                                 else {                                  else {
                                         array_push($out_ar, $tmpstr);                                          array_push($out_ar, array('key' => strtolower($tmpstr)));
                                         $tmpstr = '';                                          $tmpstr = $str[$i];
                                         $type = 0;                                          $type = 0;
                                 }                                  }
                         }                          }
                         else {                          else {
                                 if (preg_match("/^[\w]$/", $str[$i])) {                                  if (preg_match("/^[a-zA-Z]$/", $str[$i])) {
                                         array_push($out_ar, array('key' => strtolower($tmpstr)));                                          array_push($out_ar, $tmpstr);
                                         $tmpstr = '';                                          $tmpstr = $str[$i];
                                         $type = 1;                                          $type = 1;
                                 }                                  }
                                 else {                                  else {
Line 357  class ObjTemplate
Line 376  class ObjTemplate
                         return $ret;                          return $ret;
                 }                  }
                 else                  else
                         return "'$ar'";                          return "0";
         }          }
   
         /*  
          *       Required improvements:  
          *  
          *       - remove empty text records (at the end of array)  
          *       - return only string if array is not necessary  
          *  
          */  
   
         function _string_transform($string, $debug = 0)          function _string_transform($string, $debug = 0)
         {          {
                 $ar_out_idx = 0;  
   
                 /*                  /*
                  * Spliting string into two arrays by tags. First array ($m_tags) will                   * Spliting string into two arrays by tags. First array ($m_tags) will
                  * contain only tags without starting prefix and ending sufix.                   * contain only tags without starting prefix and ending sufix.
Line 489  class ObjTemplate
Line 498  class ObjTemplate
                  * Main loop.                   * Main loop.
                  */                   */
   
                   $ar_out_idx = 0;
   
                 for ($i = 0; $i < count($m_texts); $i++) {                  for ($i = 0; $i < count($m_texts); $i++) {
   
                         /* Text processing. */                          /* Text processing. */
Line 517  class ObjTemplate
Line 528  class ObjTemplate
                                         else                                          else
                                                 $ar_out[$ar_out_idx] =                                                  $ar_out[$ar_out_idx] =
                                                         $this->_generate_error("file not found: $filename_with_path");                                                          $this->_generate_error("file not found: $filename_with_path");
   
                                         //$ar_out_idx++;  
                                 }                                  }
   
                                 /* IF tag. */                                  /* IF tag. */
                                 elseif (! strcasecmp($this->cmd['if'], $cmd_parts[0])) {                                  elseif (! strcasecmp($this->cmd['if'], $cmd_parts[0])) {
                                         $ar_out[$ar_out_idx] = array(                                          $ar_out[$ar_out_idx] = array(
                                                         'key' => $this->cmd['if'],                                                          'key' => $this->cmd['if'],
                                                         'conditions' => $this->_start_explode($cmd_parts[1])                                                          'conditions' => array('key' => $this->_start_explode($cmd_parts[1]))
                                                         //'conditions' => strtolower($cmd_parts[1])  
                                                         );                                                          );
                                         $tmp_str = '';                                          $tmp_str = '';
                                         $level = 0;                                          $level = 0;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

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