本文整理汇总了PHP中FileSystem::normalize_path方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::normalize_path方法的具体用法?PHP FileSystem::normalize_path怎么用?PHP FileSystem::normalize_path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::normalize_path方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
public function before()
{
parent::before();
if (file_exists(CMSPATH . FileSystem::normalize_path('media/js/i18n/' . I18n::lang() . '-message.js'))) {
Assets::js('i18n', ADMIN_RESOURCES . 'js/i18n/' . I18n::lang() . '-message.js', 'global');
}
if ($this->request->action() != 'logout' and Auth::is_logged_in()) {
$this->go_home();
}
}
示例2: set_watermark_path
/**
*
* @param string $path
*/
public function set_watermark_path($path)
{
$path = FileSystem::normalize_path($path);
$image_path = DOCROOT . $path;
if ($this->is_image($image_path)) {
$this->watermark_path = $path;
} else {
$this->watermark = FALSE;
$this->watermark_path = NULL;
}
}
示例3: factory
/**
*
* @param string|SplFileInfo $file
* @return \FileSystem|\FileSystem_File|\FileSystem_Directory
* @throws Kohana_Exception
*/
public static function factory($path)
{
if (!$path instanceof SplFileInfo) {
$path = FileSystem::normalize_path($path);
if (file_exists($path)) {
if (!is_dir($path)) {
$path = new FileSystem_File($path);
} else {
$path = new FileSystem_Directory($path);
}
} else {
throw new Kohana_Exception('Directory or file :path not found', array(':path' => $path));
}
}
return new FileSystem($path);
}
示例4: init_media
public function init_media()
{
parent::init_media();
$this->template_js_params['ACE_THEME'] = Config::get('ace', 'theme', 'textmate');
$this->template_js_params['DEFAULT_FILTER'] = Config::get('site', 'default_filter_id', '');
Assets::package(array('jquery', 'bootstrap', 'notify', 'select2', 'dropzone', 'fancybox', 'datepicker', 'underscore', 'core'));
foreach (array('.js', '-message.js') as $file_name) {
$filename = Kohana::$cache_dir . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, array('i18n', NULL)) . I18n::lang() . $file_name;
if (file_exists($filename)) {
Assets::js('i18n', BASE_URL . 'cms/cache/i18n/' . I18n::lang() . $file_name, 'global', FALSE, 0);
}
}
$file = $this->request->controller();
$directory = $this->request->directory();
if (!empty($directory)) {
$file = $directory . '/' . $file;
}
$file = strtolower($file);
if (Kohana::find_file('media', FileSystem::normalize_path('js/controller/' . $file), 'js')) {
Assets::js('controller.' . $file, ADMIN_RESOURCES . 'js/controller/' . $file . '.js', 'global', FALSE, 999);
}
Assets::group('global', 'events', '<script type="text/javascript">' . Assets::merge_files('js/events', 'js') . '</script>', 'global');
}
示例5: mergeFiles
/**
* @param string $path
* @param string $ext
* @param string $cache_key
* @param integer $lifetime
* @return string
*/
public static function mergeFiles($path, $ext, $cacheKey = NULL, $lifetime = Date::DAY)
{
$cache = Cache::instance();
if ($cache_key === NULL) {
$cache_key = 'assets::merge::' . URL::title($path, '::') . '::' . $ext;
}
$content = $cache->get($cache_key);
if ($content === NULL) {
$files = Kohana::find_file('media', FileSystem::normalize_path($path), $ext, TRUE);
if (!empty($files)) {
foreach ($files as $file) {
$content .= file_get_contents($file) . "\n";
}
if (Kohana::$caching === TRUE) {
$cache->set($cache_key, $content, $lifetime);
}
}
}
return $content;
}
示例6: cache
/**
* Создание уменьшенной копии изображения.
* Копия помещается в папку PUBLICPATH . cache
*
* @param string $filepath Путь до файла относительно PUBLICPATH
* @param integer $width
* @param integer $height
* @param integer $master Мастер изменеия размера
* @param bool $crop Обрезать?
*
* return NULL | string Путь до кеша изображения
*/
public static function cache($filepath, $width, $height, $master = Image::INVERSE, $crop = FALSE)
{
if ($master === NULL) {
$master = Image::INVERSE;
}
$original_image = PUBLICPATH . $filepath;
if (!is_file($original_image)) {
return NULL;
}
$filename = pathinfo($filepath, PATHINFO_FILENAME);
$directory = pathinfo($filepath, PATHINFO_DIRNAME);
$extension = strtolower(pathinfo($filepath, PATHINFO_EXTENSION));
if (!in_array($extension, array('jpg', 'gif', 'png', 'bmp', 'jpeg'))) {
return NULL;
}
$cached_filename = $filename . '_' . $width . 'x' . $height . 'x' . $master;
if ($crop === TRUE) {
$cached_filename .= 'xCR';
}
$cached_image = 'cache/' . $directory . '/' . $cached_filename . '.' . $extension;
$directory = FileSystem::normalize_path($directory);
if (!is_file(PUBLICPATH . $cached_image) or filectime($original_image) > filectime(PUBLICPATH . $cached_image)) {
$path = PUBLICPATH . 'cache';
if (!is_dir($path) and is_writable(PUBLICPATH)) {
mkdir($path, 0777);
} else {
if (!is_writable(PUBLICPATH)) {
throw new Kohana_Exception('Unable to write to the cache directory :resource', array(':resource' => $path));
}
}
$directories = explode(DIRECTORY_SEPARATOR, $directory);
foreach ($directories as $directory) {
if (!is_writable($path)) {
throw new Kohana_Exception('Unable to write to the cache directory :resource', array(':resource' => $path));
}
$path = $path . DIRECTORY_SEPARATOR . $directory;
if (!is_dir($path)) {
mkdir($path, 0777);
}
}
list($width_orig, $height_orig) = getimagesize($original_image);
if ($width_orig > $width or $height_orig > $height) {
$iamge = Image::factory($original_image)->resize($width, $height, $master);
if ($crop === TRUE) {
$iamge->crop($width, $height);
}
$iamge->save(PUBLICPATH . $cached_image);
} else {
copy($original_image, PUBLICPATH . $cached_image);
}
}
return PUBLIC_URL . $cached_image;
}