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


PHP Path::tidy方法代码示例

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


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

示例1: index

 public function index($value, $parameters = array())
 {
     $full_url_start = Config::getSiteURL() . Config::getSiteRoot();
     return preg_replace_callback('/="(\\/[^"]+)"/ism', function ($item) use($full_url_start) {
         return '="' . Path::tidy($full_url_start . $item[1]) . '"';
     }, $value);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:7,代码来源:mod.full_urls.php

示例2: index

 public function index()
 {
     $from = $this->fetchParam('from', false);
     if (!$from) {
         return null;
     }
     // account for subfolder
     if (strpos($from, Config::getSiteRoot()) !== 0) {
         $from = Path::tidy(Config::getSiteRoot() . $from);
     }
     $from = Path::addStartingSlash($from);
     $content_set = ContentService::getContentByURL($from);
     // filter
     $content_set->filter(array('show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false))));
     // limit
     $limit = $this->fetchParam('limit', 1, 'is_numeric');
     $offset = $this->fetchParam('offset', 0, 'is_numeric');
     $content_set->limit($limit, $offset);
     // check for results
     if (!$content_set->count()) {
         return Parse::tagLoop($this->content, array(array('no_results' => true)));
     }
     // if content is used in this entries loop, parse it
     $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content);
     return Parse::tagLoop($this->content, $content_set->get($parse_content), false, $this->context);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:26,代码来源:pi.get_content.php

示例3: __construct

 /**
  * __construct
  * Constructor
  *
  * @
  */
 public function __construct($settings)
 {
     $this->settings = array_merge(array('extension' => 'log', 'path' => './_logs', 'file_prefix' => 'site'), $settings);
     $this->settings['path'] = rtrim($this->settings['path'], DIRECTORY_SEPARATOR);
     if (!in_array(substr($this->settings['path'], 0, 1), array("/", "."))) {
         $this->settings['path'] = Path::tidy(BASE_PATH . DIRECTORY_SEPARATOR . $this->settings['path']);
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:14,代码来源:logwriter.php

示例4: getURL

 /**
  * Returns the URL for a given $taxonomy and $taxonomy_slug
  *
  * @param string  $folder  Folder to use
  * @param string  $taxonomy  Taxonomy to use
  * @param string  $taxonomy_slug  Taxonomy slug to use
  * @return string
  */
 public static function getURL($folder, $taxonomy, $taxonomy_slug)
 {
     $url = Config::getSiteRoot() . '/' . $folder . '/' . $taxonomy . '/';
     $url .= Config::getTaxonomySlugify() ? Slug::make($taxonomy_slug) : $taxonomy_slug;
     // if taxonomies are not case-sensitive, make it lowercase
     if (!Config::getTaxonomyCaseSensitive()) {
         $url = strtolower($url);
     }
     return Path::tidy($url);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:18,代码来源:taxonomy.php

示例5: contextualize

 /**
  * Contextualizes taxonomy links for a given folder
  *
  * @param string  $folder  Folder to insert
  * @return void
  */
 public function contextualize($folder = NULL)
 {
     // this may be empty, if so, abort
     if (!$folder) {
         return;
     }
     // create the contextual URL root that we'll append the slug to
     $contextual_url_root = Config::getSiteRoot() . $folder . "/";
     // append the slug
     foreach ($this->data as $value => $parts) {
         $this->data[$value]['url'] = Path::tidy($contextual_url_root . $parts['slug']);
     }
 }
开发者ID:nob,项目名称:joi,代码行数:19,代码来源:taxonomyset.php

示例6: process

 public function process()
 {
     if ($this->field_data['tmp_name'] !== '') {
         $destination = BASE_PATH . '/' . $this->settings['destination'];
         $filename = File::cleanFilename($this->field_data['name']);
         if (File::upload($this->field_data['tmp_name'], $destination, $filename)) {
             return Path::tidy('/' . $this->settings['destination'] . '/' . $filename);
         } else {
             Log::fatal($this->field_data['tmp_name'] . ' could up not be uploaded to ' . $destination, 'core');
             return '';
         }
     }
 }
开发者ID:nob,项目名称:joi,代码行数:13,代码来源:ft.file.php

示例7: loadMembers

 /**
  * Loads the member cache into the local cache variable if not done yet
  * 
  * @return void
  */
 public static function loadMembers()
 {
     if (self::$members_loaded) {
         return;
     }
     // set that we've loaded things
     self::$members_loaded = true;
     self::$path = Config::getConfigPath() . '/users/%s.yaml';
     self::$members = unserialize(File::get(Path::tidy(BASE_PATH . "/_cache/_app/members/members.php")));
     // no members found, that's ok, load a blank array
     if (!is_array(self::$members)) {
         self::$members = array();
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:19,代码来源:memberservice.php

示例8: redactor__fetch_files

 public function redactor__fetch_files()
 {
     $this->authCheck();
     $dir = Path::tidy(ltrim(Request::get('path'), '/') . '/');
     $file_list = glob($dir . "*.*", GLOB_BRACE);
     $files = array();
     if (count($file_list) > 0) {
         foreach ($file_list as $file) {
             $pi = pathinfo($file);
             $files[] = array('link' => Path::toAsset($file), 'title' => $pi['filename'], 'name' => $pi['basename'], 'size' => File::getHumanSize(File::getSize(Path::assemble(BASE_PATH, $file))));
         }
     }
     echo json_encode($files);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:14,代码来源:hooks.redactor.php

示例9: control_panel__post_publish

 public function control_panel__post_publish($publish_data)
 {
     // check that caching is turned on
     if (!$this->core->isEnabled()) {
         return;
     }
     // we only need one key from the hook's value
     $file = $publish_data['file'];
     // update the cache
     _Cache::update();
     ContentService::loadCache(true);
     // grab data
     $triggers = $this->fetchConfig('publish_invalidation', array(), 'is_array', false, false);
     $content = Content::find(Path::tidy(str_replace(Config::getContentRoot(), '/', $file)));
     if ($triggers && $content) {
         foreach ($triggers as $trigger) {
             $folders = Parse::pipeList(array_get($trigger, 'folder', null));
             $key = array_get($trigger, 'key', null);
             if (!$folders || !$key) {
                 // not checking this
                 continue;
             }
             // check
             $invalidate = false;
             foreach ($folders as $folder) {
                 if ($folder === "*" || $folder === "/*") {
                     // include all
                     $invalidate = true;
                     break;
                 } elseif (substr($folder, -1) === "*") {
                     // wildcard check
                     if (strpos($content['_folder'], substr($folder, 0, -1)) === 0) {
                         $invalidate = true;
                         break;
                     }
                 } else {
                     // plain check
                     if ($folder == $content['_folder']) {
                         $invalidate = true;
                         break;
                     }
                 }
             }
             // invalidate if needed
             if ($invalidate) {
                 $this->core->deleteByKey(Parse::pipeList($key));
             }
         }
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:50,代码来源:hooks.cache.php

示例10: redactor__fetch_images

 public function redactor__fetch_images()
 {
     if (!Statamic_Auth::get_current_user()) {
         exit("Invalid Request");
     }
     $dir = Path::tidy(ltrim(Request::get('path'), '/') . '/');
     $image_list = glob($dir . "*.{jpg,jpeg,gif,png}", GLOB_BRACE);
     $images = array();
     if (count($image_list) > 0) {
         foreach ($image_list as $image) {
             $images[] = array('thumb' => Config::getSiteRoot() . $image, 'image' => Config::getSiteRoot() . $image);
         }
     }
     echo json_encode($images);
 }
开发者ID:nob,项目名称:joi,代码行数:15,代码来源:hooks.redactor.php

示例11: markitup__upload

 public function markitup__upload()
 {
     if (!Auth::getCurrentMember()) {
         exit("Invalid Request");
     }
     $path = Request::get('path');
     $is_image = Request::get('is_image');
     if (isset($path)) {
         // build directory
         $dir = Path::tidy(ltrim($path, '/') . '/');
         $file_type = strtolower($_FILES['file']['type']);
         $file_info = pathinfo($_FILES['file']['name']);
         // pull out the filename bits
         $filename = $file_info['filename'];
         $ext = $file_info['extension'];
         // build filename
         $file = $dir . $filename . '.' . $ext;
         // check for dupes
         if (File::exists($file)) {
             $file = BASE_PATH . '/' . $dir . $filename . '-' . date('YmdHis') . '.' . $ext;
         }
         if (!Folder::isWritable($dir)) {
             $this->log->error('Upload failed. Directory "' . $dir . '" is not writable.');
             die('Upload directory not writable');
         }
         if ($is_image && ($_FILES['file']['type'] == 'image/png' || $_FILES['file']['type'] == 'image/jpg' || $_FILES['file']['type'] == 'image/gif' || $_FILES['file']['type'] == 'image/jpeg')) {
             if (Request::get('resize', false)) {
                 $image = Image::make($_FILES['file']['tmp_name']);
                 $width = Request::get('width', null);
                 $height = Request::get('height', null);
                 $ratio = Request::get('ratio', true);
                 $upsize = Request::get('upsize', false);
                 $quality = Request::get('quality', '75');
                 $image->resize($width, $height, $ratio, $upsize)->save($file, $quality);
             } else {
                 move_uploaded_file($_FILES['file']['tmp_name'], $file);
             }
         } else {
             move_uploaded_file($_FILES['file']['tmp_name'], $file);
         }
         $return = array('filelink' => Path::toAsset($file));
         die(stripslashes(json_encode($return)));
     } else {
         die('Upload directory not set.');
     }
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:46,代码来源:hooks.markitup.php

示例12: render

 public function render()
 {
     $base_url = Config::getSiteRoot() . 'TRIGGER/markitup/upload';
     // build file url
     $file_path = Path::tidy(array_get($this->field_config, 'file_dir') . '/');
     $file_url = "{$base_url}?path={$file_path}";
     // build image url
     $image_path = Path::tidy(array_get($this->field_config, 'image_dir') . '/');
     $image_options = array('path' => $image_path, 'is_image' => true);
     $resize_options = array_get($this->field_config, 'resize', array());
     if (count($resize_options)) {
         $image_options['resize'] = true;
         $image_options += $resize_options;
     }
     $image_options_string = http_build_query($image_options);
     $image_url = "{$base_url}?{$image_options_string}";
     // build field
     $height = isset($this->field_config['height']) ? $this->field_config['height'] . 'px' : '300px';
     $html = "\n      <textarea\n        name='{$this->fieldname}'\n        style='height:{$height}'\n        tabindex='{$this->tabindex}'\n        class='input-textarea markitup'\n        data-image-url='{$image_url}'\n        data-file-url='{$file_url}'\n      >{$this->field_data}</textarea>";
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:21,代码来源:ft.markitup.php

示例13: password_form

 public function password_form()
 {
     // fetch parameters
     $return = $this->fetch('return', filter_input(INPUT_GET, 'return', FILTER_SANITIZE_STRING), null, false, false);
     $attr = $this->fetchParam('attr', false);
     // set up data to be parsed into content
     $data = array('error' => $this->flash->get('error', ''), 'field_name' => 'password');
     // determine form attributes
     $attr_string = '';
     if ($attr) {
         $attributes_array = Helper::explodeOptions($attr, true);
         foreach ($attributes_array as $key => $value) {
             $attr_string .= ' ' . $key . '="' . $value . '"';
         }
     }
     // build the form
     $html = '<form action="' . Path::tidy(Config::getSiteRoot() . '/TRIGGER/protect/password') . '" method="post"' . $attr_string . '>';
     $html .= '<input type="hidden" name="return" value="' . $return . '">';
     $html .= '<input type="hidden" name="token" value="' . $this->tokens->create() . '">';
     $html .= Parse::template($this->content, $data);
     $html .= '</form>';
     // return the HTML
     return $html;
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:24,代码来源:pi.protect.php

示例14: 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

示例15: getFolderData

 /**
  * Get folder data for a given path
  * 
  * @param string  $path  Path to retrieve data for
  * @return array
  */
 protected function getFolderData($path)
 {
     $local_path = str_replace(Path::tidy(BASE_PATH . '/' . Config::getContentRoot()), '', $path);
     $segments = explode('/', $local_path);
     $path = Path::tidy(BASE_PATH . '/' . Config::getContentRoot());
     $data = array();
     $content_type = Config::getContentType();
     foreach ($segments as $segment) {
         $path = Path::tidy($path . '/' . $segment);
         if (strpos($path, '.' . $content_type) !== false) {
             continue;
         }
         $data = $this->loadFolderData($path) + $data;
     }
     return $data;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:22,代码来源:contentset.php


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