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


PHP Path::fromAsset方法代码示例

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


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

示例1: download__download

 public function download__download()
 {
     $file = Request::get('file');
     $filename = Path::fromAsset($file);
     $as = Request::get('as', $file);
     $logged_in = filter_var(Request::get('logged_in', true), FILTER_VALIDATE_BOOLEAN);
     $override = Request::get('override');
     if (!$logged_in) {
         // first make sure there's an override in the config
         $override_config = $this->fetchConfig('override');
         if (!$override_config) {
             die('No override key configured');
         }
         // now see if there's an override param
         if (!$override) {
             die('No override param');
         }
         if ($override_config != $override) {
             die("Override key & param don't match");
         }
     } elseif (!Auth::isLoggedIn()) {
         // if the user has to be logged in, see if they are
         die('Must be logged in');
     }
     if (!$this->download($filename, $as)) {
         die('File doesn\'t exist');
     }
 }
开发者ID:edalzell,项目名称:Statamic-Download,代码行数:28,代码来源:hooks.download.php

示例2: render

 public function render()
 {
     // Let's make sure they set an upload destination
     if (array_get($this->field_config, 'destination', false) === false) {
         throw new Exception("You need to set a destination for your File field.");
     }
     if ($this->field_data) {
         $file = Path::toAsset($this->field_data);
         $html = "<div class='file-field-container file-exists'>";
         $html .= "<div>";
         if (File::isImage(Path::fromAsset($this->field_data, true))) {
             $html .= "<img src='{$file}' height='58'>";
         }
         $html .= "<p>" . basename($this->field_data) . "</p>";
         $html .= "<a class='btn btn-small btn-remove-file' href='#'>" . Localization::fetch('remove') . "</a>";
         $html .= "</div>";
         $html .= $this->makeFileSelect($file);
     } else {
         $html = "<div class='file-field-container'>";
         $html .= "<div class='upload-file'>";
         $html .= "<p><input type='file' name='{$this->fieldname}' tabindex='{$this->tabindex}' value='' /></p>";
         $html .= $this->makeFileSelect();
         $html .= "</div>";
     }
     $html .= "</div>";
     return $html;
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:27,代码来源:ft.file.php

示例3: render

 public function render()
 {
     $html = "<div class='file-field-container'>";
     if ($this->field_data) {
         $html .= "<div class='file-exists'>";
         if (File::isImage(Path::fromAsset($this->field_data, true))) {
             $html .= "<img src='" . Path::toAsset($this->field_data) . "' height='58'>";
         }
         $html .= "<p>" . basename($this->field_data) . "</p>";
         $html .= "<a class='btn btn-small btn-remove-file' href='#'>" . Localization::fetch('remove') . "</a>";
         $html .= "<input type='hidden' name='{$this->fieldname}' value='{$this->field_data}' />";
         $html .= "</div>";
     } else {
         $html .= "<div class='upload-file'>";
         $html .= "<p><input type='file' name='{$this->fieldname}' tabindex='{$this->tabindex}' value='' /></p>";
         $html .= "</div>";
     }
     $html .= "</div>";
     return $html;
 }
开发者ID:jeffreyDcreative,项目名称:gkp,代码行数:20,代码来源:ft.file.php

示例4: index

 public function index()
 {
     /*
     |--------------------------------------------------------------------------
     | Check for image
     |--------------------------------------------------------------------------
     |
     | Transform just needs the path to an image to get started. If it exists,
     | the fun begins.
     |
     */
     $image_src = $this->fetchParam('src', null, false, false, false);
     // Set full system path
     $image_path = Path::standardize(Path::fromAsset($image_src));
     // Check if image exists before doing anything.
     if (!File::isImage($image_path)) {
         Log::error("Could not find requested image to transform: " . $image_path, "core", "Transform");
         return;
     }
     /*
     |--------------------------------------------------------------------------
     | Resizing and cropping options
     |--------------------------------------------------------------------------
     |
     | The first transformations we want to run is for size to reduce the
     | memory usage for future effects.
     |
     */
     $width = $this->fetchParam('width', null, 'is_numeric');
     $height = $this->fetchParam('height', null, 'is_numeric');
     // resize specific
     $ratio = $this->fetchParam('ratio', true, false, true);
     $upsize = $this->fetchParam('upsize', true, false, true);
     // crop specific
     $pos_x = $this->fetchParam('pos_x', 0, 'is_numeric');
     $pos_y = $this->fetchParam('pos_y', 0, 'is_numeric');
     $quality = $this->fetchParam('quality', '75', 'is_numeric');
     /*
     |--------------------------------------------------------------------------
     | Action
     |--------------------------------------------------------------------------
     |
     | Available actions: resize, crop, and guess.
     |
     | "Guess" will find the best fitting aspect ratio of your given width and
     | height on the current image automatically, cut it out and resize it to
     | the given dimension.
     |
     */
     $action = $this->fetchParam('action', 'resize');
     /*
     |--------------------------------------------------------------------------
     | Extra bits
     |--------------------------------------------------------------------------
     |
     | Delicious and probably rarely used options.
     |
     */
     $angle = $this->fetchParam('rotate', false);
     $flip_side = $this->fetchParam('flip', false);
     $blur = $this->fetchParam('blur', false, 'is_numeric');
     $pixelate = $this->fetchParam('pixelate', false, 'is_numeric');
     $greyscale = $this->fetchParam(array('greyscale', 'grayscale'), false, false, true);
     /*
     |--------------------------------------------------------------------------
     | Assemble filename and check for duplicate
     |--------------------------------------------------------------------------
     |
     | We need to make sure we don't already have this image created, so we
     | defer any action until we've processed the parameters, which create
     | a unique filename.
     |
     */
     // Late modified time of original image
     $last_modified = File::getLastModified($image_path);
     // Find .jpg, .png, etc
     $extension = File::getExtension($image_path);
     // Filename with the extension removed so we can append our unique filename flags
     $stripped_image_path = str_replace('.' . $extension, '', $image_path);
     // The possible filename flags
     $parameter_flags = array('width' => $width, 'height' => $height, 'quality' => $quality, 'rotate' => $angle, 'flip' => $flip_side, 'pos_x' => $pos_x, 'pos_y' => $pos_y, 'blur' => $blur, 'pixelate' => $pixelate, 'greyscale' => $greyscale, 'modified' => $last_modified);
     // Start with a 1 character action flag
     $file_breadcrumbs = '-' . $action[0];
     foreach ($parameter_flags as $param => $value) {
         if ($value) {
             $flag = is_bool($value) ? '' : $value;
             // don't show boolean flags
             $file_breadcrumbs .= '-' . $param[0] . $flag;
         }
     }
     // Allow converting filetypes (jpg, png, gif)
     $extension = $this->fetchParam('type', $extension);
     // Allow saving in a different directory
     $destination = $this->fetchParam('destination', Config::get('transform_destination', false), false, false, false);
     if ($destination) {
         $destination = Path::tidy(BASE_PATH . '/' . $destination);
         // Method checks to see if folder exists before creating it
         Folder::make($destination);
         $stripped_image_path = Path::tidy($destination . '/' . basename($stripped_image_path));
     }
//.........这里部分代码省略.........
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:101,代码来源:pi.transform.php

示例5: index

 public function index()
 {
     /*
     |--------------------------------------------------------------------------
     | Paramers
     |--------------------------------------------------------------------------
     |
     | Match overrides Extension. Exclusion applies in both cases.
     |
     */
     $match = $this->fetchParam('match', false);
     $exclude = $this->fetchParam('exclude', false);
     $extension = $this->fetchParam(array('extension', 'type'), false);
     $in = $this->fetchParam(array('in', 'folder', 'from'), false);
     $not_in = $this->fetchParam('not_in', false);
     $file_size = $this->fetchParam('file_size', false);
     $file_date = $this->fetchParam('file_date', false);
     $depth = $this->fetchParam('depth', false);
     $sort_by = $this->fetchParam(array('sort_by', 'order_by'), false);
     $sort_dir = $this->fetchParam(array('sort_dir', 'sort_direction'), 'asc');
     $limit = $this->fetchParam('limit', false);
     if ($in) {
         $in = Helper::explodeOptions($in);
     }
     if ($not_in) {
         $not_in = Helper::explodeOptions($not_in);
     }
     if ($file_size) {
         $file_size = Helper::explodeOptions($file_size);
     }
     if ($extension) {
         $extension = Helper::explodeOptions($extension);
     }
     /*
     |--------------------------------------------------------------------------
     | Finder
     |--------------------------------------------------------------------------
     |
     | Get_Files implements most of the Symfony Finder component as a clean
     | tag wrapper mapped to matched filenames.
     |
     */
     $finder = new Finder();
     if ($in) {
         foreach ($in as $location) {
             $finder->in(Path::fromAsset($location));
         }
     }
     /*
     |--------------------------------------------------------------------------
     | Name
     |--------------------------------------------------------------------------
     |
     | Match is the "native" Finder name() method, which is supposed to
     | implement string, glob, and regex. The glob support is only partial,
     | so "extension" is a looped *single* glob rule iterator.
     |
     */
     if ($match) {
         $finder->name($match);
     } elseif ($extension) {
         foreach ($extension as $ext) {
             $finder->name("*.{$ext}");
         }
     }
     /*
     |--------------------------------------------------------------------------
     | Exclude
     |--------------------------------------------------------------------------
     |
     | Exclude directories from matching. Remapped to "not in" to allow more
     | intuitive differentiation between filename and directory matching.
     |
     */
     if ($not_in) {
         foreach ($not_in as $location) {
             $finder->exclude($location);
         }
     }
     /*
     |--------------------------------------------------------------------------
     | Not Name
     |--------------------------------------------------------------------------
     |
     | Exclude files matching a given pattern: string, regex, or glob.
     | By default we don't allow looking for PHP files. Be smart.
     |
     */
     if ($this->fetchParam('allow_php', false) !== TRUE) {
         $finder->notName("*.php");
     }
     if ($exclude) {
         $finder->notName($exclude);
     }
     /*
     |--------------------------------------------------------------------------
     | File Size
     |--------------------------------------------------------------------------
     |
     | Restrict files by size. Can be chained and allows comparison operators.
//.........这里部分代码省略.........
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:101,代码来源:pi.get_files.php


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