Beispiel #1
0
 public static function load($path, Config_Tree $defaults = null)
 {
     $extension = IO_FS::Path($path)->extension;
     if (isset(self::$parsers[$extension])) {
         $class_name = 'Config_File_' . self::$parsers[$extension];
         $parser = new $class_name($path);
         return $parser->parse($defaults);
     } else {
         throw new Config_File_UnknownFormatException($extension);
     }
 }
Beispiel #2
0
 public function on_execute(DB_Cursor $cursor)
 {
     self::$cnt++;
     if ($cursor->execution_time < self::$time_filter) {
         return;
     }
     if (!self::check_filters()) {
         return;
     }
     $dir = IO_FS::Path(self::$log_file)->dirname;
     IO_FS::mkdir($dir);
     $fh = fopen(self::$log_file, 'a');
     fwrite($fh, $this->create_string($cursor) . "\n");
     fclose($fh);
     CMS::chmod_file(self::$log_file);
 }
Beispiel #3
0
 /**
  * Конструктор
  *
  * @param string $tmp_name
  * @param string $original_name
  */
 public function __construct($tmp_path, $original_name, $file_array = array())
 {
     $this->original_name = IO_FS::Path($original_name)->basename;
     $this->file_array = $file_array;
     parent::__construct($tmp_path);
 }
Beispiel #4
0
 protected static function configure_paths()
 {
     $path_info = IO_FS::Path(__FILE__);
     self::$libpath = $path_info->dirname;
     self::$taopath = rtrim(self::$libpath, '/');
     self::$taopath = preg_replace('{[a-z0-9_-]+$}i', '', self::$taopath);
     self::$taopath = rtrim(self::$taopath, '/');
     self::$stdfiles_path = self::$taopath . '/files';
     self::$views_path = self::$taopath . '/views';
     self::check_assets();
     if ($m = Core_Regexps::match_with_results('{/([^/]+)$}', rtrim($_SERVER['DOCUMENT_ROOT'], '/'))) {
         CMS::$www = $m[1];
     }
 }
Beispiel #5
0
 public function set($value)
 {
     if (IO_FS::exists($value)) {
         $path = IO_FS::Path($value);
         $ext = $path->extension;
         $filename = $path->basename;
         $filename = $this->type->uploaded_file_name($this->name, $this->data, $this->item, $ext, $filename);
         $dir = $this->type->uploaded_file_dir($this->name, $this->data, $this->item);
         if ($dir) {
             if (!IO_FS::exists($dir)) {
                 CMS::mkdirs($dir);
             }
             $_dir = preg_replace('{^\\./}', '', $dir);
             copy($value, "{$dir}/{$filename}");
             $this->remove();
             $value = "{$_dir}/{$filename}";
             return parent::set($value);
         }
     }
     return $this;
 }
Beispiel #6
0
 /**
  * Определяет MIME-тип файла
  *
  * @param IO_FS_File|string $file
  *
  * @return MIME_Type
  */
 public static function type_for_file($file)
 {
     $file = IO_FS::Path($file);
     return self::type_for_suffix(isset($file->extension) ? $file->extension : '');
 }
Beispiel #7
0
 /**
  * @param IO_FS_File $file
  * @param array      $options
  */
 public function __construct(IO_FS_File $file, Service_Yandex_Direct_Manager_Application $app)
 {
     $this->file = $file;
     $this->name = IO_FS::Path($file->path)->filename;
     $this->config = $app->config;
     $this->log = $app->log->context(array('task' => $this->name));
 }