diff --git a/etemplate/inc/class.boetemplate.inc.php b/etemplate/inc/class.boetemplate.inc.php index 190f25dcdc..44911a7d4b 100644 --- a/etemplate/inc/class.boetemplate.inc.php +++ b/etemplate/inc/class.boetemplate.inc.php @@ -594,14 +594,12 @@ class boetemplate extends soetemplate */ static function set_array(&$arr,$idx,$val) { - if (!is_array($arr)) - { - throw new egw_exception_assertion_failed(__METHOD__."(\$arr,'$idx','$val') \$arr is no array!"); - } $idxs = explode('[',str_replace(']','',$idx)); $pos = &$arr; foreach($idxs as $idx) { + if (!is_array($pos) && !is_null($pos)) return; // gives fatal error under PHP5.3 + $pos = &$pos[$idx]; } $pos = $val; diff --git a/etemplate/inc/class.customfields_widget.inc.php b/etemplate/inc/class.customfields_widget.inc.php index b5408947ae..9d85fc799a 100644 --- a/etemplate/inc/class.customfields_widget.inc.php +++ b/etemplate/inc/class.customfields_widget.inc.php @@ -17,7 +17,7 @@ * All widgets here have 2+ comma-separated options ($cell[size]): * - sub-type to display only the cf's without subtype or with a matching one * - use-private to display only (non-)private cf's (0=regular ones, 1=private ones, default both) - * - field-name to display only the named custom field(s). Use ! before to display all but given field(s). + * - field-name to display only the named custom field(s). Use ! before to display all but given field(s). * Additional fields can be added with a comma between them * * Private cf's the user has no right to see (neither him nor his memberships are mentioned) are never displayed. @@ -94,7 +94,20 @@ class customfields_widget $this->advanced_search = $GLOBALS['egw_info']['etemplate']['advanced_search']; } - function pre_process($name,&$value,&$cell,&$readonlys,&$extension_data,&$tmpl) + /** + * pre-processing of the extension + * + * This function is called before the extension gets rendered + * + * @param string $form_name form-name of the control + * @param mixed &$value value / existing content, can be modified + * @param array &$cell array with the widget, can be modified for ui-independent widgets + * @param array &$readonlys names of widgets as key, to be made readonly + * @param mixed &$extension_data data the extension can store persisten between pre- and post-process + * @param etemplate &$tmpl reference to the template we belong too + * @return boolean true if extra label is allowed, false otherwise + */ + function pre_process($form_name,&$value,&$cell,&$readonlys,&$extension_data,etemplate $tmpl) { list($app) = explode('.',$tmpl->name); if ($this->appname == 'etemplate' || !$this->customfields || // if we are in the etemplate editor or the app has no cf's, load the cf's from the app the tpl belongs too @@ -126,7 +139,7 @@ class customfields_widget } // Remove filtered fields - if($field_filter && (!$negate_field_filter && !in_array($key, $field_filter) || + if($field_filter && (!$negate_field_filter && !in_array($key, $field_filter) || $negate_field_filter && in_array($key, $field_filter))) { unset($fields[$key]); @@ -139,6 +152,7 @@ class customfields_widget $fields = array($name => $fields[$name]); $value = array($this->prefix.$name => $value); $singlefield = true; + $form_name = substr($form_name,0,-strlen("[$this->prefix$name]")); } switch($type = $cell['type']) { @@ -422,6 +436,8 @@ class customfields_widget $input =& etemplate::empty_cell('link-entry',$this->prefix.$lname,array( 'size' => $field['type'] == 'link-entry' ? '' : $field['type'], )); + // register post-processing of link widget to get eg. needed/required validation + etemplate::$request->set_to_process(etemplate::form_name($form_name,$this->prefix.$lname), 'ext-link'); } $cell['data'][0]['c'.$n++] = $row_class.',top'; @@ -429,7 +445,7 @@ class customfields_widget { if ($readonly) $input['readonly'] = true; - if ($cell['needed']) $input['needed'] = $cell['needed']; + $input['needed'] = $cell['needed'] || $field['needed']; if (!empty($field['help']) && $row_class != 'th') { diff --git a/etemplate/inc/class.link_widget.inc.php b/etemplate/inc/class.link_widget.inc.php index 879db3984a..4df707d0b1 100644 --- a/etemplate/inc/class.link_widget.inc.php +++ b/etemplate/inc/class.link_widget.inc.php @@ -419,6 +419,7 @@ class link_widget (count($options) == 1 ? lang($app) : lang('Search')), 'extra' => $cell['onchange'] ? ','.self::AJAX_NEED_ONCHANGE : null, // store flang for ajax_search, to display extra_line required by onchange ); + if ($cell['needed']) $value['class'] = 'inputRequired'; if ($options) // limit the app-selectbox to the given apps { diff --git a/etemplate/setup/etemplates.inc.php b/etemplate/setup/etemplates.inc.php index b2e3a820b4..afc580b152 100644 --- a/etemplate/setup/etemplates.inc.php +++ b/etemplate/setup/etemplates.inc.php @@ -1,14 +1,14 @@ 'etemplate.link_widget.attach','template' => '', $templ_data[] = array('name' => 'etemplate.link_widget.create','template' => '','lang' => '','group' => '0','version' => '0.9.15.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:2:{s:2:"c1";s:6:"row_on";s:2:"c2";s:7:"row_off";}i:1;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"name";s:3:"app";}s:1:"B";a:4:{s:4:"type";s:6:"select";s:7:"no_lang";s:1:"1";s:4:"name";s:2:"id";s:4:"help";s:28:"Select an entry to link with";}s:1:"C";a:4:{s:4:"type";s:6:"button";s:5:"label";s:4:"Link";s:4:"name";s:6:"create";s:4:"help";s:29:"click here to create the Link";}s:1:"D";a:4:{s:4:"type";s:6:"button";s:5:"label";s:10:"New search";s:4:"name";s:3:"new";s:4:"help";s:36:"start a new search, cancel this link";}}i:2;a:4:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"Comment";}s:1:"B";a:5:{s:4:"type";s:4:"text";s:4:"size";s:5:"50,50";s:4:"span";s:3:"all";s:4:"name";s:6:"remark";s:4:"help";s:28:"optional note about the Link";}s:1:"C";a:1:{s:4:"type";s:5:"label";}s:1:"D";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:2;s:4:"cols";i:4;}}','size' => '','style' => '','modified' => '1035043515',); -$templ_data[] = array('name' => 'etemplate.link_widget.entry','template' => '','lang' => '','group' => '0','version' => '1.7.002','data' => 'a:1:{i:0;a:7:{s:4:"type";s:3:"box";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:1:"2";i:1;a:8:{s:4:"type";s:3:"box";s:4:"size";s:6:"4,,0,0";i:1;a:4:{s:4:"name";s:3:"app";s:4:"help";s:28:"Select application to search";s:4:"type";s:9:"link-apps";s:8:"onchange";s:177:"xajax_doXMLHTTP(\'etemplate.link_widget.ajax_get_types\',document.getElementById(form::name(\'app\')).value,form::name(\'link_type\'),this.form.etemplate_exec_id.value); return false;";}i:2;a:5:{s:4:"type";s:3:"box";s:4:"name";s:8:"type_box";s:4:"size";s:1:"1";i:1;a:3:{s:4:"type";s:6:"select";s:4:"name";s:9:"link_type";s:4:"help";s:51:"Search only selected record type in the application";}s:4:"span";s:10:",type_hide";}s:4:"span";s:11:",box_inline";s:4:"name";s:11:"search_line";i:3;a:4:{s:4:"type";s:4:"text";s:4:"name";s:5:"query";s:4:"blur";s:5:"@blur";s:4:"size";s:6:"@extra";}i:4;a:5:{s:4:"type";s:6:"button";s:4:"name";s:6:"search";s:5:"label";s:1:">";s:4:"help";s:30:"Click here to start the search";s:7:"onclick";s:345:"xajax_doXMLHTTP(\'etemplate.link_widget.ajax_search\',document.getElementById(form::name(\'app\')).value,document.getElementById(form::name(\'link_type\')).value,document.getElementById(form::name(\'query\')).value,form::name(\'id\'),form::name(\'search_line\'),form::name(\'select_line\'),form::name(\'query\'),this.form.etemplate_exec_id.value); return false;";}}i:2;a:5:{s:4:"type";s:3:"box";s:4:"size";s:1:"1";s:4:"span";s:22:",link_select link_hide";i:1;a:4:{s:4:"type";s:6:"select";s:4:"name";s:2:"id";s:8:"onchange";s:254:"if (this.value == \'\') { document.getElementById(form::name(\'search_line\')).style.display=\'inline\'; document.getElementById(form::name(\'select_line\')).style.display=\'none\';} else if (this.options[0].value == \' \' || this.value == 0) { this.form.submit(); }";s:7:"no_lang";s:1:"1";}s:4:"name";s:11:"select_line";}}}','size' => '','style' => '.link_hide { display: none; } +$templ_data[] = array('name' => 'etemplate.link_widget.entry','template' => '','lang' => '','group' => '0','version' => '1.7.002','data' => 'a:1:{i:0;a:8:{s:4:"type";s:3:"box";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"size";s:1:"2";i:1;a:8:{s:4:"type";s:3:"box";s:4:"size";s:6:"4,,0,0";i:1;a:4:{s:4:"name";s:3:"app";s:4:"help";s:28:"Select application to search";s:4:"type";s:9:"link-apps";s:8:"onchange";s:177:"xajax_doXMLHTTP(\'etemplate.link_widget.ajax_get_types\',document.getElementById(form::name(\'app\')).value,form::name(\'link_type\'),this.form.etemplate_exec_id.value); return false;";}i:2;a:5:{s:4:"type";s:3:"box";s:4:"name";s:8:"type_box";s:4:"size";s:1:"1";i:1;a:3:{s:4:"type";s:6:"select";s:4:"name";s:9:"link_type";s:4:"help";s:51:"Search only selected record type in the application";}s:4:"span";s:10:",type_hide";}s:4:"span";s:11:",box_inline";s:4:"name";s:11:"search_line";i:3;a:4:{s:4:"type";s:4:"text";s:4:"name";s:5:"query";s:4:"blur";s:5:"@blur";s:4:"size";s:6:"@extra";}i:4;a:5:{s:4:"type";s:6:"button";s:4:"name";s:6:"search";s:5:"label";s:1:">";s:4:"help";s:30:"Click here to start the search";s:7:"onclick";s:345:"xajax_doXMLHTTP(\'etemplate.link_widget.ajax_search\',document.getElementById(form::name(\'app\')).value,document.getElementById(form::name(\'link_type\')).value,document.getElementById(form::name(\'query\')).value,form::name(\'id\'),form::name(\'search_line\'),form::name(\'select_line\'),form::name(\'query\'),this.form.etemplate_exec_id.value); return false;";}}i:2;a:5:{s:4:"type";s:3:"box";s:4:"size";s:1:"1";s:4:"span";s:22:",link_select link_hide";i:1;a:4:{s:4:"type";s:6:"select";s:4:"name";s:2:"id";s:8:"onchange";s:254:"if (this.value == \'\') { document.getElementById(form::name(\'search_line\')).style.display=\'inline\'; document.getElementById(form::name(\'select_line\')).style.display=\'none\';} else if (this.options[0].value == \' \' || this.value == 0) { this.form.submit(); }";s:7:"no_lang";s:1:"1";}s:4:"name";s:11:"select_line";}s:4:"span";s:7:",@class";}}','size' => '','style' => '.link_hide { display: none; } .type_hide { display: none;} .type_show { display: inline;}','modified' => '1258396333',); diff --git a/etemplate/templates/default/link_widget.entry.xet b/etemplate/templates/default/link_widget.entry.xet index 284fde8aaf..3ec5bb3441 100644 --- a/etemplate/templates/default/link_widget.entry.xet +++ b/etemplate/templates/default/link_widget.entry.xet @@ -1,22 +1,28 @@ -