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.1 and 1.2

version 1.1, 2001/09/25 11:33:15 version 1.2, 2001/10/28 15:04:09
Line 12 
Line 12 
 class ObjTemplate  class ObjTemplate
 {  {
   
         var $filename;                  var $filename;
         var $html;                  var $html;
         var $start_tag, $end_tag;                  var $start_tag, $end_tag;
   
   
         function ObjTemplate($filename = '')                  function ObjTemplate($filename = '')
         {                  {
                 $this->filename = $filename;                                  $this->filename = $filename;
   
                 $this->set_tags();                                  $this->set_tags();
   
                 return $this->reload();                                  return $this->reload();
         }  
   
         function set_tags($start_tag = '%', $end_tag = '%')  
         {  
                 $this->start_tag = $start_tag;  
                 $this->end_tag = $end_tag;  
         }  
   
         function load($filename)  
         {  
                 if (file_exists($filename)) {  
                         $this->html = join('', file($filename));  
   
                         $this->_set_file();  
                         return 1;  
                 }                  }
   
                 return 0;                  function set_tags($start_tag = '%', $end_tag = '%')
         }                  {
                                   $this->start_tag = $start_tag;
         function reload()                                  $this->end_tag = $end_tag;
         {                  }
                 if (isset($this->filename))  
                         return $this->load($this->filename);  
   
                 return 0;                  function load($filename)
         }                  {
                                   if (file_exists($filename)) {
                                                   $this->html = join('', file($filename));
   
         function add_before($string)                                                  $this->_set_file();
         {                                                  return 1;
                 $this->html = $string . $this->html;                                  }
         }  
   
         function add_after($string)                                  return 0;
         {                  }
                 $this->html .= $string;  
         }  
   
         function set($key, $value = "")                  function reload()
         {                  {
                 if(gettype($key) == "array") {                                  if (isset($this->filename))
                         while ( list ($k, $v) = each ($key) ) {                                                  return $this->load($this->filename);
                                 if (!(empty($k))) {  
                                         /* Empty values are allowed. Empty Keys are NOT. */  
   
                                         $this->set($k, $v);                                  return 0;
                                 }  
                         }  
                 }                  }
                 else {  
   
                         $regexp = $this->start_tag . $key .  
                                 ( isset($this->end_tag) ? $this->end_tag : '\b' );  
   
                         if (isset($value)) {                  function add_before($string)
                                 $this->html = preg_replace("/$regexp/i", $value, $this->html);                  {
                         }                                  $this->html = $string . $this->html;
                 }                  }
   
                 $this->_set_file();                  function add_after($string)
         }                  {
                                   $this->html .= $string;
                   }
   
         function _set_file()                  function set($key, $value = "")
         {                  {
                 $regexp = $this->start_tag . 'file:([^%\b]+)' .                                  if (gettype($key) == "array") {
                         ( isset($this->end_tag) ? $this->end_tag : '\b' );                                                  while ( list ($k, $v) = each ($key) ) {
                                                                   if (!(empty($k))) {
                                                                                   /* Empty values are allowed. Empty keys are NOT. */
   
                                                                                   $this->set($k, $v);
                                                                   }
                                                   }
                                   }
                                   else {
   
                 while (preg_match("/$regexp/i", $this->html, $matches)){                                                  $regexp = $this->start_tag . $key .
                                                                   ( isset($this->end_tag) ? $this->end_tag : '\b' );
   
                         $filename = $matches[1];                                                  if (isset($value)) {
                         $filename_with_path = dirname($this->filename) . '/' . $filename;                                                                  $this->html = preg_replace("/$regexp/i", $value, $this->html);
                                                   }
                                   }
   
                         if (file_exists($filename_with_path)) {                                  $this->_set_file();
                                 $value = join('', file($filename_with_path));                  }
                         }  
                         else {  
                                 $value = "<!-- ObjTemplate.class.php: "  
                                         ."file not found: $filename_with_path -->";  
                         }  
   
                         $filename = addslashes($filename);                  function _set_file()
                   {
                                   $regexp = $this->start_tag . 'file:([^%\b]+)' .
                                                   ( isset($this->end_tag) ? $this->end_tag : '\b' );
   
                                   while (preg_match("/$regexp/i", $this->html, $matches)){
   
                                                   $filename = $matches[1];
                                                   $filename_with_path = dirname($this->filename) . '/' . $filename;
   
                                                   if (file_exists($filename_with_path)) {
                                                                   $value = join('', file($filename_with_path));
                                                   }
                                                   else {
                                                                   $value = "<!-- ObjTemplate.class.php: "
                                                                                   ."file not found: $filename_with_path -->";
                                                   }
   
                                                   $filename = addslashes($filename);
   
                                                   $regexp2 = $this->start_tag . "file:$filename" .
                                                                   ( isset($this->end_tag) ? $this->end_tag : '\b' );
                                                   $this->html = preg_replace("/$regexp2/i", $value, $this->html);
                                   }
   
                         $regexp2 = $this->start_tag . "file:$filename" .  
                                 ( isset($this->end_tag) ? $this->end_tag : '\b' );  
                         $this->html = preg_replace("/$regexp2/i", $value, $this->html);  
                 }                  }
   
         }                  function is_key($key)
                   {
                                   $regexp = $this->start_tag . $key .
                                                   ( isset($this->end_tag) ? $this->end_tag : '\b' );
   
         function is_key($key)                                  return preg_match("/$regexp/i", $this->html);
         {                  }
                 $regexp = $this->start_tag . $key .  
                         ( isset($this->end_tag) ? $this->end_tag : '\b' );  
   
                 return preg_match("/$regexp/i", $this->html);  
         }  
   
         function get_keys()                  function get_keys()
         {                  {
                 $regexp = $this->start_tag . '([\w][_\w\d]*)'.                                  $regexp = $this->start_tag . '([\w][_\w\d]*)'.
                         ( isset($this->end_tag) ? $this->end_tag : '\b' );                                                  ( isset($this->end_tag) ? $this->end_tag : '\b' );
   
                 preg_match_all("/$regexp/i", $this->html, $matches);                                  preg_match_all("/$regexp/i", $this->html, $matches);
   
                 return $matches[1];                                  return $matches[1];
         }                  }
   
         function hide()                  function hide()
         {                  {
                 $regexp = $this->start_tag . '\w+';                                  $regexp = $this->start_tag . '\w+';
                 $regexp .= ( isset($this->end_tag) ? $this->end_tag : '\b' );                                  $regexp .= ( isset($this->end_tag) ? $this->end_tag : '\b' );
   
                 $this->html = preg_replace("/($regexp)/i",                                  $this->html = preg_replace("/($regexp)/i",
                                 '<!-- ObjTemplate.class.php: hide: \\1 -->', $this->html);                                                                  '<!-- ObjTemplate.class.php: hide: \\1 -->', $this->html);
   
                 return $this->html();                                  return $this->html();
         }                  }
   
         function clean()                  function clean()
         {                  {
                 $regexp = $this->start_tag . '\w+' .                                  $regexp = $this->start_tag . '\w+' .
                         ( isset($this->end_tag) ? $this->end_tag : '\b' );                                                  ( isset($this->end_tag) ? $this->end_tag : '\b' );
   
                 $this->html = preg_replace("/$regexp/i", '', $this->html);                                  $this->html = preg_replace("/$regexp/i", '', $this->html);
   
                 return $this->html();                                  return $this->html();
         }                  }
   
         function html()                  function html()
         {                  {
                 return $this->html;                                  return $this->html;
         }                  }
   
         function html_array()                  function html_array()
         {                  {
                 $regexp =  $this->start_tag . 'include:([^%\b]+)' .                                  $regexp =  $this->start_tag . 'include:([^%\b]+)' .
                         ( isset($this->end_tag) ? $this->end_tag : '\b' ) . '';                                                  ( isset($this->end_tag) ? $this->end_tag : '\b' ) . '';
   
                 preg_match_all("/$regexp/is", $this->html, $matches);                                  preg_match_all("/$regexp/is", $this->html, $matches);
   
                 return array(preg_split("/$regexp/is", $this->html), $matches[1]);                                  return array(preg_split("/$regexp/is", $this->html), $matches[1]);
         }                  }
 }  }
   
 ?>  ?>

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

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