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