ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
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(ilStudyProgrammeUserProgress $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  if (!$this->progress->getStudyProgramme()->hasLPChildren()) {
120  return $this->getAccordionContentProgressesHTML();
121  } else {
122  return $this->getAccordionContentCoursesHTML();
123  }
124  }
125 
127  {
128  // Make shouldShowSubProgress and newSubItem protected again afterwards, do
129  // the same in the derived class ilStudyProgrammeIndividualPlanProgressListGUI.
130  return implode("\n", array_map(function (ilStudyProgrammeUserProgress $progress) {
131  if (!$this->shouldShowSubProgress($progress)) {
132  return "";
133  }
134  $gui = $this->newSubItem($progress);
135  $gui->setIndent($this->getIndent() + 1);
136  return $gui->getHTML();
137  }, $this->progress->getChildrenProgress()));
138  }
139 
140  protected function shouldShowSubProgress(ilStudyProgrammeUserProgress $a_progress)
141  {
142  if ($a_progress->isRelevant()) {
143  $prg = $a_progress->getStudyProgramme();
144  $can_read = $this->il_access->checkAccess("read", "", $prg->getRefId(), "prg", $prg->getId());
145  if ($this->visible_on_pd_mode == ilObjStudyProgrammeAdmin::SETTING_VISIBLE_ON_PD_READ && !$can_read) {
146  return false;
147  }
148 
149  return true;
150  }
151 
152  return false;
153  }
154 
155  protected function newSubItem(ilStudyProgrammeUserProgress $a_progress)
156  {
157  return new ilStudyProgrammeExpandableProgressListGUI($a_progress);
158  }
159 
160  protected function getAccordionContentCoursesHTML()
161  {
162  include_once("./Services/Object/classes/class.ilObjectListGUIPreloader.php");
164 
165  $crs = array();
166  foreach ($this->progress->getStudyProgramme()->getLPChildren() as $il_obj_crs_ref) {
167  $course = ilObjectFactory::getInstanceByRefId($il_obj_crs_ref->getTargetRefId());
168  $preloader->addItem($course->getId(), $course->getType(), $course->getRefId());
169  $crs[] = $course;
170  }
171  $preloader->preload();
172 
173  return implode("\n", array_map(function (ilObjCourse $course) {
174  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeCourseListGUI.php");
175  require_once("Modules/StudyProgramme/classes/class.ilStudyProgrammeContainerObjectMock.php");
176 
177  $item_gui = new ilStudyProgrammeCourseListGUI();
178  $this->configureItemGUI($item_gui);
179  $item_gui->setContainerObject(new ilStudyProgrammeContainerObjectMock($course));
180  return $item_gui->getListItemHTML(
181  $course->getRefId(),
182  $course->getId(),
183  $course->getTitle(),
184  $course->getDescription()
185  );
186  }, $crs));
187  }
188 
189  protected function configureItemGUI(ilStudyProgrammeCourseListGUI $a_item_gui)
190  {
191  $a_item_gui->enableComments(false);
192  $a_item_gui->enableTags(false);
193  $a_item_gui->enableIcon(true);
194  $a_item_gui->enableDelete(false);
195  $a_item_gui->enableCut(false);
196  $a_item_gui->enableCopy(false);
197  $a_item_gui->enableLink(false);
198  $a_item_gui->enableInfoScreen(true);
199  $a_item_gui->enableSubscribe(true);
200  $a_item_gui->enableCheckbox(false);
201  $a_item_gui->enableDescription(true);
202  $a_item_gui->enableProperties(true);
203  $a_item_gui->enablePreconditions(true);
204  $a_item_gui->enableNoticeProperties(true);
205  $a_item_gui->enableCommands(true, true);
206  $a_item_gui->enableProgressInfo(true);
207  $a_item_gui->setIndent($this->getIndent() + 2);
208  }
209 
210  protected function getAccordionOptions()
211  {
212  return array( "orientation" => "horizontal"
213  // Most propably we don't need this. Or do we want to call ilAccordion.initById?
214  , "int_id" => "prg_progress_" . $this->progress->getId()
215  , "initial_opened" => null
216  //, "save_url" => "./ilias.php?baseClass=ilaccordionpropertiesstorage&cmd=setOpenedTab&accordion_id=".$this->getId()."&user_id=".$ilUser->getId();
217  , "behaviour" => "AllClosed" // or "FirstOpen"
218  , "toggle_class" => 'il_PrgAccordionToggle'
219  , "toggle_act_class" => 'foo'
220  , "content_class" => 'il_PrgAccordionContent'
221  , "width" => "auto"
222  , "active_head_class" => "il_PrgAccordionHeadActive"
223  , "height" => "auto"
224  , "id" => $this->getAccordionId()
225  , "multi" => true
226  , "show_all_element" => null
227  , "hide_all_element" => null
228  , "reset_width" => true
229  );
230  }
231 
232  protected function getAccordionId()
233  {
234  return "prg_progress_" . $this->progress->getId() . "_" . $this->getIndent();
235  }
236 
237  protected function getExpandedImageURL()
238  {
239  require_once("Services/Utilities/classes/class.ilUtil.php");
240  return ilUtil::getImagePath("tree_exp.svg");
241  }
242 
243  protected function getNotExpandedImageURL()
244  {
245  require_once("Services/Utilities/classes/class.ilUtil.php");
246  return ilUtil::getImagePath("tree_col.svg");
247  }
248 
249  protected function getTitleAndIconTarget(ilStudyProgrammeUserProgress $a_progress)
250  {
251  return null;
252  }
253 
254  protected function showMyProgress()
255  {
256  return $_GET["prg_progress_id"] == $this->progress->getId();
257  }
258 
259  protected function addJavaScript()
260  {
261  if ($this->js_added) {
262  return false;
263  }
264 
265  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
267  $this->il_tpl->addJavaScript("./Services/Accordion/js/accordion.js", true, 3);
268  $this->js_added = true;
269  }
270 
271  protected function addCSS()
272  {
273  if ($this->css_added) {
274  return false;
275  }
276 
277  $this->il_tpl->addCSS("Modules/StudyProgramme/templates/css/ilStudyProgramme.css");
278  $this->css_added = true;
279  }
280 }
enableInfoScreen($a_info_screen)
En/disable path.
isRelevant()
Check whether this node is relevant for the user.
global $DIC
Definition: saml.php:7
enableDelete($a_status)
En/disable delete.
$_GET["client_id"]
$tpl
Definition: ilias.php:10
enableProperties($a_status)
En/disable properties.
getStudyProgramme()
Get the program node where this progress belongs to was made.
enableCut($a_status)
En/disable cut.
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.
static initjQueryUI($a_tpl=null)
inits and adds the jQuery-UI JS-File to the global template (see included_components.txt for included components)
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.
$i
Definition: disco.tpl.php:19
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
Class ilStudyProgrammeCourseListGUI.
Represents the progress of a user at one node of a study programme.