コード例 #1
0
ファイル: decimal.php プロジェクト: openly/Openjuice-Package
 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;
 }
コード例 #2
0
ファイル: currency.php プロジェクト: openly/Openjuice-Package
 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;
 }
コード例 #3
0
ファイル: integer.php プロジェクト: openly/Openjuice-Package
 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;
 }
コード例 #4
0
ファイル: email.php プロジェクト: openly/Openjuice-Package
 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;
 }
コード例 #5
0
ファイル: required.php プロジェクト: openly/Openjuice-Package
 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;
 }
コード例 #6
0
ファイル: field.php プロジェクト: openly/Openjuice-Package
 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;
     }
 }
コード例 #7
0
 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";
     }
 }
コード例 #8
0
 public function setFields($fields)
 {
     $this->_requiredFields = OJUtil::confArrToHash($fields);
 }
コード例 #9
0
ファイル: form.php プロジェクト: openly/Openjuice-Package
 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;
             }
         }
     }
 }
コード例 #10
0
 /**
  * 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);
 }
コード例 #11
0
 /**
  * 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;
 }
コード例 #12
0
ファイル: mysql_qb.php プロジェクト: openly/Openjuice-Package
 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);
 }