use new meta HTML for self service
This commit is contained in:
parent
c85e718178
commit
f865f365f6
167
lam/lib/html.inc
167
lam/lib/html.inc
|
@ -68,14 +68,16 @@ abstract class htmlElement {
|
||||||
class htmlTable extends htmlElement {
|
class htmlTable extends htmlElement {
|
||||||
|
|
||||||
/** table header */
|
/** table header */
|
||||||
const header = "<table>\n<tr>\n";
|
const header = "<table>\n";
|
||||||
/** table footer */
|
/** table footer */
|
||||||
const footer = "</tr>\n</table>\n";
|
const footer = "</table>\n";
|
||||||
/** new line */
|
/** new line */
|
||||||
const newLine = "</tr><tr>\n";
|
const newLine = "</tr><tr>\n";
|
||||||
|
|
||||||
/** list of subelements */
|
/** list of subelements */
|
||||||
private $elements = array();
|
private $elements = array();
|
||||||
|
/** specifies if currently a row is open */
|
||||||
|
private $rowOpen = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an element to the table. The element may be a htmlElement object or a simple String.
|
* Adds an element to the table. The element may be a htmlElement object or a simple String.
|
||||||
|
@ -85,7 +87,22 @@ class htmlTable extends htmlElement {
|
||||||
* @param array $options list of options (e.g. htmlElement::OPTION_ALIGN => htmlElement::ALIGN_TOP)
|
* @param array $options list of options (e.g. htmlElement::OPTION_ALIGN => htmlElement::ALIGN_TOP)
|
||||||
*/
|
*/
|
||||||
public function addElement($element, $newLine = false) {
|
public function addElement($element, $newLine = false) {
|
||||||
if ($element instanceof htmlElement) {
|
// add row element
|
||||||
|
if ($element instanceof htmlTableRow) {
|
||||||
|
// check if a row needs to be closed
|
||||||
|
if ($this->rowOpen) {
|
||||||
|
$this->elements[] = "</tr>\n";
|
||||||
|
$this->rowOpen = false;
|
||||||
|
}
|
||||||
|
$this->elements[] = $element;
|
||||||
|
}
|
||||||
|
// add cell element
|
||||||
|
elseif ($element instanceof htmlElement) {
|
||||||
|
// check if a row needs to be opened
|
||||||
|
if (!$this->rowOpen) {
|
||||||
|
$this->elements[] = "<tr>\n";
|
||||||
|
$this->rowOpen = true;
|
||||||
|
}
|
||||||
// check if alignment option was given
|
// check if alignment option was given
|
||||||
$align = '';
|
$align = '';
|
||||||
if ($element->alignment !== null) {
|
if ($element->alignment !== null) {
|
||||||
|
@ -120,8 +137,13 @@ class htmlTable extends htmlElement {
|
||||||
* Adds another line to the table.
|
* Adds another line to the table.
|
||||||
*/
|
*/
|
||||||
public function addNewLine() {
|
public function addNewLine() {
|
||||||
|
if (!$this->rowOpen) {
|
||||||
|
$this->elements[] = "<tr>\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
$this->elements[] = htmlTable::newLine;
|
$this->elements[] = htmlTable::newLine;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the HTML code for this element.
|
* Prints the HTML code for this element.
|
||||||
|
@ -151,12 +173,60 @@ class htmlTable extends htmlElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($this->rowOpen) {
|
||||||
|
echo "</tr>\n";
|
||||||
|
}
|
||||||
echo htmlTable::footer;
|
echo htmlTable::footer;
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A row inside a htmlTable.
|
||||||
|
*
|
||||||
|
* @see htmlTable
|
||||||
|
* @package metaHTML
|
||||||
|
*/
|
||||||
|
class htmlTableRow extends htmlElement {
|
||||||
|
|
||||||
|
private $cells;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param array $cells list of htmlElements
|
||||||
|
* @see htmlElement
|
||||||
|
*/
|
||||||
|
function __construct($cells) {
|
||||||
|
$this->cells = $cells;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
$types = array();
|
||||||
|
echo "<tr>\n";
|
||||||
|
for ($i = 0; $i < sizeof($this->cells); $i++) {
|
||||||
|
echo "<td>\n";
|
||||||
|
$types = array_merge($types, $this->cells[$i]->generateHTML($module, $input, $values, $restricted, $tabindex, $scope));
|
||||||
|
echo "</td>\n";
|
||||||
|
}
|
||||||
|
echo "</tr>";
|
||||||
|
return $types;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extended input field that combines label, input field and help.
|
* An extended input field that combines label, input field and help.
|
||||||
*
|
*
|
||||||
|
@ -695,6 +765,7 @@ class htmlTableExtendedInputCheckbox extends htmlInputCheckbox {
|
||||||
* @param boolean $checked checked
|
* @param boolean $checked checked
|
||||||
* @param String $label descriptive label
|
* @param String $label descriptive label
|
||||||
* @param String $helpID help ID
|
* @param String $helpID help ID
|
||||||
|
* @param boolean $labelFirst specifies if the label is at the beginning or at the end (optional, default beginning)
|
||||||
*/
|
*/
|
||||||
function __construct($name, $checked, $label, $helpID = null, $labelFirst = true) {
|
function __construct($name, $checked, $label, $helpID = null, $labelFirst = true) {
|
||||||
parent::__construct($name, $checked);
|
parent::__construct($name, $checked);
|
||||||
|
@ -736,6 +807,96 @@ class htmlTableExtendedInputCheckbox extends htmlInputCheckbox {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the HTML code for a file upload field.
|
||||||
|
*
|
||||||
|
* @package metaHTML
|
||||||
|
*/
|
||||||
|
class htmlInputFileUpload extends htmlElement {
|
||||||
|
|
||||||
|
/** unique name of input element */
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param String $name unique name
|
||||||
|
*/
|
||||||
|
function __construct($name) {
|
||||||
|
$this->name = htmlspecialchars($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
$tabindexValue = ' tabindex="' . $tabindex . '"';
|
||||||
|
$tabindex++;
|
||||||
|
echo '<input type="file" name="' . $this->name . '"' . $tabindexValue . '>';
|
||||||
|
return array($this->name => 'file');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File upload with descriptive label and help link.
|
||||||
|
*
|
||||||
|
* @package metaHTML
|
||||||
|
*/
|
||||||
|
class htmlTableExtendedInputFileUpload extends htmlInputFileUpload {
|
||||||
|
|
||||||
|
/** descriptive label */
|
||||||
|
private $label;
|
||||||
|
/** help ID */
|
||||||
|
private $helpID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param String $name unique name
|
||||||
|
* @param String $label descriptive label
|
||||||
|
* @param String $helpID help ID
|
||||||
|
*/
|
||||||
|
function __construct($name, $label, $helpID = null) {
|
||||||
|
parent::__construct($name);
|
||||||
|
$this->label = htmlspecialchars($label);
|
||||||
|
$this->helpID = $helpID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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) {
|
||||||
|
echo $this->label;
|
||||||
|
echo "\n</td>\n<td>\n";
|
||||||
|
$return = parent::generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
|
||||||
|
// print help link
|
||||||
|
if ($this->helpID != null) {
|
||||||
|
echo "\n</td>\n<td>\n";
|
||||||
|
$helpLink = new htmlHelpLink($this->helpID);
|
||||||
|
$helpLink->generateHTML($module, $input, $values, $restricted, $tabindex, $scope);
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the HTML code for a textarea.
|
* Prints the HTML code for a textarea.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1005,17 +1005,13 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
* @return array meta HTML code
|
* @return array meta HTML code
|
||||||
*/
|
*/
|
||||||
function display_html_photo() {
|
function display_html_photo() {
|
||||||
$return[] = array(
|
$container = new htmlTable();
|
||||||
array('kind' => 'text', 'text' => _('Photo file (JPG format)') ),
|
$container->addElement(new htmlTableExtendedInputFileUpload('photoFile', _('Photo file (JPG format)'), 'photoUpload'), true);
|
||||||
array('kind' => 'input', 'name' => 'photoFile', 'type' => 'file'),
|
$buttonContainer = new htmlTable();
|
||||||
array('kind' => 'help', 'value' => 'photoUpload'));
|
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'submit', _('Add photo')));
|
||||||
$return[] = array(
|
$buttonContainer->addElement(new htmlAccountPageButton(get_class($this), 'attributes', 'back', _('Back')));
|
||||||
array('kind' => 'table', 'value' => array(
|
$container->addElement($buttonContainer);
|
||||||
array(
|
return $container;
|
||||||
array('kind' => 'input', 'type' => 'submit', 'value' => _('Add photo'), 'name' => 'form_subpage_' . get_class($this) . '_attributes_submit'),
|
|
||||||
array('kind' => 'input', 'type' => 'submit', 'value' => _('Back'), 'name' => 'form_subpage_' . get_class($this) . '_attributes_back'),
|
|
||||||
array('kind' => 'text')))));
|
|
||||||
return $return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1377,10 +1373,9 @@ class inetOrgPerson extends baseModule implements passwordService {
|
||||||
if (in_array('firstName', $fields)) {
|
if (in_array('firstName', $fields)) {
|
||||||
$firstName = '';
|
$firstName = '';
|
||||||
if (isset($attributes['givenName'][0])) $firstName = $attributes['givenName'][0];
|
if (isset($attributes['givenName'][0])) $firstName = $attributes['givenName'][0];
|
||||||
$return['firstName'] = array(
|
$return['firstName'] = new htmlTableRow(array(
|
||||||
array('kind' => 'text', 'text' => _('First name')),
|
new htmlTableExtendedInputField(_('First name'), 'inetOrgPerson_firstName', $firstName)
|
||||||
array('kind' => 'input', 'name' => 'inetOrgPerson_firstName', 'type' => 'text', 'size' => '30',
|
));
|
||||||
'maxlength' => '255', 'value' => $firstName));
|
|
||||||
}
|
}
|
||||||
if (in_array('lastName', $fields)) {
|
if (in_array('lastName', $fields)) {
|
||||||
$lastName = '';
|
$lastName = '';
|
||||||
|
|
|
@ -90,7 +90,7 @@ function getSelfServiceFieldSettings($scope) {
|
||||||
* @param string $scope account type
|
* @param string $scope account type
|
||||||
* @param array $fields input fields (array(<moduleName> => array(<field1>, <field2>, ...)))
|
* @param array $fields input fields (array(<moduleName> => array(<field1>, <field2>, ...)))
|
||||||
* @param array $attributes LDAP attributes (attribute names in lower case)
|
* @param array $attributes LDAP attributes (attribute names in lower case)
|
||||||
* @return array meta HTML code (array(<moduleName> => array(<field1> => array(<meta HTML>))))
|
* @return array meta HTML code (array(<moduleName> => htmlTableRow))
|
||||||
*/
|
*/
|
||||||
function getSelfServiceOptions($scope, $fields, $attributes) {
|
function getSelfServiceOptions($scope, $fields, $attributes) {
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
Loading…
Reference in New Issue