<?php
namespace Moto\Application\Settings\InputFilter; use Moto\InputFilter\AbstractInputFilter; use Moto; class AdvancedSettings extends AbstractInputFilter { protected $_name = 'settingsWebsite.advancedSettings'; protected $_enabledInputs; protected function _isEnabledInput($name) { if ($this->_enabledInputs === null) { $this->_enabledInputs = $this->getOption('enableInputs', true); } if (is_array($this->_enabledInputs)) { return in_array($name, $this->_enabledInputs); } return (boolean) $this->_enabledInputs; } public function init() { if ($this->_isEnabledInput('timezone')) { $this->add(array( 'name' => 'timezone', 'required' => false, '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\Validator\TimezoneValidator', ) ), )); } if ($this->_isEnabledInput('under_construction')) { $sub = new AbstractInputFilter(); $this->add($sub, 'under_construction'); $sub->add(array( 'name' => 'enabled', 'required' => false, 'continue_if_empty' => true, 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array(false, true) ) ), ), )); $sub->add(array( 'name' => 'page_id', 'required' => true, 'filters' => array( array('name' => 'Moto\Filter\IntValue'), ), 'validators' => array( array( 'name' => 'Digits', ), ), )); } if ($this->_isEnabledInput('control_panel_analytics')) { $sub = new AbstractInputFilter(); $this->add($sub, 'control_panel_analytics'); $sub->add(array( 'name' => 'enabled', 'required' => false, 'continue_if_empty' => true, 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array(false, true) ) ), ), )); } if ($this->_isEnabledInput('lazy_loading')) { $sub = new AbstractInputFilter(); $this->add($sub, 'lazy_loading'); $sub->add(array( 'name' => 'enabled', 'required' => false, 'validators' => array( array( 'name' => 'InArray', 'options' => array( 'haystack' => array(false, true) ) ), ), )); } if ($this->_isEnabledInput('maintenance_mode')) { $this->add(new Moto\Application\Settings\InputFilter\MaintenanceMode, 'maintenance_mode'); } if ($this->_isEnabledInput('popup_preferences')) { $this->add(new Moto\Application\Settings\InputFilter\PopupPreferences, 'popup_preferences'); } if ($this->_isEnabledInput('cookie_notification')) { $this->add(new Moto\Application\Settings\InputFilter\CookieNotification, 'cookie_notification'); } } } 