summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--application/Bootstrap.php2
-rw-r--r--application/forms/EventAdd.php2
-rw-r--r--library/Poolctrl/Validator/DateGreaterThan.php153
3 files changed, 96 insertions, 61 deletions
diff --git a/application/Bootstrap.php b/application/Bootstrap.php
index 6f3a58e..0f62350 100644
--- a/application/Bootstrap.php
+++ b/application/Bootstrap.php
@@ -73,4 +73,4 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
}
}
-include 'Functions.php'; \ No newline at end of file
+include '../library/Poolctrl/Functions.php'; \ No newline at end of file
diff --git a/application/forms/EventAdd.php b/application/forms/EventAdd.php
index b4db7cf..af34f84 100644
--- a/application/forms/EventAdd.php
+++ b/application/forms/EventAdd.php
@@ -133,7 +133,7 @@ class Application_Form_EventAdd extends Zend_Form
'validators' => array(
array('StringLength', false, array(0, 16)),
array('Date', false, array('format' => 'mm/dd/yyyy H:i')),
- array('DateGreaterThan', false, array('min' => $this->getElement('start')->getValue())),
+ array('DateGreaterThan', false, array('element' => 'End', 'compare' => 'Start', 'min' => $this->getElement('start')->getValue())),
),
'required' => false,
'label' => 'End (mm/dd/yyyy H:min):',
diff --git a/library/Poolctrl/Validator/DateGreaterThan.php b/library/Poolctrl/Validator/DateGreaterThan.php
index f6c1316..880a7d4 100644
--- a/library/Poolctrl/Validator/DateGreaterThan.php
+++ b/library/Poolctrl/Validator/DateGreaterThan.php
@@ -6,66 +6,101 @@ class Poolctrl_Validate_DateGreaterThan extends Zend_Validate_Abstract
const NOT_GREATER = 'notGreaterThan';
protected $_messageTemplates = array(
- self::NOT_GREATER => "'%value%' has to be greater than '%min%'",
+ self::NOT_GREATER => "'%element%' has to be greater than '%compare%'",
);
protected $_messageVariables = array(
- 'min' => '_min'
- );
-
- protected $_min;
- protected $_minTimestamp;
-
- public function __construct($min)
- {
- if ($min instanceof Zend_Config) {
- $min = $min->toArray();
- }
-
- if (is_array($min)) {
- if (array_key_exists('min', $min)) {
- $min = $min['min'];
- $minTimestamp = strtotime($min);
- } else {
- require_once 'Zend/Validate/Exception.php';
- throw new Zend_Validate_Exception("Missing option 'min'");
- }
- }
-
- $this->setMin($min);
- $this->setMinTimestamp($minTimestamp);
- }
-
- public function getMin()
- {
- return $this->_min;
- }
-
- public function setMin($min)
- {
- $this->_min = $min;
- return $this;
- }
-
- public function getMinTimestamp()
- {
- return $this->_minTimestamp;
- }
-
- public function setMinTimestamp($_minTimestamp)
- {
- $this->_minTimestamp = $_minTimestamp;
- }
-
- public function isValid($value)
- {
- $this->_setValue($value);
- $valueTimestamp = strtotime($value);
-
- if ($this->getMinTimestamp() >= $valueTimestamp) {
- $this->_error(self::NOT_GREATER);
- return false;
- }
- return true;
- }
+ 'element' => '_element',
+ 'compare' => '_compare',
+ );
+
+ protected $_element;
+ protected $_compare;
+ protected $_min;
+ protected $_minTimestamp;
+
+ public function __construct($option)
+ {
+ if ($option instanceof Zend_Config) {
+ $option = $option->toArray();
+ }
+
+ if (is_array($option)) {
+ if (array_key_exists('min', $option)) {
+ $min = $option['min'];
+ $minTimestamp = strtotime($min);
+ } else {
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception("Missing option 'min'");
+ }
+ if (array_key_exists('element', $option)) {
+ $element = $option['element'];
+ } else {
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception("Missing option 'compare'");
+ }
+ if (array_key_exists('compare', $option)) {
+ $compare = $option['compare'];
+ } else {
+ require_once 'Zend/Validate/Exception.php';
+ throw new Zend_Validate_Exception("Missing option 'compare'");
+ }
+ }
+
+ $this->setMin($min);
+ $this->setMinTimestamp($minTimestamp);
+ }
+
+ public function getElement()
+ {
+ return $this->_element;
+ }
+
+ public function setElement($element)
+ {
+ $this->_element = $element;
+ }
+
+ public function getCompare()
+ {
+ return $this->_compare;
+ }
+
+ public function setCompare($compare)
+ {
+ $this->_compare = $compare;
+ }
+
+ public function getMin()
+ {
+ return $this->_min;
+ }
+
+ public function setMin($min)
+ {
+ $this->_min = $min;
+ return $this;
+ }
+
+ public function getMinTimestamp()
+ {
+ return $this->_minTimestamp;
+ }
+
+ public function setMinTimestamp($minTimestamp)
+ {
+ $this->_minTimestamp = $minTimestamp;
+ }
+
+ public function isValid($value)
+ {
+ $this->_setValue($value);
+ $valueTimestamp = strtotime($value);
+
+ if ($this->getMinTimestamp() >= $valueTimestamp) {
+ $this->_error(self::NOT_GREATER);
+ return false;
+ }
+ return true;
+ }
} \ No newline at end of file