ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 $example = "<div class='well'>" . $name() . "</div>"; //Executes function loaded in file indicated by 'path'
145 $content_part_1 = $this->f->legacy($example);
146 $code = str_replace("<?php\n", "", file_get_contents($path));
147 $geshi = new GeSHi($code, "php");
148 //@Todo: we need a code container UI Component
149 $code_html = "<div class='code-container'>" . $geshi->parse_code() . "</div>";
150 $content_part_2 = $this->f->legacy($code_html);
151 $content = array($content_part_1,$content_part_2);
152 $sub_panels[] = $this->f->panel()->sub($title, $content);
153 }
154 }
155 $sub_panels[] = $this->f->panel()->sub('Relations', [
156 $this->f->listing()->descriptive(
157 array(
158 "Parents" => $this->f->listing()->ordered(
159 $this->entries->getParentsOfEntryTitles($this->entry->getId())
160 ),
161 "Descendants" => $this->f->listing()->unordered(
162 $this->entries->getDescendantsOfEntryTitles($this->entry->getId())
163 )
164 )
165 )
166 ]);
167
168
169 $report = $this->f->panel()
170 ->report($this->entry->getTitle(), $sub_panels);
171
172 return $this->r->render($report);
173 }
174
175
179 public function getEntry()
180 {
181 return $this->entry;
182 }
183
187 public function setEntry(Entry\ComponentEntry $entry)
188 {
189 $this->entry = $entry;
190 }
191
195 public function getEntries()
196 {
197 return $this->entries;
198 }
199
203 public function setEntries(Entry\ComponentEntries $entries)
204 {
205 $this->entries = $entries;
206 }
207
211 public function getParent()
212 {
213 return $this->parent;
214 }
215
219 public function setParent($parent)
220 {
221 $this->parent = $parent;
222 }
223}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
if($format !==null) $name
Definition: metadata.php:230
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46