ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilStudyProgrammeExpandableProgressListGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2015 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
12require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeProgressListGUI.php");
13require_once('./Modules/StudyProgramme/classes/class.ilObjStudyProgrammeAdmin.php');
14
16{
20 protected $indent = 0;
21
25 protected $js_added = false;
26
30 protected $css_added = false;
31
35 protected $il_tpl;
36
40 protected $il_rbacsystem;
41
42 public function __construct(ilStudyProgrammeProgress $a_progress)
43 {
44 parent::__construct($a_progress);
45
46 global $DIC;
47 $tpl = $DIC['tpl'];
48 $rbacsystem = $DIC['rbacsystem'];
49 $ilSetting = $DIC['ilSetting'];
50 $ilAccess = $DIC['ilAccess'];
51 $this->il_tpl = $tpl;
52 $this->il_rbacsystem = $rbacsystem;
53 $this->il_setting = $ilSetting;
54 $this->il_access = $ilAccess;
55 }
56
57 protected function getIndent()
58 {
59 return $this->indent;
60 }
61
62 public function setIndent($a_indent)
63 {
64 assert(is_int($a_indent));
65 assert($a_indent >= 0);
66 $this->indent = $a_indent;
67 }
68
69 public function getHTML()
70 {
71 $this->addJavaScript();
72 $this->addCSS();
73 return parent::getHTML();
74 }
75
76 protected function fillTemplate($tpl)
77 {
78 require_once("./Services/JSON/classes/class.ilJsonUtil.php");
79
80 parent::fillTemplate($tpl);
81
82 if ($this->showMyProgress()) {
83 $tpl->setVariable("ACTIVE_HEAD", "il_PrgAccordionHeadActive");
84 }
85
86 $tpl->setVariable("ACCORDION_ID", 'id="' . $this->getAccordionId() . '"');
87 $tpl->setVariable("HREF_TITLE", "");
88
89 $content = $this->getAccordionContentHTML();
90
91 if (trim($content)) {
92 $tpl->setCurrentBlock("expand");
93 $tpl->setVariable("EXP_ALT", $this->il_lng->txt("expand"));
94 $tpl->setVariable("EXP_IMG", $this->getExpandedImageURL());
95 $tpl->setVariable("NOT_EXP_ALT", $this->il_lng->txt("expanded"));
96 $tpl->setVariable("NOT_EXP_IMG", $this->getNotExpandedImageURL());
97 $tpl->parseCurrentBlock();
98 } else {
99 $tpl->touchBlock("indent");
100 }
101
102 for ($i = 0; $i < $this->getIndent(); $i++) {
103 $tpl->touchBlock("indent");
104 }
105
106 $tpl->setCurrentBlock("accordion");
107 if ($this->showMyProgress()) {
108 $tpl->setVariable("ACCORDION_HIDE_CONTENT", "");
109 } else {
110 $tpl->setVariable("ACCORDION_HIDE_CONTENT", "ilAccHideContent");
111 }
112 $tpl->setVariable("ACCORDION_CONTENT", $content);
113 $this->il_tpl->addOnloadCode("il.Accordion.add(" . ilJsonUtil::encode($this->getAccordionOptions()) . ");");
114 $tpl->parseCurrentBlock();
115 }
116
117 protected function getAccordionContentHTML()
118 {
119 $programme = ilObjStudyProgramme::getInstanceByObjId($this->progress->getNodeId());
120
121 if (!$programme->hasLPChildren()) {
122 return $this->getAccordionContentProgressesHTML();
123 } else {
124 return $this->getAccordionContentCoursesHTML();
125 }
126 }
127
129 {
130 // Make shouldShowSubProgress and newSubItem protected again afterwards, do
131 // the same in the derived class ilStudyProgrammeIndividualPlanProgressListGUI.
132 $programme = ilObjStudyProgramme::getInstanceByObjId($this->progress->getNodeId());
133 $child_progresses = $programme->getChildrenProgress($this->progress);
134
135 return implode("\n", array_map(function (ilStudyProgrammeProgress $progress) {
136 if (!$this->shouldShowSubProgress($progress)) {
137 return "";
138 }
139 $gui = $this->newSubItem($progress);
140 $gui->setIndent($this->getIndent() + 1);
141 return $gui->getHTML();
142 }, $child_progresses));
143 }
144
145 protected function shouldShowSubProgress(ilStudyProgrammeProgress $a_progress)
146 {
147 if ($a_progress->isRelevant()) {
149
150 $can_read = $this->il_access->checkAccess("read", "", $prg->getRefId(), "prg", $prg->getId());
151 if ($this->visible_on_pd_mode == ilObjStudyProgrammeAdmin::SETTING_VISIBLE_ON_PD_READ && !$can_read) {
152 return false;
153 }
154
155 return true;
156 }
157
158 return false;
159 }
160
161 protected function newSubItem(ilStudyProgrammeProgress $a_progress)
162 {
163 return new ilStudyProgrammeExpandableProgressListGUI($a_progress);
164 }
165
167 {
168 include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
170
171 $crs = array();
172 $prg = ilObjStudyProgramme::getInstanceByObjId($this->progress->getNodeId());
173 foreach ($prg->getLPChildren() as $il_obj_crs_ref) {
174 if (ilObject::_exists($il_obj_crs_ref, true) &&
175 is_null(ilObject::_lookupDeletedDate($il_obj_crs_ref))
176 ) {
177 continue;
178 }
179
180 $course = ilObjectFactory::getInstanceByRefId($il_obj_crs_ref->getTargetRefId());
181 $preloader->addItem($course->getId(), $course->getType(), $course->getRefId());
182 $crs[] = $course;
183 }
184 $preloader->preload();
185
186 return implode("\n", array_map(function (ilObjCourse $course) {
187 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeCourseListGUI.php");
188 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeContainerObjectMock.php");
189
190 $item_gui = new ilStudyProgrammeCourseListGUI();
191 $this->configureItemGUI($item_gui);
192 $item_gui->setContainerObject(new ilStudyProgrammeContainerObjectMock($course));
193 return $item_gui->getListItemHTML(
194 $course->getRefId(),
195 $course->getId(),
196 $course->getTitle(),
197 $course->getDescription()
198 );
199 }, $crs));
200 }
201
202 protected function configureItemGUI(ilStudyProgrammeCourseListGUI $a_item_gui)
203 {
204 $a_item_gui->enableComments(false);
205 $a_item_gui->enableTags(false);
206 $a_item_gui->enableIcon(true);
207 $a_item_gui->enableDelete(false);
208 $a_item_gui->enableCut(false);
209 $a_item_gui->enableCopy(false);
210 $a_item_gui->enableLink(false);
211 $a_item_gui->enableInfoScreen(true);
212 $a_item_gui->enableSubscribe(true);
213 $a_item_gui->enableCheckbox(false);
214 $a_item_gui->enableDescription(true);
215 $a_item_gui->enableProperties(true);
216 $a_item_gui->enablePreconditions(true);
217 $a_item_gui->enableNoticeProperties(true);
218 $a_item_gui->enableCommands(true, true);
219 $a_item_gui->enableProgressInfo(true);
220 $a_item_gui->setIndent($this->getIndent() + 2);
221 }
222
223 protected function getAccordionOptions()
224 {
225 return array( "orientation" => "horizontal"
226 // Most propably we don't need this. Or do we want to call ilAccordion.initById?
227 , "int_id" => "prg_progress_" . $this->progress->getId()
228 , "initial_opened" => null
229 //, "save_url" => "./ilias.php?baseClass=ilaccordionpropertiesstorage&cmd=setOpenedTab&accordion_id=".$this->getId()."&user_id=".$ilUser->getId();
230 , "behaviour" => "AllClosed" // or "FirstOpen"
231 , "toggle_class" => 'il_PrgAccordionToggle'
232 , "toggle_act_class" => 'foo'
233 , "content_class" => 'il_PrgAccordionContent'
234 , "width" => "auto"
235 , "active_head_class" => "il_PrgAccordionHeadActive"
236 , "height" => "auto"
237 , "id" => $this->getAccordionId()
238 , "multi" => true
239 , "show_all_element" => null
240 , "hide_all_element" => null
241 , "reset_width" => true
242 );
243 }
244
245 protected function getAccordionId()
246 {
247 return "prg_progress_" . $this->progress->getId() . "_" . $this->getIndent();
248 }
249
250 protected function getExpandedImageURL()
251 {
252 require_once("Services/Utilities/classes/class.ilUtil.php");
253 return ilUtil::getImagePath("tree_exp.svg");
254 }
255
256 protected function getNotExpandedImageURL()
257 {
258 require_once("Services/Utilities/classes/class.ilUtil.php");
259 return ilUtil::getImagePath("tree_col.svg");
260 }
261
262 protected function getTitleAndIconTarget(ilStudyProgrammeProgress $a_progress)
263 {
264 return null;
265 }
266
267 protected function showMyProgress()
268 {
269 return $_GET["prg_progress_id"] == $this->progress->getId();
270 }
271
272 protected function addJavaScript()
273 {
274 if ($this->js_added) {
275 return false;
276 }
277
278 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
280 $this->il_tpl->addJavaScript("./Services/Accordion/js/accordion.js", true, 3);
281 $this->js_added = true;
282 }
283
284 protected function addCSS()
285 {
286 if ($this->css_added) {
287 return false;
288 }
289
290 $this->il_tpl->addCSS("Modules/StudyProgramme/templates/css/ilStudyProgramme.css");
291 $this->css_added = true;
292 }
293}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static encode($mixed, $suppress_native=false)
Class ilObjCourse.
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
Preloader for object list GUIs.
enableDescription($a_status)
En/disable description.
enableCommands($a_status, $a_std_only=false)
En/disable commands.
enableProperties($a_status)
En/disable properties.
enableLink($a_status)
En/disable link.
enableCheckbox($a_status)
En/Dis-able checkboxes.
enableNoticeProperties($a_status)
En/disable notices.
enableIcon($a_status)
En/Dis-able icons.
enableCopy($a_status)
En/disable copy.
enablePreconditions($a_status)
En/disable preconditions.
enableTags($a_value)
Toogle tags action status.
enableCut($a_status)
En/disable cut.
enableProgressInfo($a_status)
enable progress info
enableSubscribe($a_status)
En/disable subscribe.
enableComments($a_value, $a_enable_comments_settings=true)
Toogle comments action status.
enableInfoScreen($a_info_screen)
En/disable path.
enableDelete($a_status)
En/disable delete.
getRefId()
get reference id @access public
getDescription()
get object description
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
getId()
get object id @access public
static _lookupDeletedDate($a_ref_id)
only called in ilObjectGUI::insertSavedNodes
getTitle()
get object title @access public
Class ilStudyProgrammeCourseListGUI.
Class ilStudyProgrammeProgressListGUI.
Class ilStudyProgrammeProgress.
getNodeId()
Get the obj_id of the program node this progress belongs to.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components....
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$i
Definition: metadata.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17