ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilSystemStyleDocumentationGUI.php
Go to the documentation of this file.
1<?php
2require_once("Services/Style/System/classes/Documentation/class.ilKSDocumentationExplorerGUI.php");
3require_once("Services/Style/System/classes/Documentation/class.ilKSDocumentationEntryGUI.php");
4require_once("libs/composer/vendor/geshi/geshi/src/geshi.php");
5
6
14{
18 protected $tpl;
22 protected $ctrl;
23
27 protected $lng;
28
29 const ROOT_FACTORY_PATH = "./Services/Style/System/data/abstractDataFactory.php";
30 const DATA_DIRECTORY = "./Services/Style/System/data";
31 const DATA_FILE = "data.json";
32 public static $DATA_PATH;
33
39 function __construct($skin_id = "",$style_id = "")
40 {
41 global $DIC;
42
43 $this->ctrl = $DIC->ctrl();
44 $this->lng = $DIC->language();
45 $this->tpl = $DIC["tpl"];
46
47 self::$DATA_PATH= self::DATA_DIRECTORY."/".self::DATA_FILE;
48
49 }
50
54 function executeCommand()
55 {
56 $cmd = $this->ctrl->getCmd();
57
58 switch ($cmd)
59 {
60 case 'parseEntries':
61 $this->$cmd();
62 $this->show();
63 break;
64 default:
65 $this->show();
66 break;
67 }
68 }
69
70 public function show(){
71 $entries = $this->readEntries();
72 $content = "";
73
74 //The button to parse the entries from code should only be shown in DEVMODE. Other users do not need that.
75 if(DEVMODE == 1){
76 $toolbar = new ilToolbarGUI();
77 $reload_btn = ilLinkButton::getInstance();
78 $reload_btn->setCaption($this->lng->txt('refresh_entries'),false);
79 if($_GET["node_id"]){
80 $this->ctrl->saveParameter($this,"node_id");
81 }
82 $reload_btn->setUrl($this->ctrl->getLinkTarget($this, 'parseEntries'));
83 $toolbar->addButtonInstance($reload_btn);
84 $content .= $toolbar->getHTML();
85 }
86
87 $explorer = new ilKSDocumentationExplorerGUI($this, "entries", $entries, $_GET["node_id"]);
88 $this->tpl->setLeftNavContent($explorer->getHTML());
89 $entry_gui = new ilKSDocumentationEntryGUI($this,$explorer->getCurrentOpenedNode(), $entries);
90 $content .= $entry_gui->renderEntry();
91
92 $this->tpl->setContent($content);
93 }
94
99 protected function parseEntries(){
100 $crawler = new Crawler\FactoriesCrawler();
101 $entries = $crawler->crawlFactory(self::ROOT_FACTORY_PATH);
102 file_put_contents(self::$DATA_PATH, json_encode($entries));
103 ilUtil::sendSuccess($this->lng->txt("entries_reloaded"),true);
104 return $entries;
105 }
106
110 protected function readEntries(){
111 $entries_array = json_decode(file_get_contents(self::$DATA_PATH),true);
112
113 $entries = new Crawler\Entry\ComponentEntries();
114 foreach($entries_array as $entry_array){
115 $entry = new Crawler\Entry\ComponentEntry($entry_array);
116 $entries->addEntry($entry);
117 }
118
119 return $entries;
120 }
121}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static getInstance()
Factory.
__construct($skin_id="", $style_id="")
ilSystemStyleDocumentationGUI constructor.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$cmd
Definition: sahs_server.php:35
global $DIC