Guest User

template.class.php

a guest
Aug 29th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.82 KB | None | 0 0
  1. <?php        
  2. /*
  3.          Файл: template.class.php
  4.          Роль файла: Парсинг шаблонов
  5.  
  6. */
  7.  
  8.                          class template
  9.                                          {
  10.                  
  11.                  
  12.                  
  13.     public function load_template($tpl, $replace=false)
  14.                          {
  15.                                  $tpl = TPL_DIR . $tpl;
  16.                                  
  17.                                  if(!file_exists($tpl))
  18.                                  {
  19.                                                 $_SESSION['engine_error'][] = "Невозможно прочитать файл шаблона: <b>" . $tpl . "</b>";
  20.                                                 $result = false;                                                
  21.                                  }
  22.                                  else
  23.                                  {
  24.                         $result = file_get_contents($tpl);
  25.                         if(is_array($replace) == true)
  26.             {
  27.                      $result = strtr($result, $replace);
  28.             }
  29.                        
  30.                                  }
  31.                                  return $result;
  32.                          }
  33.                
  34.  
  35.    
  36.                  public function load_usermodul($mod_name)
  37.                         {
  38.                      $dir = SYS_DIR . 'user_modules/' . $mod_name . '.php';
  39.                      if(!file_exists($dir))
  40.                      {
  41.                                     $result = "Модуль <b>" . $mod_name . "</b> не найден";
  42.                      }
  43.                      else
  44.                      {
  45.                                     require $dir;
  46.                         $obj = new $mod_name;                      
  47.                                     $result = $obj->user_modul();
  48.                      }
  49.                      return $result;                     
  50.             }
  51.                                                        
  52.                          }
Advertisement
Add Comment
Please, Sign In to add comment