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


PHP Path::assemble方法代码示例

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


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

示例1: index

 public function index($file, $parameters = array())
 {
     $file = Path::assemble(BASE_PATH, $file);
     if (File::exists($file)) {
         $fileSize = File::getSize(BASE_PATH . $file);
         switch ($parameters) {
             case "file_ext":
                 return File::getExtension($file);
                 break;
             case "file_size":
                 return File::getSize(BASE_PATH . $file);
                 break;
             case "file_size_kilobytes":
                 return number_format($fileSize / 1024);
                 break;
             case "file_size_human":
                 return self::format_bytes_human($fileSize);
                 break;
             default:
                 return File::getExtension($file);
         }
     } else {
         Log::error("File does not exist or is not readable", "fileinfo_modifier", $file);
     }
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:25,代码来源:mod.fileinfo.php

示例2: makeFileSelect

 private function makeFileSelect($selected_file = null)
 {
     $html = "<span class='btn btn-file-browse'><span class='ss-icon'>openfolder</span></span>";
     $html .= "<p><select name='{$this->fieldname}' style='display:none'>";
     $html .= "<option value=''>Select a file...</option>";
     $path = Path::assemble(BASE_PATH, array_get($this->field_config, 'destination'));
     $finder = new Finder();
     // Set folder location
     $finder->in($path);
     // Limit by depth
     $finder->depth = array_get($this->field_config, 'depth', '<1');
     // Limit by file extension
     foreach (array_get($this->field_config, array('allowed', 'types'), array()) as $ext) {
         $finder->name("*.{$ext}");
     }
     // Fetch matches
     $matches = $finder->files()->followLinks();
     // Build HTML options
     foreach ($matches as $file) {
         $filename = Path::toAsset($file->getPathname(), false);
         $display_name = ltrim(str_replace($path, '', $file->getPathname()), '/');
         $selected = $selected_file === $filename ? 'selected' : '';
         $html .= "<option value='{$filename}' {$selected}>" . $display_name . "</option>";
     }
     $html .= '</select></p>';
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:27,代码来源:ft.file.php

示例3: render

 /**
  * render
  * Finds and chooses the correct template, then renders the page
  *
  * @param string $template Template (or array of templates, in order of preference) to render the page with
  * @return string
  */
 public function render($template)
 {
     $html = '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">No template found.</p>';
     $list = $template ? $list = array($template) : self::$_templates;
     $template_type = 'html';
     // Allow setting where to get the template from
     if (!self::$_template_location) {
         self::$_template_location = Path::assemble(BASE_PATH, Config::getTemplatesPath(), 'templates');
     }
     foreach ($list as $template) {
         $template_path = Path::assemble(self::$_template_location, $template);
         $override_path = Path::assemble(BASE_PATH, Config::getThemesPath(), Config::getTheme(), 'admin', $template);
         if (File::exists($template_path . '.html') || file_exists($template_path . '.php')) {
             // set debug information
             Debug::setValue('template', $template);
             Debug::setvalue('layout', str_replace('layouts/', '', self::$_layout));
             Debug::setValue('statamic_version', STATAMIC_VERSION);
             Debug::setValue('php_version', phpversion());
             Debug::setValue('theme', array_get($this->data, '_theme', null));
             Debug::setValue('environment', array_get($this->data, 'environment', '(none)'));
             $this->data['_debug'] = array('template' => Debug::getValue('template'), 'layout' => Debug::getValue('layout'), 'version' => Debug::getValue('statamic_version'), 'statamic_version' => Debug::getValue('statamic_version'), 'php_version' => Debug::getValue('php_version'), 'theme' => Debug::getValue('theme'), 'environment' => Debug::getValue('environment'));
             # standard lex-parsed template
             if (File::exists($template_path . '.html')) {
                 $template_type = 'html';
                 $this->appendNewData($this->data);
                 // Fetch template and parse any front matter
                 $template = Parse::frontMatter(File::get($template_path . '.html'));
                 self::$_extra_data = $template['data'] + self::$_extra_data;
                 $this->prependNewData(self::$_extra_data);
                 $html = Parse::template($template['content'], Statamic_View::$_dataStore, array($this, 'callback'));
                 break;
                 # lets forge into raw data
             } elseif (File::exists($override_path . '.php') || File::exists($template_path . '.php')) {
                 $template_type = 'php';
                 extract($this->data);
                 ob_start();
                 if (File::exists($override_path . '.php')) {
                     $template_path = $override_path;
                 }
                 require $template_path . ".php";
                 $html = ob_get_clean();
                 break;
             } else {
                 Log::error("Template does not exist: '{$template_path}'", 'core');
             }
         }
     }
     // mark milestone for debug panel
     Debug::markMilestone('template rendered');
     // get rendered HTML
     $rendered = $this->_render_layout($html, $template_type);
     // mark milestone for debug panel
     Debug::markMilestone('layout rendered');
     // store it into the HTML cache if needed
     if (Addon::getAPI('html_caching')->isEnabled()) {
         Addon::getAPI('html_caching')->putCachedPage($rendered);
     }
     // return rendered HTML
     return $rendered;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:67,代码来源:view.php

示例4: getServerFiles

	private function getServerFiles($config, $destination)
	{
		$path = Path::assemble(BASE_PATH, $destination);

		$finder = new Finder();

		// Set folder location
		$finder->in($path);

		// Limit by depth
		$finder->depth('<' . array_get($config, 'depth', '1'));

		// Limit by file extension
		foreach (array_get($config, array('allowed', 'types'), array()) as $ext) {
			$finder->name("/\.{$ext}/i");
		}

		// Fetch matches
		$matches = $finder->files()->followLinks();

		// Build array
		$files = array();
		foreach ($matches as $file) {
			$filename = Path::trimSubdirectory(Path::toAsset($file->getPathname(), false));
			$display_name = ltrim(str_replace($path, '', $file->getPathname()), '/');

			$value = (Config::get('prepend_site_root_to_uploads', false)) 
			         ? '{{ _site_root }}' . ltrim($filename, '/')
			         : $filename;

			$files[] = compact('value', 'display_name');
		}

		return $files;
	}
开发者ID:jalmelb,项目名称:24hl2015,代码行数:35,代码来源:tasks.file.php

示例5: __call

 public function __call($method, $arguments)
 {
     $extensions = array(".html", ".md", ".markdown", ".textile");
     $html = null;
     foreach ($extensions as $extension) {
         $full_src = Path::assemble(BASE_PATH, Config::getCurrentThemePath(), 'partials', ltrim($method . $extension, '/'));
         if (File::exists($full_src)) {
             // Merge additional variables passed as parameters
             Statamic_View::$_dataStore = $arguments + Statamic_View::$_dataStore;
             if ($this->fetchParam('use_context', false, false, true, false)) {
                 $html = Parse::contextualTemplate(File::get($full_src), Statamic_View::$_dataStore, $this->context, 'Statamic_View::callback');
             } else {
                 $html = Parse::template(File::get($full_src), Statamic_View::$_dataStore, 'Statamic_View::callback');
             }
             // parse contents if needed
             if ($extension == ".md" || $extension == ".markdown") {
                 $html = Parse::markdown($html);
             } elseif ($extension == ".textile") {
                 $html = Parse::textile($html);
             }
         }
     }
     if (Config::get('enable_smartypants', TRUE)) {
         $html = Parse::smartypants($html);
     }
     return $html;
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:27,代码来源:pi.partial.php

示例6: index

 public function index($value, $parameters = array())
 {
     $pi = pathinfo($value);
     if (Pattern::matches('resized$', $pi['dirname'])) {
         $dir = preg_replace('/resized$/', '', $pi['dirname']);
         $value = Path::assemble($dir, $pi['basename']);
     }
     return $value;
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:9,代码来源:mod.original.php

示例7: getTemplates

 /**
  * Returns a list of templates for this theme
  *
  * @param string  $theme  Optional theme to list from, otherwise, current theme
  * @return array
  */
 public static function getTemplates($theme = NULL)
 {
     $templates = array();
     $finder = new Finder();
     $files = $finder->files()->in(Path::assemble(BASE_PATH, Config::getThemesPath(), Config::getTheme(), 'templates'))->name('*.html')->followLinks();
     if (iterator_count($files) > 0) {
         foreach ($files as $file) {
             $templates[] = str_replace('.' . $file->getExtension(), '', $file->getRelativePathname());
         }
     }
     return $templates;
 }
开发者ID:Synergy23,项目名称:blackandwhite,代码行数:18,代码来源:theme.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: file__render_thumbnail

 public function file__render_thumbnail()
 {
     if (!($path = Request::get('path'))) {
         exit('No path specified');
     }
     $url = Path::toAsset($this->getTransformedImage($path));
     $url = Config::getSiteRoot() !== '/' ? str_replace(Config::getSiteRoot(), '', $url) : $url;
     $file = Path::assemble(BASE_PATH, $url);
     header('Content-type: image/jpeg');
     header('Content-length: ' . filesize($file));
     if ($file = fopen($file, 'rb')) {
         fpassthru($file);
     }
     exit;
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:15,代码来源:hooks.file.php

示例10: partial

 public function partial()
 {
     $start = time();
     $src = $this->fetchParam('src', null, null, false, false);
     $extensions = array(".html", ".md", ".markdown", ".textile");
     $html = null;
     // measurement
     $hash = Debug::markStart('partials', $src, $start);
     Debug::increment('partials', $src);
     if ($src) {
         foreach ($extensions as $extension) {
             $full_src = Path::assemble(BASE_PATH, $this->theme_root, 'partials', ltrim($src . $extension, '/'));
             if (File::exists($full_src)) {
                 Statamic_View::$_dataStore = $this->attributes + Statamic_View::$_dataStore;
                 if ($this->fetchParam('use_context', false, false, true, false)) {
                     // to use context, we only want to pass the attributes as
                     // the current data, as those will override into the context
                     // set of data; if we were to include all of ::$_dataStore,
                     // we run into the issue where all of the global-level variables
                     // are overriding variables in context, when the variables in
                     // context are more accurate scope-wise at this point in the parse
                     $html = Parse::contextualTemplate(file_get_contents($full_src), $this->attributes, $this->context, array('statamic_view', 'callback'), true);
                 } else {
                     $html = Parse::template(file_get_contents($full_src), Statamic_View::$_dataStore);
                 }
                 // parse contents if needed
                 if ($extension == ".md" || $extension == ".markdown") {
                     $html = Parse::markdown($html);
                 } elseif ($extension == ".textile") {
                     $html = Parse::textile($html);
                 }
             }
         }
         if (Config::get('enable_smartypants', TRUE)) {
             $html = Parse::smartypants($html);
         }
     }
     Debug::markEnd($hash);
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:40,代码来源:pi.theme.php

示例11: deleteFile

 public function deleteFile()
 {
     if (!Config::get('allow_file_field_deletions')) {
         return $this->abortDeletion('file_deleting_not_permitted');
     }
     if (!($path = Request::get('path'))) {
         return $this->abortDeletion('file_no_path');
     }
     if (!($destination = Request::get('config'))) {
         return $this->abortDeletion('file_no_config');
     }
     $destination = Path::addStartingSlash(Helper::decrypt(urldecode($destination)));
     if (!Pattern::startsWith($path, $destination) || strpos($path, '../')) {
         return $this->abortDeletion('error');
     }
     $full_path = Path::assemble(BASE_PATH, $path);
     if (!File::exists($full_path)) {
         return $this->abortDeletion('file_doesnt_exist');
     }
     File::delete($full_path);
     return array('success' => true, 'message' => Localization::fetch('file_deleted'));
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:22,代码来源:tasks.file.php

示例12: resolve

 /**
  * Finds a given path on the server, adding in any ordering elements missing
  *
  * @param string  $path  Path to resolve
  * @return string
  */
 public static function resolve($path)
 {
     $content_root = Config::getContentRoot();
     $content_type = Config::getContentType();
     if (strpos($path, "/") === 0) {
         $parts = explode("/", substr($path, 1));
     } else {
         $parts = explode("/", $path);
     }
     $fixedpath = "/";
     foreach ($parts as $part) {
         if (!File::exists(Path::assemble($content_root, $path . '.' . $content_type)) && !is_dir(Path::assemble($content_root, $part))) {
             // check folders
             $list = Statamic::get_content_tree($fixedpath, 1, 1, FALSE, TRUE, FALSE);
             foreach ($list as $item) {
                 $t = basename($item['slug']);
                 if (Slug::isNumeric($t)) {
                     $nl = strlen(Slug::getOrderNumber($t)) + 1;
                     if (strlen($part) >= strlen($item['slug']) - $nl && Pattern::endsWith($item['slug'], $part)) {
                         $part = $item['slug'];
                         break;
                     }
                 } else {
                     if (Pattern::endsWith($item['slug'], $part)) {
                         if (strlen($part) >= strlen($t)) {
                             $part = $item['slug'];
                             break;
                         }
                     }
                 }
             }
             // check files
             $list = Statamic::get_file_list($fixedpath);
             foreach ($list as $key => $item) {
                 if (Pattern::endsWith($key, $part)) {
                     $t = basename($item);
                     $offset = 0;
                     if (Pattern::startsWith($key, '__')) {
                         $offset = 2;
                     } elseif (Pattern::startsWith($key, '_')) {
                         $offset = 1;
                     }
                     if (Config::getEntryTimestamps() && Slug::isDateTime($t)) {
                         if (strlen($part) >= strlen($key) - 16 - $offset) {
                             $part = $key;
                             break;
                         }
                     } elseif (Slug::isDate($t)) {
                         if (strlen($part) >= strlen($key) - 12 - $offset) {
                             $part = $key;
                             break;
                         }
                     } elseif (Slug::isNumeric($t)) {
                         $nl = strlen(Slug::getOrderNumber($key)) + 1;
                         if (strlen($part) >= strlen($key) - $nl - $offset) {
                             $part = $key;
                             break;
                         }
                     } else {
                         $t = basename($item);
                         if (strlen($part) >= strlen($t) - $offset) {
                             $part = $key;
                             break;
                         }
                     }
                 }
             }
         }
         if ($fixedpath != '/') {
             $fixedpath .= '/';
         }
         $fixedpath .= $part;
     }
     return $fixedpath;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:81,代码来源:path.php

示例13: loadAllConfigs

 /**
  * Load the config (yaml) files in a specified order:
  *
  * 1. Loose per-site configs
  * 2. Routes
  * 3. Settings
  * 4. Theme overrides
  */
 public static function loadAllConfigs($admin = false)
 {
     $hash = Debug::markStart('config', 'finding');
     /*
     |--------------------------------------------------------------------------
     | YAML Mode
     |--------------------------------------------------------------------------
     |
     | We need to know the YAML mode first (loose, strict, transitional),
     | so we parse the settings file once to check before doing anything else.
     |
     */
     $preload_config = YAML::parse(Config::getConfigPath() . '/settings.yaml');
     $yaml_mode = array_get($preload_config, '_yaml_mode', 'loose');
     /*
     |--------------------------------------------------------------------------
     | Default Settings
     |--------------------------------------------------------------------------
     |
     | We keep a set of default options that the user config overrides, allowing
     | us to always have clean defaults.
     |
     */
     $settings_to_parse = File::get(Config::getAppConfigPath() . '/default.settings.yaml');
     /*
     |--------------------------------------------------------------------------
     | User Site Settings
     |--------------------------------------------------------------------------
     |
     | Next we parse and override the user's settings.
     |
     */
     $settings_to_parse .= "\n\n" . File::get(Config::getConfigPath() . '/settings.yaml');
     /*
     |--------------------------------------------------------------------------
     | Routes and vanity URLs
     |--------------------------------------------------------------------------
     |
     | Any URL can be manipulated by routes or vanity urls. We need this info
     | early on, before content parsing begins.
     |
     */
     $settings_to_parse .= "\n\n_routes:\n  " . trim(preg_replace("/\n/", "\n  ", File::get(Config::getConfigPath() . '/routes.yaml')));
     $settings_to_parse .= "\n\n_vanity_urls:\n  " . trim(preg_replace("/\n/", "\n  ", File::get(Config::getConfigPath() . '/vanity.yaml')));
     /*
     |--------------------------------------------------------------------------
     | Global Variables
     |--------------------------------------------------------------------------
     |
     | We parse all the yaml files in the root (except settings and routes) of
     | the config folder and make them available as global template variables.
     |
     */
     if (Folder::exists($config_files_location = Config::getConfigPath())) {
         $files = glob($config_files_location . '/*.yaml');
         if ($files) {
             foreach ($files as $file) {
                 if (strpos($file, 'routes.yaml') !== false || strpos($file, 'vanity.yaml') !== false || strpos($file, 'settings.yaml')) {
                     continue;
                 }
                 $settings_to_parse .= "\n\n" . File::get($file);
             }
         }
     }
     /*
     |--------------------------------------------------------------------------
     | Parse settings up until now
     |--------------------------------------------------------------------------
     |
     | Parses the concatenated settings string we've made so far.
     |
     */
     $config = YAML::parse($settings_to_parse, $yaml_mode);
     /*
     |--------------------------------------------------------------------------
     | Theme Variables
     |--------------------------------------------------------------------------
     |
     | Theme variables need to specifically parsed later so they can override
     | any site/global defaults.
     |
     */
     $themes_path = array_get($config, '_themes_path', '_themes');
     $theme_name = array_get($config, '_theme', 'acadia');
     // reset
     $settings_to_parse = '';
     if (Folder::exists($theme_files_location = Path::assemble(BASE_PATH, $themes_path, $theme_name))) {
         $theme_files = glob(Path::tidy($theme_files_location . '/*.yaml'));
         if ($theme_files) {
             foreach ($theme_files as $file) {
                 $settings_to_parse .= "\n\n" . File::get($file);
             }
//.........这里部分代码省略.........
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:101,代码来源:statamic.php

示例14: function

        Hook::run('control_panel', 'delete', null, $file);
        File::delete($file);
    }
    if ($count > 1) {
        $admin_app->flash('success', Localization::fetch('entries_deleted'));
    } else {
        $admin_app->flash('success', Localization::fetch('entry_deleted'));
    }
    $url = $admin_app->request()->getReferrer();
    $admin_app->redirect($url);
})->name('delete_entry')->via('GET', 'POST');
// GET: DELETE PAGE
$admin_app->get('/delete/page', function () use($admin_app) {
    authenticateForRole('admin');
    doStatamicVersionCheck($admin_app);
    $path = Path::assemble(BASE_PATH, Config::getContentRoot(), $admin_app->request()->get('path'));
    $type = $admin_app->request()->get('type');
    if ($type == "folder" && Folder::exists($path)) {
        Folder::delete($path);
        $admin_app->flash('success', Localization::fetch('page_deleted'));
    } else {
        if (!Pattern::endsWith($path, Config::getContentType())) {
            $path .= Config::getContentType();
        }
        if (File::exists($path)) {
            /*
            |--------------------------------------------------------------------------
            | Delete Hook
            |--------------------------------------------------------------------------
            |
            | Runs the delete hook, passing the file path
开发者ID:jalmelb,项目名称:24hl2015,代码行数:31,代码来源:routes.php

示例15: _render_layout

 /**
  * _render_layout
  * Renders the page
  *
  * @param string $_html HTML of the template to use
  * @param string $template_type Content type of the template
  * @return string
  */
 public function _render_layout($_html, $template_type = 'html')
 {
     if (self::$_layout != '') {
         $this->data['layout_content'] = $_html;
         $layout_path = Path::assemble(BASE_PATH, Config::getTemplatesPath(), self::$_layout);
         if ($template_type != 'html' or self::$_control_panel) {
             extract($this->data);
             ob_start();
             require $layout_path . ".php";
             $html = ob_get_clean();
         } else {
             if (!File::exists($layout_path . ".html")) {
                 Log::fatal("Can't find the specified theme.", 'core', 'template');
                 return '<p style="text-align:center; font-size:28px; font-style:italic; padding-top:50px;">We can\'t find your theme files. Please check your settings.';
             }
             $this->mergeNewData($this->data);
             $html = Parse::template(File::get($layout_path . ".html"), Statamic_View::$_dataStore, array($this, 'callback'));
             $html = Lex\Parser::injectNoparse($html);
         }
     } else {
         $html = $_html;
     }
     // post-render hook
     $html = \Hook::run('_render', 'after', 'replace', $html, $html);
     return $html;
 }
开发者ID:jeffreyDcreative,项目名称:gkp,代码行数:34,代码来源:view.php


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