ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilCalendarAppointmentPanelGUI.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 
33 {
34  protected static $counter = 0;
35  protected static $instance = null;
36 
37  protected $tpl = null;
38  protected $lng = null;
39  protected $ctrl = null;
40 
48  protected function __construct()
49  {
50  global $lng,$ilCtrl;
51 
52  $this->lng = $lng;
53  $this->ctrl = $ilCtrl;
54  }
55 
64  public static function _getInstance()
65  {
66  if(isset(self::$instance) and self::$instance)
67  {
68  return self::$instance;
69  }
70  return self::$instance = new ilCalendarAppointmentPanelGUI();
71  }
72 
73 
81  public function getHTML($a_app)
82  {
83  global $tree;
84 
85  self::$counter++;
86 
87  $this->tpl = new ilTemplate('tpl.appointment_panel.html',true,true,'Services/Calendar');
88 
89  // Panel variables
90  $this->tpl->setVariable('PANEL_NUM',self::$counter);
91  $this->tpl->setVariable('PANEL_TITLE',$a_app['event']->getPresentationTitle());
92  $this->tpl->setVariable('PANEL_DETAILS',$this->lng->txt('cal_details'));
93  $this->tpl->setVariable('PANEL_TXT_DATE',$this->lng->txt('date'));
94 
95  if($a_app['fullday'])
96  {
97  $this->tpl->setVariable('PANEL_DATE',ilDatePresentation::formatPeriod(
98  new ilDate($a_app['dstart'],IL_CAL_UNIX),
99  new ilDate($a_app['dend'],IL_CAL_UNIX)));
100  }
101  else
102  {
103  $this->tpl->setVariable('PANEL_DATE',ilDatePresentation::formatPeriod(
104  new ilDateTime($a_app['dstart'],IL_CAL_UNIX),
105  new ilDateTime($a_app['dend'],IL_CAL_UNIX)));
106  }
107  if($a_app['event']->getLocation())
108  {
109  $this->tpl->setVariable('PANEL_TXT_WHERE',$this->lng->txt('cal_where'));
110  $this->tpl->setVariable('PANEL_WHERE',$a_app['event']->getLocation());
111  }
112  if($a_app['event']->getDescription())
113  {
114  $this->tpl->setVariable('PANEL_TXT_DESC',$this->lng->txt('description'));
115  $this->tpl->setVariable('PANEL_DESC',nl2br($a_app['event']->getDescription()));
116  }
117 
118  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
119  $cat_id = ilCalendarCategoryAssignments::_lookupCategory($a_app['event']->getEntryId());
120  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
121 
122  $this->tpl->setVariable('PANEL_TXT_CAL_TYPE',$this->lng->txt('cal_cal_type'));
123  switch($cat_info['type'])
124  {
126  $this->tpl->setVariable('PANEL_CAL_TYPE',$this->lng->txt('cal_type_system'));
127  break;
128 
130  $this->tpl->setVariable('PANEL_CAL_TYPE',$this->lng->txt('cal_type_personal'));
131  break;
132 
134  $type = ilObject::_lookupType($cat_info['obj_id']);
135  $this->tpl->setVariable('PANEL_CAL_TYPE',$this->lng->txt('cal_type_'.$type));
136  break;
137  }
138 
139  $this->tpl->setVariable('PANEL_TXT_CAL_NAME',$this->lng->txt('cal_calendar_name'));
140  $this->tpl->setVariable('PANEL_CAL_NAME',$cat_info['title']);
141 
142 
143  if($cat_info['editable'] and !$a_app['event']->isAutoGenerated())
144  {
145  $this->tpl->setCurrentBlock('panel_edit_link');
146  $this->tpl->setVariable('TXT_PANEL_EDIT',$this->lng->txt('edit'));
147 
148  $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
149  $this->ctrl->setParameterByClass('ilcalendarappointmentgui','app_id',$a_app['event']->getEntryId());
150  $this->tpl->setVariable('PANEL_EDIT_HREF',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','edit'));
151  $this->tpl->parseCurrentBlock();
152  }
153  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
154  if($cat_info['type'] == ilCalendarCategory::TYPE_OBJ)
155  {
156  $refs = ilObject::_getAllReferences($cat_info['obj_id']);
157 
158  include_once('classes/class.ilLink.php');
159  $href = ilLink::_getStaticLink(current($refs),ilObject::_lookupType($cat_info['obj_id']),true);
160  $parent = $tree->getParentId(current($refs));
161  $parent_title = ilObject::_lookupTitle(ilObject::_lookupObjId($parent));
162  $this->tpl->setVariable('PANEL_TXT_LINK',$this->lng->txt('ext_link'));
163  $this->tpl->setVariable('PANEL_LINK_HREF',$href);
164  $this->tpl->setVariable('PANEL_LINK_NAME',ilObject::_lookupTitle($cat_info['obj_id']));
165  $this->tpl->setVariable('PANEL_PARENT',$parent_title);
166  }
167 
168  return $this->tpl->get();
169  }
170 }
171 ?>