コード例 #1
0
ファイル: number.php プロジェクト: muten84/luigibifulco.it
 public function validate()
 {
     if (!v::num($this->result())) {
         return false;
     }
     if ($this->min and !v::min($this->result(), $this->min)) {
         return false;
     }
     if ($this->max and !v::max($this->result(), $this->max)) {
         return false;
     }
     return true;
 }
コード例 #2
0
 public function createNum($to = null)
 {
     $parent = $this->parent();
     $params = $parent->blueprint()->pages()->num();
     switch ($params->mode()) {
         case 'zero':
             return 0;
             break;
         case 'date':
             if ($to = $this->date($params->format(), $params->field())) {
                 return $to;
             } else {
                 return date($params->format());
             }
             break;
         default:
             $visibleSiblings = $parent->children()->visible();
             if ($to == 'last') {
                 $to = $visibleSiblings->count() + 1;
             } else {
                 if ($to == 'first') {
                     $to = 1;
                 } else {
                     if (is_null($to)) {
                         $to = $this->num();
                     }
                 }
             }
             if (!v::num($to)) {
                 return false;
             }
             if ($to <= 0) {
                 return 1;
             }
             if ($this->isInvisible()) {
                 $limit = $visibleSiblings->count() + 1;
             } else {
                 $limit = $visibleSiblings->count();
             }
             if ($limit < $to) {
                 $to = $limit;
             }
             return intval($to);
             break;
     }
 }
コード例 #3
0
 public function validate()
 {
     if (!v::num($this->result())) {
         return false;
     }
     if ($this->validate and is_array($this->validate)) {
         return parent::validate();
     } else {
         if ($this->min and !v::min($this->result(), $this->min)) {
             return false;
         }
         if ($this->max and !v::max($this->result(), $this->max)) {
             return false;
         }
     }
     return true;
 }
コード例 #4
0
ファイル: subpages.php プロジェクト: aoimedia/kosmonautensofa
 public function num($uid, $to = null)
 {
     $page = $this->find($uid);
     $blueprint = blueprint::find($this->parent);
     $params = $blueprint->pages()->num();
     if ($to == 'last') {
         $to = $this->visible()->count() + 1;
     }
     switch ($params->mode()) {
         case 'zero':
             return 0;
             break;
         case 'date':
             if ($to = $page->date($params->format(), $params->field())) {
                 return $to;
             } else {
                 return date($params->format());
             }
             break;
         default:
             if (v::num($to)) {
                 if ($to <= 0) {
                     $to = 1;
                 } else {
                     if ($page->isInvisible()) {
                         $limit = $this->visible()->count() + 1;
                     } else {
                         $limit = $this->visible()->count();
                     }
                     if ($limit < $to) {
                         $to = $limit;
                     }
                 }
                 return intval($to);
             } else {
                 return false;
             }
             break;
     }
 }
コード例 #5
0
ファイル: VTest.php プロジェクト: nsteiner/kdoc
 public function testNum()
 {
     $this->assertTrue(v::num('1234'));
     $this->assertFalse(v::num('abc'));
 }
コード例 #6
0
 public function validate()
 {
     return v::num($this->result());
 }