schema.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * Presentation of the data model
  18. *
  19. * @author Erwan Taloc <erwan.taloc@combodo.com>
  20. * @author Romain Quetiez <romain.quetiez@combodo.com>
  21. * @author Denis Flaven <denis.flaven@combodo.com>
  22. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  23. */
  24. require_once('../application/application.inc.php');
  25. require_once('../application/itopwebpage.class.inc.php');
  26. require_once('../application/startup.inc.php');
  27. require_once('../application/loginwebpage.class.inc.php');
  28. LoginWebPage::DoLogin(true); // Check user rights and prompt if needed (must be admin)
  29. /**
  30. * Helper for this page -> link to a class
  31. */
  32. function MakeClassHLink($sClass)
  33. {
  34. return "<a href=\"?operation=details_class&class=$sClass\" title=\"".MetaModel::GetClassDescription($sClass)."\">".MetaModel::GetName($sClass)."</a>";
  35. }
  36. /**
  37. * Helper for this page -> link to a class
  38. */
  39. function MakeRelationHLink($sRelCode)
  40. {
  41. $sDesc = MetaModel::GetRelationDescription($sRelCode);
  42. return "<a href=\"?operation=details_relation&relcode=$sRelCode\" title=\"$sDesc\">".$sRelCode."</a>";
  43. }
  44. /**
  45. * Helper for the global list and the details of a given class
  46. */
  47. function DisplaySubclasses($oPage, $sClass)
  48. {
  49. $aChildClasses = MetaModel::EnumChildClasses($sClass);
  50. if (count($aChildClasses) != 0)
  51. {
  52. $oPage->add("<ul>\n");
  53. $aOrderedClasses = array();
  54. foreach($aChildClasses as $sClassName)
  55. {
  56. // Skip indirect childs, they will be handled somewhere else
  57. if (MetaModel::GetParentPersistentClass($sClassName) == $sClass)
  58. {
  59. $aOrderedClasses[$sClassName] = MetaModel::GetName($sClassName);
  60. }
  61. }
  62. // Sort on the display name
  63. asort($aOrderedClasses);
  64. foreach($aOrderedClasses as $sClassName => $sDisplayName)
  65. {
  66. // Skip indirect childs, they will be handled somewhere else
  67. if (MetaModel::GetParentPersistentClass($sClassName) == $sClass)
  68. {
  69. $oPage->add("<li>".MakeClassHLink($sClassName)."\n");
  70. DisplaySubclasses($oPage, $sClassName);
  71. $oPage->add("</li>\n");
  72. }
  73. }
  74. $oPage->add("</ul>\n");
  75. }
  76. }
  77. /**
  78. * Helper for the global list and the details of a given class
  79. */
  80. function DisplayReferencingClasses($oPage, $sClass)
  81. {
  82. $bSkipLinkingClasses = false;
  83. $aRefs = MetaModel::EnumReferencingClasses($sClass, $bSkipLinkingClasses);
  84. if (count($aRefs) != 0)
  85. {
  86. $oPage->add("<ul>\n");
  87. foreach ($aRefs as $sRemoteClass => $aRemoteKeys)
  88. {
  89. foreach ($aRemoteKeys as $sExtKeyAttCode => $oExtKeyAttDef)
  90. {
  91. $oPage->add("<li>".Dict::Format('UI:Schema:Class_ReferencingClasses_From_By', $sClass, MakeClassHLink($sRemoteClass), $sExtKeyAttCode)."</li>\n");
  92. }
  93. }
  94. $oPage->add("</ul>\n");
  95. }
  96. }
  97. /**
  98. * Helper for the global list and the details of a given class
  99. */
  100. function DisplayLinkingClasses($oPage, $sClass)
  101. {
  102. $bSkipLinkingClasses = false;
  103. $aRefs = MetaModel::EnumLinkingClasses($sClass);
  104. if (count($aRefs) != 0)
  105. {
  106. $oPage->add("<ul>\n");
  107. foreach ($aRefs as $sLinkClass => $aRemoteClasses)
  108. {
  109. foreach($aRemoteClasses as $sExtKeyAttCode => $sRemoteClass)
  110. {
  111. $oPage->add("<li>".Dict::Format('UI:Schema:Class_IsLinkedTo_Class_Via_ClassAndAttribute', $sClass, MakeClassHLink($sRemoteClass), MakeClassHLink($sLinkClass), $sExtKeyAttCode));
  112. }
  113. }
  114. $oPage->add("</ul>\n");
  115. }
  116. }
  117. /**
  118. * Helper for the global list and the details of a given class
  119. */
  120. function DisplayRelatedClassesBestInClass($oPage, $sClass, $iLevels = 20, &$aVisitedClasses = array(), $bSubtree = true)
  121. {
  122. if ($iLevels <= 0) return;
  123. $iLevels--;
  124. if (array_key_exists($sClass, $aVisitedClasses)) return;
  125. $aVisitedClasses[$sClass] = true;
  126. if ($bSubtree) $oPage->add("<ul class=\"treeview\">\n");
  127. foreach (MetaModel::EnumParentClasses($sClass) as $sParentClass)
  128. {
  129. DisplayRelatedClassesBestInClass($oPage, $sParentClass, $iLevels, $aVisitedClasses, false);
  130. }
  131. ////$oPage->add("<div style=\"background-color:#ccc; border: 1px dashed #333;\">");
  132. foreach (MetaModel::EnumReferencedClasses($sClass) as $sExtKeyAttCode => $sRemoteClass)
  133. {
  134. $sVisited = (array_key_exists($sRemoteClass, $aVisitedClasses)) ? " ..." : "";
  135. if (MetaModel::GetAttributeOrigin($sClass, $sExtKeyAttCode) == $sClass)
  136. {
  137. $oPage->add("<li>$sClass| <em>$sExtKeyAttCode</em> =&gt;".MakeClassHLink($sRemoteClass)."$sVisited</li>\n");
  138. DisplayRelatedClassesBestInClass($oPage, $sRemoteClass, $iLevels, $aVisitedClasses);
  139. }
  140. }
  141. foreach (MetaModel::EnumReferencingClasses($sClass) as $sRemoteClass => $aRemoteKeys)
  142. {
  143. foreach ($aRemoteKeys as $sExtKeyAttCode => $oExtKeyAttDef)
  144. {
  145. $sVisited = (array_key_exists($sRemoteClass, $aVisitedClasses)) ? " ..." : "";
  146. $oPage->add("<li>$sClass| &lt;=".MakeClassHLink($sRemoteClass)."::<em>$sExtKeyAttCode</em>$sVisited</li>\n");
  147. DisplayRelatedClassesBestInClass($oPage, $sRemoteClass, $iLevels, $aVisitedClasses);
  148. }
  149. }
  150. ////$oPage->add("</div>");
  151. if ($bSubtree) $oPage->add("</ul>\n");
  152. }
  153. /**
  154. * Helper for the list of classes related to the given class
  155. */
  156. function DisplayRelatedClasses($oPage, $sClass)
  157. {
  158. $oPage->add("<h3>".Dict::Format('UI:Schema:Links:1-n', $sClass)."</h3>\n");
  159. DisplayReferencingClasses($oPage, $sClass);
  160. $oPage->add("<h3>".Dict::Format('UI:Schema:Links:n-n', $sClass)."</h3>\n");
  161. DisplayLinkingClasses($oPage, $sClass);
  162. $oPage->add("<h3>".Dict::S('UI:Schema:Links:All')."</h3>\n");
  163. DisplayRelatedClassesBestInClass($oPage, $sClass, 4);
  164. }
  165. /**
  166. * Helper for the lifecycle details of a given class
  167. */
  168. function DisplayLifecycle($oPage, $sClass)
  169. {
  170. $sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
  171. if (empty($sStateAttCode))
  172. {
  173. $oPage->p(Dict::S('UI:Schema:NoLifeCyle'));
  174. }
  175. else
  176. {
  177. $aStates = MetaModel::EnumStates($sClass);
  178. $aStimuli = MetaModel::EnumStimuli($sClass);
  179. $oPage->add("<img src=\"../pages/graphviz.php?class=$sClass\">\n");
  180. $oPage->add("<h3>".Dict::S('UI:Schema:LifeCycleTransitions')."</h3>\n");
  181. $oPage->add("<ul>\n");
  182. foreach ($aStates as $sStateCode => $aStateDef)
  183. {
  184. $sStateLabel = MetaModel::GetStateLabel($sClass, $sStateCode);
  185. $sStateDescription = MetaModel::GetStateDescription($sClass, $sStateCode);
  186. $oPage->add("<li title=\"code: $sStateCode\">$sStateLabel <span style=\"color:grey;\">($sStateCode) $sStateDescription</span></li>\n");
  187. $oPage->add("<ul>\n");
  188. foreach(MetaModel::EnumTransitions($sClass, $sStateCode) as $sStimulusCode => $aTransitionDef)
  189. {
  190. $sStimulusLabel = $aStimuli[$sStimulusCode]->GetLabel();
  191. $sTargetStateLabel = MetaModel::GetStateLabel($sClass, $aTransitionDef['target_state']);
  192. if (count($aTransitionDef['actions']) > 0)
  193. {
  194. $sActions = " <em>(".implode(', ', $aTransitionDef['actions']).")</em>";
  195. }
  196. else
  197. {
  198. $sActions = "";
  199. }
  200. $oPage->add("<li><span style=\"color:red;font-weight=bold;\">$sStimulusLabel</span> =&gt; $sTargetStateLabel $sActions</li>\n");
  201. }
  202. $oPage->add("</ul>\n");
  203. }
  204. $oPage->add("</ul>\n");
  205. $oPage->add("<h3>".Dict::S('UI:Schema:LifeCyleAttributeOptions')."</h3>\n");
  206. $oPage->add("<ul>\n");
  207. foreach ($aStates as $sStateCode => $aStateDef)
  208. {
  209. $sStateLabel = MetaModel::GetStateLabel($sClass, $sStateCode);
  210. $sStateDescription = MetaModel::GetStateDescription($sClass, $sStateCode);
  211. $oPage->add("<li title=\"code: $sStateCode\">$sStateLabel <span style=\"color:grey;\">($sStateCode) $sStateDescription</span></li>\n");
  212. if (count($aStates[$sStateCode]['attribute_list']) > 0)
  213. {
  214. $oPage->add("<ul>\n");
  215. foreach($aStates[$sStateCode]['attribute_list'] as $sAttCode => $iOptions)
  216. {
  217. $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
  218. $sAttLabel = $oAttDef->GetLabel();
  219. $aOptions = array();
  220. if ($iOptions & OPT_ATT_HIDDEN) $aOptions[] = Dict::S('UI:Schema:LifeCycleHiddenAttribute');
  221. if ($iOptions & OPT_ATT_READONLY) $aOptions[] = Dict::S('UI:Schema:LifeCycleReadOnlyAttribute');
  222. if ($iOptions & OPT_ATT_MANDATORY) $aOptions[] = Dict::S('UI:Schema:LifeCycleMandatoryAttribute');
  223. if ($iOptions & OPT_ATT_MUSTCHANGE) $aOptions[] = Dict::S('UI:Schema:LifeCycleAttributeMustChange');
  224. if ($iOptions & OPT_ATT_MUSTPROMPT) $aOptions[] = Dict::S('UI:Schema:LifeCycleAttributeMustPrompt');
  225. if (count($aOptions))
  226. {
  227. $sOptions = implode(', ', $aOptions);
  228. }
  229. else
  230. {
  231. $sOptions = "";
  232. }
  233. $oPage->add("<li><span style=\"color:purple;font-weight=bold;\">$sAttLabel</span> $sOptions</li>\n");
  234. }
  235. $oPage->add("</ul>\n");
  236. }
  237. else
  238. {
  239. $oPage->p("<em>".Dict::S('UI:Schema:LifeCycleEmptyList')."</em>");
  240. }
  241. }
  242. $oPage->add("</ul>\n");
  243. }
  244. }
  245. /**
  246. * Helper for the trigger
  247. */
  248. function DisplayTriggers($oPage, $sClass)
  249. {
  250. $sClassList = implode("', '", MetaModel::EnumParentClasses($sClass, ENUM_PARENT_CLASSES_ALL));
  251. $oSet = new CMDBObjectSet(DBObjectSearch::FromOQL("SELECT TriggerOnObject WHERE target_class IN ('$sClassList')"));
  252. cmdbAbstractObject::DisplaySet($oPage, $oSet, array('block_id' => 'triggers'));
  253. }
  254. /**
  255. * Display the list of classes from the business model
  256. */
  257. function DisplayClassesList($oPage)
  258. {
  259. $oPage->add("<h1>".Dict::S('UI:Schema:Title')."</h1>\n");
  260. $oPage->add("<ul id=\"ClassesList\" class=\"treeview fileview\">\n");
  261. // Get all the "root" classes for display
  262. $aRootClasses = array();
  263. foreach(MetaModel::GetClasses() as $sClassName)
  264. {
  265. if (MetaModel::IsRootClass($sClassName))
  266. {
  267. $aRootClasses[$sClassName] = MetaModel::GetName($sClassName);
  268. }
  269. elseif (MetaModel::IsStandaloneClass($sClassName))
  270. {
  271. $aRootClasses[$sClassName] = MetaModel::GetName($sClassName);
  272. }
  273. }
  274. // Sort them alphabetically on their display name
  275. asort($aRootClasses);
  276. foreach($aRootClasses as $sClassName => $sDisplayName)
  277. {
  278. if (MetaModel::IsRootClass($sClassName))
  279. {
  280. $oPage->add("<li class=\"closed\">".MakeClassHLink($sClassName)."\n");
  281. DisplaySubclasses($oPage, $sClassName);
  282. $oPage->add("</li>\n");
  283. }
  284. elseif (MetaModel::IsStandaloneClass($sClassName))
  285. {
  286. $oPage->add("<li>".MakeClassHLink($sClassName)."</li>\n");
  287. }
  288. }
  289. $oPage->add("</ul>\n");
  290. $oPage->add("<h1>".Dict::S('UI:Schema:Relationships')."</h1>\n");
  291. $oPage->add("<ul id=\"ClassesRelationships\" class=\"treeview\">\n");
  292. foreach (MetaModel::EnumRelations() as $sRelCode)
  293. {
  294. $oPage->add("<li>".MakeRelationHLink($sRelCode)."\n");
  295. $oPage->add("<ul>\n");
  296. $oPage->add("<li>Description: ".htmlentities(MetaModel::GetRelationDescription($sRelCode))."</li>\n");
  297. $oPage->add("<li>Verb up: ".htmlentities(MetaModel::GetRelationVerbUp($sRelCode))."</li>\n");
  298. $oPage->add("<li>Verb down: ".htmlentities(MetaModel::GetRelationVerbDown($sRelCode))."</li>\n");
  299. $oPage->add("</ul>\n");
  300. $oPage->add("</li>\n");
  301. }
  302. $oPage->add("</ul>\n");
  303. $oPage->add_ready_script('$("#ClassesList").treeview();');
  304. $oPage->add_ready_script('$("#ClassesRelationships").treeview();');
  305. }
  306. /**
  307. * Display the details of a given class of objects
  308. */
  309. function DisplayClassDetails($oPage, $sClass)
  310. {
  311. $oPage->add("<h2>$sClass - ".MetaModel::GetClassDescription($sClass)."</h2>\n");
  312. if (MetaModel::IsAbstract($sClass))
  313. {
  314. $oPage->p(Dict::S('UI:Schema:AbstractClass'));
  315. }
  316. else
  317. {
  318. $oPage->p(Dict::S('UI:Schema:NonAbstractClass'));
  319. }
  320. // $oPage->p("<h3>".Dict::S('UI:Schema:ClassHierarchyTitle')."</h3>");
  321. $aParentClasses = array();
  322. foreach(MetaModel::EnumParentClasses($sClass) as $sParentClass)
  323. {
  324. $aParentClasses[] = MakeClassHLink($sParentClass);
  325. }
  326. if (count($aParentClasses) > 0)
  327. {
  328. $sParents = implode(' &gt;&gt; ', $aParentClasses)." &gt;&gt; <b>$sClass</b>";
  329. }
  330. else
  331. {
  332. $sParents = '';
  333. }
  334. $oPage->p("[<a href=\"?operation='list'\">".Dict::S('UI:Schema:AllClasses')."</a>] $sParents");
  335. if (MetaModel::HasChildrenClasses($sClass))
  336. {
  337. $oPage->add("<ul id=\"ClassHierarchy\">");
  338. $oPage->add("<li class=\"closed\">".$sClass."\n");
  339. DisplaySubclasses($oPage, $sClass);
  340. $oPage->add("</li>\n");
  341. $oPage->add("</ul>\n");
  342. $oPage->add_ready_script('$("#ClassHierarchy").treeview();');
  343. }
  344. $oPage->p('');
  345. $oPage->AddTabContainer('details');
  346. $oPage->SetCurrentTabContainer('details');
  347. // List the attributes of the object
  348. $aDetails = array();
  349. foreach(MetaModel::ListAttributeDefs($sClass) as $sAttCode=>$oAttDef)
  350. {
  351. if ($oAttDef->IsExternalKey())
  352. {
  353. $sValue = Dict::Format('UI:Schema:ExternalKey_To',MakeClassHLink($oAttDef->GetTargetClass()));
  354. }
  355. else
  356. {
  357. $sValue = $oAttDef->GetDescription();
  358. }
  359. $sType = $oAttDef->GetType().' ('.$oAttDef->GetTypeDesc().')';
  360. $sOrigin = MetaModel::GetAttributeOrigin($sClass, $sAttCode);
  361. $sAllowedValues = "";
  362. $oAllowedValuesDef = $oAttDef->GetValuesDef();
  363. $sMoreInfo = "";
  364. $aCols = array();
  365. foreach($oAttDef->GetSQLColumns() as $sCol => $sFieldDesc)
  366. {
  367. $aCols[] = "$sCol: $sFieldDesc";
  368. }
  369. if (count($aCols) > 0)
  370. {
  371. $sCols = implode(', ', $aCols);
  372. $aMoreInfo = array();
  373. $aMoreInfo[] = Dict::Format('UI:Schema:Columns_Description', $sCols);
  374. $aMoreInfo[] = Dict::Format('UI:Schema:Default_Description', $oAttDef->GetDefaultValue());
  375. $aMoreInfo[] = $oAttDef->IsNullAllowed() ? Dict::S('UI:Schema:NullAllowed') : Dict::S('UI:Schema:NullNotAllowed');
  376. $sMoreInfo .= implode(', ', $aMoreInfo);
  377. }
  378. if (is_object($oAllowedValuesDef)) $sAllowedValues = $oAllowedValuesDef->GetValuesDescription();
  379. else $sAllowedValues = '';
  380. $aDetails[] = array('code' => $oAttDef->GetCode(), 'type' => $sType, 'origin' => $sOrigin, 'label' => $oAttDef->GetLabel(), 'description' => $sValue, 'values' => $sAllowedValues, 'moreinfo' => $sMoreInfo);
  381. }
  382. $oPage->SetCurrentTab(Dict::S('UI:Schema:Attributes'));
  383. $aConfig = array( 'code' => array('label' => Dict::S('UI:Schema:AttributeCode'), 'description' => Dict::S('UI:Schema:AttributeCode+')),
  384. 'label' => array('label' => Dict::S('UI:Schema:Label'), 'description' => Dict::S('UI:Schema:Label+')),
  385. 'type' => array('label' => Dict::S('UI:Schema:Type'), 'description' => Dict::S('UI:Schema:Type+')),
  386. 'origin' => array('label' => Dict::S('UI:Schema:Origin'), 'description' => Dict::S('UI:Schema:Origin+')),
  387. 'description' => array('label' => Dict::S('UI:Schema:Description'), 'description' => Dict::S('UI:Schema:Description+')),
  388. 'values' => array('label' => Dict::S('UI:Schema:AllowedValues'), 'description' => Dict::S('UI:Schema:AllowedValues+')),
  389. 'moreinfo' => array('label' => Dict::S('UI:Schema:MoreInfo'), 'description' => Dict::S('UI:Schema:MoreInfo+')),
  390. );
  391. $oPage->table($aConfig, $aDetails);
  392. // List the search criteria for this object
  393. $aDetails = array();
  394. foreach (MetaModel::GetClassFilterDefs($sClass) as $sFilterCode => $oFilterDef)
  395. {
  396. $aOpDescs = array();
  397. foreach ($oFilterDef->GetOperators() as $sOpCode => $sOpDescription)
  398. {
  399. $sIsTheLooser = ($sOpCode == $oFilterDef->GetLooseOperator()) ? " (loose search)" : "";
  400. $aOpDescs[] = "$sOpCode ($sOpDescription)$sIsTheLooser";
  401. }
  402. $aDetails[] = array( 'code' => $sFilterCode, 'description' => $oFilterDef->GetLabel(),'operators' => implode(" / ", $aOpDescs));
  403. }
  404. $oPage->SetCurrentTab(Dict::S('UI:Schema:SearchCriteria'));
  405. $aConfig = array( 'code' => array('label' => Dict::S('UI:Schema:FilterCode'), 'description' => Dict::S('UI:Schema:FilterCode+')),
  406. 'description' => array('label' => Dict::S('UI:Schema:FilterDescription'), 'description' => Dict::S('UI:Schema:FilterDescription+')),
  407. 'operators' => array('label' => Dict::S('UI:Schema:AvailOperators'), 'description' => Dict::S('UI:Schema:AvailOperators+'))
  408. );
  409. $oPage->table($aConfig, $aDetails);
  410. $oPage->SetCurrentTab(Dict::S('UI:Schema:ChildClasses'));
  411. DisplaySubclasses($oPage, $sClass);
  412. $oPage->SetCurrentTab(Dict::S('UI:Schema:ReferencingClasses'));
  413. DisplayReferencingClasses($oPage, $sClass);
  414. $oPage->SetCurrentTab(Dict::S('UI:Schema:RelatedClasses'));
  415. DisplayRelatedClasses($oPage, $sClass);
  416. $oPage->SetCurrentTab(Dict::S('UI:Schema:LifeCycle'));
  417. DisplayLifecycle($oPage, $sClass);
  418. $oPage->SetCurrentTab(Dict::S('UI:Schema:Triggers'));
  419. DisplayTriggers($oPage, $sClass);
  420. $oPage->SetCurrentTab();
  421. $oPage->SetCurrentTabContainer();
  422. }
  423. /**
  424. * Display the details of a given relation (e.g. "impacts")
  425. */
  426. function DisplayRelationDetails($oPage, $sRelCode)
  427. {
  428. $sDesc = MetaModel::GetRelationDescription($sRelCode);
  429. $sVerbDown = MetaModel::GetRelationVerbDown($sRelCode);
  430. $sVerbUp = MetaModel::GetRelationVerbUp($sRelCode);
  431. $oPage->add("<h1>".Dict::Format('UI:Schema:Relation_Code_Description', $sRelCode, $sDesc)."</h1>");
  432. $oPage->p(Dict::Format('UI:Schema:RelationDown_Description', $sVerbDown));
  433. $oPage->p(Dict::Format('UI:Schema:RelationUp_Description', $sVerbUp));
  434. $oPage->add("<ul id=\"RelationshipDetails\" class=\"treeview\">\n");
  435. foreach(MetaModel::GetClasses() as $sClass)
  436. {
  437. $aRelQueries = MetaModel::EnumRelationQueries($sClass, $sRelCode);
  438. if (count($aRelQueries) > 0)
  439. {
  440. $oPage->add("<li>class ".MakeClassHLink($sClass)."\n");
  441. $oPage->add("<ul>\n");
  442. foreach ($aRelQueries as $sRelKey => $aQuery)
  443. {
  444. $sQuery = $aQuery['sQuery'];
  445. $iDistance = $aQuery['iDistance'];
  446. if ($aQuery['bPropagate'])
  447. {
  448. $oPage->add("<li>".Dict::Format('UI:Schema:RelationPropagates', $sRelKey, $iDistance, $sQuery)."</li>\n");
  449. }
  450. else
  451. {
  452. $oPage->add("<li>".Dict::Format('UI:Schema:RelationDoesNotPropagate', $sRelKey, $iDistance, $sQuery)."</li>\n");
  453. }
  454. }
  455. $oPage->add("</ul>\n");
  456. $oPage->add("</li>\n");
  457. }
  458. }
  459. $oPage->add_ready_script('$("#RelationshipDetails").treeview();');
  460. }
  461. // Display the menu on the left
  462. $oAppContext = new ApplicationContext();
  463. $operation = utils::ReadParam('operation', '');
  464. $oPage = new iTopWebPage(Dict::S('UI:Schema:Title'));
  465. $oPage->no_cache();
  466. $operation = utils::ReadParam('operation', '');
  467. switch($operation)
  468. {
  469. case 'details_class':
  470. $sClass = utils::ReadParam('class', 'logRealObject');
  471. DisplayClassDetails($oPage, $sClass);
  472. break;
  473. case 'details_relation':
  474. $sRelCode = utils::ReadParam('relcode', '');
  475. DisplayRelationDetails($oPage, $sRelCode);
  476. break;
  477. case 'list':
  478. default:
  479. DisplayClassesList($oPage);
  480. }
  481. $oPage->output();
  482. ?>