コード例 #1
0
 /**
  * Load and return a file's content
  * @param String $filename The file
  * @return String
  * @throws WFEFileNotFoundException
  */
 public static function content($filename)
 {
     $filepath = ROOT . '/' . $filename;
     if (WFELoader::fileExists($filename)) {
         return file_get_contents($filepath);
     } else {
         throw new WFEFileNotFoundException($filepath);
     }
 }
コード例 #2
0
 /**
  * Render a smarty template
  * if $arg1 is a string it will render the template $arg1 with parameters $arg2
  * if $arg1 is an array it will load the default template with parameters $arg1
  * 
  * @param mixed $arg1
  * @param Array $arg2
  * @return String Template rendered
  * @throws WFETemplateException If template does not exists
  */
 public static function render($arg1 = null, $arg2 = array())
 {
     self::init();
     if (is_array($arg1)) {
         $tpl = self::defaultTemplate();
         self::setParams($arg1);
     } elseif (is_string($arg1)) {
         $tpl = $arg1;
         self::setParams($arg2);
     } else {
         $tpl = self::defaultTemplate();
         self::setParams($arg2);
     }
     if (!WFELoader::fileExists('app/templates/' . $tpl)) {
         throw new WFETemplateException($tpl);
     }
     $output = self::$smarty->fetch($tpl);
     return $output;
 }
コード例 #3
0
 /**
  * Return true if controller exists in app/controllers 
  * @param String $controller
  * @return Boolean
  */
 private static function controllerExists($controller)
 {
     return WFELoader::fileExists('app/controllers/' . $controller . '.php') && class_exists(self::getControllerClass($controller));
 }