more meta HTML
This commit is contained in:
parent
9dbcb09ea7
commit
69dc17e28d
|
@ -2437,6 +2437,71 @@ class htmlHorizontalLine extends htmlElement {
|
|||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a simple DIV element.
|
||||
*
|
||||
* @package metaHTML
|
||||
*/
|
||||
class htmlDiv extends htmlElement {
|
||||
|
||||
/** unique ID */
|
||||
private $id = null;
|
||||
/** htmlElement that generates inner content */
|
||||
private $content = null;
|
||||
/** CSS classes */
|
||||
private $classes = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param String $id unique ID
|
||||
* @param htmlElement $content inner content
|
||||
* @param array $classes CSS classes
|
||||
*/
|
||||
function __construct($id, $content, $classes = array()) {
|
||||
$this->id = htmlspecialchars($id);
|
||||
$this->content = $content;
|
||||
$this->classes = $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the HTML code for this element.
|
||||
*
|
||||
* @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 string $scope Account type
|
||||
* @return array List of input field names and their type (name => type)
|
||||
*/
|
||||
function generateHTML($module, $input, $values, $restricted, &$tabindex, $scope) {
|
||||
$return = array();
|
||||
$idValue = '';
|
||||
if ($this->id != null) {
|
||||
$idValue = ' id="' . $this->id . '"';
|
||||
}
|
||||
$classesValue = '';
|
||||
if (($this->classes != null) && (sizeof($this->classes) > 0)) {
|
||||
$classesValue = ' class="';
|
||||
for ($i = 0; $i < sizeof($this->classes); $i++) {
|
||||
$classesValue .= htmlspecialchars($this->classes[$i]) . ' ';
|
||||
}
|
||||
$classesValue .= '"';
|
||||
}
|
||||
echo '<div' . $idValue . $classesValue . '>';
|
||||
if ($this->content != null) {
|
||||
$return = $this->content->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
|
||||
}
|
||||
echo '</div>';
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -132,87 +132,86 @@ echo "<p> </p>\n";
|
|||
|
||||
echo "<form enctype=\"multipart/form-data\" action=\"masscreate.php\" method=\"post\">\n";
|
||||
|
||||
echo "<table style=\"border-color: grey\" cellpadding=\"10\" border=\"0\" cellspacing=\"0\">\n";
|
||||
echo "<tr><td>\n";
|
||||
echo '<b>' . _("Account type") . ':</b>';
|
||||
echo "</td>\n";
|
||||
echo "<td>\n";
|
||||
echo "<select class=\"$divClass\" name=\"type\" onChange=\"changeVisibleModules(this);\">\n";
|
||||
$sortedTypes = array();
|
||||
$tabindex = 1;
|
||||
$table = new htmlTable();
|
||||
|
||||
// account type
|
||||
$typeList = array();
|
||||
for ($i = 0; $i < sizeof($types); $i++) {
|
||||
$sortedTypes[$types[$i]] = getTypeAlias($types[$i]);
|
||||
$typeList[getTypeAlias($types[$i])] = $types[$i];
|
||||
}
|
||||
natcasesort($sortedTypes);
|
||||
foreach ($sortedTypes as $key => $value) {
|
||||
$selected = '';
|
||||
if (isset($_REQUEST['type']) && ($_REQUEST['type'] == $key)) {
|
||||
$selected = 'selected';
|
||||
}
|
||||
echo "<option value=\"" . $key . "\" $selected>" . $value . "</option>\n";
|
||||
}
|
||||
echo "</select>\n";
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr><td valign=\"top\">\n";
|
||||
echo '<b>' . _('Selected modules') . ':</b>';
|
||||
echo "</td>\n";
|
||||
echo "<td>\n";
|
||||
// generate one DIV for each account type
|
||||
$counter = 0;
|
||||
foreach ($sortedTypes as $type => $label) {
|
||||
$style = 'style="display:none;"';
|
||||
if ((!isset($_REQUEST['type']) && ($counter == 0)) || (isset($_REQUEST['type']) && ($_REQUEST['type'] == $type))) {
|
||||
// show first account type or last selected one
|
||||
$style = '';
|
||||
}
|
||||
echo "<div $style id=\"" . $type . "\" class=\"typeOptions\">\n";
|
||||
echo "<table border=0>";
|
||||
$modules = $_SESSION['config']->get_AccountModules($type);
|
||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
||||
if ($m%3 == 0) {
|
||||
echo "<tr>\n";
|
||||
}
|
||||
echo "<td>";
|
||||
$module = new $modules[$m]($type);
|
||||
$iconImage = $module->getIcon();
|
||||
echo '<img align="middle" src="../graphics/' . $iconImage . '" alt="' . $iconImage . '">';
|
||||
echo "</td><td>\n";
|
||||
if (is_base_module($modules[$m], $type)) {
|
||||
echo "<input type=\"hidden\" name=\"" . $type . '_' . $modules[$m] . "\" value=\"on\"><input type=\"checkbox\" checked disabled>";
|
||||
$selectedType = array();
|
||||
if (isset($_REQUEST['type'])) {
|
||||
$selectedType[] = $_REQUEST['type'];
|
||||
}
|
||||
else {
|
||||
$checked = 'checked';
|
||||
if (isset($_POST['submit']) && !isset($_POST[$type . '_' . $modules[$m]])) {
|
||||
$checked = '';
|
||||
$selectedType[] = $types[0];
|
||||
}
|
||||
echo "<input type=\"checkbox\" name=\"" . $type . '_' . $modules[$m] . "\" $checked>";
|
||||
$typeSelect = new htmlTableExtendedSelect('type', $typeList, $selectedType, _("Account type"));
|
||||
$typeSelect->setHasDescriptiveElements(true);
|
||||
$typeSelect->setOnchangeEvent('changeVisibleModules(this);');
|
||||
$table->addElement($typeSelect, true);
|
||||
$table->addElement(new htmlSpacer(null, '10px'), true);
|
||||
|
||||
// module selection
|
||||
$moduleLabel = new htmlOutputText(_('Selected modules'));
|
||||
$moduleLabel->alignment = htmlElement::ALIGN_TOP;
|
||||
$table->addElement($moduleLabel);
|
||||
$moduleGroup = new htmlGroup();
|
||||
for ($i = 0; $i < sizeof($types); $i++) {
|
||||
$divClasses = array('typeOptions');
|
||||
if ((!isset($_REQUEST['type']) && ($i != 0)) || (isset($_REQUEST['type']) && ($_REQUEST['type'] != $types[$i]))) {
|
||||
$divClasses[] = 'hidden';
|
||||
}
|
||||
echo getModuleAlias($modules[$m], $type);
|
||||
echo " </td>";
|
||||
if (($m%3 == 2) && ($m != (sizeof($modules) - 1))) {
|
||||
echo "</tr>\n";
|
||||
$innerTable = new htmlTable();
|
||||
$modules = $_SESSION['config']->get_AccountModules($types[$i]);
|
||||
for ($m = 0; $m < sizeof($modules); $m++) {
|
||||
if (($m != 0) && ($m%3 == 0)) {
|
||||
echo $innerTable->addNewLine();
|
||||
}
|
||||
$module = new $modules[$m]($types[$i]);
|
||||
$iconImage = '../graphics/' . $module->getIcon();
|
||||
$innerTable->addElement(new htmlImage($iconImage));
|
||||
$enabled = true;
|
||||
if (is_base_module($modules[$m], $types[$i])) {
|
||||
$enabled = false;
|
||||
}
|
||||
echo "</tr>";
|
||||
echo "</table>\n";
|
||||
echo "</div>\n";
|
||||
$counter++;
|
||||
$checked = true;
|
||||
if (isset($_POST['submit']) && !isset($_POST[$types[$i] . '_' . $modules[$m]])) {
|
||||
$checked = false;
|
||||
}
|
||||
echo "</td></tr>\n";
|
||||
echo "<tr><td>\n";
|
||||
echo "<button id=\"okButton\" class=\"smallPadding\" name=\"submit\">". _("Ok") . "</button>\n";
|
||||
$checkbox = new htmlTableExtendedInputCheckbox($types[$i] . '_' . $modules[$m], $checked, getModuleAlias($modules[$m], $types[$i]), null, false);
|
||||
$checkbox->setIsEnabled($enabled);
|
||||
if ($enabled) {
|
||||
$innerTable->addElement($checkbox);
|
||||
}
|
||||
else {
|
||||
$boxGroup = new htmlGroup();
|
||||
$boxGroup->addElement($checkbox);
|
||||
// add hidden field to fake disabled checkbox value
|
||||
$boxGroup->addElement(new htmlHiddenInput($types[$i] . '_' . $modules[$m], 'on'));
|
||||
$innerTable->addElement($boxGroup);
|
||||
}
|
||||
$innerTable->addElement(new htmlSpacer('10px', null));
|
||||
}
|
||||
$typeDiv = new htmlDiv($types[$i], $innerTable, $divClasses);
|
||||
$moduleGroup->addElement($typeDiv);
|
||||
}
|
||||
$table->addElement($moduleGroup, true);
|
||||
|
||||
// ok button
|
||||
$table->addElement(new htmlSpacer(null, '20px'), true);
|
||||
$table->addElement(new htmlButton('submit', _('Ok')), true);
|
||||
|
||||
parseHtml(null, $table, array(), false, $tabindex, 'user');
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('#okButton').button();
|
||||
});
|
||||
function changeVisibleModules(element) {
|
||||
jQuery('div.typeOptions').toggle(false);
|
||||
jQuery('div#' + element.options[element.selectedIndex].value).toggle();
|
||||
}
|
||||
</script>
|
||||
<?php
|
||||
echo "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "</form>\n";
|
||||
|
||||
echo '</div>';
|
||||
|
|
Loading…
Reference in New Issue