00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 include_once("Services/Block/classes/class.ilBlockGUI.php");
00025
00034 class ilPDSelectedItemsBlockGUI extends ilBlockGUI
00035 {
00036 static $block_type = "pditems";
00037
00041 function ilPDSelectedItemsBlockGUI()
00042 {
00043 global $ilCtrl, $lng, $ilUser;
00044
00045 parent::ilBlockGUI();
00046
00047
00048 $this->setTitle($lng->txt("selected_items"));
00049 $this->setEnableNumInfo(false);
00050 $this->setLimit(99999);
00051 $this->setColSpan(2);
00052 $this->setAvailableDetailLevels(3, 1);
00053 $this->setBigMode(true);
00054 $this->lng = $lng;
00055 $this->allow_moving = false;
00056 }
00057
00063 static function getBlockType()
00064 {
00065 return self::$block_type;
00066 }
00067
00073 static function isRepositoryObject()
00074 {
00075 return false;
00076 }
00077
00078
00079 function getHTML()
00080 {
00081 global $ilCtrl;
00082
00083
00084 $this->setData(array("dummy"));
00085
00086 $this->setContent($this->getSelectedItemsBlockHTML());
00087 if ($this->getContent() == "")
00088 {
00089 $this->setEnableDetailRow(false);
00090 }
00091 $ilCtrl->clearParametersByClass("ilpersonaldesktopgui");
00092 $ilCtrl->clearParameters($this);
00093 return parent::getHTML();
00094 }
00095
00099 function &executeCommand()
00100 {
00101 global $ilCtrl;
00102
00103 $next_class = $ilCtrl->getNextClass();
00104 $cmd = $ilCtrl->getCmd("getHTML");
00105
00106 return $this->$cmd();
00107 }
00108
00109 function getContent()
00110 {
00111 return $this->content;
00112 }
00113
00114 function setContent($a_content)
00115 {
00116 $this->content = $a_content;
00117 }
00118
00122 function fillDataSection()
00123 {
00124 global $ilUser;
00125
00126 if ($this->getContent() != "")
00127 {
00128 $this->tpl->setVariable("BLOCK_ROW", $this->getContent());
00129 }
00130 else
00131 {
00132 $this->setDataSection($this->getIntroduction());
00133 }
00134 }
00135
00136
00140 function fillFooter()
00141 {
00142 global $ilCtrl, $lng, $ilUser;
00143
00144 $this->setFooterLinks();
00145 $this->fillFooterLinks();
00146 $this->tpl->setVariable("FCOLSPAN", $this->getColSpan());
00147 if ($this->tpl->blockExists("block_footer"))
00148 {
00149 $this->tpl->setCurrentBlock("block_footer");
00150 $this->tpl->parseCurrentBlock();
00151 }
00152 }
00153
00157 function setFooterLinks()
00158 {
00159 global $ilUser, $ilCtrl, $lng;
00160
00161 if ($this->getContent() == "")
00162 {
00163 $this->setEnableNumInfo(false);
00164 return "";
00165 }
00166
00167
00168 if ($ilUser->getPref("pd_order_items") == 'location')
00169 {
00170 $this->addFooterLink( $lng->txt("by_type"),
00171 $ilCtrl->getLinkTarget($this,
00172 "orderPDItemsByType"),
00173 $ilCtrl->getLinkTarget($this,
00174 "orderPDItemsByType", "", true),
00175 "block_".$this->getBlockType()."_".$this->block_id
00176 );
00177 }
00178 else
00179 {
00180 $this->addFooterLink($lng->txt("by_type"));
00181 }
00182
00183
00184 if ($ilUser->getPref("pd_order_items") == 'location')
00185 {
00186 $this->addFooterLink($lng->txt("by_location"));
00187 }
00188 else
00189 {
00190 $this->addFooterLink( $lng->txt("by_location"),
00191 $ilCtrl->getLinkTarget($this,
00192 "orderPDItemsByLocation"),
00193 $ilCtrl->getLinkTarget($this,
00194 "orderPDItemsByLocation", "", true),
00195 "block_".$this->getBlockType()."_".$this->block_id
00196 );
00197 }
00198 }
00199
00203 function getSelectedItemsBlockHTML()
00204 {
00205 global $ilUser, $rbacsystem, $objDefinition, $ilBench;
00206
00207 $tpl =& $this->newBlockTemplate();
00208
00209 switch ($ilUser->getPref("pd_order_items"))
00210 {
00211 case "location":
00212 $ok = $this->getSelectedItemsPerLocation($tpl);
00213 break;
00214
00215 default:
00216 $ok = $this->getSelectedItemsPerType($tpl);
00217 break;
00218 }
00219
00220 return $tpl->get();
00221 }
00222
00226 function getSelectedItemsPerType(&$tpl)
00227 {
00228 global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache;
00229
00230 $items = $ilUser->getDesktopItems();
00231 if (count($items) > 0)
00232 {
00233
00234 $ref_ids = array();
00235 foreach($items as $item)
00236 {
00237 $ref_ids[] = $item["ref_id"];
00238 }
00239 $ilObjDataCache->preloadReferenceCache($ref_ids);
00240 }
00241
00242 $output = false;
00243 $types = array(
00244 array("title" => $this->lng->txt("objs_cat"), "types" => "cat"),
00245 array("title" => $this->lng->txt("objs_fold"), "types" => "fold"),
00246 array("title" => $this->lng->txt("objs_crs"), "types" => "crs"),
00247 array("title" => $this->lng->txt("objs_grp"), "types" => "grp"),
00248 array("title" => $this->lng->txt("objs_chat"), "types" => "chat"),
00249 array("title" => $this->lng->txt("objs_frm"), "types" => "frm"),
00250 array("title" => $this->lng->txt("learning_resources"),"types" => array("lm", "htlm", "sahs", "dbk")),
00251 array("title" => $this->lng->txt("objs_glo"), "types" => "glo"),
00252 array("title" => $this->lng->txt("objs_file"), "types" => "file"),
00253 array("title" => $this->lng->txt("objs_webr"), "types" => "webr"),
00254 array("title" => $this->lng->txt("objs_mcst"), "types" => "mcst"),
00255 array("title" => $this->lng->txt("objs_exc"), "types" => "exc"),
00256 array("title" => $this->lng->txt("objs_tst"), "types" => "tst"),
00257 array("title" => $this->lng->txt("objs_svy"), "types" => "svy"),
00258 array("title" => $this->lng->txt("objs_mep"), "types" => "mep"),
00259 array("title" => $this->lng->txt("objs_qpl"), "types" => "qpl"),
00260 array("title" => $this->lng->txt("objs_spl"), "types" => "spl"),
00261 array("title" => $this->lng->txt("objs_icrs"), "types" => "icrs"),
00262 array("title" => $this->lng->txt("objs_icla"), "types" => "icla")
00263 );
00264
00265 foreach ($types as $type)
00266 {
00267 $type = $type["types"];
00268 $title = $type["title"];
00269
00270 $items = $ilUser->getDesktopItems($type);
00271
00272 $item_html = array();
00273
00274 if ($this->getCurrentDetailLevel() == 3)
00275 {
00276 $rel_header = (is_array($type))
00277 ? "th_lres"
00278 : "th_".$type;
00279 }
00280
00281 if (count($items) > 0)
00282 {
00283 $tstCount = 0;
00284 $unsetCount = 0;
00285 $progressCount = 0;
00286 $unsetFlag = 0;
00287 $progressFlag = 0;
00288 $completedFlag = 0;
00289 if (strcmp($a_type, "tst") == 0) {
00290 $items = $this->multiarray_sort($items, "used_tries; title");
00291 foreach ($items as $tst_item) {
00292 if (!isset($tst_item["used_tries"])) {
00293 $unsetCount++;
00294 }
00295 elseif ($tst_item["used_tries"] == 0) {
00296 $progressCount++;
00297 }
00298 }
00299 }
00300
00301 foreach($items as $item)
00302 {
00303
00304 if ($cur_obj_type != $item["type"])
00305 {
00306 $class = $objDefinition->getClassName($item["type"]);
00307 $location = $objDefinition->getLocation($item["type"]);
00308 $full_class = "ilObj".$class."ListGUI";
00309 include_once($location."/class.".$full_class.".php");
00310 $item_list_gui = new $full_class();
00311 $item_list_gui->enableDelete(false);
00312 $item_list_gui->enableCut(false);
00313 $item_list_gui->enablePayment(false);
00314 $item_list_gui->enableLink(false);
00315 $item_list_gui->enableInfoScreen(false);
00316 if ($this->getCurrentDetailLevel() < 3)
00317 {
00318 $item_list_gui->enableDescription(false);
00319 $item_list_gui->enableProperties(false);
00320 $item_list_gui->enablePreconditions(false);
00321 $item_list_gui->enableNoticeProperties(false);
00322 }
00323 if ($this->getCurrentDetailLevel() < 2)
00324 {
00325 $item_list_gui->enableCommands(true, true);
00326 }
00327 }
00328
00329 $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
00330
00331 $html = $item_list_gui->getListItemHTML($item["ref_id"],
00332 $item["obj_id"], $item["title"], $item["description"]);
00333 $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
00334 if ($html != "")
00335 {
00336 $item_html[] = array("html" => $html, "item_ref_id" => $item["ref_id"],
00337 "item_obj_id" => $item["obj_id"]);
00338 }
00339 }
00340
00341
00342 if (count($item_html) > 0)
00343 {
00344
00345 if ($this->getCurrentDetailLevel() == 3)
00346 {
00347 if ($ilSetting->get("icon_position_in_lists") == "item_rows")
00348 {
00349 $this->addHeaderRow($tpl, $type, false);
00350 }
00351 else
00352 {
00353 $this->addHeaderRow($tpl, $type);
00354 }
00355 $this->resetRowType();
00356 }
00357
00358
00359 foreach($item_html as $item)
00360 {
00361 if ($this->getCurrentDetailLevel() < 3 ||
00362 $ilSetting->get("icon_position_in_lists") == "item_rows")
00363 {
00364 $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $type, $rel_header);
00365 }
00366 else
00367 {
00368 $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], "", $rel_header);
00369 }
00370 $output = true;
00371 }
00372 }
00373 }
00374 }
00375
00376 return $output;
00377 }
00378
00382 function getSelectedItemsPerLocation(&$tpl)
00383 {
00384 global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache;
00385
00386 $output = false;
00387
00388 $items = $ilUser->getDesktopItems();
00389 $item_html = array();
00390
00391 if (count($items) > 0)
00392 {
00393
00394 $ref_ids = array();
00395 foreach($items as $item)
00396 {
00397 $ref_ids[] = $item["ref_id"];
00398 }
00399 reset($items);
00400 $ilObjDataCache->preloadReferenceCache($ref_ids);
00401
00402 foreach($items as $item)
00403 {
00404
00405
00406 if ($cur_obj_type != $item["type"])
00407 {
00408 $item_list_gui =& $this->getItemListGUI($item["type"]);
00409
00410 $item_list_gui->enableDelete(false);
00411 $item_list_gui->enableCut(false);
00412 $item_list_gui->enablePayment(false);
00413 $item_list_gui->enableLink(false);
00414 $item_list_gui->enableInfoScreen(false);
00415 if ($this->getCurrentDetailLevel() < 3)
00416 {
00417
00418 $item_list_gui->enableDescription(false);
00419 $item_list_gui->enableProperties(false);
00420 $item_list_gui->enablePreconditions(false);
00421 }
00422 if ($this->getCurrentDetailLevel() < 2)
00423 {
00424 $item_list_gui->enableCommands(true, true);
00425 }
00426 }
00427
00428 $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
00429
00430 $html = $item_list_gui->getListItemHTML($item["ref_id"],
00431 $item["obj_id"], $item["title"], $item["description"]);
00432 $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
00433 if ($html != "")
00434 {
00435 $item_html[] = array("html" => $html, "item_ref_id" => $item["ref_id"],
00436 "item_obj_id" => $item["obj_id"], "parent_ref" => $item["parent_ref"],
00437 "type" => $item["type"]);
00438 }
00439 }
00440
00441
00442 if (count($item_html) > 0)
00443 {
00444 $cur_parent_ref = 0;
00445
00446
00447 foreach($item_html as $item)
00448 {
00449
00450 if ($cur_parent_ref != $item["parent_ref"])
00451 {
00452 if ($ilSetting->get("icon_position_in_lists") == "item_rows")
00453 {
00454 $this->addParentRow($tpl, $item["parent_ref"], false);
00455 }
00456 else
00457 {
00458 $this->addParentRow($tpl, $item["parent_ref"]);
00459 }
00460 $this->resetRowType();
00461 $cur_parent_ref = $item["parent_ref"];
00462 }
00463
00464
00465
00466
00467 $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $item["type"],
00468 "th_".$cur_parent_ref);
00469
00470
00471
00472
00473
00474 $output = true;
00475 }
00476 }
00477 }
00478
00479 return $output;
00480 }
00481
00482 function resetRowType()
00483 {
00484 $this->cur_row_type = "";
00485 }
00486
00493 function &newBlockTemplate()
00494 {
00495 $tpl = new ilTemplate ("tpl.pd_list_block.html", true, true);
00496 $this->cur_row_type = "";
00497 return $tpl;
00498 }
00499
00503 function &getItemListGUI($a_type)
00504 {
00505 global $objDefinition;
00506
00507 if (!is_object($this->item_list_guis[$a_type]))
00508 {
00509 $class = $objDefinition->getClassName($a_type);
00510 $location = $objDefinition->getLocation($a_type);
00511 $full_class = "ilObj".$class."ListGUI";
00512
00513 include_once($location."/class.".$full_class.".php");
00514 $item_list_gui = new $full_class();
00515 $this->item_list_guis[$a_type] =& $item_list_gui;
00516 }
00517 else
00518 {
00519 $item_list_gui =& $this->item_list_guis[$a_type];
00520 }
00521 return $item_list_gui;
00522 }
00523
00531 function addHeaderRow(&$a_tpl, $a_type, $a_show_image = true)
00532 {
00533 if (!is_array($a_type))
00534 {
00535 $icon = ilUtil::getImagePath("icon_".$a_type.".gif");
00536 $title = $this->lng->txt("objs_".$a_type);
00537 $header_id = "th_".$a_type;
00538 }
00539 else
00540 {
00541 $icon = ilUtil::getImagePath("icon_lm.gif");
00542 $title = $this->lng->txt("learning_resources");
00543 $header_id = "th_lres";
00544 }
00545 if ($a_show_image)
00546 {
00547 $a_tpl->setCurrentBlock("container_header_row_image");
00548 $a_tpl->setVariable("HEADER_IMG", $icon);
00549 $a_tpl->setVariable("HEADER_ALT", $title);
00550 }
00551 else
00552 {
00553 $a_tpl->setCurrentBlock("container_header_row");
00554 }
00555
00556 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $title);
00557 $a_tpl->setVariable("BLOCK_HEADER_ID", $header_id);
00558 $a_tpl->parseCurrentBlock();
00559 $a_tpl->touchBlock("container_row");
00560 }
00561
00569 function addParentRow(&$a_tpl, $a_ref_id, $a_show_image = true)
00570 {
00571 global $tree, $ilSetting;
00572
00573 $par_id = ilObject::_lookupObjId($a_ref_id);
00574 $type = ilObject::_lookupType($par_id);
00575 if (!in_array($type, array("lm", "dbk", "sahs", "htlm")))
00576 {
00577 $icon = ilUtil::getImagePath("icon_".$type.".gif");
00578 }
00579 else
00580 {
00581 $icon = ilUtil::getImagePath("icon_lm.gif");
00582 }
00583
00584
00585 if ($ilSetting->get("custom_icons") &&
00586 in_array($type, array("cat","grp","crs", "root")))
00587 {
00588 require_once("classes/class.ilContainer.php");
00589 if (($path = ilContainer::_lookupIconPath($par_id, "small")) != "")
00590 {
00591 $icon = $path;
00592 }
00593 }
00594
00595 if ($tree->getRootId() != $par_id)
00596 {
00597 $title = ilObject::_lookupTitle($par_id);
00598 }
00599 else
00600 {
00601 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
00602 $title = $nd["title"];
00603 if ($title == "ILIAS")
00604 {
00605 $title = $this->lng->txt("repository");
00606 }
00607 }
00608
00609 $item_list_gui =& $this->getItemListGUI($type);
00610
00611 $item_list_gui->enableDelete(false);
00612 $item_list_gui->enableCut(false);
00613 $item_list_gui->enablePayment(false);
00614 $item_list_gui->enableLink(false);
00615 $item_list_gui->enableDescription(false);
00616 $item_list_gui->enableProperties(false);
00617 $item_list_gui->enablePreconditions(false);
00618 $item_list_gui->enablePath(true);
00619 $item_list_gui->enableCommands(false);
00620 $html = $item_list_gui->getListItemHTML($a_ref_id,
00621 $par_id, $title, "");
00622
00623 if ($a_show_image)
00624 {
00625 $a_tpl->setCurrentBlock("container_header_row_image");
00626 $a_tpl->setVariable("HEADER_IMG", $icon);
00627 $a_tpl->setVariable("HEADER_ALT", $title);
00628 }
00629 else
00630 {
00631 $a_tpl->setCurrentBlock("container_header_row");
00632 }
00633
00634 $a_tpl->setVariable("BLOCK_HEADER_CONTENT", $html);
00635 $a_tpl->setVariable("BLOCK_HEADER_ID", "th_".$a_ref_id);
00636 $a_tpl->parseCurrentBlock();
00637 $a_tpl->touchBlock("container_row");
00638 }
00639
00647 function addStandardRow(&$a_tpl, $a_html, $a_item_ref_id = "", $a_item_obj_id = "",
00648 $a_image_type = "", $a_related_header = "")
00649 {
00650 global $ilSetting;
00651
00652 $this->cur_row_type = ($this->cur_row_type == "row_type_1")
00653 ? "row_type_2"
00654 : "row_type_1";
00655 $a_tpl->touchBlock($this->cur_row_type);
00656
00657 if ($a_image_type != "")
00658 {
00659 if (!is_array($a_image_type) && !in_array($a_image_type, array("lm", "dbk", "htlm", "sahs")))
00660 {
00661 $icon = ilUtil::getImagePath("icon_".$a_image_type.".gif");
00662 $title = $this->lng->txt("obj_".$a_image_type);
00663 }
00664 else
00665 {
00666 $icon = ilUtil::getImagePath("icon_lm.gif");
00667 $title = $this->lng->txt("learning_resource");
00668 }
00669
00670
00671 if ($ilSetting->get("custom_icons") &&
00672 in_array($a_image_type, array("cat","grp","crs")))
00673 {
00674 require_once("classes/class.ilContainer.php");
00675 if (($path = ilContainer::_lookupIconPath($a_item_obj_id, "small")) != "")
00676 {
00677 $icon = $path;
00678 }
00679 }
00680
00681 $a_tpl->setCurrentBlock("block_row_image");
00682 $a_tpl->setVariable("ROW_IMG", $icon);
00683 $a_tpl->setVariable("ROW_ALT", $title);
00684 $a_tpl->parseCurrentBlock();
00685 }
00686 else
00687 {
00688 $a_tpl->setVariable("ROW_NBSP", " ");
00689 }
00690 $a_tpl->setCurrentBlock("container_standard_row");
00691 $a_tpl->setVariable("BLOCK_ROW_CONTENT", $a_html);
00692 $rel_headers = ($a_related_header != "")
00693 ? "th_selected_items ".$a_related_header
00694 : "th_selected_items";
00695 $a_tpl->setVariable("BLOCK_ROW_HEADERS", $rel_headers);
00696 $a_tpl->parseCurrentBlock();
00697 $a_tpl->touchBlock("container_row");
00698 }
00699
00703 function getIntroduction()
00704 {
00705 global $ilUser, $lng, $ilCtrl, $tree;
00706
00707
00708 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
00709 $title = $nd["title"];
00710 if ($title == "ILIAS")
00711 {
00712 $title = $lng->txt("repository");
00713 }
00714
00715 $tpl = new ilTemplate("tpl.pd_intro.html", true, true, "Services/PersonalDesktop");
00716 $tpl->setVariable("IMG_PD_LARGE", ilUtil::getImagePath("icon_pd_xxl.gif"));
00717 $tpl->setVariable("TXT_WELCOME", $lng->txt("pdesk_intro"));
00718 $tpl->setVariable("TXT_INTRO_1", sprintf($lng->txt("pdesk_intro2"), $lng->txt("to_desktop")));
00719 $tpl->setVariable("TXT_INTRO_2", sprintf($lng->txt("pdesk_intro3"),
00720 '<a href="repository.php?cmd=frameset&getlast=true">'.$title.'</a>'));
00721 $tpl->setVariable("TXT_INTRO_3", $lng->txt("pdesk_intro4"));
00722
00723 return $tpl->get();
00724 }
00725
00729 function orderPDItemsByLocation()
00730 {
00731 global $ilUser, $ilCtrl;
00732
00733 $ilUser->writePref("pd_order_items", "location");
00734
00735 if ($ilCtrl->isAsynch())
00736 {
00737 echo $this->getHTML();
00738 exit;
00739 }
00740 else
00741 {
00742 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
00743 }
00744 }
00745
00749 function orderPDItemsByType()
00750 {
00751 global $ilUser, $ilCtrl;
00752
00753 $ilUser->writePref("pd_order_items", "type");
00754
00755 if ($ilCtrl->isAsynch())
00756 {
00757 echo $this->getHTML();
00758 exit;
00759 }
00760 else
00761 {
00762 $ilCtrl->redirectByClass("ilpersonaldesktopgui", "show");
00763 }
00764 }
00765
00766 }
00767
00768 ?>