/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd, $a_tree, $a_node_id, $a_tax) { global $ilCtrl, $lng, $ilAccess, $lng; if ($a_node_id == "") { $a_node_id = $a_tree->readRootId(); } $this->tree = $a_tree; $this->tax = $a_tax; $this->node_id = $a_node_id; parent::__construct($a_parent_obj, $a_parent_cmd); $childs = $this->tree->getChildsByTypeFilter($a_node_id, array("taxn")); if ($a_tax->getSortingMode() == ilObjTaxonomy::SORT_MANUAL) { $childs = ilUtil::sortArray($childs, "order_nr", "asc", false); } else { $childs = ilUtil::sortArray($childs, "title", "asc", false); } $this->setData($childs); $this->setTitle($lng->txt("tax_nodes")); $this->addColumn($this->lng->txt(""), "", "1px", true); if ($this->tax->getSortingMode() == ilObjTaxonomy::SORT_MANUAL) { $this->addColumn($this->lng->txt("tax_order"), "order_nr", "1px"); $this->setDefaultOrderField("order_nr"); $this->setDefaultOrderDirection("asc"); } $this->addColumn($this->lng->txt("title")); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->setRowTemplate("tpl.tax_row.html", "Services/Taxonomy"); $this->addMultiCommand("deleteItems", $lng->txt("delete")); $this->addMultiCommand("moveItems", $lng->txt("move")); $this->addCommandButton("saveSettingsAndSorting", $lng->txt("save")); }
/** * Constructor */ function __construct($a_parent_obj, $a_parent_cmd, $a_obj_id, $a_mode = self::MODE_SCAT) { global $ilCtrl, $lng, $ilAccess, $lng; $ilCtrl->setParameter($a_parent_obj, "tmpmode", $a_mode); $this->mode = $a_mode; include_once "./Services/Skill/classes/class.ilSkillTree.php"; $this->skill_tree = new ilSkillTree(); $this->obj_id = $a_obj_id; parent::__construct($a_parent_obj, $a_parent_cmd); if ($this->mode == self::MODE_SCAT) { $childs = $this->skill_tree->getChildsByTypeFilter($a_obj_id, array("skrt", "skll", "scat", "sktr")); $childs = ilUtil::sortArray($childs, "order_nr", "asc", true); $this->setData($childs); } else { if ($this->mode == self::MODE_SCTP) { $childs = $this->skill_tree->getChildsByTypeFilter($a_obj_id, array("skrt", "sktp", "sctp")); $childs = ilUtil::sortArray($childs, "order_nr", "asc", true); $this->setData($childs); } } if ($this->obj_id != $this->skill_tree->readRootId()) { // $this->setTitle(ilSkillTreeNode::_lookupTitle($this->obj_id)); } $this->setTitle($lng->txt("skmg_items")); $this->addColumn($this->lng->txt(""), "", "1px", true); $this->addColumn($this->lng->txt("type"), "", "1px"); $this->addColumn($this->lng->txt("skmg_order"), "", "1px"); $this->addColumn($this->lng->txt("title")); $this->setFormAction($ilCtrl->getFormAction($a_parent_obj)); $this->setRowTemplate("tpl.skill_cat_row.html", "Services/Skill"); $this->addMultiCommand("deleteNodes", $lng->txt("delete")); $this->addMultiCommand("cutItems", $lng->txt("cut")); $this->addMultiCommand("copyItems", $lng->txt("copy")); $this->addCommandButton("saveOrder", $lng->txt("skmg_save_order")); }
/** * Get items from user clipboard */ function getItems() { global $ilUser; $objs = $ilUser->getClipboardObjects("mob"); $objs2 = $ilUser->getClipboardObjects("incl"); $objs = array_merge($objs, $objs2); $objs = ilUtil::sortArray($objs, $_GET["sort_by"], $_GET["sort_order"]); $this->setData($objs); }
/** * Get last export file information * * @param int $a_obj_id object id * @param string $a_type export type ("xml", "html", ...), default "xml" * @param string $a_obj_type object type (optional, if not given, type is looked up) */ static function _getLastExportFileInformation($a_obj_id, $a_type = "", $a_obj_type = "") { $files = ilExport::_getExportFiles($a_obj_id, $a_type, $a_obj_type); if (is_array($files)) { $files = ilUtil::sortArray($files, "timestamp", "desc"); return $files[0]; } return false; }
/** * Get items of current folder */ function getItems() { $std_alias_item = new ilMediaAliasItem($this->pc_media_object->dom, $this->pc_media_object->hier_id, "Standard", $this->pc_media_object->getPcId(), $this->parent_node_name); $areas = $std_alias_item->getMapAreas(); foreach ($areas as $k => $a) { $areas[$k]["title"] = $a["Link"]["Title"]; } $areas = ilUtil::sortArray($areas, "title", "asc", false, true); $this->setData($areas); }
/** * Get materials * * @param * @return */ function getMaterials() { $materials = array(); $items = $this->item_group_items->getAssignableItems(); foreach ($items as $item) { $item["sorthash"] = (int) (!in_array($item['ref_id'], $this->items)) . $item["title"]; $materials[] = $item; } $materials = ilUtil::sortArray($materials, "sorthash", "asc"); $this->setData($materials); }
/** * read style folder data */ function read() { global $ilDB; parent::read(); // get styles of style folder $q = "SELECT * FROM style_folder_styles, style_data WHERE folder_id = " . $ilDB->quote($this->getId(), "integer") . " AND style_id = style_data.id"; $style_set = $ilDB->query($q); $this->styles = array(); while ($style_rec = $ilDB->fetchAssoc($style_set)) { $this->styles[$style_rec["style_id"]] = array("id" => $style_rec["style_id"], "title" => ilObject::_lookupTitle($style_rec["style_id"]), "category" => $style_rec["category"]); } $this->styles = ilUtil::sortArray($this->styles, "title", "asc", false, true); }
/** * Get pages for list. */ function getGroups() { global $lng; $data = array(); $subitems = ilObjRepositorySettings::getNewItemGroupSubItems(); if ($subitems[0]) { ilUtil::sendInfo(sprintf($lng->txt("rep_new_item_group_unassigned_subitems"), sizeof($subitems[0]))); unset($subitems[0]); } foreach (ilObjRepositorySettings::getNewItemGroups() as $item) { $data[] = array("id" => $item["id"], "pos" => $item["pos"], "title" => $item["title"], "type" => $item["type"], "subitems" => sizeof($subitems[$item["id"]])); } $data = ilUtil::sortArray($data, "pos", "asc", true); $this->setData($data); }
/** * Get data and put it into an array */ function getDataFromDb() { global $tree, $objDefinition; $nodes = $tree->getSubTree($tree->getNodeData($this->parent_ref_id)); $materials = array(); foreach ($nodes as $node) { // No side blocks here if ($node['child'] == $this->parent_ref_id || $objDefinition->isSideBlock($node['type']) || in_array($node['type'], array('sess', 'itgr', 'rolf'))) { continue; } if ($node['type'] == 'rolf') { continue; } $node["sorthash"] = (int) (!in_array($node['ref_id'], $this->getMaterialItems())) . $node["title"]; $materials[] = $node; } $materials = ilUtil::sortArray($materials, "sorthash", "ASC"); $this->setData($materials); }
/** * Render Page Embedded Blocks */ function renderPageEmbeddedBlocks() { global $lng; // item groups if (is_array($this->embedded_block["itgr"])) { $item_groups = array(); if (is_array($this->items["itgr"])) { foreach ($this->items["itgr"] as $ig) { $item_groups[$ig["ref_id"]] = $ig; } } foreach ($this->embedded_block["itgr"] as $ref_id) { if (isset($item_groups[$ref_id])) { $this->renderItemGroup($item_groups[$ref_id]); } } } // type specific blocks if (is_array($this->embedded_block["type"])) { foreach ($this->embedded_block["type"] as $k => $type) { if (is_array($this->items[$type]) && $this->renderer->addTypeBlock($type)) { // :TODO: obsolete? if ($type == 'sess') { $this->items['sess'] = ilUtil::sortArray($this->items['sess'], 'start', 'ASC', true, true); } $position = 1; foreach ($this->items[$type] as $k => $item_data) { if (!$this->renderer->hasItem($item_data["child"])) { $html = $this->renderItem($item_data, $position++); if ($html != "") { $this->renderer->addItemToBlock($type, $item_data["type"], $item_data["child"], $html); } } } } } } }
/** * Position and order sort order for new object without position in manual sorting type * * @param $items * @return array */ private function sortOrderDefault($items) { $no_position = array(); foreach ($items as $key => $item) { if ($item["position"] == self::ORDER_DEFAULT) { $no_position[] = array("key" => $key, "title" => $item["title"], "create_date" => $item["create_date"], "start" => $item["start"]); } } if (!count($no_position)) { return $items; } switch ($this->getSortingSettings()->getSortNewItemsOrder()) { case ilContainer::SORT_NEW_ITEMS_ORDER_TITLE: $no_position = ilUtil::sortArray((array) $no_position, 'title', $this->getSortingSettings()->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? 'asc' : 'desc', TRUE); break; case ilContainer::SORT_NEW_ITEMS_ORDER_CREATION: $no_position = ilUtil::sortArray((array) $no_position, 'create_date', $this->getSortingSettings()->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? 'asc' : 'desc', TRUE); break; case ilContainer::SORT_NEW_ITEMS_ORDER_ACTIVATION: $no_position = ilUtil::sortArray((array) $no_position, 'start', $this->getSortingSettings()->getSortDirection() == ilContainer::SORT_DIRECTION_ASC ? 'asc' : 'desc', TRUE); } $count = $this->getSortingSettings()->getSortNewItemsPosition() == ilContainer::SORT_NEW_ITEMS_POSITION_TOP ? 0 : 900000; foreach ($no_position as $values) { $items[$values["key"]]["position"] = $count; $count++; } return $items; }
/** * Export the Data * * @param type $format * @param type $send */ public function exportData($format, $send = false) { if ($this->dataExists()) { // #9640: sort if (!$this->getExternalSorting() && $this->enabled["sort"]) { $this->determineOffsetAndOrder(true); $this->row_data = ilUtil::sortArray($this->row_data, $this->getOrderField(), $this->getOrderDirection(), $this->numericOrdering($this->getOrderField())); } $filename = "export"; switch ($format) { default: case self::EXPORT_EXCEL: include_once "./Services/Excel/classes/class.ilExcelUtils.php"; include_once "./Services/Excel/classes/class.ilExcelWriterAdapter.php"; $adapter = new ilExcelWriterAdapter($filename . ".xls", $send); $workbook = $adapter->getWorkbook(); $worksheet = $workbook->addWorksheet(); $row = 0; ob_start(); $this->fillMetaExcel($worksheet, $row); $this->fillHeaderExcel($worksheet, $row); foreach ($this->row_data as $set) { $row++; $this->fillRowExcel($worksheet, $row, $set); } ob_end_clean(); $workbook->close(); break; case self::EXPORT_CSV: include_once "./Services/Utilities/classes/class.ilCSVWriter.php"; $csv = new ilCSVWriter(); $csv->setSeparator(";"); ob_start(); $this->fillMetaCSV($csv); $this->fillHeaderCSV($csv); foreach ($this->row_data as $set) { $this->fillRowCSV($csv, $set); } ob_end_clean(); if ($send) { $filename .= ".csv"; header("Content-type: text/comma-separated-values"); header("Content-Disposition: attachment; filename=\"" . $filename . "\""); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0,pre-check=0"); header("Pragma: public"); echo $csv->getCSVString(); } else { file_put_contents($filename, $csv->getCSVString()); } break; case self::EXPORT_PDF: include_once "Customizing/global/plugins/Services/Repository/RepositoryObject/RoomSharing/classes/appointments/bookings/class.ilRoomSharingBookingsExportTableGUI.php"; $exportTable = new ilRoomSharingBookingsExportTableGUI($this->parent_obj, 'showBookings', $this->ref_id); include_once "Customizing/global/plugins/Services/Repository/RepositoryObject/RoomSharing/classes/export/class.ilRoomSharingPDFCreator.php"; $staff = $exportTable->getTableHTML(); ilRoomSharingPDFCreator::generatePDF($exportTable->getTableHTML(), 'D', 'file.pdf'); break; } if ($send) { exit; } } }
public function sortResult($result) { if ($this->sort_direction != '' && $this->sort_field != '') { switch ($this->sort_field) { case 'price': $numeric_sort = true; break; default: $numeric_sort = false; break; } $result = ilUtil::sortArray($result, $this->sort_field, $this->sort_direction, $numeric_sort); } return $result; }
/** * Render workspace toolbar (folder navigation, add subobject) */ protected function renderToolbar() { global $lng, $ilCtrl, $objDefinition, $tpl, $ilSetting; $settings_map = array("blog" => "blogs", "file" => "files", "tstv" => "certificates", "excv" => "certificates", "webr" => "links"); $root = $this->tree->getNodeData($this->node_id); $subtypes = $objDefinition->getCreatableSubObjects($root["type"], ilObjectDefinition::MODE_WORKSPACE); if ($subtypes) { // :TODO: permission checks? $subobj = array(); foreach (array_keys($subtypes) as $type) { if (isset($settings_map[$type]) && $ilSetting->get("disable_wsp_" . $settings_map[$type])) { continue; } $class = $objDefinition->getClassName($type); $subobj[] = array("value" => $type, "title" => $lng->txt("wsp_type_" . $type), "img" => ilObject::_getIcon("", "tiny", $type), "alt" => $lng->txt("wsp_type_" . $type)); } $subobj = ilUtil::sortArray($subobj, "title", 1); $lng->loadLanguageModule("cntr"); $tpl->setCreationSelector($ilCtrl->getFormAction($this), $subobj, "create", $lng->txt("add")); } }
/** * Get news aggregation for child objects (e.g. for categories) */ function getAggregatedChildNewsData($a_ref_id, $a_only_public = false, $a_time_period = 0, $a_prevent_aggregation = false, $a_starting_date = "", $a_no_auto_generated = false) { global $tree, $ilAccess; // get news of parent object $data = $this->getNewsForRefId($a_ref_id, $a_only_public, true, $a_time_period, true, false, false, $a_no_auto_generated); foreach ($data as $k => $v) { $data[$k]["ref_id"] = $a_ref_id; } // get childs $nodes = $tree->getChilds($a_ref_id); // no check, for which of the objects any news are available $obj_ids = array(); foreach ($nodes as $node) { $obj_ids[] = $node["obj_id"]; } $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date); //$news_obj_ids = $obj_ids; // get news for all subtree nodes $contexts = array(); foreach ($nodes as $node) { // only go on, if news are available if (!in_array($node["obj_id"], $news_obj_ids)) { continue; } if (!$a_only_public && !$ilAccess->checkAccess("read", "", $node["child"])) { continue; } $ref_id[$node["obj_id"]] = $node["child"]; $contexts[] = array("obj_id" => $node["obj_id"], "obj_type" => $node["type"]); } $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period, $a_starting_date, $a_no_auto_generated); foreach ($news as $k => $v) { $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]]; } $data = ilNewsItem::mergeNews($data, $news); // sort and return $data = ilUtil::sortArray($data, "creation_date", "desc", false, true); if (!$a_prevent_aggregation) { $data = $this->aggregateFiles($data, $a_ref_id); } return $data; }
/** * Get an array of course material ids that can be assigned to learning objectives * No tst, fold and grp. * * @access public * @static * * @param int obj id of course * @return array data of course materials */ public static function _getAssignableMaterials($a_container_id) { global $tree, $ilDB; $all_materials = $tree->getSubTree($tree->getNodeData($a_container_id), true); $all_materials = ilUtil::sortArray($all_materials, 'title', 'asc'); // Filter foreach ($all_materials as $material) { switch ($material['type']) { case 'tst': if (ilLOSettings::getInstanceByObjId($a_container_id)->isObjectiveTest($material['child'])) { continue; } else { $assignable[] = $material; } break; case 'crs': case 'rolf': case 'itgr': continue; default: $assignable[] = $material; break; } } return $assignable ? $assignable : array(); }
/** * Determine which blocks to show. */ function determineBlocks() { global $ilUser, $ilCtrl, $ilSetting; include_once "./Services/Block/classes/class.ilBlockSetting.php"; $this->blocks[IL_COL_LEFT] = array(); $this->blocks[IL_COL_RIGHT] = array(); $this->blocks[IL_COL_CENTER] = array(); $user_id = $this->getColType() == "pd" ? $ilUser->getId() : 0; $def_nr = 1000; if (is_array($this->default_blocks[$this->getColType()])) { foreach ($this->default_blocks[$this->getColType()] as $class => $def_side) { $type = self::$block_types[$class]; if ($this->isGloballyActivated($type)) { $nr = ilBlockSetting::_lookupNr($type, $user_id); if ($nr === false) { $nr = $def_nr++; } // extra handling for system messages, feedback block and news if ($type == "news") { $nr = -15; } if ($type == "cal") { $nr = -8; } if ($type == "pdsysmess") { // $nr = -15; } if ($type == "pdfeedb") { $nr = -10; } $side = ilBlockSetting::_lookupSide($type, $user_id); if ($side === false) { $side = $def_side; } $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => 0, "custom" => false); } } } if (!$this->getRepositoryMode()) { include_once "./Services/Block/classes/class.ilCustomBlock.php"; $costum_block = new ilCustomBlock(); $costum_block->setContextObjId($ilCtrl->getContextObjId()); $costum_block->setContextObjType($ilCtrl->getContextObjType()); $c_blocks = $costum_block->queryBlocksForContext(); foreach ($c_blocks as $c_block) { $type = $c_block["type"]; if ($this->isGloballyActivated($type)) { $class = array_search($type, self::$block_types); $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]); if ($nr === false) { $nr = $def_nr++; } $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]); if ($side === false) { $side = IL_COL_RIGHT; } $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => $c_block["id"], "custom" => true); } } } else { include_once "./Services/Block/classes/class.ilCustomBlock.php"; $rep_items = $this->getRepositoryItems(); foreach ($this->rep_block_types as $block_type) { if ($this->isGloballyActivated($block_type)) { if (!is_array($rep_items[$block_type])) { continue; } foreach ($rep_items[$block_type] as $item) { $costum_block = new ilCustomBlock(); $costum_block->setContextObjId($item["obj_id"]); $costum_block->setContextObjType($block_type); $c_blocks = $costum_block->queryBlocksForContext(); $c_block = $c_blocks[0]; $type = $block_type; $class = array_search($type, self::$block_types); $nr = ilBlockSetting::_lookupNr($type, $user_id, $c_block["id"]); if ($nr === false) { $nr = $def_nr++; } $side = ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]); if ($side === false) { $side = IL_COL_RIGHT; } $this->blocks[$side][] = array("nr" => $nr, "class" => $class, "type" => $type, "id" => $c_block["id"], "custom" => true, "ref_id" => $item["ref_id"]); } } } } $this->blocks[IL_COL_LEFT] = ilUtil::sortArray($this->blocks[IL_COL_LEFT], "nr", "asc", true); $this->blocks[IL_COL_RIGHT] = ilUtil::sortArray($this->blocks[IL_COL_RIGHT], "nr", "asc", true); $this->blocks[IL_COL_CENTER] = ilUtil::sortArray($this->blocks[IL_COL_CENTER], "nr", "asc", true); }
public function getTableHTML() { global $lng, $ilCtrl, $ilUser; $this->prepareOutput(); if (is_object($ilCtrl) && $this->getId() == "") { $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter()); } if (!$this->getPrintMode()) { // set form action if ($this->form_action != "" && $this->getOpenFormTag()) { $hash = ""; if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) { $hash = "#" . $this->getTopAnchor(); } $this->tpl->setCurrentBlock("tbl_form_header"); //$this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash); //$this->tpl->setVariable("FORMNAME", $this->getFormName()); $this->tpl->parseCurrentBlock(); } if ($this->form_action != "" && $this->getCloseFormTag()) { $this->tpl->touchBlock("tbl_form_footer"); } } if (!$this->enabled['content']) { return $this->render(); } $this->determineOffsetAndOrder(); $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next")); $data = $this->getData(); if ($this->dataExists()) { // sort if (!$this->getExternalSorting() && $this->enabled["sort"]) { $data = ilUtil::sortArray($data, $this->getOrderField(), $this->getOrderDirection(), $this->numericOrdering($this->getOrderField())); } } // fill rows if ($this->dataExists()) { if ($this->getPrintMode()) { ilDatePresentation::setUseRelativeDates(false); } $this->tpl->addBlockFile("TBL_CONTENT", "tbl_content", $this->row_template, $this->row_template_dir); foreach ($data as $set) { $this->tpl->setCurrentBlock("tbl_content"); $this->css_row = $this->css_row != "tblrow1" ? "tblrow1" : "tblrow2"; $this->tpl->setVariable("CSS_ROW", $this->css_row); $this->fillRow($set); $this->tpl->setCurrentBlock("tbl_content"); $this->tpl->parseCurrentBlock(); } } else { // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008) $no_items_text = trim($this->getNoEntriesText()) != '' ? $this->getNoEntriesText() : $lng->txt("no_items"); $this->css_row = $this->css_row != "tblrow1" ? "tblrow1" : "tblrow2"; $this->tpl->setCurrentBlock("tbl_no_entries"); $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row); $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count); $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text)); $this->tpl->parseCurrentBlock(); } return $this->render(); }
/** * Get grouped repository object types */ static function getGroupedRepositoryObjectTypes($a_parent_obj_type) { global $ilDB, $ilPluginAdmin; $set = $ilDB->query("SELECT * FROM il_object_group"); $groups = array(); while ($gr_rec = $set->fetchRow(DB_FETCHMODE_ASSOC)) { $groups[$gr_rec["id"]] = $gr_rec; } if (!is_array($a_parent_obj_type)) { $set = $ilDB->queryF("SELECT il_object_def.* FROM il_object_def, il_object_subobj " . " WHERE NOT (system = 1) AND NOT (sideblock = 1) AND " . " parent = %s " . " AND subobj = id ", array("text"), array($a_parent_obj_type)); } else { $q = "SELECT DISTINCT (id) as sid, il_object_def.* FROM il_object_def, il_object_subobj " . " WHERE NOT (system = 1) AND NOT (sideblock = 1) AND " . $ilDB->in("parent", $a_parent_obj_type, false, "text") . " AND subobj = id "; $set = $ilDB->query($q); } $grouped_obj = array(); while ($rec = $ilDB->fetchAssoc($set)) { if ($rec["grp"] != "") { $grouped_obj[$rec["grp"]]["pos"] = (int) $groups[$rec["grp"]]["default_pres_pos"]; $grouped_obj[$rec["grp"]]["objs"][] = $rec["id"]; } else { $grouped_obj[$rec["id"]]["pos"] = (int) $rec["default_pres_pos"]; $grouped_obj[$rec["id"]]["objs"][] = $rec["id"]; } } //var_dump($grouped_obj); // now get objects from repository plugin $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "Repository", "robj"); foreach ($pl_names as $pl_name) { include_once "./Services/Component/classes/class.ilPlugin.php"; $pl_id = ilPlugin::lookupIdForName(IL_COMP_SERVICE, "Repository", "robj", $pl_name); if (!isset($grouped_obj[$pl_id])) { $grouped_obj[$pl_id] = array("pos" => "99992000", "objs" => array(0 => $pl_id)); } } //var_dump($grouped_obj); $ret = ilUtil::sortArray($grouped_obj, "pos", "asc", true, true); //var_dump($ret); return $ret; }
/** * Returns all available relations * * @access public */ function getAllRelations($short_as_key = false) { global $ilDB; // #7987 $custom_order = array("equal", "not_equal", "less", "less_or_equal", "more", "more_or_equal"); $custom_order = array_flip($custom_order); $result_array = array(); $result = $ilDB->query("SELECT * FROM svy_relation"); while ($row = $ilDB->fetchAssoc($result)) { if ($short_as_key) { $result_array[$row["shortname"]] = array("short" => $row["shortname"], "long" => $row["longname"], "id" => $row["relation_id"], "order" => $custom_order[$row["longname"]]); } else { $result_array[$row["relation_id"]] = array("short" => $row["shortname"], "long" => $row["longname"], "order" => $custom_order[$row["longname"]]); } } $result_array = ilUtil::sortArray($result_array, "order", "ASC", true, true); foreach ($result_array as $idx => $item) { unset($result_array[$idx]["order"]); } return $result_array; }
/** * Get recent pages changes for parent object. * * @param string $a_parent_type Parent Type * @param int $a_parent_id Parent ID * @param int $a_period Time Period */ static function getRecentChanges($a_parent_type, $a_parent_id, $a_period = 30, $a_lang = "") { global $ilDB; $and_lang = ""; if ($a_lang != "") { $and_lang = " AND lang = " . $ilDB->quote($a_lang, "text"); } $page_changes = array(); $limit_ts = date('Y-m-d H:i:s', time() - $a_period * 24 * 60 * 60); $q = "SELECT * FROM page_object " . " WHERE parent_id = " . $ilDB->quote($a_parent_id, "integer") . " AND parent_type = " . $ilDB->quote($a_parent_type, "text") . " AND last_change >= " . $ilDB->quote($limit_ts, "timestamp") . $and_lang; // " AND (TO_DAYS(now()) - TO_DAYS(last_change)) <= ".((int)$a_period); $set = $ilDB->query($q); while ($page = $ilDB->fetchAssoc($set)) { $page_changes[] = array("date" => $page["last_change"], "id" => $page["page_id"], "lang" => $page["lang"], "type" => "page", "user" => $page["last_change_user"]); } $and_str = ""; if ($a_period > 0) { $limit_ts = date('Y-m-d H:i:s', time() - $a_period * 24 * 60 * 60); $and_str = " AND hdate >= " . $ilDB->quote($limit_ts, "timestamp") . " "; } $q = "SELECT * FROM page_history " . " WHERE parent_id = " . $ilDB->quote($a_parent_id, "integer") . " AND parent_type = " . $ilDB->quote($a_parent_type, "text") . $and_str . $and_lang; $set = $ilDB->query($q); while ($page = $ilDB->fetchAssoc($set)) { $page_changes[] = array("date" => $page["hdate"], "id" => $page["page_id"], "lang" => $page["lang"], "type" => "hist", "nr" => $page["nr"], "user" => $page["user_id"]); } $page_changes = ilUtil::sortArray($page_changes, "date", "desc"); return $page_changes; }
/** * Show participants */ function showParticipants() { global $ilCtrl, $tpl, $ilTabs, $ilToolbar; $ilTabs->activateTab("submissions"); $this->addSubmissionSubTabs("participant"); // participant selection include_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/Ephorus/classes/class.ilEphAssignment.php"; $ass = ilEphAssignment::getAssignmentDataOfEphorus($this->object->getId()); $members = $this->object->members_obj->getMembers(); if (count($members) == 0) { ilUtil::sendInfo($this->txt("no_participants")); return; } $mems = array(); foreach ($members as $mem_id) { if (ilObject::_lookupType($mem_id) == "usr") { include_once "./Services/User/classes/class.ilObjUser.php"; $name = ilObjUser::_lookupName($mem_id); $mems[$mem_id] = $name; } } $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true); if ($_GET["part_id"] == "" && count($mems) > 0) { $_GET["part_id"] = key($mems); } reset($mems); if (count($mems) > 1) { $options = array(); foreach ($mems as $k => $m) { $options[$k] = $m["lastname"] . ", " . $m["firstname"] . " [" . $m["login"] . "]"; } include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $si = new ilSelectInputGUI($this->lng->txt(""), "part_id"); $si->setOptions($options); $si->setValue($_GET["part_id"]); $ilToolbar->addInputItem($si); $ilToolbar->setFormAction($ilCtrl->getFormAction($this)); $ilToolbar->addFormButton($this->lng->txt("rep_robj_xeph_select_part"), "selectParticipant"); } if (count($mems) > 0) { include_once "./Customizing/global/plugins/Services/Repository/RepositoryObject/Ephorus/classes/class.ilEphParticipantTableGUI.php"; $part_tab = new ilEphParticipantTableGUI($this, "showParticipants", $this->object, $_GET["part_id"]); $tpl->setContent($part_tab->getHTML()); } else { ilUtil::sendInfo($this->lng->txt("rep_robj_xeph_no_assignments_available")); } }
/** * Show didactic template types * @param ilPropertyFormGUI $form * @return ilPropertyFormGUI $form */ protected function initDidacticTemplate(ilPropertyFormGUI $form) { global $lng; $lng->loadLanguageModule('didactic'); $options = array(); $options['dtpl_0'] = array($this->lng->txt('didactic_default_type'), sprintf($this->lng->txt('didactic_default_type_info'), $this->lng->txt('objs_' . $this->type))); include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php'; $templates = ilDidacticTemplateSettings::getInstanceByObjectType($this->type)->getTemplates(); if ($templates) { foreach ($templates as $template) { $options["dtpl_" . $template->getId()] = array($template->getTitle(), $template->getDescription()); } } $this->addDidacticTemplateOptions($options); if (sizeof($options) > 1) { $type = new ilRadioGroupInputGUI($this->lng->txt('type'), 'didactic_type'); // workaround for containers in edit mode if (!$this->getCreationMode()) { include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php'; $type->setValue('dtpl_' . ilDidacticTemplateObjSettings::lookupTemplateId($this->object->getRefId())); } else { $type->setValue('dtpl_0'); } $form->addItem($type); ilUtil::sortArray($options, 0); foreach ($options as $id => $data) { $option = new ilRadioOption($data[0], $id, $data[1]); $type->addOption($option); } } return $form; }
/** * display edit form * * @access public */ function editObject() { global $rbacsystem, $rbacreview; if (!$rbacsystem->checkAccess("edit_permission", $_GET["ref_id"])) { $this->ilias->raiseError($this->lng->txt("permission_denied"), $this->ilias->error_obj->MESSAGE); } //prepare objectlist $this->data = array(); $this->data["data"] = array(); $this->data["ctrl"] = array(); $this->data["cols"] = array("type", "operation", "description", "status"); $ops_valid = $rbacreview->getOperationsOnType($this->obj_id); if ($ops_arr = ilRbacReview::_getOperationList('', $a_order, $a_direction)) { $options = array("e" => "enabled", "d" => "disabled"); foreach ($ops_arr as $key => $ops) { // BEGIN ROW if (in_array($ops["ops_id"], $ops_valid)) { $ops_status = 'e'; } else { $ops_status = 'd'; } $obj = $ops["ops_id"]; $ops_options = ilUtil::formSelect($ops_status, "id[{$obj}]", $options); //visible data part $this->data["data"][] = array("type" => "perm", "operation" => $ops["operation"], "description" => $ops["desc"], "status" => $ops_status, "status_html" => $ops_options, "obj_id" => $val["ops_id"]); } } //if typedata $this->maxcount = count($this->data["data"]); // sorting array $this->data["data"] = ilUtil::sortArray($this->data["data"], $_GET["sort_by"], $_GET["sort_order"]); // now compute control information foreach ($this->data["data"] as $key => $val) { $this->data["ctrl"][$key] = array("obj_id" => $val["obj_id"], "type" => $val["type"]); unset($this->data["data"][$key]["obj_id"]); $this->data["data"][$key]["status"] = $this->data["data"][$key]["status_html"]; unset($this->data["data"][$key]["status_html"]); } // build table include_once "./Services/Table/classes/class.ilTableGUI.php"; // load template for table $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html"); // load template for table content data $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html"); $num = 0; $obj_str = $this->call_by_reference ? "" : "&obj_id=" . $this->obj_id; $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=" . $this->ref_id . "{$obj_str}&cmd=save"); // create table $tbl = new ilTableGUI(); // title & header columns $tbl->setTitle($this->lng->txt("edit_operations") . " " . strtolower($this->lng->txt("of")) . " '" . $this->object->getTitle() . "'", "icon_" . $this->object->getType() . "_b.png", $this->lng->txt("obj_" . $this->object->getType())); $tbl->setHelp("tbl_help.php", "icon_help.png", $this->lng->txt("help")); foreach ($this->data["cols"] as $val) { $header_names[] = $this->lng->txt($val); } $tbl->setHeaderNames($header_names); $header_params = array("ref_id" => $this->ref_id, "obj_id" => $this->id, "cmd" => "edit"); $tbl->setHeaderVars($this->data["cols"], $header_params); // control $tbl->setOrderColumn($_GET["sort_by"]); $tbl->setOrderDirection($_GET["sort_order"]); $tbl->setLimit(0); $tbl->setOffset(0); $tbl->setMaxCount($this->maxcount); // SHOW VALID ACTIONS $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.png")); $this->tpl->setVariable("COLUMN_COUNTS", count($this->data["cols"])); // footer $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next")); //$tbl->disable("footer"); // render table $tbl->render(); if (is_array($this->data["data"][0])) { //table cell for ($i = 0; $i < count($this->data["data"]); $i++) { $data = $this->data["data"][$i]; $ctrl = $this->data["ctrl"][$i]; // color changing $css_row = ilUtil::switchColor($i + 1, "tblrow1", "tblrow2"); $this->tpl->setCurrentBlock("table_cell"); $this->tpl->setVariable("CELLSTYLE", "tblrow1"); $this->tpl->parseCurrentBlock(); foreach ($data as $key => $val) { $this->tpl->setCurrentBlock("text"); if ($key == "type") { $val = ilUtil::getImageTagByType($val, $this->tpl->tplPath); } $this->tpl->setVariable("TEXT_CONTENT", $val); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("table_cell"); $this->tpl->parseCurrentBlock(); } //foreach $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("save")); $this->tpl->setCurrentBlock("tbl_content"); $this->tpl->setVariable("CSS_ROW", $css_row); $this->tpl->parseCurrentBlock(); } //for } //if is_array }
/** * Insert new question form */ function insert($a_mode = "create") { global $ilUser, $lng, $ilCtrl; $this->setInsertTabs("new_question"); $this->displayValidationError(); // get all question types (@todo: we have to check, whether they are // suitable for self assessment or not) include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php"; $all_types = ilObjQuestionPool::_getSelfAssessmentQuestionTypes(); $options = array(); $all_types = ilUtil::sortArray($all_types, "order", "asc", true, true); foreach ($all_types as $k => $v) { $options[$v["type_tag"]] = $k; } // new table form (input of rows and columns) include_once "Services/Form/classes/class.ilPropertyFormGUI.php"; $this->form_gui = new ilPropertyFormGUI(); $this->form_gui->setFormAction($ilCtrl->getFormAction($this)); $this->form_gui->setTitle($lng->txt("cont_ed_insert_pcqst")); // Select Question Type $qtype_input = new ilSelectInputGUI($lng->txt("cont_question_type"), "q_type"); $qtype_input->setOptions($options); $qtype_input->setRequired(true); $this->form_gui->addItem($qtype_input); // additional content editor // assessment include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php"; if (ilObjAssessmentFolder::isAdditionalQuestionContentEditingModePageObjectEnabled()) { $ri = new ilRadioGroupInputGUI($this->lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode"); $ri->addOption(new ilRadioOption($this->lng->txt('tst_add_quest_cont_edit_mode_default'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT)); $ri->addOption(new ilRadioOption($this->lng->txt('tst_add_quest_cont_edit_mode_page_object'), assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT)); $ri->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT); $this->form_gui->addItem($ri, true); } else { $hi = new ilHiddenInputGUI("question_content_editing_type"); $hi->setValue(assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT); $this->form_gui->addItem($hi, true); } // Select Question Pool /* include_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php"); $qpools = ilObjQuestionPool::_getAvailableQuestionpools(false, false, false, true, false, "write"); if (count($qpools) > 0) { $pool_options = array(); foreach ($qpools as $key => $value) { $pool_options[$key] = $value["title"]; } $pool_input = new ilSelectInputGUI($lng->txt("cont_question_pool"), "qpool_ref_id"); $pool_input->setOptions($pool_options); $pool_input->setRequired(true); $this->form_gui->addItem($pool_input); } else { $pool_input = new ilTextInputGUI($lng->txt("cont_question_pool"), "qpool_title"); $pool_input->setRequired(true); $this->form_gui->addItem($pool_input); } */ if ($a_mode == "edit_empty") { $this->form_gui->addCommandButton("edit", $lng->txt("save")); } else { $this->form_gui->addCommandButton("create_pcqst", $lng->txt("save")); $this->form_gui->addCommandButton("cancelCreate", $lng->txt("cancel")); } $this->tpl->setContent($this->form_gui->getHTML()); }
/** * Show the edit screen */ function viewObject() { global $ilUser; $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.lang_edit_items.html", "Services/Language"); // set the language to compare with $compare = $this->getPar('compare', $this->lng->getDefaultLanguage()); // get the default values if the compare language is the same if ($compare == $this->object->key) { $compare_object = $this->object->getGlobalLanguageFile(); $compare_content = $compare_object->getAllValues(); $compare_comments = $compare_object->getAllComments(); $compare_note = " " . $this->lng->txt("language_default_entries"); } // get the remarks in database $remarks = $this->object->getAllRemarks(); // page translation mode: // - the table is filtered by a list of modules and topics // - all found entries are shown on the same page if ($this->_isPageTranslation()) { $offset = 0; $limit = 0; $modules = $this->getPar("page_modules", array()); $topics = $this->getPar("page_topics", array()); if (!isset($compare_content)) { $compare_content = ilObjLanguageExt::_getValues($compare, $modules, $topics); $compare_comments = ilObjLanguageExt::_getRemarks($compare); } $translations = ilObjLanguageExt::_getValues($this->object->key, $modules, $topics); } else { $offset = $this->getPar('offset', '0'); $limit = $ilUser->getPref("hits_per_page"); $filter_mode = $this->getPar('filter_mode', 'all'); $filter_pattern = $this->getPar('filter_pattern', ''); $filter_module = $this->getPar('filter_module', 'administration'); $filter_modules = $filter_module ? array($filter_module) : array(); if (!isset($compare_content)) { $compare_content = ilObjLanguageExt::_getValues($compare, $filter_modules); $compare_comments = ilObjLanguageExt::_getRemarks($compare); } switch ($filter_mode) { case "changed": $translations = $this->object->getChangedValues($filter_modules, $filter_pattern); break; case "added": //langmode only $translations = $this->object->getAddedValues($filter_modules, $filter_pattern); break; case "unchanged": $translations = $this->object->getUnchangedValues($filter_modules, $filter_pattern); break; case "commented": $translations = $this->object->getCommentedValues($filter_modules, $filter_pattern); break; case "dbremarks": $translations = $this->object->getAllValues($filter_modules, $filter_pattern); $translations = array_intersect_key($translations, $remarks); break; case "equal": $translations = $this->object->getAllValues($filter_modules, $filter_pattern); $translations = array_intersect_assoc($translations, $compare_content); break; case "different": $translations = $this->object->getAllValues($filter_modules, $filter_pattern); $translations = array_diff_assoc($translations, $compare_content); break; case "conflicts": $former_file = $this->object->getCustLangPath() . '/ilias_' . $this->object->key . '.lang'; if (!is_readable($former_file)) { ilUtil::sendFailure(sprintf($this->lng->txt("language_former_file_missing"), $former_file) . '<br />' . $this->lng->txt("language_former_file_description"), false); $translations = array(); break; } $global_file_obj = $this->object->getGlobalLanguageFile(); $former_file_obj = new ilLanguageFile($former_file); $former_file_obj->read(); $global_changes = array_diff_assoc($global_file_obj->getAllValues(), $former_file_obj->getAllValues()); if (!count($global_changes)) { ilUtil::sendInfo(sprintf($this->lng->txt("language_former_file_equal"), $former_file) . '<br />' . $this->lng->txt("language_former_file_description"), false); $translations = array(); break; } $translations = $this->object->getChangedValues($filter_modules, $filter_pattern); $translations = array_intersect_key($translations, $global_changes); break; case "all": default: $translations = $this->object->getAllValues($filter_modules, $filter_pattern); } // show the filter section $this->tpl->setCurrentBlock("filter"); // filter by language module $options = array(); $options[""] = $this->lng->txt("language_all_modules"); $modules = ilObjLanguageExt::_getModules($this->object->key); foreach ($modules as $mod) { $options[$mod] = $mod; } $this->tpl->setVariable("SELECT_MODULE", ilUtil::formSelect($filter_module, "filter_module", $options, false, true)); // filter by mode $options = array(); $options["all"] = $this->lng->txt("language_scope_global"); $options["changed"] = $this->lng->txt("language_scope_local"); if ($this->langmode) { $options["added"] = $this->lng->txt("language_scope_added"); } $options["unchanged"] = $this->lng->txt("language_scope_unchanged"); $options["equal"] = $this->lng->txt("language_scope_equal"); $options["different"] = $this->lng->txt("language_scope_different"); $options["commented"] = $this->lng->txt("language_scope_commented"); if ($this->langmode) { $options["dbremarks"] = $this->lng->txt("language_scope_dbremarks"); } $options["conflicts"] = $this->lng->txt("language_scope_conflicts"); $this->tpl->setVariable("SELECT_MODE", ilUtil::formSelect($filter_mode, "filter_mode", $options, false, true)); // filter by pattern $this->tpl->setVariable("PATTERN_NAME", "filter_pattern"); $this->tpl->setVariable("PATTERN_VALUE", ilUtil::prepareFormOutput($filter_pattern)); // and general filter variables $this->tpl->setVariable("FILTER_ACTION", $this->ctrl->getFormAction($this)); $this->tpl->setVariable("TXT_FILTER", $this->lng->txt("filter")); $this->tpl->setVariable("OFFSET_NAME", "offset"); $this->tpl->setVariable("OFFSET_VALUE", "0"); $this->tpl->setVariable("TXT_APPLY_FILTER", $this->lng->txt("apply_filter")); $this->tpl->setVariable("CMD_FILTER", "view"); $this->tpl->parseCurrentBlock(); } // show the compare section $this->tpl->setCurrentBlock("compare"); $this->tpl->setVariable("COMPARE_ACTION", $this->ctrl->getFormAction($this)); $this->tpl->setVariable("TXT_COMPARE", $this->lng->txt("language_compare")); $this->tpl->setVariable("TXT_CHANGE", $this->lng->txt("change")); $options = array(); $langlist = $this->lng->getInstalledLanguages(); foreach ($langlist as $lang_key) { $options[$lang_key] = $this->lng->txt("meta_l_" . $lang_key); } $this->tpl->setVariable("SELECT_COMPARE", ilUtil::formSelect($compare, "compare", $options, false, true, 1)); $this->tpl->setVariable("CMD_COMPARE", "view"); $this->tpl->parseCurrentBlock(); // prepare the dataset for the output table $sort_by = $this->getPar('sort_by', 'translation'); $sort_order = $this->getPar('sort_order', 'asc'); $list = array(); foreach ($translations as $name => $translation) { $keys = explode($this->lng->separator, $name); $data = array(); $data["module"] = $keys[0]; $data["topic"] = $keys[1]; $data["name"] = $name; $data["translation"] = $translation; $data["default"] = $compare_content[$name]; $data["default_comment"] = $compare_comments[$name]; $list[] = $data; } $list = ilUtil::sortArray($list, $sort_by, $sort_order); if ($limit > 0) { $list = array_slice($list, $offset, $limit); } // create and configure the table object include_once 'Services/Table/classes/class.ilTableGUI.php'; $tbl = new ilTableGUI(); $tbl->disable('title'); $tbl->setHeaderNames(array($this->lng->txt("module"), $this->lng->txt("identifier"), $this->lng->txt("meta_l_" . $this->object->key), $this->lng->txt("meta_l_" . $compare) . $compare_note)); $tbl->setHeaderVars(array("module", "topic", "translation", "default"), $this->ctrl->getParameterArray($this)); $tbl->setColumnWidth(array("10%", "20%", "40%", "30%")); $tbl->setOrderColumn($sort_by); $tbl->setOrderDirection($sort_order); $tbl->setLimit($limit); $tbl->setOffset($offset); $tbl->setMaxCount(count($translations)); // prepare the table template $tpl =& new ilTemplate("tpl.table.html", true, true); $tpl->setCurrentBlock("tbl_form_header"); $tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this)); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("tbl_action_btn"); $tpl->setVariable("BTN_NAME", 'save'); $tpl->setVariable("BTN_VALUE", $this->lng->txt('save')); $tpl->parseCurrentBlock(); $tpl->setCurrentBlock("tbl_action_row"); $tpl->setVariable("COLUMN_COUNTS", "4"); $tpl->parseCurrentBlock(); // render the table rows $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.lang_items_row.html", "Services/Language"); foreach ($list as $data) { if ($this->langmode) { $tpl->setCurrentBlock('comment'); $tpl->setVariable("COM_ID", ilUtil::prepareFormOutput($data["name"] . $this->lng->separator . "comment")); $tpl->setVariable("COM_NAME", ilUtil::prepareFormOutput($data["name"] . $this->lng->separator . "comment")); $tpl->setVariable("COM_VALUE", ilUtil::prepareFormOutput($remarks[$data["name"]])); $tpl->setVariable("COM_SIZE", $this->commentsize); $tpl->setVariable("COM_MAX", 250); $tpl->setVariable("TXT_COMMENT", $this->lng->txt('comment')); $tpl->parseCurrentBlock(); } else { $tpl->setCurrentBlock('hidden_comment'); $tpl->setVariable("COM_NAME", ilUtil::prepareFormOutput($data["name"] . $this->lng->separator . "comment")); $tpl->setVariable("COM_VALUE", ilUtil::prepareFormOutput($remarks[$data["name"]])); $tpl->parseCurrentBlock(); } $tpl->setCurrentBlock("row"); $tpl->setVariable("T_ROWS", ceil(strlen($data["translation"]) / $this->inputsize)); $tpl->setVariable("T_SIZE", $this->inputsize); $tpl->setVariable("T_NAME", ilUtil::prepareFormOutput($data["name"])); $tpl->setVariable("T_USER_VALUE", ilUtil::prepareFormOutput($data["translation"])); $tpl->setVariable("MODULE", ilUtil::prepareFormOutput($data["module"])); $tpl->setVariable("TOPIC", ilUtil::prepareFormOutput($data["topic"])); $tpl->setVariable("DEFAULT_VALUE", ilUtil::prepareFormOutput($data["default"])); $tpl->setVariable("COMMENT", ilUtil::prepareFormOutput($data["default_comment"])); $tpl->parseCurrentBlock(); } // render and show the table $tbl->setTemplate($tpl); $tbl->render(); $this->tpl->setVariable("TRANSLATION_TABLE", $tpl->get()); // $this->tpl->show(); }
/** * Show Participant */ function showParticipantObject() { global $rbacsystem, $tree, $tpl, $ilToolbar, $ilCtrl, $ilTabs, $lng; $this->checkPermission("write"); $ilTabs->activateTab("grades"); $this->addSubmissionSubTabs("participant"); // participant selection include_once "./Modules/Exercise/classes/class.ilExAssignment.php"; $ass = ilExAssignment::getAssignmentDataOfExercise($this->object->getId()); $members = $this->object->members_obj->getMembers(); if (count($members) == 0) { ilUtil::sendInfo($lng->txt("exc_no_participants")); return; } $mems = array(); foreach ($members as $mem_id) { if (ilObject::_lookupType($mem_id) == "usr") { include_once "./Services/User/classes/class.ilObjUser.php"; $name = ilObjUser::_lookupName($mem_id); $mems[$mem_id] = $name; } } $mems = ilUtil::sortArray($mems, "lastname", "asc", false, true); if ($_GET["part_id"] == "" && count($mems) > 0) { $_GET["part_id"] = key($mems); } reset($mems); if (count($mems) > 1) { $options = array(); foreach ($mems as $k => $m) { $options[$k] = $m["lastname"] . ", " . $m["firstname"] . " [" . $m["login"] . "]"; } include_once "./Services/Form/classes/class.ilSelectInputGUI.php"; $si = new ilSelectInputGUI($this->lng->txt(""), "part_id"); $si->setOptions($options); $si->setValue($_GET["part_id"]); $ilToolbar->addInputItem($si); $ilToolbar->setFormAction($ilCtrl->getFormAction($this)); $ilToolbar->addFormButton($this->lng->txt("exc_select_part"), "selectParticipant"); } if (count($mems) > 0) { include_once "./Modules/Exercise/classes/class.ilExParticipantTableGUI.php"; $part_tab = new ilExParticipantTableGUI($this, "showParticipant", $this->object, $_GET["part_id"]); $tpl->setContent($part_tab->getHTML()); } else { ilUtil::sendInfo($this->lng->txt("exc_no_assignments_available")); } }
/** * sort nodes and put adm object to the end of sorted array * @access private * @param array node list as returned by iltree::getChilds(); * @return array sorted nodes */ function sortNodes($a_nodes, $a_parent_obj_id) { foreach ($a_nodes as $key => $node) { if ($node["type"] == "adm") { $match = $key; $adm_node = $node; break; } } // cut off adm node isset($match) ? array_splice($a_nodes, $match, 1) : ""; $a_nodes = ilUtil::sortArray($a_nodes, $this->order_column, $this->order_direction); // append adm node to end of list isset($match) ? array_push($a_nodes, $adm_node) : ""; return $a_nodes; }
/** * Get subitems of container * @param bool $a_admin_panel_enabled[optional] * @param bool $a_include_side_block[optional] * @return array */ public function getSubItems($a_admin_panel_enabled = false, $a_include_side_block = false) { global $ilUser; // Caching if (is_array($this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block])) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } // Results are stored in $this->items parent::getSubItems($a_admin_panel_enabled, $a_include_side_block); $limit_sess = false; if (!$a_admin_panel_enabled && !$a_include_side_block && $this->items['sess'] && is_array($this->items['sess']) && $this->isSessionLimitEnabled() && $this->getViewMode() == ilContainer::VIEW_SESSIONS) { $limit_sess = true; } if (!$limit_sess) { return $this->items[(int) $a_admin_panel_enabled][(int) $a_include_side_block]; } // do session limit // @todo move to gui class if (isset($_GET['crs_prev_sess'])) { $ilUser->writePref('crs_sess_show_prev_' . $this->getId(), (string) (int) $_GET['crs_prev_sess']); } if (isset($_GET['crs_next_sess'])) { $ilUser->writePref('crs_sess_show_next_' . $this->getId(), (string) (int) $_GET['crs_next_sess']); } $sessions = ilUtil::sortArray($this->items['sess'], 'start', 'ASC', true, false); $today = new ilDate(date('Ymd', time()), IL_CAL_DATE); $previous = $current = $next = array(); foreach ($sessions as $key => $item) { $start = new ilDateTime($item['start'], IL_CAL_UNIX); $end = new ilDateTime($item['end'], IL_CAL_UNIX); if (ilDateTime::_within($today, $start, $end, IL_CAL_DAY)) { $current[] = $item; } elseif (ilDateTime::_before($start, $today, IL_CAL_DAY)) { $previous[] = $item; } elseif (ilDateTime::_after($start, $today, IL_CAL_DAY)) { $next[] = $item; } } $num_previous_remove = max(count($previous) - $this->getNumberOfPreviousSessions(), 0); while ($num_previous_remove--) { if (!$ilUser->getPref('crs_sess_show_prev_' . $this->getId())) { array_shift($previous); } $this->items['sess_link']['prev']['value'] = 1; } $num_next_remove = max(count($next) - $this->getNumberOfNextSessions(), 0); while ($num_next_remove--) { if (!$ilUser->getPref('crs_sess_show_next_' . $this->getId())) { array_pop($next); } // @fixme $this->items['sess_link']['next']['value'] = 1; } $sessions = array_merge($previous, $current, $next); $this->items['sess'] = $sessions; // #15389 - see ilContainer::getSubItems() include_once 'Services/Container/classes/class.ilContainerSorting.php'; $sort = ilContainerSorting::_getInstance($this->getId()); $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]; }
function sortData() { if ($this->enabled["sort"]) { $this->data = ilUtil::sortArray($this->data, $this->order_column, $this->order_direction); } $this->data = array_slice($this->data, $this->offset, $this->limit); }