responsive schema browser

This commit is contained in:
Roland Gruber 2018-01-12 17:57:32 +01:00
parent 05fac42d77
commit 999e22a2d1
6 changed files with 401 additions and 497 deletions

View File

@ -2,7 +2,7 @@
/* /*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2010 - 2017 Roland Gruber Copyright (C) 2010 - 2018 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -61,6 +61,8 @@ abstract class htmlElement {
protected $cssClasses = array(); protected $cssClasses = array();
/** table cell CSS classes */ /** table cell CSS classes */
protected $tableCellCssClasses = array(); protected $tableCellCssClasses = array();
/** data attributes */
private $dataAttributes = array();
/** /**
* Prints the HTML code for this element. * Prints the HTML code for this element.
@ -155,6 +157,29 @@ abstract class htmlElement {
return $this->tableCellCssClasses; return $this->tableCellCssClasses;
} }
/**
* Adds a data attribute.
*
* @param string $key attribute name (without "data-")
* @param string $value attribute value
*/
public function addDataAttribute($key, $value) {
$this->dataAttributes[$key] = $value;
}
/**
* Returns the data attributes as rendered string.
*
* @return string data attributes
*/
protected function getDataAttributesAsString() {
$result = '';
foreach ($this->dataAttributes as $key => $value) {
$result .= ' data-' . htmlspecialchars($key) . '="' . htmlspecialchars($value) . '"';
}
return $result;
}
} }
/** /**
@ -1254,7 +1279,9 @@ class htmlSelect extends htmlElement {
echo '<div class="hidden">'; echo '<div class="hidden">';
} }
// print select box // print select box
echo '<select' . $class . $style . $name . $size . $multi . $disabled . $onchange . ' tabindex="' . $tabindex . "\">\n"; echo '<select' . $this->getDataAttributesAsString() . $class . $style
. $name . $size . $multi . $disabled . $onchange
. ' tabindex="' . $tabindex . "\">\n";
$tabindex++; $tabindex++;
if ($this->containsOptgroups) { if ($this->containsOptgroups) {
foreach ($this->elements as $label => $elements) { foreach ($this->elements as $label => $elements) {
@ -3638,9 +3665,10 @@ class htmlResponsiveRow extends htmlElement {
* Adds the content as a typical label with 12/6/6 columns and CSS class "responsiveLabel". * Adds the content as a typical label with 12/6/6 columns and CSS class "responsiveLabel".
* *
* @param htmlElement $content label * @param htmlElement $content label
* @param string $cssClasses additional CSS classes
*/ */
public function addLabel($content) { public function addLabel($content, $cssClasses = '') {
$this->add($content, 12, 6, 6, 'responsiveLabel nowrap'); $this->add($content, 12, 6, 6, 'responsiveLabel nowrap ' . $cssClasses);
} }
/** /**
@ -4156,15 +4184,22 @@ class htmlResponsiveTable extends htmlElement {
/** widthes of the columns */ /** widthes of the columns */
private $widths = array(); private $widths = array();
/** highlighted rows */
private $highlighted = array();
/** /**
* Creates the table. * Creates the table.
* *
* @param string[] $titles row titles * @param string[] $titles row titles
* @param htmlElement[][] $data data rows * @param htmlElement[][] $data data rows
* @param int[] $highlighted list of row numbers that should be highlighted (starting at 0)
*/ */
public function __construct($titles, $data) { public function __construct($titles, $data, $highlighted = null) {
$this->titles = $titles; $this->titles = $titles;
$this->data = $data; $this->data = $data;
if (!empty($highlighted) && is_array($highlighted)) {
$this->highlighted = $highlighted;
}
} }
/** /**
@ -4189,8 +4224,13 @@ class htmlResponsiveTable extends htmlElement {
echo '</thead>'; echo '</thead>';
echo '<tbody>'; echo '<tbody>';
$titleCount = sizeof($this->titles); $titleCount = sizeof($this->titles);
$counter = 0;
foreach ($this->data as $row) { foreach ($this->data as $row) {
echo '<tr>'; $cssClass = '';
if (in_array($counter, $this->highlighted)) {
$cssClass = ' class="bold"';
}
echo '<tr ' . $cssClass . '>';
for ($i = 0; $i < $titleCount; $i++) { for ($i = 0; $i < $titleCount; $i++) {
echo '<td data-label="' . $this->titles[$i] . '">'; echo '<td data-label="' . $this->titles[$i] . '">';
$ids = parseHtml($module, $row[$i], $values, $restricted, $tabindex, $scope); $ids = parseHtml($module, $row[$i], $values, $restricted, $tabindex, $scope);
@ -4198,6 +4238,7 @@ class htmlResponsiveTable extends htmlElement {
echo '</td>'; echo '</td>';
} }
echo '</tr>'; echo '</tr>';
$counter++;
} }
echo '</tbody>'; echo '</tbody>';
echo '</table>'; echo '</table>';

View File

@ -1,9 +1,10 @@
<?php <?php
namespace LAM\SCHEMA;
/* /*
$Id$ $Id$
Copyright (C) 2004 David Smith Copyright (C) 2004 David Smith
modified to fit for LDAP Account Manager 2005 - 2016 Roland Gruber modified to fit for LDAP Account Manager 2005 - 2018 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -2028,18 +2029,10 @@ function set_cached_schema($schema_type, $schema_items )
if( ! SCHEMA_SESSION_CACHE_ENABLED ) if( ! SCHEMA_SESSION_CACHE_ENABLED )
return false; return false;
//echo "Setting cached schema for \"$schema_type\"...<br />\n";
// Sanity check. The schema must be in the form of an array // Sanity check. The schema must be in the form of an array
if( ! is_array( $schema_items ) ) { if( ! is_array( $schema_items ) ) {
die( "While attempting to cache schema, passed a non-array for \$schema_items!" ); die( "While attempting to cache schema, passed a non-array for \$schema_items!" );
} }
// Make sure we are being passed a valid array of schema_items
foreach( $schema_items as $schema_item ) {
if( ! is_subclass_of( $schema_item, 'SchemaItem' ) &&
! 0 == strcasecmp( 'SchemaItem', get_class( $schema_item ) ) ) {
die( "While attempting to cache schema, one of the schema items passed is not a true SchemaItem instance!" );
}
}
$schema_type = strtolower( $schema_type ); $schema_type = strtolower( $schema_type );
$_SESSION[ 'schema' ][ $schema_type ] = $schema_items; $_SESSION[ 'schema' ][ $schema_type ] = $schema_items;

View File

@ -403,6 +403,12 @@ div.jobList {
max-height: 50rem; max-height: 50rem;
} }
div.smallScroll {
overflow: scroll;
max-height: 10rem;
overflow-x: hidden;
}
.fullwidth { .fullwidth {
width: 100%; width: 100%;
} }
@ -615,96 +621,10 @@ div.confModList {
overflow-y: auto; overflow-y: auto;
} }
/* schema browser */ .font-big {
font-size: 130%;
table.schema_oclasses {
border-left: 1px solid black;
border-right: 1px solid black;
border-bottom: 1px solid black;
border-top: 0;
margin-bottom: 10px;
background-color: #eee;
} }
table.schema_oclasses td {
vertical-align: top;
text-align: left;
padding-left: 5px;
}
table.schema_attr {
border: 1px solid black;
}
table.schema_attr th {
background-color: #F3F3F3;
padding: 5px;
color: black;
font-weight: bold;
font-size: 125%;
}
table.schema_attr td {
padding: 5px;
vertical-align: top;
}
table.schema_attr tr.even {
background-color: #eee;
}
table.schema_attr tr.odd {
background-color: #ccc;
}
table.schema_attr tr.highlight{
background-color: #bcd;
font-weight: Bold;
}
ul.schema {
margin: 5px;
margin-left: 0px;
padding-left: 20px;
}
ul.schema li {
margin-left: 0px;
padding-left: 0px;
}
ul.schema li small {
font-size: 75%;
color: #777;
}
ul.schema li small a {
color: #77c;
}
h4.schema_oclass {
background: #F3F3F3;
padding: 5px;
margin: 0px;
margin-top: 8px;
font-weight: normal;
border: 1px solid black;
font-size: 140%;
color: black;
}
h4.schema_oclass_sub {
background: #dde;
border: 1px solid black;
border-top: 0px;
font-weight: normal;
margin: 0px;
padding: 2px;
padding-left: 5px;
font-size: 80%;
}
/** colors for account types */ /** colors for account types */
.alias-border { border-color:#af8800; } .alias-border { border-color:#af8800; }

View File

@ -1,7 +1,7 @@
/* /*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2017 Roland Gruber Copyright (C) 2017 - 2018 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -83,6 +83,8 @@ table.responsive-table th {
table.responsive-table td { table.responsive-table td {
overflow: hidden; overflow: hidden;
vertical-align: top; vertical-align: top;
padding-bottom: 0.5rem;
padding-top: 0.5rem;
} }
/* mobile */ /* mobile */
@ -136,6 +138,10 @@ table.responsive-table td {
margin-right: 5px; margin-right: 5px;
} }
.bold-mobile-only {
font-weight: bold;
}
} }
/* tablet */ /* tablet */

View File

@ -873,6 +873,20 @@ window.lam.tools.setInitialFocus = function() {
jQuery('.lam-initial-focus').focus(); jQuery('.lam-initial-focus').focus();
}; };
window.lam.tools.schema = window.lam.tools.schema || {};
/**
* Adds the onChange listener to schema selections.
*/
window.lam.tools.schema.select = function() {
var select = jQuery('#lam-schema-select');
var display = select.data('display');
select.change(function() {
var value = this.value;
document.location = 'schema.php?display=' + display + '&sel=' + value;
});
};
jQuery(document).ready(function() { jQuery(document).ready(function() {
window.lam.gui.equalHeight(); window.lam.gui.equalHeight();
window.lam.form.autoTrim(); window.lam.form.autoTrim();
@ -880,4 +894,5 @@ jQuery(document).ready(function() {
window.lam.tools.addSavedSelectListener(); window.lam.tools.addSavedSelectListener();
window.lam.tools.activateTab(); window.lam.tools.activateTab();
window.lam.tools.setInitialFocus(); window.lam.tools.setInitialFocus();
window.lam.tools.schema.select();
}); });

View File

@ -1,9 +1,18 @@
<?php <?php
namespace LAM\SCHEMA;
use \htmlResponsiveRow;
use \htmlSpacer;
use \htmlLink;
use \htmlStatusMessage;
use \htmlResponsiveTable;
use \htmlOutputText;
use \htmlGroup;
use \htmlSelect;
use \htmlDiv;
use \htmlSubTitle;
/* /*
$Id$
Copyright (C) 2004 David Smith Copyright (C) 2018 Roland Gruber
modified to fit for LDAP Account Manager 2005 - 2017 Roland Gruber
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -26,7 +35,6 @@ $Id$
* Displays the LDAP schema of the server * Displays the LDAP schema of the server
* *
* @package tools * @package tools
* @author David Smith
* @author Roland Gruber * @author Roland Gruber
*/ */
@ -48,396 +56,317 @@ checkIfToolIsActive('toolSchemaBrowser');
setlanguage(); setlanguage();
include '../main_header.php'; include '../../lib/adminHeader.inc';
echo "<div class=\"user-bright smallPaddingContent\">\n";
$availableViews = array('objectClass', 'attribute', 'syntax', 'rule');
$view = isset( $_GET['view'] ) ? $_GET['view'] : 'objectClasses'; $selectedView = 'objectClass';
$viewvalue = isset( $_GET['viewvalue'] ) ? $_GET['viewvalue'] : null; if (!empty($_GET['display']) && in_array($_GET['display'], $availableViews)) {
if( trim( $viewvalue ) == "" ) $selectedView = $_GET['display'];
$viewvalue = null; }
if( ! is_null( $viewvalue ) )
$viewed = false; $tabindex = 1;
?> $row = new htmlResponsiveRow();
$row->addVerticalSpacer('2rem');
<br /> $row->add(new htmlSpacer('1rem', '1px'), 0, 2);
<center><big> $row->add(new htmlLink(_('Object classes'), 'schema.php'), 12, 2, 2, 'font-big text-center');
<?php echo ( $view=='objectClasses' ? $row->add(new htmlLink(_('Attribute types'), 'schema.php?display=attribute'), 12, 2, 2, 'font-big text-center');
_('Object classes') : $row->add(new htmlLink(_('Syntaxes'), 'schema.php?display=syntax'), 12, 2, 2, 'font-big text-center');
'<a href="?view=objectClasses">' . _('Object classes').'</a>' ); ?> $row->add(new htmlLink(_('Matching rules'), 'schema.php?display=rule'), 12, 2, 2, 'font-big text-center');
| $row->add(new htmlSpacer('1rem', '1px'), 0, 2);
<?php echo ( $view=='attributes' ? $row->addVerticalSpacer('2rem');
_('Attribute types'):
'<a href="?view=attributes">' . _('Attribute types').'</a>' ); ?> if ($selectedView === 'syntax') {
| displaySyntaxList($row);
<?php echo ( $view=='syntaxes' ? }
_('Syntaxes') : elseif( $selectedView == 'attribute' ) {
'<a href="?view=syntaxes">' . _('Syntaxes').'</a>' ); ?> displayAttributeList($row);
| }
<?php echo ( $view=='matching_rules' ? elseif ($selectedView === 'rule') {
_('Matching rules') : displayRuleList($row);
'<a href="?view=matching_rules">' . _('Matching rules').'</a>' ); ?> }
</big></center> elseif( $selectedView == 'objectClass' ) {
<br /> displayObjectClassList($row);
}
<?php flush(); ?>
parseHtml(null, $row, array(), false, $tabindex, 'user');
<?php
echo '</div>';
if( $view == 'syntaxes' ) { include '../../lib/adminFooter.inc';
$highlight_oid = isset( $_GET['highlight_oid'] ) ? $_GET['highlight_oid'] : false;
echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n"; /**
echo "<tr><th>" . _('Syntax OID') . "</th><th>" . _('Description') . "</th></tr>\n"; * Displays the syntax list.
flush(); *
$counter=1; * @param htmlResponsiveRow $row row
$schema_syntaxes = get_schema_syntaxes(null); */
if( ! $schema_syntaxes ) StatusMessage("ERROR", _("Unable to retrieve schema!"), ""); function displaySyntaxList(&$row) {
foreach( $schema_syntaxes as $syntax ) { $schema_syntaxes = get_schema_syntaxes(null);
$counter++; if (!$schema_syntaxes) {
$oid = htmlspecialchars( $syntax->getOID() ); $row->add(new htmlStatusMessage("ERROR", _("Unable to retrieve schema!")), 12);
$desc = htmlspecialchars( $syntax->getDescription() ); return;
if( $highlight_oid && $highlight_oid == $oid ) }
echo "<tr class=\"highlight\">"; $data = array();
else $labels = array(_('Syntax OID'), _('Description'));
echo "<tr class=\"" . ($counter%2==0?'even':'odd'). "\">"; $pos = 0;
echo "<td><a name=\"$oid\">$oid</a></td><td>$desc</td></tr>\n\n"; $highlighted = array();
} foreach( $schema_syntaxes as $syntax ) {
echo "</table>\n"; $oid = new htmlOutputText($syntax->getOID());
$description = new htmlOutputText($syntax->getDescription());
} elseif( $view == 'attributes' ) { $data[] = array($oid, $description);
flush(); if (!empty($_GET['sel']) && ($syntax->getOID() === $_GET['sel'])) {
$schema_attrs = get_schema_attributes(null); $highlighted[] = $pos;
$schema_object_classes = get_schema_objectclasses(null); }
if( ! $schema_attrs || ! $schema_object_classes ) $pos++;
StatusMessage("ERROR", _("Unable to retrieve schema!"), ""); }
$row->add(new htmlResponsiveTable($labels, $data, $highlighted), 12);
?> }
<small><?php echo _('Jump to an attribute type'); ?>:</small>
<form action="schema.php" method="get"><input type="hidden" name="view" value="<?php echo $view; ?>" /> /**
<select name="viewvalue" onChange="submit()"> * Displays the matching rule list.
<option value=""> - all -</option> *
* @param htmlResponsiveRow $row row
<?php foreach( $schema_attrs as $attr ) { */
echo( '<option value="' function displayRuleList(&$row) {
.$attr->getName() $rules = get_schema_matching_rules(null);
.'" ' if (!$rules) {
.( 0 == strcasecmp( $attr->getName(), $viewvalue ) ? ' selected ' : '' ) $row->add(new htmlStatusMessage("ERROR", _("Unable to retrieve schema!")), 12);
.'>' return;
. $attr->getName() }
.'</option>' . "\n" ); $row->addLabel(new htmlOutputText(_('Jump to a matching rule')));
} ?> $availableRules = array('');
</select><input type="submit" value="<?php echo _('Go'); ?>" /></form> foreach ($rules as $rule) {
$availableRules[] = $rule->getName();
<br /> }
<table class="schema_attr" width="100%"> $selectedRule = array();
if (!empty($_GET['sel']) && in_array($_GET['sel'], $availableRules)) {
<?php $selectedRule[] = $_GET['sel'];
foreach( $schema_attrs as $attr ) { }
if ( is_null( $viewvalue ) || 0 == strcasecmp( $viewvalue, $attr->getName() ) ) { $ruleSelect = new htmlSelect('lam-schema-select', $availableRules, $selectedRule);
if( ! is_null( $viewvalue ) ) $ruleSelect->addDataAttribute('display', 'rule');
$viewed = true; $row->addField($ruleSelect);
flush(); $row->addVerticalSpacer('1rem');
echo "<tr><th colspan=\"2\">" . $attr->getName() . "</th></tr>\n\n";
$counter = 0; $labels = array(_('Matching rule OID'), _('Name'), _('Used by attributes'));
$data = array();
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; foreach ($rules as $rule) {
echo "<td>"._('Description')."</td>\n"; if (!empty($selectedRule) && !in_array($rule->getName(), $selectedRule)) {
echo "<td>" . ( $attr->getDescription() === null ? '('._('No description').')' : $attr->getDescription() ). "</td>\n"; continue;
echo "</tr>\n\n"; }
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; $oid = new htmlOutputText($rule->getOID());
echo "<td><acronym title=\"Object Identier\">"._('OID')."</acronym></td>\n"; $name = $rule->getName();
echo "<td>" . $attr->getOID() . "</td>\n"; if (!empty($rule->getDescription())) {
echo "</tr>\n\n"; $name .= ' (' . $rule->getDescription() . ')';
}
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; if ($rule->getIsObsolete()) {
echo '<td>'._('Obsolete')."?</td>\n"; $name .= ' (' . _('Obsolete') . ')';
echo "<td>" . ( $attr->getIsObsolete() ? '<b>' . _('Yes') . '</b>' : _('No') ) . "</td>\n"; }
echo "</tr>\n\n"; $nameText = new htmlOutputText($name);
$attributes = new htmlGroup();
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; foreach ($rule->getUsedByAttrs() as $attr) {
echo "<td>"._('Inherits from')."</td>\n"; $attributes->addElement(new htmlDiv(null, new htmlLink($attr, 'schema.php?display=attribute&sel=' . $attr)));
echo "<td>"; }
if( $attr->getSupAttribute() === null ) $data[] = array($oid, $nameText, new htmlDiv(null, $attributes, array('smallScroll')));
echo '('._('none').')'; }
else
echo "<a href=\"?view=$view&amp;viewvalue=" . strtolower( $attr->getSupAttribute() ) . "\">" . $attr->getSupAttribute() . "</a></td>\n"; $row->add(new htmlResponsiveTable($labels, $data), 12);
echo "</tr>\n\n"; }
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; /**
echo "<td>"._('Equality')."</td>\n"; * Displays the object class list.
echo "<td>" . ( $attr->getEquality() === null ? '('._('not specified').')' : "<a href=\"?view=matching_rules&amp;viewvalue=".$attr->getEquality()."\">".$attr->getEquality()."</a>" ) . "</td>\n"; *
echo "</tr>\n\n"; * @param htmlResponsiveRow $row row
*/
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; function displayObjectClassList(&$row) {
echo "<td>"._('Ordering')."</td>\n"; $objectClasses = get_schema_objectclasses(null);
echo "<td>" . ( $attr->getOrdering() === null? '('._('not specified').')' : $attr->getOrdering() ) . "</td>\n"; if (!$objectClasses) {
echo "</tr>\n\n"; $row->add(new htmlStatusMessage("ERROR", _("Unable to retrieve schema!")), 12);
return;
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; }
echo "<td>"._('Substring Rule')."</td>\n"; $row->addLabel(new htmlOutputText(_('Jump to an object class')));
echo "<td>" . ( $attr->getSubstr() === null? '('._('not specified').')' : $attr->getSubstr() ) . "</td>\n"; $availableClasses = array(_('all') => '');
echo "</tr>\n\n"; foreach ($objectClasses as $objectClass) {
$availableClasses[$objectClass->getName()] = $objectClass->getName();
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; }
echo "<td>"._('Syntax')."</td>\n"; $selectedClass = array();
echo "<td>"; if (isset($_GET['sel']) && (empty($_GET['sel']) || array_key_exists(strtolower($_GET['sel']), $objectClasses))) {
if( null !== $attr->getType() ) { $selectedClass[0] = $_GET['sel'];
echo "<a href=\"?view=syntaxes&amp;highlight_oid="; }
echo $attr->getSyntaxOID() . "#" . $attr->getSyntaxOID(); if (empty($selectedClass) && (sizeof($objectClasses) > 0)) {
echo "\">" . $attr->getType() . " (" . $attr->getSyntaxOID() . ")</a>"; // select first class by default
} else { $selectedClassNames = array_keys($objectClasses);
echo $attr->getSyntaxOID(); $selectedClass[0] = $selectedClassNames[0];
} }
echo "</td>\n"; $classSelect = new htmlSelect('lam-schema-select', $availableClasses, $selectedClass);
echo "</tr>\n\n"; $classSelect->addDataAttribute('display', 'objectClass');
$classSelect->setHasDescriptiveElements(true);
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; $classSelect->setSortElements(false);
echo "<td>"._('Single valued')."</td>\n"; $row->addField($classSelect);
echo "<td>" . ( $attr->getIsSingleValue() ? _('Yes') : _('No') ) . "</td>\n"; $row->addVerticalSpacer('1rem');
echo "</tr>\n\n";
// fill child object classes
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; foreach ($objectClasses as $name => $objectClass) {
echo "<td>"._('Collective')."?</td>\n"; if (!empty($objectClass->getSupClasses())) {
echo "<td>" . ( $attr->getIsCollective() ? _('Yes') : _('No') ) . "</td>\n"; foreach ($objectClass->getSupClasses() as $subClass) {
echo "</tr>\n\n"; if (!isset($objectClasses[strtolower($subClass)])) {
continue;
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; }
echo "<td>"._('User modification')."</td>\n"; $objectClasses[strtolower($subClass)]->addChildObjectClass($name);
echo "<td>" . ( $attr->getIsNoUserModification() ? _('No') : _('Yes') ) . "</td>\n"; }
echo "</tr>\n\n"; }
}
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n";
echo "<td>"._('Usage')."</td>\n"; foreach ($objectClasses as $name => $objectClass) {
echo "<td>" . ( $attr->getUsage() ? $attr->getUsage() : '('._('not specified').')' ) . "</td>\n"; if (!empty($selectedClass[0]) && ($name !== strtolower($selectedClass[0]))) {
echo "</tr>\n\n"; continue;
}
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; $row->add(new htmlSubTitle($name), 12);
echo "<td>"._('Maximum length')."</td>\n"; $row->addLabel(new htmlOutputText(_('OID')), 'bold-mobile-only');
echo "<td>"; $row->addField(new htmlOutputText($objectClass->getOID()));
if ( $attr->getMaxLength() === null ) { echo '('._('not applicable').')';} if (!empty($objectClass->getDescription())) {
else { $row->addLabel(new htmlOutputText(_('Description')), 'bold-mobile-only');
echo number_format( $attr->getMaxLength() ) ." "; $row->addField(new htmlOutputText($objectClass->getDescription()));
if ( $attr->getMaxLength()>1) {echo _('characters');} }
else { echo _('character') ;} $row->addLabel(new htmlOutputText(_('Type')), 'bold-mobile-only');
} $row->addField(new htmlOutputText($objectClass->getType()));
echo "</td>\n"; if ($objectClass->getIsObsolete()) {
echo "</tr>\n\n"; $row->addLabel(new htmlOutputText(_('Obsolete')));
$row->addField(new htmlOutputText(_('yes')));
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; }
echo "<td>"._('Aliases')."</td>\n"; if (!empty($objectClass->getSupClasses())) {
echo "<td>"; $row->addLabel(new htmlOutputText(_('Inherits from')), 'bold-mobile-only');
if( count( $attr->getAliases() ) == 0 ) $subClasses = new htmlGroup();
echo '('._('none').')'; foreach ($objectClass->getSupClasses() as $subClass) {
else $subClasses->addElement(new htmlDiv(null, new htmlLink($subClass, 'schema.php?display=objectClass&sel=' . rawurlencode($subClass))));
foreach( $attr->getAliases() as $alias_attr_name ) }
echo "<a href=\"?view=attributes&amp;viewvalue=" . $alias_attr_name. "\">$alias_attr_name</a> "; $row->addField($subClasses);
echo "</td>"; }
echo "</tr>\n\n"; if (!empty($objectClass->getChildObjectClasses())) {
$row->addLabel(new htmlOutputText(_('Parent to')), 'bold-mobile-only');
echo "<tr class=\"" . (++$counter%2==0?'even':'odd') . "\">\n"; $subClasses = new htmlGroup();
echo "<td>"._('Used by object classes')."</td>\n"; foreach ($objectClass->getChildObjectClasses() as $subClass) {
echo "<td>"; $subClasses->addElement(new htmlDiv(null, new htmlLink($subClass, 'schema.php?display=objectClass&sel=' . rawurlencode($subClass))));
if( count( $attr->getUsedInObjectClasses() ) == 0 ) }
echo '('._('none').')'; $row->addField($subClasses);
else }
foreach( $attr->getUsedInObjectClasses() as $used_in_oclass) if (!empty($objectClass->getMustAttrs())) {
echo "<a href=\"?view=objectClasses&amp;viewvalue=" . $row->addLabel(new htmlOutputText(_('Required attributes')), 'bold-mobile-only');
$used_in_oclass. "\">$used_in_oclass</a> "; $attributes = new htmlGroup();
echo "</td>"; foreach ($objectClass->getMustAttrs() as $attribute) {
echo "</tr>\n\n"; $attributes->addElement(new htmlDiv(null, new htmlLink($attribute->getName(), 'schema.php?display=attribute&sel=' . rawurlencode($attribute->getName()))));
}
flush(); $row->addField($attributes);
} }
} if (!empty($objectClass->getMayAttrs())) {
echo "</table>\n"; $row->addLabel(new htmlOutputText(_('Optional attributes')), 'bold-mobile-only');
$attributes = new htmlGroup();
} elseif( $view == 'matching_rules' ) { foreach ($objectClass->getMayAttrs() as $attribute) {
$schema_matching_rules = get_schema_matching_rules(null); $attributes->addElement(new htmlDiv(null, new htmlLink($attribute->getName(), 'schema.php?display=attribute&sel=' . rawurlencode($attribute->getName()))));
echo '<small>' . _('Jump to a matching rule').'</small><br />'; }
echo '<form action="schema.php" method="get">'; $row->addField($attributes);
echo '<input type="hidden" name="view" value="matching_rules" />'; }
echo '<select name="viewvalue" onChange="submit()">'; }
echo '<option value=""> - all -</option>'; }
foreach( $schema_matching_rules as $rule ) {
echo '<option value="'.$rule->getName().'"'.($rule->getName()==$viewvalue? ' selected ': '').'>'.$rule->getName().'</option>'; /**
} * Displays the attributes list.
*
echo '</select>'; * @param htmlResponsiveRow $row row
echo '<input type="submit" value="'._('Go').'" />'; */
echo '</form>'; function displayAttributeList($row) {
echo "\n\n<table class=\"schema_attr\" width=\"100%\">\n"; $attributes = get_schema_attributes(null);
echo "<tr><th>" . _('Matching rule OID') . "</th><th>" . _('Name') . "</th><th>"._('Used by attributes')."</th></tr>\n"; if (!$attributes) {
flush(); $row->add(new htmlStatusMessage("ERROR", _("Unable to retrieve schema!")), 12);
$counter=1; return;
$schema_matching_rules = get_schema_matching_rules(null); }
if( ! $schema_matching_rules ) StatusMessage("ERROR", _("Unable to retrieve schema!"), ""); $row->addLabel(new htmlOutputText(_('Jump to an attribute type')));
foreach( $schema_matching_rules as $rule ) { $availableAttributes = array(_('all') => '');
$counter++; foreach ($attributes as $attribute) {
$oid = htmlspecialchars( $rule->getOID() ); $availableAttributes[$attribute->getName()] = $attribute->getName();
$desc = htmlspecialchars( $rule->getName() ); }
if ( $viewvalue === null || $viewvalue==($rule->getName() )) { $selectedAttribute = array();
if( ! is_null( $viewvalue ) ) if (isset($_GET['sel']) && (empty($_GET['sel']) || array_key_exists(strtolower($_GET['sel']), $attributes))) {
$viewed = true; $selectedAttribute[0] = $_GET['sel'];
if( null !== $rule->getDescription() ) }
$desc .= ' (' . $rule->getDescription() . ')'; if (empty($selectedAttribute) && (sizeof($availableAttributes) > 0)) {
if( true === $rule->getIsObsolete() ) // select first attribute by default
$desc .= ' <span style="color:red">' . _('Obsolete') . '</span>'; $attributeNames = array_keys($availableAttributes);
echo "<tr class=\"" . ($counter%2==0?'even':'odd'). "\">"; $selectedAttribute[0] = $attributeNames[1];
echo "<td>$oid</td>"; }
echo "<td>$desc</td>"; $attributeSelect = new htmlSelect('lam-schema-select', $availableAttributes, $selectedAttribute);
echo "<td>"; $attributeSelect->addDataAttribute('display', 'attribute');
if( count( $rule->getUsedByAttrs() ) == 0 ) { $attributeSelect->setHasDescriptiveElements(true);
echo "<center>(" . _('none') . ")</center><br /><br />\n"; $attributeSelect->setSortElements(false);
} else { $row->addField($attributeSelect);
echo "<table><tr><td style=\"text-align: right\"><form action=\"schema.php\" method=\"get\">"; $row->addVerticalSpacer('1rem');
echo "<input type=\"hidden\" name=\"view\" value=\"attributes\" />";
echo "<select style=\"width: 150px; color:black; background-color: #eee\" size=\"4\" name=\"viewvalue\">\n"; foreach ($attributes as $name => $attribute) {
foreach( $rule->getUsedByAttrs() as $attr ) if (!empty($selectedAttribute[0]) && ($name !== strtolower($selectedAttribute[0]))) {
echo "<option>$attr</option>\n"; continue;
echo "</select><br /><input type=\"submit\" value=\""._('Go')."\" /></form></td></tr></table>\n"; }
} $row->add(new htmlSubTitle($name), 12);
echo "</td></tr>\n"; if (!empty($attribute->getDescription())) {
} $row->addLabel(new htmlOutputText(_('Description')), 'bold-mobile-only');
} $row->addField(new htmlOutputText($attribute->getDescription()));
echo "</table>\n"; }
$row->addLabel(new htmlOutputText(_('OID')), 'bold-mobile-only');
} elseif( $view == 'objectClasses' ) { $row->addField(new htmlOutputText($attribute->getOID()));
flush(); if ($attribute->getIsObsolete()) {
$schema_oclasses = get_schema_objectclasses(null); $row->addLabel(new htmlOutputText(_('Obsolete')), 'bold-mobile-only');
if( ! $schema_oclasses ) StatusMessage("ERROR", _("Unable to retrieve schema!"), ""); $row->addField(new htmlOutputText(_('yes')));
?> }
<small><?php echo _('Jump to an object class'); ?>:</small> if (!empty($attribute->getSupAttribute())) {
<form action="schema.php" method="get"><input type="hidden" name="view" value="<?php echo $view; ?>" /> $row->addLabel(new htmlOutputText(_('Inherits from')), 'bold-mobile-only');
<select name="viewvalue" $row->addField(new htmlOutputText($attribute->getSupAttribute()));
onChange="submit()"> }
<option value=""> - all - </option> if (!empty($attribute->getEquality())) {
<?php foreach( $schema_oclasses as $name => $oclass ) { $row->addLabel(new htmlOutputText(_('Equality')), 'bold-mobile-only');
echo '<option value="' $row->addField(new htmlLink($attribute->getEquality(), 'schema.php?display=rule&sel=' . rawurldecode($attribute->getEquality())));
.$oclass->getName() }
.'"' if (!empty($attribute->getOrdering())) {
. ( 0 == strcasecmp( $oclass->getName(), $viewvalue ) ? ' selected ':'') $row->addLabel(new htmlOutputText(_('Ordering')), 'bold-mobile-only');
.'>'.$oclass->getName() $row->addField(new htmlLink($attribute->getOrdering(), 'schema.php?display=rule&sel=' . rawurldecode($attribute->getOrdering())));
.'</option>'; }
} ?> if (!empty($attribute->getSubstr())) {
</select><input type="submit" value="<?php echo _('Go'); ?>" /> $row->addLabel(new htmlOutputText(_('Substring Rule')), 'bold-mobile-only');
</form> $row->addField(new htmlLink($attribute->getSubstr(), 'schema.php?display=rule&sel=' . rawurldecode($attribute->getSubstr())));
}
<?php flush(); ?> if (!empty($attribute->getSyntaxOID())) {
$row->addLabel(new htmlOutputText(_('Syntax')), 'bold-mobile-only');
<?php foreach( $schema_oclasses as $name => $oclass ) { $row->addField(new htmlLink($attribute->getSyntaxOID(), 'schema.php?display=syntax&sel=' . rawurldecode($attribute->getSyntaxOID())));
foreach( $oclass->getSupClasses() as $parent_name ) { }
$parent_name = $parent_name; $row->addLabel(new htmlOutputText(_('Single valued')), 'bold-mobile-only');
if( isset( $schema_oclasses[ $parent_name ] ) ) { $row->addField(new htmlOutputText($attribute->getIsSingleValue() ? _('yes') : _('no')));
$schema_oclasses[ $parent_name ]->addChildObjectClass( $oclass->getName() ); $row->addLabel(new htmlOutputText(_('Collective')), 'bold-mobile-only');
} $row->addField(new htmlOutputText($attribute->getIsCollective() ? _('yes') : _('no')));
} $row->addLabel(new htmlOutputText(_('User modification')), 'bold-mobile-only');
$row->addField(new htmlOutputText($attribute->getIsNoUserModification() ? _('no') : _('yes')));
} ?> if (!empty($attribute->getUsage())) {
$row->addLabel(new htmlOutputText(_('Usage')), 'bold-mobile-only');
<br /> $row->addField(new htmlOutputText($attribute->getUsage()));
<?php foreach( $schema_oclasses as $name => $oclass ) { }
if ( $viewvalue === null || 0 == strcasecmp( $viewvalue, $oclass->getName() ) ){ if (!empty($attribute->getMaxLength())) {
if( ! is_null( $viewvalue ) ) $row->addLabel(new htmlOutputText(_('Maximum length')), 'bold-mobile-only');
$viewed = true; $row->addField(new htmlOutputText($attribute->getMaxLength()));
?> }
if (!empty($attribute->getAliases())) {
<h4 class="schema_oclass"><?php echo $oclass->getName(); ?></h4> $row->addLabel(new htmlOutputText(_('Aliases')), 'bold-mobile-only');
<h4 class="schema_oclass_sub"><?php echo _('OID'); ?>: <b><?php echo $oclass->getOID(); ?></b></h4> $aliases = new htmlGroup();
<?php if( $oclass->getDescription() ) { ?> foreach ($attribute->getAliases() as $alias) {
<h4 class="schema_oclass_sub"><?php echo _('Description'); ?>: <b><?php echo $oclass->getDescription(); ?></b></h4> $aliases->addElement(new htmlDiv(null, new htmlLink($alias, 'schema.php?display=attribute&sel=' . rawurlencode($alias))));
<?php } ?> }
<h4 class="schema_oclass_sub"><?php echo _('Type'); ?>: <b><?php echo $oclass->getType(); ?></b></h4> $row->addField($aliases);
<?php if( $oclass->getIsObsolete() === true ) { ?> }
<h4 class="schema_oclass_sub"><?php echo _('This object class is obsolete.'); ?></h4> if (!empty($attribute->getUsedInObjectClasses())) {
<?php } ?> $row->addLabel(new htmlOutputText(_('Used by object classes')), 'bold-mobile-only');
$objectClasses = new htmlGroup();
<h4 class="schema_oclass_sub"><?php echo _('Inherits from'); ?>: <b><?php foreach ($attribute->getUsedInObjectClasses() as $objectClass) {
if( count( $oclass->getSupClasses() ) == 0 ) $objectClasses->addElement(new htmlDiv(null, new htmlLink($objectClass, 'schema.php?display=objectClass&sel=' . rawurlencode($objectClass))));
echo "(" . _('none') . ")"; }
else $row->addField($objectClasses);
foreach( $oclass->getSupClasses() as $i => $object_class ) { }
echo '<a title="' . _('Jump to an object class') . ' "
href="?view='.$view.'&amp;viewvalue='.htmlspecialchars( $object_class ) ; }
echo '">' . htmlspecialchars( $object_class ) . '</a>';
if( $i < count( $oclass->getSupClasses() ) - 1 )
echo ', ';
}
?></b></h4>
<h4 class="schema_oclass_sub"><?php echo _('Parent to'); ?>: <b><?php
if( 0 == strcasecmp( $oclass->getName(), 'top' ) )
echo "(<a href=\"schema.php?view=objectClasses\">all</a>)";
elseif( count( $oclass->getChildObjectClasses() ) == 0 )
echo "(" . _('none') . ")";
else
foreach( $oclass->getChildObjectClasses() as $i => $object_class ) {
echo '<a title="' . _('Jump to an object class') . ' "
href="?view='.$view.'&amp;viewvalue='.htmlspecialchars( $object_class ) ;
echo '">' . htmlspecialchars( $object_class ) . '</a>';
if( $i < count( $oclass->getChildObjectClasses() ) - 1 )
echo ', ';
}
?></b></h4>
<table width="100%" class="schema_oclasses">
<tr>
<th width="50%"><b><?php echo _('Required attributes'); ?></b></th>
<th width="50%"><b><?php echo _('Optional attributes'); ?></b></th>
</tr>
<tr>
<td>
<?php if( count( $oclass->getMustAttrs($schema_oclasses) ) > 0 ) {
echo '<ul class="schema">';
foreach( $oclass->getMustAttrs($schema_oclasses) as $attr ) {
echo "<li><a href=\"?view=attributes&amp;viewvalue=";
echo rawurlencode( $attr->getName() ). "\">" . htmlspecialchars($attr->getName());
echo "</a>";
if( $attr->getSource() != $oclass->getName() )
{
echo "<br /><small>&nbsp;&nbsp;("._('Inherited from')." ";
echo "<a href=\"?view=objectClasses&amp;viewvalue=" . $attr->getSource() . "\">" . $attr->getSource() . "</a>";
echo ")</small>";
}
echo "</li>\n";
}
echo "</ul>";
} else
echo "<center>(" . _('none') . ")</center>\n";
?>
</td>
<td width="50%">
<?php
if( count( $oclass->getMayAttrs($schema_oclasses) ) > 0 ) {
echo '<ul class="schema">';
foreach( $oclass->getMayAttrs($schema_oclasses) as $attr ) {
echo "<li><a href=\"?view=attributes&amp;viewvalue=";
echo rawurlencode( $attr->getName() ) . "\">" . htmlspecialchars($attr->getName() );
echo "</a>\n";
if( $attr->getSource() != $oclass->getName() )
{
echo "<br /><small>&nbsp;&nbsp; ("._('Inherited from')." ";
echo "<a href=\"?view=objectClasses&amp;viewvalue=" . $attr->getSource() . "\">" . $attr->getSource() . "</a>";
echo ")</small>";
}
echo "</li>";
}
echo "</ul>";
}
else
echo "<center>(" . _('none') . ")</center>\n";
?>
</td>
</tr>
</table>
<?php } } /* End foreach objectClass */ ?>
<?php } /* End else (displaying objectClasses */ ?>
<?php
if( ! is_null( $viewvalue ) && ! $viewed ) {
StatusMessage("ERROR", sprintf( _('No such schema item: "%s"'), htmlspecialchars( $viewvalue ) ) );
} }
include '../main_footer.php';
?> ?>