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


PHP N2Filesystem::pathToAbsoluteURL方法代码示例

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


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

示例1: actionSaveImage

 public function actionSaveImage()
 {
     $this->validateToken();
     N2Loader::import('libraries.image.aviary');
     $image = N2Request::getVar('aviaryUrl');
     $this->validateVariable(!empty($image), 'image');
     require_once dirname(__FILE__) . '/Browse.php';
     $root = N2Filesystem::getImagesFolder();
     $folder = 'aviary';
     $path = N2Filesystem::realpath($root . '/' . $folder);
     if ($path === false || $path == '') {
         N2Filesystem::createFolder($root . '/' . $folder);
         $path = N2Filesystem::realpath($root . '/' . $folder);
     }
     $tmp = tempnam(sys_get_temp_dir(), 'image-');
     file_put_contents($tmp, file_get_contents($image));
     $src = null;
     // Set variables for storage
     // fix file filename for query strings
     preg_match('/([^\\?]+)\\.(jpe?g|gif|png)\\b/i', $image, $matches);
     $file_array['name'] = basename($matches[1]);
     $file_array['tmp_name'] = $tmp;
     $file_array['size'] = filesize($tmp);
     $file_array['error'] = 0;
     try {
         $fileName = preg_replace('/[^a-zA-Z0-9_-]/', '', $file_array['name']);
         $upload = new N2BulletProof();
         $file = $upload->uploadDir($path)->upload($file_array, $fileName);
         $src = N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($file));
     } catch (Exception $e) {
         N2Message::error($e->getMessage());
         $this->response->error();
     }
     if ($src) {
         $this->response->respond(array('image' => $src));
     } else {
         N2Message::error(sprintf(n2_('Unexpected error: %s'), $image));
         $this->response->error();
     }
 }
开发者ID:vicpril,项目名称:rep_bidqa,代码行数:40,代码来源:Aviary.php

示例2: getLogo

 public function getLogo()
 {
     return N2Filesystem::pathToAbsoluteURL($this->info->getAssetsPath() . "/admin/images/logo.png");
 }
开发者ID:MBerguer,项目名称:wp-demo,代码行数:4,代码来源:application.php

示例3: parseFile

 protected function parseFile($content, $originalFilePath)
 {
     $this->baseUrl = N2Filesystem::pathToAbsoluteURL(dirname($originalFilePath));
     return preg_replace_callback('#url\\([\'"]([^"\'\\)]+)[\'"]\\)#', array($this, 'makeUrl'), $content);
 }
开发者ID:rfulwell,项目名称:transitionalresources.org,代码行数:5,代码来源:cache.php

示例4: scaleImage

 public static function scaleImage($group, $imageUrl, $scale = 1, $resizeRemote = false)
 {
     $originalImageUrl = $imageUrl;
     $imageUrl = N2ImageHelper::fixed($imageUrl);
     if ($scale > 0 && function_exists('exif_imagetype') && function_exists('imagecreatefrompng')) {
         if (substr($imageUrl, 0, 2) == '//') {
             $imageUrl = parse_url(N2Uri::getBaseuri(), PHP_URL_SCHEME) . ':' . $imageUrl;
         }
         $imageUrl = N2Uri::relativetoabsolute($imageUrl);
         $imagePath = N2Filesystem::absoluteURLToPath($imageUrl);
         $cache = new self($group);
         if ($imagePath == $imageUrl) {
             // The image is not local
             if (!$resizeRemote) {
                 return $originalImageUrl;
             }
             $pathInfo = pathinfo(parse_url($imageUrl, PHP_URL_PATH));
             $extension = self::validateExtension($pathInfo['extension']);
             if (!$extension) {
                 return $originalImageUrl;
             }
             return N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($cache->makeCache($extension, array($cache, '_scaleRemoteImage'), array($extension, $imageUrl, $scale))));
         } else {
             $extension = false;
             $imageType = @exif_imagetype($imagePath);
             switch ($imageType) {
                 case IMAGETYPE_JPEG:
                     $extension = 'jpg';
                     break;
                 case IMAGETYPE_PNG:
                     $extension = 'png';
                     $fp = fopen($imagePath, 'r');
                     fseek($fp, 25);
                     $data = fgets($fp, 2);
                     fclose($fp);
                     if (ord($data) == 3) {
                         // GD cannot resize palette PNG so we return the original image
                         return $originalImageUrl;
                     }
                     break;
             }
             if (!$extension) {
                 throw new Exception('Filtype of the image is not supported: #' . $imageType . ' code  ' . $imagePath);
             }
             return N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($cache->makeCache($extension, array($cache, '_scaleImage'), array($extension, $imagePath, $scale, filemtime($imagePath)))));
         }
     }
 }
开发者ID:MBerguer,项目名称:wp-demo,代码行数:48,代码来源:image.php

示例5: actionUpload

 public function actionUpload()
 {
     if (defined('N2_IMAGE_UPLOAD_DISABLE')) {
         N2Message::error(n2_('You are not allowed to upload!'));
         $this->response->error();
     }
     $this->validateToken();
     $root = N2Filesystem::getImagesFolder();
     $folder = ltrim(rtrim(N2Request::getVar('path', ''), '/'), '/');
     $path = N2Filesystem::realpath($root . '/' . $folder);
     if ($path === false || $path == '') {
         $folder = preg_replace("/[^A-Za-z0-9]/", '', $folder);
         if (empty($folder)) {
             N2Message::error(n2_('Folder is missing!'));
             $this->response->error();
         } else {
             N2Filesystem::createFolder($root . '/' . $folder);
             $path = N2Filesystem::realpath($root . '/' . $folder);
         }
     }
     $relativePath = $this->relative($path, $root);
     if (!$relativePath) {
         $relativePath = '';
     }
     $response = array('path' => $relativePath);
     try {
         if (isset($_FILES) && isset($_FILES['image']) && isset($_FILES['image']['name'])) {
             $info = pathinfo($_FILES['image']['name']);
             $fileName = preg_replace('/[^a-zA-Z0-9_-]/', '', $info['filename']);
             if (strlen($fileName) == 0) {
                 $fileName = '';
             }
             $upload = new N2BulletProof();
             $file = $upload->uploadDir($path)->upload($_FILES['image'], $fileName);
             $response['name'] = basename($file);
             $response['url'] = N2ImageHelper::dynamic(N2Filesystem::pathToAbsoluteURL($file));
         }
     } catch (Exception $e) {
         N2Message::error($e->getMessage());
         $this->response->error();
     }
     $this->response->respond($response);
 }
开发者ID:RenatoToasa,项目名称:Pagina-Web,代码行数:43,代码来源:Browse.php


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