ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCalendarCategoryTableGUI.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24include_once('./Services/Table/classes/class.ilTable2GUI.php');
25
36{
37 private $seed = null;
38
46 public function __construct($a_parent_obj, ilDateTime $seed = null)
47 {
48 global $DIC;
49
50 $lng = $DIC['lng'];
51 $ilCtrl = $DIC['ilCtrl'];
52 $ilUser = $DIC['ilUser'];
53
54 // this should be deprecated
55 die("ilCalendarCategoryTableGUI::_construct");
56
57
58 $this->lng = $lng;
59 $this->lng->loadLanguageModule('dateplaner');
60 $this->ctrl = $ilCtrl;
61
62 $this->seed = $seed;
63
64 $this->setId('calmng');
65
66 parent::__construct($a_parent_obj, 'showCategories');
67 $this->setFormName('categories');
68 $this->addColumn('', '', "1", true);
69 $this->addColumn($this->lng->txt('type'), 'type_sortable', "1");
70 $this->addColumn($this->lng->txt('title'), 'title', "100%");
71 $this->addColumn('', 'subscription', '');
72
73 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'seed', $this->seed->get(IL_CAL_DATE));
74 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
75 $this->setRowTemplate("tpl.show_category_row.html", "Services/Calendar");
76 $this->disable('sort');
77 if (!$ilUser->prefs["screen_reader_optimization"]) {
78 $this->disable('header');
79 }
80
81 //$this->setShowRowsSelector(true);
82 $this->disable('numinfo');
83 $this->enable('select_all');
84 $this->setSelectAllCheckbox('selected_cat_ids');
85 $this->setDisplayAsBlock(true);
86
87 $this->setDefaultOrderDirection('asc');
88 $this->setDefaultOrderField('type_sortable');
89
90 // Show add calendar button
91 $this->addCommandButton('add', $this->lng->txt('cal_add_calendar'));
92 }
93
101 protected function fillRow($a_set)
102 {
103 $this->tpl->setVariable('VAL_ID', $a_set['id']);
104 if (!$a_set['hidden']) {
105 $this->tpl->setVariable('VAL_CHECKED', 'checked="checked"');
106 }
107 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
108 $this->tpl->setVariable('BGCOLOR', $a_set['color']);
109
110 $this->ctrl->setParameter($this->getParentObject(), 'category_id', $a_set['id']);
111 $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTarget($this->getParentObject(), 'details'));
112 $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
113
114 switch ($a_set['type']) {
116 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_calg.svg'));
117 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_system'));
118 break;
119
121 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_usr.svg'));
122 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_personal'));
123 break;
124
126 $type = ilObject::_lookupType($a_set['obj_id']);
127 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_' . $type . '.svg'));
128 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_' . $type));
129 break;
130 }
131 if (strlen($a_set['path'])) {
132 $this->tpl->setCurrentBlock('calendar_path');
133 $this->tpl->setVariable('ADD_PATH_INFO', $a_set['path']);
134 $this->tpl->parseCurrentBlock();
135 }
136
137 // Subscription link
138 $this->tpl->setVariable('SUB_SRC', ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_ICAL));
139 $this->ctrl->setParameterByClass('ilcalendarsubscriptiongui', 'seed', $this->seed->get(IL_CAL_DATE));
140 $this->ctrl->setParameterByClass('ilcalendarsubscriptiongui', 'category_id', $a_set['id']);
141 $this->tpl->setVariable('SUB_LINK', $this->ctrl->getLinkTargetByClass(array('ilcalendarpresentationgui','ilcalendarsubscriptiongui')));
142 $this->ctrl->setParameterByClass('ilcalendarsubscriptiongui', 'category_id', "");
143 $this->tpl->setVariable('SUB_ALT', $this->lng->txt('ical_export'));
144 }
145
152 public function parse()
153 {
154 global $DIC;
155
156 $ilUser = $DIC['ilUser'];
157 $tree = $DIC['tree'];
158
159 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
160 include_once('./Services/Calendar/classes/class.ilCalendarVisibility.php');
161
163 $hidden = $hidden_obj->getHidden();
164
166 $all = $cats->getCategoriesInfo();
167 $tmp_title_counter = array();
168 $categories = array();
169 foreach ($all as $category) {
170 $tmp_arr['obj_id'] = $category['obj_id'];
171 $tmp_arr['id'] = $category['cat_id'];
172 $tmp_arr['hidden'] = (bool) in_array($category['cat_id'], $hidden);
173 $tmp_arr['title'] = $category['title'];
174 $tmp_arr['type'] = $category['type'];
175
176 // Append object type to make type sortable
177 $tmp_arr['type_sortable'] = ilCalendarCategory::lookupCategorySortIndex($category['type']);
178 if ($category['type'] == ilCalendarCategory::TYPE_OBJ) {
179 $tmp_arr['type_sortable'] .= ('_' . ilObject::_lookupType($category['obj_id']));
180 }
181
182 $tmp_arr['color'] = $category['color'];
183 $tmp_arr['editable'] = $category['editable'];
184
185 $categories[] = $tmp_arr;
186
187 // count title for appending the parent container if there is more than one entry.
188 $tmp_title_counter[$category['type'] . '_' . $category['title']]++;
189 }
190
191 $path_categories = array();
192 foreach ($categories as $cat) {
193 if ($cat['type'] == ilCalendarCategory::TYPE_OBJ) {
194 if ($tmp_title_counter[$cat['type'] . '_' . $cat['title']] > 1) {
195 foreach (ilObject::_getAllReferences($cat['obj_id']) as $ref_id) {
196 $cat['path'] = $this->buildPath($ref_id);
197 break;
198 }
199 }
200 }
201 $path_categories[] = $cat;
202 }
203 $this->setData($path_categories);
204 }
205
206 protected function buildPath($a_ref_id)
207 {
208 global $DIC;
209
210 $tree = $DIC['tree'];
211
212 $path_arr = $tree->getPathFull($a_ref_id, ROOT_FOLDER_ID);
213 $counter = 0;
214 unset($path_arr[count($path_arr) - 1]);
215
216 foreach ($path_arr as $data) {
217 if ($counter++) {
218 $path .= " -> ";
219 }
220 $path .= $data['title'];
221 }
222 if (strlen($path) > 30) {
223 return '...' . substr($path, -30);
224 }
225 return $path;
226 }
227}
$path
Definition: aliased.php:25
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATE
static _getInstance($a_usr_id=0)
get singleton instance
show presentation of calendar category side block
__construct($a_parent_obj, ilDateTime $seed=null)
Constructor.
static lookupCategorySortIndex($a_type_id)
Lookup sort index of calendar type.
static _getInstanceByUserId($a_user_id, $a_ref_id=0)
get instance by user id
@classDescription Date and time handling
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static get($a_type, $a_href="")
Get icon html.
Class ilTable2GUI.
setDisplayAsBlock($a_val)
Set display as block.
getParentObject()
Get parent object.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
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.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
setDefaultOrderDirection($a_defaultorderdirection)
Set Default order direction.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
enable($a_module_name)
enables particular modules of table
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilCtrl
Definition: ilias.php:18
$type
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18