ILIAS  Release_4_0_x_branch Revision 61816
 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,$lng;
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  if ($a_app["event"]->isMilestone())
93  {
94  $this->tpl->setVariable('PANEL_DETAILS',$this->lng->txt('cal_ms_details'));
95  }
96  else
97  {
98  $this->tpl->setVariable('PANEL_DETAILS',$this->lng->txt('cal_details'));
99  }
100  $this->tpl->setVariable('PANEL_TXT_DATE',$this->lng->txt('date'));
101 
102  if($a_app['fullday'])
103  {
104  $this->tpl->setVariable('PANEL_DATE',ilDatePresentation::formatPeriod(
105  new ilDate($a_app['dstart'],IL_CAL_UNIX),
106  new ilDate($a_app['dend'],IL_CAL_UNIX)));
107  }
108  else
109  {
110  $this->tpl->setVariable('PANEL_DATE',ilDatePresentation::formatPeriod(
111  new ilDateTime($a_app['dstart'],IL_CAL_UNIX),
112  new ilDateTime($a_app['dend'],IL_CAL_UNIX)));
113  }
114  if($a_app['event']->getLocation())
115  {
116  $this->tpl->setVariable('PANEL_TXT_WHERE',$this->lng->txt('cal_where'));
117  $this->tpl->setVariable('PANEL_WHERE',$a_app['event']->getLocation());
118  }
119  if($a_app['event']->getDescription())
120  {
121  $this->tpl->setVariable('PANEL_TXT_DESC',$this->lng->txt('description'));
122  $this->tpl->setVariable('PANEL_DESC',nl2br($a_app['event']->getDescription()));
123  }
124 
125  if($a_app['event']->isMilestone() && $a_app['event']->getCompletion() > 0)
126  {
127  $this->tpl->setVariable('PANEL_TXT_COMPL',$this->lng->txt('cal_task_completion'));
128  $this->tpl->setVariable('PANEL_COMPL',$a_app['event']->getCompletion()." %");
129  }
130 
131  if ($a_app['event']->isMilestone())
132  {
133  // users responsible
134  $users = $a_app['event']->readResponsibleUsers();
135  $delim = "";
136  foreach($users as $r)
137  {
138  $value.= $delim.$r["lastname"].", ".$r["firstname"]." [".$r["login"]."]";
139  $delim = "<br />";
140  }
141  if (count($users) > 0)
142  {
143  $this->tpl->setVariable('PANEL_TXT_RESP', $this->lng->txt('cal_responsible'));
144  $this->tpl->setVariable('PANEL_RESP', $value);
145  }
146  }
147 
148  include_once('./Services/Calendar/classes/class.ilCalendarCategoryAssignments.php');
149  $cat_id = ilCalendarCategoryAssignments::_lookupCategory($a_app['event']->getEntryId());
150  $cat_info = ilCalendarCategories::_getInstance()->getCategoryInfo($cat_id);
151 
152  $this->tpl->setVariable('PANEL_TXT_CAL_TYPE',$this->lng->txt('cal_cal_type'));
153  switch($cat_info['type'])
154  {
156  $this->tpl->setVariable('PANEL_CAL_TYPE',$this->lng->txt('cal_type_system'));
157  break;
158 
160  $this->tpl->setVariable('PANEL_CAL_TYPE',$this->lng->txt('cal_type_personal'));
161  break;
162 
164  $type = ilObject::_lookupType($cat_info['obj_id']);
165  $this->tpl->setVariable('PANEL_CAL_TYPE',$this->lng->txt('cal_type_'.$type));
166  break;
167  }
168 
169  $this->tpl->setVariable('PANEL_TXT_CAL_NAME',$this->lng->txt('cal_calendar_name'));
170  $this->tpl->setVariable('PANEL_CAL_NAME',$cat_info['title']);
171 
172 
173  if($cat_info['editable'] and !$a_app['event']->isAutoGenerated())
174  {
175  $this->tpl->setCurrentBlock('panel_edit_link');
176  $this->tpl->setVariable('TXT_PANEL_EDIT',$this->lng->txt('edit'));
177 
178  $this->ctrl->clearParametersByClass('ilcalendarappointmentgui');
179  $this->ctrl->setParameterByClass('ilcalendarappointmentgui','app_id',$a_app['event']->getEntryId());
180  $this->tpl->setVariable('PANEL_EDIT_HREF',$this->ctrl->getLinkTargetByClass('ilcalendarappointmentgui','edit'));
181  $this->tpl->parseCurrentBlock();
182  }
183  include_once('./Services/Calendar/classes/class.ilCalendarCategory.php');
184  if($cat_info['type'] == ilCalendarCategory::TYPE_OBJ)
185  {
186  $refs = ilObject::_getAllReferences($cat_info['obj_id']);
187  $type = ilObject::_lookupType($cat_info['obj_id']);
188  $title = ilObject::_lookupTitle($cat_info['obj_id']) ?
189  ilObject::_lookupTitle($cat_info['obj_id']) :
190  $lng->txt('obj_'.$type);
191 
192  include_once('classes/class.ilLink.php');
193  $href = ilLink::_getStaticLink(current($refs),ilObject::_lookupType($cat_info['obj_id']));
194  $parent = $tree->getParentId(current($refs));
195  $parent_title = ilObject::_lookupTitle(ilObject::_lookupObjId($parent));
196  $this->tpl->setVariable('PANEL_TXT_LINK',$this->lng->txt('ext_link'));
197  $this->tpl->setVariable('PANEL_LINK_HREF',$href);
198  $this->tpl->setVariable('PANEL_LINK_NAME',$title);
199  $this->tpl->setVariable('PANEL_PARENT',$parent_title);
200  }
201 
202  return $this->tpl->get();
203  }
204 }
205 ?>