From 2bf54307372c2c8f958f7464bee1d96002d942ba Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Tue, 29 Mar 2005 10:05:08 +0000 Subject: [PATCH] moved parse_html function out of accountContainer and added image option --- lam/lib/modules.inc | 241 ++++++++++++++++++++++---------------------- 1 file changed, 122 insertions(+), 119 deletions(-) diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index d93dcb6a..3f421fc2 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -526,6 +526,127 @@ function doUploadPostActions($scope, $data, $ids, $failed) { return $return; } +/** +* Takes a list of meta-HTML elements and prints the equivalent HTML output. +* +* @param string $module Name of account module +* @param array $input List of meta-HTML elements +* @param array $values List of values which override the defaults in $input (name => value) +* @param boolean $restricted If true then no buttons will be displayed +* @param integer $tabindex Start value of tabulator index for input fields +* @param integer $tabindexLink Start value of tabulator index for links +*/ +function parseHtml($module, $input, $values, $restricted, &$tabindex, &$tabindexLink) { + if (is_array($input)) { + echo "\n"; + for ($i=0; $i\n"; + for ($j=0; $j\n"; + switch ($input[$i][$j]['kind']) { + // plain text + case 'text': + echo $input[$i][$j]['text']; + break; + // input fields + case 'input': + if ($restricted && ($input[$i][$j]['type'] == "submit")) break; // no buttons in restricted mode + $output = "\n"; + if ($input[$i][$j]['legend']!='') echo "" . $input[$i][$j]['legend'] . "\n"; + parseHtml($module, $input[$i][$j]['value'], $values, $restricted, $tabindex, $tabindexLink); + echo "\n"; + break; + // selection + case 'select': + if (!is_array($input[$i][$j]['options'])) $input[$i][$j]['options'] = array ( $input[$i][$j]['options'] ); + if (isset($input[$i][$j]['options_selected'])) { + if (!is_array($input[$i][$j]['options_selected'])) { + // one selected element + $input[$i][$j]['options_selected'] = array ( $input[$i][$j]['options_selected'] ); + } + } + else { + $input[$i][$j]['options_selected'] = array(); + } + echo "\n"; + break; + // sub table + case 'table': + parseHtml($module, $input[$i][$j]['value'], $values, $restricted, $tabindex, $tabindexLink); + break; + // help link + case 'help': + echo "" . _('Help') . "\n"; + $tabindexLink++; + break; + // status message + case 'message': + StatusMessage($input[$i][$j]['type'], $input[$i][$j]['headline'], $input[$i][$j]['text']); + break; + // image + case 'image': + echo "\n"; + break; + // error, unknown type + default: + echo "Unrecognized type: " . $input[$i][$j]['kind'] . "\n"; + break; + } + } + echo "\n"; + echo "\n"; + } + } + echo "
\n"; +} /** * This class includes all modules and attributes of an account. @@ -769,7 +890,7 @@ class accountContainer { else $return = call_user_func(array($this->module[$this->order[$this->current_page]], 'display_html_'.$this->subpage), $post); $y = 5000; $z = 10000; - $this->parse_html($this->order[$this->current_page], $return, $y, $z); + parseHtml($this->order[$this->current_page], $return, array(), false, $y, $z); // Display rest of html-page echo "\n"; echo "\n"; @@ -779,124 +900,6 @@ class accountContainer { return 0; } - function parse_html($module, $input, &$y, &$z) { - /* $y and $z are used to change the the taborder. - * Unfortunatly we don't now how many taborders we need - * Every link also help needs a taborder. - * Therefore we start with taborder=10000 for help - * and taborder=5000 for input fields - * taborder starts at 5000 because we need also some - * taborders for the side bar. - */ - if (is_array($input)) { - echo "\n"; - for ($i=0; $i\n"; - for ($j=0; $j\n"; - echo $input[$i][$j]['text'] . "\n"; - break; - case 'input': - echo "\n"; - $output = "\n"; - echo "
\n"; - if ($input[$i][$j]['legend']!='') echo "" . $input[$i][$j]['legend'] . "\n"; - $this->parse_html($module, $input[$i][$j]['value'], $y, $z); - echo "
\n"; - break; - case 'select': - if (!is_array($input[$i][$j]['options'])) $input[$i][$j]['options'] = array ( $input[$i][$j]['options'] ); - if (isset($input[$i][$j]['options_selected'])) { - if (!is_array($input[$i][$j]['options_selected'])) { - // one selected element - $input[$i][$j]['options_selected'] = array ( $input[$i][$j]['options_selected'] ); - } - } - else { - $input[$i][$j]['options_selected'] = array(); - } - echo "\n"; - echo "\n"; - break; - case 'table': - echo "\n"; - $this->parse_html($module, $input[$i][$j]['value'], $y, $z); - echo "\n"; - break; - case 'help': - echo "\n"; - echo "" . _('Help') . "\n"; - $z++; - break; - case 'message': - echo "\n"; - StatusMessage($input[$i][$j]['type'], $input[$i][$j]['headline'], $input[$i][$j]['text']); - echo "\n"; - break; - default: - echo "
\n"; - break; - } - } - echo "\n"; - } - } - echo "
Unrecognized type: " . $input[$i][$j]['kind'] . "
\n"; - } - /* Add attributes to variable. Syntax is array( attribute = array ( objectClass1 => MUST|MAX, objectClass2 => MUST|MAY ), ... ) */ function add_attributes($objectClass) {