ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilKSDocumentationEntryGUI.php
Go to the documentation of this file.
1<?php
2include_once("./Services/UIComponent/Panel/classes/class.ilPanelGUI.php");
3include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4include_once("libs/composer/vendor/geshi/geshi/src/geshi.php");
5
6
9
15class ilKSDocumentationEntryGUI
16{
20 protected $entry = null;
21
25 protected $entries = null;
26
30 protected $ctrl;
31
35 protected $parent;
36
40 protected $f = null;
41
45 protected $r = null;
46
50 protected $explorer;
51
58 public function __construct(
60 ) {
61 global $DIC;
62
63 $this->f = $DIC->ui()->factory();
64 $this->r = $DIC->ui()->renderer();
65
66
67 $entries = Crawler\Entry\ComponentEntries::createFromArray(include ilSystemStyleDocumentationGUI::$DATA_PATH);
68 $current_opened_node_id = $_GET["node_id"];
69
70 if ($current_opened_node_id) {
71 $DIC->ctrl()->setParameterByClass("ilsystemstyledocumentationgui", "node_id", $current_opened_node_id);
72 $this->setEntry($entries->getEntryById($_GET["node_id"]));
73 } else {
74 $this->setEntry($entries->getRootEntry());
75 }
76 $this->setEntries($entries);
77 $this->setParent($parent);
78 $this->ctrl = $DIC->ctrl();
79 }
80
84 public function renderEntry()
85 {
86 $sub_panels = array();
87
88 $feature_wiki_links = array();
89 foreach ($this->entry->getFeatureWikiReferences()as $href) {
90 $feature_wiki_links[] = $href;
91 }
92
93
94 $sub_panels[] = $this->f->panel()->sub(
95 "Description",
96 array(
97 $this->f->listing()->descriptive(
98 array(
99 "Purpose" => $this->entry->getDescription()->getProperty("purpose"),
100 "Composition" => $this->entry->getDescription()->getProperty("composition"),
101 "Effect" => $this->entry->getDescription()->getProperty("effect"),
102
103 )
104 ),
105 $this->f->listing()->descriptive(
106 array(
107 "Background" => $this->entry->getBackground(),
108 "Context" => $this->f->listing()->ordered($this->entry->getContext()),
109 "Feature Wiki References" => $this->f->listing()->ordered($feature_wiki_links)
110 )
111 )
112 )
113 );
114
115 if (sizeof($this->entry->getDescription()->getProperty("rivals"))) {
116 $sub_panels[] = $this->f->panel()->sub(
117 "Rivals",
118 $this->f->listing()->descriptive(
119 $this->entry->getDescription()->getProperty("rivals")
120 )
121 );
122 }
123
124 if ($this->entry->getRules()->hasRules()) {
125 $rule_listings = array();
126 foreach ($this->entry->getRulesAsArray() as $categoery => $category_rules) {
127 $rule_listings[ucfirst($categoery)] = $this->f->listing()->ordered($category_rules);
128 }
129
130
131 $sub_panels[] = $this->f->panel()->sub(
132 "Rules",
133 $this->f->listing()->descriptive($rule_listings)
134 );
135 }
136
137
138 if ($this->entry->getExamples()) {
139 $nr = 1;
140 foreach ($this->entry->getExamples() as $name => $path) {
141 include_once($path);
142 $title = "Example " . $nr . ": " . ucfirst(str_replace("_", " ", $name));
143 $nr++;
144 try{
145 $example = "<div class='well'>" . $name() . "</div>"; //Executes function loaded in file indicated by 'path'
146 }catch(\ILIAS\UI\NotImplementedException $e){
147 $example = "<div class='well'>This component is not yet fully implemented.</div>";
148 }
149 $content_part_1 = $this->f->legacy($example);
150 $code = str_replace("<?php\n", "", file_get_contents($path));
151 $geshi = new GeSHi($code, "php");
152 //@Todo: we need a code container UI Component
153 $code_html = "<div class='code-container'>" . $geshi->parse_code() . "</div>";
154 $content_part_2 = $this->f->legacy($code_html);
155 $content = array($content_part_1,$content_part_2);
156 $sub_panels[] = $this->f->panel()->sub($title, $content);
157 }
158 }
159 $sub_panels[] = $this->f->panel()->sub('Relations', [
160 $this->f->listing()->descriptive(
161 array(
162 "Parents" => $this->f->listing()->ordered(
163 $this->entries->getParentsOfEntryTitles($this->entry->getId())
164 ),
165 "Descendants" => $this->f->listing()->unordered(
166 $this->entries->getDescendantsOfEntryTitles($this->entry->getId())
167 )
168 )
169 )
170 ]);
171
172
173 $report = $this->f->panel()
174 ->report($this->entry->getTitle(), $sub_panels);
175
176 return $this->r->render($report);
177 }
178
179
183 public function getEntry()
184 {
185 return $this->entry;
186 }
187
191 public function setEntry(Entry\ComponentEntry $entry)
192 {
193 $this->entry = $entry;
194 }
195
199 public function getEntries()
200 {
201 return $this->entries;
202 }
203
207 public function setEntries(Entry\ComponentEntries $entries)
208 {
209 $this->entries = $entries;
210 }
211
215 public function getParent()
216 {
217 return $this->parent;
218 }
219
223 public function setParent($parent)
224 {
225 $this->parent = $parent;
226 }
227}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
global $DIC
Definition: goto.php:24
if($format !==null) $name
Definition: metadata.php:230
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Class ChatMainBarProvider \MainMenu\Provider.
Class Factory.