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_TAGS_ACTION_HOME', 'home');
|
---|
24 | define('BX_TAGS_ACTION_ALL', 'all');
|
---|
25 | define('BX_TAGS_ACTION_POPULAR', 'popular');
|
---|
26 | define('BX_TAGS_ACTION_CALENDAR', 'calendar');
|
---|
27 | define('BX_TAGS_ACTION_SEARCH', 'search');
|
---|
28 |
|
---|
29 | define('BX_TAGS_BOX_DISIGN', 1);
|
---|
30 | define('BX_TAGS_BOX_INT_MENU', 2);
|
---|
31 |
|
---|
32 | require_once( 'inc/header.inc.php' );
|
---|
33 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
34 |
|
---|
35 | bx_import('BxTemplTags');
|
---|
36 | bx_import('BxDolPageView');
|
---|
37 | bx_import('BxTemplCalendar');
|
---|
38 |
|
---|
39 | $bAjaxMode = isset($_SERVER['HTTP_X_REQUESTED_WITH']) and $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ? true : false;
|
---|
40 |
|
---|
41 | function showTags($aParam = array(), $iBoxId = 1, $sAction = '', $iBox = 0, $sTitle = '')
|
---|
42 | {
|
---|
43 | $oTags = new BxTemplTags();
|
---|
44 |
|
---|
45 | $oTags->getTagObjectConfig($aParam);
|
---|
46 |
|
---|
47 | if (empty($oTags->aTagObjects))
|
---|
48 | {
|
---|
49 | if ($iBox & BX_TAGS_BOX_DISIGN)
|
---|
50 | return DesignBoxContent($sTitle, MsgBox(_t('_Empty')), 1);
|
---|
51 | else
|
---|
52 | return MsgBox(_t('_Empty'));
|
---|
53 | }
|
---|
54 |
|
---|
55 | $aParam['type'] = isset($_REQUEST['tags_mode']) ? $_REQUEST['tags_mode'] : $oTags->getFirstObject();
|
---|
56 |
|
---|
57 | $sCode = '';
|
---|
58 | if ($iBox & BX_TAGS_BOX_INT_MENU)
|
---|
59 | $sCode .= $oTags->getTagsInternalMenuHtml($aParam, $iBoxId, $sAction);
|
---|
60 | $sCode .= $oTags->display($aParam, $iBoxId, $sAction);
|
---|
61 |
|
---|
62 | if ($iBox & BX_TAGS_BOX_DISIGN)
|
---|
63 | {
|
---|
64 | $aCaptionMenu = $iBox & BX_TAGS_BOX_INT_MENU ? '' : $oTags->getTagsTopMenuHtml($aParam, $iBoxId, $sAction);
|
---|
65 | $sCode = DesignBoxContent($sTitle, $sCode, 1, $aCaptionMenu);
|
---|
66 | $sCode = '<div id="page_block_' . $iBoxId . '">' . $sCode . '<div class="clear_both"></div></div>';
|
---|
67 | return $sCode;
|
---|
68 | }
|
---|
69 | else
|
---|
70 | return array(
|
---|
71 | $sCode,
|
---|
72 | ($iBox & BX_TAGS_BOX_INT_MENU ? '' : $oTags->getTagsTopMenu($aParam, $sAction)),
|
---|
73 | array(),
|
---|
74 | ($sDate ? _t('_tags_by_day') . $sDate : '')
|
---|
75 | );
|
---|
76 | }
|
---|
77 |
|
---|
78 | class TagsCalendar extends BxTemplCalendar
|
---|
79 | {
|
---|
80 | function TagsCalendar($iYear, $iMonth)
|
---|
81 | {
|
---|
82 | parent::BxTemplCalendar($iYear, $iMonth);
|
---|
83 | }
|
---|
84 |
|
---|
85 | function display() {
|
---|
86 | $aVars = array (
|
---|
87 | 'bx_repeat:week_names' => $this->_getWeekNames (),
|
---|
88 | 'bx_repeat:calendar_row' => $this->_getCalendar (),
|
---|
89 | 'month_prev_url' => $this->getBaseUri () . "&year={$this->iPrevYear}&month={$this->iPrevMonth}",
|
---|
90 | 'month_prev_name' => _t('_month_prev'),
|
---|
91 | 'month_prev_icon' => getTemplateIcon('sys_back.png'),
|
---|
92 | 'month_next_url' => $this->getBaseUri () . "&year={$this->iNextYear}&month={$this->iNextMonth}",
|
---|
93 | 'month_next_name' => _t('_month_next'),
|
---|
94 | 'month_next_icon' => getTemplateIcon('sys_next.png'),
|
---|
95 | 'month_current' => $this->getTitle(),
|
---|
96 | );
|
---|
97 | $sHtml = $GLOBALS['oSysTemplate']->parseHtmlByName('calendar.html', $aVars);
|
---|
98 | $sHtml = preg_replace ('#<bx_repeat:events>.*?</bx_repeat:events>#s', '', $sHtml);
|
---|
99 | $GLOBALS['oSysTemplate']->addCss('calendar.css');
|
---|
100 | return $sHtml;
|
---|
101 | }
|
---|
102 |
|
---|
103 | function getData()
|
---|
104 | {
|
---|
105 | $oDb = new BxDolDb();
|
---|
106 |
|
---|
107 | return $oDb->getAll("SELECT *, DAYOFMONTH(`Date`) AS `Day`
|
---|
108 | FROM `sys_tags`
|
---|
109 | WHERE `Date` >= TIMESTAMP('{$this->iYear}-{$this->iMonth}-1') AND `Date` < TIMESTAMP('{$this->iNextYear}-{$this->iNextMonth}-1')");
|
---|
110 | }
|
---|
111 |
|
---|
112 | function getBaseUri()
|
---|
113 | {
|
---|
114 | return BX_DOL_URL_ROOT . 'tags.php?action=calendar';
|
---|
115 | }
|
---|
116 |
|
---|
117 | function getBrowseUri()
|
---|
118 | {
|
---|
119 | return BX_DOL_URL_ROOT . 'tags.php?action=calendar';
|
---|
120 | }
|
---|
121 |
|
---|
122 | function getEntriesNames ()
|
---|
123 | {
|
---|
124 | return array(_t('_tags_single'), _t('_tags_plural'));
|
---|
125 | }
|
---|
126 |
|
---|
127 | function _getCalendar ()
|
---|
128 | {
|
---|
129 | $sBrowseUri = $this->getBrowseUri();
|
---|
130 | list ($sEntriesSingle, $sEntriesMul) = $this->getEntriesNames ();
|
---|
131 |
|
---|
132 | $this->_getCalendarGrid($aCalendarGrid);
|
---|
133 | $aRet = array ();
|
---|
134 | for ($i = 0; $i < 6; $i++) {
|
---|
135 |
|
---|
136 | $aRow = array ('bx_repeat:cell');
|
---|
137 | $isRowEmpty = true;
|
---|
138 |
|
---|
139 | for ($j = $this->iWeekStart; $j < $this->iWeekEnd; $j++) {
|
---|
140 |
|
---|
141 | $aCell = array ();
|
---|
142 |
|
---|
143 | if ($aCalendarGrid[$i][$j]['today']) {
|
---|
144 | $aCell['class'] = 'sys_cal_cell sys_cal_today';
|
---|
145 | $aCell['day'] = $aCalendarGrid[$i][$j]['day'];
|
---|
146 | $aCell['bx_if:num'] = array ('condition' => $aCalendarGrid[$i][$j]['num'], 'content' => array(
|
---|
147 | 'num' => $aCalendarGrid[$i][$j]['num'],
|
---|
148 | 'href' => $sBrowseUri . '&year=' . $this->iYear . '&month=' . $this->iMonth . '&day=' . $aCell['day'],
|
---|
149 | 'entries' => 1 == $aCalendarGrid[$i][$j]['num'] ? $sEntriesSingle : $sEntriesMul,
|
---|
150 | ));
|
---|
151 | $isRowEmpty = false;
|
---|
152 | } elseif (isset($aCalendarGrid[$i][$j]['day'])) {
|
---|
153 | $aCell['class'] = 'sys_cal_cell';
|
---|
154 | $aCell['day'] = $aCalendarGrid[$i][$j]['day'];
|
---|
155 | $aCell['bx_if:num'] = array ('condition' => $aCalendarGrid[$i][$j]['num'], 'content' => array(
|
---|
156 | 'num' => $aCalendarGrid[$i][$j]['num'],
|
---|
157 | 'href' => $sBrowseUri . '&year=' . $this->iYear . '&month=' . $this->iMonth . '&day=' . $aCell['day'],
|
---|
158 | 'entries' => 1 == $aCalendarGrid[$i][$j]['num'] ? $sEntriesSingle : $sEntriesMul,
|
---|
159 | ));
|
---|
160 | $isRowEmpty = false;
|
---|
161 | } else {
|
---|
162 | $aCell['class'] = 'sys_cal_cell_blank';
|
---|
163 | $aCell['day'] = '';
|
---|
164 | $aCell['bx_if:num'] = array ('condition' => false, 'content' => array(
|
---|
165 | 'num' => '',
|
---|
166 | 'href' => '',
|
---|
167 | 'entries' => '',
|
---|
168 | ));
|
---|
169 | }
|
---|
170 |
|
---|
171 | if ($aCell)
|
---|
172 | $aRow['bx_repeat:cell'][] = $aCell;
|
---|
173 | }
|
---|
174 |
|
---|
175 | if ($aRow['bx_repeat:cell'] && !$isRowEmpty) {
|
---|
176 | $aRet[] = $aRow;
|
---|
177 | }
|
---|
178 | }
|
---|
179 | return $aRet;
|
---|
180 | }
|
---|
181 |
|
---|
182 | }
|
---|
183 |
|
---|
184 | class TagsHomePage extends BxDolPageView
|
---|
185 | {
|
---|
186 | var $sPage;
|
---|
187 |
|
---|
188 | function TagsHomePage()
|
---|
189 | {
|
---|
190 | $this->sPage = 'tags_home';
|
---|
191 | parent::BxDolPageView($this->sPage);
|
---|
192 | }
|
---|
193 |
|
---|
194 | function getBlockCode_Recent($iBlockId)
|
---|
195 | {
|
---|
196 | $aParam = array(
|
---|
197 | 'orderby' => 'recent',
|
---|
198 | 'limit' => getParam('tags_show_limit'),
|
---|
199 | );
|
---|
200 |
|
---|
201 | return showTags($aParam, $iBlockId, BX_TAGS_ACTION_HOME, BX_TAGS_BOX_INT_MENU, _t('_tags_recent'));
|
---|
202 | }
|
---|
203 |
|
---|
204 | function getBlockCode_Popular($iBlockId)
|
---|
205 | {
|
---|
206 | $aParam = array(
|
---|
207 | 'orderby' => 'popular',
|
---|
208 | 'limit' => getParam('tags_show_limit')
|
---|
209 | );
|
---|
210 |
|
---|
211 | return showTags($aParam, $iBlockId, BX_TAGS_ACTION_HOME, 0, _t('_tags_popular'));
|
---|
212 | }
|
---|
213 | }
|
---|
214 |
|
---|
215 | class TagsCalendarPage extends BxDolPageView
|
---|
216 | {
|
---|
217 | var $sPage;
|
---|
218 |
|
---|
219 | function TagsCalendarPage()
|
---|
220 | {
|
---|
221 | $this->sPage = 'tags_calendar';
|
---|
222 | parent::BxDolPageView($this->sPage);
|
---|
223 | }
|
---|
224 |
|
---|
225 | function getBlockCode_Calendar($iBlockId)
|
---|
226 | {
|
---|
227 | $sYear = isset($_REQUEST['year']) ? (int)$_REQUEST['year'] : '';
|
---|
228 | $sMonth = isset($_REQUEST['month']) ? (int)$_REQUEST['month'] : '';
|
---|
229 | $oCalendar = new TagsCalendar($sYear, $sMonth);
|
---|
230 |
|
---|
231 | return $oCalendar->display();
|
---|
232 | }
|
---|
233 |
|
---|
234 | function getBlockCode_TagsDate($iBlockId)
|
---|
235 | {
|
---|
236 | if (isset($_REQUEST['year']) && isset($_REQUEST['month']) && isset($_REQUEST['day']))
|
---|
237 | {
|
---|
238 | $aParam = array(
|
---|
239 | 'pagination' => getParam('tags_perpage_browse'),
|
---|
240 | 'date' => array(
|
---|
241 | 'year' => (int)$_REQUEST['year'],
|
---|
242 | 'month' => (int)$_REQUEST['month'],
|
---|
243 | 'day' => (int)$_REQUEST['day']
|
---|
244 | )
|
---|
245 | );
|
---|
246 |
|
---|
247 | return showTags($aParam, $iBlockId, BX_TAGS_ACTION_CALENDAR, 0, _t('_tags_by_day'));
|
---|
248 | }
|
---|
249 | else
|
---|
250 | return MsgBox(_t('_Empty'));
|
---|
251 | }
|
---|
252 | }
|
---|
253 |
|
---|
254 | class TagsSearchPage extends BxDolPageView {
|
---|
255 |
|
---|
256 | var $aSearchForm;
|
---|
257 | var $oForm;
|
---|
258 | var $sPage;
|
---|
259 |
|
---|
260 | function TagsSearchPage()
|
---|
261 | {
|
---|
262 | $this->sPage = 'tags_search';
|
---|
263 | parent::BxDolPageView($this->sPage);
|
---|
264 |
|
---|
265 | bx_import('BxTemplFormView');
|
---|
266 | $this->aSearchForm = array(
|
---|
267 | 'form_attrs' => array(
|
---|
268 | 'name' => 'form_search_tags',
|
---|
269 | 'action' => '',
|
---|
270 | 'method' => 'post',
|
---|
271 | ),
|
---|
272 |
|
---|
273 | 'params' => array (
|
---|
274 | 'db' => array(
|
---|
275 | 'submit_name' => 'submit_form',
|
---|
276 | ),
|
---|
277 | ),
|
---|
278 |
|
---|
279 | 'inputs' => array(
|
---|
280 | 'Keyword' => array(
|
---|
281 | 'type' => 'text',
|
---|
282 | 'name' => 'Keyword',
|
---|
283 | 'caption' => _t('_tags_caption_keyword'),
|
---|
284 | 'required' => true,
|
---|
285 | 'checker' => array (
|
---|
286 | 'func' => 'length',
|
---|
287 | 'params' => array(1, 100),
|
---|
288 | 'error' => _t ('_tags_err_keyword'),
|
---|
289 | ),
|
---|
290 | 'db' => array (
|
---|
291 | 'pass' => 'Xss',
|
---|
292 | ),
|
---|
293 | ),
|
---|
294 | 'Submit' => array (
|
---|
295 | 'type' => 'submit',
|
---|
296 | 'name' => 'submit_form',
|
---|
297 | 'value' => _t('_Submit'),
|
---|
298 | 'colspan' => true,
|
---|
299 | ),
|
---|
300 | ),
|
---|
301 | );
|
---|
302 |
|
---|
303 | $this->oForm = new BxTemplFormView($this->aSearchForm);
|
---|
304 | $this->oForm->initChecker();
|
---|
305 | }
|
---|
306 |
|
---|
307 | function getBlockCode_Form()
|
---|
308 | {
|
---|
309 | return $GLOBALS['oSysTemplate']->parseHtmlByName('search_tags_box.html', array('form' => $this->oForm->getCode()));
|
---|
310 | }
|
---|
311 |
|
---|
312 | function getBlockCode_Founded($iBlockId)
|
---|
313 | {
|
---|
314 | $aParam = array(
|
---|
315 | 'pagination' => getParam('tags_perpage_browse')
|
---|
316 | );
|
---|
317 |
|
---|
318 | if (isset($_REQUEST['filter']))
|
---|
319 | $aParam['filter'] = $_REQUEST['filter'];
|
---|
320 | else if ($this->oForm->isSubmittedAndValid())
|
---|
321 | $aParam['filter'] = $this->oForm->getCleanValue('Keyword');
|
---|
322 |
|
---|
323 | if (isset($aParam['filter']))
|
---|
324 | return showTags($aParam, $iBlockId, BX_TAGS_ACTION_SEARCH, 0, _t('_tags_founded_tags'));
|
---|
325 | else
|
---|
326 | return MsgBox(_t('_Empty'));
|
---|
327 | }
|
---|
328 | }
|
---|
329 |
|
---|
330 | function getPage_Home()
|
---|
331 | {
|
---|
332 | $oHomePage = new TagsHomePage();
|
---|
333 |
|
---|
334 | return $oHomePage->getCode();
|
---|
335 | }
|
---|
336 |
|
---|
337 | function getPage_All()
|
---|
338 | {
|
---|
339 | $aParam = array(
|
---|
340 | 'pagination' => getParam('tags_perpage_browse')
|
---|
341 | );
|
---|
342 |
|
---|
343 | return showTags($aParam, 1, BX_TAGS_ACTION_ALL, BX_TAGS_BOX_DISIGN, _t('_all_tags'));
|
---|
344 | }
|
---|
345 |
|
---|
346 | function getPage_Popular()
|
---|
347 | {
|
---|
348 | $aParam = array(
|
---|
349 | 'orderby' => 'popular',
|
---|
350 | 'limit' => getParam('tags_show_limit')
|
---|
351 | );
|
---|
352 |
|
---|
353 | return showTags($aParam, 2, BX_TAGS_ACTION_POPULAR, BX_TAGS_BOX_DISIGN, _t('_popular_tags'));
|
---|
354 | }
|
---|
355 |
|
---|
356 | function getPage_Calendar()
|
---|
357 | {
|
---|
358 | $oCalendarPage = new TagsCalendarPage();
|
---|
359 |
|
---|
360 | return $oCalendarPage->getCode();
|
---|
361 | }
|
---|
362 |
|
---|
363 | function getPage_Search()
|
---|
364 | {
|
---|
365 | $oSearchPage = new TagsSearchPage();
|
---|
366 |
|
---|
367 | return $oSearchPage->getCode();
|
---|
368 | }
|
---|
369 |
|
---|
370 | switch ($_REQUEST['action'])
|
---|
371 | {
|
---|
372 | case BX_TAGS_ACTION_POPULAR:
|
---|
373 | $sContent = getPage_Popular();
|
---|
374 | break;
|
---|
375 |
|
---|
376 | case BX_TAGS_ACTION_ALL:
|
---|
377 | $sContent = getPage_All();
|
---|
378 | break;
|
---|
379 |
|
---|
380 | case BX_TAGS_ACTION_CALENDAR:
|
---|
381 | $sContent = getPage_Calendar();
|
---|
382 | break;
|
---|
383 |
|
---|
384 | case BX_TAGS_ACTION_SEARCH:
|
---|
385 | $sContent = getPage_Search();
|
---|
386 | break;
|
---|
387 |
|
---|
388 | default:
|
---|
389 | $sContent = getPage_Home();
|
---|
390 | }
|
---|
391 |
|
---|
392 | if (!$bAjaxMode)
|
---|
393 | {
|
---|
394 | global $_page;
|
---|
395 | global $_page_cont;
|
---|
396 | $iIndex = 25;
|
---|
397 |
|
---|
398 | $_page['name_index'] = $iIndex;
|
---|
399 | $_page['css_name'] = 'tags.css';
|
---|
400 |
|
---|
401 | $_page['header'] = _t('_Tags');
|
---|
402 | $_page['header_text'] = _t('_Tags');
|
---|
403 | $_page_cont[$iIndex]['page_main_code'] = $sContent;
|
---|
404 |
|
---|
405 | check_logged();
|
---|
406 | PageCode();
|
---|
407 | }
|
---|
408 | else
|
---|
409 | echo $sContent;
|
---|
410 |
|
---|
411 | ?> |
---|