當前位置: 首頁>>代碼示例>>PHP>>正文


PHP InputFilter\InputFilter類代碼示例

本文整理匯總了PHP中Zend\InputFilter\InputFilter的典型用法代碼示例。如果您正苦於以下問題:PHP InputFilter類的具體用法?PHP InputFilter怎麽用?PHP InputFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了InputFilter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getInputFilter

 /**
  * Return a configured input filter to be able to validate and
  * filter the data.
  *
  * @return InputFilter
  */
 public function getInputFilter()
 {
     $inputFilter = new InputFilter();
     $factory = new InputFactory();
     $inputFilter->add($factory->createInput(array('name' => 'user_id', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim'), array('name' => 'Int')), 'validators' => array(array('name' => 'NotEmpty'), array('name' => 'Digits'), array('name' => 'Zend\\Validator\\Db\\RecordExists', 'options' => array('table' => 'users', 'field' => 'id', 'adapter' => $this->adapter))))));
     return $inputFilter;
 }
開發者ID:CPDeutschland,項目名稱:zf2-api-client,代碼行數:13,代碼來源:UserImagesTable.php

示例2: addInputFilter

 public function addInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     $title = sprintf("%.0f ", microtime(true) * 20000);
     $title = str_replace(' ', '', $title);
     //$title=(float) microtime(true)*20000;
     $fileInput = new InputFilter\FileInput('seriecode');
     $fileInput->setRequired(true);
     // You only need to define validators and filters
     // as if only one file was being uploaded. All files
     // will be run through the same validators and filters
     // automatically.
     $fileInput->getValidatorChain()->attachByName('filesize', array('max' => 500000000))->attachByName('filemimetype', array('mimeType' => 'video/mp4'));
     // All files will be renamed, i.e.:
     //   ./data/tmpuploads/avatar_4b3403665fea6.png,
     //   ./data/tmpuploads/avatar_5c45147660fb7.png
     $name = md5(date('ymd'));
     if (!file_exists('temp/data/tmpuploads/videos/' . $name)) {
         mkdir('temp/data/tmpuploads/videos/' . $name, 0777, true);
     }
     $fileInput->getFilterChain()->attachByName('filerenameupload', array('target' => './temp/data/tmpuploads/videos/' . $name . '/', 'randomize' => true));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
開發者ID:gstearmit,項目名稱:EshopVegeTable,代碼行數:25,代碼來源:UploadForm.php

示例3: getLeaveFilter

 public function getLeaveFilter()
 {
     $filter = new InputFilter();
     $filter->add(array('name' => 'leaveType', 'required' => true));
     $filter->add(array('name' => 'description', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'max' => 500, 'min' => 1, 'encoding' => 'UTF-8'))));
     return $filter;
 }
開發者ID:khinmyatkyi,項目名稱:Office_Management,代碼行數:7,代碼來源:DashboardHelper.php

示例4: initFilters

 protected function initFilters()
 {
     $filter = new InputFilter();
     $filter->add(['name' => 'startDate', 'required' => true, 'validators' => [['name' => 'date']], 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']]]);
     $filter->add(['name' => 'expirationDate', 'required' => true, 'validators' => [['name' => 'date']], 'filters' => [['name' => 'StripTags'], ['name' => 'StringTrim']]]);
     $this->setInputFilter($filter);
 }
開發者ID:Mesoptier,項目名稱:gewisweb,代碼行數:7,代碼來源:EditPackage.php

示例5: getInputFilter

 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $inputFilter = new InputFilter();
         $factory = new InputFactory();
         $inputFilter->add($factory->createInput(['name' => 'item_id', 'required' => true, 'filters' => array(array("name" => "Int")), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'It was not possible to find the package to change the participant for.'), 'callback' => function ($value, $context = array()) {
             # check if order with the id of $value exists
             if (!is_numeric($value)) {
                 return false;
             }
             $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
             $item = $em->getRepository("ErsBase\\Entity\\Item")->findOneBy(array('id' => $value));
             if ($item) {
                 return true;
             }
             return false;
         })))]));
         $inputFilter->add($factory->createInput(['name' => 'user_id', 'required' => true, 'filters' => array(array("name" => "Int")), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'It was not possible to find the user that should be set as participant.'), 'callback' => function ($value, $context = array()) {
             # check if user with the id of $value exists
             if (!is_numeric($value)) {
                 return false;
             }
             $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
             $user = $em->getRepository("ErsBase\\Entity\\User")->findOneBy(array('id' => $value));
             if ($user) {
                 return true;
             }
             return false;
         })))]));
         $inputFilter->add($factory->createInput(['name' => 'comment', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty'))]));
         $this->inputFilter = $inputFilter;
     }
     return $this->inputFilter;
 }
開發者ID:odegroot,項目名稱:ers,代碼行數:34,代碼來源:AcceptParticipantChangeItem.php

示例6: addInputFilter

 public function addInputFilter()
 {
     $inputFilter = new InputFilter();
     $inputFilter->add(array('name' => 'name', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 3, 'max' => 20)))));
     $inputFilter->add(array('name' => 'desc', 'required' => false, 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'max' => 500)))));
     $this->setInputFilter($inputFilter);
 }
開發者ID:kouks,項目名稱:Sleanded,代碼行數:7,代碼來源:TicketForm.php

示例7: addInputFilter

 public function addInputFilter()
 {
     $inputFilter = new InputFilter\InputFilter();
     // File Input
     //$title=microtime(true)*20000;
     $fileInput = new InputFilter\FileInput('imagefile');
     $fileInput->setRequired(true);
     // You only need to define validators and filters
     // as if only one file was being uploaded. All files
     // will be run through the same validators and filters
     // automatically.
     //$validator = new \Zend\Validator\File\MimeType('image/gif,image/jpg,image/png');
     $fileInput->getValidatorChain()->attachByName('filesize', array('max' => 5480000))->attachByName('filemimetype', array('mimeType' => 'image/png'));
     // All files will be renamed, i.e.:
     //   ./data/tmpuploads/avatar_4b3403665fea6.png,
     //   ./data/tmpuploads/avatar_5c45147660fb7.png
     /* $fileInput->getFilterChain()->attachByName(
            'filerenameupload',
            array(
                'target'    => './data/tmpuploads/123/',
                'randomize' => true,
            )
        );*/
     $name = 1;
     if (!file_exists('eclip.tv/data/uploads/user/' . $name)) {
         mkdir('eclip.tv/data/uploads/user/' . $name, 0777, true);
     }
     $fileInput->getFilterChain()->attach(new \Zend\Filter\File\Rename("eclip.tv/data/uploads/user/" . $name . '/' . $title . ".png"));
     $inputFilter->add($fileInput);
     $this->setInputFilter($inputFilter);
 }
開發者ID:gstearmit,項目名稱:EshopVegeTable,代碼行數:31,代碼來源:ChangeavaForm.php

示例8: initFilters

 protected function initFilters()
 {
     $filter = new InputFilter();
     $filter->add(['name' => 'lidnr', 'required' => true, 'validators' => [['name' => 'not_empty'], ['name' => 'digits']]]);
     $filter->add(['name' => 'email', 'required' => true, 'validators' => [['name' => 'not_empty'], ['name' => 'email_address']]]);
     $this->setInputFilter($filter);
 }
開發者ID:Mesoptier,項目名稱:gewisweb,代碼行數:7,代碼來源:Register.php

示例9: getInputFilter

 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $inputFilter = new InputFilter();
         $factory = new InputFactory();
         /*
                     $inputFilter->add($factory->createInput(array(
                         'name'     => 'name',
                         'required' => true,
                         'filters'  => array(
                             array('name' => 'StripTags'),
                             array('name' => 'StringTrim'),
                         ),
                         'validators' => array(
                             array(
                                 'name'    => 'StringLength',
                                 'options' => array(
                                     'encoding' => 'UTF-8',
                                     'min'      => 1,
                                     'max'      => 100,
                                 ),
                             ),
                         ),
                     )));
         */
         $inputFilter->add($factory->createInput(array('name' => 'min_start_range', 'required' => true)));
         $inputFilter->add($factory->createInput(array('name' => 'max_start_range', 'required' => true)));
         $this->inputFilter = $inputFilter;
     }
     return $this->inputFilter;
 }
開發者ID:bladehr8,項目名稱:bowhunter2015,代碼行數:31,代碼來源:Deerinfo.php

示例10: loginAction

 public function loginAction()
 {
     $form = new LoginForm('', false, $this->getServiceLocator());
     $request = $this->getRequest();
     if ($request->isPost()) {
         $inputFilter = new InputFilter();
         $factory = new InputFactory();
         $inputFilter->add($factory->createInput(array('name' => 'username', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty')))));
         $inputFilter->add($factory->createInput(array('name' => 'password', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty')))));
         $form->setInputFilter($inputFilter);
         $form->setData($request->getPost());
         if ($form->isValid()) {
             //check authentication...
             $this->getAuthService()->getAdapter()->setIdentity('' . $request->getPost('username'))->setCredential('' . $request->getPost('password'));
             $result = $this->getAuthService()->authenticate();
             foreach ($result->getMessages() as $message) {
                 //save message temporary into flashmessenger
                 $this->flashmessenger()->addMessage($message);
             }
             if ($result->isValid()) {
                 $this->getAuthService()->getStorage()->write($this->getAuthService()->getAdapter()->getResultRowObject(null));
                 return $this->redirect()->toRoute('bhome');
             }
         }
     }
     return array('form' => $form);
 }
開發者ID:Patinger,項目名稱:Browsergame,代碼行數:27,代碼來源:LoginController.php

示例11: getInputFilter

 /**
  * @return InputFilterInterface
  */
 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $searchParam = new Input('search_param');
         $searchParam->setAllowEmpty(false);
         $searchParam->setRequired(true);
         $radius = new Input('radius');
         $radius->setAllowEmpty(true);
         $radius->setRequired(false);
         $city = new Input('city');
         $city->setAllowEmpty(true);
         $city->setRequired(false);
         $state = new Input('state');
         $state->setAllowEmpty(true);
         $state->setRequired(false);
         $postalCode = new Input('postal_code');
         $postalCode->setAllowEmpty(true);
         $postalCode->setRequired(false);
         //			$contactEmail = new Input('contact_email');
         //			$contactEmail	->setRequired(false);
         //			$contactEmail	->setAllowEmpty(true)
         //							->getValidatorChain()
         //							->addValidator(new \Zend\Validator\EmailAddress());
         $inputFilter = new InputFilter();
         $inputFilter->add($searchParam)->add($radius)->add($city)->add($state)->add($postalCode);
         $this->inputFilter = $inputFilter;
     }
     return $this->inputFilter;
 }
開發者ID:jjs180,項目名稱:dance-america,代碼行數:32,代碼來源:SearchSiteForm.php

示例12: createInputFilter

 /**
  * Définition des filtres et des validateurs
  * @return \Zend\InputFilter\InputFilter
  */
 private function createInputFilter()
 {
     $inputFilter = new InputFilter();
     $inputFilter->add(array('name' => 'libelle', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 45)))));
     $inputFilter->add(array('name' => 'nblits', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'StripTags')), 'validators' => array(array('name' => 'Int'), array('name' => 'GreaterThan', 'options' => array('min' => 0)))));
     return $inputFilter;
 }
開發者ID:oussaka,項目名稱:magasins-feedback,代碼行數:11,代碼來源:PuiForm.php

示例13: Input

 function __construct()
 {
     parent::__construct('console_address');
     $element_id = new Element\Hidden('id');
     $element_id->setValue('');
     $this->add($element_id);
     $this->add(array('name' => 'username', 'type' => 'Text'));
     $this->add(array('name' => 'domain', 'type' => 'Text'));
     $this->add(array('name' => 'nickname', 'type' => 'Text'));
     $element_sex = new Element\Select('sex');
     $element_sex->setValueOptions(array(self::ADDRESS_SEX_BOY => '男性', self::ADDRESS_SEX_GIRL => '女性'));
     $this->add($element_sex);
     $this->add(array('name' => 'submit', 'type' => 'Submit'));
     /**
      * Setting up inputFilter
      */
     $input_id = new Input('id');
     $input_id->setRequired(false)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)))->attach(new \Zend\Validator\Digits());
     $input_username = new Input('username');
     $input_username->setRequired(true)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 18)))->attach(new \Zend\Validator\Digits());
     $input_filter = new InputFilter();
     $input_filter->add($input_id);
     $input_filter->add($input_username);
     $this->setInputFilter($input_filter);
 }
開發者ID:solody,項目名稱:xmail,代碼行數:25,代碼來源:AddressForm.php

示例14: getInputFilter

 public function getInputFilter()
 {
     $inputFilter = new InputFilter();
     $inputFilter->add(array('name' => 'email', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => sprintf('%sを入力してください。', 'メールアドレス')))), array('name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('encoding' => 'UTF-8', 'min' => 0, 'max' => 100, 'message' => array(\Zend\Validator\StringLength::TOO_LONG => sprintf('%sは%s文字以內で入力してください。', 'メールアドレス', '100')))), array('name' => 'EmailAddress', 'options' => array('message' => array(\Zend\Validator\EmailAddress::INVALID_FORMAT => sprintf('%sは有効な形式で入力してください。', 'メールアドレス')))))));
     $inputFilter->add(array('name' => 'password', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array(\Zend\Validator\NotEmpty::IS_EMPTY => sprintf('%sを入力してください。', 'パスワード'))), 'name' => 'StringLength', 'break_chain_on_failure' => true, 'options' => array('encoding' => 'UTF-8', 'min' => 6, 'messages' => array(\Zend\Validator\StringLength::TOO_SHORT => sprintf('%sを最低%s文字で入力してください。', 'パスワード', '6')))))));
     return $inputFilter;
 }
開發者ID:saiseisei,項目名稱:Bookstore,代碼行數:7,代碼來源:UserInfo.php

示例15: getInputFilter

 /**
  * (non-PHPdoc)
  *
  * @see \Zend\InputFilter\InputFilterAwareInterface::getInputFilter()
  *
  */
 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $inputFilter = new InputFilter();
         $factory = new InputFactory();
         // Transaction Date
         $inputFilter->add($factory->createInput(array('name' => 'transaction_date', 'required' => true, 'validators' => array(array("name" => "regex", 'options' => array('pattern' => ClassicValidator::getDateRegex(), 'messages' => array(Regex::INVALID => "Date format is invalid.", Regex::NOT_MATCH => "Date format is invalid.", Regex::ERROROUS => "Date format is invalid.")))))));
         // Currency
         $inputFilter->add($factory->createInput(array('name' => 'currency', 'required' => true, 'validators' => array(array('name' => 'Digits', 'options' => array('min' => 5, 'max' => 1000, 'messages' => array(Digits::NOT_DIGITS => 'Can contain only digits.')))))));
         // Category
         $inputFilter->add($factory->createInput(array('name' => 'category', 'required' => true, 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000))))));
         // Bank Account
         $inputFilter->add($factory->createInput(array('name' => 'bank_account', 'required' => true, 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000))))));
         // Supplier
         $inputFilter->add($factory->createInput(array('name' => 'supplier', 'required' => true, 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000))))));
         // Purpose
         $inputFilter->add($factory->createInput(array('name' => 'purpose', 'required' => true, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('encoding' => 'UTF-8', 'min' => 1, 'max' => 3500))))));
         // Entered For
         $inputFilter->add($factory->createInput(array('name' => 'entered_for', 'required' => true, 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000))))));
         // Global Cost
         $inputFilter->add($factory->createInput(array('name' => 'type', 'validators' => array(array('name' => 'Int', 'options' => array('min' => 1, 'max' => 1000))))));
         $mainFilter = new InputFilter();
         $mainFilter->add($inputFilter, 'fsOne');
         $this->inputFilter = $mainFilter;
     }
     return $this->inputFilter;
 }
開發者ID:arbi,項目名稱:MyCode,代碼行數:33,代碼來源:SearchExpenseFilter.php


注:本文中的Zend\InputFilter\InputFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。