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.6 and 1.7

version 1.6, 2001/11/13 00:12:44 version 1.7, 2001/11/13 23:14:30
Line 205  class ObjTemplate
Line 205  class ObjTemplate
                 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'])) {
                                         if (is_array($ar[$i]['conditions']))                                          if (is_array($ar[$i]['conditions'])) {
                                                 array_push($ar_out, $this->_get_keys($ar[$i]['conditions']));                                                  if (is_array($ar[$i]['conditions']['key'])) {
                                         else                                                          $ar_out = array_merge($ar_out, $this->_get_keys($ar[$i]['conditions']['key']));
                                                 array_push($ar_out, $ar[$i]['conditions']);                                                  }
                                                   else
                                                           array_push($ar_out, $ar[$i]['conditions']['key']);
                                           }
   
                                         if (is_array($ar[$i]['true']))                                          if (is_array($ar[$i]['true']))
                                                 $ar_out = array_merge($ar_out, $this->_get_keys($ar[$i]['true']));                                                  $ar_out = array_merge($ar_out, $this->_get_keys($ar[$i]['true']));
Line 217  class ObjTemplate
Line 220  class ObjTemplate
                                 }                                  }
                                 elseif (isset($ar[$i]['key'])) {                                  elseif (isset($ar[$i]['key'])) {
                                         if (is_array($ar[$i]['key']))                                          if (is_array($ar[$i]['key']))
                                                 array_push($ar_out, $this->_get_keys($ar[$i]['key']));                                                  $ar_out = array_merge($ar_out, $this->_get_keys($ar[$i]['key']));
                                         else                                          else
                                                 array_push($ar_out, $ar[$i]['key']);                                                  array_push($ar_out, $ar[$i]['key']);
                                 }                                  }
Line 245  class ObjTemplate
Line 248  class ObjTemplate
                 return $this->_get_content($this->array, 'normal');                  return $this->_get_content($this->array, 'normal');
         }          }
   
         function _get_content($ar, $mode)          function _get_content($ar, $mode = "")
         {          {
                 $string = '';                  $string = '';
   
Line 253  class ObjTemplate
Line 256  class ObjTemplate
                         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'])) {
                                         if (is_array($ar[$i]['conditions']))                                          if (is_array($ar[$i]['conditions']))
                                                 $evalstr = $this->_final_join($ar[$i]['conditions']['key']);                                                  $evalstr = $this->_final_join($ar[$i]['conditions']['key'], $mode);
                                         else                                          else
                                                 $evalstr = '"' . $ar[$i]['conditions'] . '"';                                                  $evalstr = '"' . $ar[$i]['conditions'] . '"';
   
                                         $evalcode = "return ($evalstr);";                                          if (is_array($evalstr)) {
                                         print "evalcode = $evalcode<br>";                                                  $string .= $this->tag['begin'] . $this->cmd['if'] . $this->tag['delim'];
                                         if (eval($evalcode)) {                                                  $string .= $evalstr['uncompleted'] . $this->tag['end'];
                                                 echo "- returned true<br>";  
                                                 if (isset($ar[$i]['true'])) {                                                  if (is_array($ar[$i]['true']))
                                                         if (is_array($ar[$i]['true']))                                                          $string .= $this->_get_content($ar[$i]['true'], $mode);
                                                                 $string .= $this->_get_content($ar[$i]['true'], $mode);                                                  else
                                                         else                                                          $string .= $ar[$i]['true'];
                                                                 $string .= $ar[$i]['true'];  
                                                 }                                                  if (is_array($ar[$i]['false']))
                                                           $string .= $this->tag['begin'].$this->cmd['else'].$this->tag['end']
                                                                   . $this->_get_content($ar[$i]['false'], $mode);
                                                   else
                                                           $string .= $this->tag['begin'].$this->cmd['else'].$this->tag['end']
                                                                   . $ar[$i]['false'];
   
                                                   $string .= $this->tag['begin'].$this->cmd['endif'].$this->tag['end'];
                                         }                                          }
                                         else {                                          else {
                                                 echo "- returned false<br>";  
                                                 if (isset($ar[$i]['false'])) {                                                  $evalcode = "return ($evalstr);";
                                                         if (is_array($ar[$i]['false']))                                                  //print "evalcode = $evalcode<br>";
                                                                 $string .= $this->_get_content($ar[$i]['false'], $mode);                                                  if (eval($evalcode)) {
                                                         else                                                          //echo "- returned true<br>";
                                                                 $string .= $ar[$i]['false'];                                                          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 {
                                                           //echo "- returned false<br>";
                                                           if (isset($ar[$i]['false'])) {
                                                                   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'])) {
                                         if (is_array($ar[$i]['key'])) {                                          if (is_array($ar[$i]['key'])) {
                                                 $evalcode = "return (".$this->_final_join($ar[$i]['key']).");";                                                  $evalcode = "return (".$this->_final_join($ar[$i]['key']).");";
                                                 print "evalcode = $evalcode<br>";                                                  //print "NORMAL evalcode = $evalcode<br>";
                                                 $string .= eval($evalcode);                                                  $string .= eval($evalcode);
                                         }                                          }
                                         else {                                          else {
Line 366  class ObjTemplate
Line 390  class ObjTemplate
                 return $out_ar;                  return $out_ar;
         }          }
   
         function _final_join($ar) {          function _final_join($ar, $mode = "") {
                   $uncompleted = 0;
   
   
                 if (is_array($ar)) {                  if (is_array($ar)) {
                           // TODO comment
                           //print "Entering _final_join() with mode [$mode] / array set<br>";
                         $ret = '';                          $ret = '';
                         foreach ($ar as $i)                          foreach ($ar as $i) {
                                 if (! is_array($i))                                  if (is_array($i)) {
                                           switch ($mode) {
                                                   case "clean":
                                                           ;
                                                   break;
                                                   case "hide":
                                                           //              $string .= $this->_generate_error("hide: " . $ar[$i]['key']);
                                                           break;
                                                   default:
                                                   $uncompleted = 1;
                                                   $ret .= $i['key'];
                                                   break;
                                           }
                                   }
                                   else
                                         $ret .= $i;                                          $ret .= $i;
                           }
                   }
                   else {
                           switch ($mode) {
                                   case "clean":
                                           $ret = "0";
                                   break;
                                   case "hide":
                                           $ret = "0";
                                   //              $string .= $this->_generate_error("hide: " . $ar[$i]['key']);
                                   break;
                                   default:
                                   $uncompleted = 1;
                                   $ret = $ar;
                                   break;
                           }
                   }
   
                         return $ret;                  if ($uncompleted) {
                           // TODO comment
                           //print "_final_join(): returning uncompleted ($uncompleted)<b>[</b>$ret<b>]</b><br>";
                 }                  }
                 else  
                         return "0";                  return $uncompleted ? array('uncompleted' => $ret) : $ret;
         }          }
   
         function _string_transform($string, $debug = 0)          function _string_transform($string, $debug = 0)

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

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