bugfixes
[eventlist:eventlist.git] / views / venueevents / view.html.php
1 <?php
2 /**
3  * @version 0.9 $Id$
4  * @package Joomla
5  * @subpackage EventList
6  * @copyright (C) 2005 - 2007 Christoph Lukes
7  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
8  */
9
10 // no direct access
11 defined( '_JEXEC' ) or die( 'Restricted access' );
12
13 jimport( 'joomla.application.component.view');
14
15 /**
16  * HTML View class for the Venueevents View
17  *
18  * @package Joomla
19  * @subpackage EventList
20  * @since 0.9
21  */
22 class EventListViewVenueevents extends JView
23 {
24         /**
25          * Creates the Venueevents View
26          *
27          * @since 0.9
28          */
29         function display( $tpl = null )
30         {
31                 global $mainframe, $option;
32
33                 //initialize variables
34                 $document       = & JFactory::getDocument();
35                 $menu           = & JMenu::getInstance();
36                 $elsettings = ELHelper::config();
37                 $item           = $menu->getActive();
38                 $params         =& $menu->getParams($item->id);
39
40                 //cleanup events
41                 ELHelper::cleanevents( $elsettings->lastupdate );
42
43                 //add css file
44                 $document->addStyleSheet('components/com_eventlist/assets/css/eventlist.css');
45                 $document->addCustomTag('<!--[if IE]><style type="text/css">.floattext{zoom:1;}</style><![endif]-->');
46
47                 // Request variables
48                 $limitstart             = JRequest::getVar('limitstart', 0, '', 'int');
49                 $limit          = $mainframe->getUserStateFromRequest('com_eventlist.venueevents.limit', 'limit', $params->def('display_num', 0));
50                 $live_site              = $mainframe->getCfg('live_site');
51                 $locatid                = JRequest::getVar('locatid', 0, '', 'int');
52                 $pop                    = JRequest::getVar('pop', 0, '', 'int');
53
54                 //get data from model
55                 $rows           = & $this->get('Data');
56                 $venue          = & $this->get('Venue');
57                 $total          = & $this->get('Total');
58
59                 //does the venue exist?
60                 if ($venue->id == 0)
61                 {
62                         return JError::raiseError( 404, JText::sprintf( 'Venue #%d not found', $locatid ) );
63                 }
64
65                 //are events available?
66                 if (!$rows) {
67                         $noevents = 1;
68                 } else {
69                         $noevents = 0;
70                 }
71
72                 // Add needed scripts if the lightbox effect is enabled
73                 if ($elsettings->lightbox == 1) {
74                         $document->addScript('components/com_eventlist/assets/js/slimbox.js');
75                         $document->addStyleSheet('components/com_eventlist/assets/css/slimbox.css', 'text/css', 'screen');
76                 }
77
78                 //Get image
79                 $limage = ELImage::venueimage($live_site, $venue->locimage, $elsettings->imagewidth, $elsettings->imagehight, $elsettings->imageprob, $elsettings->gddisabled);
80
81                 //add alternate feed link
82                 $link    = 'index.php?option=com_eventlist&view=venueevents&format=feed&locatid='.$venue->id;
83                 $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
84                 $document->addHeadLink($link.'&type=rss', 'alternate', 'rel', $attribs);
85                 $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
86                 $document->addHeadLink($link.'&type=atom', 'alternate', 'rel', $attribs);
87
88                 //set Page title
89                 $document->setTitle( $item->name.' - '.$venue->club );
90                 $document->setMetadata('keywords', $venue->meta_keywords );
91                 $document->setDescription( strip_tags($venue->meta_description) );
92
93                 //pathway
94                 $pathway        = & $mainframe->getPathWay();
95                 $pathway->setItemName(1, $item->name);
96                 $pathway->addItem( $venue->club, JRoute::_('index.php?option='.$option.'&view=venueevents&locatid='.$locatid));
97
98                 //Printfunction
99                 $params->def( 'print', !$mainframe->getCfg( 'hidePrint' ) );
100                 $params->def( 'icons', $mainframe->getCfg( 'icons' ) );
101
102                 if ($params->def('page_title', 1)) {
103                         $params->def('header', $item->name);
104                 }
105
106                 if ( $pop ) {
107                         $params->set( 'popup', 1 );
108                 }
109
110                 $print_link = JRoute::_('index.php?option=com_eventlist&view=venueevents&locatid='. $venue->id .'&pop=1&tmpl=component');
111
112                 //Check if the user has access to the form
113                 $maintainer = ELUser::ismaintainer();
114                 $genaccess      = ELUser::validate_user( $elsettings->evdelrec, $elsettings->delivereventsyes );
115
116                 if ($maintainer || $genaccess ) $dellink = 1;
117
118                 //Generate Venuedescription
119                 if (empty ($venue->locdescription)) {
120                         $venuedescription = JText::_( 'NO DESCRIPTION' );
121                 } else {
122                         //execute plugins
123                         $venue->text    = $venue->locdescription;
124                         $venue->title   = $venue->club;
125                         JPluginHelper::importPlugin('content');
126                         $results = $mainframe->triggerEvent( 'onPrepareContent', array( &$venue, &$params, 0 ));
127                         $venuedescription = $venue->text;
128                 }
129
130                 //build the url
131         if(strtolower(substr($venue->url, 0, 7)) != "http://") {
132                 $venue->url = 'http://'.$venue->url;
133         }
134
135                 // Create the pagination object
136                 jimport('joomla.html.pagination');
137                 $pageNav = new JPagination($total, $limitstart, $limit);
138
139                 $page = $total - $limit;
140
141                 //create select lists
142                 $lists  = $this->_buildSortLists();
143                 $this->assign('lists'     , $lists);
144
145                 $this->assignRef('rows' ,                                       $rows);
146                 $this->assignRef('noevents' ,                           $noevents);
147                 $this->assignRef('venue' ,                                      $venue);
148                 $this->assignRef('print_link' ,                         $print_link);
149                 $this->assignRef('params' ,                             $params);
150                 $this->assignRef('dellink' ,                            $dellink);
151                 $this->assignRef('limage' ,                             $limage);
152                 $this->assignRef('venuedescription' ,           $venuedescription);
153                 $this->assignRef('locatid' ,                            $locatid);
154                 $this->assignRef('pageNav' ,                            $pageNav);
155                 $this->assignRef('page' ,                                       $page);
156                 $this->assignRef('elsettings' ,                         $elsettings);
157                 $this->assignRef('item' ,                                       $item);
158
159
160                 parent::display($tpl);
161         }
162
163         /**
164          * Manipulate Data
165          *
166          * @since 0.9
167          */
168         function &getRows()
169         {
170                 global $mainframe;
171
172                 if (!count( $this->rows ) ) {
173                         return;
174                 }
175
176                 $k = 0;
177                 for($i = 0; $i <  count($this->rows); $i++)
178                 {
179                         $row =& $this->rows[$i];
180
181                         //Format date
182                         $date = strftime( $this->elsettings->formatdate, strtotime( $row->dates ));
183                         if (!$row->enddates) {
184                                 $displaydate = $date;
185                         } else {
186                                 $enddate        = strftime( $this->elsettings->formatdate, strtotime( $row->enddates ));
187                                 $displaydate = $date.' - '.$enddate;
188                         }
189
190                         //Format time
191                         unset($displaytime);
192                         if ($this->elsettings->showtime == 1) {
193                                 if ($row->times) {
194                                         $time = strftime( $this->elsettings->formattime, strtotime( $row->times ));
195                                         $time = $time.' '.$this->elsettings->timename;
196                                         $displaytime = '<br />'.$time;
197                                 
198                                 }
199                                 if ($row->endtimes) {
200                                         $endtime = strftime( $this->elsettings->formattime, strtotime( $row->endtimes ));
201                                         $endtime = $endtime.' '.$this->elsettings->timename;
202                                         $displaytime = '<br />'.$time.' - '.$endtime;
203                                         
204                                 }
205                         }
206                         
207                         if (isset($displaytime)) {
208                                 $row->displaytime = $displaytime;
209                         } else {
210                                 $row->displaytime = '<br />-';
211                         }
212
213                         $row->displaydate = $displaydate;
214                         $row->odd   = $k;
215                         $k = 1 - $k;
216                 }
217
218                 return $this->rows;
219         }
220
221         function _buildSortLists()
222         {
223                 // Table ordering values
224                 $filter_order           = JRequest::getVar('filter_order');
225                 $filter_order_Dir       = JRequest::getVar('filter_order_Dir');
226
227                 $filter                         = JRequest::getVar('filter');
228
229                 $html= '';
230
231                 if ($filter_order_Dir == 'DESC') {
232                         $lists['order_Dir'] = 'ASC';
233                 } else {
234                         $lists['order_Dir'] = 'DESC';
235                 }
236
237                 $lists['order']                 = $filter_order;
238                 $lists['filter']                = $filter;
239                 $lists['filter_type']   = $html;
240
241                 return $lists;
242         }
243 }
244 ?>