Beispiel #1
0
 /**
  * Change the current decorators
  *
  * @param \Zend_Form_Element $element
  * @param array $decorators
  */
 private function _applyDecorators(\Zend_Form_Element $element, array $decorators)
 {
     $element->clearDecorators();
     foreach ($decorators as $decorator) {
         call_user_func_array(array($element, 'addDecorator'), $decorator);
     }
 }
 /**
  * Add element to stack
  *
  * @param  \Zend_Form_Element $element
  * @return \Zend_Form_DisplayGroup
  */
 public function addElement(\Zend_Form_Element $element)
 {
     $decorators = $element->getDecorators();
     $decorator = array_shift($decorators);
     $element->setDecorators(array($decorator, array('Description', array('class' => 'description')), 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')), array('Label'), array(array('labelCell' => 'HtmlTag'), array('tag' => 'td', 'class' => 'label')), array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'class' => $this->_alternate))));
     return parent::addElement($element);
 }
 public function init()
 {
     // Set the method for the display form to POST
     $this->setMethod('post');
     $this->setAttribs(array('class' => 'form-horizontal'));
     $decoratorField = new My_Decorator_FieldLogin();
     $elements = array();
     // Add email field
     $input = new Zend_Form_Element_Text('email', array('required' => true, 'label' => 'Email Address:', 'id' => 'email', 'placeholder' => 'Your email..', 'class' => 'form-control', 'type' => 'email'));
     $validator = new Zend_Validate_EmailAddress();
     $validator->setOptions(array('domain' => false));
     $input->addValidators(array($validator, new Zend_Validate_NotEmpty()));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     // Add password field
     $input = new Zend_Form_Element_Password('password', array('required' => true, 'label' => 'Password:'******'id' => 'password', 'class' => 'form-control', 'placeholder' => 'Your password..'));
     $input->addValidators(array(new Zend_Validate_NotEmpty()));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     // Add checkbox field
     $input = new Zend_Form_Element_Checkbox('rememberMe', array('label' => 'Remember me', 'id' => 'rememberMe', 'class' => 'checkbox', 'type' => 'checkbox'));
     $decoratorCheckBox = new My_Decorator_CheckBox();
     $input->addDecorator($decoratorCheckBox);
     $elements[] = $input;
     $input = new Zend_Form_Element('resetpass', array('label' => 'Reset your password', 'id' => 'resetpass', 'class' => 'form-control', 'value' => 'resetpass'));
     $input->addDecorator(new My_Decorator_AnchoraForm());
     $elements[] = $input;
     //Add Submit button
     $input = new Zend_Form_Element_Submit('submit', array('Label' => '', 'class' => 'btn btn-default', 'value' => 'Login'));
     $input->addDecorator($decoratorField);
     $elements[] = $input;
     $this->addElements($elements);
     $this->addDisplayGroup(array('email', 'password', 'resetpass', 'rememberMe', 'submit'), 'displgrp', array('decorators' => array('FormElements', 'Fieldset')));
 }
Beispiel #4
0
 private function addDefaultValidators(Zend_Form_Element $element, $meta)
 {
     if (!$meta['NULLABLE'] && $meta['PRIMARY'] != true) {
         $element->setRequired(true);
         $element->setAllowEmpty(false);
     }
 }
Beispiel #5
0
 /**
  * @param mixed $value
  * @return booleans
  */
 public function isValid($value)
 {
     $db = Zend_Db_Table::getDefaultAdapter();
     $sql = 'SELECT
             m.id
         FROM
             meeting m LEFT JOIN event e ON (m.id_event = e.id)
         WHERE
             m.ghost = false
             AND (e.latest = true OR (e.latest IS NULL AND m.id_meeting_type = 6))
             AND m.id_meeting_type IN (3,4,6)
             AND
             (
                    (' . $db->quoteInto('m.meeting_at >= ?', $this->_objectEventAt->getValue()) . ' AND ' . $db->quoteInto('m.meeting_at + (m.length * interval \'1 minute\') <= timestamp ? + interval \'' . $this->_objectLength->getValue() . ' minutes\'', $this->_objectEventAt->getValue()) . ')
                 OR (' . $db->quoteInto('m.meeting_at <= ?', $this->_objectEventAt->getValue()) . ' AND ' . $db->quoteInto('m.meeting_at >= timestamp ?', $this->_objectEventAt->getValue()) . ')
                 OR (' . $db->quoteInto('m.meeting_at <= ?', $this->_objectEventAt->getValue()) . ' AND ' . $db->quoteInto('m.meeting_at + (m.length * interval \'1 minute\') >= timestamp ? + interval \'' . $this->_objectLength->getValue() . ' minutes\'', $this->_objectEventAt->getValue()) . ')
                 OR (' . $db->quoteInto('m.meeting_at < timestamp ? + interval \'' . $this->_objectLength->getValue() . ' minutes\'', $this->_objectEventAt->getValue()) . ' AND ' . $db->quoteInto('m.meeting_at + (m.length * interval \'1 minute\') >= timestamp ? + interval \'' . $this->_objectLength->getValue() . ' minutes\'', $this->_objectEventAt->getValue()) . ')
             )
             AND ' . $db->quoteInto('m.id_user = ?', Zend_Auth::getInstance()->getIdentity()->id) . '
             AND ' . $db->quoteInto('m.id_branch = ?', Zend_Auth::getInstance()->getIdentity()->id_branch);
     if ($this->_nextEvent !== false) {
         $sql .= ' AND ' . $db->quoteInto('m.id_event <> ?', $this->_nextEvent);
     }
     $rows = $db->query($sql);
     if ($rows->rowCount() > 0) {
         $this->_error(self::VISIT_EXISTS);
         return false;
     } else {
         return true;
     }
 }
 public function buildForm()
 {
     $this->clearElements();
     $hourForm = new Zend_Form_SubForm();
     foreach ($this->data as $record) {
         $elm = new Zend_Form_Element((string) $record['id']);
         $elm->setValue($record);
         $hourForm->addElement($elm);
     }
     $this->addSubForm($hourForm, $this->key_existing);
     // add template element
     $newForm = new Zend_Form_SubForm();
     $elm = new Zend_Form_Element('__unique__');
     $newForm->addElement($elm);
     // add elements based on $_POST, (this is crap but will do for now)
     if (isset($_POST['hour_new'])) {
         foreach ($_POST['hour_new'] as $idx => $values) {
             if ($idx != '__unique__') {
                 $elm = new Zend_Form_Element($idx);
                 $elm->setValue($values);
                 $newForm->addElement($elm);
             }
         }
     }
     $this->addSubForm($newForm, $this->key_new);
 }
Beispiel #7
0
 public function renderLabel(Zend_Form_Element $element, Zend_View_Interface $view)
 {
     $label = $element->getLabel();
     if (empty($label)) {
         $label = $element->getName();
     }
     return '<div class="pointer" onClick = goToErrorLabel(\'' . $element->getId() . '\')>' . $this->getMarkupElementLabelStart() . $view->escape($label) . $this->getMarkupElementLabelEnd() . '</div>';
 }
Beispiel #8
0
 /**
  * Adds default decorators to an existing element
  * 
  * @param Zend_Form_Element $element
  */
 public static function addDefaultDecorators(Zend_Form_Element $element)
 {
     $fqName = $element->getName();
     if (null !== ($belongsTo = $element->getBelongsTo())) {
         $fqName = $belongsTo . '-' . $fqName;
     }
     $element->addDecorator('Description', array('tag' => 'p', 'class' => 'description', 'placement' => 'PREPEND'))->addDecorator('HtmlTag', array('tag' => 'div', 'id' => $fqName . '-element', 'class' => 'form-element'))->addDecorator('Label', array('tag' => 'div', 'tagOptions' => array('id' => $fqName . '-label', 'class' => 'form-label')))->addDecorator('HtmlTag2', array('tag' => 'div', 'id' => $fqName . '-wrapper', 'class' => 'form-wrapper'));
 }
Beispiel #9
0
 public function setupElement()
 {
     $element = new Zend_Form_Element('foo');
     $element->addValidator('Alnum')->addValidator('Alpha')->setView($this->getView());
     $element->isValid('abc-123');
     $this->element = $element;
     $this->decorator->setElement($element);
 }
Beispiel #10
0
 /**
  * Construit un champ de type input (générique) avec le helper de Zend correspondant a ce champ
  *
  * @brief	construit un champ générique
  * @author	francoisespinet
  * 	@param Zend_Form_Element $oElement
  */
 protected function buildInput(Zend_Form_Element $oElement, $bNoErreurs = false)
 {
     //ajout des erreurs si besoin
     if ($oElement->getAttrib(self::FORM_HAS_ERROR) && !$bNoErreurs) {
         return $this->formAddErreurChamp($oElement->renderViewHelper(), $oElement->hasErrors());
     } else {
         return $oElement->renderViewHelper();
     }
 }
Beispiel #11
0
 /**
  * @param mixed $value
  * @return booleans
  */
 public function isValid($value)
 {
     if (count($this->_object->getValue()) >= count($this->_object->getMultiOptions())) {
         return true;
     } else {
         $this->_error(self::ALL_FIELDS_NOT_CHECKED);
         return false;
     }
 }
Beispiel #12
0
 /**
  * Overrides isValid() from Zend_Validate_Interface
  *
  * @param string $value
  * @access public
  * @return bool
  */
 public function isValid($value)
 {
     if (NULL === $this->_element) {
         require_once 'Zend/Exception.php';
         throw new Zend_Exception('You must add a Zend_Form_Element to the SameAs validator prior to calling the isValid() method');
     }
     if ($value != $this->_element->getValue()) {
         $this->_error(self::NOT_THE_SAME);
         return FALSE;
     }
     return TRUE;
 }
Beispiel #13
0
 public function init()
 {
     $this->setMethod('post');
     $cat = new Zend_Form_Element_Select('G_P_CAT');
     $cat->setLabel('Kategorie: ')->addValidator('alnum')->setRequired(true)->addMultiOptions(array('Adresse' => 'Adresse', 'Falle' => 'Falle', 'Brutstätte' => 'Brutstätte'));
     $name = new Zend_Form_Element_Text('G_P_NAME');
     $name->setLabel('Name: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setRequired(true);
     $lat = new Zend_Form_Element('G_P_LAT');
     $lat->setLabel('Lat: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
     $lng = new Zend_Form_Element('G_P_LNG');
     $lng->setLabel('Lon: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
     $submit = new Zend_Form_Element_Submit('senden');
     $this->addElements(array($name, $cat, $lat, $lng, $submit));
 }
Beispiel #14
0
 public function init()
 {
     $this->setMethod('post');
     $typ = new Zend_Form_Element_Select('G_TYP');
     $typ->setLabel('Typ: ')->addValidator('alnum')->setRequired(true)->addMultiOptions(array(1 => 'Adresse', 2 => 'Falle', 3 => 'Brutstätte'));
     $name = new Zend_Form_Element_Text('G_NAME');
     $name->setLabel('Name: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setRequired(true);
     $lat = new Zend_Form_Element('G_LAT');
     $lat->setLabel('Lat: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
     $lon = new Zend_Form_Element('G_LON');
     $lon->setLabel('Lon: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
     $submit = new Zend_Form_Element_Submit('senden');
     $this->addElements(array($name, $typ, $lat, $lon, $submit));
 }
 /**
  * Extract the class names from a Zend_Form_Element if given or from the
  * base form
  *
  * @param Zend_Form_Element $element
  * @return array
  */
 protected function _getClassNames(Zend_Form_Element $element = null)
 {
     if (null !== $element) {
         return explode(' ', $element->getAttrib('class'));
     }
     return explode(' ', $this->getAttrib('class'));
 }
Beispiel #16
0
 public function __construct($spec = '', $options = '')
 {
     parent::__construct($spec, $options);
     //		$table = new AttributeDescriptor();
     //		$select = $table->select();
     //		$select->order(AttributeDescriptor::COL_NAME);
     //		$select->where(AttributeDescriptor::COL_SHOW_IN_LIST . "= ?", 1);
     //		if ($group != '') {
     //			$select->where(AttributeDescriptor::COL_GROUP . "= ?",$group);
     //		}
     //		$rowset = $table->fetchAll($select);
     //		$array = $rowset->toArray();
     //		$optArray = array(null=>'Please select');
     //
     //		foreach ($array as $value) {
     //			$optArray = $optArray + array($value[AttributeDescriptor::COL_ID]=>$value[AttributeDescriptor::COL_NAME]);
     //		}
     //		$this->setMultiOptions($optArray);
     $from = new Zend_Form_Element_Text($spec);
     $this->setIsArray(TRUE);
     $to = new Zend_Form_Element_Text($spec);
     $this->setIsArray(TRUE);
     $this->add($from);
     $this->add($to);
     //$this->
 }
Beispiel #17
0
 public function getValue($name = '')
 {
     $value = parent::getValue();
     if ($name) {
         $value = isset($value[$name]) ? $value[$name] : '';
     }
     return $value;
 }
Beispiel #18
0
 /**
  * Set an error class into element HtmlTag decorator
  *
  * @param Zend_Form_Element $element Element to 'decorate' for the error.
  * @param string $styleClass CSS class name.
  *
  * @return void
  */
 protected function setClassToAnElement(Zend_Form_Element $element, $styleClass)
 {
     $htmlTagDecorator = $element->getDecorator('HtmlTag');
     if (!empty($htmlTagDecorator)) {
         $class = $htmlTagDecorator->getOption('class');
         $htmlTagDecorator->setOption('class', $class . ' ' . $styleClass);
     }
     $element->setAttrib('class', $element->getAttrib('class') . ' ' . $styleClass);
 }
Beispiel #19
0
 public function __construct($script, $spec, $wide = true, $options = null, $class = null)
 {
     parent::__construct($spec, $options);
     if ($wide == true) {
         $this->setDecorators(array('ViewScript', array(array('element' => 'HtmlTag'), array('tag' => 'td', 'colspan' => 2)), array(array('elementTr' => 'HtmlTag'), array('tag' => 'tr', 'class' => 'snep_form_element ' . $class))));
     } else {
         $this->setDecorators(array('ViewScript', array(array('element' => 'HtmlTag'), array('tag' => 'td')), array('Label', array('tag' => 'th')), array(array('elementTr' => 'HtmlTag'), array('tag' => 'tr', 'class' => 'snep_form_element ' . $class))));
     }
     $this->getDecorator('ViewScript')->setViewScript($script);
 }
Beispiel #20
0
 public function __construct($spec, $options = null)
 {
     if (empty($options['id'])) {
         $options['id'] = '';
     }
     $options['ignore'] = true;
     parent::__construct($spec, $options);
     $this->clearDecorators();
     $this->setDecorators(array('ViewHelper'));
 }
 /**
  * Remove cookie.jar if configs change and convert form password to password element
  * @param string $section
  * @param string $namespace
  * @param unknown_type $key
  * @param Zend_Form_Element $element
  * @param Zend_Form $form
  * @param Zend_Controller_Action $controller
  */
 public function prepareConfigElement($section, $namespace, $key, Zend_Form_Element $element, Zend_Form $form, Zend_Controller_Action $controller)
 {
     // nothing to do if this isn't the right section
     if ($namespace != $this->getId()) {
         return;
     }
     // remove cookie.jar if somethings has value
     if (!$form->isErrors() && !is_null($element->getValue())) {
         $this->clearLastCheck();
     }
 }
Beispiel #22
0
 public function isValid($value, $context = null)
 {
     if ($this->isRequired()) {
         if (!array_key_exists($this->getName(), $context)) {
             throw new Glo_Exception_MissingParameter($this->getName() . " is a required parameter");
         } elseif (!$value) {
             throw new Glo_Exception_BadData($this->getName() . " cannot be null");
         }
     }
     return parent::isValid($value, $context);
 }
Beispiel #23
0
 public function render(Zend_View_Interface $view = null)
 {
     $realName = $this->getName();
     foreach ($this->_parentForm->getElements() as $key => $element) {
         if ($element === $this) {
             $realName = $key;
         }
     }
     $this->setDecorators(array(new Media_Form_Decorator_MultiFile()));
     $ticket = Centurion_Db::getSingleton('media/multiupload_ticket')->createTicket($this->_parentForm, $realName);
     $this->setAttrib('ticket', $ticket->ticket);
     return parent::render($view);
 }
Beispiel #24
0
 /**
  * Static function that adds all the elements in 1 wrapping element instead of dt, dd structure
  *
  * @param $elm
  * @return void
  */
 public static function setElementDecorator(Zend_Form_Element $elm)
 {
     $elm->addPrefixPath('Glitch_Form_Decorator', 'Glitch/Form/Decorator/', 'decorator');
     $labelSettings = array();
     if ($elm->getDecorator('Label')) {
         $labelSettings = $elm->getDecorator('Label')->getOptions();
         unset($labelSettings['tag']);
         //Tag should never be needed when you call this method
     }
     $class = 'wrapper';
     if ($elm->getAttrib('wrapperClass')) {
         $class .= ' ' . $elm->getAttrib('wrapperClass');
         $elm->setAttrib('wrapperClass', null);
     }
     if ($elm instanceof Zend_Form_Element_Hidden) {
         $class .= ' hidden';
     }
     $elm->clearDecorators()->addDecorator('Label', $labelSettings)->addDecorator('ViewHelper')->addDecorator('Description', array('escape' => false))->addDecorator('Errors')->addDecorator('Wrapper', array('tag' => 'div', 'id' => $elm->getName() . '-wrapper', 'class' => $class));
     if ($elm instanceof Zend_Form_Element_Submit) {
         $elm->removeDecorator('Label');
     }
 }
 /**
  * Constructor for element and adds validator
  *
  * @param array|string|Zend_Config $spec
  * @param null $options
  * @throws \Zend_Exception
  * @throws \Zend_Form_Exception
  */
 public function __construct($spec, $options = null)
 {
     if (empty($options['siteKey']) || empty($options['secretKey'])) {
         throw new \Zend_Exception('Site key and secret key must be specified.');
     }
     $this->_siteKey = trim($options['siteKey']);
     // trim the white space if there is any just to be sure
     $this->_secretKey = trim($options['secretKey']);
     // trim the white space if there is any just to be sure
     $this->addValidator('Recaptcha', false, array('secretKey' => $this->_secretKey));
     $this->setAllowEmpty(false);
     parent::__construct($spec, $options);
 }
Beispiel #26
0
 /**
  * Remove all decorators to the specified zend form element
  * @param \Zend_Form_Element $element the element to remove the decorators from
  */
 public function removeAllDecorators(\Zend_Form_Element $element)
 {
     $element->removeDecorator("Description");
     $element->removeDecorator("HtmlTag");
     $element->removeDecorator("Label");
     $element->removeDecorator("DtDdWrapper");
     $element->removeDecorator("Errors");
 }
Beispiel #27
0
 public function init()
 {
     $this->setMethod('post');
     $g_name = new Zend_Form_Element_Text('G_NAME');
     $g_name->setLabel('Name des Punktes: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setRequired(true);
     $lat = new Zend_Form_Element('G_LAT');
     $lat->setLabel('Lat: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
     //->setAttrib('disabled', 'true');
     $lon = new Zend_Form_Element('G_LON');
     $lon->setLabel('Lon: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
     //->setAttrib('disabled', 'true');
     $b_name = new Zend_Form_Element_Text('B_NAME');
     $b_name->setLabel('Name der Brutstaette: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setRequired(true);
     $groesse = new Zend_Form_Element('B_GROESSE');
     $groesse->setLabel('Größe: ')->setRequired(true)->addValidator('Int')->addValidator('Between', true, array(0, 100));
     $gewaesser_art = new Zend_Form_Element_Text('B_GEWAESSER_ART');
     $gewaesser_art->setLabel('Gewässer Art: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true));
     $zugang = new Zend_Form_Element_Text('B_ZUGANG');
     $zugang->setLabel('Zugang: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true));
     $bek_art = new Zend_Form_Element_Text('B_BEK_ART');
     $bek_art->setLabel('Bekämpfung Art: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true));
     $text = new Zend_Form_Element_Textarea('B_TEXT');
     $text->setLabel('Text: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setAttrib('rows', '5')->setAttrib('cols', '50');
     $submit = new Zend_Form_Element_Submit('senden');
     $this->addElements(array($g_name, $lat, $lon, $b_name, $groesse, $gewaesser_art, $zugang, $bek_art, $text, $submit));
     //Layout
     $this->addDisplayGroup(array('G_NAME', 'G_LAT', 'G_LON'), 'geopoint', array('legend' => 'Koordinaten des Punktes'));
     $contact = $this->getDisplayGroup('geopoint');
     $contact->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'openOnly' => true, 'style' => 'float:left;'))));
     $this->addDisplayGroup(array('B_NAME', 'B_GROESSE', 'B_GEWAESSER_ART', 'B_ZUGANG', 'B_BEK_ART', 'B_TEXT'), 'brutstaette', array('legend' => 'Daten zur Brutstaette'));
     $pass = $this->getDisplayGroup('brutstaette');
     $pass->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('style' => 'float:right'))));
     $this->addDisplayGroup(array('senden'), 'submitbutton', array('legend' => 'Daten Abschicken'));
     $pass = $this->getDisplayGroup('submitbutton');
     $pass->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'closeOnly' => true, 'style' => 'float:left'))));
     $this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'style' => 'width:98%')), 'Form'));
 }
 /**
  * Setup per-element properties like labels, and classes
  */
 protected function setupSingleElement(Zend_Form_Element $elm)
 {
     // determine if this element has an error. (Will be used below)
     $elmHasError = count($elm->getMessages()) > 0;
     // set element values from the language pack
     $elm->setLabel($this->lang->get('form.label.' . $elm->getName()));
     // display info about required length if validator exists
     if ($elm->getValidator('StringLength')) {
         $elm->setDescription(sprintf($this->lang->get('form.description.' . $elm->getName()), $elm->getValidator('StringLength')->getMin(), $elm->getValidator('StringLength')->getMax()));
     } else {
         $elm->setDescription($this->lang->get('form.description.' . $elm->getName()));
     }
     // Duplicating type attr to classname in case we need to support IE6
     // and want to be able to directly target the element without using
     // input[type=text]
     $zendType = $elm->getType();
     $className = strtolower(substr($zendType, strrpos($zendType, '_') + 1));
     $elm->setAttrib('class', $className);
     // wrap this stuff up in a html div with class 'element'
     $elm->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'element'));
     // determine if element has error and use that to determine prefix char.
     // 1. There seems to be no way to add html to the reqPrefix
     // 2. There seems to be no way to add a custom classname to the div tag
     if ($elm->getName() != 'submit') {
         $reqChar = $elmHasError ? '! ' : '* ';
         $elm->addDecorator('Label', array('placement' => 'prepend', 'tag' => 'div', 'requiredPrefix' => $reqChar));
     }
     // use custom error decorator that attempts to replace default error
     // messages by the ones supplied by My_LanguagaPack
     $errorDecorator = new My_Decorator_Errors();
     $errorDecorator->setLanguagePack($this->lang);
     $elm->addDecorator($errorDecorator);
     // wrap everything so far in a li tag, give it class error if elm has error
     // ATT: using array to create alias for allready used HtmlTag decorator
     $liClass = $elmHasError ? 'error' : '';
     $elm->addDecorator(array('outerLi' => 'HtmlTag'), array('tag' => 'li', 'class' => $liClass));
 }
Beispiel #29
0
 public function isValid($value, $context = null)
 {
     $result = parent::isValid($value, $context);
     if ($result) {
         $_ranges = $this->getValue();
         if (is_array($_ranges)) {
             $dateRange_validator = new Cible_Validate_DateRange('YY-mm-dd');
             $dateRange_validator->setMessages(array('dateNotYYYY-MM-DD' => Cible_Translation::getCibleText('validation_message_invalid_date_format'), 'endDateEarlier' => Cible_Translation::getCibleText('validation_message_endDate_earlier')));
             foreach ($_ranges as $_range) {
                 if (!$dateRange_validator->isValid($_range)) {
                     $this->addErrorMessages($dateRange_validator->getMessages());
                     $result = false;
                 }
             }
         }
         $errors = $this->getErrorMessages();
         $this->setErrorMessages(array_unique($errors));
     }
     return $result;
 }
Beispiel #30
0
 public function getValue($toString = true)
 {
     $value = parent::getValue();
     if (is_array($value)) {
         $xml = new SimpleXMLElement('<elementData />');
         foreach ($value as $k => $v) {
             $xml->{$k} = $v;
         }
     } else {
         $xml = simplexml_load_string($value);
     }
     if (is_object($xml)) {
         if ($toString) {
             return $xml->asXML();
         } else {
             return $xml;
         }
     } else {
         return null;
     }
 }