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


PHP SpoonFilter::isBetween方法代码示例

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


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

示例1: cache

 /**
  * Cache a certain block.
  *
  * @param	string $name				The name of the block that you want to cache.
  * @param	int[optional] $lifetime		The lifetime in seconds.
  */
 public function cache($name, $lifetime = 60)
 {
     // redefine lifetime
     $lifetime = SpoonFilter::isBetween(10, 30758400, $lifetime) ? (int) $lifetime : 60;
     // set lifetime
     $this->cache[(string) $name] = $lifetime;
 }
开发者ID:sunkangtaichi,项目名称:library,代码行数:13,代码来源:template.php

示例2: isBetween

 /**
  * Checks if the field is between a given minimum and maximum (includes min & max).
  *
  * @return	bool
  * @param	int $minimum				The minimum.
  * @param	int $maximum				The maximum.
  * @param	string[optional] $error		The error message to set.
  */
 public function isBetween($minimum, $maximum, $error = null)
 {
     // filled
     if ($this->isFilled()) {
         // post/get data
         $data = $this->getMethod(true);
         // validate
         if (!isset($data[$this->attributes['name']]) || !SpoonFilter::isBetween($minimum, $maximum, $data[$this->attributes['name']])) {
             if ($error !== null) {
                 $this->setError($error);
             }
             return false;
         }
         return true;
     }
     // not submitted
     if ($error !== null) {
         $this->setError($error);
     }
     return false;
 }
开发者ID:szLuis,项目名称:oac,代码行数:29,代码来源:text.php

示例3: testIsBetween

 public function testIsBetween()
 {
     $this->assertTrue(SpoonFilter::isBetween(1, 10, 5));
     $this->assertTrue(SpoonFilter::isBetween(1, 10, 1));
     $this->assertTrue(SpoonFilter::isBetween(1, 10, 10));
     $this->assertFalse(SpoonFilter::isBetween(1, 10, -1));
     $this->assertFalse(SpoonFilter::isBetween(1, 10, 0));
     $this->assertFalse(SpoonFilter::isBetween(1, 10, 12));
 }
开发者ID:jeroendesloovere,项目名称:library,代码行数:9,代码来源:SpoonFilterTest.php

示例4: parseToFile

 /**
  * Saves the image to a file (quality is only used for jpg images).
  *
  * @return	bool						True if the image was saved, false if not.
  * @param	string $filename			The path where the image should be saved.
  * @param	int[optional] $quality		The quality to use (only applies on jpg-images).
  * @param	int[optional] $chmod		Mode that should be applied on the file.
  */
 public function parseToFile($filename, $quality = 100, $chmod = 0666)
 {
     // redefine vars
     $filename = (string) $filename;
     $quality = (int) $quality;
     //
     if (@is_writable(dirname($filename)) !== true) {
         // does the folder exist? if not, try to create
         if (!SpoonDirectory::create(dirname($filename))) {
             if ($this->strict) {
                 throw new SpoonThumbnailException('The destination-path should be writable.');
             }
             return false;
         }
     }
     // get extension
     $extension = SpoonFile::getExtension($filename);
     // invalid quality
     if (!SpoonFilter::isBetween(1, 100, $quality)) {
         // strict?
         if ($this->strict) {
             throw new SpoonThumbnailException('The quality should be between 1 - 100');
         }
         return false;
     }
     // invalid extension
     if (SpoonFilter::getValue($extension, array('gif', 'jpeg', 'jpg', 'png'), '') == '') {
         if ($this->strict) {
             throw new SpoonThumbnailException('Only gif, jpeg, jpg or png are allowed types.');
         }
         return false;
     }
     // get current dimensions
     $imageProperties = @getimagesize($this->filename);
     // validate imageProperties
     if ($imageProperties === false) {
         // strict?
         if ($this->strict) {
             throw new SpoonThumbnailException('The sourcefile "' . $this->filename . '" could not be found.');
         }
         return false;
     }
     // set current dimensions
     $currentWidth = (int) $imageProperties[0];
     $currentHeight = (int) $imageProperties[1];
     $currentType = (int) $imageProperties[2];
     $currentMime = (string) $imageProperties['mime'];
     // file is the same?
     if ($currentType == IMAGETYPE_GIF && $extension == 'gif' || $currentType == IMAGETYPE_JPEG && in_array($extension, array('jpg', 'jpeg')) || $currentType == IMAGETYPE_PNG && $extension == 'png') {
         if ($currentWidth == $this->width && $currentHeight == $this->height) {
             return SpoonDirectory::copy($this->filename, $filename, true, true, $chmod);
         }
     }
     // resize image
     $this->resizeImage($currentWidth, $currentHeight, $currentType, $currentMime);
     // output to file
     switch (strtolower($extension)) {
         case 'gif':
             $return = @imagegif($this->image, $filename);
             break;
         case 'jpeg':
         case 'jpg':
             $return = @imagejpeg($this->image, $filename, $quality);
             break;
         case 'png':
             $return = @imagepng($this->image, $filename);
             break;
     }
     // chmod
     @chmod($filename, $chmod);
     // cleanup memory
     @imagedestroy($this->image);
     // return success
     return (bool) $return;
 }
开发者ID:sunkangtaichi,项目名称:library,代码行数:83,代码来源:thumbnail.php


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