Cheetah
ChGroupsSearchResult.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbTwigSearchResult');
9 
11 {
12  var $aCurrent = array(
13  'name' => 'ch_groups',
14  'title' => '_ch_groups_page_title_browse',
15  'table' => 'ch_groups_main',
16  'ownFields' => array('id', 'title', 'uri', 'created', 'author_id', 'thumb', 'rate', 'fans_count', 'country', 'city', 'desc'),
17  'searchFields' => array('title', 'desc', 'tags', 'categories'),
18  'join' => array(
19  'profile' => array(
20  'type' => 'left',
21  'table' => 'Profiles',
22  'mainField' => 'author_id',
23  'onField' => 'ID',
24  'joinFields' => array('NickName'),
25  ),
26  ),
27  'restriction' => array(
28  'activeStatus' => array('value' => 'approved', 'field'=>'status', 'operator'=>'='),
29  'owner' => array('value' => '', 'field' => 'author_id', 'operator' => '='),
30  'tag' => array('value' => '', 'field' => 'tags', 'operator' => 'against'),
31  'category' => array('value' => '', 'field' => 'Category', 'operator' => '=', 'table' => 'sys_categories'),
32  'category_type' => array('value' => '', 'field' => 'Type', 'operator' => '=', 'table' => 'sys_categories'),
33  'public' => array('value' => '', 'field' => 'allow_view_group_to', 'operator' => '='),
34  ),
35  'paginate' => array('perPage' => 14, 'page' => 1, 'totalNum' => 0, 'totalPages' => 1),
36  'sorting' => 'last',
37  'rss' => array(
38  'title' => '',
39  'link' => '',
40  'image' => '',
41  'profile' => 0,
42  'fields' => array (
43  'Link' => '',
44  'Title' => 'title',
45  'DateTimeUTS' => 'created',
46  'Desc' => 'desc',
47  'Image' => 'thumb',
48  ),
49  ),
50  'ident' => 'id'
51  );
52 
53  function __construct($sMode = '', $sValue = '', $sValue2 = '', $sValue3 = '')
54  {
55  switch ($sMode) {
56 
57  case 'pending':
58  if (false !== ch_get('ch_groups_filter'))
59  $this->aCurrent['restriction']['keyword'] = array('value' => process_db_input(ch_get('ch_groups_filter'), CH_TAGS_STRIP), 'field' => '','operator' => 'against');
60  $this->aCurrent['restriction']['activeStatus']['value'] = 'pending';
61  $this->sBrowseUrl = "administration";
62  $this->aCurrent['title'] = _t('_ch_groups_page_title_pending_approval');
63  unset($this->aCurrent['rss']);
64  break;
65 
66  case 'my_pending':
67  $oMain = $this->getMain();
68  $this->aCurrent['restriction']['owner']['value'] = $oMain->_iProfileId;
69  $this->aCurrent['restriction']['activeStatus']['value'] = 'pending';
70  $this->sBrowseUrl = "browse/user/" . getNickName($oMain->_iProfileId);
71  $this->aCurrent['title'] = _t('_ch_groups_page_title_pending_approval');
72  unset($this->aCurrent['rss']);
73  break;
74 
75  case 'search':
76  if ($sValue)
77  $this->aCurrent['restriction']['keyword'] = array('value' => $sValue,'field' => '','operator' => 'against');
78 
79  if ($sValue2) {
80 
81  $this->aCurrent['join']['category'] = array(
82  'type' => 'inner',
83  'table' => 'sys_categories',
84  'mainField' => 'id',
85  'onField' => 'ID',
86  'joinFields' => '',
87  );
88 
89  $this->aCurrent['restriction']['category_type']['value'] = $this->aCurrent['name'];
90  $this->aCurrent['restriction']['category']['value'] = $sValue2;
91  if (is_array($sValue2)) {
92  $this->aCurrent['restriction']['category']['operator'] = 'in';
93  }
94  }
95 
96  $sValue = $GLOBALS['MySQL']->unescape($sValue);
97  $sValue2 = $GLOBALS['MySQL']->unescape($sValue2);
98  $this->sBrowseUrl = "search/$sValue/" . (is_array($sValue2) ? implode(',',$sValue2) : $sValue2);
99  $this->aCurrent['title'] = _t('_ch_groups_page_title_search_results') . ' ' . (is_array($sValue2) ? implode(', ',$sValue2) : $sValue2) . ' ' . $sValue;
100  unset($this->aCurrent['rss']);
101  break;
102 
103  case 'user':
104  $iProfileId = $GLOBALS['oChGroupsModule']->_oDb->getProfileIdByNickName ($sValue, false);
105  $GLOBALS['oTopMenu']->setCurrentProfileID($iProfileId); // select profile subtab, instead of module tab
106  if (!$iProfileId)
107  $this->isError = true;
108  else
109  $this->aCurrent['restriction']['owner']['value'] = $iProfileId;
110  $sValue = $GLOBALS['MySQL']->unescape($sValue);
111  $this->sBrowseUrl = "browse/user/$sValue";
112 
113  $iProfileId = getID($sValue);
114  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_by_author', $iProfileId ? getNickName($iProfileId) : $sValue);
115 
116  if (ch_get('rss')) {
117  $aData = getProfileInfo($iProfileId);
118  if ($aData['Avatar']) {
119  $a = array ('ID' => $aData['author_id'], 'Avatar' => $aData['thumb']);
120  $aImage = ChWsbService::call('photos', 'get_image', array($a, 'browse'), 'Search');
121  if (!$aImage['no_image'])
122  $this->aCurrent['rss']['image'] = $aImage['file'];
123  }
124  }
125  break;
126 
127  case 'joined':
128  $iProfileId = $GLOBALS['oChGroupsModule']->_oDb->getProfileIdByNickName ($sValue, false);
129  $GLOBALS['oTopMenu']->setCurrentProfileID($iProfileId); // select profile subtab, instead of module tab
130 
131  if (!$iProfileId) {
132 
133  $this->isError = true;
134 
135  } else {
136 
137  $this->aCurrent['join']['fans'] = array(
138  'type' => 'inner',
139  'table' => 'ch_groups_fans',
140  'mainField' => 'id',
141  'onField' => 'id_entry',
142  'joinFields' => array('id_profile'),
143  );
144  $this->aCurrent['restriction']['fans'] = array(
145  'value' => $iProfileId,
146  'field' => 'id_profile',
147  'operator' => '=',
148  'table' => 'ch_groups_fans',
149  );
150  $this->aCurrent['restriction']['confirmed_fans'] = array(
151  'value' => 1,
152  'field' => 'confirmed',
153  'operator' => '=',
154  'table' => 'ch_groups_fans',
155  );
156  }
157 
158  $sValue = $GLOBALS['MySQL']->unescape($sValue);
159  $this->sBrowseUrl = "browse/joined/$sValue";
160 
161  $iProfileId = getID($sValue);
162  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_by_author_joined_groups', $iProfileId ? getNickName($iProfileId) : $sValue);
163 
164  if (ch_get('rss')) {
165  $aData = getProfileInfo($iProfileId);
166  if ($aData['Avatar']) {
167  $a = array ('ID' => $aData['author_id'], 'Avatar' => $aData['thumb']);
168  $aImage = ChWsbService::call('photos', 'get_image', array($a, 'browse'), 'Search');
169  if (!$aImage['no_image'])
170  $this->aCurrent['rss']['image'] = $aImage['file'];
171  }
172  }
173  break;
174 
175  case 'admin':
176  if (false !== ch_get('ch_groups_filter'))
177  $this->aCurrent['restriction']['keyword'] = array('value' => process_db_input(ch_get('ch_groups_filter'), CH_TAGS_STRIP), 'field' => '','operator' => 'against');
178  $this->aCurrent['restriction']['owner']['value'] = 0;
179  $this->sBrowseUrl = "browse/admin";
180  $this->aCurrent['title'] = _t('_ch_groups_page_title_admin_groups');
181  break;
182 
183  case 'category':
184  $this->aCurrent['join']['category'] = array(
185  'type' => 'inner',
186  'table' => 'sys_categories',
187  'mainField' => 'id',
188  'onField' => 'ID',
189  'joinFields' => '',
190  );
191  $this->aCurrent['restriction']['category_type']['value'] = $this->aCurrent['name'];
192  $this->aCurrent['restriction']['category']['value'] = $sValue;
193  $sValue = $GLOBALS['MySQL']->unescape($sValue);
194  $this->sBrowseUrl = "browse/category/" . title2uri($sValue);
195  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_by_category', $sValue);
196  break;
197 
198  case 'tag':
199  $this->aCurrent['restriction']['tag']['value'] = $sValue;
200  $sValue = $GLOBALS['MySQL']->unescape($sValue);
201  $this->sBrowseUrl = "browse/tag/" . title2uri($sValue);
202  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_by_tag', $sValue);
203  break;
204 
205  case 'recent':
206  $this->sBrowseUrl = 'browse/recent';
207  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_recent');
208  break;
209 
210  case 'top':
211  $this->sBrowseUrl = 'browse/top';
212  $this->aCurrent['sorting'] = 'top';
213  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_top_rated');
214  break;
215 
216  case 'popular':
217  $this->sBrowseUrl = 'browse/popular';
218  $this->aCurrent['sorting'] = 'popular';
219  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_popular');
220  break;
221 
222  case 'featured':
223  $this->aCurrent['restriction']['featured'] = array('value' => 1, 'field' => 'featured', 'operator' => '=');
224  $this->sBrowseUrl = 'browse/featured';
225  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_featured');
226  break;
227 
228  case 'calendar':
229  $this->aCurrent['restriction']['calendar-min'] = array('value' => "UNIX_TIMESTAMP('{$sValue}-{$sValue2}-{$sValue3} 00:00:00')", 'field' => 'created', 'operator' => '>=', 'no_quote_value' => true);
230  $this->aCurrent['restriction']['calendar-max'] = array('value' => "UNIX_TIMESTAMP('{$sValue}-{$sValue2}-{$sValue3} 23:59:59')", 'field' => 'created', 'operator' => '<=', 'no_quote_value' => true);
231  $this->sEventsBrowseUrl = "browse/calendar/{$sValue}/{$sValue2}/{$sValue3}";
232  $this->aCurrent['title'] = _t('_ch_groups_page_title_browse_by_day', getLocaleDate(strtotime("{$sValue}-{$sValue2}-{$sValue3}"), CH_WSB_LOCALE_DATE_SHORT));
233  break;
234 
235  case '':
236  $this->sBrowseUrl = 'browse/';
237  $this->aCurrent['title'] = _t('_ch_groups');
238  unset($this->aCurrent['rss']);
239  break;
240 
241  default:
242  $this->isError = true;
243  }
244 
245  $oMain = $this->getMain();
246 
247  $this->aCurrent['paginate']['perPage'] = $oMain->_oDb->getParam('ch_groups_perpage_browse');
248 
249  if (isset($this->aCurrent['rss']))
250  $this->aCurrent['rss']['link'] = CH_WSB_URL_ROOT . $oMain->_oConfig->getBaseUri() . $this->sBrowseUrl;
251 
252  if (ch_get('rss')) {
253  $this->aCurrent['ownFields'][] = 'desc';
254  $this->aCurrent['ownFields'][] = 'created';
255  $this->aCurrent['paginate']['perPage'] = $oMain->_oDb->getParam('ch_groups_max_rss_num');
256  }
257 
258  ch_import('Voting', $oMain->_aModule);
259  $oVotingView = new ChGroupsVoting ('ch_groups', 0);
260  $this->oVotingView = $oVotingView->isEnabled() ? $oVotingView : null;
261 
262  $this->sFilterName = 'ch_groups_filter';
263 
264  parent::__construct();
265  }
266 
267  function getAlterOrder()
268  {
269  if ($this->aCurrent['sorting'] == 'last') {
270  $aSql = array();
271  $aSql['order'] = " ORDER BY `ch_groups_main`.`created` DESC";
272  return $aSql;
273  } elseif ($this->aCurrent['sorting'] == 'top') {
274  $aSql = array();
275  $aSql['order'] = " ORDER BY `ch_groups_main`.`rate` DESC, `ch_groups_main`.`rate_count` DESC";
276  return $aSql;
277  } elseif ($this->aCurrent['sorting'] == 'popular') {
278  $aSql = array();
279  $aSql['order'] = " ORDER BY `ch_groups_main`.`fans_count` DESC, `ch_groups_main`.`views` DESC";
280  return $aSql;
281  }
282  return array();
283  }
284 
285  function displayResultBlock ()
286  {
288  $s = parent::displayResultBlock ();
289  if ($s) {
290  $oMain = $this->getMain();
291  $GLOBALS['oSysTemplate']->addDynamicLocation($oMain->_oConfig->getHomePath(), $oMain->_oConfig->getHomeUrl());
292  $GLOBALS['oSysTemplate']->addCss(array('unit.css', 'twig.css'));
293  return $GLOBALS['oSysTemplate']->parseHtmlByName('default_padding.html', array('content' => $s));
294  }
295  return '';
296  }
297 
298  function getMain()
299  {
300  return ChWsbModule::getInstance('ChGroupsModule');
301  }
302 
303  function getRssUnitLink (&$a)
304  {
305  $oMain = $this->getMain();
306  return CH_WSB_URL_ROOT . $oMain->_oConfig->getBaseUri() . 'view/' . $a['uri'];
307  }
308 
309  function _getPseud ()
310  {
311  return array(
312  'id' => 'id',
313  'title' => 'title',
314  'uri' => 'uri',
315  'created' => 'created',
316  'author_id' => 'author_id',
317  'NickName' => 'NickName',
318  'thumb' => 'thumb',
319  'price_range' => 'price_range',
320  );
321  }
322 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
$sMode
else $sMode
Definition: antispam.php:362
ChWsbModule\getInstance
static getInstance($sClassName)
Definition: ChWsbModule.php:89
ChGroupsSearchResult\getRssUnitLink
getRssUnitLink(&$a)
Definition: ChGroupsSearchResult.php:303
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ch_get
ch_get($sName)
Definition: utils.inc.php:1664
php
ChWsbTwigSearchResult\$oVotingView
$oVotingView
Definition: ChWsbTwigSearchResult.php:15
ChGroupsSearchResult
Definition: ChGroupsSearchResult.php:11
$oFunctions
$oFunctions
Definition: ChTemplFunctions.php:20
ChGroupsSearchResult\$aCurrent
$aCurrent
Definition: ChGroupsSearchResult.php:12
ChGroupsVoting
Definition: ChGroupsVoting.php:11
ChGroupsSearchResult\displayResultBlock
displayResultBlock()
Definition: ChGroupsSearchResult.php:285
getNickName
getNickName( $ID='')
Definition: profiles.inc.php:461
title2uri
title2uri($sValue)
Definition: utils.inc.php:42
ChWsbTwigSearchResult
Definition: ChWsbTwigSearchResult.php:14
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
ChGroupsSearchResult\__construct
__construct($sMode='', $sValue='', $sValue2='', $sValue3='')
Definition: ChGroupsSearchResult.php:53
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
CH_WSB_LOCALE_DATE_SHORT
const CH_WSB_LOCALE_DATE_SHORT
Definition: utils.inc.php:15
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
$s
$s
Definition: embed.php:13
getID
getID( $str, $with_email=1)
Definition: admin.inc.php:139
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
ChGroupsSearchResult\getAlterOrder
getAlterOrder()
Definition: ChGroupsSearchResult.php:267
ChWsbTwigSearchResult\$sBrowseUrl
$sBrowseUrl
Definition: ChWsbTwigSearchResult.php:17
ChGroupsSearchResult\_getPseud
_getPseud()
Definition: ChGroupsSearchResult.php:309
ChWsbService\call
static call($mixed, $sMethod, $aParams=array(), $sClass='Module')
Definition: ChWsbService.php:32
getLocaleDate
getLocaleDate($sTimestamp='', $iCode=CH_WSB_LOCALE_DATE_SHORT)
Definition: utils.inc.php:70
ChGroupsSearchResult\getMain
getMain()
Definition: ChGroupsSearchResult.php:298
$iProfileId
if( $sMembersList) $iProfileId
Definition: communicator.php:29
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10