當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。