removed old meta HTML support

This commit is contained in:
Roland Gruber 2011-04-28 17:42:47 +00:00
parent 11f6e5005e
commit 1e1ff9f1a9
2 changed files with 10 additions and 339 deletions

View File

@ -1,6 +1,7 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-15"><title>Upgrade notes</title>
@ -18,8 +19,11 @@ This is a list of API changes for all LAM releases.
<br>
<h2>3.4.0 -&gt; 3.5.0</h2>The old meta HTML code is no longer supported. Please use the new solution based on htmlElement (see lib/html.inc).<br>
<br>
<h2>3.3.0 -&gt; 3.4.0</h2>
Module interface:<br>
<ul>

View File

@ -557,141 +557,7 @@ function getRequiredExtensions() {
* Takes a list of meta-HTML elements and prints the equivalent HTML output.
*
* The modules are not allowed to display HTML code directly but return
* meta HTML code. This allows to have a common design for all module pages.<br>
* <br>
* Meta HTML code is always returned as a three dimensional <b>array[a][b][c]</b>
* where <b>a</b> is the row number, <b>b</b> is the column number and <b>c</b> is
* is a <i>data element</i>.<br>
* <br>
* <b>Format of data elements:</b><br>
* <br>
* A <i>data element</i> is an array which contains the data to display.<br>
* All <i>data elements</i> must contail a value <b>"kind"</b> which
* defines what kind of element should be displayed.<br>
* <br>
* These are the possibilies for <b>kind</b> and what other options have to be added to the array:<br>
* <br>
* <ul>
* <li><b>fieldset:</b> Inserts a fieldset.
* <ul>
* <li><b>legend:</b> The legend of the fieldset.</li>
* <li><b>value:</b> A <i>data element</i>. Can be used recursively.</li>
* </ul>
* </li>
* <li><b>help:</b> Adds a help link.
* <ul>
* <li><b>value:</b> The help number for the help entry.</li>
* <li><b>scope:</b> The account type for the help entry.<br>
* </li>
* </ul>
* </li>
* <li><b>input:</b> Adds a HTML input element.
* <ul>
* <li><b>name:</b> The name of the element, will be used later as variable name
* when user input is returned.</li>
* <li><b>type:</b> allowed values: submit, reset, checkbox, text, password, file, hidden</li>
* <li><b>checked:</b> Boolean value, if true a checkbox will be checked. This
* value is only needed or checkboxes.</li>
* <li><b>disabled:</b> Boolean value, if true the element will be disabled.</li>
* <li><b>size:</b> The length of the input element, only used for text, password and file.</li>
* <li><b>maxlength:</b> The maximum size of the input element, only used for
* text, password and file.</li>
* <li><b>value:</b> The element will have this value as default. Button elements will have
* this as caption.</li>
* <li><b>title:</b> Title value for input element (optional).</li>
* <li><b>image:</b> This is used to display image buttons. File name of an 16x16px image in the graphics folder
* (e.g. add.png). You may only use this for submit buttons.</li>
* </ul>
* </li>
* <li><b>select:</b> This will add a select field.
* <ul>
* <li><b>name:</b> The name of the element, will be used later as variable name when user input is
* returned.</li>
* <li><b>multiple:</b> Boolean value, if set to true the user can select more than one entry.</li>
* <li><b>options:</b> Array of string. This is the list of option values the user can select.</li>
* <li><b>options_selected:</b> Array of string. This is the list of pre selected elements, must contain
* values that are also in <i>options</i>.</li>
* <li><b>descriptiveOptions:</b>
* Boolean value, if set to true then all elements in options must be arrays themselves (array(<i>value</i>,
*<i>description</i>)) (default: false)<br>
* </li>
* <li><b>size:</b> The size of the select field, if set to 1 a dropdown box will be displayed.</li>
* <li><b>noSorting:</b> If set to true then the entries will not be sorted. Default is false.</li>
* <li><b>onchange:</b> onchange event<br>
* </li>
* </ul>
* </li>
* <li><b>table:</b> Adds a table. Can be used recursively.
* <ul>
* <li><b>value:</b> A <i>data element</i>. Can be used recursively.</li>
* </ul>
* </li>
* <li><b>text:</b> Inserts a text element.
* <ul>
* <li><b>text:</b> The text to display.</li>
* </ul>
* </li>
* <li><b>textarea:</b> Adds a multiline text field.
* <ul>
* <li><b>name:</b> The name of the element, will be used later as variable name when user
* input is returned.</li>
* <li><b>rows:</b> Number of rows (required)<br>
* </li>
* <li><b>cols:</b> Number of characters for each line (required)<br>
* </li>
* <li><b>readonly:</b> Boolean value, if true the text field will be read only.<br>
* </li>
* </ul>
* </li>
* <li><b>image:</b> Displays an image.
* <ul>
* <li><b>path:</b> Path to the image</li>
* <li><b>width:</b> Width of the image</li>
* <li><b>height:</b> Height of the image</li>
* <li><b>alt:</b> Alt text of the image<br>
* </li>
* </ul>
* </li>
* </ul>
* <br>
* Beneath those values a <b>"td"</b> value may be added. This has to be an array with one or more
* of these options:<br>
* <br>
* <ul>
* <li><b>colspan:</b> Like the HTML colspan attribute for td elements</li>
* <li><b>rowspan:</b> Like the HTML rowspan attribute for td elements</li>
* <li><b>align:</b> left/center/right/justify Like the HTML align attribute</li>
* <li><b>valign:</b> top/middle/bottom Like the HTML valign attribute</li>
* <li><b>width:</b> Like the HTML height attribute for td elements</li>
* </ul>
* <br>
* Input buttons which should load a different subpage of a module must have a special <i>name</i> attribute:<br>
* <br>
* <b>name</b> => 'form_subpage_' . <i><module name></i> . '_' . <i><subpage name></i> . '_' . <i><button name></i><br>
* <ul>
* <li><b><module name>:</b> name of this account module (e.g. 'posixAccount')</li>
* <li><b><subpage name>:</b> name of next subpage (e.g. 'attributes')</li>
* <li><b><button name>:</b> a name to distinguish buttons (e.g. 'ok'/'cancel'/'back')</li>
* </ul>
* <br>
* <br>
* <b>Example:</b>
* <code>
* array(
* array(
* array("kind" => "text", "text" => "This is an example", "td" => array("colspan" => 3))
* ),
* array(
* array("kind" => "text", "text" => "Input:"),
* array("kind" => "input", "name" => "myinput", "type" => "text"),
* array("kind" => "help", "value" => "42")
* ),
* array(
* array("kind" => "input", "name" => 'form_subpage_myModule_attributes_back', "value" => _("Back"))
* )
*)
* </code>
*
* meta HTML code. This allows to have a common design for all module pages.
*
* @param string $module Name of account module
* @param mixed $input htmlElement or array of htmlElement elements
@ -705,213 +571,14 @@ function parseHtml($module, $input, $values, $restricted, &$tabindex, $scope) {
if ($input instanceof htmlElement) {
return $input->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
}
$ret = array();
if (is_array($input) && (sizeof($input) > 0)) {
// check for array of metaHTML objects
if ($input[0] instanceof htmlElement) {
$return = array();
for ($i = 0; $i < sizeof($input); $i++) {
$return = array_merge($return, $input[$i]->generateHTML($module, $input, $values, $restricted, $tabindex, $scope));
}
return $return;
$return = array();
for ($i = 0; $i < sizeof($input); $i++) {
$return = array_merge($return, $input[$i]->generateHTML($module, $input, $values, $restricted, $tabindex, $scope));
}
echo "<table>\n";
for ($i=0; $i<count($input); $i++) { // $i = row number
// Draw column
echo "<tr>\n";
for ($j=0; $j<count($input[$i]); $j++ ) { // $j = column number
// Draw cell
echo "<td";
if (isset($input[$i][$j]['td']['align'])) echo " align=\"" . $input[$i][$j]['td']['align'] . "\"";
if (isset($input[$i][$j]['td']['valign'])) echo " valign=\"" . $input[$i][$j]['td']['valign'] . "\"";
if (isset($input[$i][$j]['td']['colspan'])) echo " colspan=\"" . $input[$i][$j]['td']['colspan'] . "\"";
if (isset($input[$i][$j]['td']['rowspan'])) echo " rowspan=\"" . $input[$i][$j]['td']['rowspan'] . "\"";
if (isset($input[$i][$j]['td']['width'])) echo " width=\"" . $input[$i][$j]['td']['width'] . "\"";
echo ">\n";
switch ($input[$i][$j]['kind']) {
// plain text
case 'text':
if (isset($input[$i][$j]['text'])) echo $input[$i][$j]['text'];
break;
// input fields
case 'input':
$type = $input[$i][$j]['type'];
if ($restricted && (($type == "submit") || ($type == "reset"))) break; // no buttons in restricted mode
$output = "<input";
if ($input[$i][$j]['name']!='') $output .= ' name="' . $input[$i][$j]['name'] . '"';
if ($type != '') $output .= ' type="' . $type . '"';
if (isset($input[$i][$j]['size']) && ($input[$i][$j]['size'] != '')) {
$output .= ' size="' . $input[$i][$j]['size'] . '"';
}
if (isset($input[$i][$j]['maxlength']) && ($input[$i][$j]['maxlength'] != '')) {
$output .= ' maxlength="' . $input[$i][$j]['maxlength'] . '"';
}
// checkbox
if ($type == "checkbox") {
if (isset($values[$input[$i][$j]['name']])) {
if ($values[$input[$i][$j]['name']][0] == "true") $output .= ' checked';
}
elseif (isset($input[$i][$j]['checked']) && ($input[$i][$j]['checked'])) $output .= ' checked';
}
// other input element
else {
if (isset($values[$input[$i][$j]['name']])) {
$output .= ' value="' . htmlspecialchars($values[$input[$i][$j]['name']][0], ENT_QUOTES, "UTF-8") . '"';
}
elseif (isset($input[$i][$j]['value']) && $input[$i][$j]['value']!='') {
$output .= ' value="' . htmlspecialchars($input[$i][$j]['value'], ENT_QUOTES, "UTF-8") . '"';
}
if (($type == "submit") && isset($input[$i][$j]['image'])) {
$output .= ' style="background-image: url(../../graphics/' . $input[$i][$j]['image'] . ');background-position: 2px center;background-repeat: no-repeat;width:24px;height:24px;background-color:transparent"';
}
}
if (isset($input[$i][$j]['title'])) {
$output .= ' title="' . $input[$i][$j]['title'] . '"';
}
if (isset($input[$i][$j]['disabled']) && ($input[$i][$j]['disabled'] == true)) $output .= ' disabled';
// Show taborder
else {
$output .= " tabindex=$tabindex";
$tabindex++;
}
$output .= ">";
echo $output;
$ret[$input[$i][$j]['name']] = $type; // save type
break;
// text area
case 'textarea':
echo "<textarea";
if (isset($input[$i][$j]['name'])) echo ' name="' . $input[$i][$j]['name'] . '"';
if (isset($input[$i][$j]['readonly']) && (isset($input[$i][$j]['readonly']) === true)) echo ' readonly';
echo ' cols="' . $input[$i][$j]['cols'] . '"';
echo ' rows="' . $input[$i][$j]['rows'] . '"';
echo ">";
if (isset($values[$input[$i][$j]['name']])) {
echo htmlspecialchars(implode("\r\n", $values[$input[$i][$j]['name']]), ENT_QUOTES, "UTF-8");
}
else {
if (isset($input[$i][$j]['value'])) {
echo htmlspecialchars($input[$i][$j]['value'], ENT_QUOTES, "UTF-8");
}
}
echo "</textarea>";
$ret[$input[$i][$j]['name']] = 'textarea'; // save type
break;
// inner fieldset
case 'fieldset':
$styleClass = '';
if (isset($scope) && ($scope != '')) {
$styleClass = ' class="' . $scope . 'edit"';
}
echo "<fieldset" . $styleClass . ">\n";
if ($input[$i][$j]['legend']!='') echo "<legend>" . $input[$i][$j]['legend'] . "</legend>\n";
$retTemp = parseHtml($module, $input[$i][$j]['value'], $values, $restricted, $tabindex, $scope);
$ret = array_merge($ret, $retTemp);
echo "</fieldset>\n";
break;
// selection
case 'select':
if (! isset($input[$i][$j]['size'])) $input[$i][$j]['size'] = 1; // correct size if needed
if (isset($input[$i][$j]['multiple'])) {
echo "<select name=\"" . $input[$i][$j]['name'] . '[]"';
echo ' multiple';
$ret[$input[$i][$j]['name']] = 'multiselect'; // save type
}
else {
echo "<select name=\"" . $input[$i][$j]['name'] . '"';
$ret[$input[$i][$j]['name']] = 'select'; // save type
}
echo ' size="' . $input[$i][$j]['size'] . '"';
if (!$restricted && isset($input[$i][$j]['onchange'])) {
echo ' onchange="' . htmlspecialchars($input[$i][$j]['onchange']) . '"';
}
// Show taborder
echo " tabindex=$tabindex";
$tabindex++;
echo ">\n";
// init option fields
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();
}
if (isset($values[$input[$i][$j]['name']])) $input[$i][$j]['options_selected'] = $values[$input[$i][$j]['name']];
// merge both option arrays and sort them.
$options = $input[$i][$j]['options'];
if (!isset($input[$i][$j]['descriptiveOptions']) || ($input[$i][$j]['descriptiveOptions'] === false)) {
// merge both option arrays and sort them.
$options = array_merge($input[$i][$j]['options'], $input[$i][$j]['options_selected'] );
$options = array_unique($options);
if (!isset($input[$i][$j]['noSorting']) || !$input[$i][$j]['noSorting']) {
natcasesort($options);
}
}
else {
if (!isset($input[$i][$j]['noSorting']) || !$input[$i][$j]['noSorting']) {
// sort descriptive options with helper function
usort($options, 'lamCompareDescriptiveOptions');
}
}
foreach ($options as $option) {
if (isset($input[$i][$j]['descriptiveOptions']) && ($input[$i][$j]['descriptiveOptions'] === true)) {
if (in_array($option[0], $input[$i][$j]['options_selected'])) {
echo "<option value=\"" . htmlspecialchars($option[0], ENT_QUOTES, "UTF-8") . "\" selected>" . htmlspecialchars($option[1], ENT_QUOTES, "UTF-8") . "</option>\n";
}
else {
echo "<option value=\"" . htmlspecialchars($option[0], ENT_QUOTES, "UTF-8") . "\">" . htmlspecialchars($option[1], ENT_QUOTES, "UTF-8") . "</option>\n";
}
}
elseif ($option!='') {
if (in_array($option, $input[$i][$j]['options_selected'])) {
echo "<option selected>" . htmlspecialchars($option, ENT_QUOTES, "UTF-8") . "</option>\n";
}
else {
echo "<option>" . htmlspecialchars($option, ENT_QUOTES, "UTF-8") . "</option>\n";
}
}
}
echo "</select>\n";
break;
// sub table
case 'table':
$retTemp = parseHtml($module, $input[$i][$j]['value'], $values, $restricted, $tabindex, $scope);
$ret = array_merge($ret, $retTemp);
break;
// help link
case 'help':
$helpEntry = getHelp($module, $input[$i][$j]['value'], $scope);
printHelpLink($helpEntry, $input[$i][$j]['value'], $module, $scope);
break;
// status message
case 'message':
StatusMessage($input[$i][$j]['type'], $input[$i][$j]['headline'], $input[$i][$j]['text']);
break;
// image
case 'image':
echo "<img ";
if (isset($input[$i][$j]['path'])) echo 'src="' . $input[$i][$j]['path'] . '" ';
if (isset($input[$i][$j]['width'])) echo 'width="' . $input[$i][$j]['width'] . '" ';
if (isset($input[$i][$j]['height'])) echo 'height="' . $input[$i][$j]['height'] . '" ';
if (isset($input[$i][$j]['alt'])) echo 'alt="' . $input[$i][$j]['alt'] . '" ';
echo ">\n";
break;
// error, unknown type
default:
echo "Unrecognized type: " . $input[$i][$j]['kind'] . "\n";
break;
}
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>\n";
return $return;
}
return $ret;
return array();
}
/**