use more metaHTML

This commit is contained in:
Roland Gruber 2012-10-08 18:01:55 +00:00
parent 4d02ce9607
commit de824adfa7
2 changed files with 52 additions and 32 deletions

View File

@ -368,6 +368,8 @@ class htmlInputField extends htmlElement {
private $fieldSize = 30; private $fieldSize = 30;
/** field max length (default 255) */ /** field max length (default 255) */
private $fieldMaxLength = 255; private $fieldMaxLength = 255;
/** on keypress event */
private $onKeyPress = null;
/** password field */ /** password field */
private $isPassword = false; private $isPassword = false;
/** enabled or disabled */ /** enabled or disabled */
@ -458,7 +460,11 @@ class htmlInputField extends htmlElement {
if (!$this->isEnabled) { if (!$this->isEnabled) {
$disabled = ' disabled'; $disabled = ' disabled';
} }
echo '<input type="' . $inputType . '"' . $class . $name . $id . $value . $maxLength . $size . $fieldTabIndex . $disabled . '>'; $onKeyPress = '';
if ($this->onKeyPress != null) {
$onKeyPress = ' onkeypress="' . $this->onKeyPress . '"';
}
echo '<input type="' . $inputType . '"' . $class . $name . $id . $value . $maxLength . $size . $fieldTabIndex . $onKeyPress . $disabled . '>';
// autocompletion // autocompletion
if ($this->autocomplete) { if ($this->autocomplete) {
echo "<script type=\"text/javascript\">\n"; echo "<script type=\"text/javascript\">\n";
@ -566,6 +572,15 @@ class htmlInputField extends htmlElement {
$this->autocompleteValues = $values; $this->autocompleteValues = $values;
$this->autocompleteMinLength = $minLength; $this->autocompleteMinLength = $minLength;
} }
/**
* Sets the JavaScript for the onKeyPress event.
*
* @param String $onKeyPress JavaScript code
*/
public function setOnKeyPress($onKeyPress) {
$this->onKeyPress = $onKeyPress;
}
} }
@ -763,12 +778,13 @@ class htmlButton extends htmlElement {
if ($this->onClick != null) { if ($this->onClick != null) {
$type = ' type="button"'; $type = ' type="button"';
$onClick = ' onclick="' . $this->onClick . '"'; $onClick = ' onclick="' . $this->onClick . '"';
} }
$id = ' id="btn_' . preg_replace('/[^a-zA-Z0-9_-]/', '', $this->name) . '"';
if ($this->isImageButton) { if ($this->isImageButton) {
echo '<input type="submit" id="btn_' . $this->name . '" value=" "' . $name . $fieldTabIndex . $style . $class . $title . $disabled . '>'; echo '<input type="submit" ' . $id . ' value=" "' . $name . $fieldTabIndex . $style . $class . $title . $disabled . '>';
} }
else { else {
echo '<button id="btn_' . $this->name . '"' . $name . $fieldTabIndex . $type . $onClick . $style . $class . $title . $disabled . '>' . $this->value . '</button>'; echo '<button' . $id . $name . $fieldTabIndex . $type . $onClick . $style . $class . $title . $disabled . '>' . $this->value . '</button>';
// text buttons get JQuery style // text buttons get JQuery style
$icon = ''; $icon = '';
if ($this->iconClass != null) { if ($this->iconClass != null) {

View File

@ -348,7 +348,8 @@ class lamList {
printHelpLink(getHelp('', '250'), '250'); printHelpLink(getHelp('', '250'), '250');
echo "</td>\n"; echo "</td>\n";
echo "<td>"; echo "<td>";
echo "<button type=\"submit\" class=\"smallPadding\" id=\"apply_filter\" name=\"apply_filter\">" . _("Filter") . "</button>"; $filterButton = new htmlButton('apply_filter', _("Filter"));
parseHtml(null, $filterButton, array(), false, $this->tabindex, $this->type);
echo "</td>\n"; echo "</td>\n";
// print input boxes for filters // print input boxes for filters
for ($k = 0; $k < sizeof ($this->descArray); $k++) { for ($k = 0; $k < sizeof ($this->descArray); $k++) {
@ -356,12 +357,15 @@ class lamList {
if ($this->canBeFiltered($this->attrArray[$k])) { if ($this->canBeFiltered($this->attrArray[$k])) {
$value = ""; $value = "";
if (isset($_GET["filter" . strtolower($this->attrArray[$k])])) { if (isset($_GET["filter" . strtolower($this->attrArray[$k])])) {
$value = " value=\"" . $_GET["filter" . strtolower($this->attrArray[$k])] . "\""; $value = $_GET["filter" . strtolower($this->attrArray[$k])];
} }
if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) { if (isset($_POST["filter" . strtolower($this->attrArray[$k])])) {
$value = " value=\"" . $_POST["filter" . strtolower($this->attrArray[$k])] . "\""; $value = $_POST["filter" . strtolower($this->attrArray[$k])];
} }
echo "<input style=\"margin-right: 10px;\" type=\"text\" size=15 name=\"filter" . strtolower ($this->attrArray[$k]) ."\"" . $value . " onkeypress=\"SubmitForm('apply_filter', event);\">"; $filterInput = new htmlInputField('filter' . strtolower($this->attrArray[$k]), $value);
$filterInput->setFieldSize('15');
$filterInput->setOnKeyPress("SubmitForm('apply_filter', event);");
parseHtml(null, $filterInput, array(), false, $this->tabindex, $this->type);
} }
echo "</td>\n"; echo "</td>\n";
} }
@ -432,35 +436,36 @@ class lamList {
* @param String $id account ID * @param String $id account ID
*/ */
private function listPrintToolLinks($account, $id) { private function listPrintToolLinks($account, $id) {
$output = '';
$toolCount = 0; $toolCount = 0;
// edit image $group = new htmlGroup();
$output .= "<a href=\"../account/edit.php?type=" . $this->type . "&amp;DN='" . rawurlencode($account['dn']) . "'\">"; // edit link
$output .= "<img height=16 width=16 src=\"../../graphics/edit.png\" alt=\"" . _("Edit") . "\" title=\"" . _("Edit") . "\" class=\"align-middle\">"; $editLink = new htmlLink('', "../account/edit.php?type=" . $this->type . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/edit.png');
$output .= "</a>\n "; $editLink->setTitle(_("Edit"));
$group->addElement($editLink);
$toolCount++; $toolCount++;
// delete image // delete link
if (checkIfWriteAccessIsAllowed()) { if (checkIfWriteAccessIsAllowed()) {
$output .= "<a href=\"deletelink.php?type=" . $this->type . "&amp;DN='" . rawurlencode($account['dn']) . "'\">"; $deleteLink = new htmlLink('', "deletelink.php?type=" . $this->type . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/delete.png');
$output .= "<img height=16 width=16 src=\"../../graphics/delete.png\" alt=\"" . _("Delete") . "\" title=\"" . _("Delete") . "\" class=\"align-middle\">"; $deleteLink->setTitle(_("Delete"));
$output .= "</a>\n "; $group->addElement($deleteLink);
$toolCount++; $toolCount++;
} }
// pdf image // PDF button
$pdfButtonStyle = "background-image: url(../../graphics/pdf.png);background-position: -1px -1px;background-repeat: no-repeat;width:20px;height:20px;background-color:transparent;border-style:none;"; $pdfButton = new htmlButton("createPDF_" . $id, 'pdf.png', true);
$output .= "<input type=\"submit\" style=\"$pdfButtonStyle\" name=\"createPDF_" . $id . "\" value=\" \" title=\"" . _('Create PDF file') . "\" class=\"align-middle\">\n "; $pdfButton->setTitle(_('Create PDF file'));
$group->addElement($pdfButton);
$toolCount++; $toolCount++;
// additional tools // additional tools
$tools = $this->getAdditionalTools(); $tools = $this->getAdditionalTools();
for ($i = 0; $i < sizeof($tools); $i++) { for ($i = 0; $i < sizeof($tools); $i++) {
$output .= "<a href=\"" . $tools[$i]->getLinkTarget() . "?type=" . $this->type . "&amp;DN='" . rawurlencode($account['dn']) . "'\">"; $toolLink = new htmlLink('', $tools[$i]->getLinkTarget() . "?type=" . $this->type . "&DN='" . rawurlencode($account['dn']) . "'", '../../graphics/' . $tools[$i]->getImage());
$output .= "<img height=16 width=16 src=\"../../graphics/" . $tools[$i]->getImage() . "\" alt=\"" . $tools[$i]->getName() . "\" title=\"" . $tools[$i]->getName() . "\" class=\"align-middle\">"; $toolLink->setTitle($tools[$i]->getName());
$output .= "</a>\n "; $group->addElement($toolLink);
$toolCount++; $toolCount++;
} }
$width = ($toolCount * 20) + 20; $width = ($toolCount * 20) + 20;
echo "<td align='center' style=\"white-space: nowrap; width: ${width}px\">"; echo "<td align='center' style=\"white-space: nowrap; width: ${width}px;\">";
echo $output; parseHtml(null, $group, array(), false, $this->tabindex, $this->type);
echo "</td>\n"; echo "</td>\n";
} }
@ -627,12 +632,6 @@ class lamList {
echo "<div class=\"smallPaddingContent\">\n"; echo "<div class=\"smallPaddingContent\">\n";
echo "<form action=\"list.php?type=" . $this->type . "&amp;norefresh=true\" method=\"post\">\n"; echo "<form action=\"list.php?type=" . $this->type . "&amp;norefresh=true\" method=\"post\">\n";
// hiden inputs for selected accounts
for ($i = 0; $i < sizeof($selAccounts); $i++) {
echo '<input type="hidden" name="' . $selAccounts[$i] . '" value="on">';
}
echo '<input type="hidden" name="clickedAccount" value="' . $id . '">';
$container = new htmlTable(); $container = new htmlTable();
$container->addElement(new htmlSubTitle(_('Create PDF file')), true); $container->addElement(new htmlSubTitle(_('Create PDF file')), true);
@ -660,7 +659,12 @@ class lamList {
$buttonContainer->colspan = 3; $buttonContainer->colspan = 3;
$buttonContainer->addElement(new htmlButton('createPDFok', _('Ok'))); $buttonContainer->addElement(new htmlButton('createPDFok', _('Ok')));
$buttonContainer->addElement(new htmlButton('createPDFCancel', _('Cancel'))); $buttonContainer->addElement(new htmlButton('createPDFCancel', _('Cancel')));
$container->addElement($buttonContainer); $container->addElement($buttonContainer, true);
// hidden inputs for selected accounts
for ($i = 0; $i < sizeof($selAccounts); $i++) {
$container->addElement(new htmlHiddenInput($selAccounts[$i], 'on'));
}
$container->addElement(new htmlHiddenInput('clickedAccount', $id));
parseHtml(null, $container, array(), false, $this->tabindex, $this->type); parseHtml(null, $container, array(), false, $this->tabindex, $this->type);