ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $lng,$ilCtrl,$ilUser;
49
50 // this should be deprecated
51 die("ilCalendarCategoryTableGUI::_construct");
52
53
54 $this->lng = $lng;
55 $this->lng->loadLanguageModule('dateplaner');
56 $this->ctrl = $ilCtrl;
57
58 $this->seed = $seed;
59
60 $this->setId('calmng');
61
62 parent::__construct($a_parent_obj, 'showCategories');
63 $this->setFormName('categories');
64 $this->addColumn('', '', "1", true);
65 $this->addColumn($this->lng->txt('type'), 'type_sortable', "1");
66 $this->addColumn($this->lng->txt('title'), 'title', "100%");
67 $this->addColumn('', 'subscription', '');
68
69 $this->ctrl->setParameterByClass(get_class($this->getParentObject()), 'seed', $this->seed->get(IL_CAL_DATE));
70 $this->setFormAction($this->ctrl->getFormAction($a_parent_obj));
71 $this->setRowTemplate("tpl.show_category_row.html", "Services/Calendar");
72 $this->disable('sort');
73 if (!$ilUser->prefs["screen_reader_optimization"]) {
74 $this->disable('header');
75 }
76
77 //$this->setShowRowsSelector(true);
78 $this->disable('numinfo');
79 $this->enable('select_all');
80 $this->setSelectAllCheckbox('selected_cat_ids');
81 $this->setDisplayAsBlock(true);
82
83 $this->setDefaultOrderDirection('asc');
84 $this->setDefaultOrderField('type_sortable');
85
86 // Show add calendar button
87 $this->addCommandButton('add', $this->lng->txt('cal_add_calendar'));
88 }
89
97 protected function fillRow($a_set)
98 {
99 $this->tpl->setVariable('VAL_ID', $a_set['id']);
100 if (!$a_set['hidden']) {
101 $this->tpl->setVariable('VAL_CHECKED', 'checked="checked"');
102 }
103 $this->tpl->setVariable('VAL_TITLE', $a_set['title']);
104 $this->tpl->setVariable('BGCOLOR', $a_set['color']);
105
106 $this->ctrl->setParameter($this->getParentObject(), 'category_id', $a_set['id']);
107 $this->tpl->setVariable('EDIT_LINK', $this->ctrl->getLinkTarget($this->getParentObject(), 'details'));
108 $this->tpl->setVariable('TXT_EDIT', $this->lng->txt('edit'));
109
110 switch ($a_set['type']) {
112 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_calg.svg'));
113 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_system'));
114 break;
115
117 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_usr.svg'));
118 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_personal'));
119 break;
120
122 $type = ilObject::_lookupType($a_set['obj_id']);
123 $this->tpl->setVariable('IMG_SRC', ilUtil::getImagePath('icon_' . $type . '.svg'));
124 $this->tpl->setVariable('IMG_ALT', $this->lng->txt('cal_type_' . $type));
125 break;
126 }
127 if (strlen($a_set['path'])) {
128 $this->tpl->setCurrentBlock('calendar_path');
129 $this->tpl->setVariable('ADD_PATH_INFO', $a_set['path']);
130 $this->tpl->parseCurrentBlock();
131 }
132
133 // Subscription link
134 $this->tpl->setVariable('SUB_SRC', ilRSSButtonGUI::get(ilRSSButtonGUI::ICON_ICAL));
135 $this->ctrl->setParameterByClass('ilcalendarsubscriptiongui', 'seed', $this->seed->get(IL_CAL_DATE));
136 $this->ctrl->setParameterByClass('ilcalendarsubscriptiongui', 'category_id', $a_set['id']);
137 $this->tpl->setVariable('SUB_LINK', $this->ctrl->getLinkTargetByClass(array('ilcalendarpresentationgui','ilcalendarsubscriptiongui')));
138 $this->ctrl->setParameterByClass('ilcalendarsubscriptiongui', 'category_id', "");
139 $this->tpl->setVariable('SUB_ALT', $this->lng->txt('ical_export'));
140 }
141
148 public function parse()
149 {
150 global $ilUser,$tree;
151
152 include_once('./Services/Calendar/classes/class.ilCalendarCategories.php');
153 include_once('./Services/Calendar/classes/class.ilCalendarVisibility.php');
154
156 $hidden = $hidden_obj->getHidden();
157
159 $all = $cats->getCategoriesInfo();
160 $tmp_title_counter = array();
161 $categories = array();
162 foreach ($all as $category) {
163 $tmp_arr['obj_id'] = $category['obj_id'];
164 $tmp_arr['id'] = $category['cat_id'];
165 $tmp_arr['hidden'] = (bool) in_array($category['cat_id'], $hidden);
166 $tmp_arr['title'] = $category['title'];
167 $tmp_arr['type'] = $category['type'];
168
169 // Append object type to make type sortable
170 $tmp_arr['type_sortable'] = ilCalendarCategory::lookupCategorySortIndex($category['type']);
171 if ($category['type'] == ilCalendarCategory::TYPE_OBJ) {
172 $tmp_arr['type_sortable'] .= ('_' . ilObject::_lookupType($category['obj_id']));
173 }
174
175 $tmp_arr['color'] = $category['color'];
176 $tmp_arr['editable'] = $category['editable'];
177
178 $categories[] = $tmp_arr;
179
180 // count title for appending the parent container if there is more than one entry.
181 $tmp_title_counter[$category['type'] . '_' . $category['title']]++;
182 }
183
184 $path_categories = array();
185 foreach ($categories as $cat) {
186 if ($cat['type'] == ilCalendarCategory::TYPE_OBJ) {
187 if ($tmp_title_counter[$cat['type'] . '_' . $cat['title']] > 1) {
188 foreach (ilObject::_getAllReferences($cat['obj_id']) as $ref_id) {
189 $cat['path'] = $this->buildPath($ref_id);
190 break;
191 }
192 }
193 }
194 $path_categories[] = $cat;
195 }
196 $this->setData($path_categories);
197 }
198
199 protected function buildPath($a_ref_id)
200 {
201 global $tree;
202
203 $path_arr = $tree->getPathFull($a_ref_id, ROOT_FOLDER_ID);
204 $counter = 0;
205 unset($path_arr[count($path_arr) - 1]);
206
207 foreach ($path_arr as $data) {
208 if ($counter++) {
209 $path .= " -> ";
210 }
211 $path .= $data['title'];
212 }
213 if (strlen($path) > 30) {
214 return '...' . substr($path, -30);
215 }
216 return $path;
217 }
218}
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.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
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.
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)
$counter
global $ilCtrl
Definition: ilias.php:18
$type
$ilUser
Definition: imgupload.php:18