notEmpty() публичный статический Метод

public static notEmpty ( $value )
Пример #1
0
 /**
  * testNotEmpty method
  *
  * @access public
  * @return void
  */
 function testNotEmpty()
 {
     $this->assertTrue(Validation::notEmpty('abcdefg'));
     $this->assertTrue(Validation::notEmpty('fasdf '));
     $this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla'));
     $this->assertFalse(Validation::notEmpty("\t "));
     $this->assertFalse(Validation::notEmpty(""));
 }
Пример #2
0
 public function arrayNotEmpty($check)
 {
     $value = current((array) $check);
     if (!is_array($value)) {
         return Validation::notEmpty($check);
     }
     return !empty($value);
 }
Пример #3
0
Файл: Tag.php Проект: tnoi/tags
 /**
  * Custom validation for keeping BC to CakePHP version below 2.7
  *
  * @param array $check
  * @return bool
  */
 public function notBlank($check)
 {
     $value = array_values($check);
     $value = $value[0];
     if (method_exists('Validation', 'notBlank')) {
         return Validation::notBlank($value);
     } else {
         // below 2.7
         return Validation::notEmpty($value);
     }
 }
Пример #4
0
 public function notEmptyForWebApp($validationFields = array())
 {
     if (Validation::notEmpty(@$this->data[$this->alias]['type']) && $this->data[$this->alias]['type'] == 'web') {
         foreach ($validationFields as $key => $value) {
             if (!Validation::notEmpty($value)) {
                 return false;
             }
         }
         return true;
     } else {
         return true;
     }
 }
Пример #5
0
 /**
  * testNotEmptyISO88591Encoding method
  *
  * @return void
  */
 public function testNotEmptyISO88591AppEncoding()
 {
     Configure::write('App.encoding', 'ISO-8859-1');
     $this->assertTrue(Validation::notEmpty('abcdefg'));
     $this->assertTrue(Validation::notEmpty('fasdf '));
     $this->assertTrue(Validation::notEmpty('fooo' . chr(243) . 'blabla'));
     $this->assertTrue(Validation::notEmpty('abçďĕʑʘπй'));
     $this->assertTrue(Validation::notEmpty('José'));
     $this->assertTrue(Validation::notEmpty(utf8_decode('José')));
     $this->assertFalse(Validation::notEmpty("\t "));
     $this->assertFalse(Validation::notEmpty(""));
 }
Пример #6
0
 function buy()
 {
     try {
         if ($this->request->is('post')) {
             $store = $this->Store->findByStoreHash($this->data['Item']['store_hash']);
             if (!$store) {
                 throw new Exception('Invalid store hash.');
             }
             $this->Item->id = $this->data['Item']['id'];
             $item_is_active = $this->Item->field('is_active');
             if (!$item_is_active) {
                 throw new Exception('Item is sold out.');
             }
             if (!Validation::email($this->data['Item'][$this->_imap['email']])) {
                 $this->Item->invalidate($this->_imap['email'], __('Invalid email.'));
             }
             if (!Validation::notEmpty($this->data['Item']['message'])) {
                 $this->Item->invalidate('message', __('Cannot be left empty.'));
             }
             if ($this->Item->validates()) {
                 if ($this->Item->Save($this->data)) {
                     $this->Session->setFlash('Item purchased.', 'default', array('class' => 'message success'));
                     $message = array('Message' => array('store_id' => $store['Store']['id'], 'item_id' => $this->Item->id, 'sender_email' => $this->data['Item'][$this->_imap['email']], 'receiver_email' => $store['Store']['email'], 'body' => $this->data['Item']['message']));
                     if ($this->_logged_user) {
                         $message['Message']['sender_id'] = $this->_logged_user['id'];
                         $message['Message']['sender_email'] = $this->_logged_user['email'];
                     }
                     if (isset($store['Store']['user_id'])) {
                         $message['Message']['receiver_id'] = $store['Store']['user_id'];
                     }
                     if ($this->Message->save($message)) {
                         $subject = 'Someone bought your item';
                         $this->Email->send($message['Message']['sender_email'], $store['Store']['email'], $subject, $this->data['Item']['message']);
                     }
                 }
             }
             $this->_processIframeForm($this->Item->validationErrors, $this->data, $this->referer());
         }
     } catch (Exception $e) {
         $this->Session->setFlash($e->getMessage(), 'default', array('class' => 'message error'));
         $this->redirect($this->referer());
         exit;
     }
 }
Пример #7
0
 /**
  * @testdox notEmpty should return false to blank space string
  */
 public function testInvalidNotEmptyWithSpaces()
 {
     $value = '   ';
     $this->assertFalse(Validation::notEmpty($value));
 }
Пример #8
0
 function add()
 {
     global $G;
     require CLASS_PATH . "validation.class.php";
     $validate = new Validation();
     uses("trade", "member", "tradefield", "tag");
     $tag = new Tags();
     $offer = $tradefield = new Tradefields();
     $member = new Members();
     $trade = new Trades();
     if (isset($_POST['visit_post'])) {
         capt_check("capt_post_free");
         pb_submit_check('visit_post');
         $_POST['data']['trade']['title'] = pb_lang_merge($_POST['data']['multi']);
         $trade->setParams();
         $tradefield->setParams();
         $if_title_exists = $trade->findByTitle($trade->params['data']['trade']['title']);
         if (!empty($if_title_exists)) {
             $trade->validationErrors[] = L("semilar_offer_post");
         }
         if (!$validate->notEmpty($trade->params['data']['trade']['title'])) {
             $trade->validationErrors[] = L("title_cant_be_empty");
         }
         $trade->params['expire_days'] = $_POST['expire_days'];
         $if_check = $G['setting']['vis_post_check'];
         $msg = null;
         $words = $trade->dbstuff->GetArray("SELECT * FROM {$trade->table_prefix}words");
         if (!empty($words)) {
             foreach ($words as $word_val) {
                 if (!empty($word_val['title'])) {
                     str_replace($word_val['title'], "***", $trade->params['data']['trade']['title']);
                     str_replace($word_val['title'], "***", $trade->params['data']['trade']['content']);
                 }
             }
             $item['forbid_word'] = implode("\r\n", $tmp_str);
         }
         if ($if_check) {
             $trade->params['data']['trade']['status'] = 0;
             $msg = 'pls_wait_for_check';
         } else {
             $trade->params['data']['trade']['status'] = 1;
             $msg = 'success';
         }
         if (!empty($trade->validationErrors)) {
             setvar("item", am($trade->params['data']['trade'], $tradefield->params['data']['tradefield']));
             setvar("Errors", $validate->show($trade));
             render("offer/post");
         } else {
             $trade->params['data']['trade']['industry_id'] = implode(",", $_POST['industry']['id']);
             $trade->params['data']['trade']['area_id'] = implode(",", $_POST['area']['id']);
             $result = $trade->Add();
             if ($result) {
                 flash($msg);
             } else {
                 flash();
             }
         }
     }
 }
Пример #9
0
 /**
  * Shim wrapper for 2.6 to allow 2.7 notBlank validation rule to work already.
  * This is only there to avoid the deprecation errors in 2.6 test runs.
  *
  * @param array $data
  * @return bool
  */
 public function notBlank($data)
 {
     $value = array_shift($data);
     if ((double) Configure::version() < 2.7) {
         return Validation::notEmpty($value);
     }
     return Validation::notBlank($value);
 }
Пример #10
0
setvar("PhoneTypes", $typeoption->get_cache_type("phone_type"));
setvar("ImTypes", $typeoption->get_cache_type("im_type"));
$if_visit_post = $_PB_CACHE['setting']['vis_post'];
if (!$if_visit_post) {
    $smarty->flash('visitor_forbid', URL, 0);
}
capt_check("capt_post_free");
if (isset($_POST['visit_post'])) {
    pb_submit_check('visit_post');
    $trade->setParams();
    $tradefield->setParams();
    $if_title_exists = $trade->findByTitle($trade->params['data']['trade']['title']);
    if (!empty($if_title_exists)) {
        $trade->validationErrors[] = L("semilar_offer_post");
    }
    if (!$validate->notEmpty($trade->params['data']['trade']['title'])) {
        $trade->validationErrors[] = L("title_cant_be_empty");
    }
    $trade->params['expire_days'] = $_POST['expire_days'];
    //$trade->params['data']['trade']['tag_ids'] = $tag->setTagId($_POST['data']['tag']);;
    $if_check = $_PB_CACHE['setting']['vis_post_check'];
    $msg = null;
    $words = $pdb->GetArray("SELECT * FROM {$tb_prefix}words");
    if (!empty($words)) {
        foreach ($words as $word_val) {
            if (!empty($word_val['title'])) {
                str_replace($word_val['title'], "***", $trade->params['data']['trade']['title']);
                str_replace($word_val['title'], "***", $trade->params['data']['trade']['content']);
            }
        }
        $item['forbid_word'] = implode("\r\n", $tmp_str);
 /**
  * formatJson
  * jpn: json形式の文字列かどうか
  *
  */
 public function formatJson(Model $model, $field)
 {
     $value = array_shift($field);
     if (!Validation::notEmpty($value)) {
         return true;
     }
     $result = json_decode($value);
     if ($result === null) {
         return false;
     }
     return true;
 }