ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilKSDocumentationEntryGUI.php
Go to the documentation of this file.
1 <?php
2 include_once("./Services/UIComponent/Panel/classes/class.ilPanelGUI.php");
3 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4 include_once("libs/composer/vendor/geshi/geshi/src/geshi.php");
5 
6 
8 
15 {
19  protected $entry = null;
20 
24  protected $entries = null;
25 
29  protected $ctrl;
30 
34  protected $parent;
35 
39  protected $f = null;
40 
44  protected $r = null;
45 
52  public function __construct(ilSystemStyleDocumentationGUI $parent, Entry\ComponentEntry $entry, Entry\ComponentEntries $entries)
53  {
54  global $DIC;
55 
56  $this->f = $DIC->ui()->factory();
57  $this->r = $DIC->ui()->renderer();
58 
59  $this->setEntry($entry);
60  $this->setEntries($entries);
61  $this->setParent($parent);
62  $this->ctrl = $DIC->ctrl();
63  }
64 
68  public function renderEntry()
69  {
70  $sub_panels = array();
71 
72  $feature_wiki_links = array();
73  foreach ($this->entry->getFeatureWikiReferences()as $href) {
74  $feature_wiki_links[] = $href;
75  }
76 
77  $sub_panels[] = $this->f->panel()->sub(
78  "Description",
79  array(
80  $this->f->listing()->descriptive(
81  array(
82  "Purpose" => $this->entry->getDescription()->getProperty("purpose"),
83  "Composition" => $this->entry->getDescription()->getProperty("composition"),
84  "Effect" => $this->entry->getDescription()->getProperty("effect"),
85 
86  )
87  ),
88  $this->f->listing()->descriptive(
89  array(
90  "Background" => $this->entry->getBackground(),
91  "Context" => $this->f->listing()->ordered($this->entry->getContext()),
92  "Feature Wiki References" => $this->f->listing()->ordered($feature_wiki_links)
93  )
94  )
95  )
96  );
97 
98  if (sizeof($this->entry->getDescription()->getProperty("rivals"))) {
99  $sub_panels[] = $this->f->panel()->sub(
100  "Rivals",
101  $this->f->listing()->descriptive(
102  $this->entry->getDescription()->getProperty("rivals")
103  )
104  );
105  }
106 
107  if ($this->entry->getRules()->hasRules()) {
108  $rule_listings = array();
109  foreach ($this->entry->getRulesAsArray() as $categoery => $category_rules) {
110  $rule_listings[ucfirst($categoery)] = $this->f->listing()->ordered($category_rules);
111  }
112 
113 
114  $sub_panels[] = $this->f->panel()->sub(
115  "Rules",
116  $this->f->listing()->descriptive($rule_listings)
117  );
118  }
119 
120 
121  if ($this->entry->getExamples()) {
122  $nr = 1;
123  foreach ($this->entry->getExamples() as $name => $path) {
124  include_once($path);
125  $title = "Example " . $nr . ": " . ucfirst(str_replace("_", " ", $name));
126  $nr++;
127  $example = "<div class='well'>" . $name() . "</div>"; //Executes function loaded in file indicated by 'path'
128  $content_part_1 = $this->f->legacy($example);
129  $code = str_replace("<?php\n", "", file_get_contents($path));
130  $geshi = new GeSHi($code, "php");
131  $content_part_2 = $this->f->legacy($geshi->parse_code());
132  $content = array($content_part_1,$content_part_2);
133  $sub_panels[] = $this->f->panel()->sub($title, $content);
134  }
135  }
136 
137  $sub_panels[] = $this->f->panel()->sub(
138  "Relations",
139  $this->f->listing()->descriptive(
140  array(
141  "Parents" => $this->f->listing()->ordered(
142  $this->entries->getParentsOfEntryTitles($this->entry->getId())
143  ),
144  "Descendants" => $this->f->listing()->unordered(
145  $this->entries->getDescendantsOfEntryTitles($this->entry->getId())
146  )
147  )
148  )
149  );
150 
151  $report = $this->f->panel()->report($this->entry->getTitle(), $sub_panels);
152 
153  return $this->r->render($report);
154  }
155 
156 
160  public function getEntry()
161  {
162  return $this->entry;
163  }
164 
168  public function setEntry(Entry\ComponentEntry $entry)
169  {
170  $this->entry = $entry;
171  }
172 
176  public function getEntries()
177  {
178  return $this->entries;
179  }
180 
184  public function setEntries(Entry\ComponentEntries $entries)
185  {
186  $this->entries = $entries;
187  }
188 
192  public function getParent()
193  {
194  return $this->parent;
195  }
196 
200  public function setParent($parent)
201  {
202  $this->parent = $parent;
203  }
204 }
$path
Definition: aliased.php:25
global $DIC
Definition: saml.php:7
if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) if(!file_exists($path)) $geshi
Definition: aliased.php:40
$code
Definition: example_050.php:99
__construct(ilSystemStyleDocumentationGUI $parent, Entry\ComponentEntry $entry, Entry\ComponentEntries $entries)
ilKSDocumentationEntryGUI constructor.
setEntries(Entry\ComponentEntries $entries)
setEntry(Entry\ComponentEntry $entry)