link to a class */ function MakeClassHLink($sClass) { return "".MetaModel::GetName($sClass).""; } /** * Helper for this page -> link to a class */ function MakeRelationHLink($sRelCode) { $sDec = MetaModel::GetRelationProperty($sRelCode, 'description'); //$sVerbDown = MetaModel::GetRelationProperty($sRelCode, 'verb_down'); //$sVerbUp = MetaModel::GetRelationProperty($sRelCode, 'verb_up'); return "".$sRelCode.""; } /** * Helper for the global list and the details of a given class */ function DisplaySubclasses($oPage, $sClass) { $aChildClasses = MetaModel::EnumChildClasses($sClass); if (count($aChildClasses) != 0) { $oPage->add("\n"); } } /** * Helper for the global list and the details of a given class */ function DisplayReferencingClasses($oPage, $sClass) { $bSkipLinkingClasses = false; $aRefs = MetaModel::EnumReferencingClasses($sClass, $bSkipLinkingClasses); if (count($aRefs) != 0) { $oPage->add("\n"); } } /** * Helper for the global list and the details of a given class */ function DisplayLinkingClasses($oPage, $sClass) { $bSkipLinkingClasses = false; $aRefs = MetaModel::EnumLinkingClasses($sClass); if (count($aRefs) != 0) { $oPage->add("\n"); } } /** * Helper for the global list and the details of a given class */ function DisplayRelatedClassesBestInClass($oPage, $sClass, $iLevels = 20, &$aVisitedClasses = array(), $bSubtree = true) { if ($iLevels <= 0) return; $iLevels--; if (array_key_exists($sClass, $aVisitedClasses)) return; $aVisitedClasses[$sClass] = true; if ($bSubtree) $oPage->add("\n"); } /** * Helper for the list of classes related to the given class */ function DisplayRelatedClasses($oPage, $sClass) { $oPage->add("

Childs

\n"); DisplaySubclasses($oPage, $sClass); $oPage->add("

Pointed to by...

\n"); DisplayReferencingClasses($oPage, $sClass); $oPage->add("

Linked to ...

\n"); DisplayLinkingClasses($oPage, $sClass); $oPage->add("

ZE Graph ...

\n"); DisplayRelatedClassesBestInClass($oPage, $sClass, 4); } /** * Helper for the lifecycle details of a given class */ function DisplayLifecycle($oPage, $sClass) { $sStateAttCode = MetaModel::GetStateAttributeCode($sClass); if (empty($sStateAttCode)) { $oPage->p("no lifecycle for this class"); } else { $aStates = MetaModel::EnumStates($sClass); $aStimuli = MetaModel::EnumStimuli($sClass); $oPage->add("\n"); $oPage->add("

Transitions

\n"); $oPage->add("\n"); $oPage->add("

Attribute options

\n"); $oPage->add("\n"); } } /** * Display the list of classes from the business model */ function DisplayClassesList($oPage) { $oPage->add("

iTop objects schema

\n"); $oPage->add("\n"); $oPage->add("

Relationships

\n"); $oPage->add("\n"); $oPage->add_ready_script('$("#ClassesList").treeview();'); $oPage->add_ready_script('$("#ClassesRelationships").treeview();'); } /** * Display the details of a given class of objects */ function DisplayClassDetails($oPage, $sClass) { $oPage->p("

$sClass


\n".MetaModel::GetClassDescription($sClass)."
\n"); $oPage->p("

Class Hierarchy

"); $oPage->p("[All classes]"); // List the parent classes $sParent = MetaModel::GetParentPersistentClass($sClass); $aParents = array(); $aParents[] = $sClass; while($sParent != "" && $sParent != 'cmdbAbstractObject') { $aParents[] = $sParent; $sParent = MetaModel::GetParentPersistentClass($sParent); } $iIndex = count($aParents); $sSpace =""; $oPage->add("\n"); $oPage->add_ready_script('$("#ClassHierarchy").treeview();'); $oPage->p(''); $oPage->AddTabContainer('details'); $oPage->SetCurrentTabContainer('details'); // List the attributes of the object $aDetails = array(); foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode=>$oAttDef) { if ($oAttDef->IsExternalKey()) { $sValue = "External key to ".MakeClassHLink($oAttDef->GetTargetClass()); } else { $sValue = $oAttDef->GetDescription(); } $sType = $oAttDef->GetType().' ('.$oAttDef->GetTypeDesc().')'; $sOrigin = MetaModel::GetAttributeOrigin($sClass, $sAttCode); $sAllowedValues = ""; $oAllowedValuesDef = $oAttDef->GetValuesDef(); $sMoreInfo = ""; if (is_subclass_of($oAttDef, 'AttributeDBFieldVoid')) { $aMoreInfo = array(); $aMoreInfo[] = "Column: ".$oAttDef->GetSQLExpr().""; $aMoreInfo[] = "Default: '".$oAttDef->GetDefaultValue()."'"; $aMoreInfo[] = $oAttDef->IsNullAllowed() ? "Null allowed" : "Null NOT allowed"; //$aMoreInfo[] = $oAttDef->DBGetUsedFields(); $sMoreInfo .= implode(', ', $aMoreInfo); } if (is_object($oAllowedValuesDef)) $sAllowedValues = $oAllowedValuesDef->GetValuesDescription(); else $sAllowedValues = ''; $aDetails[] = array('code' => $oAttDef->GetCode(), 'type' => $sType, 'origin' => $sOrigin, 'label' => $oAttDef->GetLabel(), 'description' => $sValue, 'values' => $sAllowedValues, 'moreinfo' => $sMoreInfo); } $oPage->SetCurrentTab('Attributes'); $aConfig = array( 'code' => array('label' => 'Attribute code', 'description' => 'Code of this attribute'), 'label' => array('label' => 'Label', 'description' => 'Label of this attribute'), 'type' => array('label' => 'Type', 'description' => 'Data type of this attribute'), 'origin' => array('label' => 'Origin', 'description' => 'The base class for this attribute'), 'description' => array('label' => 'Description', 'description' => 'Description of this attribute'), 'values' => array('label' => 'Allowed Values', 'description' => 'Restrictions on the possible values for this attribute'), 'moreinfo' => array('label' => 'More info', 'description' => 'More info for the fields related to a Database field'), ); $oPage->table($aConfig, $aDetails); // List the search criteria for this object $aDetails = array(); foreach (MetaModel::GetClassFilterDefs($sClass) as $sFilterCode => $oFilterDef) { $aOpDescs = array(); foreach ($oFilterDef->GetOperators() as $sOpCode => $sOpDescription) { $sIsTheLooser = ($sOpCode == $oFilterDef->GetLooseOperator()) ? " (loose search)" : ""; $aOpDescs[] = "$sOpCode ($sOpDescription)$sIsTheLooser"; } $aDetails[] = array( 'code' => $sFilterCode, 'description' => $oFilterDef->GetLabel(),'operators' => implode(" / ", $aOpDescs)); } $oPage->SetCurrentTab('Search criteria'); $aConfig = array( 'code' => array('label' => 'Filter code', 'description' => 'Code of this search criteria'), 'description' => array('label' => 'Description', 'description' => 'Description of this search criteria'), 'operators' => array('label' => 'Available operators', 'description' => 'Possible operators for this search criteria') ); $oPage->table($aConfig, $aDetails); $oPage->SetCurrentTab('Child classes'); DisplaySubclasses($oPage, $sClass); $oPage->SetCurrentTab('Referencing classes'); DisplayReferencingClasses($oPage, $sClass); $oPage->SetCurrentTab('Related classes'); DisplayRelatedClasses($oPage, $sClass); $oPage->SetCurrentTab('Lifecycle'); DisplayLifecycle($oPage, $sClass); $oPage->SetCurrentTab(); $oPage->SetCurrentTabContainer(); } /** * Display the details of a given relation (e.g. "impacts") */ function DisplayRelationDetails($oPage, $sRelCode) { $sDesc = MetaModel::GetRelationProperty($sRelCode, 'description'); $sVerbDown = MetaModel::GetRelationProperty($sRelCode, 'verb_down'); $sVerbUp = MetaModel::GetRelationProperty($sRelCode, 'verb_up'); $oPage->add("

Relation $sRelCode ($sDesc)

"); $oPage->p("Down: $sVerbDown"); $oPage->p("Up: $sVerbUp"); $oPage->add("