From 0a02c90ac762b776ea632ef1c361430d091b0715 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 9 Oct 2002 00:31:01 +0000 Subject: [PATCH] made labels with accesskey work changed name for html-widget from raw to html fixed some error/warnings --- etemplate/inc/class.boetemplate.inc.php | 14 ++++---- etemplate/inc/class.html.inc.php | 46 +++++++++++++++++++++---- etemplate/inc/class.uietemplate.inc.php | 25 ++++++++------ 3 files changed, 60 insertions(+), 25 deletions(-) diff --git a/etemplate/inc/class.boetemplate.inc.php b/etemplate/inc/class.boetemplate.inc.php index 7a5e763e73..6ba97c77dd 100644 --- a/etemplate/inc/class.boetemplate.inc.php +++ b/etemplate/inc/class.boetemplate.inc.php @@ -30,18 +30,18 @@ 'text' => 'Text', // Textfield 1 Line (size = [length][,maxlength]) 'int' => 'Integer', // like text, but only numbers (size = [min][,max]) 'float' => 'Floating Point', // --------------- " -------------------------- - 'textarea' => 'Textarea', // Multiline Text Input (size = [rows][,cols]) + 'textarea'=> 'Textarea', // Multiline Text Input (size = [rows][,cols]) 'checkbox'=> 'Checkbox', 'radio' => 'Radiobutton', // Radiobutton (size = value if checked) 'button' => 'Submitbutton', 'hrule' => 'Horizontal Rule', - 'template' => 'Template', // $cell['name'] contains template-name, $cell['size'] index into $content,$cname,$readonlys - 'image' => 'Image', // label = url, name=link or method, help=alt or title - 'date' => '', // Datefield, size='' timestamp or size=format like 'm/d/Y' + 'template'=> 'Template', // $cell['name'] contains template-name, $cell['size'] index into $content,$cname,$readonlys + 'image' => 'Image', // label = url, name=link or method, help=alt or title + 'date' => '', // Datefield, size='' timestamp or size=format like 'm/d/Y' 'select' => 'Selectbox', // Selectbox ($sel_options[$name] or $content[options-$name] is array with options) // if size > 1 then multiple selections, size lines showed - 'raw' => 'Raw', // Raw html in $content[$cell['name']] - 'file' => 'FileUpload' // show an input type='file', set the local name as ${name}_path + 'html' => 'Html', // Raw html in $content[$cell['name']] + 'file' => 'FileUpload' // show an input type='file', set the local name as ${name}_path ); /*! @function boetemplate @@ -591,4 +591,4 @@ } return $result; } - }; \ No newline at end of file + }; diff --git a/etemplate/inc/class.html.inc.php b/etemplate/inc/class.html.inc.php index 0f1841f1b6..13a72f504a 100644 --- a/etemplate/inc/class.html.inc.php +++ b/etemplate/inc/class.html.inc.php @@ -14,15 +14,18 @@ class html { - var $user_agent,$ua_version; + var $user_agent,$ua_version; // 'mozilla','msie','konqueror' var $prefered_img_title; function html() { // should be Ok for all HTML 4 compatible browsers if (!eregi('compatible; ([a-z_]+)[/ ]+([0-9.]+)',$GLOBALS['HTTP_USER_AGENT'],$parts)) + { eregi('^([a-z_]+)/([0-9.]+)',$GLOBALS['HTTP_USER_AGENT'],$parts); + } list(,$this->user_agent,$this->ua_version) = $parts; $this->user_agent = strtolower($this->user_agent); + $this->prefered_img_title = $this->user_agent == 'mozilla' && $this->ua_version < 5 ? 'ALT' : 'TITLE'; //echo "

HTTP_USER_AGENT='$GLOBALS[HTTP_USER_AGENT]', UserAgent: '$this->user_agent', Version: '$this->ua_version', img_title: '$this->prefered_img_title'

\n"; } @@ -112,11 +115,32 @@ class html { if (!($path = $GLOBALS['phpgw']->common->image($app,$image))) $path = $image; // name may already contain absolut path - $options .= ' src="'.$path.'"'; + $image = ' SRC="'.$path.'"'; + } + if (!$no_lang) + { + $lang = lang($lang); + } + if (($accesskey = strstr($lang,'&')) && $accesskey[1] != ' ') + { + $lang_u = str_replace('&'.$accesskey[1],''.$accesskey[1].'',$lang); + $lang = str_replace('&','',$lang); + $options = 'ACCESSKEY="'.$accesskey[1].'" '.$options; + } + else + { + $accesskey = ''; + $lang_u = $lang; } - if (!$no_lang) $lang = lang($lang); if ($onClick) $options .= " onClick=\"$onClick\""; - return $this->input($name,$lang,$image != '' ? 'IMAGE' : 'SUBMIT',$options); + + // '; } /*! @@ -282,7 +306,7 @@ class html { return $this->style( ".th { background: ".$GLOBALS['phpgw_info']['theme']['th_bg']."; }\n". - ".row_on { background: ".$GLOBALS['phpgw_info']['theme']['row_on']."; }\n". + ".row_on,.th_bright { background: ".$GLOBALS['phpgw_info']['theme']['row_on']."; }\n". ".row_off { background: ".$GLOBALS['phpgw_info']['theme']['row_off']."; }\n" ); } @@ -292,8 +316,16 @@ class html return $styles ? "" : ''; } - function label($content,$options='') + function label($content,$id='',$accesskey='',$options='') { - return ""; + if ($id != '') + { + $id = " FOR=\"$id\""; + } + if ($accesskey != '') + { + $accesskey = " ACCESSKEY=\"$accesskey\""; + } + return "$content"; } } diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index 0a4fa8f493..4c23fb5cdb 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -405,6 +405,10 @@ $options .= ' onChange="'.($cell['onchange']=='1'?'this.form.submit();':$cell['onchange']).'"'; } } + if ($form_name != '') + { + $options = "ID=\"$form_name\" $options"; + } list($type,$sub_type) = explode('-',$cell['type']); switch ($type) { @@ -414,7 +418,7 @@ if ($value != '' && strstr($cell['size'],'i')) $value = $this->html->italic($value); $html .= $value; break; - case 'raw': + case 'html': $html .= $value; break; case 'int': // size: [min][,[max][,len]] @@ -641,9 +645,9 @@ } break; } - if ($ext_type && !$readonly && // extension-processing need to be after all other and only with diff. name - !isset($GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name])) - { + if ($ext_type && !$readonly) // extension-processing need to be after all other and only with diff. name + { // unset it first, if it is already set, to be after the other widgets of the ext. + unset($GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name]); $GLOBALS['phpgw_info']['etemplate']['to_process'][$form_name] = 'ext-'.$ext_type; } if ($extra_label && ($label != '' || $html == '')) @@ -652,8 +656,11 @@ { $label = lang($label); } - $html_label = $html != '' && $label != ''; - + if (($accesskey = strstr($label,'&')) && $accesskey[1] != ' ' && $form_name != '') + { + $label = str_replace('&'.$accesskey[1],''.$accesskey[1].'',$label); + $label = $this->html->label($label,$form_name,$accesskey[1]); + } if (strstr($label,'%s')) { $html = str_replace('%s',$html,$label); @@ -662,10 +669,6 @@ { $html = ' '; } - if ($html_label) - { - $html = $this->html->label($html); - } } return $html; } @@ -683,7 +686,7 @@ */ function process_show(&$content,$to_process,$cname='') { - if (!isset($content) || !is_array($content)) + if (!isset($content) || !is_array($content) || !is_array($to_process)) { return; }