break; case 'xml': default: $oPage->SetContentType('text/xml'); $oObj = MetaModel::GetObject($sClass, $id, true); // Build the root XML part $oXmlDoc = new DOMDocument('1.0', 'UTF-8'); $oXmlRoot = $oXmlDoc->CreateElement('root'); $oXmlNode = $oXmlDoc->CreateElement('node'); $oXmlNode->SetAttribute('id', $oObj->GetKey()); $oXmlNode->SetAttribute('obj_class', get_class($oObj)); $oXmlNode->SetAttribute('obj_class_name', htmlspecialchars(MetaModel::GetName(get_class($oObj)))); $oXmlNode->SetAttribute('name', htmlspecialchars($oObj->GetRawName())); $oXmlNode->SetAttribute('icon', BuildIconPath($oObj->GetIcon(false))); // Hard coded for the moment AddNodeDetails($oXmlNode, $oObj); $oLinks = $oXmlDoc->CreateElement("links"); $oXmlRoot->SetAttribute('position', 'left'); $oXmlRoot->SetAttribute('title', MetaModel::GetRelationDescription($sRelation) . ' ' . htmlspecialchars($oObj->GetRawName())); IssueLog::Info(__FUNCTION__ . " Rel: {$sRelation}"); GetRelatedObjectsAsXml($oObj, $sRelation, $oLinks, $oXmlDoc, $oXmlNode, 0, $aExcludedClasses); $oXmlRoot->AppendChild($oXmlNode); $oXmlDoc->AppendChild($oXmlRoot); $oPage->add($oXmlDoc->SaveXML()); break; } } $oPage->output(); } catch (Exception $e) { echo "Error: " . $e->getMessage(); }
/** * Display the details of a given relation (e.g. "impacts") */ function DisplayRelationDetails($oPage, $sRelCode, $sContext) { $sDesc = MetaModel::GetRelationDescription($sRelCode); $sVerbDown = MetaModel::GetRelationVerbDown($sRelCode); $sVerbUp = MetaModel::GetRelationVerbUp($sRelCode); $oPage->add("<h1>" . Dict::Format('UI:Schema:Relation_Code_Description', $sRelCode, $sDesc) . "</h1>"); $oPage->p(Dict::Format('UI:Schema:RelationDown_Description', $sVerbDown)); $oPage->p(Dict::Format('UI:Schema:RelationUp_Description', $sVerbUp)); $oPage->add("<ul id=\"RelationshipDetails\" class=\"treeview\">\n"); foreach (MetaModel::GetClasses() as $sClass) { $aRelQueries = MetaModel::EnumRelationQueries($sClass, $sRelCode); if (count($aRelQueries) > 0) { $oPage->add("<li>class " . MakeClassHLink($sClass, $sContext) . "\n"); $oPage->add("<ul>\n"); foreach ($aRelQueries as $sRelKey => $aQuery) { $sQuery = $aQuery['sQuery']; $iDistance = $aQuery['iDistance']; if ($aQuery['bPropagate']) { $oPage->add("<li>" . Dict::Format('UI:Schema:RelationPropagates', $sRelKey, $iDistance, $sQuery) . "</li>\n"); } else { $oPage->add("<li>" . Dict::Format('UI:Schema:RelationDoesNotPropagate', $sRelKey, $iDistance, $sQuery) . "</li>\n"); } } $oPage->add("</ul>\n"); $oPage->add("</li>\n"); } } $oPage->add_ready_script('$("#RelationshipDetails").treeview();'); }
function DisplayNavigatorListTab($oP, $aResults, $sRelation, $oObj) { $oP->SetCurrentTab(Dict::S('UI:RelationshipList')); $oP->add("<div id=\"impacted_objects\" style=\"width:100%;background-color:#fff;padding:10px;\">"); $iBlock = 1; // Zero is not a valid blockid foreach ($aResults as $sListClass => $aObjects) { $oSet = CMDBObjectSet::FromArray($sListClass, $aObjects); $oP->add("<h1>" . MetaModel::GetRelationDescription($sRelation) . ' ' . $oObj->GetName() . "</h1>\n"); $oP->add("<div class=\"page_header\">\n"); $oP->add("<h2>" . MetaModel::GetClassIcon($sListClass) . " <span class=\"hilite\">" . Dict::Format('UI:Search:Count_ObjectsOf_Class_Found', count($aObjects), Metamodel::GetName($sListClass)) . "</h2>\n"); $oP->add("</div>\n"); $oBlock = DisplayBlock::FromObjectSet($oSet, 'list'); $oBlock->Display($oP, $iBlock++); $oP->P(' '); // Some space ? } $oP->add("</div>"); }
/** * Display the details of a given relation (e.g. "impacts") */ function DisplayRelationDetails($oPage, $sRelCode, $sContext) { $sDesc = MetaModel::GetRelationDescription($sRelCode); $sLabel = MetaModel::GetRelationLabel($sRelCode); $oPage->add("<h1>" . Dict::Format('UI:Schema:Relation_Code_Description', $sRelCode, $sDesc) . "</h1>"); $oPage->p(Dict::Format('UI:Schema:RelationUp_Description', $sLabel)); $oPage->add("<ul id=\"RelationshipDetails\" class=\"treeview\">\n"); foreach (MetaModel::GetClasses() as $sClass) { $aRelQueries = MetaModel::EnumRelationQueries($sClass, $sRelCode); if (count($aRelQueries) > 0) { $oPage->add("<li>class " . MakeClassHLink($sClass, $sContext) . "\n"); $oPage->add("<ul>\n"); foreach ($aRelQueries as $sRelKey => $aQuery) { $sQueryDown = isset($aQuery['sQueryDown']) ? $aQuery['sQueryDown'] : ''; $sQueryUp = isset($aQuery['sQueryUp']) ? $aQuery['sQueryUp'] : ''; $sAttribute = isset($aQuery['sAttribute']) ? $aQuery['sAttribute'] : ''; /* if ($aQuery['bPropagate']) { $oPage->add("<li>".Dict::Format('UI:Schema:RelationPropagates', $sRelKey, $iDistance, $sQuery)."</li>\n"); } else { $oPage->add("<li>".Dict::Format('UI:Schema:RelationDoesNotPropagate', $sRelKey, $iDistance, $sQuery)."</li>\n"); } */ $sLabel = strlen($sQueryDown) > 0 ? $sQueryDown : $sAttribute; if ($aQuery['_legacy_']) { $sLabel .= ' (<b>Old style specification</b>: it is recommended to upgrade to XML)'; } $oPage->add("<li>" . $sLabel . "</li>\n"); } $oPage->add("</ul>\n"); $oPage->add("</li>\n"); } } $oPage->add_ready_script('$("#RelationshipDetails").treeview();'); }