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


PHP Library::safeFilename方法代码示例

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


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

示例1: testSafeFilename

 public function testSafeFilename()
 {
     $abs = '/etc/passwd';
     $this->assertEquals('etc/passwd', Library::safeFilename($abs));
     // Test urlparams get encoded
     $urlparams = '%2F..%2F..%2Fsecretfile.txt';
     $this->assertEquals('%252F..%252F..%252Fsecretfile.txt', Library::safeFilename($urlparams));
 }
开发者ID:johndotcat,项目名称:bolt,代码行数:8,代码来源:BoltLibraryTest.php

示例2: image

 /**
  * Helper function to make a path to an image.
  *
  * @param string         $filename Target filename
  * @param string|integer $width    Target width
  * @param string|integer $height   Target height
  * @param string         $crop     String identifier for cropped images
  *
  * @return string Image path
  */
 public function image($filename, $width = '', $height = '', $crop = '')
 {
     if ($width != '' || $height != '') {
         // You don't want the image, you just want a thumbnail.
         return $this->thumbnail($filename, $width, $height, $crop);
     }
     // After v1.5.1 we store image data as an array
     if (is_array($filename)) {
         $filename = isset($filename['filename']) ? $filename['filename'] : $filename['file'];
     }
     $image = sprintf('%sfiles/%s', $this->app['paths']['root'], Lib::safeFilename($filename));
     return $image;
 }
开发者ID:aaleksu,项目名称:bolt_cm,代码行数:23,代码来源:ImageHandler.php

示例3: image

 /**
  * Helper function to make a path to an image.
  *
  * @param string         $filename Target filename
  * @param string|integer $width    Target width
  * @param string|integer $height   Target height
  * @param string         $crop     String identifier for cropped images
  *
  * @return string Image path
  */
 public function image($filename, $width = null, $height = null, $crop = null)
 {
     if ($width || $height) {
         // You don't want the image, you just want a thumbnail.
         return $this->thumbnail($filename, $width, $height, $crop);
     }
     // After v1.5.1 we store image data as an array
     if (is_array($filename)) {
         $filename = isset($filename['filename']) ? $filename['filename'] : $filename['file'];
     }
     $image = sprintf('%s%s', $this->app['resources']->getUrl('files'), Lib::safeFilename($filename));
     return $image;
 }
开发者ID:draconusdesigns,项目名称:bolt,代码行数:23,代码来源:ImageHandler.php

示例4: getLocalUrl

 public function getLocalUrl($path)
 {
     $prefix = $this->app['resources']->getUrl($this->namespace);
     return $prefix . Lib::safeFilename($path);
 }
开发者ID:draconusdesigns,项目名称:bolt,代码行数:5,代码来源:PublicUrl.php

示例5: htmlRespImg

 public function htmlRespImg($html, $name, array $options = array())
 {
     $dom = $this->createDOMDocument($html);
     $elements = $dom->getElementsByTagName('img');
     if (count($elements) === 0) {
         return $html;
     }
     // Get Extension boltresponsiveimages
     $extensionName = 'boltresponsiveimages';
     if (!$this->app['extensions']->isEnabled($extensionName)) {
         return $html;
     }
     $extension = $this->app['extensions.' . $extensionName];
     if ($extension == null) {
         return $html;
     }
     // Get Twig Function respImg
     $twigFunction = $this->twig->getFunction('respImg');
     if (!$twigFunction) {
         return $html;
     }
     $respImg = $twigFunction->getCallable();
     // Not override sizes, if defined
     if (!$options['sizes']) {
         $options['sizes'] = $extension->getSizesAttrib($name);
     }
     foreach ($elements as $element) {
         if (!$element->hasAttribute('src')) {
             continue;
         }
         $file = $element->getAttribute('src');
         $filename = Lib::safeFilename($file);
         // Set options for specific image
         $optionsImg = $options;
         // Add width fallback to sizes because layout reasons
         // Example: An editor choose a specific width
         if ($element->hasAttribute('width')) {
             $width = $element->getAttribute('width');
             $optionsImg['sizes'][] = $width . 'px';
         }
         if ($element->hasAttribute('class')) {
             $attrClass = $element->getAttribute('class');
             $optionsImg['class'][] = $attrClass;
         }
         $htmlImg = (string) $respImg($filename, $name, $optionsImg);
         $domImg = $this->createDOMDocument($htmlImg);
         // Load the $domImg document fragment node into the current document
         $newnode = $dom->importNode($domImg->documentElement, true);
         // Replace current img node
         $element->parentNode->replaceChild($newnode, $element);
     }
     $result = $dom->saveHTML();
     return new \Twig_Markup($result, 'UTF-8');
 }
开发者ID:nikgo,项目名称:bolt-extension-nikgo-extra,代码行数:54,代码来源:HtmlTools.php


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