当前位置: 首页>>代码示例>>PHP>>正文


PHP Media::short方法代码示例

本文整理汇总了PHP中Media::short方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::short方法的具体用法?PHP Media::short怎么用?PHP Media::short使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Media的用法示例。


在下文中一共展示了Media::short方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _map

 /**
  * (Interactively) maps source files to destinations
  *
  * @param string $path Path to search for source files
  * @access protected
  * @return array
  */
 function _map($path)
 {
     $include = '.*[\\/\\].*\\.[a-z0-9]{2,3}$';
     $directories = array('.htaccess', '.DS_Store', 'media', '.git', '.svn', 'simpletest', 'empty');
     $extensions = array('db', 'htm', 'html', 'txt', 'php', 'ctp');
     $exclude = '.*[/\\\\](' . implode('|', $directories) . ').*$';
     $exclude .= '|.*[/\\\\].*\\.(' . implode('|', $extensions) . ')$';
     if (!empty($this->_exclude)) {
         $exclude = '|.*[/\\\\](' . implode('|', $this->_exclude) . ').*$';
     }
     $Folder = new Folder($path);
     $files = $Folder->findRecursive($include);
     foreach ($files as $file) {
         if (preg_match('#' . $exclude . '#', $file)) {
             continue;
         }
         $search[] = '/' . preg_quote($Folder->pwd(), '/') . '/';
         $search[] = '/(' . implode('|', Media::short()) . ')' . preg_quote(DS, '/') . '/';
         $fragment = preg_replace($search, null, $file);
         $mapped = array($file => MEDIA_STATIC . Media::short($file) . DS . $fragment);
         while (in_array(current($mapped), $this->_map) && $mapped) {
             $mapped = $this->_handleCollision($mapped);
         }
         while (file_exists(current($mapped)) && $mapped) {
             $this->out($this->shortPath(current($mapped)) . ' already exists.');
             $answer = $this->in('Would you like to [r]ename or [s]kip?', 'r,s', 's');
             if ($answer == 's') {
                 $mapped = array();
             } else {
                 $mapped = array(key($mapped) => $this->_rename(current($mapped)));
             }
         }
         if ($mapped) {
             $this->_map[key($mapped)] = current($mapped);
         }
     }
 }
开发者ID:razzman,项目名称:media,代码行数:44,代码来源:collect.php

示例2: transferTo

 /**
  * Returns a relative path to the destination file
  *
  * @param array $source Information about the source
  * @return string
  */
 function transferTo(&$Model, $via, $from)
 {
     extract($from);
     $path = Media::short($file, $mimeType) . DS;
     $path .= strtolower(Inflector::slug($filename));
     $path .= !empty($extension) ? '.' . strtolower($extension) : null;
     return $path;
 }
开发者ID:redlion09,项目名称:ems-1,代码行数:14,代码来源:transfer.php

示例3: __compatFile

 /**
  * Resolves partial path (compat)
  *
  * Examples:
  * img/cern                 >>> MEDIA_STATIC/img/cern.png
  * transfer/img/image.jpg   >>> MEDIA_TRANSFER/img/image.jpg
  * s/img/image.jpg          >>> MEDIA_FILTER/s/static/img/image.jpg
  *
  * @param string|array $path Either a string or an array with dirname and basename keys
  * @return string|boolean False on error or if path couldn't be resolbed otherwise
  *                        an absolute path to the file
  * @deprecated
  */
 function __compatFile($path)
 {
     $path = array();
     foreach (func_get_args() as $arg) {
         if (is_array($arg)) {
             if (isset($arg['dirname'])) {
                 $path[] = rtrim($arg['dirname'], '/\\');
             }
             if (isset($arg['basename'])) {
                 $path[] = $arg['basename'];
             }
         } else {
             $path[] = rtrim($arg, '/\\');
         }
     }
     $path = implode(DS, $path);
     $path = str_replace(array('/', '\\'), DS, $path);
     if (isset($this->__cached[$path])) {
         return $this->__cached[$path];
     }
     if (Folder::isAbsolute($path)) {
         return file_exists($path) ? $path : false;
     }
     $parts = explode(DS, $path);
     if (in_array($parts[0], $this->_versions)) {
         array_unshift($parts, basename(key($this->_map['filter'])));
     }
     if (!in_array($parts[0], array_keys($this->_directories))) {
         array_unshift($parts, basename(key($this->_map['static'])));
     }
     if (in_array($parts[1], $this->_versions) && !in_array($parts[2], array_keys($this->_directories))) {
         array_splice($parts, 2, 0, basename(key($this->_map['static'])));
     }
     $path = implode(DS, $parts);
     if (isset($this->__cached[$path])) {
         return $this->__cached[$path];
     }
     $file = $this->_directories[array_shift($parts)] . implode(DS, $parts);
     if (file_exists($file)) {
         return $this->__cached[$path] = $file;
     }
     $short = current(array_intersect(Media::short(), $parts));
     if (!$short) {
         $message = "MediaHelper::file - ";
         $message .= "You've provided a partial path without a media directory (e.g. img) ";
         $message .= "which is required to resolve the path.";
         trigger_error($message, E_USER_NOTICE);
         return false;
     }
     $extension = null;
     extract(pathinfo($file), EXTR_OVERWRITE);
     if (!isset($filename)) {
         /* PHP < 5.2.0 */
         $filename = substr($basename, 0, isset($extension) ? -(strlen($extension) + 1) : 0);
     }
     for ($i = 0; $i < 2; $i++) {
         $file = $i ? $dirname . DS . $filename : $dirname . DS . $basename;
         foreach ($this->_extensions[$short] as $extension) {
             $try = $file . '.' . $extension;
             if (file_exists($try)) {
                 return $this->__cached[$path] = $try;
             }
         }
     }
     return false;
 }
开发者ID:razzman,项目名称:media,代码行数:79,代码来源:MediaHelper.php

示例4: init

 /**
  * Initializes directory structure
  *
  * @access public
  * @return void
  */
 function init()
 {
     $message = 'Do you want to create missing media directories now?';
     if ($this->in($message, 'y,n', 'n') == 'n') {
         return false;
     }
     $dirs = array(MEDIA => array(), MEDIA_STATIC => Media::short(), MEDIA_TRANSFER => Media::short(), MEDIA_FILTER => array());
     foreach ($dirs as $dir => $subDirs) {
         if (is_dir($dir)) {
             $result = 'SKIP';
         } else {
             new Folder($dir, true);
             if (is_dir($dir)) {
                 $result = 'OK';
             } else {
                 $result = 'FAIL';
             }
         }
         $this->out(sprintf('%-50s [%-4s]', $this->shortPath($dir), $result));
         foreach ($subDirs as $subDir) {
             if (is_dir($dir . $subDir)) {
                 $result = 'SKIP';
             } else {
                 new Folder($dir . $subDir, true);
                 if (is_dir($dir . $subDir)) {
                     $result = 'OK';
                 } else {
                     $result = 'FAIL';
                 }
             }
             $this->out(sprintf('%-50s [%-4s]', $this->shortPath($dir . $subDir), $result));
         }
     }
     $this->out('');
     $this->protect();
     $this->out('Remember to set the correct permissions on transfer and filter directory.');
 }
开发者ID:redlion09,项目名称:ems-1,代码行数:43,代码来源:media.php


注:本文中的Media::short方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。