Ejemplo n.º 1
0
 public function naturalNumber($name, $value)
 {
     if ($value !== null && !is_natural_number($value)) {
         //return $this->getDisplayName($name) . "は自然数で入力してください";
         return $this->getDisplayName($name) . "は整数で入力してください";
     }
 }
Ejemplo n.º 2
0
function range_string_to_array($range_string)
{
    $result = array();
    if (is_cs_natural_numbers($range_string)) {
        $parts = explode(',', $range_string);
        foreach ($parts as $part) {
            if (is_natural_number_range(trim($part))) {
                $range = explode('..', $part);
                if ($range[0] < $range[1]) {
                    for ($i = trim($range[0]); $i <= trim($range[1]); ++$i) {
                        $result[] = $i;
                    }
                }
            } elseif (is_natural_number(trim($part))) {
                $result[] = trim($part);
            }
        }
        sort($result, SORT_NUMERIC);
        $result = array_unique($result, SORT_NUMERIC);
    }
    return $result;
}
Ejemplo n.º 3
0
 /**
  * @param int $length
  *
  * @return self
  */
 public function setSummaryLength($length)
 {
     if (is_natural_number($length)) {
         $this->summaryLength = $length;
     } else {
         $message = __METHOD__ . "() argument must be an integer.";
         throw new Sabel_Exception_Runtime($message);
     }
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * @param string $fileName
  * @param int    $size
  *
  * @return void
  */
 public function thumbnail($fileName, $size)
 {
     if (!is_natural_number($size)) {
         $size = self::$config["defaultThumbnailSize"];
     } elseif (!in_array((int) $size, self::$config["thumbnailSizes"], true)) {
         $_size = 0;
         $diff = PHP_INT_MAX;
         foreach (self::$config["thumbnailSizes"] as $tSize) {
             if (($abs = abs($tSize - $size)) <= $diff) {
                 $diff = $abs;
                 $_size = $tSize;
             }
         }
         $size = $_size;
     }
     $filePath = $this->getThumbnailDir($size) . DS . $fileName;
     if (!is_file($filePath)) {
         if (($source = $this->getSourceImage($fileName)) === null) {
             return false;
         } else {
             $image = $this->createImageObject($source);
             $image->resize($size)->save($filePath);
         }
     }
     $resource = file_get_contents($filePath);
     $type = $this->getType($resource);
     header("Content-Type: image/{$type}");
     echo $resource;
     return true;
 }
Ejemplo n.º 5
0
 public function naturalNumber($name, $value)
 {
     if (!is_empty($value) && !is_natural_number($value)) {
         return $this->getDisplayName($name) . "は整数で入力してください";
     }
 }
Ejemplo n.º 6
0
 public function naturalNumber($name, $value)
 {
     if (!is_empty($value) && !is_natural_number($value)) {
         return $this->getDisplayName($name) . " must be a natural number.";
     }
 }