ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
19 protected $indent = 0;
20
24 protected $js_added = false;
25
29 protected $css_added = false;
30
34 protected $il_tpl;
35
39 protected $il_rbacsystem;
40
42 parent::__construct($a_progress);
43
44 global $tpl, $rbacsystem, $ilSetting, $ilAccess;
45 $this->il_tpl = $tpl;
46 $this->il_rbacsystem = $rbacsystem;
47 $this->il_setting = $ilSetting;
48 $this->il_access = $ilAccess;
49 }
50
51 public function getIndent() {
52 return $this->indent;
53 }
54
55 public function setIndent($a_indent) {
56 assert(is_int($a_indent));
57 assert($a_indent >= 0);
58 $this->indent = $a_indent;
59 }
60
61 public function getHTML() {
62 $this->addJavaScript();
63 $this->addCSS();
64 return parent::getHTML();
65 }
66
67 protected function fillTemplate($tpl) {
68 require_once("./Services/JSON/classes/class.ilJsonUtil.php");
69
70 parent::fillTemplate($tpl);
71
72 if ($this->showMyProgress()) {
73 $tpl->setVariable("ACTIVE_HEAD", "il_PrgAccordionHeadActive");
74 }
75
76 $tpl->setVariable("ACCORDION_ID", 'id="'.$this->getAccordionId().'"');
77 $tpl->setVariable("HREF_TITLE", "");
78
79 $content = $this->getAccordionContentHTML();
80
81 if (trim($content)) {
82 $tpl->setCurrentBlock("expand");
83 $tpl->setVariable("EXP_ALT", $this->il_lng->txt("expand"));
84 $tpl->setVariable("EXP_IMG", $this->getExpandedImageURL());
85 $tpl->setVariable("NOT_EXP_ALT", $this->il_lng->txt("expanded"));
86 $tpl->setVariable("NOT_EXP_IMG", $this->getNotExpandedImageURL());
87 $tpl->parseCurrentBlock();
88 }
89 else {
90 $tpl->touchBlock("indent");
91 }
92
93 for($i = 0; $i < $this->getIndent(); $i++) {
94 $tpl->touchBlock("indent");
95 }
96
97 $tpl->setCurrentBlock("accordion");
98 if ($this->showMyProgress()) {
99 $tpl->setVariable("ACCORDION_HIDE_CONTENT", "");
100 }
101 else {
102 $tpl->setVariable("ACCORDION_HIDE_CONTENT", "ilAccHideContent");
103 }
104 $tpl->setVariable("ACCORDION_CONTENT", $content);
105 $tpl->setVariable("ACCORDION_OPTIONS", ilJsonUtil::encode($this->getAccordionOptions()));
106 $tpl->parseCurrentBlock();
107 }
108
109 protected function getAccordionContentHTML() {
110 if (!$this->progress->getStudyProgramme()->hasLPChildren()) {
111 return $this->getAccordionContentProgressesHTML();
112 }
113 else {
114 return $this->getAccordionContentCoursesHTML();
115 }
116 }
117
119 // TODO: $this could be removed as soon as support for PHP 5.3 is dropped:
120 $self = $this;
121 // Make shouldShowSubProgress and newSubItem protected again afterwards, do
122 // the same in the derived class ilStudyProgrammeIndividualPlanProgressListGUI.
123 return implode("\n", array_map(function(ilStudyProgrammeUserProgress $progress) use ($self) {
124 if (!$self->shouldShowSubProgress($progress)) {
125 return "";
126 }
127 $gui = $self->newSubItem($progress);
128 $gui->setIndent($self->getIndent() + 1);
129 return $gui->getHTML();
130 }, $this->progress->getChildrenProgress()));
131 }
132
134 if($a_progress->isRelevant()) {
135 $prg = $a_progress->getStudyProgramme();
136 $can_read = $this->il_access->checkAccess("read", "", $prg->getRefId(), "prg", $prg->getId());
137 if($this->visible_on_pd_mode == ilObjStudyProgrammeAdmin::SETTING_VISIBLE_ON_PD_READ && !$can_read) {
138 return false;
139 }
140
141 return true;
142 }
143
144 return false;
145 }
146
147 public function newSubItem(ilStudyProgrammeUserProgress $a_progress) {
148 return new ilStudyProgrammeExpandableProgressListGUI($a_progress);
149 }
150
151 protected function getAccordionContentCoursesHTML() {
152 include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
154
155 $crs = array();
156 foreach ($this->progress->getStudyProgramme()->getLPChildren() as $il_obj_crs_ref) {
157 $course = ilObjectFactory::getInstanceByRefId($il_obj_crs_ref->getTargetRefId());
158 $preloader->addItem($course->getId(), $course->getType(), $course->getRefId());
159 $crs[] = $course;
160 }
161 $preloader->preload();
162
163 //TODO: remove when PHP5.3 support is canceld
164 $self = $this;
165 return implode("\n", array_map(function(ilObjCourse $course) use ($self) {
166 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeCourseListGUI.php");
167 require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeContainerObjectMock.php");
168
169 $item_gui = new ilStudyProgrammeCourseListGUI();
170 $self->configureItemGUI($item_gui);
171 $item_gui->setContainerObject(new ilStudyProgrammeContainerObjectMock($course));
172 return $item_gui->getListItemHTML
173 ( $course->getRefId()
174 , $course->getId()
175 , $course->getTitle()
176 , $course->getDescription()
177 );
178 }, $crs));
179 }
180
181 //TODO: public -> protected when PHP5.3 support is cancelled
182 public function configureItemGUI(ilStudyProgrammeCourseListGUI $a_item_gui) {
183 $a_item_gui->enableComments(false);
184 $a_item_gui->enableTags(false);
185 $a_item_gui->enableIcon(true);
186 $a_item_gui->enableDelete(false);
187 $a_item_gui->enableCut(false);
188 $a_item_gui->enableCopy(false);
189 $a_item_gui->enablePayment(false);
190 $a_item_gui->enableLink(false);
191 $a_item_gui->enableInfoScreen(true);
192 $a_item_gui->enableSubscribe(true);
193 $a_item_gui->enableCheckbox(false);
194 $a_item_gui->enableDescription(true);
195 $a_item_gui->enableProperties(true);
196 $a_item_gui->enablePreconditions(true);
197 $a_item_gui->enableNoticeProperties(true);
198 $a_item_gui->enableCommands(true, true);
199 $a_item_gui->enableProgressInfo(true);
200 $a_item_gui->setIndent($this->getIndent() + 2);
201 }
202
203 protected function getAccordionOptions() {
204 return array
205 ( "orientation" => "horizontal"
206 // Most propably we don't need this. Or do we want to call ilAccordion.initById?
207 , "int_id" => "prg_progress_".$this->progress->getId()
208 , "initial_opened" => null
209 //, "save_url" => "./ilias.php?baseClass=ilaccordionpropertiesstorage&cmd=setOpenedTab&accordion_id=".$this->getId()."&user_id=".$ilUser->getId();
210 , "behaviour" => "AllClosed" // or "FirstOpen"
211 , "toggle_class" => 'il_PrgAccordionToggle'
212 , "toggle_act_class" => 'foo'
213 , "content_class" => 'il_PrgAccordionContent'
214 , "width" => "auto"
215 , "active_head_class" => "il_PrgAccordionHeadActive"
216 , "height" => "auto"
217 , "id" => $this->getAccordionId()
218 , "multi" => true
219 , "show_all_element" => null
220 , "hide_all_element" => null
221 , "reset_width" => true
222 );
223 }
224
225 protected function getAccordionId() {
226 return "prg_progress_".$this->progress->getId()."_".$this->getIndent();
227 }
228
229 protected function getExpandedImageURL() {
230 require_once("Services/Utilities/classes/class.ilUtil.php");
231 return ilUtil::getImagePath("tree_exp.svg");
232 }
233
234 protected function getNotExpandedImageURL() {
235 require_once("Services/Utilities/classes/class.ilUtil.php");
236 return ilUtil::getImagePath("tree_col.svg");
237 }
238
239 protected function getTitleAndIconTarget(ilStudyProgrammeUserProgress $a_progress) {
240 return null;
241 }
242
243 protected function showMyProgress() {
244 return $_GET["prg_progress_id"] == $this->progress->getId();
245 }
246
247 protected function addJavaScript() {
248 if ($this->js_added) {
249 return false;
250 }
251
252 include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
254 $this->il_tpl->addJavaScript("./Services/Accordion/js/accordion.js", true, 3);
255 $this->js_added = true;
256 }
257
258 protected function addCSS() {
259 if ($this->css_added) {
260 return false;
261 }
262
263 $this->il_tpl->addCSS("Modules/StudyProgramme/templates/css/ilStudyProgramme.css");
264 $this->css_added = true;
265 }
266}
267
268
269?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
static encode($mixed, $suppress_native=false)
Class ilObjCourse.
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.
enablePayment($a_status)
En/disable payment.
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
getId()
get object id @access public
getTitle()
get object title @access public
Class ilStudyProgrammeCourseListGUI.
Class ilStudyProgrammeProgressListGUI.
Represents the progress of a user at one node of a study programme.
getStudyProgramme()
Get the program node where this progress belongs to was made.
isRelevant()
Check whether this node is relevant for the user.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initjQueryUI()
Init jQuery UI (see included_components.txt for included components)
global $ilSetting
Definition: privfeed.php:40