From b1724f012045eb0f377df5172e5c47062b183036 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 24 Oct 2010 13:52:51 +0000 Subject: [PATCH] new meta HTML classes --- lam/docs/devel/mod_accountPages.htm | 57 ++++++++++++----------- lam/docs/devel/mod_config.htm | 72 +++++++---------------------- lam/docs/devel/mod_profiles.htm | 34 +++----------- lam/docs/devel/mod_upload.htm | 41 ++++++---------- 4 files changed, 68 insertions(+), 136 deletions(-) diff --git a/lam/docs/devel/mod_accountPages.htm b/lam/docs/devel/mod_accountPages.htm index cf684a0d..f9d8a024 100644 --- a/lam/docs/devel/mod_accountPages.htm +++ b/lam/docs/devel/mod_accountPages.htm @@ -1,9 +1,8 @@ Module HowTo - Account pages + - - - +

Module HowTo - Account pages

@@ -94,39 +93,41 @@ contains the LDAP attributes which are useful for this module.
    * This function will create the meta HTML code to show a page with all attributes.
    *
-    * @param array $post HTTP-POST values
+    * @return htmlElement HTML meta data
    */
-    function display_html_attributes($post) {
-        $return = array();
+    function display_html_attributes() {
        $return = new htmlTable();
+        $macCount = 0;
        // list current MACs
-        for ($i = 0; $i < -sizeof($this->attributes['macAddress']); $i++) {
-            $return[] = -array(
+        if (isset($this->attributes['macAddress'])) {
+            $macCount = sizeof($this->attributes['macAddress']);
+            for ($i = 0; +$i < sizeof($this->attributes['macAddress']); $i++) {
            -    array('kind' => 'text', 'text' => -_('MAC address')),
+    $return->addElement(new htmlOutputText(_('MAC +address')));
            -    array('kind' => 'input', 'name' => -'macAddress' . $i, 'type' => 'text', 'size' => '17', 'maxlength' -=> '17', 'value' => $this->attributes['macAddress'][$i]),
+    $macInput = new htmlInputField('macAddress' . $i, +$this->attributes['macAddress'][$i]);
+                $macInput->setFieldSize(17);
+                $macInput->setFieldMaxLength(17);
+                $return->addElement($macInput);
            -    array('kind' => 'input', 'type' => -'submit', 'name' => 'delMAC' . $i, 'value' => _("Remove")),
+    $return->addElement(new htmlButton('delMAC' . $i, +'del.png', true));
            -    array('kind' => 'help', 'value' => -'mac'));
+    $return->addElement(new htmlHelpLink('mac'), +true);
+            }
        }
        // input box for new MAC
-        $return[] = array(
-            array('kind' => 'text', 'text' => _('New MAC address')),
-            array('kind' => 'input', 'name' => 'macAddress', 'type' => -'text', 'size' => '17', 'maxlength' => '17', 'value' => ''),
-            array('kind' => 'input', 'type' => 'submit', 'name' => -'addMAC', 'value' => _("Add")),
-            array('kind' => 'help', 'value' => 'mac'),
-            array('kind' => 'input', 'type' => 'hidden', 'value' => -sizeof($this->attributes['macAddress']), 'name' => 'mac_number'));
+        $return->addElement(new htmlOutputText(_('New MAC address')));
+        $newMacInput = new htmlInputField('macAddress', '');
+        $newMacInput->setFieldSize(17);
+        $newMacInput->setFieldMaxLength(17);
+        $return->addElement($newMacInput);
+        $return->addElement(new htmlButton('addMAC', 'add.png', true));
+        $return->addElement(new htmlHelpLink('mac'));
+        $return->addElement(new htmlHiddenInput('mac_number', $macCount));
        return $return;
    }
diff --git a/lam/docs/devel/mod_config.htm b/lam/docs/devel/mod_config.htm index d4e6c138..373af105 100644 --- a/lam/docs/devel/mod_config.htm +++ b/lam/docs/devel/mod_config.htm @@ -1,11 +1,9 @@ Module HowTo - Configuration options + - - - - +

Module HowTo - Configuration options


@@ -31,9 +29,7 @@ or meta['config_options'].

Example:

-The posixGroup module offers -three configuration options. The min/maximum values for GIDs and the -password hash type.
+The posixGroup module offers several configuration options including the min/maximum values for GIDs.

@@ -48,60 +44,26 @@ class
get_metaData() {
        $return = array();
        // configuration options
-        $return['config_options']['group'] = array(
-            array(
-           -     array('kind' => 'text', 'text' => -'<b>' . -_('Minimum GID number') . " *: </b>"),
-                array('kind' => 'input', 'name' => -'posixGroup_minGID', 'type' => 'text', 'size' => '10', -'maxlength' => '255'),
-           -     array('kind' => 'text', 'value' => -'&nbsp;'),
-           -     array('kind' => 'text', 'text' => -'<b>' . -_('Maximum GID number') . " *: </b>"),
-                array('kind' => 'input', 'name' => -'posixGroup_maxGID', 'type' => 'text', 'size' => '10', -'maxlength' => '255'),
-           -     array('kind' => 'help', 'value' => -'minMaxGID')),
-            array(
-           -     array('kind' => 'text', 'text' => -'<b>' . -_("Password hash type") . ': &nbsp;</b>'),
-                array('kind' => 'select', 'name' => -'posixGroup_pwdHash', 'size' => '1', 'options' => array("CRYPT", "SHA", "SSHA", "MD5", "SMD5", -"PLAIN"), 'options_selected' => array('SSHA')),
-           -     array('kind' => 'text', 'value' => -'&nbsp;'),
-           -     array('kind' => 'text', 'value' => -'&nbsp;'),
-           -     array('kind' => 'text', 'value' => -'&nbsp;'),
-                array('kind' => 'help', 'value' => 'pwdHash'))
-        );
+        $configContainer = new htmlTable();
+        $configContainer->addElement(new htmlSubTitle(_("Groups")), true);
+        $minGidInput = new +htmlTableExtendedInputField(_('Minimum GID number'), +'posixGroup_minGID', null, 'minMaxGID');
+        $minGidInput->setRequired(true);
+        $configContainer->addElement($minGidInput, true);
+        $maxGidInput = new +htmlTableExtendedInputField(_('Maximum GID number'), +'posixGroup_maxGID', null, 'minMaxGID');
+        $maxGidInput->setRequired(true);
+        $configContainer->addElement($maxGidInput, true);
+        $return['config_options']['group'] = $configContainer;
        [...]

-The min/maximum GID numbers are defined with simple text boxes. The -password hash is selected with a drop down box and SSHA as default -value.
-You should make sure that the column count (here: 6) is the same for -each row. Otherwise the configuration page might be badly rendered by -the browser.
-
+The min/maximum GID numbers are defined with simple text boxes.

2. Checking user input

Probably you also want to check if the input data is syntactically correct.
diff --git a/lam/docs/devel/mod_profiles.htm b/lam/docs/devel/mod_profiles.htm index 1034b1a3..a7ac2ca0 100644 --- a/lam/docs/devel/mod_profiles.htm +++ b/lam/docs/devel/mod_profiles.htm @@ -1,10 +1,8 @@ Module HowTo - Account profiles - - - - + +

Module HowTo - Account profiles

@@ -48,28 +46,10 @@ get_metaData() {
        $return = array();
        // profile elements
        $return['profile_options'] = array(
-            array(
-            -    array('kind' => 'text', 'text' => -_('Job title') . ":"),
-            -    array('kind' => 'input', 'name' => -'inetOrgPerson_title', 'type' => 'text', 'size' => '30', -'maxlength' => '255'),
-            -    array('kind' => 'help', 'value' => -'title')),
-            array(
-            -    array('kind' => 'text', 'text' => -_('Employee type') . ":"),
-            -    array('kind' => 'input', 'name' => -'inetOrgPerson_employeeType', 'type' => 'text', 'size' => '30', -'maxlength' => '255'),
-            -    array('kind' => 'help', 'value' => -'employeeType'))
+            new +htmlTableExtendedInputField(_('Job title'), 'inetOrgPerson_title', +null, 'title'),
+            new htmlTableExtendedInputField(_('Employee type'), 'inetOrgPerson_employeeType', null, 'employeeType')
        );
        [...]
@@ -79,7 +59,7 @@ _('Employee type') . ":"),

This defines two text boxes in the profile editor, one for the job title and one for the employee type.
-Your profile options should also provide a help link if the description +Your profile options should also provide a help link because the description of the input element might be not enough.


diff --git a/lam/docs/devel/mod_upload.htm b/lam/docs/devel/mod_upload.htm index 1877fdf3..403d8745 100644 --- a/lam/docs/devel/mod_upload.htm +++ b/lam/docs/devel/mod_upload.htm @@ -1,11 +1,10 @@ - - - Module HowTo - File upload +Module HowTo - File upload + + + - - - +

Module HowTo - File upload

@@ -22,14 +21,12 @@ and several other values.
The upload columns are specified with get_uploadColumns() or meta['upload_columns'].

-Example:
+Example:

The ieee802Device module has only one attribute and therefore one column: the MAC address.

- +
    /**
@@ -46,11 +43,9 @@ get_metaData() {
    $return["account_types"] = array("host");
        // upload fields
    -    $return['upload_columns'] = array(
+    $return['upload_columns'] = array(
    -        array(
+        array(
                'name' => 'ieee802Device_mac',
@@ -64,8 +59,7 @@ get_metaData() {
            'example' => '00:01:02:DE:EF:18'
    -        )
+        )
        );
        return $return;
@@ -85,16 +79,14 @@ This is done with build_uploadAccounts() The function gets the input data and a list of LDAP accounts as parameter.

-Example:
+Example:

The ieee802Device module has only one LDAP attribute - 'macAddress' - and the 'ieee802Device' objectClass which is added to all accounts.

- +
    /**
@@ -105,12 +97,10 @@ objectClass which is added to all accounts.
    * @param array $partialAccounts list of hash arrays (name => value) which are later added to LDAP
    * @param array $ids list of IDs for column position -(e.g. "posixAccount_uid" => 5)
  -   * @param array $selectedModules list of selected account modules
+(e.g. "posixAccount_uid" => 5)
    * @param array $selectedModules list of selected account modules
    * @return array list of error messages if any
    */
-    function build_uploadAccounts($rawAccounts, +    function build_uploadAccounts($rawAccounts, $ids, &$partialAccounts, $selectedModules) {
        $messages = array();
        for ($i = 0; $i < @@ -169,5 +159,4 @@ $errMsg;

- - + \ No newline at end of file