source: trunk/search.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 11.4 KB
Line 
1<?php
2
3/***************************************************************************
4* Dolphin Smart Community Builder
5* -----------------
6* begin : Mon Mar 23 2006
7* copyright : (C) 2006 BoonEx Group
8* website : http://www.boonex.com/
9* This file is part of Dolphin - Smart Community Builder
10*
11* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12* http://creativecommons.org/licenses/by/3.0/
13*
14* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16* See the Creative Commons Attribution 3.0 License for more details.
17* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18* see license.txt file; if not, write to marketing@boonex.com
19***************************************************************************/
20
21require_once( './inc/header.inc.php' );
22require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
23require_once( BX_DIRECTORY_PATH_INC . 'admin.inc.php' );
24require_once( BX_DIRECTORY_PATH_INC . 'db.inc.php' );
25require_once( BX_DIRECTORY_PATH_INC . 'match.inc.php');
26require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolProfileFields.php' );
27require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolProfilesController.php' );
28
29bx_import('BxDolDb');
30bx_import('BxBaseSearchProfile');
31bx_import('BxTemplProfileView');
32
33class BxDolSearchPageView extends BxDolPageView {
34 var $oPF;
35
36 var $aFilterSortSettings;
37
38 function BxDolSearchPageView() {
39 parent::BxDolPageView('search');
40
41 // get search mode
42 switch( $_REQUEST['search_mode'] ) {
43 case 'quick': $iPFArea = 10; break;
44 case 'adv': $iPFArea = 11; break;
45 default: $iPFArea = 9; // simple search (default)
46 }
47
48 $this->oPF = new BxDolProfileFields($iPFArea);
49
50 $this->aFilterSortSettings = array();
51 }
52
53 function collectFilteredSettings() {
54 //$this->aFilterSortSettings
55 $sSort = (isset($_GET['sort'])) ? process_db_input($_GET['sort'], BX_TAGS_STRIP) : null;
56 // $sPhotos = (isset($_GET['photos_only'])) ? $_GET['photos_only'] : null;
57 // $sOnline = (isset($_GET['online_only'])) ? $_GET['online_only'] : null;
58 // $sInfoMode = (isset($_GET['search_result_mode']) && $_GET['search_result_mode'] == 'ext') ? 'ext' : 'sim';
59
60 $this->aFilterSortSettings = array (
61 //'f_photos' => $sPhotos,
62 //'f_online' => $sOnline,
63 'sort' => $sSort,
64 //'s_mode' => $sInfoMode
65 );
66 }
67
68 function getBlockCode_SearchForm() {
69 global $logged;
70
71 $aProfile = $logged['member'] ? getProfileInfo(getLoggedId()) : array();
72
73 // default params for search form
74 $aDefaultParams = array(
75 'LookingFor' => isset($_GET['LookingFor']) ? $_GET['LookingFor'] : ($aProfile['Sex'] ? $aProfile['Sex'] : 'male'),
76 'Sex' => isset($_GET['Sex']) ? $_GET['Sex'] : ($aProfile['LookingFor'] ? $aProfile['LookingFor'] : 'female'),
77 'Country' => isset($_GET['Country'][0]) ? $_GET['Country'][0] : ($aProfile['Country'] ? $aProfile['Country'] : getParam('default_country')),
78 'DateOfBirth' => isset($_GET['DateOfBirth']) ? $_GET['DateOfBirth'] : getParam('search_start_age') . '-' . getParam('search_end_age'),
79 'Tags' => isset($_GET['Tags']) ? $_GET['Tags'] : '',
80 'online_only' => isset($_GET['online_only']) ? $_GET['online_only'] : '',
81 'photos_only' => isset($_GET['photos_only']) ? $_GET['photos_only'] : ''
82 );
83
84 $sForms = $this->oPF->getFormCode(array('default_params' => $aDefaultParams));
85
86 $bSimAct = ($this->oPF->iAreaID == 9) ? true : false;
87 $bAdvAct = ($this->oPF->iAreaID == 11) ? true : false;
88 $bQuiAct = ($this->oPF->iAreaID == 10) ? true : false;
89
90 $sLinks = BxDolPageView::getBlockCaptionMenu(mktime(), array(
91 'simple' => array('href' => $_SERVER['PHP_SELF'] . '?search_mode=sim', 'title' => _t('Simple'), 'onclick' => '', 'active' => $bSimAct),
92 'advanced' => array('href' => $_SERVER['PHP_SELF'] . '?search_mode=adv', 'title' => _t('Adv'), 'onclick' => '', 'active' => $bAdvAct),
93 'quick' => array('href' => $_SERVER['PHP_SELF'] . '?search_mode=quick', 'title' => _t('Quick'), 'onclick' => '', 'active' => $bQuiAct),
94 ));
95
96 return DesignBoxContent(_t('_Search profiles'), $sForms, 1, $sLinks);
97 }
98
99 function showMatchProfiles($iBlockID)
100 {
101 $iProfileId = getLoggedId();
102
103 if (!$iProfileId)
104 return array('', MsgBox(_t('_Empty')));
105
106 $sSort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'none';
107 $aProfiles = getMatchProfiles($iProfileId, false, $sSort);
108
109 if (empty($aProfiles))
110 return array('', MsgBox(_t('_Empty')));
111
112 $sBaseUri = 'search.php?show=match';
113 $sTopLinksUri = '';
114 $sPaginateUri = '';
115
116 foreach ($_REQUEST as $sKey => $sVal)
117 {
118 switch ($sKey)
119 {
120 case 'page':
121 $sPaginateUri .= '&page=' . $sVal;
122 break;
123 case 'per_page':
124 $sPaginateUri .= '&per_page=' . $sVal;
125 break;
126 case 'sort':
127 $sPaginateUri .= '&sort=' . $sVal;
128 break;
129 case 'mode':
130 $sTopLinksUri .= '&mode=' . $sVal;
131 break;
132 }
133 }
134
135 $aPaginate = array(
136 'page_url' => $sBaseUri . $sTopLinksUri . '&page={page}&per_page={per_page}&sort={sorting}',
137 'info' => true,
138 'page_links' => true,
139 'per_page' => isset($_REQUEST['per_page']) ? (int)$_REQUEST['per_page'] : 25,
140 'sorting' => $sSort,
141 'count' => count($aProfiles),
142 'page' => isset($_REQUEST['page']) ? (int)$_REQUEST['page'] : 1,
143 'page_reloader' => true,
144 'per_page_changer' => true
145 );
146 $sMode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'simple';
147
148 $oPaginate = new BxDolPaginate($aPaginate);
149
150 $oSearchProfile = new BxBaseSearchProfile();
151 $aExtendedCss = array( 'ext_css_class' => 'search_filled_block');
152 $sTemplateName = $sMode == 'extended' ? 'search_profiles_ext.html' : 'search_profiles_sim.html';
153 $iIndex = 0;
154 $sOutputHtml = '';
155
156 for ($i = ($aPaginate['page'] - 1) * $aPaginate['per_page'];
157 $i < $aPaginate['page'] * $aPaginate['per_page'] && $i < $aPaginate['count']; $i++)
158 {
159 $aProfile = getProfileInfo($aProfiles[$i]);
160
161 if ($aProfile['Couple'])
162 {
163 $aCoupleInfo = getProfileInfo($aProfile['Couple']);
164 if (!($iIndex % 2))
165 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, $aCoupleInfo, null, $sTemplateName);
166 else
167 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, $aCoupleInfo, $aExtendedCss, $sTemplateName);
168 }
169 else
170 {
171 if (!($iIndex % 2))
172 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, '', null, $sTemplateName);
173 else
174 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, '', $aExtendedCss, $sTemplateName);
175 }
176
177 $iIndex++;
178 }
179
180 $aSortingParam = array (
181 'none' => _t('_None'),
182 'activity' => _t('_Latest activity'),
183 'date_reg' => _t('_FieldCaption_DateReg_View'),
184 );
185
186 // gen sorting block ( type of : drop down ) ;
187 $sSortBlock = $oPaginate->getSorting($aSortingParam);
188 $sSortElement = <<<EOF
189<div class="top_settings_block">
190 <div class="ordered_block">
191 {$sSortBlock}
192 </div>
193 <div class="clear_both"></div>
194</div>
195EOF;
196
197 $sOutputHtml .= '<div class="clear_both"></div>';
198 $sContent = $sSortElement . $GLOBALS['oSysTemplate']->parseHtmlByName('view_profiles.html', array('content' => $sOutputHtml)) . $oPaginate->getPaginate();
199 $aItems = array(
200 _t('_Simple') => array(
201 'href' => $sBaseUri . $sPaginateUri . '&mode=simple',
202 'dynamic' => true,
203 'active' => $sMode == 'simple'
204 ),
205 _t('_Extended') => array(
206 'href' => $sBaseUri . $sPaginateUri . '&mode=extended',
207 'dynamic' => true,
208 'active' => $sMode == 'extended'
209 )
210 );
211 $sLinks = BxDolPageView::getBlockCaptionItemCode($iBlockID, $aItems);
212
213 return array(
214 $sLinks,
215 $sContent
216 );
217 }
218
219 function getBlockCode_Results($iBlockID) {
220 //collect inputs
221 $aRequestParams = $this->oPF->collectSearchRequestParams();
222
223 if( isset( $_REQUEST['Tags'] ) and trim( $_REQUEST['Tags'] ) )
224 $aRequestParams['Tags'] = trim( process_pass_data( $_REQUEST['Tags'] ) );
225
226 if( isset( $_REQUEST['distance'] ) and (int)$_REQUEST['distance'] )
227 $aRequestParams['distance'] = (int)$_REQUEST['distance'];
228
229 // start page generation
230 $oProfile = new BxBaseProfileGenerator((int)$_COOKIE['memberID']);
231
232 switch($_REQUEST['show']) {
233 case 'match':
234 list($sLinks, $sResults) = $this->showMatchProfiles($iBlockID);
235 break;
236 case 'calendar':
237 list($sResults, $aDBTopMenu, $sPagination, $sTopFilter) = $oProfile->GenProfilesCalendarBlock();
238 $sLinks = (is_array($aDBTopMenu) && count($aDBTopMenu)>0) ? $this->getBlockCaptionItemCode($iBlockID, $aDBTopMenu) : '';
239 break;
240 default:
241 $this->collectFilteredSettings();
242 list($sResults, $aDBTopMenu, $sPagination, $sTopFilter) = $oProfile->GenSearchResultBlock($this->oPF->aBlocks, $aRequestParams, $this->aFilterSortSettings);
243 $sLinks = (is_array($aDBTopMenu) && count($aDBTopMenu)>0) ? $this->getBlockCaptionItemCode($iBlockID, $aDBTopMenu) : '';
244 break;
245 }
246
247 return DesignBoxContent($this->getTitle(), $sTopFilter . $sResults . $sPagination, 1, $sLinks);
248 }
249
250 function getTitle() {
251 $sHeaderTitle = _t('_Search profiles');
252 switch($_REQUEST['show']) {
253 case 'match':
254 $sHeaderTitle = _t('_Match');
255 break;
256 /*case 'online':
257 $sHeaderTitle = _t('_Online');
258 break;*/
259 case 'featured':
260 $sHeaderTitle = _t('_Featured');
261 break;
262 case 'top_rated':
263 $sHeaderTitle = _t('_Top Rated');
264 break;
265 case 'popular':
266 $sHeaderTitle = _t('_Popular');
267 break;
268 case 'birthdays':
269 $sHeaderTitle = _t('_Birthdays');
270 break;
271 case 'world_map':
272 $sHeaderTitle = _t('_World_Map');
273 break;
274 case 'calendar':
275 $sHeaderTitle = _t('_People_Calendar');
276 break;
277 }
278 return $sHeaderTitle;
279 }
280}
281
282check_logged();
283
284$_page['name_index'] = 81;
285$_page['css_name'] = 'search.css';
286
287$oSearchView = new BxDolSearchPageView();
288$sHeaderTitle = $oSearchView->getTitle();
289$_page['header'] = $sHeaderTitle;
290$_ni = $_page['name_index'];
291$_page_cont[$_ni]['page_main_code'] = $oSearchView->getCode();
292
293PageCode();
294exit;
295
296?>
Note: See TracBrowser for help on using the repository browser.