Exemple #1
0
 public function doExecApplier()
 {
     $form = new MyQuickForm('applyform', 'POST', M_Office::URL());
     $opts = M::tablesWithPlugin('tag');
     $opts = array_combine($opts, $opts);
     $form->addElement('select', 'table', 'Table', $opts);
     $form->addElement('textarea', 'clause', 'clause', 'rows="4" cols="60"');
     $form->addElement('text', 'tagname', 'tagname');
     $form->addElement('text', 'tagdel', 'tagdel');
     $form->addElement('checkbox', 'distinct', 'distinct');
     $form->addElement('submit', '__submit__', 'Apply');
     $form->addFormRule(array($this, 'checkApplier'));
     if ($form->validate()) {
         @set_time_limit(0);
         ini_set('memory_limit', '1024M');
         $values = $form->exportValues();
         $t = DB_DataObject::factory($values['table']);
         $query = 'SELECT ' . ($values['distinct'] ? 'DISTINCT ' : ' ') . $values['table'] . '.* FROM ' . $values['table'] . ' ' . $values['clause'];
         $t->query($query);
         while ($t->fetch()) {
             if ($values['tagname']) {
                 $t->addTag($values['tagname']);
             }
             if ($values['tagdel']) {
                 $t->removeTag($values['tagdel']);
             }
             $applied++;
         }
         $this->assign('success', 1);
         $this->assign('applied', $applied);
     }
     $this->assign('form', $form);
 }
Exemple #2
0
 function &_createSelectBox($fieldName, $options, $multiple = false)
 {
     if ($multiple) {
         $element = MyQuickForm::createElement($this->_getQFType('multiselect'), $this->_fb->getFieldName($fieldName), $this->_fb->getFieldLabel($fieldName), $options, array('multiple' => 'multiple'));
     } else {
         $element = MyQuickForm::createElement($this->_getQFType('select'), $this->_fb->getFieldName($fieldName), $this->_fb->getFieldLabel($fieldName), $options);
         $attr = $this->_getAttributes('select', $fieldName);
         $element->updateAttributes($attr);
         if (isset($this->linkNewValue[$fieldName])) {
             $links = $this->_fb->_do->links();
             if (isset($links[$fieldName])) {
                 list($table, ) = explode(':', $links[$fieldName]);
                 $element->addOption($this->linkNewValueText, $this->linkNewValueText);
                 $element->updateAttributes(array('onchange' => 'db_do_fb_' . $this->_fb->getFieldName($fieldName) . '__subForm_display(this)'));
                 $element->updateAttributes(array('id' => $element->getName()));
                 $this->_prepareForLinkNewValue($fieldName, $table);
                 $subFormElement = self::createElement($this->_getQFType('subForm'), $this->_fb->getFieldName($fieldName) . '__subForm', '', $this->_linkNewValueForms[$fieldName]);
                 $subFormElement->setPreValidationCallback(array(&$subFormElement, 'preValidationCallback'));
                 $subFormElement->linkNewValueText = $this->linkNewValueText;
                 $subFormElement->selectName = $this->_fb->getFieldName($fieldName);
                 $el =& $this->_form->addElement('hidden', $this->_fb->getFieldName($fieldName) . '__subForm__displayed');
                 $el->updateAttributes(array('id' => $el->getName()));
                 $element = MyQuickForm::createElement('group', $this->_fb->getFieldName($fieldName), $this->_fb->getFieldLabel($fieldName), array($element, $subFormElement), '', false);
             }
         }
     }
     return $element;
 }
Exemple #3
0
 function preGenerateForm(&$fb, &$obj)
 {
     $info = $obj->_getPluginsDef();
     $info = $info['images'];
     HTML_QuickForm::registerElementType('imagefile', 'HTML/QuickForm/imagefile.php', 'HTML_QuickForm_imagefile');
     foreach ($info as $k => $v) {
         $v = key_exists(0, $v) ? $v[0] : $v;
         switch (true) {
             case $v['x'] && $v['y']:
                 $newSize = $v['x'] . ' X ' . $v['y'] . ' pixels';
                 break;
             case $v['x'] && !$v['y']:
                 $newSize = $v['x'] . ' ' . __('pixels wide (proportions kept)');
                 break;
             case !$v['x'] && $v['y']:
                 $newSize = $v['y'] . ' ' . __('pixels high (proportions kept)');
                 break;
             default:
                 $newSize = '';
                 break;
         }
         $obj->fb_fieldLabels[$k] = array($obj->fb_fieldLabels[$k], 'note' => $newSize ? '. ' . __('Image will be resized to %s', array($newSize)) : '');
         if (!empty($obj->{$k})) {
             //TODO move this to postGenerateForm (like in upload plugin)
             $obj->fb_fieldLabels[$k]['unit'] = '<input type="checkbox" name="__image_delete_' . $k . '" value="1" />' . __('Delete current');
         }
         $obj->fb_preDefElements[$k] =& MyQuickForm::createElement('imagefile', $obj->fb_elementNamePrefix . $k . $obj->fb_elementNamePostfix, $obj->fb_fieldLabels[$k], array('showimage' => $v['showimage']), SITE_URL . WWW_IMAGES_FOLDER . $info[$k][0]['path'] . '/');
     }
 }
 public function __construct()
 {
     MyQuickForm::MyQuickForm('form_querypasswd', 'post', APP_BASE_URL . 'begin/query_password', '', '', true);
     $this->applyFilter('__ALL__', 'trim');
     $this->addElement('password', 'passwd', 'Passwort:', array('class' => 'cls-input-password'));
     $this->registerRule('cbPasswordMustMatch', 'callback', 'cbPasswordMustMatch', $this);
     $this->addRule('passwd', 'Das Passwort ist falsch!', 'cbPasswordMustMatch');
 }
Exemple #5
0
 public function preGenerateForm(&$fb, &$obj)
 {
     $uploadFields = $obj->_getPluginsDef();
     $uploadFields = $uploadFields['upload'];
     $upFields = array_keys($uploadFields);
     foreach ($upFields as $k) {
         $obj->fb_preDefElements[$k] = MyQuickForm::createElement('file', $obj->fb_elementNamePrefix . $k . $obj->fb_elementNamePostfix, $obj->fb_fieldsLabel[$k]);
     }
 }
 public function __construct()
 {
     MyQuickForm::MyQuickForm('form_begin', 'post', APP_BASE_URL . 'begin', '', '', true);
     $this->applyFilter('__ALL__', 'trim');
     $this->addElement('text', 'bogen_id', '', array('class' => 'cls-input-bogen-id'));
     $this->registerRule('cbBogenIdMustBeValid', 'callback', 'cbBogenIdMustBeValid', $this);
     $this->addRule('bogen_id', 'Ung&uuml;tige Bogen-ID!', 'cbBogenIdMustBeValid');
     $this->addRule('bogen_id', 'Bitte gib eine Bogen-ID ein!', 'required');
 }
 public function __construct()
 {
     MyQuickForm::MyQuickForm('form_setpasswd', 'post', APP_BASE_URL . 'begin/set_password', '', '', true);
     $this->applyFilter('__ALL__', 'trim');
     $this->addElement('hidden', 'bogen_id', $_SESSION['bogen_id']);
     $this->addElement('password', 'pw1', 'Neues Passwort:', array('class' => 'cls-input-password'));
     $this->addElement('password', 'pw2', 'Passwort wiederholen:', array('class' => 'cls-input-password'));
     $this->addRule('pw1', 'Das Passwort muss mindestens 5 Zeichen lang sein', 'minlength', 5);
     $this->addRule(array('pw1', 'pw2'), 'Die eingegebenen Passw&ouml;rter stimmen nicht &uuml;berein', 'compare');
     $this->registerRule('cbBogenIdMustMatch', 'callback', 'cbBogenIdMustMatch', $this);
     $this->addRule('bogen_id', 'Die Bogen-ID muss passen!', 'cbBogenIdMustMatch');
 }
Exemple #8
0
 public function abschliessen()
 {
     for ($i = 0; $i < count($this->questionCollection->questionPages); $i++) {
         if (!$_SESSION['pages_filled'][$i + 1]) {
             header("Location: " . APP_BASE_URL . "fragen/seite/" . ($i + 1));
         }
     }
     $tmvc = tmvc::instance();
     $form = new MyQuickForm('form_finish', 'post', APP_BASE_URL . 'fragen/abschliessen', '', '', true);
     if ($form->validate()) {
         DBfunctions::getInstance()->doSingleCall("DELETE FROM t_person_properties WHERE person_id=?", "i", $_SESSION['person_id']);
         foreach ($_SESSION['properties'] as $prop => $val) {
             DBfunctions::getInstance()->doSingleCall("INSERT INTO t_person_properties(person_id, property, value) VALUES (?, ?, ?)", "iss", $_SESSION['person_id'], $prop, $val);
         }
         DBfunctions::getInstance()->doSingleCall("UPDATE t_persons SET submitted_at=NOW() WHERE id=?", "i", $_SESSION['person_id']);
         $form->resetToken();
         header("Location: " . APP_BASE_URL . "ende");
     } else {
         $form->addReloadLock();
         $form->assignToSmarty($tmvc->smarty);
         $tmvc->smarty->assign('content', $this->questionCollection->buildOutput($tmvc->smarty));
         $tmvc->smarty->display();
     }
 }
Exemple #9
0
 public function __construct($module)
 {
     parent::__construct();
     $this->assign('__action', 'add');
     $tpl = Mreg::get('tpl');
     $tpl->concat('adminTitle', ' :: ' . $this->moduloptions['title'] . ' :: ' . __('Add record'));
     $mopts = PEAR::getStaticProperty('m_office', 'options');
     $mopt = $mopts['modules'][$module];
     $table = $mopt['table'];
     $do = M_Office_Util::doForModule($module);
     $this->append('subActions', '<a href="' . M_Office_Util::getQueryParams(array(), array('record', 'doSingleAction')) . '">' . __('Go to the %s list', array($mopt['title'])) . '</a>');
     $formBuilder =& MyFB::create($do);
     //	linkNewValue creates an issue if some linked elements are put in predefgroups
     //        $formBuilder->linkNewValue = true;
     $form = new MyQuickForm('editRecord', 'POST', M_Office_Util::getQueryParams(array(), array(), false), '_self', null, true);
     $form->addElement('hidden', 'submittedNewRecord', 1);
     if (isset($_REQUEST['filterField'])) {
         $form->addElement('hidden', 'filterField', $_REQUEST['filterField']);
         $form->addElement('hidden', 'filterValue', $_REQUEST['filterValue']);
         $do->{$_REQUEST['filterField']} = $_REQUEST['filterValue'];
     }
     $links = $do->links();
     if (key_exists($_REQUEST['filterField'], $links)) {
         $linfo = explode(':', $links[$_REQUEST['filterField']]);
         $form->addElement('static', 'mod', '', __('Add record with %s = %s', array($_REQUEST['filterField'], $_REQUEST['filterValue'])) . '. ' . '<a href="' . M_Office_Util::getQueryParams(array('table' => $linfo[0], 'record' => $_REQUEST['filterValue']), array('addRecord', 'filterField', 'filterValue')) . '">' . __('Back to main record') . '</a>');
     }
     $formBuilder->useForm($form);
     $formBuilder->getForm();
     if ($this->getOption('createAnother', $table)) {
         $form->addElement('static', '&nbsp;', '&nbsp;');
         $form->addElement('checkbox', 'returnHere', __('Create another record'));
         if (isset($_REQUEST['returnHere']) && $_REQUEST['returnHere']) {
             $form->setDefaults(array('returnHere' => true));
         }
     }
     M_Office_Util::addHiddenFields($form);
     if ($form->validate()) {
         if (PEAR::isError($ret = $form->process(array(&$formBuilder, 'processForm'), false))) {
             $this->append('error', __('An error occured while inserting record') . ' : ' . $ret->getMessage());
         } else {
             $pk = DB_DataObject_FormBuilder::_getPrimaryKey($do);
             $this->say(__('New record was successfully created. Its identifier is : %s', array($do->{$pk})));
             if ($this->getOption('createAnother', $table) && isset($_REQUEST['returnHere']) && $_REQUEST['returnHere']) {
                 M_Office_Util::refresh(M_Office_Util::getQueryParams(array('returnHere' => $_REQUEST['returnHere']), array(), false));
             } else {
                 $pk = DB_DataObject_FormBuilder::_getPrimaryKey($do);
                 M_Office_Util::refresh(M_Office_Util::getQueryParams(array('record' => $do->{$pk}), array('returnHere', 'addRecord'), false));
             }
         }
     } elseif ($form->isSubmitted()) {
     }
     $this->assign('addForm', $form);
     $this->assign('do', $do);
 }
Exemple #10
0
 public function after_form($form, $fb)
 {
     $obj = $fb->_do;
     $defs = $obj->_getPluginsDef();
     $defs = $defs['user'];
     if ($form->elementExists($fb->elementNamePrefix . $defs['pwd'] . $fb->elementNamePostfix)) {
         $pwd = $form->getElement($fb->elementNamePrefix . $defs['pwd'] . $fb->elementNamePostfix);
         $pwd->setLabel($obj->fb_fieldLabels[$defs['pwd']] . __('(Vérification)'));
         $pwd->setValue('');
         $pwd2 = MyQuickForm::createElement('password', $fb->elementNamePrefix . $defs['pwd'] . '2' . $fb->elementNamePostfix, $obj->fb_fieldLabels[$defs['pwd']]);
         if (empty($obj->id)) {
             $form->addRule($fb->elementNamePrefix . $defs['pwd'] . $fb->elementNamePostfix, __('user.register.error.required_password'), 'required');
             $form->addRule($fb->elementNamePrefix . $defs['pwd'] . '2' . $fb->elementNamePostfix, __('user.register.error.required_password'), 'required');
         }
         $form->insertElementBefore($pwd2, $fb->elementNamePrefix . $defs['pwd'] . $fb->elementNamePostfix);
         $form->addRule(array($fb->elementNamePrefix . $defs['pwd'] . '2' . $fb->elementNamePostfix, $fb->elementNamePrefix . $defs['pwd'] . $fb->elementNamePostfix), __('user.register.error.unmatched_password'), 'compare');
         $form->addFormRule(array($this, 'checkUniqueLogin'));
     }
     $form->setDefaults(array($fb->elementNamePrefix . $defs['pwd'] . $fb->elementNamePostfix => '', $fb->elementNamePrefix . $defs['pwd'] . '2' . $fb->elementNamePostfix => ''));
     $this->_obj = $fb->_do;
 }
Exemple #11
0
 /**
  * Creates the form for action parameters, if params are required for the current action
  * @return null if no param
  * @return HTML_QuickForm if params
  */
 public function createParamsForm()
 {
     $tpl = Mreg::get('tpl');
     $tpl->concat('adminTitle', ' :: ' . $this->getActionTitle());
     if ($this->actiondo instanceof M_Plugin) {
         $tpl->addPath('M/DB/DataObject/Plugin/' . $this->actiondo->getFolderName() . '/templates/', 'before');
     }
     $prepareMethod = 'prepare' . $this->actionName;
     if (method_exists($this->actiondo, $prepareMethod) || is_array($this->_actionInfo['chainable'])) {
         $qfAction = new MyQuickForm('actionparamsForm', 'POST', M_Office_Util::getQueryParams(array(), array('selected', 'doaction', 'glaction', 'doSingleAction'), false), '_self', null, true);
         Mreg::get('tpl')->addJSinline('$("input[type=text],textarea","form[name=actionparamsForm]").eq(0).focus()', 'ready');
         Mreg::get('tpl')->assign('do', $do);
         $qfAction->addElement('header', 'qfActionHeader', $this->getActionTitle());
         $qfAction->addElement('hidden', $this->typeval, $this->actionName);
         $qfAction->addElement('hidden', '__actionscope', $this->scope);
         if ($this->scope == 'selected') {
             M_Office_Util::addHiddenField($qfAction, 'selected', $this->getSelectedIds());
         }
         $selectedDo = $this->getSelected(true);
         if ('single' == $this->type) {
             $selectedDo->fetch();
         }
         if (method_exists($this->actiondo, $prepareMethod)) {
             if (is_a($this->actiondo, 'M_Plugin')) {
                 call_user_func(array($this->actiondo, $prepareMethod), $qfAction, $selectedDo);
             } else {
                 call_user_func(array($selectedDo, $prepareMethod), $qfAction);
             }
         }
         if ($this->_actionInfo['chainable'] && count($this->nextactions) == 0) {
             $qfAction->addElement('select', '__nextaction', __('Execute this action then ...'), array_merge(array('' => ''), $this->getNextActions()));
         }
         if (count($this->nextactions) > 0) {
             $qfAction->addElement('hidden', '__actionchain', implode(',', $this->nextactions));
         }
         $qfAction->addElement('submit', '__submit__', __('Execute'));
         return $qfAction;
     } else {
         return null;
     }
 }
Exemple #12
0
 public function preGenerateForm(&$fb, &$obj)
 {
     $obj->fb_preDefElements['filename'] = MyQuickForm::createElement('file', $obj->fb_elementNamePrefix . 'filename' . $obj->fb_elementNamePostfix, $obj->fb_fieldsLabel['filename']);
 }
Exemple #13
0
 public function postPrepareSearchForm($form, $obj)
 {
     $archiver_archived = MyQuickForm::createElement('select', 'archiver_archived', __('Archived'), array('' => __('No'), 'B' => __('Both'), 'O' => __('Yes')));
     $form->insertElementBefore($archiver_archived, '__submit__');
 }
Exemple #14
0
 function postGenerateReminder(&$form, &$fb)
 {
     $do = $fb->_do;
     $defs = $do->_getPluginsDef();
     $defs = $defs['user'];
     $elt = MyQuickForm::createElement('static', 'remindertext', '', __('user.reminder.text'));
     $form->insertElementBefore($elt, $fb->elementNamePrefix . $defs['email'] . $fb->elementNamePostfix);
 }
Exemple #15
0
 public function testWithNamePrefix()
 {
     T::setLang('fr');
     $t = DB_DataObject::factory('formtest');
     $t->fb_elementNamePrefix = 'test';
     $fb = MyFB::create($t);
     $form = new MyQuickForm('testform', 'POST', M_Office::URL());
     $post = array_merge($form->exportValues(), array('testtitre_group' => array('testtitre_fr' => 'Test titre', 'testtitre_en' => 'title', 'testtitre_es' => 'titulo'), 'testdescription_group' => array('testdescription_fr' => 'Nouv desc 2 FR', 'testdescription_en' => null, 'testdescription_es' => 'Nueva desc 2 ES'), 'testpays' => 'ma', 'testtestuser_id' => 1, '_qf__' . $form->getAttribute('name') => 1, 'testi18n_id_fr' => '', 'testi18n_id_en' => '', 'testi18n_id_es' => '', 'testid' => ''));
     $get = $_GET;
     $request = array_merge($get, $post);
     $form->initRequest($get, $post, $request);
     $fb->useForm($form);
     $fb->getForm();
     $form->validate();
     $form->process(array($fb, 'processForm'), false);
     T::setLang('es');
     $t2 = DB_DataObject::factory('formtest');
     $t2->get($t->id);
     $this->assertEqual($t2->titre, 'titulo');
     T::setLang('en');
     $t2 = DB_DataObject::factory('formtest');
     $t2->get($t->id);
     $this->assertEqual($t2->titre, 'title');
 }
Exemple #16
0
 function &getAddFormObject($record = null)
 {
     if (is_null($record)) {
         $record = $this->getObject();
     }
     if (!$record->isNew()) {
         $formaction = 'updateFromTableRecord';
         $formclass = 'updateFromTableForm';
         $formactionval = $record->pk();
         $formname = 'addFromTable__' . $this->table . $record->pk();
         $update = $this->table . $record->pk();
         $sub = "OK";
     } else {
         $formaction = 'addFromTableRecord';
         $formclass = 'addFromTableForm';
         $formactionval = 1;
         $formname = 'addFromTable__' . $this->table;
         $update = 'endList__' . $this->table;
         $sub = "+";
     }
     $form = new MyQuickForm($formname, 'POST', M_Office_Util::getQueryParams(array('module' => $this->table, 'filterField' => $this->field, 'filterValue' => $this->value, $formaction => $formactionval, 'ajaxfromtable' => 1), array_keys($_REQUEST), false));
     $form->updateAttributes(array('class' => $formclass, 'target' => $update));
     Mtpl::addJS('jquery.form');
     $record->fb_requiredRuleMessage = __('The field "%s" is required');
     $record->fb_ruleViolationMessage = __('The field "%s" is not valid');
     $record->fb_formAddHeader = true;
     $record->fb_createSubmit = false;
     $record->fb_submitText = $sub;
     $this->fb =& MyFB::create($record);
     $this->fb->useForm($form);
     $this->fb->getForm();
     if ($form->elementExists($this->field)) {
         $form->removeElement($this->field);
     }
     $form->addElement('submit', '__submit__', '+');
     $form->addElement('hidden', $this->field, $this->value);
     //        $form->addElement('static','st','','<pre>'.print_r($_REQUEST,true).'</pre>');
     return $form;
 }
Exemple #17
0
 /**
  * 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);
         }
     }
 }
Exemple #18
0
 public static function &getSearchForm($do, $module)
 {
     MyQuickForm::registerElementType('advandate', 'HTML/QuickForm/advandate.php', 'HTML_QuickForm_advandate');
     $form = new MyQuickForm('formSearch', 'GET', self::getQueryParams(array(), array('page', '_c_'), false));
     $fields = $_GET;
     unset($fields['_c_']);
     unset($fields['page']);
     unset($fields['module']);
     unset($fields['action']);
     unset($fields['filterField']);
     unset($fields['filterValue']);
     if (count($fields) == 0) {
         Log::info('caching search form');
         $cache = true;
     } else {
         Log::info('NO SEARCH FORM CACHING');
         $cache = false;
     }
     $cacheName = 'searchform_' . $module;
     $options = array('caching' => $cache, 'cacheDir' => APP_ROOT . 'app/' . APP_NAME . '/cache/forms/', 'lifeTime' => 3600, 'fileNameProtection' => false);
     $cache = new Cache_Lite($options);
     if ($_cachedData = $cache->get($cacheName)) {
         Mreg::append('autoloadcallback', array(array('MyQuickForm', 'autoloadElements')));
         $_cachedData = unserialize($_cachedData);
         foreach ($_cachedData as $element) {
             $form->addElement($element);
         }
     } else {
         $do->fb_selectAddEmpty = array();
         if (is_array($do->links())) {
             foreach ($do->links() as $field => $link) {
                 $do->fb_selectAddEmpty[] = $field;
             }
         }
         if (is_array($do->fb_enumFields)) {
             foreach ($do->fb_enumFields as $field) {
                 $do->fb_selectAddEmpty[] = $field;
             }
         }
         $do->fb_formHeaderText = __('Search');
         $do->fb_submitText = '>>';
         $do->fb_linkNewValue = false;
         $formBuilder =& MyFB::create($do);
         $formBuilder->_cacheOptions = array('name' => 'office_searchform', 'cacheDir' => APP_ROOT . 'app/' . APP_NAME . '/cache/forms/');
         $formBuilder->preGenerateFormCallback = array($do, 'prepareSearchForm');
         $do->prepareSearchForm($fb);
         $do->fb_userEditableFields = $do->fb_fieldsToRender;
         $table = $do->table();
         foreach ($do->fb_fieldsToRender as $field) {
             if ($table[$field] & DB_DATAOBJECT_DATE || $table[$field] & DB_DATAOBJECT_TIME) {
                 $label = $do->fb_fieldLabels[$field] ? $do->fb_fieldLabels[$field] : $field;
                 $do->fb_preDefElements[$field] = MyQuickForm::createElement('advandate', $field, $label, array("language" => T::getLang()));
             }
         }
         $formBuilder->postGenerateFormCallback = array($do, 'postPrepareSearchForm');
         $formBuilder->useForm($form);
         $formBuilder->getForm();
         foreach ($form->_elements as $elem) {
             $cached[] = $elem;
         }
         if ($cache) {
             $cache->save(serialize($cached));
         }
     }
     $form->_rules = array();
     $form->_formRules = array();
     $form->_required = array();
     self::addHiddenFields($form, array('search', 'page', '__dontpaginate', '_c_'), true);
     $form->addElement('checkbox', '__dontpaginate', 'Afficher les résultats sur une seule page');
     return $form;
 }
Exemple #19
0
 public function postGenerateFormGrouped($form, $fb, $info, $langs, $obj)
 {
     $lang = $langs[0];
     $elements = $obj->_i18nfbs[$lang]->_reorderElements();
     if (is_array($obj->fb_fieldsToRender)) {
         $iFields = array_intersect($info, $obj->fb_fieldsToRender);
     } else {
         $iFields = $info;
     }
     $allLangs = array_diff($langs, array($this->getDefaultLang($obj)));
     array_unshift($allLangs, $this->getDefaultLang($obj));
     $langs = $allLangs;
     foreach ($iFields as $field) {
         $fields = array();
         foreach ($langs as $lang) {
             $completename = $obj->fb_elementNamePrefix . $field . $obj->fb_elementNamePostfix;
             $elem = $form->getElement($completename . '_' . $lang);
             $elem->setAttribute('rel', $completename);
             if ($lang == $this->getDefaultLang($obj)) {
                 $class = 'translatesource field_' . $lang;
                 $id = 'autotransid_' . $completename;
             } else {
                 $class = 'autotranslate source_autotransid_' . $completename . ' field_' . $lang;
                 $id = 'autotransid_' . $completename . '_' . $lang;
             }
             $elem->setAttribute('class', $elem->getAttribute('class') . ($elem->getAttribute('class') ? ' ' : '') . $class);
             $elem->setAttribute('id', $id);
             $label = $elem->getLabel();
             if (is_array($label)) {
                 $sublabel = $label[0];
             } else {
                 $sublabel = $label;
             }
             $elem->setLabel($sublabel . '(' . $lang . ')');
             $fields[] = $elem;
             $form->removeElement($completename . '_' . $lang);
         }
         if (!$form->elementExists('__submit__')) {
             $form->addElement('group', $completename . '_group', $label, $fields, '');
         } else {
             $form->insertElementBefore(MyQuickForm::createElement('group', $completename . '_group', $label, $fields), '__submit__');
         }
         if (in_array($field, $fb->fieldsRequired) || $elements[$field] & DB_DATAOBJECT_NOTNULL) {
             $form->addGroupRule($completename . '_group', $fb->requiredRuleMessage, 'required', null, 1);
         }
     }
 }