<?php
namespace Moto\Application\Content\InputFilter; use Moto\InputFilter\AbstractInputFilter; use Moto; class SaveContentBlock extends AbstractInputFilter { protected $_name = 'content.save'; public function init() { $this->add(array( 'name' => 'id', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'Digits', 'break_chain_on_failure' => true, ), array( 'name' => 'Moto\Application\Content\Validator\ContentBlockExists', 'options' => array( 'table' => Moto\Config::get('database.prefix') . 'content_blocks', 'field' => 'id', 'adapter' => Moto\Config::get('databaseAdapter'), ) ) ), )); $this->add(array( 'name' => 'type', 'required' => true, 'filters' => array( array('name' => 'StripTags'), array('name' => 'StringTrim'), ), 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array('header', 'footer', 'sidebar', 'popup',) ) ) ), )); $this->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' => 1, 'max' => 200, ), 'break_chain_on_failure' => true ), array( 'name' => 'Moto\Application\Content\Validator\UniqueName', 'options' => array( 'table' => Moto\Config::get('database.prefix') . 'content_blocks', 'field' => 'name', 'adapter' => Moto\Config::get('databaseAdapter') ) ) ), )); $this->add(array( 'name' => 'styles', 'required' => false, 'allow_empty' => true, 'filters' => array( array( 'name' => 'Moto\Filter\DefaultFilter', 'options' => array( 'value' => '' ) ), ) )); $this->add(array( 'name' => 'properties', 'required' => false, 'allow_empty' => true, 'filters' => array( array( 'name' => 'Moto\Filter\DefaultFilter', 'options' => array( 'value' => null ) ), ) )); $this->add(array( 'name' => 'content', 'required' => false, 'allow_empty' => true, 'filters' => array( array('name' => 'StringTrim'), array('name' => 'Moto\Filter\StripCode'), array('name' => 'Moto\Filter\BodyContent'), array( 'name' => 'Moto\Filter\DefaultFilter', 'options' => array( 'value' => '' ) ), ), )); } } 