Exemple #1
0
 /**
  * 写日志
  * 
  * @param type $message 
  */
 public static function log($message, $type = 'error')
 {
     $now = time();
     $time = date('Y-m-d H:i:s', $now);
     $file_name = "{$type}_" . date('Ymd', $now);
     $message = "\n{$time}:  {$message}";
     if (self::$file_path) {
         if (!is_dir(self::$file_path)) {
             mkdir(self::$file_path, 0775, true);
         }
         $file_path = Star_Loader::getFilePath(array(self::$file_path, $file_name), '.txt');
     } else {
         $directory = Star_Loader::getModuleDirect(self::$directory_name);
         if (!is_dir($directory)) {
             mkdir($directory, 0775, true);
         }
         $file_path = Star_Loader::getFilePath(array($directory, $file_name), '.txt');
     }
     $handle = fopen($file_path, self::$model, false);
     fwrite($handle, $message);
     fclose($handle);
 }
Exemple #2
0
 /**
  * 返回controller目录
  * 
  * @return type 
  */
 public function getControllerDirectory()
 {
     if ($this->controller_directory == null) {
         $module = $this->request->getModuleName();
         if ($this->isValidModule($module)) {
             $this->controller_directory = $this->getModuleControllerDirectory($module);
         } else {
             $directory_name = Star_Loader::getLoadTypeByKey($this->getControllerkey());
             $this->controller_directory = Star_Loader::getModuleDirect($directory_name);
         }
     }
     return $this->controller_directory;
 }
 /**
  * 设置自动加载
  */
 public function setAutoload($library_path)
 {
     $star_autoload = new Star_Loader();
     $star_autoload->setApplicationPath($this->application_path)->setLibraryPath($library_path);
     spl_autoload_register(array($star_autoload, 'autoload'));
     return $this;
 }
Exemple #4
0
 /**
  * 返回controller目录
  * 
  * @return type 
  */
 public function getControllerDirectory()
 {
     if ($this->controller_directory == null) {
         if ($this->module_name) {
             $this->controller_directory = $this->getModuleControllerDirectory($this->module_name);
         } else {
             $directory_name = Star_Loader::getLoadTypeByKey($this->controller_key);
             $this->controller_directory = Star_Loader::getModuleDirect($directory_name);
         }
     }
     return $this->controller_directory;
 }
 /**
  * 获取模板绝对地址
  * 
  * @param $file_name
  * @return type
  */
 private function getTemplatePath($file_name)
 {
     $view_segments = array($this->_base_name, $this->_template_name, $file_name);
     $view_path = Star_Loader::getFilePath($view_segments, $this->_postfix);
     return $view_path;
 }
Exemple #6
0
 /**
  * 设置框架路径
  * 
  * @param type $path
  * @return \Star_Loader
  */
 public function setLibraryPath($path)
 {
     if (!empty($path)) {
         self::$library_path = $path;
     }
     return $this;
 }