Exemplo n.º 1
0
 /**
  * Tests Valid::alpha_dash()
  *
  * Checks whether a string consists of alphabetical characters, numbers, underscores and dashes only.
  *
  * @test
  * @dataProvider provider_alpha_dash
  * @param string  $input          The string to test
  * @param boolean $contains_utf8  Does the string contain utf8 specific characters
  * @param boolean $expected       Is $input valid?
  */
 public function test_alpha_dash($input, $expected, $contains_utf8 = FALSE)
 {
     if (!$contains_utf8) {
         $this->assertSame($expected, Valid::alpha_dash($input));
     }
     $this->assertSame($expected, Valid::alpha_dash($input, TRUE));
 }
Exemplo n.º 2
0
 public static function check_data($value, $data)
 {
     switch ($data['type']) {
         case 'static':
             return TRUE;
         case 'module':
             return Valid::not_empty($value) and Valid::alpha_dash($value) and $value != '-';
         case 'page':
             return Valid::not_empty($value) and Valid::digit($value) and $value != '-' and $data['id'] != $value;
         case 'url':
             return Valid::not_empty($value) and Model_Page::check_link($value) and $value != '-';
     }
     return FALSE;
 }
Exemplo n.º 3
0
Arquivo: api.php Projeto: anqh/core
 /**
  * Output response.
  */
 public function after()
 {
     switch ($this->format) {
         // Support JSON and JSONP
         case self::FORMAT_JSON:
             $this->response->headers('Content-Type', 'application/json');
             // Check and sanitize JSONP
             $jsonp = Arr::get($_REQUEST, 'callback');
             if ($jsonp && Valid::alpha_dash($jsonp)) {
                 $this->response->body($jsonp . '(' . json_encode($this->data) . ')');
             } else {
                 $this->response->body(json_encode($this->data));
             }
             break;
         case self::FORMAT_XML:
             $this->response->headers('Content-Type', 'application/xml');
             $this->response->body(Arr::xml($this->data));
             break;
     }
 }