1 | <?php
|
---|
2 |
|
---|
3 | /***************************************************************************
|
---|
4 | * Dolphin Smart Community Builder
|
---|
5 | * -------------------
|
---|
6 | * begin : Mon Mar 23 2006
|
---|
7 | * copyright : (C) 2007 BoonEx Group
|
---|
8 | * website : http://www.boonex.com
|
---|
9 | * This file is part of Dolphin - Smart Community Builder
|
---|
10 | *
|
---|
11 | * Dolphin is free software; you can redistribute it and/or modify it under
|
---|
12 | * the terms of the GNU General Public License as published by the
|
---|
13 | * Free Software Foundation; either version 2 of the
|
---|
14 | * License, or any later version.
|
---|
15 | *
|
---|
16 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
---|
17 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
18 | * See the GNU General Public License for more details.
|
---|
19 | * You should have received a copy of the GNU General Public License along with Dolphin,
|
---|
20 | * see license.txt file; if not, write to marketing@boonex.com
|
---|
21 | ***************************************************************************/
|
---|
22 |
|
---|
23 | define('BX_CATEG_ACTION_ALL', 'all');
|
---|
24 | define('BX_CATEG_ACTION_COMMON', 'common');
|
---|
25 | define('BX_CATEG_ACTION_USERS', 'users');
|
---|
26 | define('BX_CATEG_ACTION_CALENDAR', 'calendar');
|
---|
27 | define('BX_CATEG_ACTION_SEARCH', 'search');
|
---|
28 |
|
---|
29 | require_once( 'inc/header.inc.php' );
|
---|
30 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
31 |
|
---|
32 | bx_import('BxTemplCategories');
|
---|
33 | bx_import('BxDolPageView');
|
---|
34 | bx_import('BxTemplCalendar');
|
---|
35 |
|
---|
36 | $bAjaxMode = isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? true : false;
|
---|
37 |
|
---|
38 | function showCategories($aParam = array(), $iBoxId = 1, $sAction = '', $isBox = false, $bOrderPanel = false, $sTitle)
|
---|
39 | {
|
---|
40 | $oCateg = new BxTemplCategories();
|
---|
41 |
|
---|
42 | $oCateg->getTagObjectConfig($aParam);
|
---|
43 |
|
---|
44 | if (empty($oCateg->aTagObjects))
|
---|
45 | {
|
---|
46 | if ($isBox)
|
---|
47 | return DesignBoxContent($sTitle, MsgBox(_t('_Empty')), 1);
|
---|
48 | else
|
---|
49 | return MsgBox(_t('_Empty'));
|
---|
50 | }
|
---|
51 |
|
---|
52 | $aParam['type'] = isset($_REQUEST['tags_mode']) ? $_REQUEST['tags_mode'] : $oCateg->getFirstObject();
|
---|
53 |
|
---|
54 | $sCode = $oCateg->display($aParam, $iBoxId, $sAction, $bOrderPanel, getParam('categ_show_columns'));
|
---|
55 |
|
---|
56 | if ($isBox)
|
---|
57 | {
|
---|
58 | $aCaptionMenu = $oCateg->getCategTopMenuHtml($aParam, $iBoxId, $sAction);
|
---|
59 | $sCode = DesignBoxContent($sTitle, $sCode, 1, $aCaptionMenu);
|
---|
60 | $sCode = '<div id="page_block_' . $iBoxId . '">' . $sCode . '<div class="clear_both"></div></div>';
|
---|
61 | return $sCode;
|
---|
62 | }
|
---|
63 | else
|
---|
64 | return array(
|
---|
65 | $sCode,
|
---|
66 | $oCateg->getCategTopMenu($aParam, $sAction),
|
---|
67 | array(),
|
---|
68 | ($sDate ? _t('_categ_by_day') . $sDate : '')
|
---|
69 | );
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 | class CategoriesCalendar extends BxTemplCalendar
|
---|
74 | {
|
---|
75 | function CategoriesCalendar($iYear, $iMonth)
|
---|
76 | {
|
---|
77 | parent::BxTemplCalendar($iYear, $iMonth);
|
---|
78 | }
|
---|
79 |
|
---|
80 | function display() {
|
---|
81 | $aVars = array (
|
---|
82 | 'bx_repeat:week_names' => $this->_getWeekNames (),
|
---|
83 | 'bx_repeat:calendar_row' => $this->_getCalendar (),
|
---|
84 | 'month_prev_url' => $this->getBaseUri () . "&year={$this->iPrevYear}&month={$this->iPrevMonth}",
|
---|
85 | 'month_prev_name' => _t('_month_prev'),
|
---|
86 | 'month_prev_icon' => getTemplateIcon('sys_back.png'),
|
---|
87 | 'month_next_url' => $this->getBaseUri () . "&year={$this->iNextYear}&month={$this->iNextMonth}",
|
---|
88 | 'month_next_name' => _t('_month_next'),
|
---|
89 | 'month_next_icon' => getTemplateIcon('sys_next.png'),
|
---|
90 | 'month_current' => $this->getTitle(),
|
---|
91 | );
|
---|
92 | $sHtml = $GLOBALS['oSysTemplate']->parseHtmlByName('calendar.html', $aVars);
|
---|
93 | $sHtml = preg_replace ('#<bx_repeat:events>.*?</bx_repeat:events>#s', '', $sHtml);
|
---|
94 | $GLOBALS['oSysTemplate']->addCss('calendar.css');
|
---|
95 | return $sHtml;
|
---|
96 | }
|
---|
97 |
|
---|
98 | function getData()
|
---|
99 | {
|
---|
100 | $oDb = new BxDolDb();
|
---|
101 |
|
---|
102 | return $oDb->getAll("SELECT *, DAYOFMONTH(`Date`) AS `Day`
|
---|
103 | FROM `sys_categories`
|
---|
104 | WHERE `Date` >= TIMESTAMP('{$this->iYear}-{$this->iMonth}-1')
|
---|
105 | AND `Date` < TIMESTAMP('{$this->iNextYear}-{$this->iNextMonth}-1')
|
---|
106 | AND `Owner` <> 0 AND `Status` = 'active'");
|
---|
107 | }
|
---|
108 |
|
---|
109 | function getBaseUri()
|
---|
110 | {
|
---|
111 | return BX_DOL_URL_ROOT . 'categories.php?action=calendar';
|
---|
112 | }
|
---|
113 |
|
---|
114 | function getBrowseUri()
|
---|
115 | {
|
---|
116 | return BX_DOL_URL_ROOT . 'categories.php?action=calendar';
|
---|
117 | }
|
---|
118 |
|
---|
119 | function getEntriesNames ()
|
---|
120 | {
|
---|
121 | return array(_t('_categ_single'), _t('_categ_plural'));
|
---|
122 | }
|
---|
123 |
|
---|
124 | function _getCalendar ()
|
---|
125 | {
|
---|
126 | $sBrowseUri = $this->getBrowseUri();
|
---|
127 | list ($sEntriesSingle, $sEntriesMul) = $this->getEntriesNames ();
|
---|
128 |
|
---|
129 | $this->_getCalendarGrid($aCalendarGrid);
|
---|
130 | $aRet = array ();
|
---|
131 | for ($i = 0; $i < 6; $i++) {
|
---|
132 |
|
---|
133 | $aRow = array ('bx_repeat:cell');
|
---|
134 | $isRowEmpty = true;
|
---|
135 |
|
---|
136 | for ($j = $this->iWeekStart; $j < $this->iWeekEnd; $j++) {
|
---|
137 |
|
---|
138 | $aCell = array ();
|
---|
139 |
|
---|
140 | if ($aCalendarGrid[$i][$j]['today']) {
|
---|
141 | $aCell['class'] = 'sys_cal_cell sys_cal_today';
|
---|
142 | $aCell['day'] = $aCalendarGrid[$i][$j]['day'];
|
---|
143 | $aCell['bx_if:num'] = array ('condition' => $aCalendarGrid[$i][$j]['num'], 'content' => array(
|
---|
144 | 'num' => $aCalendarGrid[$i][$j]['num'],
|
---|
145 | 'href' => $sBrowseUri . '&year=' . $this->iYear . '&month=' . $this->iMonth . '&day=' . $aCell['day'],
|
---|
146 | 'entries' => 1 == $aCalendarGrid[$i][$j]['num'] ? $sEntriesSingle : $sEntriesMul,
|
---|
147 | ));
|
---|
148 | $isRowEmpty = false;
|
---|
149 | } elseif (isset($aCalendarGrid[$i][$j]['day'])) {
|
---|
150 | $aCell['class'] = 'sys_cal_cell';
|
---|
151 | $aCell['day'] = $aCalendarGrid[$i][$j]['day'];
|
---|
152 | $aCell['bx_if:num'] = array ('condition' => $aCalendarGrid[$i][$j]['num'], 'content' => array(
|
---|
153 | 'num' => $aCalendarGrid[$i][$j]['num'],
|
---|
154 | 'href' => $sBrowseUri . '&year=' . $this->iYear . '&month=' . $this->iMonth . '&day=' . $aCell['day'],
|
---|
155 | 'entries' => 1 == $aCalendarGrid[$i][$j]['num'] ? $sEntriesSingle : $sEntriesMul,
|
---|
156 | ));
|
---|
157 | $isRowEmpty = false;
|
---|
158 | } else {
|
---|
159 | $aCell['class'] = 'sys_cal_cell_blank';
|
---|
160 | $aCell['day'] = '';
|
---|
161 | $aCell['bx_if:num'] = array ('condition' => false, 'content' => array(
|
---|
162 | 'num' => '',
|
---|
163 | 'href' => '',
|
---|
164 | 'entries' => '',
|
---|
165 | ));
|
---|
166 | }
|
---|
167 |
|
---|
168 | if ($aCell)
|
---|
169 | $aRow['bx_repeat:cell'][] = $aCell;
|
---|
170 | }
|
---|
171 |
|
---|
172 | if ($aRow['bx_repeat:cell'] && !$isRowEmpty) {
|
---|
173 | $aRet[] = $aRow;
|
---|
174 | }
|
---|
175 | }
|
---|
176 | return $aRet;
|
---|
177 | }
|
---|
178 |
|
---|
179 | }
|
---|
180 |
|
---|
181 | class CategoriesCalendarPage extends BxDolPageView
|
---|
182 | {
|
---|
183 | var $sPage;
|
---|
184 |
|
---|
185 | function CategoriesCalendarPage()
|
---|
186 | {
|
---|
187 | $this->sPage = 'categ_calendar';
|
---|
188 | parent::BxDolPageView($this->sPage);
|
---|
189 | }
|
---|
190 |
|
---|
191 | function getBlockCode_Calendar($iBlockId)
|
---|
192 | {
|
---|
193 | $sYear = isset($_REQUEST['year']) ? (int)$_REQUEST['year'] : '';
|
---|
194 | $sMonth = isset($_REQUEST['month']) ? (int)$_REQUEST['month'] : '';
|
---|
195 | $oCalendar = new CategoriesCalendar($sYear, $sMonth);
|
---|
196 |
|
---|
197 | return $oCalendar->display();
|
---|
198 | }
|
---|
199 |
|
---|
200 | function getBlockCode_CategoriesDate($iBlockId)
|
---|
201 | {
|
---|
202 | if (isset($_REQUEST['year']) && isset($_REQUEST['month']) && isset($_REQUEST['day']))
|
---|
203 | {
|
---|
204 | $aParam = array(
|
---|
205 | 'pagination' => getParam('categ_perpage_browse'),
|
---|
206 | 'date' => array(
|
---|
207 | 'year' => (int)$_REQUEST['year'],
|
---|
208 | 'month' => (int)$_REQUEST['month'],
|
---|
209 | 'day' => (int)$_REQUEST['day']
|
---|
210 | )
|
---|
211 | );
|
---|
212 |
|
---|
213 | return showCategories($aParam, $iBlockId, BX_CATEG_ACTION_CALENDAR, false, false, _t('_categ_caption_calendar'));
|
---|
214 | }
|
---|
215 | else
|
---|
216 | return MsgBox(_t('_Empty'));
|
---|
217 | }
|
---|
218 | }
|
---|
219 |
|
---|
220 | class CategoriesSearchPage extends BxDolPageView {
|
---|
221 |
|
---|
222 | var $aSearchForm;
|
---|
223 | var $oForm;
|
---|
224 | var $sPage;
|
---|
225 |
|
---|
226 | function CategoriesSearchPage()
|
---|
227 | {
|
---|
228 | $this->sPage = 'categ_search';
|
---|
229 | parent::BxDolPageView($this->sPage);
|
---|
230 |
|
---|
231 | bx_import('BxTemplFormView');
|
---|
232 | $this->aSearchForm = array(
|
---|
233 | 'form_attrs' => array(
|
---|
234 | 'name' => 'form_search_categories',
|
---|
235 | 'action' => '',
|
---|
236 | 'method' => 'post',
|
---|
237 | ),
|
---|
238 |
|
---|
239 | 'params' => array (
|
---|
240 | 'db' => array(
|
---|
241 | 'submit_name' => 'submit_form',
|
---|
242 | ),
|
---|
243 | ),
|
---|
244 |
|
---|
245 | 'inputs' => array(
|
---|
246 | 'Keyword' => array(
|
---|
247 | 'type' => 'text',
|
---|
248 | 'name' => 'Keyword',
|
---|
249 | 'caption' => _t('_categ_caption_keyword'),
|
---|
250 | 'required' => true,
|
---|
251 | 'checker' => array (
|
---|
252 | 'func' => 'length',
|
---|
253 | 'params' => array(1, 100),
|
---|
254 | 'error' => _t ('_categ_err_keyword'),
|
---|
255 | ),
|
---|
256 | 'db' => array (
|
---|
257 | 'pass' => 'Xss',
|
---|
258 | ),
|
---|
259 | ),
|
---|
260 | 'Submit' => array (
|
---|
261 | 'type' => 'submit',
|
---|
262 | 'name' => 'submit_form',
|
---|
263 | 'value' => _t('_Submit'),
|
---|
264 | 'colspan' => true,
|
---|
265 | ),
|
---|
266 | ),
|
---|
267 | );
|
---|
268 |
|
---|
269 | $this->oForm = new BxTemplFormView($this->aSearchForm);
|
---|
270 | $this->oForm->initChecker();
|
---|
271 | }
|
---|
272 |
|
---|
273 | function getBlockCode_Form()
|
---|
274 | {
|
---|
275 | return $GLOBALS['oSysTemplate']->parseHtmlByName('search_tags_box.html', array('form' => $this->oForm->getCode()));
|
---|
276 | }
|
---|
277 |
|
---|
278 | function getBlockCode_Founded($iBlockId)
|
---|
279 | {
|
---|
280 | $aParam = array(
|
---|
281 | 'pagination' => getParam('categ_perpage_browse')
|
---|
282 | );
|
---|
283 |
|
---|
284 | if (isset($_REQUEST['filter']))
|
---|
285 | $aParam['filter'] = $_REQUEST['filter'];
|
---|
286 | else if ($this->oForm->isSubmittedAndValid())
|
---|
287 | $aParam['filter'] = $this->oForm->getCleanValue('Keyword');
|
---|
288 |
|
---|
289 | if (isset($aParam['filter']))
|
---|
290 | return showCategories($aParam, $iBlockId, BX_CATEG_ACTION_SEARCH, false, false, _t('_categ_caption_founded_categ'));
|
---|
291 | else
|
---|
292 | return MsgBox(_t('_Empty'));
|
---|
293 | }
|
---|
294 | }
|
---|
295 |
|
---|
296 | function getPage_All()
|
---|
297 | {
|
---|
298 | $aParam = array(
|
---|
299 | 'pagination' => getParam('categ_perpage_browse')
|
---|
300 | );
|
---|
301 |
|
---|
302 | return showCategories($aParam, 1, BX_CATEG_ACTION_ALL, true, true, _t('_categ_caption_all'));
|
---|
303 | }
|
---|
304 |
|
---|
305 | function getPage_Common()
|
---|
306 | {
|
---|
307 | $aParam = array(
|
---|
308 | 'pagination' => getParam('categ_perpage_browse'),
|
---|
309 | 'common' => true,
|
---|
310 | );
|
---|
311 |
|
---|
312 | return showCategories($aParam, 1, BX_CATEG_ACTION_COMMON, true, false, _t('_categ_caption_common'));
|
---|
313 | }
|
---|
314 |
|
---|
315 | function getPage_Users()
|
---|
316 | {
|
---|
317 | $aParam = array(
|
---|
318 | 'pagination' => getParam('categ_perpage_browse'),
|
---|
319 | 'common' => false
|
---|
320 | );
|
---|
321 |
|
---|
322 | return showCategories($aParam, 1, BX_CATEG_ACTION_USERS, true, false, _t('_categ_caption_users'));
|
---|
323 | }
|
---|
324 |
|
---|
325 | function getPage_Calendar()
|
---|
326 | {
|
---|
327 | $oCalendarPage = new CategoriesCalendarPage();
|
---|
328 |
|
---|
329 | return $oCalendarPage->getCode();
|
---|
330 | }
|
---|
331 |
|
---|
332 | function getPage_Search()
|
---|
333 | {
|
---|
334 | $oSearchPage = new CategoriesSearchPage();
|
---|
335 |
|
---|
336 | return $oSearchPage->getCode();
|
---|
337 | }
|
---|
338 |
|
---|
339 | switch ($_REQUEST['action'])
|
---|
340 | {
|
---|
341 | case BX_CATEG_ACTION_COMMON:
|
---|
342 | $sContent = getPage_Common();
|
---|
343 | break;
|
---|
344 |
|
---|
345 | case BX_CATEG_ACTION_USERS:
|
---|
346 | $sContent = getPage_Users();
|
---|
347 | break;
|
---|
348 |
|
---|
349 | case BX_CATEG_ACTION_CALENDAR:
|
---|
350 | $sContent = getPage_Calendar();
|
---|
351 | break;
|
---|
352 |
|
---|
353 | case BX_CATEG_ACTION_SEARCH:
|
---|
354 | $sContent = getPage_Search();
|
---|
355 | break;
|
---|
356 |
|
---|
357 | default:
|
---|
358 | $sContent = getPage_All();
|
---|
359 | }
|
---|
360 |
|
---|
361 | if (!$bAjaxMode)
|
---|
362 | {
|
---|
363 | global $_page;
|
---|
364 | global $_page_cont;
|
---|
365 | $iIndex = 25;
|
---|
366 |
|
---|
367 | $_page['name_index'] = $iIndex;
|
---|
368 | $_page['css_name'] = 'tags.css';
|
---|
369 |
|
---|
370 | $_page['header'] = _t('_Categories');
|
---|
371 | $_page['header_text'] = _t('_Categories');
|
---|
372 | $_page_cont[$iIndex]['page_main_code'] = $sContent;
|
---|
373 |
|
---|
374 | check_logged();
|
---|
375 | PageCode();
|
---|
376 | }
|
---|
377 | else
|
---|
378 | echo $sContent;
|
---|
379 |
|
---|
380 | ?> |
---|