31 if ( $instance === 0 ){
95 $widget =&
$field[
'widget'];
99 if ( isset($widgetHandler) and method_exists($widgetHandler,
'pullField') ){
100 return $widgetHandler->pullField($record,
$field, $form, $formFieldName, $new);
107 'scripts.Dataface.QuickForm.pullField.ERROR_NO_ACCESS_TO_FIELD',
108 "No read access on field '$field[name]'",
109 array(
'fieldname'=>
$field[
'name'])
116 $raw = $record->getValue(
$field[
'name']);
118 $delegate =&
$table->getDelegate();
127 if ( $delegate !== null and method_exists($delegate,
$field[
'name'].
"__pullValue") ){
133 $method =
$field[
'name'].
'__pullValue';
134 $val = $delegate->$method($record, $element);
135 $filterValue =
false;
137 }
else if ( isset($widgetHandler) and method_exists($widgetHandler,
'pullValue') ){
138 $val = $widgetHandler->pullValue($record,
$field, $form, $element, $new);
141 $val = $record->getValueAsString(
$field[
'name']);
146 $evt->record = $record;
149 $evt->element = $element;
151 $evt->{
'new'} = $new;
152 $table->app->fireEvent(
'FormTool::pullValue', $evt);
156 $form->setDefaults( array( $formFieldName=>$val) );
190 if ( !is_array(
$field) )
throw new Exception(
"No field passed to pushField");
192 $table =& $record->_table;
194 $widget =&
$field[
'widget'];
196 $widgetHandler =& $this->getWidgetHandler($widget[
'type']);
199 if ( isset($widgetHandler) and method_exists($widgetHandler,
'pushField') ){
201 return $widgetHandler->pushField($record,
$field[
'name'], $form, $formFieldName, $new);
205 $metaValues = array();
220 if ( is_a($formFieldName,
'HTML_QuickForm_element') ){
221 $element =& $formFieldName;
222 unset($formFieldName);
223 $formFieldName = $element->getName();
225 $element =& $this->getElement($form,
$field, $formFieldName);
229 if (
PEAR::isError($element) || !is_a($element,
'HTML_QuickForm_element') || $element->isFrozen() || $element->getType() ==
'static'){
234 $value = $this->pushValue($record,
$field, $form, $element, $metaValues);
240 if ( !$record->validate(
$field[
'name'], $value, $params) ){
249 'scripts.Dataface.QuickForm.pushField.ERROR_GETTING_VALUE',
250 "Error getting value for field '$field[name]' in QuickForm::pushField()",
251 array(
'file'=>
"_",
'line'=>0,
'fieldname'=>
$field[
'name'])
271 $res = $record->setValue(
$field[
'name'], $value);
276 'scripts.Dataface.QuickForm.pushField.ERROR_SETTING_VALUE',
277 "Error setting value for field '$field[name]' in QuickForm::pushField()",
278 array(
'file'=>
"_",
'line'=>0,
'fieldname'=>
$field[
'name'])
281 throw new Exception($value->toString(), E_USER_ERROR);
291 foreach ($metaValues as $key=>$value){
292 $res = $record->setValue($key, $value);
296 'scripts.Dataface.QuickForm.pushField.ERROR_SETTING_METAVALUE',
297 "Error setting value for meta field '$key' in QuickForm::pushField() ",
298 array(
'file'=>
"_",
'line'=>0,
'field'=>$key)
301 throw new Exception($res->toString(), E_USER_ERROR);
337 throw new Exception(
"Invalid field parameter: $field", E_USER_ERROR);
341 $widgetHandler =& $this->getWidgetHandler(
$field[
'widget'][
'type']);
347 $table =& $record->_table;
352 'scripts.Dataface.QuickForm.pushValue.ERROR_PUSHING_VALUE',
353 "Error trying to push value onto field name in push()",
354 array(
'file'=>
"_",
'line'=>0)
360 $widget =&
$field[
'widget'];
365 $delegate =&
$table->getDelegate();
370 if ( $delegate !== null and method_exists( $delegate,
$field[
'name'].
'__pushValue') ){
372 $val =& $element->getValue();
376 'scripts.Dataface.QuickForm.pushValue.ERROR_GETTING_ELEMENT_VALUE',
377 "Error getting element value for element $field[name] in QuickForm::pushField ",
378 array(
'fieldname'=>
$field[
'name'],
'file'=>
"_",
'line'=>0)
385 $method =
$field[
'name'].
'__pushValue';
386 $val = $delegate->$method($record, $element);
390 'scripts.Dataface.QuickForm.pushValue.ERROR_THROWN_BY_DELEGATE',
391 "Error thrown by delegate when preparing value for field '$field[name]'",
392 array(
'file'=>
"_",
'line'=>0,
'fieldname'=>
$field[
'name'])
401 }
else if ( isset($widgetHandler) and method_exists($widgetHandler,
'pushValue') ){
402 $out = $widgetHandler->pushValue($record,
$field, $form, $element, $metaValues);
405 $out = $element->getValue();
410 $evt->record = $record;
413 $evt->element = $element;
414 $evt->metaValues =& $metaValues;
416 $app->fireEvent(
'FormTool::pushValue', $evt);
438 $table =& $record->_table;
441 $widget =&
$field[
'widget'];
442 if ( !isset($permissions) ){
452 $widgetHandler =& $this->getWidgetHandler($widget[
'type']);
453 if ( isset($widgetHandler) and method_exists($widgetHandler,
'buildWidget') ){
454 $el =& $widgetHandler->buildWidget($record,
$field, $form, $formFieldName, $new);
460 $el =& $factory->addElement($widget[
'type'], $formFieldName, $widget[
'label'], array(
'class'=>$widget[
'class'],
'id'=>$formFieldName) );
465 throw new Exception($el->toString(), E_USER_ERROR);
468 if ( isset( $record ) && $record && $record->_table->hasField(
$field[
'name']) ){
469 if ( $link = $record->getLink(
$field[
'name']) ){
470 $el->setProperty(
'link',$link);
472 $el->setProperty(
'record_url', $record->getURL());
474 $atts = $el->getAttributes();
475 if ( !is_array($atts) ) $atts = array();
476 $atts = array_merge($atts,
$field[
'widget'][
'atts']);
478 if ( !isset($atts[
'data-xf-field']) ){
479 $atts[
'data-xf-field'] =
$field[
'name'];
481 $el->setAttributes($atts);
483 if ( $new and !$pt->checkPermission(
'new', $permissions) ){
485 }
else if ( !$new and !$pt->checkPermission(
'edit', $permissions) ){
497 $el->record =& $record;
499 $form->addElement($el);
506 $validators =
$field[
'validators'];
508 foreach ($validators as $vname=>$validator){
526 if ( $vname ==
'required' && $widget[
'type'] ==
'file' ){
530 $form->addRule($formFieldName, $validator[
'message'], $vname, @$validator[
'arg'], (($widget[
'type'] ==
'htmlarea' )?null:
'client'));
536 $this->pullField($record,
$field, $form, $formFieldName, $new);
539 $el->_persistantFreeze =
true;
566 $this->widgetHandlerClasses[$widgetType] = $class;
567 $this->widgetHandlerPaths[$widgetType] =
$path;
576 unset($this->widgetHandlerClasses[$widgetType] );
577 unset($this->widgetHandlerPaths[$widgetType]);
578 unset($this->widgetHandlers[$widgetType]);
591 if ( !isset($this->widgetHandlers[$widgetType]) ){
593 if ( !isset($this->widgetHandlerPaths[$widgetType]) and !isset($this->widgetHandlerClasses[$widgetType]) ){
595 $class =
'Dataface_FormTool_'.$widgetType;
596 if ( class_exists(
'Dataface_FormTool_'.$widgetType) ){
598 $this->widgetHandlers[$widgetType] =
new $class;
599 }
else if ( $this->_file_exists_incpath(
'Dataface/FormTool/'.$widgetType.
'.php') ){
601 import(
'Dataface/FormTool/'.$widgetType.
'.php');
602 $this->widgetHandlers[$widgetType] =
new $class;
612 if ( !class_exists($this->widgetHandlerClasses[$widgetType]) ){
613 import($this->widgetHandlerPaths[$widgetType]);
615 $class = $this->widgetHandlerClasses[$widgetType];
616 $this->widgetHandlers[$widgetType] =
new $class;
619 return $this->widgetHandlers[$widgetType];
627 static $factory = -1;
628 if ( is_scalar($factory) ){
644 $res = Dataface_FormTool::_getVocabAndClasses($record,
$field);
645 return $res[
'options'];
659 $res = Dataface_FormTool::_getVocabAndClasses($record,
$field);
660 return $res[
'options__classes'];
675 static function _getVocabAndClasses($record, &
$field){
677 throw new Exception(
"No record foudn in getVocabulary()", E_USER_ERROR);
680 $table =& $record->_table;
683 if ( isset(
$field[
'vocabulary']) and
$field[
'vocabulary'] ){
690 $options =&
$table->getValuelist($field[
'vocabulary']);
691 $options__classes =&
$table->getValuelist($field[
'vocabulary'].
'__meta');
694 $options->addUserInfo(
"Error getting vocabulary '$field[vocabulary]' when building widget for field '$field[name]' in QuickForm::buildWidget() ");
695 throw new Exception($options->toString(), E_USER_ERROR);
704 if ( is_array($options) ){
705 $opts = array(
''=>df_translate(
'scripts.GLOBAL.FORMS.OPTION_PLEASE_SELECT',
"Please Select..."));
706 foreach ($options as $key=>$value){
707 $opts[$key] = $value;
713 return array(
'options'=>&$options,
'options__classes'=>&$options__classes);
726 function _file_exists_incpath ($file)
728 $paths = explode(PATH_SEPARATOR, get_include_path());
730 foreach ($paths as
$path) {
732 $fullpath = $path . DIRECTORY_SEPARATOR . $file;
735 if (@file_exists($fullpath)) {
754 function _formGroupExists(&$form, $group){
755 $el =& $form->getElement($group);
756 return ( $el and !
PEAR::isError($el) and ($el->getType() ==
'group') );
772 if ( !is_array($field) ){
773 throw new Exception(
"Expected field definition for 2nd parameter but received something else.");
777 if ( isset($field[
'group']) and $this->_formGroupExists($form,$field[
'group'])){
784 $el =& $form->getElement($field[
'group']);
788 'scripts.Dataface.QuickForm.getElementByFieldName.ERROR_GETTING_GROUP',
789 "Failed to get group '$field[group]' when trying to load field '$fieldname' in Dataface_Quickform::pushWidget() ",
790 array(
'groupname'=>$field[
'group'],
'fieldname'=>
$fieldname,
'line'=>0,
'file'=>
"_")
793 throw new Exception($el->toString(), E_USER_ERROR);
803 $els =& $el->getElements();
806 foreach ( array_keys($els) as $key) {
808 if ( $el->getName() == $name ){
820 if ( !isset($element) ){
823 'scripts.Dataface.QuickForm.getElementByFieldName.ERROR_GETTING_GROUP_FIELD',
824 "Error trying to load field '$fieldname' in group '$field[group][name]'. The group was found but not the field. in Dataface_Quickform::pushWidget()",
825 array(
'fieldname'=>
$fieldname,
'groupname'=>$field[
'group'][
'name'],
'line'=>0,
'file'=>
"_")
836 $element =& $form->getElement($name);
854 $query =&
$app->getQuery();
858 if ( isset($query[
'--collapsed']) ){
859 $collapsed = explode(
',',$query[
'--collapsed']);
861 $collapsed = array();
864 if ( isset($query[
'--expanded']) ){
865 $expanded = explode(
',', $query[
'--expanded']);
870 $groupOrders = array();
874 if ( !isset($groupOrders[$groupname]) ){
876 $grp =&
$table->getFieldgroup($groupname);
877 if ( in_array($groupname, $collapsed) ){
878 $grp[
'collapsed'] = 1;
880 if ( in_array($groupname, $expanded) ){
881 $grp[
'collapsed'] = 0;
884 $groupOrders[$groupname] = array(
'order'=>( (is_array($grp) and isset($grp[
'order'])) ? floatval($grp[
'order']) : 0));
886 $groupOrders[$groupname] = array(
'order'=>0);
892 $groupOrders[
'__global__'][
'order'] = -1;
893 uasort($groupOrders, array(&$this,
'_compareGroups'));
894 foreach ( array_keys($groupOrders) as $group){
895 $groupOrders[$group] =& $groups[$group];
903 function _compareGroups($g1, $g2){
904 $o1 = ( isset($g1[
'order']) ? intval($g1[
'order']) : 0 );
905 $o2 = ( isset($g2[
'order']) ? intval($g2[
'order']) : 0 );
906 if ( $o1 <= $o2 )
return -1;
923 function display(&$form, $template=null, $singleField=
false, $useTabs=
false){
926 import(
'HTML/QuickForm/Renderer/ArrayDataface.php');
929 $form->accept($renderer);
930 $form_data = $renderer->toArray();
931 if ( !@$form_data[
'sections'] ){
932 $form_data[
'sections'] = array(
'__global__'=>array(
'header'=>df_translate(
'scripts.Dataface_FormTool.LABEL_EDIT_DETAILS',
'Edit Details'),
'name'=>
'Edit',
'elements'=>&$form_data[
'elements']));
933 unset($form_data[
'elements']);
936 $form_data[
'tabs'] = array();
937 if ( @is_array($form_data[
'elements']) ){
938 foreach ($form_data[
'elements'] as $key=>$element){
939 if ( !@$element[
'field'] )
continue;
940 $tabname = $element[
'field'][
'tab'];
941 if ( !$tabname ) $tabname =
'__main__';
942 if ( !isset($form_data[
'tabs'][$tabname] ) ){
946 $form_data[
'tabs'][$tabname] =
$table->getTab($element[
'field'][
'tab']);
947 $form_data[
'tabs'][$tabname][
'elements'] = array();
948 $form_data[
'tabs'][$tabname][
'sections'] = array();
951 $form_data[
'tabs'][$tabname][
'elements'][$key] =& $form_data[
'elements'][$key];
956 if ( is_array($form_data[
'sections']) ){
957 foreach ($form_data[
'sections'] as $skey=>$section ){
958 if ( !@$section[
'elements'] )
continue;
959 foreach ($section[
'elements'] as $ekey=>$element ){
960 if ( !@$element[
'field'] )
continue;
961 $tabname = $element[
'field'][
'tab'];
962 if ( !$tabname ) $tabname =
'__main__';
963 if ( !isset($form_data[
'tabs'][$tabname] ) ){
967 $form_data[
'tabs'][$tabname] =
$table->getTab($tabname);
968 $form_data[
'tabs'][$tabname][
'elements'] = array();
969 $form_data[
'tabs'][$tabname][
'sections'] = array();
973 if ( !isset($form_data[
'tabs'][$tabname][
'sections'][$skey]) ){
974 $section_copy = $section;
975 $section_copy[
'elements'] = array();
976 $form_data[
'tabs'][$tabname][
'sections'][$skey] =& $section_copy;
977 unset($section_copy);
980 $form_data[
'tabs'][$tabname][
'sections'][$skey][
'elements'][$ekey] =& $form_data[
'sections'][$skey][
'elements'][$ekey];
986 uasort($form_data[
'tabs'], array(&$this,
'_sortTabs'));
988 $context = array(
'form_data'=>$form_data);
990 if ( isset($form->_record) and method_exists($form->_record,
'getId') ){
991 $context[
'form_record_id'] = $form->_record->getId();
994 $context[
'singleField'] =& $form->getElement($singleField);
995 $context[
'singleField']->updateAttributes(array(
'onblur'=>
'submitThisForm(this.form);'));
996 if (!isset($template) ) $template =
'Dataface_Form_single_field_template.html';
998 if ( !isset($template) ) $template =
'Dataface_Form_Template.html';
999 df_display($context, $template);
1005 function _sortTabs($a,$b){
1006 if ( @$a[
'order'] == @$b[
'order'] )
return 0;
1007 return (@$a[
'order'] < @$b[
'order']) ? -1 : 1;
1022 $table =& $record->_table;
1024 if (
$table->hasJoinTable($tab, $record) ){
1025 $query[
'--tab'] = null;
1026 $jrecord = $record->getJoinRecord($tab,
true );
1027 if ( !isset($jrecord) ) $new =
true;
1029 $form = $this->createRecordForm($record->getJoinRecord($tab), $new, null, $query);
1030 $form->overrideNoQuery =
true;
1036 $form->_record =& $record;
1057 @$form->removeElement(
'__keys__');
1062 $factory =& self::factory();
1064 foreach ( array_keys($record->_table->keys()) as $key ){
1065 $els[] = $factory->addElement(
'hidden',$key);
1067 $form->addGroup($els,
'__keys__');
1068 $form->setConstants(array(
'__keys__'=>$record->strvals(array_keys($record->_table->keys()))));
1070 $form->addElement(
'hidden',
'--form-session-key', $this->getSessionKey());
1071 @$form->removeElement(
'--session:save');
1072 $form->addElement(
'header',
'__submit__',
'Submit');
1073 $grp =& $form->addGroup($this->createRecordButtons($record, $tab));
1074 $grp->_separator =
"\n";
1076 $data = $this->getSessionData($tab);
1077 if ( isset($data) ){
1080 $form->_setSubmitValues($data[
'_submitValues'], $data[
'_submitFiles']);
1086 $form->setDefaults($data[
'_submitValues']);
1090 if ( $record->_table->hasJoinTable($tab, $record ) ){
1091 foreach ( $record->getJoinKeys($tab) as $key=>$value ){
1092 @$form->removeElement($key);
1113 if ( !$form->validate() )
return false;
1115 $query =&
$app->getQuery();
1117 $targets = preg_grep(
'/^--session:target:/', array_keys($query));
1119 if ( count($targets) > 0 )
return true;
1121 $tabs = $record->tabs();
1123 if ( count($tabs) <= 1 )
return true;
1128 $session_data =& $this->getSessionData();
1129 foreach ( array_keys($tabs) as $tabname ){
1130 if ($tabname == $tab)
continue;
1131 if ( !$session_data or !$session_data[
'tabs'] or !in_array($tabname, array_keys($session_data[
'tabs'])) )
continue;
1132 $currForm =& $this->createRecordForm($record, $new, $tabname);
1133 $currForm->_build();
1137 $this->decorateRecordForm($record, $currForm, $new, $tabname);
1139 $currForm->_flagSubmitted =
true;
1140 if ( !$currForm->validate() ){
1142 $form->setElementError(
'global.'.$tabname, df_translate(
'classes.FormTool.errors.ERROR_IN_TAB',
'A validation error occurred in the '.$tabs[$tabname][
'label'].
' tab. Please verify that this tab\'s input is correct before saving.', array(
'tab'=>$tabs[$tabname][
'label'])));
1150 return (count($form->_errors) == 0 );
1169 $tabs = $record->tabs();
1170 $tabnames = array_keys($tabs);
1171 if ( count($tabs) > 1 and isset($tab) ){
1174 $this->storeSessionData(array(
'_submitValues'=>$form->_submitValues,
'_submitFiles'=>$form->_submitFiles), $tab, null, $record->getId());
1178 $query =&
$app->getQuery();
1180 $targets = preg_grep(
'/^--session:target:/', array_keys($query));
1182 if ( isset($tab) and count($targets) >0 ){
1185 $target = reset($targets);
1187 $res = preg_match(
'/--session:target:(.*)$/', $target, $matches);
1188 if ( !$res )
throw new Exception(
"Programming error: no matching target in query.", E_USER_ERROR);
1190 $target = $matches[1];
1192 if ( $target ==
'__default__' ) $target = $query[
'--session:target:__default__'];
1193 if ( $target ==
'__save__' )
return;
1195 $currentTabKey = intval(array_search($tab, $tabnames));
1197 if ( $currentTabKey ===
false ){
1200 return PEAR::raiseError(
"Sorry there was a problem finding the specified tab: ".$query[
'--tab'].
" in the tabs for the record ".$currentRecord->getId().
". The available tabs are '".implode(
', ', $tabnames).
".");
1203 if ( $target ==
'__next__' ){
1207 if ( isset($tabnames[$currentTabKey+1]) ){
1208 $target = $tabnames[$currentTabKey+1];
1212 }
else if ( $target ==
'__back__' ){
1216 if ( isset($tabnames[$currentTabKey-1]) ){
1217 $target = $tabnames[$currentTabKey-1];
1225 if ( isset( $query[
'-query'] ) ){
1226 $q = $query[
'-query'];
1227 }
else if ( isset(
$_SERVER[
'HTTP_REFERER']) and strpos(
$_SERVER[
'HTTP_REFERER'],
'?') !==
false ){
1228 $q = substr(
$_SERVER[
'HTTP_REFERER'], strpos(
$_SERVER[
'HTTP_REFERER'],
'?')+1);
1232 foreach ( $record->keys() as $key=>$value ){
1233 $couples[] = urlencode($key).
'='.urlencode($value);
1235 $q =
'-table='.urlencode($query[
'-table']).
'&-action='.$query[
'-action'].
'&'.implode(
'&', $couples);
1238 if ( strpos($q,
'&--form-session-key=') ===
false ) $q .=
'&--form-session-key='.$this->getSessionKey();
1239 if ( strpos($q,
'&--tab=') ===
false ) $q .=
'&--tab='.urlencode($target);
1240 else $q = preg_replace(
'/([&?])--tab=[^&]*(&?)/',
'${1}--tab='.urlencode($target).
'$2', $q);
1241 $q = preg_replace(
'/[&?]--msg=[^&]*/',
'',$q);
1243 $url = DATAFACE_SITE_HREF.
'?'.$q;
1244 $app->redirect($url);
1273 $formname = $form->getAttribute(
'name');
1274 $tabs = $record->_table->tabs($record);
1275 if ( !$tabs or count($tabs)<2 )
return null;
1276 foreach ( $tabs as $tab ){
1277 $tab[
'url'] =
'javascript: document.forms[\''.$formname.
'\'].elements[\
'--session:target:'.$tab[
'name'].
'\'].click()
';
1279 $tab['css_class
'] = 'edit-form-tab
'. ( ( $tab['name
'] == $selectedTab ) ? ' selected tabs-selected
':'');
1293 function getSessionKey(){
1294 $app =& Dataface_Application::getInstance();
1295 $query =& $app->getQuery();
1296 if ( isset($query['--form-session-key
']) ){
1297 return $query['--form-session-key
'];
1299 $key = rand().'_
'.time();
1300 $query['--form-session-key
'] = $key;
1329 function getSessionData($tab=null, $session_key = null){
1331 if ( !isset($session_key) ) $session_key = $this->getSessionKey();
1334 if ( isset($tab) and isset($_SESSION[$session_key]['tabs
'][$tab]) ){
1336 return $_SESSION[$session_key]['tabs
'][$tab];
1338 } else if ( !isset($tab) and isset($_SESSION[$session_key]) ) {
1339 return $_SESSION[$session_key];
1353 function clearSessionData($session_key=null){
1354 if ( !isset($session_key) ) $session_key = $this->getSessionKey();
1356 unset($_SESSION[$session_key]);
1367 function storeSessionData($data, $tab, $session_key = null, $record_id=null){
1368 if ( !isset($session_key) ) $session_key = $this->getSessionKey();
1369 if ( !isset($record_id) ){
1370 $app =& Dataface_Application::getInstance();
1371 $record =& $app->getRecord();
1373 $record_id = $record->getId();
1376 if ( !isset($_SESSION[$session_key]) ) $_SESSION[$session_key] = array('tabs
'=>array(),'table
'=>$data['_submitValues
']['-table
'], 'id'=>$record_id);
1378 $_SESSION[$session_key]['tabs
'][$tab] = $data;
1394 function createRecordButtons($record, $currentTab=null){
1396 $factory =& self::factory();
1398 $tabs = $record->tabs();
1399 $tabnames = array_keys($tabs);
1400 if ( count($tabnames) > 0 and !isset($currentTab) ) $currentTab = $tabnames[0];
1401 $saveButtonLabel = df_translate('tables.
'.$record->table()->tablename.'.save_button_label
', '');
1402 if ( !$saveButtonLabel ) $saveButtonLabel = df_translate('save_button_label
','Save
');
1403 $out[] = $factory->createElement('submit
', '--session:save
', $saveButtonLabel);
1406 if ( isset($currentTab) and count($tabnames)>1 ){
1407 if ( isset($tabs[$currentTab]['actions
']['default']) ){
1408 $default = $tabs[$currentTab]['actions
']['default'];
1410 $default = '__save__
';
1412 $out[] = $factory->createElement('submit
', '--session:target:__default__
', $default, array('style
'=>'display:none
'));
1414 $currIndex = array_search($currentTab, $tabnames);
1415 $next = ( isset( $tabnames[$currIndex+1] ) ? $tabnames[$currIndex+1] : null);
1416 $prev = ( isset( $tabnames[$currIndex-1] ) ? $tabnames[$currIndex-1] : null);
1417 if ( isset($tabs[$currentTab]['actions
']['next
']) ) $next = $tabs[$currentTab]['actions
']['next
'];
1418 if ( isset($tabs[$currentTab]['actions
']['back
']) ) $prev = $tabs[$currentTab]['actions
']['back
'];
1420 if ( isset($tabs[$currentTab]['actions
']['default'] ) ) $default = $tabs[$currentTab]['actions
']['default'];
1422 foreach ( $tabs as $tab ){
1423 if ( @$params['tab
'] == $tab['name
'] ) continue; // we don't include a button to the current tab
1424 $tabname = $tab[
'name'];
1427 if ( isset($tab[
'button'][
'atts']) ) $atts = $tab[
'button'][
'atts'];
1428 if ( isset($params[
'atts'][
'__global__']) ) $atts = array_merge($atts, $params[
'atts'][
'__global__']);
1429 if ( isset($params[
'atts'][$tab]) ) $atts = array_merge($atts, $params[
'atts'][$tab]);
1430 if ( !isset($atts[
'style']) ) $atts[
'style'] =
'display: none';
1434 $out[] = $factory->createElement(
'submit',
'--session:target:'.$tabname, $tab[
'label'], $atts);
1437 if ( isset($prev) )
$out[] = $factory->createElement(
'submit',
'--session:target:__back__', df_translate(
'scripts.GLOBAL.LABEL_BACK',
'Back'));
1438 if ( isset($next) )
$out[] = $factory->createElement(
'submit',
'--session:target:__next__', df_translate(
'scripts.GLOBAL.LABEL_NEXT',
'Next'));
1450 $session_data = $this->getSessionData(null, $session_key);
1451 if ( !isset($session_data) )
return false;
1454 if ( !$new and $session_data[
'id'] != $record->getId() ){
1456 return PEAR::raiseError(
'Failed to save session because the session data is not registered to the same record.');
1459 if ( $session_data[
'table'] != $record->_table->tablename ){
1461 return PEAR::raiseError(
'Failed to save session because the session data is for a different table than the record.');
1464 $joinRecords = array();
1468 foreach ( array_keys($session_data[
'tabs']) as $tabname ){
1469 $temp =& $this->createRecordForm($record, $new, $tabname);
1475 $this->decorateRecordForm($record, $temp, $new, $tabname);
1478 if ( $temp->_record->getId() != $record->getId() ){
1479 $joinRecords[$tabname] =& $temp->_record;
1485 $res = $record->save(null,
true);
1490 foreach ( $joinRecords as $name=>$jrecord ){
1494 $jrecord->setValues($record->getJoinKeys($name));
1497 $res = $jrecord->save(null,
true);
1505 $this->clearSessionData($session_key);
1518 import(
'HTML/QuickForm.php');
1526 $this->HTML_QuickForm($name);
1530 $args = func_get_args();
1531 if ( is_object($element) and $this->elementExists($element->getName()) ){
1532 $this->removeElement($element->getName());
1535 if ( $this->elementExists($args[1]) ){
1536 $this->removeElement($args[1]);
1539 switch ( count($args) ){
1551 $res =&
parent::addElement($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
break;
1553 $res =&
parent::addElement($args[0], $args[1], $args[2], $args[3], $args[4], $args[5], $args[6]);
break;