Cheetah
ChBaseBrowse.php
Go to the documentation of this file.
1 <?php
2 
8 ch_import('ChWsbBrowse');
9 ch_import('ChWsbPaginate');
10 ch_import('ChTemplSearchProfile');
11 
13 {
15 
16  // for block devider ;
18 
20 
21  // link on search profile ;
23 
24  // array with some visible parameters (page, per_page ....);
26 
27  // add this string to all sql queries
28  var $_sSqlActive = "`Profiles`.`Status` = 'Active'";
29 
30 
48  {
49  if(!$this->bShowBothCoupleProfiles)
50  $this->_sSqlActive .= " AND (`Profiles`.`Couple` = 0 or `Profiles`.`Couple` > `Profiles`.`ID`)";
51 
52  if ( isset($aFilteredSettings['sex']) and $aFilteredSettings['sex'] == 'all' )
53  $aFilteredSettings['sex'] = null;
54 
55  if ( isset($aFilteredSettings['age']) and $aFilteredSettings['age'] == 'all' )
56  $aFilteredSettings['age'] = null;
57 
58  if ( isset($aFilteredSettings['country']) and $aFilteredSettings['country'] == 'all' )
59  $aFilteredSettings['country'] = null;
60 
61  $this -> aParameters = array
62  (
65  'country' => process_db_input($aFilteredSettings['country'], CH_TAGS_STRIP),
66  );
67 
68  $this -> aAdditionalParameters = array
69  (
70  'photos_only' => process_db_input($aFilteredSettings['photos_only'], CH_TAGS_STRIP),
71  'online_only' => process_db_input($aFilteredSettings['online_only'], CH_TAGS_STRIP),
72  );
73 
74  $this -> aDisplaySettings = &$aDisplaySettings;
75 
76  // fill sKeyName with parameters for search into cache file ;
77  $this -> sKeyName .= ($this -> aParameters['sex']) ? $this -> aParameters['sex'] . '|' : '';
78  $this -> sKeyName .= ($this -> aParameters['age']) ? $this -> aParameters['age'] . '|' : '';
79 
80  $this -> sKeyName .= ($this -> aParameters['country']) ? $this -> aParameters['country'] . '|' : '';
81 
82  $this -> sKeyName .= ($this -> aAdditionalParameters['photos_only']) ? 'photo|' : '';
83  $this -> sKeyName .= ($this -> aAdditionalParameters['online_only']) ? 'online|' : '';
84 
85  $this -> sKeyName = preg_replace("|\|$|", '', $this -> sKeyName);
86 
87  parent::__construct($sPageName);
88 
89  // fill global array with the needed parameters ;
90 
91  $this -> _getGlobalStatistics
92  (
93  $this -> aParameters['sex'],
94  $this -> aParameters['age'],
95  $this -> aParameters['country'],
96  $aFilteredSettings['photos_only'],
97  $aFilteredSettings['online_only']
98  );
99 
100  $this -> oSearchProfileTmpl = new ChTemplSearchProfile();
101  }
102 
113  function genBrowseLink( $sName, $sValue, $sLink, $sIcon, $bImgDetect = true )
114  {
115  // try to find link's icon
116 
117  if ( $bImgDetect )
118  $sIcon = getTemplateIcon($sIcon);
119 
120  $sValue = ( $sValue ) ? '<span>(' . $sValue . ')</span>' : null;
121 
122  return '
123  <div class="linkSection">
124  <table>
125  <tr>
126  <td>
127  <img src="' . $sIcon . '" alt="' . $sName . '" />
128  </td>
129  <td>
130  <a href="' . $sLink . '">' . $sName . '</a>
131  ' . $sValue . '
132  </td>
133  </tr>
134  </table>
135  </div>
136  ';
137  }
138 
145  {
146  // lang keys ;
147  $sSexCaption = _t( '_By Sex' );
148  $sAgeCaption = _t( '_By Age' );
149  $sCountryCaption = _t( '_By Country' );
150 
151  // init some variables ;
152 
153  $sSexSection = '';
154  $sAgeSection = '';
155  $sCountrySection = '';
156 
157  $sCurrentKey = ( $this -> sKeyName ) ? $this -> sKeyName : 'public';
158 
159  // ** INTERNAL FUNCTIONS ;
160 
168  function _genSexSection( &$oObject, $sCurrentKey )
169  {
170  global $aPreValues;
171 
172  // init some variables ;
173  $sSexSection = '';
174  $aCurrentArray = '';
175  $sExtendedCss = '';
176 
177  $aUsedTemplates = array
178  (
179  'browse_settings_section.html'
180  );
181 
182  $iIndex = 0; // ** need for dividers ;
183 
184  if ( isset($oObject -> aMembersInfo[$sCurrentKey]['sex']) ) {
185  $aCurrentArray = &$oObject -> aMembersInfo[$sCurrentKey]['sex'];
186  } elseif ( $oObject -> aParameters['sex'] ) {
187  // ** if param `Sex` was selected ;
188  // ** load data again ;
189 
190  $aCurrentArray = $oObject -> _getGlobalStatistics
191  (
192  null,
193  $oObject -> aParameters['age'],
194  $oObject -> aParameters['country'],
195  $oObject -> aAdditionalParameters['photos_only'],
196  $oObject -> aAdditionalParameters['online_only'],
197  'sex'
198  );
199  }
200 
201  // hide selected block ;
202 
203  if ( $oObject -> aParameters['sex'] ) {
204  $aCurrentArray['all'] = _t( '_All' );
205  $sExtendedCss = 'hidden_block';
206  }
207 
208  $iArrayCount = count($aCurrentArray);
209 
210  if ( is_array($aCurrentArray) and !empty($aCurrentArray) )
211  foreach( $aCurrentArray AS $sKey => $sValue ) {
212  $iDivider = $iIndex % 2;
213 
214  if ( $sKey != 'all' )
215  $sValue = ( $oObject -> aParameters['sex'] ) ? 0 : $sValue;
216 
217  switch ($sKey) {
218  case 'male' :
219  $sSexSection .= $oObject -> genBrowseLink( _t( '_By Male' ), $sValue, $oObject -> genLinkLocation( 'sex', 'male'), 'male.png');
220  break;
221  case 'female' :
222  $sSexSection .= $oObject -> genBrowseLink( _t( '_By Female' ), $sValue, $oObject -> genLinkLocation( 'sex', 'female'), 'female.png');
223  break;
224  case 'all' :
225  $sSexSection .= $oObject -> genBrowseLink( $sValue, null, $oObject -> genLinkLocation( 'sex', $sKey), 'post_featured.png');
226  break;
227  default :
228  $sSexSection .= $oObject -> genBrowseLink( _t($aPreValues['Sex'][$sKey]['LKey']), $sValue, $oObject -> genLinkLocation( 'sex', $sKey), 'tux.png');
229  break;
230  }
231 
232  if ( $iDivider )
233  $sSexSection .=
234  '
235  <div class="clear_both"></div>
236  ';
237 
238  $iIndex++;
239 
240  if ( $iDivider and $iIndex >= 2 and $iArrayCount > 2 and ($iIndex <= $iArrayCount - 1) )
241  $sSexSection .=
242  '
243  <div class="devider"></div>
244  ';
245  }
246 
247  if ( !$sSexSection )
248  $sSexSection = MsgBox(_t( '_Empty' ));
249 
250  // fill array with template's keys ;
251  $aTemplateKeys = array
252  (
253  'section_id' => 'sex_section',
254  'extended_css' => $sExtendedCss,
255  'section_data' => $sSexSection,
256  );
257 
258  $sSexSection = $GLOBALS['oSysTemplate'] -> parseHtmlByName( $aUsedTemplates[0], $aTemplateKeys );
259 
260  // return builded template ;
261  return $sSexSection;
262  }
263 
271  function _genAgeSection( &$oObject, $sCurrentKey )
272  {
273  global $aCurrentPointer;
274 
275  // init some variables ;
276  $sAgeSection = '';
277  $sExtendedCss = '';
278  $aCurrentArray = '';
279 
280  $aUsedTemplates = array
281  (
282  'browse_settings_section.html'
283  );
284 
285  $iIndex = 0; // ** need for dividers ;
286 
287  if ( isset($oObject -> aMembersInfo[$sCurrentKey]['age']) ) {
288  $aCurrentArray = &$oObject -> aMembersInfo[$sCurrentKey]['age'];
289  } elseif ( $oObject -> aParameters['age'] ) {
290  // ** if param `Age` was selected ;
291  // ** load data again ;
292 
293  $aCurrentArray = $oObject -> _getGlobalStatistics
294  (
295  $oObject -> aParameters['sex'],
296  null,
297  $oObject -> aParameters['country'],
298  $oObject -> aAdditionalParameters['photos_only'],
299  $oObject -> aAdditionalParameters['online_only'],
300  'age'
301  );
302  }
303 
304  // hide selected block ;
305  if ( $oObject -> aParameters['age'] ) {
306  $aCurrentArray['all'] = _t( '_All' );
307  $sExtendedCss = 'hidden_block';
308  }
309 
310  $iArrayCount = count($aCurrentArray);
311 
312  if ( is_array($aCurrentArray) and $iArrayCount ) {
313  foreach( $aCurrentArray AS $sKey => $sValue ) {
314  $iDivider = $iIndex % 2;
315 
316  if ( $sKey != 'all')
317  $sValue = ( $sExtendedCss ) ? 0 : $sValue;
318 
319  if ( $sKey == 'all' )
320  $sAgeSection .= $oObject -> genBrowseLink( $sValue, null, $oObject -> genLinkLocation( 'age', $sKey), 'post_featured.png');
321  else
322  $sAgeSection .= $oObject -> genBrowseLink( $sKey, $sValue, $oObject -> genLinkLocation( 'age', $sKey), 'birthday.png');
323 
324  if ( $iDivider )
325  $sAgeSection .=
326  '
327  <div class="clear_both"></div>
328  ';
329 
330  $iIndex++;
331 
332  if ( $iDivider and $iIndex >= 2 and $iArrayCount > 2 and ($iIndex <= $iArrayCount - 1) )
333  $sAgeSection .=
334  '
335  <div class="devider"></div>
336  ';
337  }
338  }
339 
340  if ( !$sAgeSection )
341  $sAgeSection = MsgBox(_t( '_Empty' ));
342 
343  // fill array with template's keys ;
344  $aTemplateKeys = array
345  (
346  'section_id' => 'age_section',
347  'extended_css' => $sExtendedCss,
348  'section_data' => $sAgeSection,
349  );
350 
351  $sAgeSection = $GLOBALS['oSysTemplate'] -> parseHtmlByName( $aUsedTemplates[0], $aTemplateKeys );
352 
353  // return builded template ;
354  return $sAgeSection;
355  }
356 
364  function _genCountrySection( &$oObject, $sCurrentKey )
365  {
366  global $site;
367 
368  // init some variables ;
369  $sCountrySection = '';
370  $sExtendedCss = '';
371  $aCurrentArray = array();
372 
373  $aUsedTemplates = array
374  (
375  'browse_settings_section.html'
376  );
377 
378  $iIndex = 0; // ** need for dividers ;
379 
380  if ( isset($oObject -> aMembersInfo[$sCurrentKey]['country']) ) {
381  $aCurrentArray = &$oObject -> aMembersInfo[$sCurrentKey]['country'];
382  } elseif ( $oObject -> aParameters['country'] ) {
383  // ** if param `Country` was selected;
384  // ** load data again;
385 
386  $aCurrentArray = $oObject -> _getGlobalStatistics
387  (
388  $oObject -> aParameters['sex'],
389  $oObject -> aParameters['age'],
390  null,
391  $oObject -> aAdditionalParameters['photos_only'],
392  $oObject -> aAdditionalParameters['online_only'],
393  'country'
394  );
395  }
396 
397  // hide selected block ;
398  if ( $oObject -> aParameters['country'] ) {
399  $aCurrentArray['all'] = _t( '_All' );
400  $sExtendedCss = 'hidden_block';
401  }
402 
403  $iArrayCount = count($aCurrentArray);
404 
405  if ( is_array($aCurrentArray) and !empty($aCurrentArray) ) {
406  foreach( $aCurrentArray AS $sKey => $sValue ) {
407  $iDivider = $iIndex % 2;
408 
409  if ( $sKey != 'all' )
410  $sValue = ( $sExtendedCss ) ? 0 : $sValue;
411 
412  if ( $sKey == 'all' )
413  $sCountrySection .= $oObject -> genBrowseLink( $sValue, null, $oObject -> genLinkLocation( 'country', $sKey), 'post_featured.png');
414  else {
415  $sCountryName = strtolower($sKey);
416  $sImagePath = $site['flags'] . $sCountryName . '.gif';
417  $sCountrySection .= $oObject -> genBrowseLink( $sKey, $sValue, $oObject -> genLinkLocation( 'country', $sCountryName), $sImagePath, false );
418  }
419 
420  if ( $iDivider )
421  $sCountrySection .=
422  '
423  <div class="clear_both"></div>
424  ';
425 
426  $iIndex++;
427 
428  if ( $iDivider and $iIndex >= 2 and $iArrayCount > 2 and ($iIndex <= $iArrayCount - 1) )
429  $sCountrySection .=
430  '
431  <div class="devider"></div>
432  ';
433  }
434  }
435 
436  if ( !$sCountrySection )
437  $sCountrySection = MsgBox(_t( '_Empty' ));
438 
439  // fill array with template's keys ;
440  $aTemplateKeys = array
441  (
442  'section_id' => 'country_section',
443  'extended_css' => $sExtendedCss,
444  'section_data' => $sCountrySection,
445  );
446 
447  $sCountrySection = $GLOBALS['oSysTemplate'] -> parseHtmlByName( $aUsedTemplates[0], $aTemplateKeys );
448 
449  // return builded template ;
450  return $sCountrySection;
451  }
452 
461  function _genJsControlBox( $sCaption, $sBlockID, $bIsHidden = false )
462  {
463  // lang keys
464  $sToggleCaption = _t( '_Show' ) . ' / ' . _t( '_Hide' );
465 
466  // extended parameters
467  $sVisibleParam = ( !$bIsHidden ) ? 'closed_toggle_block' : null;
468 
469  $sJsControlBlock =
470  '
471  <div class="caption_section">
472  ' . $sCaption . '
473  </div>
474  <div class="js_control_section ' . $sVisibleParam . '" bxchild="' . $sBlockID . '" title="' . $sToggleCaption . '">
475  &nbsp;
476  </div>
477  <div class="clear_both"></div>
478  ';
479 
480  return $sJsControlBlock;
481  }
482 
490  function _genSubDesignBox( $sCaption, $sContent )
491  {
492  $sOutputHtml =
493  '
494  <div class="sub_design_box_head">
495  ' . $sCaption . '
496  </div>
497  ' . $sContent . '
498  ';
499 
500  return $sOutputHtml;
501  }
502 
503  // gen sex section ;
504  $sSexSection = _genSexSection( $this, $sCurrentKey );
505  if ( $sSexSection ) {
506  $sVisibleParam = ( $this -> aParameters['sex'] ) ? false : true;
507 
508  $sSexSection = _genSubDesignBox(
509  _genJsControlBox($sSexCaption, 'sex_section', $sVisibleParam) ,
510  $sSexSection
511  );
512  }
513 
514  // gen Age section ;
515  $sAgeSection = _genAgeSection( $this, $sCurrentKey );
516  if ( $sAgeSection ) {
517  $sVisibleParam = ( $this -> aParameters['age'] ) ? false : true;
518 
519  $sAgeSection = _genSubDesignBox(
520  _genJsControlBox($sAgeCaption, 'age_section', $sVisibleParam),
521  $sAgeSection
522  );
523  }
524 
525  // gen County section ;
526  $sCountrySection = _genCountrySection( $this, $sCurrentKey );
527  if ( $sCountrySection ) {
528  $sVisibleParam = ( $this -> aParameters['country'] ) ? false : true;
529 
530  $sCountrySection = _genSubDesignBox(
531  _genJsControlBox($sCountryCaption, 'country_section', $sVisibleParam),
532  $sCountrySection
533  );
534  }
535 
536  $sJsEventInit =
537  '
538  <script type="text/javascript">
539  $(".js_control_section").click( function() { oBrowsePage.ShowHideToggle(this) } );
540  </script>
541  ';
542 
543  $sContent =
544  '
545  <div class="main_settings ch-def-bc-margin">
546  <div class="devider"></div>
547  ' . $sSexSection . '
548  ' . $sAgeSection . '
549  ' . $sCountrySection . '
550  </div>
551  ' . $sJsEventInit . '
552  ';
553 
554  return DesignBoxContent( _t( '_Browse' ), $sContent, 1);
555  }
556 
563  function genLinkLocation( $sType, $sTypeValue )
564  {
565  $sLocation = null;
566 
567  foreach( $this -> aParameters AS $sKey => $sValue ) {
568  if ( $this -> bPermalinkMode ) {
569  if ( $sType == $sKey )
570  $sLocation .= '/' . $sTypeValue;
571  else
572  $sLocation .= ( $sValue ) ? '/' . $sValue : '/all';
573  } else {
574  if ( $sType == $sKey )
575  $sLocation .= '&' . $sKey . '=' . $sTypeValue;
576  else
577  $sLocation .= ( $sValue ) ? '&' . $sKey . '=' . $sValue : '&' . $sKey . '=all';
578  }
579  }
580 
581  $sLocation = ($this->bPermalinkMode) ? CH_WSB_URL_ROOT . 'browse' . $sLocation : 'browse.php?' . $sLocation;
582 
583  // concatenate some get visible params ;
584  if ( isset($this -> aAdditionalParameters['photos_only']) && $this -> aAdditionalParameters['photos_only'])
585  $sLocation .= "&amp;photos_only=on";
586 
587  if ( isset($this -> aAdditionalParameters['online_only']) && $this -> aAdditionalParameters['online_only'])
588  $sLocation .= "&amp;online_only=on";
589 
590  if ( isset($this -> aDisplaySettings['mode']) && $this -> aDisplaySettings['mode'])
591  $sLocation .= "&amp;mode=" . $this -> aDisplaySettings['mode'];
592 
593  return $sLocation;
594  }
595 
602  {
603  // lang keys ;
604  $sOutputHtml = '';
605 
606  $sPhotoCaption = _t( '_With photos only' );
607  $sOnlineCaption = _t( '_online only' );
608  $sSimpleCaption = _t( '_Simple' );
609  $sExtendCaption = _t( '_Extended' );
610 
611  $aUsedTemplates = array
612  (
613  'browse_searched_block.html'
614  );
615 
616  // collect the SQL parameters ;
617 
618  $aWhereParam = array();
619  $aWhereParam[] = ( $this -> aParameters['sex'] )
620  ? '`Profiles`.`Sex` = "' . $this -> aParameters['sex'] . '"'
621  : null;
622 
623  if ( $this -> aParameters['age'] ) {
624  $aAgeTemp = explode('-', $this -> aParameters['age']);
625  $iFrom = ( isset($aAgeTemp[0]) )
626  ? (int) $aAgeTemp[0]
627  : 0;
628 
629  $iTo = ( isset($aAgeTemp[1]) )
630  ? (int) $aAgeTemp[1]
631  : 0;
632 
633  unset($aAgeTemp);
634 
635  if ($iFrom) {
636  $sSign = $iTo ? '>=' : '=';
637  $aWhereParam[] =
638  "
639  ((YEAR(CURDATE())-YEAR(`Profiles`.`DateOfBirth`)) - (RIGHT(CURDATE(),5)<RIGHT(`Profiles`.`DateOfBirth`,5))) {$sSign} {$iFrom}
640  ";
641  }
642 
643  if($iTo) {
644  $sSign = $iFrom ? '<=' : '=';
645  $aWhereParam[] =
646  "
647  ((YEAR(CURDATE())-YEAR(`Profiles`.`DateOfBirth`)) - (RIGHT(CURDATE(),5)<RIGHT(`Profiles`.`DateOfBirth`,5))) {$sSign} {$iTo}
648  ";
649  }
650  }
651 
652  $aWhereParam[] = ( $this -> aParameters['country'] )
653  ? '`Profiles`.`Country` = "' . $this -> aParameters['country'] . '"'
654  : null;
655 
656  if ( $this -> aAdditionalParameters['photos_only'] )
657  $aWhereParam[] = '`Profiles`.`Avatar` <> 0';
658 
659  if ( $this -> aAdditionalParameters['online_only'] )
660  $aWhereParam[] = "(`Profiles`.`DateLastNav` > SUBDATE(NOW(), INTERVAL " . $this -> iMemberOnlineTime . " MINUTE)) ";
661 
662  $sWhereParam = null;
663  foreach( $aWhereParam AS $sValue )
664  if ( $sValue )
665  $sWhereParam .= ' AND ' . $sValue;
666 
667  // make search ;
668  $sQuery = "SELECT COUNT(*) AS `Cnt` FROM `Profiles` WHERE {$this->_sSqlActive} {$sWhereParam}";
669  $iTotalNum = db_value($sQuery);
670 
671  if( !$iTotalNum )
672  $sOutputHtml = MsgBox(_t( '_Empty' ));
673 
674  // init some pagination parameters ;
675 
676  $iPerPage = $this -> aDisplaySettings['per_page'];
677  $iCurPage = $this -> aDisplaySettings['page'];
678 
679  if( $iCurPage < 1 )
680  $iCurPage = 1;
681 
682  $sLimitFrom = ( $iCurPage - 1 ) * $iPerPage;
683  $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
684 
685  // switch template for `simle` and `advanced` mode ;
686 
687  $sTemplateName = ($this->aDisplaySettings['mode'] == 'extended') ? 'search_profiles_ext.html' : 'search_profiles_sim.html';
688 
689  // select sorting parameters ;
690  $sSortParam = '`Profiles`.`DateLastNav` DESC';
691  if ( isset($this -> aDisplaySettings['sort']) ) {
692  switch($this -> aDisplaySettings['sort']) {
693  case 'date_reg' :
694  $sSortParam = ' `Profiles`.`DateReg` DESC';
695  break;
696  case 'rate' :
697  $sSortParam = ' `Profiles`.`Rate` DESC, `Profiles`.`RateCount` DESC';
698  break;
699  default :
700  $this -> aDisplaySettings['sort'] = 'activity';
701  case 'activity' :
702  $sSortParam = ' `Profiles`.`DateLastNav` DESC';
703  break;
704  }
705  } else
706  $this -> aDisplaySettings['sort'] = 'activity';
707 
708  // status uptimization
709  $iOnlineTime = (int)getParam( "member_online_time" );
710  $sIsOnlineSQL = ", if(`DateLastNav` > SUBDATE(NOW(), INTERVAL {$iOnlineTime} MINUTE ), 1, 0) AS `is_online`";
711 
712  $sQuery =
713  "
714  SELECT
715  `Profiles`.* {$sIsOnlineSQL}
716  FROM
717  `Profiles`
718  WHERE
719  {$this->_sSqlActive}
720  {$sWhereParam}
721  ORDER BY
722  {$sSortParam}
723  {$sqlLimit}
724  ";
725 
726  $rResult = db_res($sQuery);
727  $iIndex = 0;
728 
729  // need for the block divider ;
730  $aExtendedCss = array(
731  'ext_css_class' => $this->aDisplaySettings['mode'] == 'extended' ? 'search_filled_block' : ''
732  );
733  while( true == ($aRow = $rResult->fetch()) ) {
734  // generate the `couple` thumbnail ;
735  if ( $aRow['Couple']) {
736  $aCoupleInfo = getProfileInfo( $aRow['Couple'] );
737  $sOutputHtml .= $this -> oSearchProfileTmpl -> PrintSearhResult($aRow, $aCoupleInfo, ($iIndex % 2 ? $aExtendedCss : array()), $sTemplateName);
738  } else
739  $sOutputHtml .= $this -> oSearchProfileTmpl -> PrintSearhResult($aRow, array(), ($iIndex % 2 ? $aExtendedCss : array()), $sTemplateName);
740  $iIndex++;
741  }
742  // # end of search generation ;
743 
744  // work with link pagination ;
745  if ( $this -> bPermalinkMode ) {
746  preg_match("|([^\?\&]*)|", $_SERVER['REQUEST_URI'], $aMatches);
747  if ( isset( $aMatches[1] ) and $aMatches[1] )
748  $sRequest = $aMatches[1] . '?';
749 
750  // need for additional parameters ;
751  $aGetParams = array('photos_only', 'online_only', 'sort', 'mode');
752  foreach($aGetParams AS $sValue )
753  if ( isset($_GET[$sValue]) ) {
754  $sRequest .= '&' . $sValue . '=' . rawurlencode($_GET[$sValue]);
755  }
756  } else {
757  $sRequest = CH_WSB_URL_ROOT . 'browse.php?';
758 
759  // need for additional parameters ;
760  $aGetParams = array('sex', 'age', 'country','photos_only', 'online_only', 'sort', 'mode');
761  foreach($aGetParams AS $sValue )
762  if ( isset($_GET[$sValue]) ) {
763  $sRequest .= '&' . $sValue . '=' . rawurlencode($_GET[$sValue]);
764  }
765  }
766 
767  // cutted al aunecessary parameters ;
768  $sRequest = getClearedParam( 'sort', $sRequest);
769 
770  $sRequest = $sRequest . '&page={page}&per_page={per_page}&sort={sorting}';
771 
772  // gen pagination block ;
773  $oPaginate = new ChWsbPaginate
774  (
775  array
776  (
777  'page_url' => $sRequest,
778  'count' => $iTotalNum,
779  'per_page' => $iPerPage,
780  'sorting' => $this -> aDisplaySettings['sort'],
781  'page' => $iCurPage,
782  )
783  );
784 
785  $sPagination = $oPaginate -> getPaginate();
786 
787  // gen per page block ;
788  $sPerPageBlock = $oPaginate -> getPages( $iPerPage );
789 
790  // prepare to output ;
791  $sOutputHtml .=
792  '
793  <div class="clear_both"></div>
794  ';
795 
796  $sRequest = str_replace('{page}', '1', $sRequest);
797  $sRequest = str_replace('{per_page}', $iPerPage, $sRequest);
798  $sRequest = str_replace('{sorting}', $this -> aDisplaySettings['sort'], $sRequest);
799 
800  // fill array with sorting params
801  $aSortingParam = array(
802  'activity' => _t('_Latest activity'),
803  'date_reg' => _t('_FieldCaption_DateReg_View'),
804  );
805  if (getParam('votes')) $aSortingParam['rate'] = _t('_Rate');
806 
807  // gen sorting block ( type of : drop down ) ;
808 
809  $sSortBlock = $oPaginate -> getSorting($aSortingParam);
810 
811  // init some visible parameters ;
812 
813  $sPhotosChecked = ($this -> aAdditionalParameters['photos_only']) ? 'checked="checked"' : null;
814 
815  $sOnlineChecked = ($this -> aAdditionalParameters['online_only']) ? 'checked="checked"' : null;
816 
817  // ** cutting all unnecessary get parameters ;
818 
819  // link for photos section ;
820 
821  $sPhotoLocation = getClearedParam( 'photos_only', $sRequest);
822 
823  // link for online section ;
824 
825  $sOnlineLocation = getClearedParam( 'online_only', $sRequest);
826 
827  // link for `mode switcher` ;
828 
829  $sModeLocation = getClearedParam( 'mode', $sRequest);
830  $sModeLocation = getClearedParam( 'per_page', $sModeLocation);
831 
832  // ** gen header part - with some display options ;
833 
834  // fill array with template's keys ;
835  ch_import('ChWsbMemberInfo');
836  $oMemberInfo = ChWsbMemberInfo::getObjectInstance(getParam('sys_member_info_thumb'));
837 
838  $sTopControls = $GLOBALS['oSysTemplate']->parseHtmlByName('browse_sb_top_controls.html', array(
839  'sort_block' => $sSortBlock,
840  'ch_if:show_with_photos' => array(
841  'condition' => $oMemberInfo ? $oMemberInfo->isAvatarSearchAllowed() : false,
842  'content' => array(
843  'photo_checked' => $sPhotosChecked,
844  'photo_location' => $sPhotoLocation,
845  'photo_caption' => $sPhotoCaption,
846  )
847  ),
848  'online_checked' => $sOnlineChecked,
849  'online_location' => $sOnlineLocation,
850  'online_caption' => $sOnlineCaption,
851  'per_page_block' => $sPerPageBlock,
852  ));
853 
854  // build template ;
855  $sOutputHtml = $GLOBALS['oSysTemplate'] -> parseHtmlByName( $aUsedTemplates[0], array(
856  'top_controls' => $sTopControls,
857  'ch_if:show_sim_css' => array (
858  'condition' => $this->aDisplaySettings['mode'] != 'extended',
859  'content' => array()
860  ),
861  'ch_if:show_ext_css' => array (
862  'condition' => $this->aDisplaySettings['mode'] == 'extended',
863  'content' => array()
864  ),
865  'searched_data' => $sOutputHtml,
866  'pagination' => $sPagination,
867  ));
868 
869  // generate toggle ellements ;
870  $aToggleItems = array (
871  '' => _t( '_Simple' ),
872  'extended' => _t( '_Extended' ),
873  );
874 
875  foreach( $aToggleItems AS $sKey => $sValue ) {
876  $aToggleEllements[$sValue] = array (
877  'href' => $sModeLocation . '&mode=' . $sKey,
878  'dynamic' => false,
879  'active' => ($this -> aDisplaySettings['mode'] == $sKey ),
880  );
881  }
882 
883  return array($sOutputHtml, $aToggleEllements, array(), true);
884  }
885 }
process_db_input
process_db_input($sText, $iStripTags=0)
Definition: utils.inc.php:256
ChBaseBrowse\$_sSqlActive
$_sSqlActive
Definition: ChBaseBrowse.php:28
ChBaseBrowse\$bShowBothCoupleProfiles
$bShowBothCoupleProfiles
Definition: ChBaseBrowse.php:14
ChWsbMemberInfo\getObjectInstance
static getObjectInstance($sObject)
Definition: ChWsbMemberInfo.php:39
$sOutputHtml
$sOutputHtml
Definition: browse.php:86
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
$sLimitFrom
$sLimitFrom
Definition: post_mod_crss.php:49
ChBaseBrowse\$aAdditionalParameters
$aAdditionalParameters
Definition: ChBaseBrowse.php:19
$aFilteredSettings
$aFilteredSettings
Definition: browse.php:68
ChTemplSearchProfile
Definition: ChTemplSearchProfile.php:11
ChBaseBrowse\$aParameters
$aParameters
Definition: ChBaseBrowse.php:17
ChBaseBrowse\getBlockCode_SearchedMembersBlock
getBlockCode_SearchedMembersBlock()
Definition: ChBaseBrowse.php:601
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
$iCurPage
$iCurPage
Definition: post_mod_crss.php:46
php
ChBaseBrowse\$oSearchProfileTmpl
$oSearchProfileTmpl
Definition: ChBaseBrowse.php:22
ChBaseBrowse\genLinkLocation
genLinkLocation( $sType, $sTypeValue)
Definition: ChBaseBrowse.php:563
$iPerPage
else $iPerPage
Definition: browse.php:61
ChBaseBrowse
Definition: ChBaseBrowse.php:13
ChBaseBrowse\__construct
__construct(&$aFilteredSettings, &$aDisplaySettings, $sPageName)
Definition: ChBaseBrowse.php:47
ChBaseBrowse\$aDisplaySettings
$aDisplaySettings
Definition: ChBaseBrowse.php:25
ChWsbBrowse\$bPermalinkMode
$bPermalinkMode
Definition: ChWsbBrowse.php:25
$sType
$sType
Definition: actions.inc.php:11
$_GET
$_GET['debug']
Definition: index.php:67
$iIndex
$iIndex
Definition: bottom_menu_compose.php:142
and
and
Definition: license.txt:18
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
getTemplateIcon
getTemplateIcon($sFileName)
Definition: design.inc.php:193
$site
$site['ver']
Definition: version.inc.php:8
ChWsbPaginate
Definition: ChWsbPaginate.php:69
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
ChWsbBrowse\_getGlobalStatistics
_getGlobalStatistics( $sSex='', $sAge='', $sCountry='', $sPhoto='', $sOnline='', $sType='')
Definition: ChWsbBrowse.php:173
CH_TAGS_STRIP
const CH_TAGS_STRIP
Definition: utils.inc.php:22
ChWsbPageView\$sPageName
$sPageName
Definition: ChWsbPageView.php:100
ChBaseBrowse\genBrowseLink
genBrowseLink( $sName, $sValue, $sLink, $sIcon, $bImgDetect=true)
Definition: ChBaseBrowse.php:113
ChWsbBrowse
Definition: ChWsbBrowse.php:11
db_res
db_res($query, $bindings=[])
Definition: db.inc.php:39
default
Attr AllowedFrameTargets _parent and _top Values should be as validation will be done in a case sensitive manner despite W3C s recommendation XHTML Strict does not permit the target attribute so this directive will have no effect in that doctype XHTML does not enable the Target module by default
Definition: Attr.AllowedFrameTargets.txt:10
getClearedParam
getClearedParam($sExceptParam, $sString)
Definition: utils.inc.php:1207
db_value
db_value($query, $bindings=[], $error_checking=true, $index=0)
Definition: db.inc.php:98
getProfileInfo
getProfileInfo($iProfileID=0, $checkActiveStatus=false, $forceCache=false)
Definition: profiles.inc.php:249
ChBaseBrowse\getBlockCode_SettingsBlock
getBlockCode_SettingsBlock()
Definition: ChBaseBrowse.php:144
$sCaption
$sCaption
Definition: tellfriend.php:39
$iTotalNum
if(isset($_POST['crsss']) &&is_array($_POST['crsss'])) $iTotalNum
Definition: post_mod_crss.php:40
DesignBoxContent
DesignBoxContent($title, $content, $db_num=0, $caption_item='', $bottom_item='')
Definition: design.inc.php:78
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
$sName
$sName
Definition: ChWsbAdminTools.php:853
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10