Cheetah
ChBaseIndexPageView.php
Go to the documentation of this file.
1 <?php
2 
8 include_once (CH_DIRECTORY_PATH_MODULES . 'cheetah/avatar/include.php');
9 
10 ch_import('ChWsbSubscription');
11 ch_import('ChTemplTags');
12 ch_import('ChTemplCategories');
13 
15 {
16  function __construct()
17  {
18  ChWsbPageView::__construct( 'index' );
19  }
20 
25  {
26  global $site;
27 
28  $iUserId = isLogged() ? getLoggedId() : 0;
29 
31  $aButton = $oSubscription->getButton($iUserId, 'system', '');
32  $sContent = $oSubscription->getData() . $GLOBALS['oSysTemplate']->parseHtmlByName('home_page_subscribe.html', array(
33  'message' => _t('_SUBSCRIBE_TEXT', $site['title']),
34  'button_title' => $aButton['title'],
35  'button_script' => $aButton['script']
36  ));
37 
38  return array($sContent, array(), array(), false);
39  }
40 
45  {
46  $iFeatureNum = getParam('featured_num');
47  $aCode = $this->getMembers('Featured', array('Featured' => 1), $iFeatureNum);
48  return $aCode;
49  }
50 
52  {
53  $iMaxNum = (int) getParam( "top_members_max_num" ); // number of profiles
54  $aCode = $this->getMembers('Members', array(), $iMaxNum);
55  return $aCode;
56  }
57 
58  function getBlockCode_Tags($iBlockId)
59  {
60  $oTags = new ChTemplTags();
61  $oTags->getTagObjectConfig(array('type' => ''));
62 
63  if(empty($oTags->aTagObjects))
64  return '';
65 
66  $aParam = array(
67  'type' => isset($_REQUEST['tags_mode']) && isset($oTags->aTagObjects[$_REQUEST['tags_mode']]) ? $_REQUEST['tags_mode'] : $oTags->getFirstObject(),
68  'orderby' => 'popular',
69  'limit' => getParam('tags_perpage_browse')
70  );
71 
72  $sMenu = $oTags->getTagsTopMenu($aParam);
73  $sContent = $oTags->display($aParam, $iBlockId);
74  return array($sContent, $sMenu, array(), false);
75  }
76 
77  function getBlockCode_Categories($iBlockId)
78  {
79  $oCategories = new ChTemplCategories();
80  $oCategories->getTagObjectConfig(array('status' => 'active'));
81 
82  if(empty($oCategories->aTagObjects))
83  return '';
84 
85  $aParam = array(
86  'type' => isset($_REQUEST['tags_mode']) && isset($oCategories->aTagObjects[$_REQUEST['tags_mode']]) ? $_REQUEST['tags_mode'] : $oCategories->getFirstObject(),
87  'limit' => getParam('categ_perpage_browse'),
88  'orderby' => 'popular'
89  );
90 
91  $sMenu = $oCategories->getCategTopMenu($aParam);
92  $sContent = $oCategories->display($aParam, $iBlockId, '', false, getParam('categ_show_columns'));
93  return array($sContent, $sMenu, array(), false);
94  }
95 
97  {
98  $aProfile = isLogged() ? getProfileInfo() : array();
99 
100  // default params for search form
101  $aDefaultParams = array(
102  'LookingFor' => !empty($aProfile['Sex']) ? $aProfile['Sex'] : 'male',
103  'Sex' => !empty($aProfile['LookingFor']) ? $aProfile['LookingFor'] : 'female',
104  'Country' => !empty($aProfile['Country']) ? $aProfile['Country'] : getParam('default_country'),
105  'DateOfBirth' => getParam('search_start_age') . '-' . getParam('search_end_age'),
106  );
107 
108  $oPF = new ChWsbProfileFields(10);
109  return array($oPF->getFormCode(array('default_params' => $aDefaultParams)), array(), array(), false);
110  }
111 
113  {
114  return array(getSiteStatUser(), array(), array(), false);
115  }
116 
118  {
119  $a = $GLOBALS['MySQL']->fromCache('sys_box_download', 'getAll', 'SELECT * FROM `sys_box_download` WHERE `disabled` = 0 ORDER BY `order`');
120  $s = '';
121 
122  foreach ($a as $r) {
123  if ('_' == $r['title'][0])
124  $r['title'] = _t($r['title']);
125  if ('_' == $r['desc'][0])
126  $r['desc'] = _t($r['desc']);
127 
128  if (0 === strncmp('php:', $r['url'], 4))
129  $r['url'] = eval(substr($r['url'], 4));
130  if (!$r['url'])
131  continue;
132 
133  $s .= $GLOBALS['oSysTemplate']->parseHtmlByName('download_box_unit.html', $r);
134  }
135 
136  return array($s, array(), array(), false);
137  }
138 
139  // ----- non-block functions ----- //
140  function getMembers ($sBlockName, $aParams = array(), $iLimit = 16, $sMode = 'last')
141  {
142  $aDefFields = array(
143  'ID', 'NickName', 'Couple', 'Sex'
144  );
145  $sCode = '';
146 
147  $iOnlineTime = (int)getParam( "member_online_time" );
148 
149  //main fields
150  $sqlMainFields = "";
151  foreach ($aDefFields as $iKey => $sValue)
152  $sqlMainFields .= "`Profiles`. `$sValue`, ";
153 
154  $sqlMainFields .= "if(`DateLastNav` > SUBDATE(NOW(), INTERVAL $iOnlineTime MINUTE ), 1, 0) AS `is_online`";
155 
156  // possible conditions
157  $sqlCondition = "WHERE `Profiles`.`Status` = 'Active' and (`Profiles`.`Couple` = 0 or `Profiles`.`Couple` > `Profiles`.`ID`)";
158  if (is_array($aParams)) {
159  foreach ($aParams as $sField => $sValue)
160  $sqlCondition .= " AND `Profiles`.`$sField` = '$sValue'";
161  }
162 
163  // top menu and sorting
164  $aModes = getParam('votes') ? array('last', 'top', 'online') : array('last', 'online');
165  $aDBTopMenu = array();
166 
167  if (empty($_GET[$sBlockName . 'Mode'])) {
168  $sMode = 'last';
169  } else {
170  $sMode = (in_array($_GET[$sBlockName . 'Mode'], $aModes)) ? $_GET[$sBlockName . 'Mode'] : $sMode = 'last';
171  }
172  $sqlOrder = "";
173  foreach( $aModes as $sMyMode ) {
174  switch ($sMyMode) {
175  case 'online':
176  if ($sMode == $sMyMode) {
177  $sqlCondition .= " AND `Profiles`.`DateLastNav` > SUBDATE(NOW(), INTERVAL ".$iOnlineTime." MINUTE)";
178  $sqlOrder = " ORDER BY `Profiles`.`DateLastNav` DESC";
179  $sViewAllQuery = 'online_only=on';
180  }
181  $sModeTitle = _t('_Online');
182  break;
183  case 'last':
184  if ($sMode == $sMyMode) {
185  $sqlOrder = " ORDER BY `Profiles`.`DateReg` DESC";
186  $sViewAllQuery = 'sort=date_reg';
187  }
188  $sModeTitle = _t('_Latest');
189  break;
190  case 'top':
191  if ($sMode == $sMyMode) {
192  $sqlOrder = ' ORDER BY `Profiles`.`Rate` DESC, `Profiles`.`RateCount` DESC';
193  $sViewAllQuery = 'sort=rate';
194  }
195  $sModeTitle = _t('_Top');
196  break;
197  }
198  $aDBTopMenu[$sModeTitle] = array('href' => CH_WSB_URL_ROOT . "index.php?{$sBlockName}Mode=$sMyMode", 'dynamic' => true, 'active' => ( $sMyMode == $sMode ));
199  }
200  $iCount = (int)db_value("SELECT COUNT(`Profiles`.`ID`) FROM `Profiles` $sqlCondition");
201  $aData = array();
202  $sPaginate = '';
203  if ($iCount) {
204  $iLimit = (int)$iLimit > 0 ? (int)$iLimit : 8;
205  $iPages = ceil($iCount/ $iLimit);
206  $iPage = empty($_GET['page']) ? 1 : (int)$_GET['page'];
207  if ($iPage > $iPages)
208  $iPage = $iPages;
209  if ($iPage < 1)
210  $iPage = 1;
211  $sqlFrom = ($iPage - 1) * $iLimit;
212  $sqlLimit = "LIMIT $sqlFrom, $iLimit";
213 
214  $sqlQuery = "SELECT " . $sqlMainFields . " FROM `Profiles` $sqlCondition $sqlOrder $sqlLimit";
215  $rData = db_res($sqlQuery);
216  $iCurrCount = $rData->rowCount();
217  $aOnline = $aTmplVars = array();
218  while ($aData = $rData->fetch()) {
219  $aOnline['is_online'] = $aData['is_online'];
220  $aTmplVars[] = array(
221  'thumbnail' => get_member_thumbnail($aData['ID'], 'none', true, 'visitor', $aOnline)
222  );
223  }
224  $sCode = $GLOBALS['oSysTemplate']->parseHtmlByName('members_list.html', array(
225  'ch_repeat:list' => $aTmplVars
226  ));
227 
228  if ($iPages > 1) {
229  $oPaginate = new ChWsbPaginate(array(
230  'page_url' => CH_WSB_URL_ROOT . 'index.php',
231  'count' => $iCount,
232  'per_page' => $iLimit,
233  'page' => $iPage,
234  'on_change_page' => 'return !loadDynamicBlock({id}, \'index.php?'.$sBlockName.'Mode='.$sMode.'&page={page}&per_page={per_page}\');',
235  ));
236  $sViewAllUrl = empty($aParams['Featured']) ? 'browse.php?' : 'search.php?show=featured&amp;';
237  $sPaginate = $oPaginate->getSimplePaginate(CH_WSB_URL_ROOT . $sViewAllUrl . $sViewAllQuery);
238  }
239  } else {
240  $sCode = MsgBox(_t("_Empty"));
241  }
242  return array($sCode, $aDBTopMenu, $sPaginate, true);
243  }
244 }
ChBaseIndexPageView\getBlockCode_Subscribe
getBlockCode_Subscribe()
Definition: ChBaseIndexPageView.php:24
ChBaseIndexPageView\getBlockCode_Download
getBlockCode_Download()
Definition: ChBaseIndexPageView.php:117
$sMode
else $sMode
Definition: antispam.php:362
ChWsbProfileFields
Definition: ChWsbProfileFields.php:13
MsgBox
MsgBox($sText, $iTimer=0)
Definition: design.inc.php:175
ChWsbPageView
Definition: ChWsbPageView.php:99
ChBaseIndexPageView\getBlockCode_Tags
getBlockCode_Tags($iBlockId)
Definition: ChBaseIndexPageView.php:58
ch_import
ch_import($sClassName, $aModule=array())
Definition: utils.inc.php:1218
ChBaseIndexPageView\getBlockCode_Members
getBlockCode_Members()
Definition: ChBaseIndexPageView.php:51
ChWsbPageView\__construct
__construct( $sPageName)
Definition: ChWsbPageView.php:114
ChBaseIndexPageView\getBlockCode_QuickSearch
getBlockCode_QuickSearch()
Definition: ChBaseIndexPageView.php:96
php
isLogged
isLogged()
Definition: profiles.inc.php:24
ChBaseIndexPageView\__construct
__construct()
Definition: ChBaseIndexPageView.php:16
ChWsbSubscription\getInstance
static getInstance()
Definition: ChWsbSubscription.php:67
getSiteStatUser
getSiteStatUser()
Definition: design.inc.php:226
ChTemplCategories
Definition: ChTemplCategories.php:11
$_GET
$_GET['debug']
Definition: index.php:67
getParam
getParam($sParamName, $bUseCache=true)
Definition: db.inc.php:130
get_member_thumbnail
get_member_thumbnail($ID, $float, $bGenProfLink=false, $sForceSex='visitor', $aOnline=array())
Definition: design.inc.php:165
getLoggedId
getLoggedId()
Definition: profiles.inc.php:32
$aProfile
$aProfile
Definition: flash.php:14
ChTemplTags
Definition: ChTemplTags.php:11
$site
$site['ver']
Definition: version.inc.php:8
$_REQUEST
$_REQUEST['action']
Definition: cmd.php:11
ChWsbPaginate
Definition: ChWsbPaginate.php:69
global
if(!defined("GLOBAL_MODULE")) define("GLOBAL_MODULE" global
Definition: header.inc.php:25
ChBaseIndexPageView
Definition: ChBaseIndexPageView.php:15
$sContent
$sContent
Definition: bottom_menu_compose.php:169
_t
_t($key, $arg0="", $arg1="", $arg2="")
Definition: languages.inc.php:509
$s
$s
Definition: embed.php:13
ChBaseIndexPageView\getBlockCode_SiteStats
getBlockCode_SiteStats()
Definition: ChBaseIndexPageView.php:112
$iPage
$iPage
Definition: browse.php:50
db_res
db_res($query, $bindings=[])
Definition: db.inc.php:39
ChBaseIndexPageView\getBlockCode_Featured
getBlockCode_Featured()
Definition: ChBaseIndexPageView.php:44
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
ChBaseIndexPageView\getMembers
getMembers($sBlockName, $aParams=array(), $iLimit=16, $sMode='last')
Definition: ChBaseIndexPageView.php:140
empty
Attr AllowedRel this is empty
Definition: Attr.AllowedRel.txt:7
as
as
Definition: Filter.ExtractStyleBlocks.Escaping.txt:10
ChWsbPageView\$sCode
$sCode
Definition: ChWsbPageView.php:102
$GLOBALS
$GLOBALS['iAdminPage']
Definition: advanced_settings.php:10
ChBaseIndexPageView\getBlockCode_Categories
getBlockCode_Categories($iBlockId)
Definition: ChBaseIndexPageView.php:77
$oSubscription
$oSubscription
Definition: notifies.php:28