Beispiel #1
0
 public function validate($args)
 {
     $valueToTest = $args[$this->getDisplayFieldName()];
     if (!OJUtil::checkNotBlank($valueToTest) || preg_match('/^\\+?-?\\d+\\.+\\d*$/', $valueToTest)) {
         return true;
     }
     $this->error = array('message' => t('Field "%s" is not a vaild Decimal number.', $this->label), 'name' => $this->fieldName);
     return false;
 }
Beispiel #2
0
 public function validate($args)
 {
     $valueToTest = $args[$this->getDisplayFieldName()];
     if (!OJUtil::checkNotBlank($valueToTest) || preg_match('/^\\$?.?.?.?[1-9]\\d*(?:\\.?\\d{0,2})?$/', $valueToTest)) {
         return true;
     }
     $this->error = array('message' => t('Field "%s" is not a vaild currency.', $this->label), 'name' => $this->fieldName);
     return false;
 }
Beispiel #3
0
 public function validate($args)
 {
     $valueToTest = $args[$this->getDisplayFieldName()];
     if (!OJUtil::checkNotBlank($valueToTest) || $this->isInteger($valueToTest)) {
         return true;
     }
     $this->error = array('message' => t('Field "%s" is not an integer.', $this->label), 'name' => $this->fieldName);
     return false;
 }
Beispiel #4
0
 public function validate($args)
 {
     $valueToTest = $args[$this->getDisplayFieldName()];
     if (!OJUtil::checkNotBlank($valueToTest) || preg_match('/^([a-zA-Z0-9])+([a-zA-Z0-9\\._-])*@([a-zA-Z0-9\\._-])+.([a-zA-Z0-9\\._-]+)+$/', $valueToTest)) {
         return true;
     }
     $this->error = array('message' => t('Field "%s" is not a vaild email address.', $this->label), 'name' => $this->fieldName);
     return false;
 }
Beispiel #5
0
 public function validate($args)
 {
     //	var_dump($args);
     if (OJUtil::checkNotBlank($args[$this->getDisplayFieldName()])) {
         return true;
     }
     $this->error = array('message' => t('Field "%s" is required.', $this->label), 'name' => $this->fieldName);
     return false;
 }
Beispiel #6
0
 public function setVars(&$hash)
 {
     if (OJUtil::checkNotBlank($hash['name'])) {
         $this->fieldName = $hash['name'];
     } else {
         throw new Exception("Field name cannot be blank", 1);
     }
     $this->label = $hash['name'];
     foreach ($hash as $key => $val) {
         $this->{$key} = $val;
     }
 }
 public function initialize()
 {
     parent::initialize();
     if ($this->model != NULL) {
         $relationModel = new $this->model();
         $values = $relationModel->getDistinctRows($this->filter, $this->requiredArgs);
         if (is_null($values)) {
             $values = array();
         }
         OJUtil::array_unshift_assoc($values, '0', '- Select -');
         $form = Loader::helper('form');
         $this->field = $form->select($this->getDisplayFieldName(), $values, $this->default, $this->fieldAttrs);
     } else {
         $this->field = "Model Name not defined properly for the model-drop-down field";
     }
 }
 public function setFields($fields)
 {
     $this->_requiredFields = OJUtil::confArrToHash($fields);
 }
Beispiel #9
0
 private function includeValidators()
 {
     $fileHelper = Loader::helper('file');
     foreach (OJUtil::getIncludeDirs('validators') as $dir) {
         foreach ($fileHelper->getDirectoryContents($dir) as $file) {
             if (preg_match('/\\.php$/', $file)) {
                 require_once $dir . '/' . $file;
             }
         }
     }
 }
 /**
  * init
  * 
  * @param mixed $model Description.
  *
  * @access private
  *
  * @return mixed Value.
  */
 private function init($model)
 {
     if ($this->isPost()) {
         $model->process();
         if ($model->getForm()->hasErrors()) {
             $this->set('error', OJUtil::getErrorsList($model->getForm()->getErrors()));
         } else {
             $status = $model->getStatus();
             if ($this->listURL != null && ($status == 'Added' || $status == 'Updated')) {
                 $this->redirect($this->listURL);
             }
         }
     }
     $this->form = $model->getForm();
     $this->form->setFieldTemplate($this->fieldTemplate);
 }
 /**
  * getListHeaders
  * 
  * @param mixed $args Description.
  *
  * @access protected
  *
  * @return mixed Value.
  */
 protected function getListHeaders($args = null)
 {
     if (!$args) {
         $args = $_GET;
     }
     $mfields = $this->getModelObj()->getFields();
     $headers = array();
     foreach ($this->fieldsToShow as $fieldName => $customizations) {
         $sortFieldname = str_replace('.', '_', $fieldName);
         // Make usre we are using right sql for sorting
         $thisColSorted = $args['sort_col'] == $sortFieldname;
         $thisSortDesc = $thisColSorted && $args['sort_dir'] == 'desc';
         $sortDir = $thisSortDesc ? 'asc' : 'desc';
         $class = $thisColSorted ? 'ccm-results-list-active-sort-' . $args['sort_dir'] : '';
         list($fName) = explode('.', $fieldName);
         $headers[] = array('label' => OJUtil::thisOrThat($customizations, $mfields[$fName], 'label'), 'hasSort' => !$customizations['no_sort'], 'sort_link' => OJUtil::queryLink($_GET, array('sort_col' => $sortFieldname, 'sort_dir' => $sortDir)), 'class' => $class);
     }
     if ($this->showDelete) {
         $headers[] = array('label' => '', 'hasSort' => false);
     }
     return $headers;
 }
Beispiel #12
0
 protected function getFilter()
 {
     if (OJUtil::isAssoc($this->_filters)) {
         $this->_args = array_merge($this->_args, array_values($this->_filters));
         return implode('=? AND ', array_keys($this->filters)) . '=?';
     } else {
         if (is_array($this->_filters)) {
             $filterStr = implode(' AND ', $this->_filters);
         } else {
             if (is_string($this->_filters)) {
                 $filterStr = $this->_filters;
             } else {
                 $filterStr = '1=1';
             }
         }
     }
     preg_match_all('/\\{\\{(.*?)\\}\\}/', $filterStr, $matches);
     $this->hasNull = false;
     foreach ($matches[1] as $match) {
         // 0 has all the matches and 1 and later will have groups
         //echo "HERE: " . implode(", ", array_values($this->_unsortedArgs));echo $match . '<br />';
         if ($this->_unsortedArgs[$match] == null) {
             $this->hasNull = true;
         }
         $this->_args[] = $this->_unsortedArgs[$match];
     }
     return preg_replace('/\\{\\{.*?\\}\\}/', '?', $filterStr);
 }