ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPDSelectedItemsBlockGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 include_once("Services/Block/classes/class.ilBlockGUI.php");
25 
35 {
36  const VIEW_MY_OFFERS = 0;
38 
39  static $block_type = "pditems";
40 
42  private $allowed_views = array();
43 
48  {
49  global $ilCtrl, $lng, $ilUser;
50 
52 
53  $lng->loadLanguageModule('pd');
54 
55  //$this->setImage(ilUtil::getImagePath("icon_bm_s.gif"));
56  $this->setEnableNumInfo(false);
57  $this->setLimit(99999);
58  $this->setColSpan(2);
59  $this->setAvailableDetailLevels(3, 1);
60  $this->setBigMode(true);
61  $this->lng = $lng;
62  $this->allow_moving = false;
63 
64  $this->determineViewSettings();
65  }
66 
72  public function changeView()
73  {
74  global $ilUser, $ilCtrl;
75 
76  if(in_array((int)$_GET['view'], $this->allowed_views))
77  {
78  $ilUser->writePref('pd_view', (int)$_GET['view']);
79  }
80  else
81  {
82  @reset($this->allowed_views);
83  $view = (int)@current($this->allowed_views);
84  $ilUser->writePref('pd_view', $view);
85  }
86 
87  $ilCtrl->redirectByClass('ilpersonaldesktopgui', 'show');
88  }
89 
95  protected function determineViewSettings()
96  {
97  global $ilSetting, $ilUser;
98 
99  $this->allowed_views = array();
100 
101  // determine view
102  if($ilSetting->get('disable_my_offers') == 1 &&
103  $ilSetting->get('disable_my_memberships') == 1)
104  {
105  // if both views are disabled set default view (should not occur but we should prevent it)
106  $ilSetting->set('personal_items_default_view', self::VIEW_MY_OFFERS);
107  $this->allowed_views[] = self::VIEW_MY_OFFERS;
108  }
109  // both views are enabled, get default view
110  else if($ilSetting->get('disable_my_offers') == 0 &&
111  $ilSetting->get('disable_my_memberships') == 0)
112  {
113  $this->allowed_views[] = self::VIEW_MY_OFFERS;
114  $this->allowed_views[] = self::VIEW_MY_MEMBERSHIPS;
115  }
116  else if($ilSetting->get('disable_my_offers') == 0 &&
117  $ilSetting->get('disable_my_memberships') == 1)
118  {
119  $this->allowed_views[] = self::VIEW_MY_OFFERS;
120  }
121  else
122  {
123  $this->allowed_views[] = self::VIEW_MY_MEMBERSHIPS;
124  }
125 
126  $this->view = (int)$ilUser->getPref('pd_view');
127  if(!in_array($this->view, $this->allowed_views))
128  {
129  @reset($this->allowed_views);
130  $view = (int)@current($this->allowed_views);
131  $ilUser->writePref('writePref', $view);
132  $this->view = $view;
133  }
134  }
135 
141  static function getBlockType()
142  {
143  return self::$block_type;
144  }
145 
151  static function isRepositoryObject()
152  {
153  return false;
154  }
155 
156 
157  function getHTML()
158  {
159  global $ilCtrl, $ilSetting;
160 
161  // both views are activated (show buttons)
162  if($ilSetting->get('disable_my_offers') == 0 &&
163  $ilSetting->get('disable_my_memberships') == 0)
164  {
165  $ilCtrl->setParameter($this, 'block_type', $this->getBlockType());
166  $ilCtrl->setParameter($this, 'view', self::VIEW_MY_OFFERS);
167  $this->addHeaderLink($ilCtrl->getLinkTarget($this, 'changeView'), $this->lng->txt('pd_my_offers'),
168  ($this->view == self::VIEW_MY_OFFERS ? false : true)
169  );
170  $ilCtrl->setParameter($this, 'view', self::VIEW_MY_MEMBERSHIPS);
171  $this->addHeaderLink($ilCtrl->getLinkTarget($this, 'changeView'), $this->lng->txt('pd_my_memberships'),
172  ($this->view == self::VIEW_MY_MEMBERSHIPS ? false : true)
173  );
174  $ilCtrl->clearParameters($this);
175  }
176 
177  // workaround to show details row
178  $this->setData(array("dummy"));
179 
180  switch((int)$this->view)
181  {
182  case self::VIEW_MY_MEMBERSHIPS:
183  $this->setTitle($this->lng->txt('pd_my_memberships'));
184  $this->setContent($this->getMembershipItemsBlockHTML());
185  break;
186 
187  case self::VIEW_MY_OFFERS:
188  default:
189  if(!in_array(self::VIEW_MY_MEMBERSHIPS, $this->allowed_views))
190  {
191  $this->setTitle($this->lng->txt('selected_items'));
192  }
193  else
194  {
195  $this->setTitle($this->lng->txt('pd_my_offers'));
196  }
197 
198  $this->setContent($this->getSelectedItemsBlockHTML());
199  break;
200  }
201 
202  if ($this->getContent() == "")
203  {
204  $this->setEnableDetailRow(false);
205  }
206  $ilCtrl->clearParametersByClass("ilpersonaldesktopgui");
207  $ilCtrl->clearParameters($this);
208  return parent::getHTML();
209  }
210 
214  function &executeCommand()
215  {
216  global $ilCtrl;
217 
218  $next_class = $ilCtrl->getNextClass();
219  $cmd = $ilCtrl->getCmd("getHTML");
220 
221  return $this->$cmd();
222  }
223 
224  function getContent()
225  {
226  return $this->content;
227  }
228 
229  function setContent($a_content)
230  {
231  $this->content = $a_content;
232  }
233 
237  function fillDataSection()
238  {
239  global $ilUser;
240 
241  if ($this->getContent() != "")
242  {
243  $this->tpl->setVariable("BLOCK_ROW", $this->getContent());
244  }
245  else
246  {
247  $this->setDataSection($this->getIntroduction());
248  }
249  }
250 
251 
255  function fillFooter()
256  {
257  global $ilCtrl, $lng, $ilUser;
258 
259  $this->setFooterLinks();
260  $this->fillFooterLinks();
261  $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
262  if ($this->tpl->blockExists("block_footer"))
263  {
264  $this->tpl->setCurrentBlock("block_footer");
265  $this->tpl->parseCurrentBlock();
266  }
267  }
268 
272  function setFooterLinks()
273  {
274  global $ilUser, $ilCtrl, $lng;
275 
276  if ($this->getContent() == "")
277  {
278  $this->setEnableNumInfo(false);
279  return "";
280  }
281 
282  // by type
283  if ($ilUser->getPref("pd_order_items") == 'location')
284  {
285  $this->addFooterLink( $lng->txt("by_type"),
286  $ilCtrl->getLinkTarget($this,
287  "orderPDItemsByType"),
288  $ilCtrl->getLinkTarget($this,
289  "orderPDItemsByType", "", true),
290  "block_".$this->getBlockType()."_".$this->block_id
291  );
292  }
293  else
294  {
295  $this->addFooterLink($lng->txt("by_type"));
296  }
297 
298  // by location
299  if ($ilUser->getPref("pd_order_items") == 'location')
300  {
301  $this->addFooterLink($lng->txt("by_location"));
302  }
303  else
304  {
305  $this->addFooterLink( $lng->txt("by_location"),
306  $ilCtrl->getLinkTarget($this,
307  "orderPDItemsByLocation"),
308  $ilCtrl->getLinkTarget($this,
309  "orderPDItemsByLocation", "", true),
310  "block_".$this->getBlockType()."_".$this->block_id
311  );
312  }
313  }
314 
321  protected function getObjectsByMembership($types = array())
322  {
323  global $tree, $ilUser, $ilObjDataCache;
324 
325  include_once 'Services/Membership/classes/class.ilParticipants.php';
326  $items = array();
327 
328  if(is_array($types) && count($types))
329  {
330  foreach($types as $type)
331  {
332  switch($type)
333  {
334  case 'grp':
335  $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'grp'), $items);
336  break;
337  case 'crs':
338  $items = array_merge(ilParticipants::_getMembershipByType($ilUser->getId(), 'crs'), $items);
339  break;
340  default:
341  break;
342  }
343  }
344  }
345  else
346  {
347  $crs_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'crs');
348  $grp_mbs = ilParticipants::_getMembershipByType($ilUser->getId(), 'grp');
349  $items = array_merge($crs_mbs, $grp_mbs);
350  }
351 
352  $references = array();
353  foreach($items as $key => $obj_id)
354  {
355  $item_references = ilObject::_getAllReferences($obj_id);
356  if(is_array($item_references) && count($item_references))
357  {
358  foreach($item_references as $ref_id)
359  {
360  $title = $ilObjDataCache->lookupTitle($obj_id);
361  $type = $ilObjDataCache->lookupType($obj_id);
362 
363  $references[$title.$ref_id] =
364  array('ref_id' => $ref_id,
365  'obj_id' => $obj_id,
366  'type' => $type,
367  'title' => $title,
368  'description' => $ilObjDataCache->lookupDescription($obj_id),
369  'parent_ref' => $tree->getParentId($ref_id));
370  }
371  }
372  }
373  ksort($references);
374  return is_array($references) ? $references : array();
375  }
376 
384  {
385  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $rbacreview;
386 
387  $output = false;
388 
389  $items = $this->getObjectsByMembership();
390  $item_html = array();
391  if(count($items) > 0)
392  {
393  // preload object data cache
394  $ref_ids = array();
395  foreach($items as $item)
396  {
397  $ref_ids[] = $item['ref_id'];
398  }
399  reset($items);
400  $ilObjDataCache->preloadReferenceCache($ref_ids);
401 
402  foreach($items as $item)
403  {
404  //echo "1";
405  // get list gui class for each object type
406  if ($cur_obj_type != $item["type"])
407  {
408  $item_list_gui =& $this->getItemListGUI($item["type"]);
409 
410  $item_list_gui->enableDelete(false);
411  $item_list_gui->enableCut(false);
412  $item_list_gui->enablePayment(false);
413  $item_list_gui->enableLink(false);
414  $item_list_gui->enableInfoScreen(false);
415  $item_list_gui->enableSubscribe(false);
416  if ($this->getCurrentDetailLevel() < 3)
417  {
418  //echo "3";
419  $item_list_gui->enableDescription(false);
420  $item_list_gui->enableProperties(false);
421  $item_list_gui->enablePreconditions(false);
422  }
423  if ($this->getCurrentDetailLevel() < 2)
424  {
425  $item_list_gui->enableCommands(true, true);
426  }
427  }
428  // render item row
429  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
430 
431  if (is_object($item_list_gui))
432  {
433  $html = $item_list_gui->getListItemHTML($item["ref_id"],
434  $item["obj_id"], $item["title"], $item["description"]);
435  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
436  if ($html != "")
437  {
438  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
439  $item_html[] = array(
440  "html" => $html,
441  "item_ref_id" => $item["ref_id"],
442  "item_obj_id" => $item["obj_id"],
443  "parent_ref" => $item["parent_ref"],
444  "type" => $item["type"],
445  'item_icon_image_type' => $item_list_gui->getIconImageType()
446  );
447  // END WebDAV: Use $item_list_gui to determine icon image type
448  }
449  }
450  }
451 
452  // output block for resource type
453  if (count($item_html) > 0)
454  {
455  $cur_parent_ref = 0;
456 
457  // content row
458  foreach($item_html as $item)
459  {
460  // add a parent header row for each new parent
461  if ($cur_parent_ref != $item["parent_ref"])
462  {
463  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
464  {
465  $this->addParentRow($tpl, $item["parent_ref"], false);
466  }
467  else
468  {
469  $this->addParentRow($tpl, $item["parent_ref"]);
470  }
471  $this->resetRowType();
472  $cur_parent_ref = $item["parent_ref"];
473  }
474 
475  // BEGIN WebDAV: Use $item_list_gui to determine icon image type.
476  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
477  $item['item_icon_image_type'],
478  "th_".$cur_parent_ref);
479  // END WebDAV: Use $item_list_gui to determine icon image type.
480  $output = true;
481  }
482  }
483  }
484 
485  return $output;
486  }
487 
495  {
496  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache;
497 
498  $output = false;
499 
500  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
501  array("cat", "crs", "grp", "fold"));
502 
503  $types = array();
504  foreach($objtype_groups as $grp => $grpdata)
505  {
506  $types[] = array(
507  "grp" => $grp,
508  "title" => $this->lng->txt("objs_".$grp),
509  "types" => $grpdata["objs"]);
510  }
511 
512  foreach ($types as $t)
513  {
514  $type = $t["types"];
515  $title = $t["title"];
516  $grp = $t["grp"];
517 
518  $items = $this->getObjectsByMembership($type);
519 //var_dump($items);
520  // preload object data cache
521  $ref_ids = array();
522  foreach($items as $item)
523  {
524  $ref_ids[] = $item['ref_id'];
525  }
526  reset($items);
527  $ilObjDataCache->preloadReferenceCache($ref_ids);
528  $item_html = array();
529 
530  if ($this->getCurrentDetailLevel() == 3)
531  {
532  $rel_header = "th_".$grp;
533  }
534 
535  if (count($items) > 0)
536  {
537  $tstCount = 0;
538  $unsetCount = 0;
539  $progressCount = 0;
540  $unsetFlag = 0;
541  $progressFlag = 0;
542  $completedFlag = 0;
543  if (strcmp($a_type, "tst") == 0) {
544  $items = $this->multiarray_sort($items, "used_tries; title");
545  foreach ($items as $tst_item) {
546  if (!isset($tst_item["used_tries"])) {
547  $unsetCount++;
548  }
549  elseif ($tst_item["used_tries"] == 0) {
550  $progressCount++;
551  }
552  }
553  }
554 
555  foreach($items as $item)
556  {
557  // get list gui class for each object type
558  if ($cur_obj_type != $item["type"])
559  {
560  $class = $objDefinition->getClassName($item["type"]);
561  $location = $objDefinition->getLocation($item["type"]);
562  $full_class = "ilObj".$class."ListGUI";
563  include_once($location."/class.".$full_class.".php");
564  $item_list_gui = new $full_class();
565  $item_list_gui->enableDelete(false);
566  $item_list_gui->enableCut(false);
567  $item_list_gui->enablePayment(false);
568  $item_list_gui->enableLink(false);
569  $item_list_gui->enableInfoScreen(false);
570  $item_list_gui->enableSubscribe(false);
571  if ($this->getCurrentDetailLevel() < 3)
572  {
573  $item_list_gui->enableDescription(false);
574  $item_list_gui->enableProperties(false);
575  $item_list_gui->enablePreconditions(false);
576  $item_list_gui->enableNoticeProperties(false);
577  }
578  if ($this->getCurrentDetailLevel() < 2)
579  {
580  $item_list_gui->enableCommands(true, true);
581  }
582  }
583  // render item row
584  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
585 
586  $html = $item_list_gui->getListItemHTML($item["ref_id"],
587  $item["obj_id"], $item["title"], $item["description"]);
588  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
589  if ($html != "")
590  {
591  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
592  $item_html[] = array(
593  "html" => $html,
594  "item_ref_id" => $item["ref_id"],
595  "item_obj_id" => $item["obj_id"],
596  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
597  $item_list_gui->getIconImageType() :
598  $item['type']
599  );
600  // END WebDAV: Use $item_list_gui to determine icon image type
601  }
602  }
603 
604  // output block for resource type
605  if (count($item_html) > 0)
606  {
607  // add a header for each resource type
608  if ($this->getCurrentDetailLevel() == 3)
609  {
610  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
611  {
612  $this->addHeaderRow($tpl, $grp, false);
613  }
614  else
615  {
616  $this->addHeaderRow($tpl, $grp);
617  }
618  $this->resetRowType();
619  }
620 
621  // content row
622  foreach($item_html as $item)
623  {
624  if ($this->getCurrentDetailLevel() < 3 ||
625  $ilSetting->get("icon_position_in_lists") == "item_rows")
626  {
627  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
628  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
629  $item['item_icon_image_type'],
630  $rel_header);
631  // END WebDAV: Use $item_list_gui to determine icon image type
632  }
633  else
634  {
635  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
636  }
637  $output = true;
638  }
639  }
640  }
641  }
642 
643  return $output;
644  }
645 
652  public function getMembershipItemsBlockHTML()
653  {
654  global $ilUser;
655 
656  $tpl = $this->newBlockTemplate();
657 
658  switch($ilUser->getPref('pd_order_items'))
659  {
660  case 'location':
662  break;
663 
664  default:
666  break;
667  }
668 
669  return $tpl->get();
670  }
671 
676  {
677  global $ilUser, $rbacsystem, $objDefinition, $ilBench;
678 
679  $tpl =& $this->newBlockTemplate();
680 
681  switch ($ilUser->getPref("pd_order_items"))
682  {
683  case "location":
685  break;
686 
687  default:
688  $ok = $this->getSelectedItemsPerType($tpl);
689  break;
690  }
691 
692  return $tpl->get();
693  }
694 
699  {
700  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache;
701 
702  $items = $ilUser->getDesktopItems();
703  if (count($items) > 0)
704  {
705  // preload object data cache
706  $ref_ids = array();
707  foreach($items as $item)
708  {
709  $ref_ids[] = $item["ref_id"];
710  }
711  $ilObjDataCache->preloadReferenceCache($ref_ids);
712  }
713 
714  $output = false;
715 
716  $objtype_groups = $objDefinition->getGroupedRepositoryObjectTypes(
717  array("cat", "crs", "grp", "fold"));
718 
719  $types = array();
720  foreach($objtype_groups as $grp => $grpdata)
721  {
722  $types[] = array(
723  "grp" => $grp,
724  "title" => $this->lng->txt("objs_".$grp),
725  "types" => $grpdata["objs"]);
726  }
727 
728  foreach ($types as $t)
729  {
730 
731  $type = $t["types"];
732  $title = $t["title"];
733  $grp = $t["grp"];
734 
735  $items = $ilUser->getDesktopItems($type);
736 //var_dump($items);
737  $item_html = array();
738 
739  if ($this->getCurrentDetailLevel() == 3)
740  {
741  $rel_header = "th_".$grp;
742  }
743 
744  if (count($items) > 0)
745  {
746  $tstCount = 0;
747  $unsetCount = 0;
748  $progressCount = 0;
749  $unsetFlag = 0;
750  $progressFlag = 0;
751  $completedFlag = 0;
752  if (strcmp($a_type, "tst") == 0) {
753  $items = $this->multiarray_sort($items, "used_tries; title");
754  foreach ($items as $tst_item) {
755  if (!isset($tst_item["used_tries"])) {
756  $unsetCount++;
757  }
758  elseif ($tst_item["used_tries"] == 0) {
759  $progressCount++;
760  }
761  }
762  }
763 
764  foreach($items as $item)
765  {
766  // get list gui class for each object type
767  if ($cur_obj_type != $item["type"])
768  {
769  $class = $objDefinition->getClassName($item["type"]);
770  $location = $objDefinition->getLocation($item["type"]);
771  $full_class = "ilObj".$class."ListGUI";
772  include_once($location."/class.".$full_class.".php");
773  $item_list_gui = new $full_class();
774  $item_list_gui->enableDelete(false);
775  $item_list_gui->enableCut(false);
776  $item_list_gui->enablePayment(false);
777  $item_list_gui->enableLink(false);
778  $item_list_gui->enableInfoScreen(false);
779  if ($this->getCurrentDetailLevel() < 3)
780  {
781  $item_list_gui->enableDescription(false);
782  $item_list_gui->enableProperties(false);
783  $item_list_gui->enablePreconditions(false);
784  $item_list_gui->enableNoticeProperties(false);
785  }
786  if ($this->getCurrentDetailLevel() < 2)
787  {
788  $item_list_gui->enableCommands(true, true);
789  }
790  }
791  // render item row
792  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
793 
794  $html = $item_list_gui->getListItemHTML($item["ref_id"],
795  $item["obj_id"], $item["title"], $item["description"]);
796  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
797  if ($html != "")
798  {
799  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
800  $item_html[] = array(
801  "html" => $html,
802  "item_ref_id" => $item["ref_id"],
803  "item_obj_id" => $item["obj_id"],
804  'item_icon_image_type' => (method_exists($item_list_gui, 'getIconImageType')) ?
805  $item_list_gui->getIconImageType() :
806  $item['type']
807  );
808  // END WebDAV: Use $item_list_gui to determine icon image type
809  }
810  }
811 
812  // output block for resource type
813  if (count($item_html) > 0)
814  {
815  // add a header for each resource type
816  if ($this->getCurrentDetailLevel() == 3)
817  {
818  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
819  {
820  $this->addHeaderRow($tpl, $grp, false);
821  }
822  else
823  {
824  $this->addHeaderRow($tpl, $grp);
825  }
826  $this->resetRowType();
827  }
828 
829  // content row
830  foreach($item_html as $item)
831  {
832  if ($this->getCurrentDetailLevel() < 3 ||
833  $ilSetting->get("icon_position_in_lists") == "item_rows")
834  {
835  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
836  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
837  $item['item_icon_image_type'],
838  $rel_header);
839  // END WebDAV: Use $item_list_gui to determine icon image type
840  }
841  else
842  {
843  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
844  }
845  $output = true;
846  }
847  }
848  }
849  }
850 
851  return $output;
852  }
853 
858  {
859  global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache;
860 
861  $output = false;
862 
863  $items = $ilUser->getDesktopItems();
864  $item_html = array();
865 
866  if (count($items) > 0)
867  {
868  // preload object data cache
869  $ref_ids = array();
870  foreach($items as $item)
871  {
872  $ref_ids[] = $item["ref_id"];
873  }
874  reset($items);
875  $ilObjDataCache->preloadReferenceCache($ref_ids);
876 
877  foreach($items as $item)
878  {
879  //echo "1";
880  // get list gui class for each object type
881  if ($cur_obj_type != $item["type"])
882  {
883  $item_list_gui =& $this->getItemListGUI($item["type"]);
884 
885  $item_list_gui->enableDelete(false);
886  $item_list_gui->enableCut(false);
887  $item_list_gui->enablePayment(false);
888  $item_list_gui->enableLink(false);
889  $item_list_gui->enableInfoScreen(false);
890  if ($this->getCurrentDetailLevel() < 3)
891  {
892  //echo "3";
893  $item_list_gui->enableDescription(false);
894  $item_list_gui->enableProperties(false);
895  $item_list_gui->enablePreconditions(false);
896  }
897  if ($this->getCurrentDetailLevel() < 2)
898  {
899  $item_list_gui->enableCommands(true, true);
900  }
901  }
902  // render item row
903  $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
904 
905  $html = $item_list_gui->getListItemHTML($item["ref_id"],
906  $item["obj_id"], $item["title"], $item["description"]);
907  $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
908  if ($html != "")
909  {
910  // BEGIN WebDAV: Use $item_list_gui to determine icon image type
911  $item_html[] = array(
912  "html" => $html,
913  "item_ref_id" => $item["ref_id"],
914  "item_obj_id" => $item["obj_id"],
915  "parent_ref" => $item["parent_ref"],
916  "type" => $item["type"],
917  'item_icon_image_type' => $item_list_gui->getIconImageType()
918  );
919  // END WebDAV: Use $item_list_gui to determine icon image type
920  }
921  }
922 
923  // output block for resource type
924  if (count($item_html) > 0)
925  {
926  $cur_parent_ref = 0;
927 
928  // content row
929  foreach($item_html as $item)
930  {
931  // add a parent header row for each new parent
932  if ($cur_parent_ref != $item["parent_ref"])
933  {
934  if ($ilSetting->get("icon_position_in_lists") == "item_rows")
935  {
936  $this->addParentRow($tpl, $item["parent_ref"], false);
937  }
938  else
939  {
940  $this->addParentRow($tpl, $item["parent_ref"]);
941  }
942  $this->resetRowType();
943  $cur_parent_ref = $item["parent_ref"];
944  }
945 
946  // BEGIN WebDAV: Use $item_list_gui to determine icon image type.
947  $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"],
948  $item['item_icon_image_type'],
949  "th_".$cur_parent_ref);
950  // END WebDAV: Use $item_list_gui to determine icon image type.
951  $output = true;
952  }
953  }
954  }
955 
956  return $output;
957  }
958 
959  function resetRowType()
960  {
961  $this->cur_row_type = "";
962  }
963 
970  function &newBlockTemplate()
971  {
972  $tpl = new ilTemplate ("tpl.pd_list_block.html", true, true, "Services/PersonalDesktop");
973  $this->cur_row_type = "";
974  return $tpl;
975  }
976 
980  function &getItemListGUI($a_type)
981  {
982  global $objDefinition;
983  //echo "<br>+$a_type+";
984  if (!is_object($this->item_list_guis[$a_type]))
985  {
986  $class = $objDefinition->getClassName($a_type);
987  $location = $objDefinition->getLocation($a_type);
988  $full_class = "ilObj".$class."ListGUI";
989  //echo "<br>-".$location."/class.".$full_class.".php"."-";
990  include_once($location."/class.".$full_class.".php");
991  $item_list_gui = new $full_class();
992  $this->item_list_guis[$a_type] =& $item_list_gui;
993  }
994  else
995  {
996  $item_list_gui =& $this->item_list_guis[$a_type];
997  }
998  return $item_list_gui;
999  }
1000 
1008  function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
1009  {
1010  $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
1011  $title = $this->lng->txt("objs_".$a_type);
1012  $header_id = "th_".$a_type;
1013 
1014  if ($a_show_image)
1015  {
1016  $a_tpl->setCurrentBlock("container_header_row_image");
1017  $a_tpl->setVariable("HEADER_IMG", $icon);
1018  $a_tpl->setVariable("HEADER_ALT", $title);
1019  }
1020  else
1021  {
1022  $a_tpl->setCurrentBlock("container_header_row");
1023  }
1024 
1025  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
1026  $a_tpl->setVariable("BLOCK_HEADER_ID", $header_id);
1027  $a_tpl->parseCurrentBlock();
1028  $a_tpl->touchBlock("container_row");
1029  }
1030 
1038  function addParentRow(&$a_tpl, $a_ref_id, $a_show_image = true)
1039  {
1040  global $tree, $ilSetting;
1041 
1042  $par_id = ilObject::_lookupObjId($a_ref_id);
1043  $type = ilObject::_lookupType($par_id);
1044  if (!in_array($type, array("lm", "dbk", "sahs", "htlm")))
1045  {
1046  $icon = ilUtil::getImagePath("icon_".$type.".gif");
1047  }
1048  else
1049  {
1050  $icon = ilUtil::getImagePath("icon_lm.gif");
1051  }
1052 
1053  // custom icon
1054  if ($ilSetting->get("custom_icons") &&
1055  in_array($type, array("cat","grp","crs", "root")))
1056  {
1057  require_once("./Services/Container/classes/class.ilContainer.php");
1058  if (($path = ilContainer::_lookupIconPath($par_id, "small")) != "")
1059  {
1060  $icon = $path;
1061  }
1062  }
1063 
1064  if ($tree->getRootId() != $par_id)
1065  {
1066  $title = ilObject::_lookupTitle($par_id);
1067  }
1068  else
1069  {
1070  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1071  $title = $nd["title"];
1072  if ($title == "ILIAS")
1073  {
1074  $title = $this->lng->txt("repository");
1075  }
1076  }
1077 
1078  $item_list_gui =& $this->getItemListGUI($type);
1079 
1080  $item_list_gui->enableDelete(false);
1081  $item_list_gui->enableCut(false);
1082  $item_list_gui->enablePayment(false);
1083  $item_list_gui->enableLink(false);
1084  $item_list_gui->enableDescription(false);
1085  $item_list_gui->enableProperties(false);
1086  $item_list_gui->enablePreconditions(false);
1087  $item_list_gui->enablePath(true);
1088  $item_list_gui->enableCommands(false);
1089  $html = $item_list_gui->getListItemHTML($a_ref_id,
1090  $par_id, $title, "");
1091 
1092  if ($a_show_image)
1093  {
1094  $a_tpl->setCurrentBlock("container_header_row_image");
1095  $a_tpl->setVariable("HEADER_IMG", $icon);
1096  $a_tpl->setVariable("HEADER_ALT", $title);
1097  }
1098  else
1099  {
1100  $a_tpl->setCurrentBlock("container_header_row");
1101  }
1102 
1103  $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $html);
1104  $a_tpl->setVariable("BLOCK_HEADER_ID", "th_".$a_ref_id);
1105  $a_tpl->parseCurrentBlock();
1106  $a_tpl->touchBlock("container_row");
1107  }
1108 
1116  function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
1117  $a_image_type = "", $a_related_header = "")
1118  {
1119  global $ilSetting;
1120 
1121  $this->cur_row_type = ($this->cur_row_type == "row_type_1")
1122  ? "row_type_2"
1123  : "row_type_1";
1124  $a_tpl->touchBlock($this->cur_row_type);
1125 
1126  if ($a_image_type != "")
1127  {
1128  if (!is_array($a_image_type) && !in_array($a_image_type, array("lm", "dbk", "htlm", "sahs")))
1129  {
1130  $icon = ilUtil::getImagePath("icon_".$a_image_type.".gif");
1131  $title = $this->lng->txt("obj_".$a_image_type);
1132  }
1133  else
1134  {
1135  $icon = ilUtil::getImagePath("icon_lm.gif");
1136  $title = $this->lng->txt("learning_resource");
1137  }
1138 
1139  // custom icon
1140  if ($ilSetting->get("custom_icons") &&
1141  in_array($a_image_type, array("cat","grp","crs")))
1142  {
1143  require_once("./Services/Container/classes/class.ilContainer.php");
1144  if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
1145  {
1146  $icon = $path;
1147  }
1148  }
1149 
1150  $a_tpl->setCurrentBlock("block_row_image");
1151  $a_tpl->setVariable("ROW_IMG", $icon);
1152  $a_tpl->setVariable("ROW_ALT", $title);
1153  $a_tpl->parseCurrentBlock();
1154  }
1155  else
1156  {
1157  $a_tpl->setVariable("ROW_NBSP", "&nbsp;");
1158  }
1159  $a_tpl->setCurrentBlock("container_standard_row");
1160  $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
1161  $rel_headers = ($a_related_header != "")
1162  ? "th_selected_items ".$a_related_header
1163  : "th_selected_items";
1164  $a_tpl->setVariable("BLOCK_ROW_HEADERS", $rel_headers);
1165  $a_tpl->parseCurrentBlock();
1166  $a_tpl->touchBlock("container_row");
1167  }
1168 
1172  function getIntroduction()
1173  {
1174  global $ilUser, $lng, $ilCtrl, $tree;
1175 
1176  switch((int)$this->view)
1177  {
1178  case self::VIEW_MY_MEMBERSHIPS:
1179  $tpl = new ilTemplate('tpl.pd_my_memberships_intro.html', true, true, 'Services/PersonalDesktop');
1180  $tpl->setVariable('IMG_PD_LARGE', ilUtil::getImagePath('icon_pd_xxl.gif'));
1181  $tpl->setVariable('TXT_WELCOME', $lng->txt('pd_my_memberships_intro'));
1182  $tpl->setVariable('TXT_INTRO_1', $lng->txt('pd_my_memberships_intro2'));
1183  break;
1184 
1185  case self::VIEW_MY_OFFERS:
1186  default:
1187  // get repository link
1188  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
1189  $title = $nd["title"];
1190  if ($title == "ILIAS")
1191  {
1192  $title = $lng->txt("repository");
1193  }
1194 
1195  $tpl = new ilTemplate("tpl.pd_intro.html", true, true, "Services/PersonalDesktop");
1196  $tpl->setVariable("IMG_PD_LARGE", ilUtil::getImagePath("icon_pd_xxl.gif"));
1197  $tpl->setVariable("TXT_WELCOME", $lng->txt("pdesk_intro"));
1198  $tpl->setVariable("TXT_INTRO_1", sprintf($lng->txt("pdesk_intro2"), $lng->txt("to_desktop")));
1199  $tpl->setVariable("TXT_INTRO_2", sprintf($lng->txt("pdesk_intro3"),
1200  '<a href="repository.php?cmd=frameset&getlast=true">'.$title.'</a>'));
1201  $tpl->setVariable("TXT_INTRO_3", $lng->txt("pdesk_intro4"));
1202  break;
1203  }
1204 
1205  return $tpl->get();
1206  }
1207 
1212  {
1213  global $ilUser, $ilCtrl;
1214 
1215  $ilUser->writePref("pd_order_items", "location");
1216 
1217  if ($ilCtrl->isAsynch())
1218  {
1219  echo $this->getHTML();
1220  exit;
1221  }
1222  else
1223  {
1224  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1225  }
1226  }
1227 
1232  {
1233  global $ilUser, $ilCtrl;
1234 
1235  $ilUser->writePref("pd_order_items", "type");
1236 
1237  if ($ilCtrl->isAsynch())
1238  {
1239  echo $this->getHTML();
1240  exit;
1241  }
1242  else
1243  {
1244  $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
1245  }
1246  }
1247 
1248 }
1249 
1250 ?>