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/)
Copyright (C) 2010 - 2017 Roland Gruber
Copyright (C) 2010 - 2018 Roland Gruber
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
@ -61,6 +61,8 @@ abstract class htmlElement {
protected $cssClasses = array();
/** table cell CSS classes */
protected $tableCellCssClasses = array();
/** data attributes */
private $dataAttributes = array();
/**
* Prints the HTML code for this element.
@ -155,6 +157,29 @@ abstract class htmlElement {
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">';
}
// 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++;
if ($this->containsOptgroups) {
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".
*
* @param htmlElement $content label
* @param string $cssClasses additional CSS classes
*/
public function addLabel($content) {
$this->add($content, 12, 6, 6, 'responsiveLabel nowrap');
public function addLabel($content, $cssClasses = '') {
$this->add($content, 12, 6, 6, 'responsiveLabel nowrap ' . $cssClasses);
}
/**
@ -4156,15 +4184,22 @@ class htmlResponsiveTable extends htmlElement {
/** widthes of the columns */
private $widths = array();
/** highlighted rows */
private $highlighted = array();
/**
* Creates the table.
*
* @param string[] $titles row titles
* @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->data = $data;
if (!empty($highlighted) && is_array($highlighted)) {
$this->highlighted = $highlighted;
}
}
/**
@ -4189,8 +4224,13 @@ class htmlResponsiveTable extends htmlElement {
echo '</thead>';
echo '<tbody>';
$titleCount = sizeof($this->titles);
$counter = 0;
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++) {
echo '<td data-label="' . $this->titles[$i] . '">';
$ids = parseHtml($module, $row[$i], $values, $restricted, $tabindex, $scope);
@ -4198,6 +4238,7 @@ class htmlResponsiveTable extends htmlElement {
echo '</td>';
}
echo '</tr>';
$counter++;
}
echo '</tbody>';
echo '</table>';

View File

@ -1,9 +1,10 @@
<?php
namespace LAM\SCHEMA;
/*
$Id$
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
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 )
return false;
//echo "Setting cached schema for \"$schema_type\"...<br />\n";
// Sanity check. The schema must be in the form of an array
if( ! is_array( $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 );
$_SESSION[ 'schema' ][ $schema_type ] = $schema_items;

View File

@ -403,6 +403,12 @@ div.jobList {
max-height: 50rem;
}
div.smallScroll {
overflow: scroll;
max-height: 10rem;
overflow-x: hidden;
}
.fullwidth {
width: 100%;
}
@ -615,96 +621,10 @@ div.confModList {
overflow-y: auto;
}
/* schema browser */
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;
.font-big {
font-size: 130%;
}
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 */
.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/)
Copyright (C) 2017 Roland Gruber
Copyright (C) 2017 - 2018 Roland Gruber
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
@ -83,6 +83,8 @@ table.responsive-table th {
table.responsive-table td {
overflow: hidden;
vertical-align: top;
padding-bottom: 0.5rem;
padding-top: 0.5rem;
}
/* mobile */
@ -136,6 +138,10 @@ table.responsive-table td {
margin-right: 5px;
}
.bold-mobile-only {
font-weight: bold;
}
}
/* tablet */

View File

@ -873,6 +873,20 @@ window.lam.tools.setInitialFocus = function() {
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() {
window.lam.gui.equalHeight();
window.lam.form.autoTrim();
@ -880,4 +894,5 @@ jQuery(document).ready(function() {
window.lam.tools.addSavedSelectListener();
window.lam.tools.activateTab();
window.lam.tools.setInitialFocus();
window.lam.tools.schema.select();
});

View File

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