ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjectBadgeTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("Services/Table/classes/class.ilTable2GUI.php");
5include_once("./Services/Badge/classes/class.ilBadge.php");
6
16{
17 protected $has_write; // [bool]
18
19 function __construct($a_parent_obj, $a_parent_cmd = "", $a_has_write = false)
20 {
21 global $ilCtrl, $lng;
22
23 $this->setId("bdgobdg");
24 $this->has_write = (bool)$a_has_write;
25
26 parent::__construct($a_parent_obj, $a_parent_cmd);
27
28 $this->setLimit(9999);
29
30 $this->setTitle($lng->txt("badge_object_badges"));
31
32 if($this->has_write)
33 {
34 $this->addColumn("", "", 1);
35 }
36
37 $this->addColumn($lng->txt("title"), "title");
38 $this->addColumn($lng->txt("type"), "type");
39 $this->addColumn($lng->txt("object"), "container");
40 $this->addColumn($lng->txt("active"), "active");
41 $this->addColumn($lng->txt("action"), "");
42
43 if($this->has_write)
44 {
45 $this->addMultiCommand("activateObjectBadges", $lng->txt("activate"));
46 $this->addMultiCommand("deactivateObjectBadges", $lng->txt("deactivate"));
47 $this->addMultiCommand("confirmDeleteObjectBadges", $lng->txt("delete"));
48 $this->setSelectAllCheckbox("id");
49 }
50
51 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
52 $this->setRowTemplate("tpl.object_badge_row.html", "Services/Badge");
53 $this->setDefaultOrderField("title");
54
55 $this->setFilterCommand("applyObjectFilter");
56 $this->setResetCommand("resetObjectFilter");
57
58 $this->initFilter();
59
60 $this->getItems();
61 }
62
63 public function initFilter()
64 {
65 global $lng;
66
67 $title = $this->addFilterItemByMetaType("title", self::FILTER_TEXT, false, $lng->txt("title"));
68 $this->filter["title"] = $title->getValue();
69
70 $object = $this->addFilterItemByMetaType("object", self::FILTER_TEXT, false, $lng->txt("object"));
71 $this->filter["object"] = $object->getValue();
72
73 $lng->loadLanguageModule("search");
74
75 $options = array(
76 "" => $lng->txt("search_any"),
77 );
78 foreach(ilBadgeHandler::getInstance()->getAvailableTypes() as $id => $type)
79 {
80 // no activity badges
81 if(!in_array("bdga", $type->getValidObjectTypes()))
82 {
84 }
85 }
86 asort($options);
87
88 $type = $this->addFilterItemByMetaType("type", self::FILTER_SELECT, false, $lng->txt("type"));
89 $type->setOptions($options);
90 $this->filter["type"] = $type->getValue();
91 }
92
93 function getItems()
94 {
95 global $lng, $ilAccess;
96
97 $data = $filter_types = array();
98
99 $types = ilBadgeHandler::getInstance()->getAvailableTypes();
100
101 include_once "Services/Badge/classes/class.ilBadgeRenderer.php";
102 include_once "Services/Link/classes/class.ilLink.php";
103
104 foreach(ilBadge::getObjectInstances($this->filter) as $badge_item)
105 {
106 // :TODO: container presentation
107 $container_url = null;
108 $container = '<img src="'.
109 ilObject::_getIcon($badge_item["parent_id"], "big", $badge_item["parent_type"]).
110 '" alt="'.$lng->txt("obj_".$badge_item["parent_type"]).
111 '" title="'.$lng->txt("obj_".$badge_item["parent_type"]).'" /> '.
112 $badge_item["parent_title"];
113
114 if((bool)$badge_item["deleted"])
115 {
116 $container .= ' <span class="il_ItemAlertProperty">'.$lng->txt("deleted").'</span>';
117 }
118 else
119 {
120 $ref_id = array_shift(ilObject::_getAllReferences($badge_item["parent_id"]));
121 if($ilAccess->checkAccess("read", "", $ref_id))
122 {
123 $container_url = ilLink::_getLink($ref_id);
124 }
125 }
126
127 $type_caption = ilBadge::getExtendedTypeCaption($types[$badge_item["type_id"]]);
128
129 $data[] = array(
130 "id" => $badge_item["id"],
131 "active"=> $badge_item["active"],
132 "type" => $type_caption,
133 "title" => $badge_item["title"],
134 "container_meta" => $container,
135 "container_url" => $container_url,
136 "container_id" => $badge_item["parent_id"],
137 "renderer" => new ilBadgeRenderer(null, new ilBadge($badge_item["id"]))
138 );
139
140 $filter_types[$badge_item["type_id"]] = $type_caption;
141 }
142
143 $this->setData($data);
144 }
145
146 protected function fillRow($a_set)
147 {
148 global $lng, $ilCtrl;
149
150 if($a_set["container_url"])
151 {
152 $this->tpl->setCurrentBlock("container_link_bl");
153 $this->tpl->setVariable("TXT_CONTAINER", $a_set["container_meta"]);
154 $this->tpl->setVariable("URL_CONTAINER", $a_set["container_url"]);
155 $this->tpl->parseCurrentBlock();
156 }
157 else
158 {
159 $this->tpl->setCurrentBlock("container_nolink_bl");
160 $this->tpl->setVariable("TXT_CONTAINER_STATIC", $a_set["container_meta"]);
161 $this->tpl->parseCurrentBlock();
162 }
163
164 if($this->has_write)
165 {
166 $this->tpl->setVariable("VAL_ID", $a_set["id"]);
167 }
168
169 $this->tpl->setVariable("PREVIEW", $a_set["renderer"]->getHTML());
170 $this->tpl->setVariable("TXT_TITLE", $a_set["title"]);
171 $this->tpl->setVariable("TXT_TYPE", $a_set["type"]);
172 $this->tpl->setVariable("TXT_ACTIVE", $a_set["active"]
173 ? $lng->txt("yes")
174 : $lng->txt("no"));
175
176 if($this->has_write)
177 {
178 $ilCtrl->setParameter($this->getParentObject(), "pid", $a_set["container_id"]);
179 $ilCtrl->setParameter($this->getParentObject(), "bid", $a_set["id"]);
180 $url = $ilCtrl->getLinkTarget($this->getParentObject(), "listObjectBadgeUsers");
181 $ilCtrl->setParameter($this->getParentObject(), "bid", "");
182 $ilCtrl->setParameter($this->getParentObject(), "pid", "");
183
184 $this->tpl->setVariable("TXT_LIST", $lng->txt("users"));
185 $this->tpl->setVariable("URL_LIST", $url);
186 }
187 }
188}
An exception for terminatinating execution or to throw for unit testing.
static getInstance()
Constructor.
static getExtendedTypeCaption(ilBadgeType $a_type)
static getObjectInstances(array $a_filter=null)
TableGUI class for badge listing.
__construct($a_parent_obj, $a_parent_cmd="", $a_has_write=false)
Constructor.
fillRow($a_set)
Standard Version of Fill Row.
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _getAllReferences($a_id)
get all reference ids of object
Class ilTable2GUI.
getHTML()
Get HTML.
addColumn($a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
getParentObject()
Get parent object.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=NULL)
Add filter by standard type.
setFilterCommand($a_val, $a_caption=null)
Set filter command.
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:17
$ref_id
Definition: sahs_server.php:39
$url
Definition: shib_logout.php:72
if(!is_array($argv)) $options