ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectListGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 define ("IL_LIST_AS_TRIGGER", "trigger");
5 define ("IL_LIST_FULL", "full");
6 
7 include_once 'payment/classes/class.ilGeneralSettings.php';
8 
25 {
26  const DETAILS_MINIMAL = 10;
27  const DETAILS_SEARCH = 20 ;
28  const DETAILS_ALL = 30;
29 
30  var $ctrl;
33  var $properties_enabled = true;
35  var $commands_enabled = true;
36  var $cust_prop = array();
37  var $cust_commands = array();
38  var $info_screen_enabled = false;
40  var $std_cmd_only = false;
41  var $sub_item_html = array();
42 
43  protected $substitutions = null;
44  protected $substitutions_enabled = false;
45 
46  protected $icons_enabled = false;
47  protected $checkboxes_enabled = false;
48  protected $position_enabled = false;
49  protected $progress_enabled = false;
50  protected $item_detail_links_enabled = false;
51  protected $item_detail_links = array();
52  protected $item_detail_links_intro = '';
53 
54  protected $search_fragments_enabled = false;
55  protected $search_fragment = '';
56  protected $path_linked = false;
57 
58  protected $enabled_relevance = false;
59  protected $relevance = 0;
60 
61  protected $expand_enabled = false;
62  protected $is_expanded = true;
63  protected $bold_title = false;
64 
65  protected $copy_enabled = true;
66 
68 
73  function ilObjectListGUI()
74  {
75  global $rbacsystem, $ilCtrl, $lng, $ilias;
76 
77  $this->rbacsystem = $rbacsystem;
78  $this->ilias = $ilias;
79  $this->ctrl = $ilCtrl;
80  $this->lng = $lng;
81  $this->mode = IL_LIST_FULL;
82  $this->path_enabled = false;
83 
84 //echo "list";
85  $this->init();
86 
87  include_once('Services/LDAP/classes/class.ilLDAPRoleGroupMapping.php');
88  $this->ldap_mapping = ilLDAPRoleGroupMapping::_getInstance();
89  }
90 
91 
98  function setContainerObject(&$container_obj)
99  {
100  $this->container_obj =& $container_obj;
101  }
102 
110  public function getContainerObject()
111  {
112  return $this->container_obj;
113  }
114 
115 
121  function init()
122  {
123  // Create static links for default command (linked title) or not
124  $this->static_link_enabled = true;
125  $this->delete_enabled = true;
126  $this->cut_enabled = true;
127  $this->subscribe_enabled = true;
128  $this->link_enabled = false;
129  $this->copy_enabled = false;
130  $this->payment_enabled = false;
131  $this->progress_enabled = false;
132  $this->notice_properties_enabled = true;
133  $this->info_screen_enabled = false;
134  $this->type = ""; // "cat", "course", ...
135  $this->gui_class_name = ""; // "ilobjcategorygui", "ilobjcoursegui", ...
136 
137  // general commands array, e.g.
138  include_once('class.ilObjectAccess.php');
139  $this->commands = ilObjectAccess::_getCommands();
140  }
141 
142  // Single get set methods
149  function enableProperties($a_status)
150  {
151  $this->properties_enabled = $a_status;
152 
153  return;
154  }
162  {
164  }
171  function enablePreconditions($a_status)
172  {
173  $this->preconditions_enabled = $a_status;
174 
175  return;
176  }
177 
179  {
181  }
182 
189  function enableNoticeProperties($a_status)
190  {
191  $this->notice_properties_enabled = $a_status;
192 
193  return;
194  }
202  {
204  }
211  function enableDescription($a_status)
212  {
213  $this->description_enabled = $a_status;
214 
215  return;
216  }
224  {
226  }
227 
235  {
237  }
238 
245  function enableSearchFragments($a_status)
246  {
247  $this->search_fragment_enabled = $a_status;
248 
249  return;
250  }
251 
257  public function enableLinkedPath($a_status)
258  {
259  $this->path_linked = $a_status;
260  }
261 
266  public function enabledRelevance()
267  {
269  }
270 
275  public function enableRelevance($a_status)
276  {
277  $this->enabled_relevance = $a_status;
278  }
279 
285  public function setRelevance($a_rel)
286  {
287  $this->relevance = $a_rel;
288  }
289 
295  public function getRelevance()
296  {
297  return $this->relevance;
298  }
299 
305  function enableIcon($a_status)
306  {
307  $this->icons_enabled = $a_status;
308  }
309 
315  function getIconStatus()
316  {
317  return $this->icons_enabled;
318  }
319 
325  function enableCheckbox($a_status)
326  {
327  $this->checkboxes_enabled = $a_status;
328  }
329 
335  function getCheckboxStatus()
336  {
338  }
339 
345  function enableExpand($a_status)
346  {
347  $this->expand_enabled = $a_status;
348  }
349 
355  function getExpandStatus()
356  {
357  return $this->expand_enabled;
358  }
359 
360  function setExpanded($a_status)
361  {
362  $this->is_expanded = $a_status;
363  }
364 
365  function isExpanded()
366  {
367  return $this->is_expanded;
368  }
375  function setPositionInputField($a_field_index, $a_position_value)
376  {
377  $this->position_enabled = true;
378  $this->position_field_index = $a_field_index;
379  $this->position_value = $a_position_value;
380  }
381 
388  function enableDelete($a_status)
389  {
390  $this->delete_enabled = $a_status;
391 
392  return;
393  }
400  function getDeleteStatus()
401  {
402  return $this->delete_enabled;
403  }
404 
411  function enableCut($a_status)
412  {
413  $this->cut_enabled = $a_status;
414 
415  return;
416  }
422  function getCutStatus()
423  {
424  return $this->cut_enabled;
425  }
426 
433  function enableCopy($a_status)
434  {
435  $this->copy_enabled = $a_status;
436 
437  return;
438  }
444  function getCopyStatus()
445  {
446  return $this->copy_enabled;
447  }
448 
455  function enableSubscribe($a_status)
456  {
457  $this->subscribe_enabled = $a_status;
458 
459  return;
460  }
467  {
468  return $this->subscribe_enabled;
469  }
476  function enablePayment($a_status)
477  {
478  $this->payment_enabled = $a_status;
479 
480  return;
481  }
487  function getPaymentStatus()
488  {
489  return $this->payment_enabled;
490  }
497  function enableLink($a_status)
498  {
499  $this->link_enabled = $a_status;
500 
501  return;
502  }
508  function getLinkStatus()
509  {
510  return $this->link_enabled;
511  }
512 
519  function enablePath($a_path)
520  {
521  $this->path_enabled = $a_path;
522  }
523 
529  function getPathStatus()
530  {
531  return $this->path_enabled;
532  }
533 
540  function enableCommands($a_status, $a_std_only = false)
541  {
542  $this->commands_enabled = $a_status;
543  $this->std_cmd_only = $a_std_only;
544  }
550  function getCommandsStatus()
551  {
553  }
554 
561  function enableInfoScreen($a_info_screen)
562  {
563  $this->info_screen_enabled = $a_info_screen;
564  }
565 
571  function addSubItemHTML($a_html)
572  {
573  $this->sub_item_html[] = $a_html;
574  }
575 
582  {
584  }
585 
593  public function enableProgressInfo($a_status)
594  {
595  $this->progress_enabled = $a_status;
596  }
597 
605  public function getProgressInfoStatus()
606  {
608  }
609 
617  public function enableSubstitutions($a_status)
618  {
619  $this->substitutions_enabled = $a_status;
620  }
621 
628  public function getSubstitutionStatus()
629  {
631  }
632 
641  public function enableItemDetailLinks($a_status)
642  {
643  $this->item_detail_links_enabled = $a_status;
644  }
645 
652  public function getItemDetailLinkStatus()
653  {
655  }
656 
664  public function setItemDetailLinks($a_detail_links,$a_intro_txt = '')
665  {
666  $this->item_detail_links = $a_detail_links;
667  $this->item_detail_links_intro = $a_intro_txt;
668  }
669 
677  public function insertItemDetailLinks()
678  {
679  if(!count($this->item_detail_links))
680  {
681  return true;
682  }
683  if(strlen($this->item_detail_links_intro))
684  {
685  $this->tpl->setCurrentBlock('item_detail_intro');
686  $this->tpl->setVariable('ITEM_DETAIL_INTRO_TXT',$this->item_detail_links_intro);
687  $this->tpl->parseCurrentBlock();
688  }
689 
690  foreach($this->item_detail_links as $info)
691  {
692  $this->tpl->setCurrentBlock('item_detail_link');
693  $this->tpl->setVariable('ITEM_DETAIL_LINK_TARGET',$info['target']);
694  $this->tpl->setVariable('ITEM_DETAIL_LINK_DESC',$info['desc']);
695  $this->tpl->setVariable('ITEM_DETAIL_LINK_HREF',$info['link']);
696  $this->tpl->setVariable('ITEM_DETAIL_LINK_NAME',$info['name']);
697  $this->tpl->parseCurrentBlock();
698  }
699  $this->tpl->setCurrentBlock('item_detail_links');
700  $this->tpl->parseCurrentBlock();
701  }
702 
703 
704 
709  function setTitle($a_title)
710  {
711  $this->title = $a_title;
712  }
713 
719  function getTitle()
720  {
721  return $this->title;
722  }
723 
728  function setDescription($a_description)
729  {
730  $this->description = $a_description;
731  }
732 
738  function getDescription()
739  {
740  return $this->description;
741  }
742 
748  public function setSearchFragment($a_text)
749  {
750  $this->search_fragment = $a_text;
751  }
752 
757  public function getSearchFragment()
758  {
759  return $this->search_fragment;
760  }
761 
767  function setSeparateCommands($a_val)
768  {
769  $this->separate_commands = $a_val;
770  }
771 
778  {
780  }
790  public function getCommandId()
791  {
792  return $this->ref_id;
793  }
794 
800  function setAdditionalInformation($a_val)
801  {
802  $this->additional_information = $a_val;
803  }
804 
811  {
813  }
814 
822  public function setDetailsLevel($a_level)
823  {
824  $this->details_level = $a_level;
825  }
826 
831  public function getDetailsLevel()
832  {
833  return $this->details_level;
834  }
835 
841  public function checkCommandAccess($a_permission,$a_cmd,$a_ref_id,$a_type,$a_obj_id="")
842  {
843  global $ilAccess;
844 
845  if (isset($this->access_cache[$a_permission]["-".$a_cmd][$a_ref_id]))
846  {
847  return $this->access_cache[$a_permission]["-".$a_cmd][$a_ref_id];
848  }
849  $access = $ilAccess->checkAccess($a_permission,$a_cmd,$a_ref_id,$a_type,$a_obj_id);
850  if ($ilAccess->getPreventCachingLastResult())
851  {
852  $this->prevent_access_caching = true;
853  }
854  $this->access_cache[$a_permission]["-".$a_cmd][$a_ref_id] = $access;
855  return $access;
856  }
857 
866  function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "")
867  {
868  $this->access_cache = array();
869  $this->ref_id = $a_ref_id;
870  $this->obj_id = $a_obj_id;
871  $this->setTitle($a_title);
872  $this->setDescription($a_description);
873  #$this->description = $a_description;
874 
875  // checks, whether any admin commands are included in the output
876  $this->adm_commands_included = false;
877  $this->prevent_access_caching = false;
878  }
879 
890  {
891  if($this->static_link_enabled)
892  {
893  include_once('classes/class.ilLink.php');
894  if($link = ilLink::_getStaticLink($this->ref_id,$this->type,false))
895  {
896  $command['link'] = $link;
897  $command['frame'] = '_top';
898  }
899  }
900  return $command;
901  }
902 
903 
916  function getCommandLink($a_cmd)
917  {
918  // BEGIN WebDAV Get mount webfolder link.
919  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
920  if ($a_cmd == 'mount_webfolder' && ilDAVActivationChecker::_isActive())
921  {
922  require_once ('Services/WebDAV/classes/class.ilDAVServer.php');
923  $davServer = new ilDAVServer();
924 
925  // XXX: The following is a very dirty, ugly trick.
926  // To mount URI needs to be put into two attributes:
927  // href and folder. This hack returns both attributes
928  // like this: http://...mount_uri..." folder="http://...folder_uri...
929  return $davServer->getMountURI($this->ref_id).
930  '" folder="'.$davServer->getFolderURI($this->ref_id);
931  }
932  // END WebDAV Get mount webfolder link.
933 
934  // don't use ctrl here in the moment
935  return 'repository.php?ref_id='.$this->getCommandId().'&cmd='.$a_cmd;
936 
937  // separate method for this line
938  $cmd_link = $this->ctrl->getLinkTargetByClass($this->gui_class_name,
939  $a_cmd);
940  return $cmd_link;
941  }
942 
943 
953  function getCommandFrame($a_cmd)
954  {
955  // BEGIN WebDAV Get mount webfolder link.
956  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
957  if ($a_cmd == 'mount_webfolder' && ilDAVActivationChecker::_isActive())
958  {
959  return '_blank';
960  }
961  return "";
962  }
963 
973  function getCommandImage($a_cmd)
974  {
975  return "";
976  }
977 
989  public function getProperties($a_item = '')
990  {
991  $props = array();
992  // please list alert properties first
993  // example (use $lng->txt instead of "Status"/"Offline" strings):
994  // $props[] = array("alert" => true, "property" => "Status", "value" => "Offline");
995  // $props[] = array("alert" => false, "property" => ..., "value" => ...);
996  // ...
997 
998  // BEGIN WebDAV Display locking information
999  require_once ('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1001  {
1002  require_once ('Services/WebDAV/classes/class.ilDAVServer.php');
1003  global $ilias, $lng;
1004 
1005  // Show lock info
1006  require_once('Services/WebDAV/classes/class.ilDAVLocks.php');
1007  $davLocks = new ilDAVLocks();
1008  if ($ilias->account->getId() != ANONYMOUS_USER_ID)
1009  {
1010  $locks =& $davLocks->getLocksOnObjectObj($this->obj_id);
1011  if (count($locks) > 0)
1012  {
1013  $lockUser = new ilObjUser($locks[0]['ilias_owner']);
1014 
1015  $props[] = array(
1016  "alert" => false,
1017  "property" => $lng->txt("in_use_by"),
1018  "value" => $lockUser->getLogin(),
1019  "link" => "./ilias.php?user=".$locks[0]['ilias_owner'].'&cmd=showUserProfile&cmdClass=ilpersonaldesktopgui&cmdNode=1&baseClass=ilPersonalDesktopGUI',
1020  );
1021  }
1022  }
1023  // END WebDAV Display locking information
1024 
1025  if($this->getDetailsLevel() == self::DETAILS_SEARCH)
1026  {
1027  return $props;
1028  }
1029 
1030  // BEGIN WebDAV Display warning for invisible Unix files and files with special characters
1031  if (preg_match('/^(\\.|\\.\\.)$/', $this->title))
1032  {
1033  $props[] = array("alert" => true, "property" => $lng->txt("filename_interoperability"),
1034  "value" => $lng->txt("filename_special_filename"),
1035  'propertyNameVisible' => false);
1036  }
1037  else if (preg_match('/^\\./', $this->title))
1038  {
1039  $props[] = array("alert" => true, "property" => $lng->txt("filename_visibility"),
1040  "value" => $lng->txt("filename_hidden_unix_file"),
1041  'propertyNameVisible' => false);
1042  }
1043  else if (preg_match('/~$/', $this->title))
1044  {
1045  $props[] = array("alert" => true, "property" => $lng->txt("filename_visibility"),
1046  "value" => $lng->txt("filename_hidden_backup_file"),
1047  'propertyNameVisible' => false);
1048  }
1049  else if (preg_match('/[\\/]/', $this->title))
1050  {
1051  $props[] = array("alert" => true, "property" => $lng->txt("filename_interoperability"),
1052  "value" => $lng->txt("filename_special_characters"),
1053  'propertyNameVisible' => false);
1054  }
1055  else if (preg_match('/[\\\\\\/:*?"<>|]/', $this->title))
1056  {
1057  $props[] = array("alert" => true, "property" => $lng->txt("filename_interoperability"),
1058  "value" => $lng->txt("filename_windows_special_characters"),
1059  'propertyNameVisible' => false);
1060  }
1061  else if (preg_match('/\\.$/', $this->title))
1062  {
1063  $props[] = array("alert" => true, "property" => $lng->txt("filename_interoperability"),
1064  "value" => $lng->txt("filename_windows_empty_extension"),
1065  'propertyNameVisible' => false);
1066  }
1067  else if (preg_match('/^(\\.|\\.\\.)$/', $this->title))
1068  {
1069  $props[] = array("alert" => true, "property" => $lng->txt("filename_interoperability"),
1070  "value" => $lng->txt("filename_special_filename"),
1071  'propertyNameVisible' => false);
1072  }
1073  else if (preg_match('/#/', $this->title))
1074  {
1075  $props[] = array("alert" => true, "property" => $lng->txt("filename_interoperability"),
1076  "value" => $lng->txt("filename_windows_webdav_issue"),
1077  'propertyNameVisible' => false);
1078  }
1079  }
1080  // END WebDAV Display warning for invisible files and files with special characters
1081  // BEGIN ChangeEvent: display changes.
1082  require_once('Services/Tracking/classes/class.ilChangeEvent.php');
1084  {
1085  global $ilias, $lng, $ilUser;
1086  if ($ilias->account->getId() != ANONYMOUS_USER_ID)
1087  {
1088  // Performance improvement: for container objects
1089  // we only display 'changed inside' events, for
1090  // leaf objects we only display 'object new/changed'
1091  // events
1092  $isContainer = in_array($this->type, array('cat','fold','crs','grp'));
1093  if ($isContainer)
1094  {
1095  $state = ilChangeEvent::_lookupInsideChangeState($this->obj_id, $ilUser->getId());
1096  if ($state > 0)
1097  {
1098  $props[] = array("alert" => true, "property" => $lng->txt("event"),
1099  "value" => $lng->txt('state_changed_inside'),
1100  'propertyNameVisible' => false);
1101  }
1102  }
1103  else
1104  {
1105  $state = ilChangeEvent::_lookupChangeState($this->obj_id, $ilUser->getId());
1106  if ($state > 0)
1107  {
1108  $props[] = array("alert" => true, "property" => $lng->txt("event"),
1109  "value" => $lng->txt(($state == 1) ? 'state_unread' : 'state_changed'),
1110  'propertyNameVisible' => false);
1111  }
1112  }
1113  }
1114  }
1115  // END ChangeEvent: display changes.
1116 
1117  return $props;
1118  }
1119 
1123  function addCustomProperty($a_property = "", $a_value = "",
1124  $a_alert = false, $a_newline = false)
1125  {
1126  $this->cust_prop[] = array("property" => $a_property, "value" => $a_value,
1127  "alert" => $a_alert, "newline" => $a_newline);
1128  }
1129 
1133  function getCustomProperties($a_prop)
1134  {
1135  if (is_array($this->cust_prop))
1136  {
1137  foreach($this->cust_prop as $prop)
1138  {
1139  $a_prop[] = $prop;
1140  }
1141  }
1142  return $a_prop;
1143  }
1144 
1149  {
1150  $this->notice_prop = array();
1151  if($infos = $this->ldap_mapping->getInfoStrings($this->obj_id,true))
1152  {
1153  foreach($infos as $info)
1154  {
1155  $this->notice_prop[] = array('value' => $info);
1156  }
1157  }
1158  return $this->notice_prop ? $this->notice_prop : array();
1159  }
1163  public function addCustomCommand($a_link, $a_lang_var, $a_frame = "")
1164  {
1165  $this->cust_commands[] =
1166  array("link" => $a_link, "lang_var" => $a_lang_var,
1167  "frame" => $a_frame);
1168  }
1169 
1170 
1194  public function getCommands()
1195  {
1196  global $ilAccess, $ilBench;
1197 
1198  $ref_commands = array();
1199  foreach($this->commands as $command)
1200  {
1201  $permission = $command["permission"];
1202  $cmd = $command["cmd"];
1203  $lang_var = $command["lang_var"];
1204  $txt = $command["txt"];
1205 
1206  // BEGIN WebDAV: Suppress commands that don't make sense for anonymous users.
1207  // Suppress commands that don't make sense for anonymous users
1208  global $ilias;
1209  if ($ilias->account->getId() == ANONYMOUS_USER_ID &&
1210  $command['enable_anonymous'] == 'false')
1211  {
1212  continue;
1213  }
1214  // END WebDAV: Suppress commands that don't make sense for anonymous users.
1215 
1216  // all access checking should be made within $ilAccess and
1217  // the checkAccess of the ilObj...Access classes
1218  $ilBench->start("ilObjectListGUI", "4110_get_commands_check_access");
1219  //$access = $ilAccess->checkAccess($permission, $cmd, $this->ref_id, $this->type);
1220  $access = $this->checkCommandAccess($permission,$cmd,$this->ref_id,$this->type);
1221  $ilBench->stop("ilObjectListGUI", "4110_get_commands_check_access");
1222 
1223  if ($access)
1224  {
1225  $cmd_link = $this->getCommandLink($command["cmd"]);
1226  $cmd_frame = $this->getCommandFrame($command["cmd"]);
1227  $cmd_image = $this->getCommandImage($command["cmd"]);
1228  $access_granted = true;
1229  }
1230  else
1231  {
1232  $access_granted = false;
1233  $info_object = $ilAccess->getInfo();
1234  }
1235 
1236  $ref_commands[] = array(
1237  "permission" => $permission,
1238  "cmd" => $cmd,
1239  "link" => $cmd_link,
1240  "frame" => $cmd_frame,
1241  "lang_var" => $lang_var,
1242  "txt" => $txt,
1243  "granted" => $access_granted,
1244  "access_info" => $info_object,
1245  "img" => $cmd_image,
1246  "default" => $command["default"]
1247  );
1248  }
1249 
1250  return $ref_commands;
1251  }
1252 
1253  // BEGIN WebDAV: Visualize object state in its icon.
1261  public function getIconImageType()
1262  {
1263  return $this->type;
1264  }
1265  // END WebDAV: Visualize object state in its icon.
1266 
1274  public function insertTitle()
1275  {
1276  if (!$this->default_command || !$this->getCommandsStatus())
1277  {
1278  $this->tpl->setCurrentBlock("item_title");
1279  $this->tpl->setVariable("TXT_TITLE", $this->getTitle());
1280  $this->tpl->parseCurrentBlock();
1281  }
1282  else
1283  {
1284  if ($this->default_command["frame"] != "")
1285  {
1286  $this->tpl->setCurrentBlock("title_linked_frame");
1287  $this->tpl->setVariable("TARGET_TITLE_LINKED", $this->default_command["frame"]);
1288  $this->tpl->parseCurrentBlock();
1289  }
1290 
1291  // workaround for repository frameset
1292  #var_dump("<pre>",$this->default_command['link'],"</pre>");
1293  $this->default_command["link"] =
1294  $this->appendRepositoryFrameParameter($this->default_command["link"]);
1295 
1296  #var_dump("<pre>",$this->default_command['link'],"</pre>");
1297 
1298 
1299  // the default command is linked with the title
1300  $this->tpl->setCurrentBlock("item_title_linked");
1301  $this->tpl->setVariable("TXT_TITLE_LINKED", $this->getTitle());
1302  $this->tpl->setVariable("HREF_TITLE_LINKED", $this->default_command["link"]);
1303  $this->tpl->parseCurrentBlock();
1304  }
1305 
1306  if ($this->bold_title == true)
1307  {
1308  $this->tpl->touchBlock('bold_title_start');
1309  $this->tpl->touchBlock('bold_title_end');
1310  }
1311  }
1312 
1319  public function insertSubstitutions()
1320  {
1321  $fields_shown = false;
1322  foreach($this->substitutions->getParsedSubstitutions($this->ref_id,$this->obj_id) as $data)
1323  {
1324  if($data['bold'])
1325  {
1326  $data['name'] = '<strong>'.$data['name'].'</strong>';
1327  $data['value'] = '<strong>'.$data['value'].'</strong>';
1328  }
1329  $this->tpl->touchBlock("std_prop");
1330  $this->tpl->setCurrentBlock('item_property');
1331  if($data['show_field'])
1332  {
1333  $this->tpl->setVariable('TXT_PROP',$data['name']);
1334  }
1335  $this->tpl->setVariable('VAL_PROP',$data['value']);
1336  $this->tpl->parseCurrentBlock();
1337 
1338  if($data['newline'])
1339  {
1340  $this->tpl->touchBlock('newline_prop');
1341  }
1342  $fields_shown = false;
1343 
1344  }
1345  if($fields_shown)
1346  {
1347  $this->tpl->touchBlock('newline_prop');
1348  }
1349  }
1350 
1351 
1360  {
1361  if($this->getSubstitutionStatus())
1362  {
1363  $this->insertSubstitutions();
1364  if(!$this->substitutions->isDescriptionEnabled())
1365  {
1366  return true;
1367  }
1368  }
1369 
1370  $this->tpl->setCurrentBlock("item_description");
1371  $this->tpl->setVariable("TXT_DESC", $this->getDescription());
1372  $this->tpl->parseCurrentBlock();
1373  }
1374 
1379  public function insertSearchFragment()
1380  {
1381  if(strlen($this->getSearchFragment()))
1382  {
1383  $this->tpl->setCurrentBlock('search_fragment');
1384  $this->tpl->setVariable('TXT_SEARCH_FRAGMENT',$this->getSearchFragment().' ...');
1385  $this->tpl->parseCurrentBlock();
1386  }
1387  }
1388 
1394  public function insertRelevance()
1395  {
1396  global $lng;
1397 
1398  if(!$this->enabledRelevance() or !(int) $this->getRelevance())
1399  {
1400  return false;
1401  }
1402 
1403  $width1 = (int) $this->getRelevance();
1404  $width2 = (int) (100 - $width1);
1405 
1406  $this->tpl->setCurrentBlock('relevance');
1407  #$this->tpl->setVariable('TXT_RELEVANCE',$lng->txt('search_relevance'));
1408  $this->tpl->setVariable('VAL_REL',sprintf("%.02f %%",$this->getRelevance()));
1409  $this->tpl->setVariable('WIDTH_A',$width1);
1410  $this->tpl->setVariable('WIDTH_B',$width2);
1411  $this->tpl->setVariable('IMG_A',ilUtil::getImagePath("relevance_blue.gif"));
1412  $this->tpl->setVariable('IMG_B',ilUtil::getImagePath("relevance_dark.gif"));
1413  $this->tpl->parseCurrentBlock();
1414 
1415  }
1416 
1422  function setMode($a_mode)
1423  {
1424  $this->mode = $a_mode;
1425  }
1426 
1432  function getMode()
1433  {
1434  return $this->mode;
1435  }
1436 
1440  function setConditionDepth($a_depth)
1441  {
1442  $this->condition_depth = $a_depth;
1443  }
1444 
1452  function isMode($a_mode)
1453  {
1454  if ($a_mode == $this->mode)
1455  {
1456  return true;
1457  }
1458  else
1459  {
1460  return false;
1461  }
1462  }
1463 
1469  function insertProperties($a_item = '')
1470  {
1471  global $ilAccess, $lng;
1472 
1473  $props = $this->getProperties($a_item);
1474  $props = $this->getCustomProperties($props);
1475 
1476  // add no item access note in public section
1477  // for items that are visible but not readable
1478  if ($this->ilias->account->getId() == ANONYMOUS_USER_ID)
1479  {
1480  if (!$ilAccess->checkAccess("read", "", $this->ref_id, $this->type, $this->obj_id))
1481  {
1482  $props[] = array("alert" => true,
1483  "value" => $lng->txt("no_access_item_public"),
1484  "newline" => true);
1485  }
1486  }
1487 
1488  $cnt = 1;
1489  if (is_array($props) && count($props) > 0)
1490  {
1491  foreach($props as $prop)
1492  {
1493  // BEGIN WebDAV: Display a separator between properties.
1494  if ($cnt > 1)
1495  {
1496  $this->tpl->touchBlock("separator_prop");
1497  }
1498  // END WebDAV: Display a separator between properties.
1499 
1500  if ($prop["alert"] == true)
1501  {
1502  $this->tpl->touchBlock("alert_prop");
1503  }
1504  else
1505  {
1506  $this->tpl->touchBlock("std_prop");
1507  }
1508  if ($prop["newline"] == true && $cnt > 1)
1509  {
1510  $this->tpl->touchBlock("newline_prop");
1511  }
1512  //BEGIN WebDAV: Support hidden property names.
1513  if (isset($prop["property"]) && $prop['propertyNameVisible'] !== false)
1514  //END WebDAV: Support hidden property names.
1515  {
1516  $this->tpl->setCurrentBlock("prop_name");
1517  $this->tpl->setVariable("TXT_PROP", $prop["property"]);
1518  $this->tpl->parseCurrentBlock();
1519  }
1520  $this->tpl->setCurrentBlock("item_property");
1521  //BEGIN WebDAV: Support links in property values.
1522  if ($prop['link'])
1523  {
1524  $this->tpl->setVariable("LINK_PROP", $prop['link']);
1525  $this->tpl->setVariable("LINK_VAL_PROP", $prop["value"]);
1526  }
1527  else
1528  {
1529  $this->tpl->setVariable("VAL_PROP", $prop["value"]);
1530  }
1531  //END WebDAV: Support links in property values.
1532  $this->tpl->parseCurrentBlock();
1533 
1534  $cnt++;
1535  }
1536  $this->tpl->setCurrentBlock("item_properties");
1537  $this->tpl->parseCurrentBlock();
1538  }
1539  }
1540 
1542  {
1543  $this->getNoticeProperties();
1544  foreach($this->notice_prop as $property)
1545  {
1546  $this->tpl->setCurrentBlock('notice_item');
1547  $this->tpl->setVariable('NOTICE_ITEM_VALUE',$property['value']);
1548  $this->tpl->parseCurrentBlock();
1549  }
1550  $this->tpl->setCurrentBlock('notice_property');
1551  $this->tpl->parseCurrentBlock();
1552  }
1553 
1554 
1560  function insertPayment()
1561  {
1562  include_once 'payment/classes/class.ilPaymentObject.php';
1563 
1564  if((bool)ilGeneralSettings::_getInstance()->get('shop_enabled') &&
1565  $this->payment_enabled &&
1566  ilPaymentObject::_isBuyable($this->ref_id))
1567  {
1568  if(ilPaymentObject::_hasAccess($this->ref_id))
1569  {
1570  $this->ctpl->setCurrentBlock('payment');
1571  $this->ctpl->setVariable('PAYMENT_TYPE_IMG', ilUtil::getImagePath('icon_pays_access.gif'));
1572  $this->ctpl->setVariable('PAYMENT_ALT_IMG', $this->lng->txt('payment_system') . ': ' . $this->lng->txt('payment_payed_access'));
1573  $this->ctpl->parseCurrentBlock();
1574  }
1575  else if(ilPaymentObject::_isInCart($this->ref_id))
1576  {
1577  $this->ctpl->setCurrentBlock('payment');
1578  $this->ctpl->setVariable('PAYMENT_TYPE_IMG', ilUtil::getImagePath('icon_pays_cart.gif'));
1579  $this->ctpl->setVariable('PAYMENT_ALT_IMG', $this->lng->txt('payment_system') . ': ' . $this->lng->txt('payment_in_sc'));
1580  $this->ctpl->parseCurrentBlock();
1581 
1582  $this->insertPaymentCommand();
1583  }
1584  else
1585  {
1586  $this->ctpl->setCurrentBlock('payment');
1587  $this->ctpl->setVariable('PAYMENT_TYPE_IMG', ilUtil::getImagePath('icon_pays.gif'));
1588  $this->ctpl->setVariable('PAYMENT_ALT_IMG', $this->lng->txt('payment_system') . ': ' . $this->lng->txt('payment_buyable'));
1589  $this->ctpl->parseCurrentBlock();
1590 
1591  $this->insertPaymentCommand();
1592  }
1593  }
1594  }
1595 
1596  protected function insertPaymentCommand()
1597  {
1598  include_once 'Services/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
1599  $this->current_selection_list = new ilAdvancedSelectionListGUI();
1600  $this->current_selection_list->setListTitle($this->lng->txt("shop_actions"));
1601  $this->current_selection_list->setId("act_".$this->ref_id);
1602  $this->current_selection_list->setSelectionHeaderClass("small");
1603  $this->current_selection_list->setItemLinkClass("xsmall");
1604  $this->current_selection_list->setLinksMode("il_ContainerItemCommand2");
1605  $this->current_selection_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
1606  $this->current_selection_list->setUseImages(false);
1607  $this->current_selection_list->setAdditionalToggleElement("lg_div_".$this->ref_id, "ilContainerListItemOuterHighlight");
1608 
1609  $commands = $this->getCommands($this->ref_id, $this->obj_id);
1610  foreach($commands as $command)
1611  {
1612  if($command['default'] === true)
1613  {
1614  $command = $this->createDefaultCommand($command);
1615  if(is_null($command['link']))
1616  {
1617  switch($this->type)
1618  {
1619  case 'sahs':
1620  $command['link'] = 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id='.$this->ref_id;
1621  break;
1622 
1623  case 'lm':
1624  $command['link'] = 'ilias.php?baseClass=ilLMPresentationGUI&ref_id='.$this->ref_id;
1625  break;
1626 
1627  default:
1628  $command['link'] = 'repository.php?ref_id='.$this->ref_id;
1629  break;
1630  }
1631  }
1632 
1633  $type = $this->type;
1634  if(strpos($command['link'], '_'.$type.'_') !== false)
1635  {
1636  $demo_link = str_replace('_'.$type.'_', '_'.$type.'purchasetypedemo_', $command['link']);
1637  $buy_link = str_replace('_'.$type.'_', '_'.$type.'purchasetypebuy_', $command['link']);
1638  }
1639  else
1640  {
1641  $demo_link = $command['link'].(strpos($command['link'], '?') === false ? '?' : '&').'purchasetype=demo';
1642  $buy_link = $command['link'].(strpos($command['link'], '?') === false ? '?' : '&').'purchasetype=buy';
1643  }
1644 
1645  #$this->current_selection_list->addItem($this->lng->txt('payment_demo'), "", $command['link'].'&purchasetype=demo', $a_img, $this->lng->txt('payment_demo'), $command['frame']);
1646  #$this->current_selection_list->addItem($this->lng->txt('buy'), "", $command['link'].'&purchasetype=buy', $a_img, $this->lng->txt('buy'), $command['frame']);
1647  $this->current_selection_list->addItem($this->lng->txt('payment_demo'), "", $demo_link, $a_img, $this->lng->txt('payment_demo'), $command['frame']);
1648  $this->current_selection_list->addItem($this->lng->txt('buy'), "", $buy_link, $a_img, $this->lng->txt('buy'), $command['frame']);
1649 
1650  }
1651  }
1652 
1653  $this->ctrl->clearParametersByClass($this->gui_class_name);
1654 
1655  $this->ctpl->setVariable("COMMAND_SELECTION_LIST",
1656  $this->current_selection_list->getHTML());
1657  }
1658 
1663  {
1664  global $ilAccess, $lng, $objDefinition,$tree;
1665 
1666  include_once("classes/class.ilConditionHandler.php");
1667 
1668  $missing_cond_exist = false;
1669 
1670  // do not show multi level conditions (messes up layout)
1671  if ($this->condition_depth > 0)
1672  {
1673  return;
1674  }
1675 
1676  // Sort by title
1677  foreach(ilConditionHandler::_getConditionsOfTarget($this->ref_id, $this->obj_id) as $condition)
1678  {
1679  $condition['title'] = ilObject::_lookupTitle($condition['trigger_obj_id']);
1680  }
1681 
1682  $conditions = ilConditionHandler::_getConditionsOfTarget($this->ref_id, $this->obj_id);
1683  for($i = 0; $i < count($conditions); $i++)
1684  {
1685  $conditions[$i]['title'] = ilObject::_lookupTitle($conditions[$i]['trigger_obj_id']);
1686  }
1687 
1688  $conditions = ilUtil::sortArray($conditions,'title','DESC');
1689  foreach($conditions as $condition)
1690  {
1691  if($tree->isDeleted($condition['trigger_ref_id']))
1692  {
1693  continue;
1694  }
1695  include_once './Services/Container/classes/class.ilMemberViewSettings.php';
1696  if(ilConditionHandler::_checkCondition($condition['id']) and
1697  !ilMemberViewSettings::getInstance()->isActive())
1698  {
1699  continue;
1700  }
1701 
1702  $cond_txt = $lng->txt("condition_".$condition["operator"])." ".
1703  $condition["value"];
1704 
1705  // display trigger item
1706  $class = $objDefinition->getClassName($condition["trigger_type"]);
1707  $location = $objDefinition->getLocation($condition["trigger_type"]);
1708  if ($class == "" && $location == "")
1709  {
1710  continue;
1711  }
1712  $missing_cond_exist = true;
1713 
1714  $full_class = "ilObj".$class."ListGUI";
1715  include_once($location."/class.".$full_class.".php");
1716  $item_list_gui = new $full_class($this);
1717  $item_list_gui->setMode(IL_LIST_AS_TRIGGER);
1718  $item_list_gui->enablePath(true);
1719  $item_list_gui->setConditionDepth($this->condition_depth + 1);
1720  $trigger_html = $item_list_gui->getListItemHTML($condition['trigger_ref_id'],
1721  $condition['trigger_obj_id'], trim($cond_txt).": ".ilObject::_lookupTitle($condition["trigger_obj_id"]),
1722  "");
1723  $this->tpl->setCurrentBlock("precondition");
1724  if ($trigger_html == "")
1725  {
1726  $trigger_html = $this->lng->txt("precondition_not_accessible");
1727  }
1728  //$this->tpl->setVariable("TXT_CONDITION", trim($cond_txt));
1729  $this->tpl->setVariable("TRIGGER_ITEM", $trigger_html);
1730  $this->tpl->parseCurrentBlock();
1731  }
1732 
1733  if ($missing_cond_exist)
1734  {
1735  $this->tpl->setCurrentBlock("preconditions");
1736  $this->tpl->setVariable("TXT_PRECONDITIONS", $lng->txt("preconditions"));
1737  $this->tpl->parseCurrentBlock();
1738  }
1739  }
1740 
1749  function insertCommand($a_href, $a_text, $a_frame = "", $a_img = "")
1750  {
1751  if ($a_frame != "")
1752  {
1753  $this->ctpl->setCurrentBlock("item_frame");
1754  $this->ctpl->setVariable("TARGET_COMMAND", $a_frame);
1755  $this->ctpl->parseCurrentBlock();
1756  }
1757 
1758  $this->ctpl->setCurrentBlock("item_command");
1759  $this->ctpl->setVariable("HREF_COMMAND", $a_href);
1760  $this->ctpl->setVariable("TXT_COMMAND", $a_text);
1761  $this->ctpl->parseCurrentBlock();
1762 
1763  $this->current_selection_list->addItem($a_text, "", $a_href, $a_img, $a_text, $a_frame);
1764  }
1765 
1774  {
1775  if ($this->std_cmd_only)
1776  {
1777  return;
1778  }
1779 
1780  if(is_object($this->getContainerObject()) and
1782  {
1783  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
1784  {
1785  $this->ctrl->setParameter($this->getContainerObject(),'item_ref_id',$this->getCommandId());
1786  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "delete");
1787  $this->insertCommand($cmd_link, $this->lng->txt("delete"));
1788  $this->adm_commands_included = true;
1789  return true;
1790  }
1791  return false;
1792  }
1793 
1794  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
1795  {
1796  $this->ctrl->setParameter($this->container_obj, "ref_id",
1797  $this->container_obj->object->getRefId());
1798  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
1799  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "delete");
1800  $this->insertCommand($cmd_link, $this->lng->txt("delete"), "",
1801  ilUtil::getImagePath("cmd_delete_s.gif"));
1802  $this->adm_commands_included = true;
1803  }
1804  }
1805 
1814  {
1815  global $ilAccess;
1816 
1817  if ($this->std_cmd_only)
1818  {
1819  return;
1820  }
1821  // BEGIN PATCH Lucene search
1822 
1823  if(is_object($this->getContainerObject()) and
1825  {
1826  global $objDefinition;
1827 
1828  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type) and
1829  $objDefinition->allowLink(ilObject::_lookupType($this->obj_id)))
1830  {
1831  $this->ctrl->setParameter($this->getContainerObject(),'item_ref_id',$this->getCommandId());
1832  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "link");
1833  $this->insertCommand($cmd_link, $this->lng->txt("link"));
1834  $this->adm_commands_included = true;
1835  return true;
1836  }
1837  return false;
1838  }
1839  // END PATCH Lucene Search
1840 
1841  // if the permission is changed here, it has
1842  // also to be changed in ilContainerGUI, admin command check
1843  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
1844  {
1845  $this->ctrl->setParameter($this->container_obj, "ref_id",
1846  $this->container_obj->object->getRefId());
1847  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
1848  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "link");
1849  $this->insertCommand($cmd_link, $this->lng->txt("link"), "",
1850  ilUtil::getImagePath("cmd_link_s.gif"));
1851  $this->adm_commands_included = true;
1852  }
1853  }
1854 
1860  function insertCutCommand()
1861  {
1862  global $ilAccess;
1863 
1864  if ($this->std_cmd_only)
1865  {
1866  return;
1867  }
1868  // BEGIN PATCH Lucene search
1869  if(is_object($this->getContainerObject()) and
1871  {
1872  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
1873  {
1874  $this->ctrl->setParameter($this->getContainerObject(),'item_ref_id',$this->getCommandId());
1875  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "cut");
1876  $this->insertCommand($cmd_link, $this->lng->txt("move"));
1877  $this->adm_commands_included = true;
1878  return true;
1879  }
1880  return false;
1881  }
1882  // END PATCH Lucene Search
1883 
1884  // if the permission is changed here, it has
1885  // also to be changed in ilContainerContentGUI, determineAdminCommands
1886  if($this->checkCommandAccess('delete','',$this->ref_id,$this->type))
1887  {
1888  $this->ctrl->setParameter($this->container_obj, "ref_id",
1889  $this->container_obj->object->getRefId());
1890  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
1891  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "cut");
1892  $this->insertCommand($cmd_link, $this->lng->txt("move"), "",
1893  ilUtil::getImagePath("cmd_move_s.gif"));
1894  $this->adm_commands_included = true;
1895  }
1896  }
1897 
1902  public function insertCopyCommand()
1903  {
1904  if($this->std_cmd_only)
1905  {
1906  return;
1907  }
1908 
1909  if($this->checkCommandAccess('copy', 'copy', $this->ref_id, $this->type))
1910  {
1911  $this->ctrl->setParameterByClass('ilobjectcopygui','source_id',$this->getCommandId());
1912  $cmd_copy = $this->ctrl->getLinkTargetByClass('ilobjectcopygui','initTargetSelection');
1913  $this->insertCommand($cmd_copy, $this->lng->txt('copy'));
1914  $this->adm_commands_included = true;
1915 
1916  }
1917  return;
1918  }
1919 
1920 
1925  {
1926  global $ilAccess, $objDefinition;
1927 
1928  if ($this->std_cmd_only)
1929  {
1930  return;
1931  }
1932 
1933  if(!$objDefinition->isContainer(ilObject::_lookupType($this->obj_id)))
1934  {
1935  return false;
1936  }
1937 
1938  if(is_object($this->getContainerObject()) and
1939  $this->getContainerObject() instanceof ilAdministrationCommandHandling and
1940  isset($_SESSION['clipboard']))
1941  {
1942  $this->ctrl->setParameter($this->getContainerObject(),'item_ref_id',$this->getCommandId());
1943  $cmd_link = $this->ctrl->getLinkTarget($this->getContainerObject(), "paste");
1944  $this->insertCommand($cmd_link, $this->lng->txt("paste"));
1945  $this->adm_commands_included = true;
1946  return true;
1947  }
1948  return false;
1949  }
1950 
1959  {
1960  global $ilSetting;
1961 
1962  if ($this->std_cmd_only)
1963  {
1964  return;
1965  }
1966 
1967  if((int)$ilSetting->get('disable_my_offers'))
1968  {
1969  return;
1970  }
1971 
1973 
1974  if ($this->ilias->account->getId() != ANONYMOUS_USER_ID)
1975  {
1976  // BEGIN WebDAV: Lock/Unlock objects
1977  /* This code section is temporarily commented out.
1978  I will reactivate it at a later point, when I get the
1979  the backend working properly. - Werner Randelshofer 2008-04-17
1980  if (is_object($this->container_obj) && $this->rbacsystem->checkAccess("write", $this->ref_id))
1981  {
1982  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
1983  if (ilDAVServer::_isActive() && ilDAVServer::_isActionsVisible())
1984  {
1985  $this->ctrl->setParameter($this->container_obj, "ref_id",
1986  $this->container_obj->object->getRefId());
1987  $this->ctrl->setParameter($this->container_obj, "type", $this->type);
1988  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->ref_id);
1989  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "lock");
1990  $this->insertCommand($cmd_link, $this->lng->txt("lock"));
1991 
1992  $this->ctrl->setParameter($this->container_obj, "ref_id",
1993  $this->container_obj->object->getRefId());
1994  $this->ctrl->setParameter($this->container_obj, "type", $this->type);
1995  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->ref_id);
1996  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "unlock");
1997  $this->insertCommand($cmd_link, $this->lng->txt("unlock"));
1998  }
1999  }
2000  */
2001  // END WebDAV: Lock/Unlock objects
2002 
2003  if (!$this->ilias->account->isDesktopItem($this->getCommandId(), $type))
2004  {
2005  // Pass type and object ID to ilAccess to improve performance
2006  global $ilAccess;
2007  if ($this->checkCommandAccess("read", "", $this->ref_id, $this->type, $this->obj_id))
2008  {
2009  if($this->getContainerObject() instanceof ilDesktopItemHandling)
2010  {
2011  $this->ctrl->setParameter($this->container_obj, "type", $type);
2012  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2013  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "addToDesk");
2014  $this->insertCommand($cmd_link, $this->lng->txt("to_desktop"), "",
2015  ilUtil::getImagePath("cmd_pd_put_s.gif"));
2016  }
2017  }
2018  }
2019  else
2020  {
2021  if ($this->getContainerObject() instanceof ilDesktopItemHandling)
2022  {
2023  $this->ctrl->setParameter($this->container_obj, "type", $type);
2024  $this->ctrl->setParameter($this->container_obj, "item_ref_id", $this->getCommandId());
2025  $cmd_link = $this->ctrl->getLinkTarget($this->container_obj, "removeFromDesk");
2026  $this->insertCommand($cmd_link, $this->lng->txt("unsubscribe"), "",
2027  ilUtil::getImagePath("cmd_pd_rem_s.gif"));
2028  }
2029  }
2030  }
2031  }
2032 
2038  {
2039  if ($this->std_cmd_only)
2040  {
2041  return;
2042  }
2043  $cmd_link = $this->getCommandLink("infoScreen");
2044  $cmd_frame = $this->getCommandFrame("infoScreen");
2045  $this->insertCommand($cmd_link, $this->lng->txt("info_short"), $cmd_frame,
2046  ilUtil::getImagePath("cmd_info_s.gif"));
2047  }
2048 
2056  function insertCommands($a_use_asynch = false, $a_get_asynch_commands = false,
2057  $a_asynch_url = "")
2058  {
2059  global $lng;
2060 
2061  if (!$this->getCommandsStatus())
2062  {
2063  return;
2064  }
2065 
2066  $id_ref = ($this->reference_ref_id > 0)
2067  ? $this->reference_ref_id
2068  : $this->ref_id;
2069  include_once("./Services/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2070  $this->current_selection_list = new ilAdvancedSelectionListGUI();
2071  $this->current_selection_list->setAsynch($a_use_asynch && !$a_get_asynch_commands);
2072  $this->current_selection_list->setAsynchUrl($a_asynch_url);
2073  $this->current_selection_list->setListTitle($lng->txt("actions"));
2074  $this->current_selection_list->setId("act_".$id_ref);
2075  $this->current_selection_list->setSelectionHeaderClass("small");
2076  $this->current_selection_list->setItemLinkClass("xsmall");
2077  $this->current_selection_list->setLinksMode("il_ContainerItemCommand2");
2078  $this->current_selection_list->setHeaderIcon(ilAdvancedSelectionListGUI::DOWN_ARROW_DARK);
2079  $this->current_selection_list->setUseImages(false);
2080  $this->current_selection_list->setAdditionalToggleElement("lg_div_".$id_ref, "ilContainerListItemOuterHighlight");
2081 
2082  include_once './payment/classes/class.ilPaymentObject.php';
2083 
2084  $this->ctrl->setParameterByClass($this->gui_class_name, "ref_id", $this->ref_id);
2085 
2086  $commands = $this->getCommands($this->ref_id, $this->obj_id);
2087 
2088  // only standard command?
2089  $only_default = false;
2090  if ($a_use_asynch && !$a_get_asynch_commands)
2091  {
2092  $only_default = true;
2093  }
2094 
2095  $this->default_command = false;
2096 
2097  foreach($commands as $command)
2098  {
2099  if ($command["granted"] == true )
2100  {
2101  if (!$command["default"] === true)
2102  {
2103  if (!$this->std_cmd_only && !$only_default)
2104  {
2105  // workaround for repository frameset
2106  $command["link"] =
2107  $this->appendRepositoryFrameParameter($command["link"]);
2108 
2109  // standard edit icon
2110  if ($command["lang_var"] == "edit" && $command["img"] == "")
2111  {
2112  $command["img"] = ilUtil::getImagePath("cmd_edit_s.gif");
2113  }
2114 
2115  $cmd_link = $command["link"];
2116  $txt = ($command["lang_var"] == "")
2117  ? $command["txt"]
2118  : $this->lng->txt($command["lang_var"]);
2119  $this->insertCommand($cmd_link, $txt,
2120  $command["frame"], $command["img"]);
2121  }
2122  }
2123  else
2124  {
2125  $this->default_command = $this->createDefaultCommand($command);
2126  //$this->default_command = $command;
2127  }
2128  }
2129  elseif($command["default"] === true)
2130  {
2131  $items =& $command["access_info"];
2132  foreach ($items as $item)
2133  {
2134  if ($item["type"] == IL_NO_LICENSE)
2135  {
2136  $this->addCustomProperty($this->lng->txt("license"),$item["text"],true);
2137  $this->enableProperties(true);
2138  break;
2139  }
2140  }
2141  }
2142  }
2143 
2144  // custom commands
2145  if (is_array($this->cust_commands))
2146  {
2147  foreach ($this->cust_commands as $command)
2148  {
2149  $this->insertCommand($command["link"], $this->lng->txt($command["lang_var"]),
2150  $command["frame"]);
2151  }
2152  }
2153 
2154  // info screen commmand
2155  if ($this->getInfoScreenStatus() && !$only_default)
2156  {
2157  $this->insertInfoScreenCommand();
2158  }
2159 
2160  if (!$this->isMode(IL_LIST_AS_TRIGGER) && !$only_default)
2161  {
2162  // delete
2163  if ($this->delete_enabled)
2164  {
2165  $this->insertDeleteCommand();
2166  }
2167 
2168  // link
2169  if ($this->link_enabled)
2170  {
2171  $this->insertLinkCommand();
2172  }
2173 
2174  // cut
2175  if ($this->cut_enabled)
2176  {
2177  $this->insertCutCommand();
2178  }
2179 
2180  // copy
2181  if ($this->copy_enabled)
2182  {
2183  $this->insertCopyCommand();
2184  }
2185 
2186  // subscribe
2187  if ($this->subscribe_enabled)
2188  {
2189  $this->insertSubscribeCommand();
2190  }
2191 
2192  // BEGIN PATCH Lucene search
2193  if($this->cut_enabled or $this->link_enabled)
2194  {
2195  $this->insertPasteCommand();
2196  }
2197  // END PATCH Lucene Search
2198 
2199  }
2200  $this->ctrl->clearParametersByClass($this->gui_class_name);
2201 
2202  if ($a_use_asynch && $a_get_asynch_commands)
2203  {
2204  return $this->current_selection_list->getHTML(true);
2205  }
2206 
2207  $this->ctpl->setVariable("COMMAND_SELECTION_LIST",
2208  $this->current_selection_list->getHTML());
2209  }
2210 
2216  {
2217  $script = substr(strrchr($_SERVER["PHP_SELF"],"/"),1);
2218 
2219  if (substr($script,0,14) != "repository.php" &&
2220  is_int(strpos($a_link,"repository.php")))
2221  {
2222  $a_link =
2223  ilUtil::appendUrlParameterString($a_link, "rep_frame=1");
2224  }
2225 
2226  return $a_link;
2227  }
2228 
2232  function insertPath()
2233  {
2234  global $tree, $lng;
2235 
2236  if($this->getPathStatus() != false)
2237  {
2238  include_once './Services/Tree/classes/class.ilPathGUI.php';
2239  $path_gui = new ilPathGUI();
2240  $path_gui->enableTextOnly(!$this->path_linked);
2241  $path_gui->setUseImages(false);
2242 
2243  $this->tpl->setCurrentBlock("path_item");
2244  $this->tpl->setVariable('PATH_ITEM',$path_gui->getPath(ROOT_FOLDER_ID,$this->ref_id));
2245  $this->tpl->parseCurrentBlock();
2246 
2247  $this->tpl->setCurrentBlock("path");
2248  $this->tpl->setVariable("TXT_LOCATION", $lng->txt("locator"));
2249  $this->tpl->parseCurrentBlock();
2250  return true;
2251  }
2252  }
2253 
2260  public function insertProgressInfo()
2261  {
2262  return true;
2263  }
2264 
2265 
2270  {
2271  global $lng, $objDefinition;
2272 
2273  $cnt = 0;
2274  if ($this->getCheckboxStatus())
2275  {
2276  $this->tpl->setCurrentBlock("check");
2277  $this->tpl->setVariable("VAL_ID", $this->getCommandId());
2278  $this->tpl->parseCurrentBlock();
2279  $cnt += 1;
2280  }
2281  elseif($this->getExpandStatus())
2282  {
2283  $this->tpl->setCurrentBlock('expand');
2284 
2285  if($this->isExpanded())
2286  {
2287  $this->ctrl->setParameter($this->container_obj,'expand',-1 * $this->obj_id);
2288  $this->tpl->setVariable('EXP_HREF',$this->ctrl->getLinkTarget($this->container_obj));
2289  $this->ctrl->clearParameters($this->container_obj);
2290  $this->tpl->setVariable('EXP_IMG',ilUtil::getImagePath('browser/minus.gif'));
2291  $this->tpl->setVariable('EXP_ALT',$this->lng->txt('collapse'));
2292  }
2293  else
2294  {
2295  $this->ctrl->setParameter($this->container_obj,'expand',$this->obj_id);
2296  $this->tpl->setVariable('EXP_HREF',$this->ctrl->getLinkTarget($this->container_obj));
2297  $this->ctrl->clearParameters($this->container_obj);
2298  $this->tpl->setVariable('EXP_IMG',ilUtil::getImagePath('browser/plus.gif'));
2299  $this->tpl->setVariable('EXP_ALT',$this->lng->txt('expand'));
2300  }
2301 
2302  $this->tpl->parseCurrentBlock();
2303  $cnt += 1;
2304  }
2305 
2306  if ($this->getIconStatus())
2307  {
2308  if ($cnt == 1)
2309  {
2310  $this->tpl->touchBlock("i_1"); // indent
2311  }
2312  $this->tpl->setCurrentBlock("icon");
2313  if (!$objDefinition->isPlugin($this->getIconImageType()))
2314  {
2315  $this->tpl->setVariable("ALT_ICON", $lng->txt("icon")." ".$lng->txt("obj_".$this->getIconImageType()));
2316  }
2317  else
2318  {
2319  include_once("./Services/Component/classes/class.ilPlugin.php");
2320  $this->tpl->setVariable("ALT_ICON", $lng->txt("icon")." ".
2321  ilPlugin::lookupTxt("rep_robj", $this->getIconImageType(), "obj_".$this->getIconImageType()));
2322  }
2323 
2324  $this->tpl->setVariable("SRC_ICON",
2325  ilObject::_getIcon($this->obj_id, "small", $this->getIconImageType()));
2326  $this->tpl->parseCurrentBlock();
2327  $cnt += 1;
2328  }
2329 
2330  $this->tpl->touchBlock("d_".$cnt); // indent main div
2331  }
2332 
2336  function insertSubItems()
2337  {
2338  foreach ($this->sub_item_html as $sub_html)
2339  {
2340  $this->tpl->setCurrentBlock("subitem");
2341  $this->tpl->setVariable("SUBITEM", $sub_html);
2342  $this->tpl->parseCurrentBlock();
2343  }
2344  }
2345 
2350  {
2351  if ($this->position_enabled)
2352  {
2353  $this->tpl->setCurrentBlock("position");
2354  $this->tpl->setVariable("POS_ID", $this->position_field_index);
2355  $this->tpl->setVariable("POS_VAL", $this->position_value);
2356  $this->tpl->parseCurrentBlock();
2357  }
2358  }
2359 
2365  {
2366  return $this->adm_commands_included;
2367  }
2368 
2372  function storeAccessCache()
2373  {
2374  global $ilUser;
2375  if($this->acache->getLastAccessStatus() == "miss" &&
2376  !$this->prevent_access_caching)
2377  {
2378  $this->acache->storeEntry($ilUser->getId().":".$this->ref_id,
2379  serialize($this->access_cache), $this->ref_id);
2380  }
2381  }
2382 
2393  function getListItemHTML($a_ref_id, $a_obj_id, $a_title, $a_description,
2394  $a_use_asynch = false, $a_get_asynch_commands = false, $a_asynch_url = "")
2395  {
2396  global $ilAccess, $ilBench, $ilUser, $ilCtrl;
2397 
2398  // this variable stores wheter any admin commands
2399  // are included in the output
2400  $this->adm_commands_included = false;
2401 
2402  // only for permformance exploration
2403  $type = ilObject::_lookupType($a_obj_id);
2404 
2405  // initialization
2406  $ilBench->start("ilObjectListGUI", "1000_getListHTML_init$type");
2407  $this->tpl = new ilTemplate ("tpl.container_list_item.html", true, true, false, "DEFAULT", false, true);
2408  $this->ctpl = new ilTemplate ("tpl.container_list_item_commands.html", true, true, false, "DEFAULT", false, true);
2409  $this->initItem($a_ref_id, $a_obj_id, $a_title, $a_description);
2410  $ilBench->stop("ilObjectListGUI", "1000_getListHTML_init$type");
2411 
2412  if ($a_use_asynch && $a_get_asynch_commands)
2413  {
2414  return $this->insertCommands(true, true);
2415  }
2416 
2417  // read from cache
2418  include_once("./Services/Object/classes/class.ilListItemAccessCache.php");
2419  $this->acache = new ilListItemAccessCache();
2420  $cres = $this->acache->getEntry($ilUser->getId().":".$a_ref_id);
2421  if($this->acache->getLastAccessStatus() == "hit")
2422  {
2423  $this->access_cache = unserialize($cres);
2424  }
2425 
2426  // visible check
2427  $ilBench->start("ilObjectListGUI", "2000_getListHTML_check_visible");
2428  if (!$this->checkCommandAccess("visible", "", $a_ref_id, "", $a_obj_id))
2429  {
2430  $this->storeAccessCache();
2431  $ilBench->stop("ilObjectListGUI", "2000_getListHTML_check_visible");
2432  return "";
2433  }
2434  $ilBench->stop("ilObjectListGUI", "2000_getListHTML_check_visible");
2435 
2436 
2437  // commands
2438  $ilBench->start("ilObjectListGUI", "4000_insert_commands");
2439  $this->insertCommands($a_use_asynch, $a_get_asynch_commands, $a_asynch_url);
2440  $ilBench->stop("ilObjectListGUI", "4000_insert_commands");
2441 
2442  // write to cache
2443  $this->storeAccessCache();
2444 
2445  // payment
2446 // todo
2447  $ilBench->start("ilObjectListGUI", "5000_insert_pay");
2448  $this->insertPayment();
2449  $ilBench->stop("ilObjectListGUI", "5000_insert_pay");
2450 
2451  if($this->getProgressInfoStatus())
2452  {
2453  $this->insertProgressInfo();
2454  }
2455 
2456  if ($this->getCommandsStatus() ||
2457  ($this->payment_enabled && (bool)ilGeneralSettings::_getInstance()->get('shop_enabled')))
2458  {
2459  if (!$this->getSeparateCommands())
2460  {
2461  $this->tpl->setVariable("COMMANDS", $this->ctpl->get());
2462  }
2463  }
2464 
2465  // insert title and describtion
2466  $ilBench->start("ilObjectListGUI", "3000_insert_title_desc");
2467  $this->insertTitle();
2468  if (!$this->isMode(IL_LIST_AS_TRIGGER))
2469  {
2470  if ($this->getDescriptionStatus())
2471  {
2472  $this->insertDescription();
2473  }
2474  }
2475  $ilBench->stop("ilObjectListGUI", "3000_insert_title_desc");
2476 
2477  if($this->getSearchFragmentStatus())
2478  {
2479  $this->insertSearchFragment();
2480  }
2481  if($this->enabledRelevance())
2482  {
2483  $this->insertRelevance();
2484  }
2485 
2486  // properties
2487  $ilBench->start("ilObjectListGUI", "6000_insert_properties$type");
2488  if ($this->getPropertiesStatus())
2489  {
2490  $this->insertProperties();
2491  }
2492  $ilBench->stop("ilObjectListGUI", "6000_insert_properties$type");
2493 
2494  // notice properties
2495  $ilBench->start("ilObjectListGUI", "6500_insert_notice_properties$type");
2496  if($this->getNoticePropertiesStatus())
2497  {
2498  $this->insertNoticeProperties();
2499  }
2500  $ilBench->stop("ilObjectListGUI", "6500_insert_notice_properties$type");
2501 
2502  // preconditions
2503  $ilBench->start("ilObjectListGUI", "7000_insert_preconditions");
2504  if ($this->getPreconditionsStatus())
2505  {
2506  $this->insertPreconditions();
2507  }
2508  $ilBench->stop("ilObjectListGUI", "7000_insert_preconditions");
2509 
2510  // path
2511  $ilBench->start("ilObjectListGUI", "8000_insert_path");
2512  $this->insertPath();
2513  $ilBench->stop("ilObjectListGUI", "8000_insert_path");
2514 
2515  $ilBench->start("ilObjectListGUI", "8500_item_detail_links");
2516  if($this->getItemDetailLinkStatus())
2517  {
2518  $this->insertItemDetailLinks();
2519  }
2520  $ilBench->stop("ilObjectListGUI", "8500_item_detail_links");
2521 
2522  // icons and checkboxes
2523  $this->insertIconsAndCheckboxes();
2524 
2525  // input field for position
2526  $this->insertPositionField();
2527 
2528  // subitems
2529  $this->insertSubItems();
2530 
2531  // reset properties and commands
2532  $this->cust_prop = array();
2533  $this->cust_commands = array();
2534  $this->sub_item_html = array();
2535  $this->position_enabled = false;
2536 
2537  $id_ref = ($this->reference_ref_id > 0)
2538  ? $this->reference_ref_id
2539  : $this->ref_id;
2540 
2541  $this->tpl->setVariable("DIV_ID", 'id = "lg_div_'.$id_ref.'"');
2542  $this->tpl->setVariable("ADDITIONAL", $this->getAdditionalInformation());
2543 
2544  return $this->tpl->get();
2545  }
2546 
2550  function getCommandsHTML()
2551  {
2552  return $this->ctpl->get();
2553  }
2554 
2558  function isSideBlock()
2559  {
2560  return false;
2561  }
2562 
2568  public function setBoldTitle($a_bold_title)
2569  {
2570  $this->bold_title = $a_bold_title;
2571 
2572  }
2573 
2579  public function isTitleBold()
2580  {
2581  return $this->bold_title;
2582  }
2583 
2584 
2585 } // END class.ilObjectListGUI
2586 ?>