This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| php:zend_validate_array [d.m.Y H:i] – kodmasin | php:zend_validate_array [d.m.Y H:i] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Zend_Validate_Array class ====== | ||
| + | ===== About ===== | ||
| + | This class was developed when ZF did not have good Zend_Filter_Input. When Zned_Filter_Input was created (ZF 1.0.0) this class lost some of its benefits but is is still useful for people which want to add end-user custom error messages. You can then use Zend_Translate_* . Also Zend_Validate_* classes are not designed to have end-user friendly error messages (to many of them and to detailed ex. Zend_Validate_EmailAddress). | ||
| + | |||
| + | I have no time to polish this class. Here I mean that it does not confirm ZF codding standards and that some of method names could sound strange. I have created proposal in ZF developer (in archive as there were low interest for this) wiki so any contribution is welcome especially if someone want to polish this class. | ||
| + | |||
| + | :!: **NOTE** - I will be much happier if ZF implemented setUserMessage/ | ||
| + | |||
| + | :!: **NOTE** - There is uptodate version in SVN of my project loota [[http:// | ||
| + | |||
| + | ===== Download ===== | ||
| + | |||
| + | * {{: | ||
| + | * {{php: | ||
| + | * {{php: | ||
| + | |||
| + | ===== Reference ===== | ||
| + | Until better documentation is written please see code below. I hope it is self explaining. if you have questions please send it to [[boris@kodmasin.net]]. | ||
| + | ==== Case 21.09.2008. ==== | ||
| + | <code php> | ||
| + | $inputValidator = new Zend_Validate_Array(array(' | ||
| + | $inputValidator-> | ||
| + | $id = $inputValidator-> | ||
| + | $id-> | ||
| + | -> | ||
| + | -> | ||
| + | $name = $inputValidator-> | ||
| + | $name-> | ||
| + | -> | ||
| + | -> | ||
| + | $description = $inputValidator-> | ||
| + | $description-> | ||
| + | |||
| + | if($inputValidator-> | ||
| + | $this-> | ||
| + | } | ||
| + | else{ | ||
| + | $this-> | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Case 28.12.2007. ==== | ||
| + | <code php> | ||
| + | public function ajaxAddAction() | ||
| + | { | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | |||
| + | //this is my extension see / | ||
| + | $input = new Zend_Validate_Array(array(" | ||
| + | $input-> | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | $status = null; | ||
| + | |||
| + | if($input-> | ||
| + | try{ | ||
| + | $user_t= new Users_TUsers(array(' | ||
| + | |||
| + | $user_t-> | ||
| + | ' | ||
| + | ' | ||
| + | )); | ||
| + | $status = array(" | ||
| + | } | ||
| + | catch(Zend_Db_Exception $e){ | ||
| + | $error_code = $e-> | ||
| + | $message = $this-> | ||
| + | $db_message = $e-> | ||
| + | if(strpos($db_message, | ||
| + | $message = $this-> | ||
| + | } | ||
| + | // | ||
| + | $this-> | ||
| + | $status = array(" | ||
| + | } | ||
| + | } | ||
| + | else{ | ||
| + | $messages = $input-> | ||
| + | $status = array( | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ); | ||
| + | } | ||
| + | echo json_encode($status); | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Case 09.12.2007. ==== | ||
| + | <code php> | ||
| + | public function ajaxListAction(){ | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | require_once ' | ||
| + | |||
| + | $page = 1; | ||
| + | $limit = 25; | ||
| + | $filterField = " | ||
| + | $filter = null; | ||
| + | $sortField = " | ||
| + | $sortType = 0; | ||
| + | //set requested values | ||
| + | if(isset($_GET)){ | ||
| + | $input = new Zend_Validate_Array(array(" | ||
| + | $input-> | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | -> | ||
| + | if($input-> | ||
| + | if($input-> | ||
| + | $page = $input-> | ||
| + | if($input-> | ||
| + | $page = $inpur-> | ||
| + | if($input-> | ||
| + | $filterField = $input-> | ||
| + | if($input-> | ||
| + | $filter = $input-> | ||
| + | if($input-> | ||
| + | $sortField = $input-> | ||
| + | if($input-> | ||
| + | $sortType = $input-> | ||
| + | } | ||
| + | } | ||
| + | try{ | ||
| + | //db stuff .... | ||
| + | } | ||
| + | catch(Zend_Db_Exception $e){ | ||
| + | //db error stuff .... | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||