public static function initialize(array $options = array()) { foreach (self::$options as $k => $v) { self::$options[$k] = str_replace('%files%', Core::option('files_name'), $v); } self::options($options); }
public function file_path_for($module, $first = false) { $file = null; foreach ($this->paths as $name => $roots) { if (!is_array($roots)) { $roots = array($roots); } $drop_prefix = $this->extract_prefix_from($name); $parms = $this->parse_params_from($name); foreach ($roots as $root) { $module_template = $this->create_module_template_from($name); if (preg_match($module_template, $module, $module_match)) { $prefix = $this->set_parms_to($drop_prefix, $parms, $module_match); $root = $this->set_parms_to($root, $parms, $module_match); $file = $this->compose_file_path_for($module, $root, $prefix); $file = $this->process_not_necessarily_part($file); if (!is_file($file) && !$first) { continue; } else { return $file; } } } } if (!is_null($file)) { return $file; } if (Core::option('spl_autoload')) { return false; } else { throw new Core_ModuleNotFoundException($module); } }
/** * Инициализация модуля * * @param array $options */ public static function initialize(array $options = array()) { self::options($options); self::$helpers = Object::Aggregator(); if (Core::option('deprecated')) { self::$options['templates_root'][] = Core::tao_dir() . '/deprecated/views'; } }
static function initialize($config = array()) { foreach ($config as $key => $value) { self::${$key} = $value; } if (!self::$dir) { self::$dir = '../' . Core::option('files_name') . '/vars'; } }
/** * @param array $config */ static function initialize($config = array()) { self::$files_dir = './' . Core::option('files_name') . '/vars'; foreach ($config as $key => $value) { self::${$key} = $value; } Core::load('CMS.Vars.Types'); if (self::$type == 'orm') { Core::load('CMS.Vars.ORM'); WS::env()->orm->submapper('vars', 'CMS.Vars.ORM.Mapper'); } if (self::$type == 'storage') { Core::load('Storage'); Storage::manager()->add('vars', 'CMS.Vars.Storage'); } CMS::cached_run('CMS.Vars.Schema'); self::register_type('CMS.Vars.Types.Dir', 'CMS.Vars.Types.Integer', 'CMS.Vars.Types.String', 'CMS.Vars.Types.Text', 'CMS.Vars.Types.Html', 'CMS.Vars.Types.Array', 'CMS.Vars.Types.Mail', 'CMS.Vars.Types.HtmlP', 'CMS.Vars.Types.File'); CMS_Dumps::dumper('VARS', 'CMS.Dumps.Vars'); }
public function attaches($parms) { $id = (int) $parms['id']; $attaches = array(); if (IO_FS::exists("./" . Core::option('files_name') . "/vars/{$id}")) { foreach (IO_FS::Dir("./" . Core::option('files_name') . "/vars/{$id}") as $f) { $fp = $f->path; $attaches[$fp] = array('name' => $fp, 'path' => $f->path); } } return $this->render('attaches', array('id' => $id, 'attaches' => $attaches)); }
/** * Выполняет непосредствунную загрузкку файла модуля * * @param string $file * @param string $class_name * @param string $module * * @return Core_ModuleLoader */ protected function load_module_file($file, $class_name = '', $module = '') { if (Core::option('spl_autoload') && !$file) { return false; } $path = realpath($file); if (empty($path) && !class_exists($class_name, true)) { //Даем сработать autoload if (Core::option('spl_autoload')) { return false; } else { throw new Core_ModuleNotFoundException($module, $file); } } if (!empty($path)) { include_once $path; } return Core::option('spl_autoload') ? true : $this; }
protected function homedir_location($private = false) { return ($private ? '../' : '') . Core::option('files_name') . '/' . $this->mnemocode(); }
public function change($id, $data, $item) { if (is_object($item)) { $item->id = $id; } $file = $_FILES['value']; $name = trim($file['name']); $tmp_name = trim($file['tmp_name']); if ($tmp_name != '') { $dir = "./" . Core::option('files_name') . "/vars/{$id}"; CMS::mkdirs($dir, 0775); foreach (IO_FS::Dir($dir) as $f) { @IO_FS::rm($f->path); } $name = CMS::translit(mb_strtolower($name)); $name = preg_replace('{\\s+}', '_', $name); $name = trim(preg_replace('{[^a-z0-9_\\.\\-]}', '', $name)); if ($name == '') { $name = 'noname'; } if ($name[0] == '.') { $name = "noname.{$name}"; } move_uploaded_file($tmp_name, "{$dir}/{$name}"); chmod("{$dir}/{$name}", 0775); $rc = CMS::vars()->on_change_call($id, $value, $data); if (is_string($rc)) { $item->valuesrc = $data['valuesrc']; return $rc; } $item->value = "{$dir}/{$name}"; $item->update_value(); } }
public function homedir($private = false) { $path = $private ? '../' : './'; $path .= Core::option('files_name'); $path .= '/varfiles/' . $this->id(); CMS::mkdirs($path); return $path; }
/** * Возвращает имя каталога для хранения временных файлов * * @return string */ static function temp_dir() { if (self::$temp_dir === true) { return rtrim(sys_get_temp_dir(), '/'); } if (is_string(self::$temp_dir)) { return rtrim(self::$temp_dir, '/'); } if (isset(self::$cfg->site) && ($dir = self::$cfg->site->temp_dir)) { return rtrim($dir, '/'); } if (!IO_FS::exists('../' . Core::option('files_name') . '/tmp')) { @self::mkdirs('../' . Core::option('files_name') . '/tmp'); } if (IO_FS::exists('../' . Core::option('files_name') . '/tmp')) { return '../' . Core::option('files_name') . '/tmp'; } if (!IO_FS::exists('./' . Core::option('files_name') . '/tmp')) { self::mkdirs('./' . Core::option('files_name') . '/tmp'); } return './' . Core::option('files_name') . '/tmp'; }
public static function path($type, $path, $copy = true, $link = false) { $rc = Events::call('templates.asset.path', $type, $path, $copy, $link); if (!is_null($rc)) { return $rc; } $key = "{$type};{$path};{$copy};{$link}"; if (isset(self::$cached_paths[$key])) { return self::$cached_paths[$key]; } $path = self::extern_filepath($path, $copy, $link); if (Templates::is_absolute_path($path) || self::is_url($path)) { return self::$cached_paths[$key] = $path; } $urls = array(); foreach (self::option('assets') as $asset) { if ($asset[0] == '.') { $asset = self::option('extern_file_prefix') . $asset; } $url = sprintf("%s/%s/%s", $asset, self::option("{$type}_dir"), $path); $url = self::extern_filepath($url, $copy, $link); $urls[] = $url; $file = ".{$url}"; if (is_file($file)) { return self::$cached_paths[$key] = $url; } } if (Core::option('deprecated')) { $file = Core::tao_deprecated_file('files/' . self::option("{$type}_dir") . '/' . $path); if (is_file($file)) { return self::$cached_paths[$key] = self::extern_filepath(self::option('extern_file_prefix') . $file, $copy, $link); } } return self::$cached_paths[$key] = null; }
public function action_imagelist() { $id = (int) $this->args[0]; $ar = array(); if (IO_FS::exists("./" . Core::option('files_name') . "/vars/{$id}")) { foreach (IO_FS::Dir("./" . Core::option('files_name') . "/vars/{$id}") as $f) { $fp = $f->path; if ($m = Core_Regexps::match_with_results('{/([^/]+)$}', $fp)) { $fp = $m[1]; } $ar[] = '["' . $fp . '","' . CMS::file_url($f->path) . '"]'; } } echo 'var tinyMCEImageList = new Array(' . implode(',', $ar) . ');'; die; }