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


PHP File::name方法代码示例

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


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

示例1: execute

 public function execute()
 {
     // I18nProfile class: http://stackoverflow.com/questions/8433686/is-there-a-php-library-for-parsing-gettext-po-pot-files
     App::import('Lib', 'I18nJs.PoParser');
     $dir = new Folder(APP . 'Locale');
     $locales = $dir->read();
     foreach ($locales[0] as $localeDir) {
         $msgids = array();
         $language = $localeDir;
         $localeDir = new Folder(APP . 'Locale' . DS . $localeDir);
         $files = $localeDir->findRecursive('i18n_js.*\\.po');
         // Loop over PO i18n_js PO files
         foreach ($files as $file) {
             $file = new File($file);
             // Get language
             if (preg_match('%Locale/(.*?)/LC_MESSAGES%', $file->path, $regs)) {
                 $language = $regs[1];
             } else {
                 // todo return
                 $this->out(__d('i18n_js', '<error>Unable to determine language of PO file:</error>') . $file->path);
                 return;
             }
             // Get context, domain
             $context = '';
             if (strpos($file->name(), '.')) {
                 $context = explode('.', $file->name());
                 $context = $context[1];
             }
             // Parse PO file
             $poparser = new \Sepia\PoParser();
             $translations = $poparser->parse($file->path);
             foreach ($translations as $key => $translation) {
                 if (empty($key)) {
                     continue;
                 }
                 if (is_array($translation['msgid'])) {
                     $translation['msgid'] = implode('', $translation['msgid']);
                 }
                 if (is_array($translation['msgstr'])) {
                     $translation['msgstr'] = implode('', $translation['msgstr']);
                 }
                 $msgids[$context][$translation['msgid']] = $translation['msgstr'];
             }
         }
         if (empty($msgids)) {
             continue;
         }
         // Write JS file
         $outputFile = new File(WWW_ROOT . 'js' . DS . 'Locale' . DS . 'i18n_js.' . $language . '.js', true);
         $data = "I18nJs.locale = { ";
         $data .= "'pluralFormula': function (\$n) { return Number((\$n != 1)); }, ";
         $data .= "'strings': " . json_encode($msgids, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) . " };";
         if ($outputFile->write($data)) {
             $this->out(__d('i18n_js', '<info>%s created</info>', $outputFile->path));
         } else {
             $this->out(__d('i18n_js', '<error>Unable to write: %s</error>', $outputFile->path));
         }
     }
 }
开发者ID:wvdongen,项目名称:cakephp-i18njs,代码行数:59,代码来源:CreateJsTask.php

示例2: flags

 public function flags($current)
 {
     $dir = new Folder(WWW_ROOT . 'img/flags');
     $files = $dir->find('.*', true);
     if ($current != 'unknown') {
         $flag[$current] = $current;
     }
     $flag[''] = '';
     foreach ($files as $file) {
         $file = new File($dir->pwd() . DS . $file);
         $flag[Inflector::humanize($file->name())] = Inflector::humanize($file->name());
         $file->close();
         // Be sure to close the file when you're done
     }
     return $flag;
 }
开发者ID:nsystem1,项目名称:cwt,代码行数:16,代码来源:Profile.php

示例3: main

 /**
  * undocumented function
  *
  * @return void
  */
 function main()
 {
     $result = $folder = null;
     $mainfiles = explode(',', $this->args[0]);
     $target = !empty($this->params['ext']) ? $this->args[0] . '.' . $this->params['ext'] : $this->args[0] . '.min';
     $jsroot = $this->params['working'] . DS . $this->params['webroot'] . DS . 'js' . DS;
     foreach ((array) $mainfiles as $mainfile) {
         $mainfile = strpos($mainfile, '/') === false ? $jsroot . $mainfile : $mainfile;
         $Pack = new File(str_replace('.js', '', $mainfile) . '.js');
         $result .= JsMin::minify($Pack->read());
     }
     if (!empty($this->args[1])) {
         $folder = $this->args[1] . DS;
         $Js = new Folder($jsroot . $folder);
         list($ds, $files) = $Js->read();
         foreach ((array) $files as $file) {
             $file = strpos($file, '/') === false ? $jsroot . $folder . $file : $file;
             $Pack = new File(str_replace('.js', '', $file) . '.js');
             $result .= JsMin::minify($Pack->read());
         }
     }
     $Packed = new File($jsroot . $target . '.js');
     if ($Packed->write($result, 'w', true)) {
         $this->out($Packed->name() . ' created');
     }
 }
开发者ID:Galvanio,项目名称:Kinspir,代码行数:31,代码来源:minify.php

示例4: main

 public function main()
 {
     $Folder = new Folder(dirname(dirname(dirname(__FILE__))) . DS . "features");
     $this->out("copy " . $Folder->pwd() . " to Cake Root...");
     $Folder->copy(array('to' => ROOT . DS . "features"));
     $File = new File(dirname(__FILE__) . DS . "behat.yml.default");
     $this->out("copy " . $File->name() . " to App/Config...");
     $File->copy(APP . DS . "Config" . DS . "behat.yml");
 }
开发者ID:nojimage,项目名称:Bdd,代码行数:9,代码来源:InitShell.php

示例5: __construct

 /**
  * Constructor.
  *
  * @access  protected
  */
 protected function __construct()
 {
     $plugins_cache_id = '';
     $plugin_manifest = [];
     $plugin_settings = [];
     // Get Plugins List
     $plugins_list = Config::get('system.plugins');
     // If Plugins List isnt empty then create plugin cache ID
     if (is_array($plugins_list) && count($plugins_list) > 0) {
         // Go through...
         foreach ($plugins_list as $plugin) {
             if (File::exists($_plugin = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yml')) {
                 $plugins_cache_id .= filemtime($_plugin);
             }
         }
         // Create Unique Cache ID for Plugins
         $plugins_cache_id = md5('plugins' . ROOT_DIR . PLUGINS_PATH . $plugins_cache_id);
     }
     // Get plugins list from cache or scan plugins folder and create new plugins cache item
     if (Cache::driver()->contains($plugins_cache_id)) {
         Config::set('plugins', Cache::driver()->fetch($plugins_cache_id));
     } else {
         // If Plugins List isnt empty
         if (is_array($plugins_list) && count($plugins_list) > 0) {
             // Go through...
             foreach ($plugins_list as $plugin) {
                 if (File::exists($_plugin_manifest = PLUGINS_PATH . '/' . $plugin . '/' . $plugin . '.yml')) {
                     $plugin_manifest = Yaml::parseFile($_plugin_manifest);
                 }
                 if (File::exists($_plugin_settings = PLUGINS_PATH . '/' . $plugin . '/settings.yml')) {
                     $plugin_settings = Yaml::parseFile($_plugin_settings);
                 }
                 $_plugins_config[File::name($_plugin_manifest)] = array_merge($plugin_manifest, $plugin_settings);
             }
             Config::set('plugins', $_plugins_config);
             Cache::driver()->save($plugins_cache_id, $_plugins_config);
         }
     }
     // Include enabled plugins
     if (is_array(Config::get('plugins')) && count(Config::get('plugins')) > 0) {
         foreach (Config::get('plugins') as $plugin_name => $plugin) {
             if (Config::get('plugins.' . $plugin_name . '.enabled')) {
                 include_once PLUGINS_PATH . '/' . $plugin_name . '/' . $plugin_name . '.php';
             }
         }
     }
     // Run Actions on plugins_loaded
     Action::run('plugins_loaded');
 }
开发者ID:cv0,项目名称:fansoro,代码行数:54,代码来源:Plugins.php

示例6: info

 /**
  * @return array
  */
 public function info()
 {
     if ($this->info) {
         return $this->info;
     }
     $file = $this->getFullPath();
     if (!$this->exists()) {
         return '';
     }
     list($width, $height) = getimagesize($file);
     $extension = \File::extension($file);
     $name = \File::name($file);
     $info = ['extension' => $extension, 'name' => $name, 'width' => $width, 'height' => $height];
     return $info;
 }
开发者ID:stcoder,项目名称:uf-vova,代码行数:18,代码来源:Image.php

示例7: admin_view

 public function admin_view($id = null)
 {
     $filename = WWW_ROOT . FilesController::FILE_ROOT . DS . implode(DS, $this->request->params['pass']) . "." . $this->request->params['ext'];
     debug($filename);
     $file = new File($filename, false);
     if (!$file->exists()) {
         throw new NotFoundException(__('File not found: ') . $file->path);
     }
     debug($file->name);
     debug($file->ext());
     debug($file->Folder()->path);
     $this->viewClass = 'Media';
     $params = array('id' => $file->name, 'name' => $file->name(), 'download' => false, 'extension' => $file->ext(), 'path' => $file->Folder()->path . DS);
     $this->set($params);
     //$this->set('fee', $this->Fee->read(null, $id));
 }
开发者ID:barkow,项目名称:ringelsoeckchen,代码行数:16,代码来源:FilesController.php

示例8: flipCss

 /**
  * Twig Markup Filter 'flipCss'
  * @param $paths
  * @param bool $force
  * @return array|string
  */
 public function flipCss($paths)
 {
     if (!LanguageDetector::isRtl()) {
         return $paths;
     }
     if (!is_array($paths)) {
         $paths = [$paths];
     }
     $rPaths = [];
     foreach ($paths as $path) {
         $assetPath = $path;
         if (File::exists(dirname($assetPath) . '/' . File::name($assetPath) . '.rtl.' . File::extension($assetPath))) {
             $newPath = dirname($assetPath) . '.rtl.' . File::extension($assetPath);
         } else {
             $newPath = CssFlipper::flipCss($assetPath, true);
         }
         $rPaths[] = $newPath;
     }
     return $rPaths;
 }
开发者ID:sajjad-ser,项目名称:oc-rtler,代码行数:26,代码来源:Rtler.php

示例9: beforeRender

 /**
  * beforeRender callback function
  *
  * @param Controller $controller
  * @return array contents for panel
  */
 public function beforeRender(Controller $controller)
 {
     $data = array();
     $dir = new Folder(LOGS);
     $files = $dir->find();
     foreach ($files as $log) {
         $file = new File(LOGS . $log);
         $name = $file->name();
         $data[$name] = array();
         if (!$file->readable()) {
             $data[$name]['content'] = __('This log file is unreadable.');
             continue;
         }
         $data[$name]['lastChange'] = date('Y-m-d H:i:s', $file->lastChange());
         if ($file->size() > $this->readBytes) {
             $file->offset(-$this->readBytes, SEEK_END);
         }
         $data[$name]['content'] = $file->read($this->readBytes);
     }
     return $data;
 }
开发者ID:ExpandOnline,项目名称:DebugPlus,代码行数:27,代码来源:LogfilePanel.php

示例10: ShortCode

 public static function ShortCode($arguments)
 {
     extract($arguments);
     // Obtain json file on public folder
     $id = $id ? $id : '';
     $json = '';
     $galleryFile = ROOT_DIR . '/public/gallery/gallery.json';
     if (File::exists($galleryFile)) {
         $json = json_decode(File::getContent($galleryFile), true);
     } else {
         die('OOps Whrere is media.json file!');
     }
     $num = 0;
     $photos = File::scan(ROOT_DIR . '/public/gallery/galleries/' . $id);
     $img = Url::getBase() . '/public/gallery/galleries/' . $id . '/' . File::name($photos[0]) . '.' . File::ext($photos[0]);
     // get plugin info
     //var_dump(json_encode(Config::get('plugins.gallery'),true));
     $template = Template::factory(PLUGINS_PATH . '/gallery/templates/');
     $template->setOptions(['strip' => false]);
     // show template
     return $template->fetch('slide.tpl', ['id' => $id, 'title' => $json[$id]['title'], 'description' => $json[$id]['desc'], 'first' => $img, 'photos' => $photos]);
 }
开发者ID:nakome,项目名称:Fansoro-gallery-plugin,代码行数:22,代码来源:gallery_functions.php

示例11: getFilename

 public function getFilename()
 {
     return $this->file->name();
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:4,代码来源:Paper.php

示例12: store

 /**
  * Stores the media to a file and assures that the output file has the correct extension
  *
  * @param string $file Absolute path to a file
  * @param boolean $overwrite Enable overwriting of an existent file
  * @return mixed
  */
 function store($file, $overwrite = false, $guessExtension = true)
 {
     $File = new File($file);
     if ($overwrite) {
         $File->delete();
     }
     if ($File->exists()) {
         $message = "Media::store - File `{$file}` already exists.";
         trigger_error($message, E_USER_NOTICE);
         return false;
     }
     if ($guessExtension) {
         $file = $File->Folder->pwd() . DS . $File->name();
         $correctExtension = MimeType::guessExtension($this->mimeType);
         if ($correctExtension) {
             $file .= '.' . $correctExtension;
         } elseif (isset($extension)) {
             $file .= '.' . $File->ext();
         }
     }
     if ($this->Adapters->dispatchMethod($this, 'store', array($file))) {
         return $file;
     }
     return false;
 }
开发者ID:redlion09,项目名称:ems-1,代码行数:32,代码来源:media.php

示例13: load

 /**
  * Load a article
  */
 public function load()
 {
     // Get filename from params
     if (isset($this->request->pass)) {
         if (isset($this->request->pass[0])) {
             $selectedFilename = base64_decode($this->request->pass[0]);
         }
     }
     // Get current filename from Sesssion
     if (empty($selectedFilename)) {
         $selectedFilename = $this->Session->read("selected");
     }
     // Get all files name
     $filenames = $this->noteDir->find('.*\\.html');
     // Get current file from articles directory
     if (!empty($selectedFilename)) {
         $tmp = $this->noteDir->find('.*^' . $selectedFilename . '\\.html');
         $fileSelected = $tmp[0];
     } else {
         //If none selected we take the first artcle as selected
         $fileSelected = $filenames[0];
     }
     // Warning case : file set in Session not found
     if (empty($fileSelected)) {
         echo json_encode(array('code' => 2, 'message' => 'Warning! Selected file from Session not found'));
         die;
     }
     $notes = array();
     // Get short file name
     foreach ($filenames as $filename) {
         $file = new File($this->noteDir->pwd() . DS . $filename);
         $notes[] = $file->name();
         $file->close();
     }
     // Get Content of selected file
     $file = new File($this->noteDir->pwd() . DS . $fileSelected);
     $selectedFileContent = $file->read();
     $file->close();
     // Return values
     echo json_encode(array("fileSelected" => $fileSelected, "noteSelected" => $file->name(), "selectedFileContent" => $selectedFileContent, "notes" => $notes));
     exit;
 }
开发者ID:ellioh-thoto,项目名称:memory,代码行数:45,代码来源:PagesController.php

示例14: array

                  <li><b>Filename: </b>' . File::name($path) . '</li>
                  <li><b>Extension: </b>' . File::ext($path) . '</li>
                  <li><b>Size: </b>' . $width . 'x' . $height . 'px</li>
                  <li class="code"><b>Markdown: </b><code>![text img](<a target="_blank" href="' . Panel::$site['url'] . '/public/uploads/' . $link . '">' . Panel::$site['url'] . '/public/uploads/' . $link . '</a>)</code></li>
                  <li class="code"><b>Html: </b><code>&lt;img src="<a target="_blank" href="' . Panel::$site['url'] . '/public/uploads/' . $link . '">' . Panel::$site['url'] . '/public/uploads/' . $link . '</a> /&gt;</code></li>
                  <li><a class="btn red" href="' . $p->url() . '/uploads">' . Panel::$lang['back_to_uploads'] . '</a></li>
                </ul>
              </div>
            </div>
          </div>';
        } else {
            // other template files
            $template = '
        <div class="box-1 col">
            <div class="media">
              <div class="info-media">
                <ul>
                  <li>' . Panel::$lang['no_preview_for_this_file'] . '</li>
                  <li><b>Filename: </b>' . File::name($path) . '</li>
                  <li><b>Extension: </b>' . File::ext($path) . '</li>
                  <li class="code"><b>Markdown: </b><code>[text link](<a target="_blank" href="' . Panel::$site['url'] . '/public/uploads/' . $link . '">' . Panel::$site['url'] . '/public/uploads/' . $link . '</a>)</code></li>
                  <li class="code"><b>Html: </b><code>&lt;a href="<a target="_blank" href="' . Panel::$site['url'] . '/public/uploads/' . $link . '">' . Panel::$site['url'] . '/public/uploads/' . $link . '</a>" download &gt;text link&lt;/a&gt;</code></li>
                  <li><a class="btn red" href="' . $p->url() . '/uploads">' . Panel::$lang['back_to_uploads'] . '</a></li>
                </ul>
              </div>
            </div>
          </div>';
        }
    }
    $p->view('actions', array('type' => 'Upload Preview', 'title' => Panel::$lang['Preview'], 'content' => $file, 'html' => $template));
});
开发者ID:xxwebplus,项目名称:morfy-admin-panel,代码行数:31,代码来源:preview.php

示例15: low

 function _makeFilePath(&$model, $field)
 {
     $config = $this->config[$model->alias][$field];
     $data = $this->_data[$model->alias][$field];
     $file = $config['dir'] . low($data['name']);
     $File = new File($this->fileRoot . $file);
     $file = str_replace($File->name() . '.', String::uuid() . '.', $file);
     if ($config['ext']) {
         $file = str_replace('.' . $File->ext(), '.' . $config['ext'], $file);
     }
     $file = strtr($file, DS, '/');
     return $file;
 }
开发者ID:slywalker,项目名称:image_kit,代码行数:13,代码来源:upload.php


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