forked from jemproject/JEM-Project
/
view.html.php
304 lines (257 loc) · 10.9 KB
/
view.html.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
<?php
/**
* @version 1.9.6
* @package JEM
* @copyright (C) 2013-2014 joomlaeventmanager.net
* @copyright (C) 2005-2009 Christoph Lukes
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
defined('_JEXEC') or die;
require JPATH_COMPONENT_SITE.'/classes/view.class.php';
/**
* Category-View
*/
class JemViewCategory extends JEMView
{
function __construct($config = array()) {
parent::__construct($config);
// additional path for common templates + corresponding override path
$this->addCommonTemplatePath();
}
/**
* Creates the Category View
*/
function display($tpl=null)
{
if($this->getLayout() == 'calendar') {
$app = JFactory::getApplication();
// Load tooltips behavior
JHtml::_('behavior.tooltip');
//initialize variables
$document = JFactory::getDocument();
$jemsettings = JemHelper::config();
$menu = $app->getMenu();
$menuitem = $menu->getActive();
$params = $app->getParams();
$uri = JFactory::getURI();
$pathway = $app->getPathWay();
$print = JRequest::getBool('print');
// Load css
JHtml::_('stylesheet', 'com_jem/jem.css', array(), true);
JHtml::_('stylesheet', 'com_jem/calendar.css', array(), true);
$document->addCustomTag('<!--[if IE]><style type="text/css">.floattext{zoom:1;}, * html #jem dd { height: 1%; }</style><![endif]-->');
if ($print) {
JHtml::_('stylesheet', 'com_jem/print.css', array(), true);
$document->setMetaData('robots', 'noindex, nofollow');
}
$evlinkcolor = $params->get('eventlinkcolor');
$evbackgroundcolor = $params->get('eventbackgroundcolor');
$currentdaycolor = $params->get('currentdaycolor');
$eventandmorecolor = $params->get('eventandmorecolor');
$style = '
div[id^=\'scat\'] a {color:' . $evlinkcolor . ';}
div[id^=\'scat\'] {background-color:'.$evbackgroundcolor .';}
.eventandmore {background-color:'.$eventandmorecolor .';}
.today .daynum {background-color:'.$currentdaycolor.';}';
$document->addStyleDeclaration($style);
// Retrieve date variables
$year = (int)JRequest::getVar('yearID', strftime("%Y"));
$month = (int)JRequest::getVar('monthID', strftime("%m"));
if (JRequest::getVar('id')) {
$catid = JRequest::getVar('id');
} else {
$catid = $params->get('id');
}
//get data from model and set the month
$model = $this->getModel('CategoryCal');
$model->setDate(mktime(0, 0, 1, $month, 1, $year));
$category = $this->get('Category', 'CategoryCal');
$rows = $this->get('Data', 'CategoryCal');
//Set Page title
$pagetitle = $params->def('page_title', $menuitem->title);
$params->def('page_heading', $params->get('page_title'));
$pageclass_sfx = $params->get('pageclass_sfx');
// Add site name to title if param is set
if ($app->getCfg('sitename_pagetitles', 0) == 1) {
$pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
$pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename'));
}
$document->setTitle($pagetitle);
$document->setMetaData('title', $pagetitle);
//init calendar
$itemid = JRequest::getInt('Itemid');
$partItemid = ($itemid > 0) ? '&Itemid='.$itemid : '';
$partCatid = ($catid > 0) ? '&id=' . $catid : '';
$cal = new JEMCalendar($year, $month, 0, $app->getCfg('offset'));
$cal->enableMonthNav('index.php?option=com_jem&view=category&layout=calendar' . $partCatid . $partItemid);
$cal->setFirstWeekDay($params->get('firstweekday', 1));
//$cal->enableDayLinks(false);
$this->rows = $rows;
$this->catid = $catid;
$this->params = $params;
$this->jemsettings = $jemsettings;
$this->cal = $cal;
$this->pageclass_sfx = htmlspecialchars($pageclass_sfx);
} else {
//initialize variables
$app = JFactory::getApplication();
$document = JFactory::getDocument();
$jemsettings = JemHelper::config();
$settings = JemHelper::globalattribs();
$db = JFactory::getDBO();
$user = JFactory::getUser();
JHtml::_('behavior.tooltip');
//get menu information
$params = $app->getParams();
$uri = JFactory::getURI();
$pathway = $app->getPathWay();
$menu = $app->getMenu();
$menuitem = $menu->getActive();
// Load css
JHtml::_('stylesheet', 'com_jem/jem.css', array(), true);
$document->addCustomTag('<!--[if IE]><style type="text/css">.floattext{zoom:1;}, * html #jem dd { height: 1%; }</style><![endif]-->');
//get data from model
$rows = $this->get('Data');
$category = $this->get('Category');
$categories = $this->get('Childs');
//are events available?
if (!$rows) {
$noevents = 1;
} else {
$noevents = 0;
}
//does the category exist
if ($category->id == 0)
{
// TODO Translation
return JError::raiseError(404, JText::sprintf('Category #%d not found', $category->id));
}
// Decide which parameters should take priority
$useMenuItemParams = ($menuitem && $menuitem->query['option'] == 'com_jem'
&& $menuitem->query['view'] == 'category'
&& (!isset($menuitem->query['layout']) || $menuitem->query['layout'] == 'default')
&& $menuitem->query['id'] == $category->id);
// get variables
$filter_order = $app->getUserStateFromRequest('com_jem.category.filter_order', 'filter_order', 'a.dates', 'cmd');
$filter_order_Dir = $app->getUserStateFromRequest('com_jem.category.filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter = $app->getUserStateFromRequest('com_jem.category.filter', 'filter', '', 'int');
$search = $app->getUserStateFromRequest('com_jem.category.filter_search', 'filter_search', '', 'string');
$search = $db->escape(trim(JString::strtolower($search)));
$task = JRequest::getWord('task');
// table ordering
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
//search filter
$filters = array();
if ($jemsettings->showtitle == 1) {
$filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_TITLE'));
}
if ($jemsettings->showlocate == 1) {
$filters[] = JHtml::_('select.option', '2', JText::_('COM_JEM_VENUE'));
}
if ($jemsettings->showcity == 1) {
$filters[] = JHtml::_('select.option', '3', JText::_('COM_JEM_CITY'));
}
if ($jemsettings->showcat == 1) {
$filters[] = JHtml::_('select.option', '4', JText::_('COM_JEM_CATEGORY'));
}
if ($jemsettings->showstate == 1) {
$filters[] = JHtml::_('select.option', '5', JText::_('COM_JEM_STATE'));
}
$lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter', 'size="1" class="inputbox"', 'value', 'text', $filter);
// search filter
$lists['search']= $search;
// Add feed links
$link = '&format=feed&id='.$category->id.'&limitstart=';
$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
$this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
$this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);
//create the pathway
$cats = new JEMCategories($category->id);
$parents = $cats->getParentlist();
foreach($parents as $parent) {
$pathway->addItem($this->escape($parent->catname), JRoute::_(JemHelperRoute::getCategoryRoute($parent->slug)) );
}
// Show page heading specified on menu item or category title as heading - idea taken from com_content.
//
// Check to see which parameters should take priority
// If the current view is the active menuitem and an category view for this category, then the menu item params take priority
if ($useMenuItemParams) {
$pagetitle = $params->get('page_title', $menuitem->title ? $menuitem->title : $category->catname);
$pageheading = $params->get('page_heading', $pagetitle);
$pathway->setItemName(1, $menuitem->title);
} else {
$pagetitle = $category->catname;
$pageheading = $pagetitle;
$params->set('show_page_heading', 1); // ensure page heading is shown
$pathway->addItem($category->catname, JRoute::_(JemHelperRoute::getCategoryRoute($category->slug)) );
}
$pageclass_sfx = $params->get('pageclass_sfx');
if ($task == 'archive') {
$pathway->addItem(JText::_('COM_JEM_ARCHIVE'), JRoute::_(JemHelperRoute::getCategoryRoute($category->slug).'&task=archive'));
$print_link = JRoute::_(JemHelperRoute::getCategoryRoute($category->id) .'&task=archive&print=1&tmpl=component');
$pagetitle .= ' - '.JText::_('COM_JEM_ARCHIVE');
$pageheading .= ' - '.JText::_('COM_JEM_ARCHIVE');
} else {
$print_link = JRoute::_(JemHelperRoute::getCategoryRoute($category->id) .'&print=1&tmpl=component');
}
$params->set('page_heading', $pageheading);
// Add site name to title if param is set
if ($app->getCfg('sitename_pagetitles', 0) == 1) {
$pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
$pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename'));
}
//Set Page title & Meta data
$this->document->setTitle($pagetitle);
$document->setMetaData('title', $pagetitle);
$document->setMetadata('keywords', $category->meta_keywords);
$document->setDescription(strip_tags($category->meta_description));
//Check if the user has access to the form
$maintainer = JemUser::ismaintainer('add');
$genaccess = JemUser::validate_user($jemsettings->evdelrec, $jemsettings->delivereventsyes);
if ($maintainer || $genaccess || $user->authorise('core.create','com_jem')) {
$dellink = 1;
} else {
$dellink = 0;
}
// Create the pagination object
$pagination = $this->get('Pagination');
//Generate Categorydescription
if (empty ($category->description)) {
$description = JText::_('COM_JEM_NO_DESCRIPTION');
} else {
//execute plugins
$category->text = $category->description;
$category->title = $category->catname;
JPluginHelper::importPlugin('content');
$app->triggerEvent('onContentPrepare', array('com_jem.category', &$category, &$params, 0));
$description = $category->text;
}
$cimage = JemImage::flyercreator($category->image,'category');
//create select lists
$this->lists = $lists;
$this->action = $uri->toString();
$this->cimage = $cimage;
$this->rows = $rows;
$this->noevents = $noevents;
$this->category = $category;
$this->print_link = $print_link;
$this->params = $params;
$this->dellink = $dellink;
$this->task = $task;
$this->description = $description;
$this->pagination = $pagination;
$this->jemsettings = $jemsettings;
$this->settings = $settings;
$this->categories = $categories;
$this->pageclass_sfx = htmlspecialchars($pageclass_sfx);
}
parent::display($tpl);
}
}
?>