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


PHP Path::toAsset方法代码示例

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


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

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

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

 public function index($value, $parameters = array())
 {
     $dimensions_str = '';
     if (!empty($parameters)) {
         $dimensions = explode(',', $parameters[0]);
         $width = $dimensions[0];
         $dimensions_str .= " width=\"{$width}\"";
         if (isset($dimensions[1])) {
             $height = $dimensions[1];
             $dimensions_str .= " height=\"{$height}\"";
         }
     }
     return '<img src="' . Path::toAsset($value) . '"' . $dimensions_str . ' />';
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:14,代码来源:mod.img.php

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

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

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

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

示例8: upload

 /**
  * Upload a file.
  *
  * @param string  $file  Name of file
  * @param string  $target  target of file
  * @param string  $filename  Name of new file
  * @return bool
  **/
 public static function upload($file, $destination, $add_root_variable = false, $renamed_file = false)
 {
     Folder::make($destination);
     $info = pathinfo($file['name']);
     $extension = $info['extension'];
     $filename = $renamed_file ?: $info['filename'];
     // build filename
     $new_filename = Path::assemble(BASE_PATH, $destination, $filename . '.' . $extension);
     // check for dupes
     if (File::exists($new_filename)) {
         $new_filename = Path::assemble(BASE_PATH, $destination, $filename . '-' . date('YmdHis') . '.' . $extension);
     }
     // Check if destination is writable
     if (!Folder::isWritable($destination)) {
         Log::error('Upload failed. Directory "' . $destination . '" is not writable.', 'core');
         return null;
     }
     // write file
     move_uploaded_file($file['tmp_name'], $new_filename);
     return Path::toAsset($new_filename, $add_root_variable);
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:29,代码来源:file.php

示例9: index


//.........这里部分代码省略.........
     |
     */
     // 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));
     }
     // Reassembled filename with all flags filtered and delimited
     $new_image_path = $stripped_image_path . $file_breadcrumbs . '.' . $extension;
     // Check if we've already built this image before
     if (File::exists($new_image_path)) {
         return Path::toAsset($new_image_path);
     }
     /*
     |--------------------------------------------------------------------------
     | Create Image
     |--------------------------------------------------------------------------
     |
     | Transform just needs the path to an image to get started. The image is
     | created in memory so we can start manipulating it.
     |
     */
     $image = Image::make($image_path);
     /*
     |--------------------------------------------------------------------------
     | Perform Actions
     |--------------------------------------------------------------------------
     |
     | This is fresh transformation. Time to work the magic!
     |
     */
     if ($action === 'resize' && ($width || $height)) {
         $image->resize($width, $height, $ratio, $upsize);
     }
     if ($action === 'crop' && $width && $height) {
         $image->crop($width, $height, $pos_x, $pos_y);
     }
     if ($action === 'smart') {
         $image->grab($width, $height);
     }
     $resize = $this->fetchParam('resize', null);
     if ($resize) {
         $resize_options = Helper::explodeOptions($resize, true);
         $image->resize(array_get($resize_options, 'width'), array_get($resize_options, 'height'), array_get($resize_options, 'ratio', true), array_get($resize_options, 'upsize', true));
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:67,代码来源:pi.transform.php

示例10: uploadBatch

    /**
     * Upload file(s)
     * 
     * @param  string $destination  Where the file is going
     * @param  string $id           The field took look at in the files array
     * @return array
     */
    public static function uploadBatch($destination = null, $id = null)
    {
        $destination = $destination ?: Request::get('destination');
        $id          = $id ?: Request::get('id');
        $files       = self::standardizeFileUploads($_FILES);
        $results     = array();
  
        // Resizing configuration
        if ($resize = Request::get('resize')) {
            $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'); 
        }
  
        // If $files[$id][0] exists, it means there's an array of images.
        // If there's not, there's just one. We want to change this to an array.
        if ( ! isset($files[$id][0])) {
            $tmp = $files[$id];
            unset($files[$id]);
            $files[$id][] = $tmp;
        }
  
        // Process each image
        foreach ($files[$id] as $file) {
  
            // Image data
            $path = File::upload($file, $destination);
            $name = basename($path);
    
            // Resize
            if ($resize) {
                $image = \Intervention\Image\Image::make(Path::assemble(BASE_PATH, $path));
                $resize_folder = Path::assemble($image->dirname, 'resized');
                if ( ! Folder::exists($resize_folder)) {
                    Folder::make($resize_folder);
                }
                $resize_path = Path::assemble($resize_folder, $image->basename);
                $path = Path::toAsset($resize_path);
                $name = basename($path);
                $image->resize($width, $height, $ratio, $upsize)->save($resize_path, $quality);
            }
  
            $results[] = compact('path', 'name');
        }

        return $results;
    }
开发者ID:jalmelb,项目名称:24hl2015,代码行数:56,代码来源:_upload.php

示例11: getVariable

 /**
  * Takes a dot-notated key and finds the value for it in the given
  * array or object.
  *
  * @param  string       $key     Dot-notated key to find
  * @param  array|object $data    Array or object to search
  * @param  mixed        $default Default value to use if not found
  * @return mixed
  */
 protected function getVariable($key, $data, $default = null)
 {
     $modifiers = null;
     if (strpos($key, "|") === false) {
     } else {
         $parts = explode("|", $key);
         $key = $parts[0];
         $modifiers = array_splice($parts, 1);
     }
     if (strpos($key, $this->scopeGlue) === false) {
         $parts = explode('.', $key);
     } else {
         $parts = explode($this->scopeGlue, $key);
     }
     foreach ($parts as $key_part) {
         if (is_array($data)) {
             if (!array_key_exists($key_part, $data)) {
                 return $default;
             }
             $data = $data[$key_part];
         } elseif (is_object($data)) {
             if (!isset($data->{$key_part})) {
                 return $default;
             }
             $data = $data->{$key_part};
         } else {
             return $default;
         }
     }
     if ($modifiers) {
         foreach ($modifiers as $mod) {
             if (strpos($mod, ":") === false) {
                 $modifier_name = $mod;
                 $modifier_params = array();
             } else {
                 $parts = explode(":", $mod);
                 $modifier_name = $parts[0];
                 $modifier_params = array_splice($parts, 1);
             }
             if ($modifier_name == 'trim') {
                 $data = trim($data);
             } elseif ($modifier_name == 'img') {
                 $data = '<img src="' . \Path::toAsset($data) . '" />';
             } elseif ($modifier_name == 'link') {
                 if (filter_var($data, FILTER_VALIDATE_EMAIL)) {
                     // email address
                     $data = '<a href="mailto:' . $data . '" />' . $data . '</a>';
                 } else {
                     $data = '<a href="' . $data . '" />' . $data . '</a>';
                 }
             } elseif ($modifier_name == 'upper') {
                 $data = strtoupper($data);
             } else {
                 if ($modifier_name == 'lower') {
                     $data = strtolower($data);
                 } else {
                     if ($modifier_name == 'slugify') {
                         $data = \Slug::make($data);
                     } else {
                         if ($modifier_name == 'deslugify') {
                             $data = trim(preg_replace('~[-_]~', ' ', $data), " ");
                         } else {
                             if ($modifier_name == 'title') {
                                 $data = ucwords($data);
                             } else {
                                 if ($modifier_name == 'format') {
                                     $data = date($modifier_params[0], $data);
                                 } else {
                                     if ($modifier_name == 'format_number') {
                                         $decimals = isset($modifier_params[0]) ? $modifier_params[0] : 0;
                                         $data = number_format($data, $decimals);
                                     } else {
                                         if ($modifier_name == 'in_future') {
                                             $data = \Date::resolve($data) > time() ? "true" : "";
                                         } else {
                                             if ($modifier_name == 'in_past') {
                                                 $data = \Date::resolve($data) < time() ? "true" : "";
                                             } else {
                                                 if ($modifier_name == 'markdown') {
                                                     $data = Markdown($data);
                                                 } else {
                                                     if ($modifier_name == 'textile') {
                                                         $textile = new \Textile();
                                                         $data = $textile->TextileThis($data);
                                                     } else {
                                                         if ($modifier_name == 'length') {
                                                             if (is_array($data)) {
                                                                 $data = count($data);
                                                             } else {
                                                                 $data = strlen($data);
                                                             }
//.........这里部分代码省略.........
开发者ID:nob,项目名称:joi,代码行数:101,代码来源:Parser.php

示例12: index


//.........这里部分代码省略.........
     /*
     |--------------------------------------------------------------------------
     | File Size
     |--------------------------------------------------------------------------
     |
     | Restrict files by size. Can be chained and allows comparison operators.
     |
     */
     if ($file_size) {
         foreach ($file_size as $size) {
             $finder->size($size);
         }
     }
     /*
     |--------------------------------------------------------------------------
     | File Date
     |--------------------------------------------------------------------------
     |
     | Restrict files by last modified date. Can use comparison operators, and
     | since/after is aliased to >, and until/before to <.
     |
     */
     if ($file_date) {
         $finder->date($file_date);
     }
     /*
     |--------------------------------------------------------------------------
     | Depth
     |--------------------------------------------------------------------------
     |
     | Recursively traverse directories, starting at 0.
     |
     */
     if ($depth) {
         $finder->depth($depth);
     }
     /*
     |--------------------------------------------------------------------------
     | Sort By
     |--------------------------------------------------------------------------
     |
     | Sort by name, file, or type
     |
     */
     if ($sort_by) {
         if ($sort_by === 'file' || $sort_by === 'name') {
             $finder->sortByName();
         } elseif ($sort_by === 'type') {
             $finder->sortByType();
         }
     }
     /*
     |--------------------------------------------------------------------------
     | Assemble File Array
     |--------------------------------------------------------------------------
     |
     | Select the important bits of data on the list of files.
     |
     */
     $matches = $finder->files()->followLinks();
     $files = array();
     foreach ($matches as $file) {
         $files[] = array('extension' => $file->getExtension(), 'filename' => $file->getFilename(), 'file' => Path::toAsset($file->getPathname()), 'name' => Path::toAsset($file->getPathname()), 'size' => File::getHumanSize($file->getSize()), 'size_bytes' => $file->getSize(), 'size_kilobytes' => number_format($file->getSize() / 1024, 2), 'size_megabytes' => number_format($file->getSize() / 1048576, 2), 'size_gigabytes' => number_format($file->getSize() / 1073741824, 2), 'is_image' => File::isImage($file->getPathname()));
     }
     /*
     |--------------------------------------------------------------------------
     | Sort Direction
     |--------------------------------------------------------------------------
     |
     | Set the sort direction, defaulting to "asc" (ascending)
     |
     */
     if ($sort_dir === 'desc') {
         $files = array_reverse($files);
     }
     /*
     |--------------------------------------------------------------------------
     | Randomizing
     |--------------------------------------------------------------------------
     |
     | You can't sort randomly using Symfony finder, so we'll do it manually.
     |
     */
     if ($sort_by === 'random') {
         shuffle($files);
     }
     /*
     |--------------------------------------------------------------------------
     | Limit Files
     |--------------------------------------------------------------------------
     |
     | Limit the number of files returned. Needs to be run after sort_dir to 
     | ensure consistency.
     |
     */
     if ($limit) {
         $files = array_slice($files, 0, $limit);
     }
     return Parse::tagLoop($this->content, $files, true, $this->context);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:101,代码来源:pi.get_files.php

示例13: index

 public function index()
 {
     $src = $this->fetchParam('src', '', NULL, FALSE, FALSE);
     return Path::toAsset($src);
 }
开发者ID:andorpandor,项目名称:git-deploy.eu2.frbit.com-yr-prototype,代码行数:5,代码来源:pi.path.php

示例14: index

 public function index($value, $parameters = array())
 {
     return '<img src="' . Path::toAsset($value) . '">';
 }
开发者ID:zane-insight,项目名称:WhiteLaceInn,代码行数:4,代码来源:mod.img.php


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