protected function getItems()
 {
     global $ilUser;
     include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
     $tree = new ilWorkspaceTree($ilUser->getId());
     $nodes = $tree->getChilds($this->node_id, "title");
     if (sizeof($nodes)) {
         include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php";
         $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_WORKSPACE);
         foreach ($nodes as $node) {
             $preloader->addItem($node["obj_id"], $node["type"]);
         }
         $preloader->preload();
         unset($preloader);
     }
     $this->shared_objects = $this->access_handler->getObjectsIShare();
     $this->setData($nodes);
 }
 protected function filterContainer()
 {
     global $objDefinition, $lng, $tree, $ilAccess, $ilCtrl;
     $this->initProviders();
     // empty selection is invalid
     if (!$_SESSION[self::getBlockType()]) {
         exit;
     }
     $all_matching_provider_object_ids = null;
     foreach ($this->providers as $provider) {
         $id = get_class($provider);
         $current = $_SESSION[self::getBlockType()][$id];
         if ($current) {
             // combine providers AND
             $provider_object_ids = $provider->getFilteredObjects();
             if (is_array($all_matching_provider_object_ids)) {
                 $all_matching_provider_object_ids = array_intersect($matching_provider_object_ids, $provider_object_ids);
             } else {
                 $all_matching_provider_object_ids = $provider_object_ids;
             }
         }
     }
     $has_content = false;
     $ltpl = new ilTemplate("tpl.classification_object_list.html", true, true, "Services/Classification");
     if (sizeof($all_matching_provider_object_ids)) {
         $fields = array("object_reference.ref_id", "object_data.obj_id", "object_data.type", "object_data.title", "object_data.description");
         $matching = $tree->getSubTreeFilteredByObjIds($this->parent_ref_id, $all_matching_provider_object_ids, $fields);
         if (sizeof($matching)) {
             $valid_objects = array();
             // :TODO: not sure if this makes sense...
             include_once "Services/Object/classes/class.ilObjectListGUIPreloader.php";
             $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_REPOSITORY);
             foreach ($matching as $item) {
                 if ($item["ref_id"] != $this->parent_ref_id && !$tree->isDeleted($item["ref_id"]) && $ilAccess->checkAccess("read", "", $item["ref_id"])) {
                     $valid_objects[] = $item;
                     $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
                 }
             }
             if (sizeof($valid_objects)) {
                 $has_content = true;
                 $preloader->preload();
                 // see ilPDTaggingBlockGUI::showResourcesForTag()
                 $this->item_list_gui = array();
                 foreach ($valid_objects as $obj) {
                     $type = $obj["type"];
                     // get list gui class for each object type
                     if (empty($this->item_list_gui[$type])) {
                         $class = $objDefinition->getClassName($type);
                         $location = $objDefinition->getLocation($type);
                         $full_class = "ilObj" . $class . "ListGUI";
                         include_once $location . "/class." . $full_class . ".php";
                         $this->item_list_gui[$type] = new $full_class();
                         $this->item_list_gui[$type]->enableDelete(false);
                         $this->item_list_gui[$type]->enablePath(true, $this->parent_ref_id);
                         // relative path
                         $this->item_list_gui[$type]->enableCut(false);
                         $this->item_list_gui[$type]->enableCopy(false);
                         $this->item_list_gui[$type]->enableSubscribe(false);
                         $this->item_list_gui[$type]->enablePayment(false);
                         $this->item_list_gui[$type]->enableLink(false);
                         $this->item_list_gui[$type]->enableIcon(true);
                         // :TOOD: for each item or just for each list?
                         foreach ($this->providers as $provider) {
                             $provider->initListGUI($this->item_list_gui[$type]);
                         }
                     }
                     $html = $this->item_list_gui[$type]->getListItemHTML($obj["ref_id"], $obj["obj_id"], $obj["title"], $obj["description"]);
                     if ($html != "") {
                         $css = $css != "tblrow1" ? "tblrow1" : "tblrow2";
                         $ltpl->setCurrentBlock("res_row");
                         $ltpl->setVariable("ROWCLASS", $css);
                         $ltpl->setVariable("RESOURCE_HTML", $html);
                         $ltpl->setVariable("ALT_TYPE", $lng->txt("obj_" . $type));
                         $ltpl->setVariable("IMG_TYPE", ilUtil::getImagePath("icon_" . $type . ".svg"));
                         $ltpl->parseCurrentBlock();
                     }
                 }
             }
         }
     }
     include_once "./Services/PersonalDesktop/classes/class.ilPDContentBlockGUI.php";
     $content_block = new ilPDContentBlockGUI();
     $content_block->setTitle($lng->txt("clsfct_content_title"));
     $content_block->addHeaderCommand($ilCtrl->getParentReturn($this), "", true);
     if ($has_content) {
         $content_block->setContent($ltpl->get());
     } else {
         $content_block->setContent($lng->txt("clsfct_content_no_match"));
     }
     echo $content_block->getHTML();
     exit;
 }
 /**
  * Render item list 
  * @return void
  */
 protected function renderItemList()
 {
     global $tree, $ilBench;
     $this->html = '';
     $ilBench->start('Lucene', '2000_pr');
     $this->parseResultReferences();
     $ilBench->stop('Lucene', '2000_pr');
     include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php";
     $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_SEARCH);
     $set = array();
     foreach ($this->getResults() as $c_ref_id => $obj_id) {
         $ilBench->start('Lucene', '2100_res');
         foreach ($this->getAllReferences($c_ref_id) as $ref_id) {
             $ilBench->start('Lucene', '2120_tree');
             if (!$tree->isInTree($ref_id)) {
                 continue;
             }
             $ilBench->stop('Lucene', '2120_tree');
             $obj_type = ilObject::_lookupType($obj_id);
             $set[] = array("ref_id" => $ref_id, "obj_id" => $obj_id, "title" => $this->lookupTitle($obj_id, 0), "title_sort" => ilObject::_lookupTitle($obj_id), "description" => $this->lookupDescription($obj_id, 0), "type" => $obj_type, "relevance" => $this->getRelevance($obj_id), "s_relevance" => sprintf("%03d", $this->getRelevance($obj_id)));
             $preloader->addItem($obj_id, $obj_type, $ref_id);
         }
         $ilBench->stop('Lucene', '2100_res');
     }
     if (!count($set)) {
         return false;
     }
     $preloader->preload();
     unset($preloader);
     $ilBench->start('Lucene', '2900_tb');
     include_once "./Services/Search/classes/class.ilSearchResultTableGUI.php";
     $result_table = new ilSearchResultTableGUI($this->container, "showSavedResults", $this);
     $result_table->setCustomPreviousNext($this->prev, $this->next);
     $result_table->setData($set);
     $this->thtml = $result_table->getHTML();
     $ilBench->stop('Lucene', '2900_tb');
     return true;
 }
Esempio n. 4
0
 /**
  * Get subitems of container
  * 
  * @param bool administration panel enabled
  * @param bool side blocks enabled
  *
  * @return	array
  */
 function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false, $a_get_single = 0)
 {
     global $objDefinition, $ilBench, $tree, $ilObjDataCache, $ilUser, $rbacsystem, $ilSetting;
     // Caching
     if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]) && !$a_get_single) {
         return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
     }
     $type_grps = $this->getGroupedObjTypes();
     $objects = $tree->getChilds($this->getRefId(), "title");
     // using long descriptions?
     $short_desc = $ilSetting->get("rep_shorten_description");
     $short_desc_max_length = $ilSetting->get("rep_shorten_description_length");
     if (!$short_desc || $short_desc_max_length != ilObject::TITLE_LENGTH) {
         // using (part of) shortened description
         if ($short_desc && $short_desc_max_length && $short_desc_max_length < ilObject::TITLE_LENGTH) {
             foreach ($objects as $key => $object) {
                 $objects[$key]["description"] = ilUtil::shortenText($object["description"], $short_desc_max_length, true);
             }
         } else {
             $obj_ids = array();
             foreach ($objects as $key => $object) {
                 $obj_ids[] = $object["obj_id"];
             }
             if (sizeof($obj_ids)) {
                 $long_desc = ilObject::getLongDescriptions($obj_ids);
                 foreach ($objects as $key => $object) {
                     // #12166 - keep translation, ignore long description
                     if ($ilObjDataCache->isTranslatedDescription($object["obj_id"])) {
                         $long_desc[$object["obj_id"]] = $object["description"];
                     }
                     if ($short_desc && $short_desc_max_length) {
                         $long_desc[$object["obj_id"]] = ilUtil::shortenText($long_desc[$object["obj_id"]], $short_desc_max_length, true);
                     }
                     $objects[$key]["description"] = $long_desc[$object["obj_id"]];
                 }
             }
         }
     }
     $found = false;
     $all_ref_ids = array();
     if (!self::$data_preloaded) {
         include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php";
         $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_REPOSITORY);
     }
     include_once 'Services/Container/classes/class.ilContainerSorting.php';
     $sort = ilContainerSorting::_getInstance($this->getId());
     // TODO: check this
     // get items attached to a session
     include_once './Modules/Session/classes/class.ilEventItems.php';
     $event_items = ilEventItems::_getItemsOfContainer($this->getRefId());
     foreach ($objects as $key => $object) {
         if ($a_get_single > 0 && $object["child"] != $a_get_single) {
             continue;
         }
         // hide object types in devmode
         if ($objDefinition->getDevMode($object["type"]) || $object["type"] == "adm" || $object["type"] == "rolf") {
             continue;
         }
         // remove inactive plugins
         if ($objDefinition->isInactivePlugin($object["type"])) {
             continue;
         }
         // BEGIN WebDAV: Don't display hidden Files, Folders and Categories
         if (in_array($object['type'], array('file', 'fold', 'cat'))) {
             include_once 'Modules/File/classes/class.ilObjFileAccess.php';
             if (ilObjFileAccess::_isFileHidden($object['title'])) {
                 $this->setHiddenFilesFound(true);
                 if (!$a_admin_panel_enabled) {
                     continue;
                 }
             }
         }
         // END WebDAV: Don't display hidden Files, Folders and Categories
         // including event items!
         if (!self::$data_preloaded) {
             $preloader->addItem($object["obj_id"], $object["type"], $object["child"]);
         }
         // filter out items that are attached to an event
         if (in_array($object['ref_id'], $event_items)) {
             continue;
         }
         // filter side block items
         if (!$a_include_side_block && $objDefinition->isSideBlock($object['type'])) {
             continue;
         }
         $all_ref_ids[] = $object["child"];
     }
     // data preloader
     if (!self::$data_preloaded) {
         $preloader->preload();
         unset($preloader);
         self::$data_preloaded = true;
     }
     foreach ($objects as $key => $object) {
         // see above, objects were filtered
         if (!in_array($object["child"], $all_ref_ids)) {
             continue;
         }
         // group object type groups together (e.g. learning resources)
         $type = $objDefinition->getGroupOfObj($object["type"]);
         if ($type == "") {
             $type = $object["type"];
         }
         // this will add activation properties
         $this->addAdditionalSubItemInformation($object);
         $this->items[$type][$key] = $object;
         $this->items["_all"][$key] = $object;
         if ($object["type"] != "sess") {
             $this->items["_non_sess"][$key] = $object;
         }
     }
     $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block] = $sort->sortItems($this->items);
     return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block];
 }
 protected function getItems()
 {
     global $ilUser, $ilObjDataCache, $ilAccess;
     include_once './Modules/Course/classes/class.ilCourseLMHistory.php';
     include_once './Services/Link/classes/class.ilLink.php';
     $lm_continue = new ilCourseLMHistory($this->start_object->getRefId(), $ilUser->getId());
     $continue_data = $lm_continue->getLMHistory();
     $items = array();
     $counter = 0;
     foreach ($this->start_object->getStartObjects() as $start) {
         $obj_id = $ilObjDataCache->lookupObjId($start['item_ref_id']);
         $ref_id = $start['item_ref_id'];
         $type = $ilObjDataCache->lookupType($obj_id);
         if (!$ilAccess->checkAccess("visible", "", $ref_id)) {
             continue;
         }
         // start object status
         if ($this->start_object->isFullfilled($ilUser->getId(), $ref_id)) {
             $accomplished = 'accomplished';
         } else {
             $accomplished = 'not_accomplished';
         }
         // add/remove desktop
         $actions = array();
         if ((bool) $this->enable_desktop) {
             // add to desktop link
             if (!$ilUser->isDesktopItem($ref_id, $type)) {
                 if ($ilAccess->checkAccess('read', '', $ref_id)) {
                     $this->ctrl->setParameter($this->getParentObject(), 'item_ref_id', $ref_id);
                     $this->ctrl->setParameter($this->getParentObject(), 'item_id', $ref_id);
                     $this->ctrl->setParameter($this->getParentObject(), 'type', $type);
                     $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'addToDesk');
                     $actions[$url] = $this->lng->txt("to_desktop");
                 }
             } else {
                 $this->ctrl->setParameter($this->getParentObject(), 'item_ref_id', $ref_id);
                 $this->ctrl->setParameter($this->getParentObject(), 'item_id', $ref_id);
                 $this->ctrl->setParameter($this->getParentObject(), 'type', $type);
                 $url = $this->ctrl->getLinkTarget($this->getParentObject(), 'removeFromDesk');
                 $actions[$url] = $this->lng->txt("unsubscribe");
             }
         }
         $default_params = null;
         if ($type == "tst") {
             $default_params["crs_show_result"] = $ref_id;
         }
         /* continue is currently inactive
         			if(isset($continue_data[$ref_id]))
         			{
         				// :TODO: should "continue" be default or 2nd link/action?
         				// $this->lng->txt('continue_work') 
         				$default_params["obj_id"] = $continue_data[$ref_id]['lm_page_id'];
         			}
         			*/
         if ($accomplished == 'accomplished') {
             $icon = ilUtil::getImagePath("icon_ok.svg");
         } else {
             $icon = ilUtil::getImagePath("icon_not_ok.svg");
         }
         $items[] = array("nr" => ++$counter, "obj_id" => $obj_id, "ref_id" => $ref_id, "type" => $type, "append_default" => $default_params, "title" => $ilObjDataCache->lookupTitle($obj_id), "description" => $ilObjDataCache->lookupDescription($obj_id), "status" => $this->lng->txt('crs_objective_' . $accomplished), "status_img" => $icon, "actions" => $actions);
     }
     include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php";
     $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_REPOSITORY);
     foreach ($items as $item) {
         $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
     }
     $preloader->preload();
     unset($preloader);
     reset($items);
     $this->setData($items);
 }
 /**
  * get selected items per type
  */
 function getSelectedItemsPerLocation(&$tpl)
 {
     global $ilUser, $rbacsystem, $objDefinition, $ilBench, $ilSetting, $ilObjDataCache, $tree;
     $output = false;
     $items = $ilUser->getDesktopItems();
     $item_html = array();
     $cur_obj_type = "";
     if (count($items) > 0) {
         include_once "./Services/Object/classes/class.ilObjectListGUIPreloader.php";
         $preloader = new ilObjectListGUIPreloader(ilObjectListGUI::CONTEXT_PERSONAL_DESKTOP);
         foreach ($items as $item) {
             $preloader->addItem($item["obj_id"], $item["type"], $item["ref_id"]);
         }
         $preloader->preload();
         unset($preloader);
         reset($items);
         foreach ($items as $item) {
             //echo "1";
             // get list gui class for each object type
             if ($cur_obj_type != $item["type"]) {
                 $item_list_gui =& $this->getItemListGUI($item["type"]);
                 if (!$item_list_gui) {
                     continue;
                 }
                 // notes, comment currently do not work properly
                 $item_list_gui->enableNotes(false);
                 $item_list_gui->enableComments(false);
                 $item_list_gui->enableTags(false);
                 $item_list_gui->enableIcon(true);
                 $item_list_gui->enableDelete(false);
                 $item_list_gui->enableCut(false);
                 $item_list_gui->enableCopy(false);
                 $item_list_gui->enablePayment(false);
                 $item_list_gui->enableLink(false);
                 $item_list_gui->enableInfoScreen(true);
                 if ($this->getCurrentDetailLevel() < 3 || $this->manage) {
                     //echo "3";
                     $item_list_gui->enableDescription(false);
                     $item_list_gui->enableProperties(false);
                     $item_list_gui->enablePreconditions(false);
                 }
                 if ($this->getCurrentDetailLevel() < 2 || $this->manage) {
                     $item_list_gui->enableCommands(true, true);
                 }
             }
             // render item row
             $ilBench->start("ilPersonalDesktopGUI", "getListHTML");
             ilObjectActivation::addListGUIActivationProperty($item_list_gui, $item);
             $item_list_gui->setContainerObject($this);
             $html = $item_list_gui->getListItemHTML($item["ref_id"], $item["obj_id"], $item["title"], $item["description"]);
             $ilBench->stop("ilPersonalDesktopGUI", "getListHTML");
             if ($html != "") {
                 $item_html[] = array("html" => $html, "item_ref_id" => $item["ref_id"], "item_obj_id" => $item["obj_id"], "parent_ref" => $item["parent_ref"], "type" => $item["type"], 'item_icon_image_type' => $item_list_gui->getIconImageType());
             }
         }
         // output block for resource type
         if (count($item_html) > 0) {
             $cur_parent_ref = 0;
             // content row
             foreach ($item_html as $item) {
                 // add a parent header row for each new parent
                 if ($cur_parent_ref != $item["parent_ref"]) {
                     if ($ilSetting->get("icon_position_in_lists") == "item_rows") {
                         $this->addParentRow($tpl, $item["parent_ref"], false);
                     } else {
                         $this->addParentRow($tpl, $item["parent_ref"]);
                     }
                     $this->resetRowType();
                     $cur_parent_ref = $item["parent_ref"];
                 }
                 $this->addStandardRow($tpl, $item["html"], $item["item_ref_id"], $item["item_obj_id"], $item['item_icon_image_type'], "th_" . $cur_parent_ref);
                 $output = true;
             }
         }
     }
     return $output;
 }