Exemplo n.º 1
0
 public function getInputFilter()
 {
     if (!$this->inputFilter) {
         $inputFilter = new InputFilter();
         $factory = new InputFactory();
         $inputFilter->add($factory->createInput(['name' => 'BankStatement_id', 'required' => true, 'filters' => array(array("name" => "Callback", "options" => array("callback" => function ($values) {
             $strip = new \Zend\Filter\StripTags();
             $trim = new \Zend\Filter\StringTrim();
             $int = new \Zend\Filter\Int();
             foreach ($values as $key => $val) {
                 $val = $strip->filter($val);
                 $val = $trim->filter($val);
                 $val = $int->filter($val);
                 $values[$key] = $val;
             }
             return $values;
         }))), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Please choose either one statement and multiple orders or multiple statements and one order.'), 'callback' => function ($values, $context = array()) {
             if (count($values) == 1 && count($context['Order_id']) >= 1) {
                 return true;
             }
             if (count($values) >= 1 && count($context['Order_id']) == 1) {
                 return true;
             }
             return false;
         })))]));
         $inputFilter->add($factory->createInput(['name' => 'Order_id', 'required' => true, 'filters' => array(array("name" => "Callback", "options" => array("callback" => function ($values) {
             $strip = new \Zend\Filter\StripTags();
             $trim = new \Zend\Filter\StringTrim();
             $int = new \Zend\Filter\Int();
             foreach ($values as $key => $val) {
                 $val = $strip->filter($val);
                 $val = $trim->filter($val);
                 $val = $int->filter($val);
                 $values[$key] = $val;
             }
             return $values;
         }))), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Please choose either one order and multiple statements or multiple orders and one statement.'), 'callback' => function ($values, $context = array()) {
             if (count($values) == 1 && count($context['BankStatement_id']) >= 1) {
                 return true;
             }
             if (count($values) >= 1 && count($context['BankStatement_id']) == 1) {
                 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;
 }
Exemplo n.º 2
0
 public function index10Action()
 {
     echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>";
     $filter = new \Zend\Filter\StripTags();
     $input = "<h3 style='color:red'>\$%#\$\$%dsgsdgs123</h3>";
     $output = $filter->filter($input);
     echo "<h2>Input: {$input}</h2><br>";
     echo "<h2>Output : {$output}</h2>";
     return false;
 }
Exemplo n.º 3
0
 public function getInputFilter()
 {
     $this->inputFilter = new InputFilter();
     $factory = new InputFactory();
     $this->inputFilter->add($factory->createInput(['name' => 'Product_id', 'required' => true, 'filters' => array(array('name' => 'Int')), 'validators' => array()]));
     $this->inputFilter->add($factory->createInput(['name' => 'participant_id', 'required' => true, 'filters' => array(array('name' => 'Int')), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Please select a person.'), 'callback' => function ($value, $context = array()) {
         if (is_numeric($value)) {
             return true;
         }
         if (isset($context['agegroup_id']) && is_numeric($context['agegroup_id'])) {
             return true;
         }
         return false;
     })), array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Unable to add personalized product to person without birthdate. Please add date of birth in My Person list.'), 'callback' => function ($value, $context = array()) {
         $cartContainer = new Container('cart');
         $participant = $cartContainer->order->getParticipantById($value);
         if (is_object($participant)) {
             if (!$participant->getBirthday() instanceof \DateTime) {
                 return false;
             } else {
                 return true;
             }
         } else {
             # this is not a personalized product
             return true;
         }
     })))]));
     $this->inputFilter->add($factory->createInput(['name' => 'agegroup_id', 'required' => true, 'filters' => array(array('name' => 'Int')), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Please select a agegroup.'), 'callback' => function ($value, $context = array()) {
         if (is_numeric($value)) {
             return true;
         }
         if (isset($context['participant_id']) && is_numeric($context['participant_id'])) {
             return true;
         }
         return false;
     })))]));
     $this->inputFilter->add($factory->createInput(['name' => 'pv', 'required' => true, 'filters' => array(array("name" => "Callback", "options" => array("callback" => function ($values) {
         #$int = new \Zend\Filter\Int();
         $strip = new \Zend\Filter\StripTags();
         $trim = new \Zend\Filter\StringTrim();
         foreach ($values as $key => $value) {
             #$value = $int->filter($value);
             $value = $strip->filter($value);
             $value = $trim->filter($value);
             $values[$key] = $value;
         }
         return $values;
     }))), 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Please select a product variant.'), 'callback' => function ($values, $context = array()) {
         foreach ($values as $key => $value) {
             if ($value == '') {
                 return false;
             }
             if (!is_numeric($value)) {
                 return false;
             }
         }
         return true;
     })))]));
     return $this->inputFilter;
 }