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


PHP Path::trimFilesystem方法代码示例

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


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

示例1: update

 /**
  * Updates the internal content cache
  *
  * @return boolean
  */
 public static function update()
 {
     // track if any files have changed
     $files_changed = false;
     // grab length of content type extension
     $content_type = Config::getContentType();
     $full_content_root = rtrim(Path::tidy(BASE_PATH . "/" . Config::getContentRoot()), "/");
     $content_type_length = strlen($content_type) + 1;
     // the cache file we'll use
     $cache_file = BASE_PATH . "/_cache/_app/content/content.php";
     $time_file = BASE_PATH . "/_cache/_app/content/last.php";
     $now = time();
     // grab the existing cache
     $cache = unserialize(File::get($cache_file));
     if (!is_array($cache)) {
         $cache = array("urls" => array(), "content" => array(), "taxonomies" => array());
     }
     $last = File::get($time_file);
     // grab a list of all files
     $finder = new Finder();
     $files = $finder->files()->name("*." . Config::getContentType())->in(Config::getContentRoot());
     // grab a separate list of files that have changed since last check
     $updated_files = clone $files;
     $updated = array();
     if ($last) {
         $updated_files->date(">= " . Date::format("Y-m-d H:i:s", $last));
         foreach ($updated_files as $file) {
             // we don't want directories, they may show up as being modified
             // if a file inside them has changed or been renamed
             if (is_dir($file)) {
                 continue;
             }
             // this isn't a directory, add it to the list
             $updated[] = Path::trimFilesystem(Path::standardize($file->getRealPath()));
         }
     }
     // loop over current files
     $current_files = array();
     foreach ($files as $file) {
         $current_files[] = Path::trimFilesystem(Path::standardize($file->getRealPath()));
     }
     // get a diff of files we know about and files currently existing
     $new_files = array_diff($current_files, $cache['urls']);
     // create a master list of files that need updating
     $changed_files = array_unique(array_merge($new_files, $updated));
     // add to the cache if files have been updated
     if (count($changed_files)) {
         $files_changed = true;
         // build content cache
         foreach ($changed_files as $file) {
             $file = $full_content_root . $file;
             $local_path = Path::trimFilesystem($file);
             $local_filename = Path::clean($local_path);
             // file parsing
             $content = substr(File::get($file), 3);
             $divide = strpos($content, "\n---");
             $front_matter = trim(substr($content, 0, $divide));
             // parse data
             $data = YAML::parse($front_matter);
             // set additional information
             $data['_file'] = $file;
             $data['_local_path'] = $local_path;
             $data['_order_key'] = null;
             $data['datetimestamp'] = null;
             // legacy
             $data['datestamp'] = null;
             $data['date'] = null;
             $data['time'] = null;
             $data['numeric'] = null;
             $data['last_modified'] = filemtime($file);
             $data['_is_hidden'] = false;
             $data['_is_draft'] = false;
             // folder
             $data['_folder'] = preg_replace(Pattern::ORDER_KEY, "", str_replace($full_content_root, "", $data['_file']));
             $slash = strrpos($data['_folder'], "/");
             $data['_folder'] = $slash === 0 ? "" : substr($data['_folder'], 1, $slash - 1);
             // fix hidden/draft files
             $slug = basename($file, "." . $content_type);
             if (substr($slug, 0, 2) === "__") {
                 $data['_is_hidden'] = true;
                 $data['slug'] = substr($slug, 2);
             } elseif (substr($slug, 0, 1) === "_") {
                 $data['_is_draft'] = true;
                 $data['slug'] = substr($slug, 1);
             } else {
                 $data['slug'] = $slug;
             }
             $data['_basename'] = $data['slug'] . "." . $content_type;
             $data['_filename'] = $data['slug'];
             $data['_is_entry'] = preg_match(Pattern::ENTRY_FILEPATH, $data['_basename']);
             $data['_is_page'] = preg_match(Pattern::PAGE_FILEPATH, $data['_basename']);
             // 404 is special
             if ($data['_local_path'] === "/404.{$content_type}") {
                 $local_filename = $local_path;
                 // order key
//.........这里部分代码省略.........
开发者ID:nob,项目名称:joi,代码行数:101,代码来源:cache.php

示例2: toAsset

 /**
  * Creates a URL-friendly path from webroot
  *
  * @param string  $path  Path to trim
  * @return string
  */
 public static function toAsset($path, $as_variable = false)
 {
     $asset_path = Path::trimFilesystem($path);
     if (Pattern::startsWith($asset_path, '{{ _site_root }}')) {
         $asset_path = str_replace('{{ _site_root }}', '/', $asset_path);
     }
     if (!Pattern::startsWith($asset_path, Config::getSiteRoot())) {
         $asset_path = $as_variable ? '{{ _site_root }}' . $asset_path : Config::getSiteRoot() . '/' . $asset_path;
     }
     return rtrim(self::tidy($asset_path), '/');
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:17,代码来源:path.php

示例3: download

 /**
  * Creates and downloads a zip file of the static pages
  * 
  * @return void
  */
 public function download()
 {
     $path = Path::assemble(BASE_PATH, $this->config['destination']);
     $zip_name = 'site-' . time() . '.zip';
     $zip_filename = Path::assemble(BASE_PATH, '_cache/_add-ons/', $this->addon_name, $zip_name);
     $zip = new ZipArchive();
     $zip->open($zip_filename, ZipArchive::CREATE);
     $ignore = array('.', '..', '.DS_Store');
     foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)) as $file) {
         // Ignore ignored files
         if (in_array(substr($file, strrpos($file, '/') + 1), $ignore)) {
             continue;
         }
         $filename = trim(Path::trimFilesystem($file), '_');
         $zip->addFile($file->getPathname(), $filename);
     }
     $zip->close();
     header('Content-Type: application/zip');
     header('Content-disposition: attachment; filename=' . $zip_name);
     header('Content-Length: ' . filesize($zip_filename));
     readfile($zip_filename);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:27,代码来源:core.generator.php


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