BX_DOL_URL_ROOT . "index.php?leaders_mode={$sEachMode}", 'dynamic' => true, 'active' => ( $sEachMode == $sCurrentMode )); } $aPeriodTypesMale = explode(',', $sPeriodTypesMale); $aPeriodTypesFemale = explode(',', $sPeriodTypesFemale); $oVoting = new BxTemplVotingView ('profile', 0, 0); $aLeadersList = array(); $aPeriodTypes = array(); $iIDYear = $iIDMonth = $iIDWeek = $iIDDay = 0; foreach ($aPreferSex as $sSex) { $aPeriodTypes[$sSex] = ($sSex=='male') ? $aPeriodTypesMale : $aPeriodTypesFemale; foreach ($aPeriodTypes[$sSex] as $sPeriodType) { switch($sPeriodType) { case 'year': $iIDYear = $oVoting->getTopVotedItem(365, '`Profiles`', '`ID`', "AND `Profiles`.`Status` = 'Active' AND `Profiles`.`Sex` = '{$sSex}'"); $aLeadersList[$sSex]['year'] = $iIDYear; break; case 'month': $sYearAddon = ($iIDYear) ? "AND `ID`<>'{$iIDYear}'" : ''; $iIDMonth = $oVoting->getTopVotedItem(30, '`Profiles`', '`ID`', "AND `Profiles`.`Status` = 'Active' {$sYearAddon} AND `Profiles`.`Sex` = '{$sSex}'"); $aLeadersList[$sSex]['month'] = $iIDMonth; break; case 'week': $sYearAddon = ($iIDYear) ? "AND `ID`<>'{$iIDYear}'" : ''; $sMonthAddon = ($iIDMonth) ? "AND `ID`<>'{$iIDMonth}'" : ''; $iIDWeek = $oVoting->getTopVotedItem(7, '`Profiles`', '`ID`', "AND `Profiles`.`Status` = 'Active' {$sYearAddon} {$sMonthAddon} AND `Profiles`.`Sex` = '{$sSex}'"); $aLeadersList[$sSex]['week'] = $iIDWeek; break; case 'day': $sYearAddon = ($iIDYear) ? "AND `ID`<>'{$iIDYear}'" : ''; $sMonthAddon = ($iIDMonth) ? "AND `ID`<>'{$iIDMonth}'" : ''; $sWeekAddon = ($iIDWeek) ? "AND `ID`<>'{$iIDWeek}'" : ''; $iIDDay = $oVoting->getTopVotedItem(1, '`Profiles`', '`ID`', "AND `Profiles`.`Status` = 'Active' {$sYearAddon} {$sMonthAddon} {$sWeekAddon} AND `Profiles`.`Sex` = '{$sSex}'"); $aLeadersList[$sSex]['day'] = $iIDDay; break; } } $sLeaderValues .= $this->genLeaderPack($aLeadersList[$sSex], $sSex); } $sLeaders = << {$sLeaderValues}
EOF; $sLeaderMembers = $GLOBALS['oFunctions']->centerContent($sLeaders, '.featured_block_1'); return array($sLeaderMembers, $aDBTopMenu); } function genLeaderPack($aMTypes, $sSex = 'male') { $sSLeaders = ''; if (is_array($aMTypes) and count($aMTypes) > 0) { $sVacantC = _t('_Vacant'); $sOfflineC = _t('_Offline'); $sMaleIcon = getTemplateIcon('male.png'); $sFemaleIcon = getTemplateIcon('female.png'); $sSpacerIcon = getTemplateImage('spacer.gif'); $sOfflineIcon = getTemplateIcon('sys_status_offline.png'); $sSexIcon = $sThumbType = ''; switch($sSex) { case 'male': $sSexIcon = $sMaleIcon; $sThumbType = 'man'; break; case 'female': $sSexIcon = $sFemaleIcon; $sThumbType = 'woman'; break; } $sSexThumbIcon = getTemplateIcon($sThumbType . '_medium.gif'); foreach ($aMTypes as $sTopType => $iMembID) { $sTypeName = $sTopType; $sTypeNameUcf = ucfirst($sTopType); $sLabel = _t('_' . $sTypeNameUcf); $oMembVoting = new BxTemplVotingView('profile', $iMembID); $sVotingVal = '
' . $oMembVoting->getJustVotingElement(0) . '
'; $iVotesCnt = $oMembVoting->getVoteCount(); $sMembThumb = $sProfileLink = ''; if ($iMembID>0) { $sMembThumb = get_member_thumbnail($iMembID, 'none', false); $sMemberName = getNickname($iMembID); $sMemberLink = getProfileLink($iMembID); $sProfileLink = <<{$sMemberName} EOF; } else { $sMembThumb = << {$sVacantC} {$sOfflineC} EOF; $sProfileLink = <<{$sVacantC} EOF; } $sVotes = _t('_{0} votes', $iVotesCnt); $sSLeaders .= <<
 
{$sLabel}
$sVotes
{$sMembThumb} {$sVotingVal}
{$sProfileLink}
EOF; } return $sSLeaders; } } /** * News Letters block */ function getBlockCode_Subscribe() { global $site; $oSubscription = new BxDolSubscription(); $aButton = $oSubscription->getButton(0, 'system', 'mass_mailer'); return $oSubscription->getData() . $GLOBALS['oSysTemplate']->parseHtmlByName('home_page_subscribe.html', array( 'message' => _t('_SUBSCRIBE_TEXT', $site['title']), 'button_title' => $aButton['title'], 'button_script' => $aButton['script'] )); } /** * Featured members block */ function getBlockCode_Featured() { $iFeatureNum = getParam('featured_num'); $aCode = $this->getMembers('Featured', array('Featured' => 1), $iFeatureNum); return $aCode; } function getBlockCode_Members() { $iMaxNum = (int) getParam( "top_members_max_num" ); // number of profiles $aCode = $this->getMembers('Members', array(), $iMaxNum); return $aCode; } function getBlockCode_Tags($iBlockId) { $oTags = new BxTemplTags(); $oTags->getTagObjectConfig(array('type' => '')); if (!empty($oTags->aTagObjects)) { $aParam = array( 'type' => isset($_REQUEST['tags_mode']) ? $_REQUEST['tags_mode'] : $oTags->getFirstObject(), 'popular' => true, 'limit' => getParam('tags_perpage_browse') ); return array( $oTags->display($aParam, $iBlockId), $oTags->getTagsTopMenu($aParam), array(), '' ); } else return ''; } function getBlockCode_Categories($iBlockId) { $oCategories = new BxTemplCategories(); $oCategories->getTagObjectConfig(array('status' => 'active')); if (!empty($oCategories->aTagObjects)) { $aParam = array( 'type' => isset($_REQUEST['tags_mode']) ? $_REQUEST['tags_mode'] : $oCategories->getFirstObject(), 'limit' => getParam('categ_perpage_browse'), 'orderby' => 'popular' ); return array( $oCategories->display($aParam, $iBlockId, '', false, getParam('categ_show_columns')), $oCategories->getCategTopMenu($aParam), array(), '' ); } else return ''; } function getBlockCode_QuickSearch() { $aProfile = isLogged() ? getProfileInfo() : array(); // default params for search form $aDefaultParams = array( 'LookingFor' => !empty($aProfile['Sex']) ? $aProfile['Sex'] : 'male', 'Sex' => !empty($aProfile['LookingFor']) ? $aProfile['LookingFor'] : 'female', 'Country' => !empty($aProfile['Country']) ? $aProfile['Country'] : getParam('default_country'), 'DateOfBirth' => getParam('search_start_age') . '-' . getParam('search_end_age'), ); //echoDbg($aDefaultParams); $oPF = new BxDolProfileFields(10); return $oPF->getFormCode(array('default_params' => $aDefaultParams)); } function getBlockCode_SiteStats() { return '
'.getSiteStatUser().'
'; } function getBlockCode_Download() { $a = $GLOBALS['MySQL']->fromCache('sys_box_download', 'getAll', 'SELECT * FROM `sys_box_download` WHERE `disabled` = 0 ORDER BY `order`'); $s = ''; foreach ($a as $r) { if ('_' == $r['title'][0]) $r['title'] = _t($r['title']); if ('_' == $r['desc'][0]) $r['desc'] = _t($r['desc']); if (0 == strncmp('php:', $r['url'], 4)) $r['url'] = eval(substr($r['url'], 4)); if (!$r['url']) continue; $r['icon'] = $GLOBALS['oSysTemplate']->getIconUrl($r['icon']); $s .= $GLOBALS['oSysTemplate']->parseHtmlByName('download_box_unit.html', $r); } return $s; } // ----- non-block functions ----- // function getMembers ($sBlockName, $aParams = array(), $iLimit = 16, $sMode = 'last') { $aDefFields = array( 'ID', 'NickName', 'Couple', 'Sex' ); $sCode = ''; $iOnlineTime = (int)getParam( "member_online_time" ); //main fields $sqlMainFields = ""; foreach ($aDefFields as $iKey => $sValue) $sqlMainFields .= "`Profiles`. `$sValue`, "; $sqlMainFields .= "if(`DateLastNav` > SUBDATE(NOW(), INTERVAL $iOnlineTime MINUTE ), 1, 0) AS `is_online`"; // possible conditions $sqlCondition = "WHERE `Profiles`.`Status` = 'Active' and (`Profiles`.`Couple` = 0 or `Profiles`.`Couple` > `Profiles`.`ID`)"; if (is_array($aParams)) { foreach ($aParams as $sField => $sValue) $sqlCondition .= " AND `Profiles`.`$sField` = '$sValue'"; } // top menu and sorting $aModes = array('last', 'top', 'rand', 'online'); $aDBTopMenu = array(); if (empty($_GET[$sBlockName . 'Mode'])) { $sMode = 'last'; } else { $sMode = (in_array($_GET[$sBlockName . 'Mode'], $aModes)) ? $_GET[$sBlockName . 'Mode'] : $sMode = 'rand'; } $sqlOrder = ""; foreach( $aModes as $sMyMode ) { switch ($sMyMode) { case 'online': if ($sMode == $sMyMode) { $sqlCondition .= " AND `Profiles`.`DateLastNav` > SUBDATE(NOW(), INTERVAL ".$iOnlineTime." MINUTE)"; $sqlOrder = " ORDER BY `Profiles`.`Couple` ASC"; } $sModeTitle = _t('_Online'); break; case 'last': if ($sMode == $sMyMode) $sqlOrder = " ORDER BY `Profiles`.`Couple` ASC, `Profiles`.`DateReg` DESC"; $sModeTitle = _t('_Latest'); break; case 'rand': if ($sMode == $sMyMode) $sqlOrder = " ORDER BY `Profiles`.`Couple` ASC, `Profiles`.`Avatar` <> 0 DESC, RAND()"; $sModeTitle = _t('_Random'); break; case 'top': if ($sMode == $sMyMode) { $oVotingView = new BxTemplVotingView ('profile', 0, 0); $aSql = $oVotingView->getSqlParts('`Profiles`', '`ID`'); $sqlOrder = $oVotingView->isEnabled() ? " ORDER BY `Profiles`.`Couple` ASC, (`pr_rating_sum`/`pr_rating_count`) DESC, `pr_rating_count` DESC, `Profiles`.`DateReg` DESC" : $sqlOrder; $sqlMainFields .= $aSql['fields']; $sqlLJoin = $aSql['join']; $sqlCondition .= " AND `pr_rating_count` > 1"; } $sModeTitle = _t('_Top'); break; } $aDBTopMenu[$sModeTitle] = array('href' => BX_DOL_URL_ROOT . "index.php?{$sBlockName}Mode=$sMyMode", 'dynamic' => true, 'active' => ( $sMyMode == $sMode )); } if (empty($sqlLJoin)) $sqlLJoin = ''; $iCount = (int)db_value("SELECT COUNT(`Profiles`.`ID`) FROM `Profiles` $sqlLJoin $sqlCondition"); $aData = array(); $sPaginate = ''; if ($iCount) { $iNewWidth = BX_AVA_W + 6; $iLimit = (int)$iLimit > 0 ? (int)$iLimit : 8; $iPages = ceil($iCount/ $iLimit); $iPage = empty($_GET['page']) ? 1 : (int)$_GET['page']; if ($iPage > $iPages) $iPage = $iPages; if ($iPage < 1) $iPage = 1; $sqlFrom = ($iPage - 1) * $iLimit; $sqlLimit = "LIMIT $sqlFrom, $iLimit"; $sqlQuery = "SELECT " . $sqlMainFields . " FROM `Profiles` $sqlLJoin $sqlCondition $sqlOrder $sqlLimit"; $rData = db_res($sqlQuery); $iCurrCount = mysql_num_rows($rData); $aOnline = array(); while ($aData = mysql_fetch_assoc($rData)) { $sCode .= ''; } $sCode = $GLOBALS['oFunctions']->centerContent($sCode, '.featured_block_1'); if ($iPages > 1) { $oPaginate = new BxDolPaginate(array( 'page_url' => BX_DOL_URL_ROOT . 'index.php', 'count' => $iCount, 'per_page' => $iLimit, 'page' => $iPage, 'per_page_changer' => true, 'page_reloader' => true, 'on_change_page' => 'return !loadDynamicBlock({id}, \'index.php?'.$sBlockName.'Mode='.$sMode.'&page={page}&per_page={per_page}\');', 'on_change_per_page' => '' )); $sPaginate = $oPaginate->getSimplePaginate(BX_DOL_URL_ROOT . 'browse.php'); } } else { $sCode = MsgBox(_t("_Empty")); } return array($sCode, $aDBTopMenu, $sPaginate); } /** * Returns the promo code. * * @todo rewrite this code for more wide using of template engine */ function getPromoCode() { $sSiteUrl = BX_DOL_URL_ROOT; if( getParam( 'enable_flash_promo' ) != 'on' ) $sCode = '
' . getParam( 'custom_promo_code' ) . '
'; else { $aImages = getPromoImagesArray(); $iImages = count($aImages); $sImagesEls = ''; foreach ($aImages as $sImg) $sImagesEls .= ''; $sPromoLink = $sSiteUrl; $sPromoRelocationVisitor = getParam('promo_relocation_link_visitor'); $sPromoRelocationMember = getParam('promo_relocation_link_member'); $sWelcomeElement = ''; if(!isMember()) { $sWelcomeC = _t('_Welcome_to_the_community'); $sWelcomeElement = '
' . $sWelcomeC . '
'; $sPromoLink .= ($sPromoRelocationVisitor!='') ? $sPromoRelocationVisitor : 'join.php'; $sLoginSection = '
'; } else { $sLoginSection = ''; $aInfo = getProfileInfo(); $sWelcomeElement = '
' . get_member_thumbnail($aInfo['ID'], "left", false) . '
' . _t('_Hello member', $aInfo['NickName']) . '
'; } $sCode = ''; if($iImages > 1) { $GLOBALS['oSysTemplate']->addJs('jquery.dolPromo.js'); $sCode .= << $(document).ready( function() { $('#indexPhoto').dolPromo(8000, 1500); } ); EOF; } $sCode .= <<
{$sWelcomeElement} {$sLoginSection}
{$sImagesEls}
EOF; } return $sCode; } } ?>