예제 #1
0
 private function _validate()
 {
     if ($this->action == TIP_FORM_ACTION_DELETE || $this->action == TIP_FORM_ACTION_CUSTOM) {
         // Special case: GET driven form
         $this->_form->freeze();
         return TIP::getGet('process', 'int') == 1;
     }
     // Add element and form rules
     isset($this->validator) && $this->_form->addFormRule($this->validator);
     foreach (array_keys($this->fields) as $id) {
         if ($this->_form->elementExists($id)) {
             $this->_addGuessedRules($id);
             $this->_addCustomRules($id);
         }
     }
     $stage_id = $this->id . '.stage';
     $last_stage = HTTP_Session2::get($stage_id);
     if (!$this->_form->isSubmitted() || isset($last_stage) && $last_stage < $this->_stage) {
         HTTP_Session2::set($stage_id, $this->_stage);
         $valid = false;
     } elseif (is_null($last_stage)) {
         // No last stage defined
         TIP::notifyError('double');
         $valid = null;
     } else {
         // Validation
         $this->_form->applyFilter('__ALL__', array('TIP', 'extendedTrim'));
         $valid = $this->_form->validate();
     }
     // Perform uploads (if needed)
     if (is_callable(array('HTML_QuickForm_attachment', 'doUploads'))) {
         HTML_QuickForm_attachment::doUploads($this->_form);
     }
     return $valid;
 }
예제 #2
0
파일: db.php 프로젝트: demental/m
 /**
  * Adds tag checkboxes to form passed as first parameter
  * 2nd parameter is the actual name of the fields used to add tags
  * @param HTML_QuickForm
  * @param string default _tags
  */
 public function addTagsToForm(HTML_QuickForm $form, $fieldname, DB_DataObject $obj)
 {
     $tags = DB_DataObject::factory('tag');
     $tags->archived = 0;
     // @todo add this field to tags table
     $tag_record = DB_DataObject::factory('tag_record');
     $tags->joinAdd($tag_record);
     $tags->whereAdd("tag_record.tagged_table = '" . $obj->__table . "'");
     $tags->selectAdd();
     $tags->selectAdd('tag.*');
     $tags->groupBy('tag.strip');
     if ($tags->find()) {
         while ($tags->fetch()) {
             $taglist[$tags->id] = $tags->strip;
         }
         foreach ($taglist as $id => $strip) {
             $arr[] = MyQuickForm::createElement('checkbox', $fieldname . '[' . $id . ']', '', $strip);
             $arr2[] = MyQuickForm::createElement('checkbox', 'exc_' . $fieldname . '[' . $id . ']', '', $strip);
         }
         $grp = MyQuickForm::createElement('group', $fieldname, __('Including Tags'), $arr, null, false);
         $grp2 = MyQuickForm::createElement('group', 'exc_' . $fieldname, __('Excluding Tags'), $arr2, null, false);
         if ($form->elementExists('__submit__')) {
             $form->insertElementBefore($grp, '__submit__');
             $form->insertElementBefore($grp2, '__submit__');
         } else {
             $form->addElement($grp);
             $form->addElement($grp2);
         }
     }
 }