当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Filter_Input::isValid方法代码示例

本文整理汇总了PHP中Zend_Filter_Input::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Filter_Input::isValid方法的具体用法?PHP Zend_Filter_Input::isValid怎么用?PHP Zend_Filter_Input::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Filter_Input的用法示例。


在下文中一共展示了Zend_Filter_Input::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showAction

 public function showAction()
 {
     $params = $this->getRequest()->getUserParams();
     $filters = array('wherecolumn' => 'alnum', 'order' => 'alnum', 'count' => 'digits', 'offset' => 'digits');
     $valids = array('wherecolumn' => array('presence' => 'optional'), 'wherevalue' => array('presence' => 'optional'), 'order' => array('presence' => 'optional'), 'count' => array('int', 'default' => 20), 'offset' => 'int');
     $input = new Zend_Filter_Input($filters, $valids, $params);
     if (!$input->isValid()) {
         $this->_redirect();
     }
     $whereColumn = $input->wherecolumn;
     $whereValue = $input->wherevalue;
     $order = $input->order;
     $count = $input->count;
     $offset = $input->offset;
     $db = $this->_model->getAdapter();
     $tableInfo = $this->_model->info();
     $this->view->tableInfo = $tableInfo;
     $where = null;
     if ($whereColumn) {
         $expr = $db->quoteIdentifier($whereColumn) . ' IN (?)';
         $where = $db->quoteInto($expr, $whereValue);
     }
     $this->view->rowset = $this->_model->fetchAll($where, $order, $count, $offset);
     $select = $db->select()->from($tableInfo['name'], 'COUNT(*)');
     $this->view->rowCount = $db->fetchOne($select);
     $this->view->distinctValues = array();
     foreach ($tableInfo['cols'] as $columnName) {
         $select = $db->select()->from($tableInfo['name'], $columnName)->distinct();
         $this->view->distinctValues[$columnName] = $db->fetchCol($select);
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:31,代码来源:GridController.php

示例2: removeContactAction

 /**
  * 
  * Remove an existing contact
  */
 public function removeContactAction()
 {
     $return = array();
     $pageSession = new Zend_Session_Namespace('letting_agents_application');
     $contactManager = new LettingAgents_Manager_Contacts();
     $postData = $this->getRequest()->getParams();
     $filters = array('uid' => 'StringTrim', 'uid' => 'StripTags');
     $validators = array('uid' => 'Alnum');
     $input = new Zend_Filter_Input($filters, $validators, $postData);
     if ($input->isValid()) {
         // Valid input
         $contactManager->deleteByUid($input->uid);
     } else {
         // false
         $return['errorHtml'] = 'Invalid Contact';
     }
     $agent = new LettingAgents_Manager_AgentApplication();
     $agentData = new LettingAgents_Object_AgentApplication();
     $agentData = $agent->fetchByUid($pageSession->agentUniqueId);
     $organisation_type = $agentData->get_organisation_type();
     switch ($organisation_type) {
         case LettingAgents_Object_CompanyTypes::LimitedCompany:
             $partialFile = "limited-company-list.phtml";
             break;
         case LettingAgents_Object_CompanyTypes::LimitedLiabilityPartnership:
         case LettingAgents_Object_CompanyTypes::Partnership:
             $partialFile = "partnership-list.phtml";
             break;
     }
     $return['contactHtml'] = $this->view->partialLoop("partials/{$partialFile}", $contactManager->fetchByAgencyUid($pageSession->agentUniqueId));
     echo Zend_Json::encode($return);
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:36,代码来源:SignUpJsonController.php

示例3: searchAction

 public function searchAction()
 {
     $filters = array('q' => array('StringTrim', 'StripTags'));
     $validators = array('q' => array('presence' => 'required'));
     $input = new Zend_Filter_Input($filters, $validators, $_GET);
     if (is_string($this->_request->getParam('q'))) {
         $queryString = $input->getEscaped('q');
         $this->view->queryString = $queryString;
         if ($input->isValid()) {
             $config = Zend_Registry::get('config');
             $index = App_Search_Lucene::open($config->luceneIndex);
             $query = new Zend_Search_Lucene_Search_Query_Boolean();
             $pathTerm = new Zend_Search_Lucene_Index_Term($queryString);
             $pathQuery = new Zend_Search_Lucene_Search_Query_Term($pathTerm);
             $query->addSubquery($pathQuery, true);
             $pathTerm = new Zend_Search_Lucene_Index_Term('20091023', 'CreationDate');
             $pathQuery = new Zend_Search_Lucene_Search_Query_Term($pathTerm);
             $query->addSubquery($pathQuery, true);
             try {
                 $hits = $index->find($query);
             } catch (Zend_Search_Lucene_Exception $ex) {
                 $hits = array();
             }
             $this->view->hits = $hits;
         } else {
             $this->view->messages = $input->getMessages();
         }
     }
 }
开发者ID:philipnorton42,项目名称:PDFSearch,代码行数:29,代码来源:IndexController.php

示例4: _savePanel

 /**
  * Save changes to an existing panel. This can be expanded to allow adding of new Panels in the future.
  *
  * @return void
  */
 protected function _savePanel()
 {
     // First of all we need to validate and sanitise the input from the form
     $urlFilter = new Zend_Filter();
     $urlFilter->addFilter(new Zend_Filter_StringTrim());
     $urlFilter->addFilter(new Zend_Filter_StringTrim('/'));
     $requiredText = new Zend_Validate();
     $requiredText->addValidator(new Zend_Validate_NotEmpty());
     $filters = array('id' => 'Digits');
     $validators = array('id' => array('allowEmpty' => true), 'content' => array('allowEmpty' => true));
     $input = new Zend_Filter_Input($filters, $validators, $_POST);
     if ($input->isValid()) {
         // Data is all valid, formatted and sanitized so we can save it in the database
         $panel = new Datasource_Cms_Panels();
         if (!$input->id) {
             // This is a new panel so we need to create a new ID
             // NOT IMPLEMENTED - YET
         } else {
             $panel->saveChanges($input->id, $input->getUnescaped('content'));
             $panelID = $input->id;
         }
         // Changes saved - so send them back with a nice success message
         $this->_helper->getHelper('FlashMessenger')->addMessage(array('saved' => true));
         $this->_helper->getHelper('Redirector')->goToUrl('/cms-admin/panels/edit?id=' . $panelID);
     } else {
         // Invalid data in form
         /*
         print_r($_POST);
         print_r($input->getErrors());
         print_r($input->getInvalid());
         */
     }
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:38,代码来源:PanelsController.php

示例5: editAction

 public function editAction()
 {
     $form = new C3op_Form_ReceivableEdit();
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $postData = $this->getRequest()->getPost();
         if ($form->isValid($postData)) {
             $form->process($postData);
             $this->_helper->getHelper('FlashMessenger')->addMessage('The record was successfully updated.');
             $this->_redirect('/projects/project/success-create');
         } else {
             throw new C3op_Projects_ProjectException("A project must have a valid title.");
         }
     } else {
         $data = $this->_request->getParams();
         $filters = array('id' => new Zend_Filter_Alnum());
         $validators = array('id' => new C3op_Util_ValidId());
         $input = new Zend_Filter_Input($filters, $validators, $data);
         if ($input->isValid()) {
             $id = $input->id;
             if (!isset($this->receivableMapper)) {
                 $this->receivableMapper = new C3op_Projects_ReceivableMapper($this->db);
             }
             $thisReceivable = $this->receivableMapper->findById($id);
             C3op_Util_FormFieldValueSetter::SetValueToFormField($form, 'title', $thisReceivable->GetTitle());
             C3op_Util_FormFieldValueSetter::SetValueToFormField($form, 'id', $id);
             $this->SetDateValueToFormField($form, 'predictedDate', $thisReceivable->GetPredictedDate());
             C3op_Util_FormFieldValueSetter::SetValueToFormField($form, 'predictedValue', $thisReceivable->GetPredictedValue());
             $this->SetDateValueToFormField($form, 'realDate', $thisReceivable->GetRealDate());
             C3op_Util_FormFieldValueSetter::SetValueToFormField($form, 'realValue', $thisReceivable->GetRealValue());
             $projectId = $this->populateProjectFields($thisReceivable->GetProject(), $form);
         }
     }
 }
开发者ID:racporto,项目名称:c3op,代码行数:34,代码来源:ReceivableController.php

示例6: contactUsAction

 public function contactUsAction()
 {
     $filters = array('name' => 'StringTrim', 'tel' => 'StringTrim', 'email' => 'StringTrim', 'enquiry' => 'StringTrim');
     $validators = array('name' => 'NotEmpty', 'tel' => 'NotEmpty', 'email' => 'NotEmpty', 'enquiry' => 'NotEmpty');
     $input = new Zend_Filter_Input($filters, $validators, $_POST);
     $returnArray = array();
     if ($input->isValid()) {
         $emailer = new Application_Core_Mail();
         $params = Zend_Registry::get('params');
         $emailer->setTo($params->email->contactUs, 'HomeLet');
         $emailer->setFrom($input->email, $input->name);
         $emailer->setSubject('HomeLet - Contact Us Form');
         $bodyHtml = 'Name : ' . $input->name . '<br />';
         $bodyHtml .= 'Email : ' . $input->email . '<br />';
         $bodyHtml .= 'Tel : ' . $input->tel . '<br />';
         $bodyHtml .= 'Enquiry : <pre>' . $input->enquiry . '</pre><br />';
         $emailer->setBodyHtml($bodyHtml);
         if ($emailer->send()) {
             // Email sent successfully
             $returnArray['success'] = true;
             $returnArray['errorMessage'] = '';
         } else {
             $returnArray['success'] = false;
             $returnArray['errorMessage'] = 'Problem sending email.';
         }
     } else {
         $returnArray['success'] = false;
         $returnArray['errorMessage'] = $input->getMessages();
     }
     echo Zend_Json::encode($returnArray);
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:31,代码来源:IndexController.php

示例7: isValid

 /**
  * This function validates the form.  if simple calls 
  * Zend_Filter_Input::isValid(), but capture the result. if the result is 
  * success, it creates the Inspekt cage around the input before returning 
  * true.
  */
 public function isValid()
 {
     if (!parent::isValid()) {
         return false;
     } else {
         $this->_clean = Inspekt_Cage::Factory($this->_validFields);
         return true;
     }
 }
开发者ID:hellogerard,项目名称:pox-framework,代码行数:15,代码来源:Form.php

示例8: validate

 /**
  * executes the validation and creates an error array or
  * returns the Zend_Filter_Input object
  *
  * @return Zend_Filter_Input|array
  * @param Zend_Filter_Input $input
  */
 protected function validate($input)
 {
     if (!$input->isValid()) {
         $errors = array();
         foreach ($input->getMessages() as $field => $fieldArray) {
             foreach ($fieldArray as $message) {
                 $errors[$field] = $message;
             }
         }
         return $errors;
     } else {
         return $input;
     }
 }
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:21,代码来源:base.php

示例9: validate

 /**
  * Validate Newsletter template
  *
  * @throws Mage_Core_Exception
  * @return bool
  */
 public function validate()
 {
     $validators = array('template_code' => array(Zend_Filter_Input::ALLOW_EMPTY => false), 'template_type' => 'Int', 'template_sender_email' => 'EmailAddress', 'template_sender_name' => array(Zend_Filter_Input::ALLOW_EMPTY => false));
     $data = array();
     foreach (array_keys($validators) as $validateField) {
         $data[$validateField] = $this->getDataUsingMethod($validateField);
     }
     $validateInput = new Zend_Filter_Input(array(), $validators, $data);
     if (!$validateInput->isValid()) {
         $errorMessages = array();
         foreach ($validateInput->getMessages() as $messages) {
             if (is_array($messages)) {
                 foreach ($messages as $message) {
                     $errorMessages[] = $message;
                 }
             } else {
                 $errorMessages[] = $messages;
             }
         }
         Mage::throwException(join("\n", $errorMessages));
     }
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:28,代码来源:Template.php

示例10: validatePass

 /**
  *
  * @param \Core_Dto_Mapping $dtoPass
  * @throws \Core_Exception_ServiceLayer_Verification
  */
 public function validatePass(\Core_Dto_Mapping $dtoPass)
 {
     $data = $dtoPass->toArray();
     $filters = array();
     $validators = array('txSenha' => array(array('NotEmpty'), array('StringLength', array('min' => 6)), 'messages' => array(0 => 'O campo Senha Antiga é de preenchimento obrigatório', 1 => 'MN043')), 'txSenhaNova' => array(array('NotEmpty'), array('StringLength', array('min' => 6)), 'messages' => array(0 => 'O campo Nova Senha é de preenchimento obrigatório', 1 => 'MN043')), 'txSenhaNovaConfirm' => array(array('NotEmpty'), array('StringLength', array('min' => 6)), array('Identical', $data['txSenhaNova']), 'messages' => array(0 => 'O campo Confirmação Nova Senha é de preenchimento obrigatório', 1 => 'MN043', 2 => 'A confirmação da nova senha não confere.')));
     $input = new \Zend_Filter_Input($filters, $validators, $data);
     if (!$input->isValid()) {
         foreach ($input->getMessages() as $msgError) {
             switch (key($msgError)) {
                 case 'isEmpty':
                     $this->getMessaging()->addErrorMessage($msgError['isEmpty']);
                     break;
                 case 'stringLengthTooShort':
                     $this->getMessaging()->addErrorMessage($msgError['stringLengthTooShort']);
                     break;
                 case 'notSame':
                     $this->getMessaging()->addErrorMessage($msgError['notSame']);
                     break;
             }
         }
         $this->getMessaging()->dispatchPackets();
         throw new \Core_Exception_ServiceLayer_Verification();
     }
 }
开发者ID:sgdoc,项目名称:sgdoce-codigo,代码行数:29,代码来源:Usuario.php

示例11: VerifyStream

 /**
  *
  * @param string $UserID
  * @param string $StreamID
  * @return boolean
  */
 public function VerifyStream($UserID, $StreamID)
 {
     //check if UserID and StreamID are vaild
     //
     //return false;
     //if true return guid else return INVALID_CREDENTIALS
     $data = array('UserName' => $UserID, 'streamid' => $StreamID);
     $filters = array('UserName' => array('HtmlEntities', 'StringTrim', 'StripTags'), 'streamid' => array('HtmlEntities', 'StringTrim', 'StripTags'));
     $validators = array('UserName' => array('NotEmpty'), 'streamid' => array('NotEmpty'));
     $input = new Zend_Filter_Input($filters, $validators);
     $input->setData($data);
     if ($input->isValid()) {
         $q = Doctrine_Query::create()->from('Webteam_Model_Video r')->where('r.StreamID = ?', $input->streamid)->addWhere('r.UserName = ?', $input->UserName);
         $result = $q->fetchArray();
         if (count($result) >= 1) {
             return true;
         } else {
             return false;
         }
     } else {
         return false;
         //returns false if input is not valid
     }
 }
开发者ID:BGCX067,项目名称:fall2011-cis553-svn-to-git,代码行数:30,代码来源:Service.php

示例12: checkIdFromGet

 private function checkIdFromGet()
 {
     $data = $this->_request->getParams();
     $filters = array('id' => new Zend_Filter_Alnum());
     $validators = array('id' => array('Digits', new Zend_Validate_GreaterThan(0)));
     $input = new Zend_Filter_Input($filters, $validators, $data);
     if ($input->isValid()) {
         $id = $input->id;
         return $id;
     }
     throw new C3op_Projects_ActionException("Invalid Action Id from Get");
 }
开发者ID:racporto,项目名称:c3op,代码行数:12,代码来源:ActionController.php

示例13: loaduserdataAction

 public function loaduserdataAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->getHelper("layout")->disableLayout();
     $aInputFilters = array("*" => array(new Zend_Filter_StringTrim()));
     $aInputValidators = array("num_row_per_page" => array(new Zend_Validate_Digits()), "curr_page" => array(new Zend_Validate_Digits()), "sort_column" => array(new AppCms2_Validate_SpecialAlpha()), "sort_method" => array(new Zend_Validate_Alpha()), "filter_company_name" => array("allowEmpty" => true), "filter_user_name" => array("allowEmpty" => true), "filter_email_address" => array("allowEmpty" => true), "filter_user_category_name" => array("allowEmpty" => true));
     $oInput = new Zend_Filter_Input($aInputFilters, $aInputValidators, $_POST);
     if ($oInput->isValid()) {
         $oModelVUser = new Admin_Model_VUser();
         $nNumRowPerPage = $oInput->getEscaped("num_row_per_page");
         $nCurrPage = $oInput->getEscaped("curr_page");
         $sSortColumn = $oInput->getEscaped("sort_column");
         $sSortMethod = $oInput->getEscaped("sort_method");
         $aFilter = array("company_name" => $oInput->getEscaped("filter_company_name"), "user_name" => $oInput->getEscaped("filter_user_name"), "email_address" => $oInput->getEscaped("filter_email_address"), "user_category_name" => $oInput->getEscaped("filter_user_category_name"));
         $oRowset = $oModelVUser->getAllUser($aFilter, $nNumRowPerPage, ($nCurrPage - 1) * $nNumRowPerPage, $sSortColumn . " " . $sSortMethod);
         $nNumRows = $oModelVUser->getAllUser($aFilter)->count();
         $aJson = array("rowset" => $oRowset->toArray(), "num_rows" => $nNumRows);
         header("Content-type: application/json");
         echo Zend_Json::encode($aJson);
     }
 }
开发者ID:lstaszak,项目名称:zf_zk_aleph,代码行数:21,代码来源:SettingsController.php

示例14: testValidatorRuleCanHaveEmptyArrayAsMetacommandValue

 /**
  * This test doesn't include any assertions as it's purpose is to 
  * ensure that passing an empty array value into a $validators rule 
  * doesn't cause a notice to be emitted
  *  
  * @group ZF-11819
  */
 public function testValidatorRuleCanHaveEmptyArrayAsMetacommandValue()
 {
     $validators = array('perms' => array('Int', 'default' => array()));
     $validate = new Zend_Filter_Input(NULL, $validators);
     $validate->isValid();
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:13,代码来源:InputTest.php

示例15: testSettingMultipleNotEmptyMessages

 /**
  * @group ZF-7394
  */
 public function testSettingMultipleNotEmptyMessages()
 {
     require_once 'Zend/Validate/NotEmpty.php';
     require_once 'Zend/Validate/Regex.php';
     require_once 'Zend/Validate/StringLength.php';
     $filters = array();
     $validators = array('name' => array('NotEmpty', 'messages' => 'Please enter your name'), 'subject' => array('NotEmpty', 'messages' => 'Please enter a subject'), 'email' => array('EmailAddress', 'messages' => 'Please enter a valid Email address'), 'content' => array('NotEmpty', 'messages' => 'Please enter message contents'));
     $data = array('name' => '', 'subject' => '', 'content' => '');
     $filter = new Zend_Filter_Input($filters, $validators, $data);
     $this->assertFalse($filter->isValid());
     $message = $filter->getMessages();
     $this->assertContains('Please enter your name', $message['name']['isEmpty']);
     $this->assertContains('Please enter a subject', $message['subject']['isEmpty']);
     $this->assertContains('Please enter message contents', $message['content']['isEmpty']);
 }
开发者ID:nbcutech,项目名称:o3drupal,代码行数:18,代码来源:InputTest.php


注:本文中的Zend_Filter_Input::isValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。