Пример #1
0
 function genSearchPagination($iCountProfiles, $iCurrentPage, $iResultsPerPage, $aFilterSortSettings = array(), $sPgnRoot = '')
 {
     $aGetParams = $_GET;
     unset($aGetParams['page']);
     unset($aGetParams['res_per_page']);
     unset($aGetParams['sort']);
     $sRequestString = $this->collectRequestString($aGetParams);
     $sRequestString = BX_DOL_URL_ROOT . strip_tags($sPgnRoot) . '?' . substr($sRequestString, 1);
     $sPaginTmpl = $sRequestString . '&res_per_page={per_page}&page={page}&sort={sorting}';
     // gen pagination block ;
     $oPaginate = new BxDolPaginate(array('page_url' => $sPaginTmpl, 'count' => $iCountProfiles, 'per_page' => $iResultsPerPage, 'sorting' => $aFilterSortSettings['sort'], 'page' => $iCurrentPage));
     $sPagination = $oPaginate->getPaginate();
     // fill array with sorting params ;
     $aSortingParam = array('none' => _t('_None'), 'activity' => _t('_Latest activity'), 'date_reg' => _t('_FieldCaption_DateReg_View'));
     // gen sorting block ( type of : drop down ) ;
     $sSortBlock = $oPaginate->getSorting($aSortingParam);
     $sSortElement = '<div class="ordered_block">' . $sSortBlock . '</div><div class="clear_both"></div>';
     $sSortElement = $GLOBALS['oSysTemplate']->parseHtmlByName('designbox_top_controls.html', array('top_controls' => $sSortElement));
     return array($sPagination, $sSortElement);
 }
Пример #2
0
 /**
  * @description : function will generate friends list ;
  * @return		: array ;
  */
 function getBlockCode_Friends()
 {
     // init some variables ;
     $sOutputHtml = '';
     $sEmpty = '';
     $iIndex = '';
     $aUsedTemplates = array('browse_searched_block.html');
     // lang keys ;
     $sPhotoCaption = _t('_With photos only');
     $sOnlineCaption = _t('_online only');
     // collect the SQL parameters ;
     $aWhereParam = array();
     if ($this->aDisplayParameters['photos']) {
         $aWhereParam[] = 'p.`Avatar` <> 0';
     }
     if ($this->aDisplayParameters['online']) {
         $aWhereParam[] = "(p.`DateLastNav` > SUBDATE(NOW(), INTERVAL " . $this->iMemberOnlineTime . " MINUTE)) ";
     }
     $sWhereParam = null;
     foreach ($aWhereParam as $sValue) {
         if ($sValue) {
             $sWhereParam .= ' AND ' . $sValue;
         }
     }
     $iTotalNum = getFriendNumber($this->iProfileID, 1, 0, $sWhereParam);
     if (!$iTotalNum) {
         $sEmpty = MsgBox(_t('_Empty'));
     }
     $iPerPage = $this->aDisplayParameters['per_page'];
     $iCurPage = $this->aDisplayParameters['page'];
     $sLimitFrom = ($iCurPage - 1) * $iPerPage;
     $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
     // switch member's template ;
     $sTemplateName = $this->aDisplayParameters['mode'] == 'extended' ? 'search_profiles_ext.html' : 'search_profiles_sim.html';
     // select the sorting parameters ;
     $sSortParam = 'activity_desc';
     if (isset($this->aDisplayParameters['sort'])) {
         switch ($this->aDisplayParameters['sort']) {
             case 'activity':
                 $sSortParam = 'activity_desc';
                 break;
             case 'date_reg':
                 $sSortParam = 'date_reg_desc';
                 break;
             case 'rate':
                 $sSortParam = 'rate';
                 break;
             default:
                 $this->aDisplayParameters['sort'] = 'activity';
                 break;
         }
     } else {
         $this->aDisplayParameters['sort'] = 'activity';
     }
     $aAllFriends = getMyFriendsEx($this->iProfileID, $sWhereParam, $sSortParam, $sqlLimit);
     $aExtendedCss = array('ext_css_class' => $this->aDisplayParameters['mode'] == 'extended' ? 'search_filled_block' : '');
     foreach ($aAllFriends as $iFriendID => $aFriendsPrm) {
         $aMemberInfo = getProfileInfo($iFriendID);
         if ($aMemberInfo['Couple']) {
             $aCoupleInfo = getProfileInfo($aMemberInfo['Couple']);
             $sOutputHtml .= $this->oSearchProfileTmpl->PrintSearhResult($aMemberInfo, $aCoupleInfo, $iIndex % 2 ? $aExtendedCss : array(), $sTemplateName);
         } else {
             $sOutputHtml .= $this->oSearchProfileTmpl->PrintSearhResult($aMemberInfo, array(), $iIndex % 2 ? $aExtendedCss : array(), $sTemplateName);
         }
         $iIndex++;
     }
     $sOutputHtml .= '<div class="clear_both"></div>';
     // work with link pagination ;
     $aGetParams = array('mode', 'iUser', 'photos_only', 'online_only');
     $sRequest = BX_DOL_URL_ROOT . 'viewFriends.php?';
     $sRequest .= bx_encode_url_params($_GET, array(), $aGetParams) . 'page={page}&per_page={per_page}&sort={sorting}';
     // gen pagination block ;
     $oPaginate = new BxDolPaginate(array('page_url' => $sRequest, 'count' => $iTotalNum, 'per_page' => $iPerPage, 'page' => $iCurPage, 'sorting' => $this->aDisplayParameters['sort']));
     $sPagination = $oPaginate->getPaginate();
     // ** GENERATE HEADER PART ;
     // gen per page block ;
     $sPerPageBlock = $oPaginate->getPages($iPerPage);
     // fill array with sorting params ;
     $aSortingParam = array('activity' => _t('_Latest activity'), 'date_reg' => _t('_FieldCaption_DateReg_View'), 'rate' => _t('_Rate'));
     // gen sorting block ( type of : drop down ) ;
     $sSortBlock = $oPaginate->getSorting($aSortingParam);
     $sRequest = str_replace('{page}', '1', $sRequest);
     $sRequest = str_replace('{per_page}', $iPerPage, $sRequest);
     $sRequest = str_replace('{sorting}', $this->aDisplayParameters['sort'], $sRequest);
     // init some visible parameters ;
     $sPhotosChecked = $this->aDisplayParameters['photos'] ? 'checked="checked"' : null;
     $sOnlineChecked = $this->aDisplayParameters['online'] ? 'checked="checked"' : null;
     // link for photos section ;
     $sPhotoLocation = $this->getCutParam('photos_only', $sRequest);
     // link for online section ;
     $sOnlineLocation = $this->getCutParam('online_only', $sRequest);
     // link for `mode switcher` ;
     $sModeLocation = $this->getCutParam('mode', $sRequest);
     $sModeLocation = $this->getCutParam('per_page', $sModeLocation);
     bx_import('BxDolMemberInfo');
     $oMemberInfo = BxDolMemberInfo::getObjectInstance(getParam('sys_member_info_thumb'));
     $sTopControls = $GLOBALS['oSysTemplate']->parseHtmlByName('browse_sb_top_controls.html', array('sort_block' => $sSortBlock, 'bx_if:show_with_photos' => array('condition' => $oMemberInfo->isAvatarSearchAllowed(), 'content' => array('photo_checked' => $sPhotosChecked, 'photo_location' => $sPhotoLocation, 'photo_caption' => $sPhotoCaption)), 'online_checked' => $sOnlineChecked, 'online_location' => $sOnlineLocation, 'online_caption' => $sOnlineCaption, 'per_page_block' => $sPerPageBlock));
     // build template ;
     $sOutputHtml = $GLOBALS['oSysTemplate']->parseHtmlByName($aUsedTemplates[0], array('top_controls' => $sTopControls, 'bx_if:show_sim_css' => array('condition' => $this->aDisplayParameters['mode'] != 'extended', 'content' => array()), 'bx_if:show_ext_css' => array('condition' => $this->aDisplayParameters['mode'] == 'extended', 'content' => array()), 'searched_data' => $sOutputHtml, 'pagination' => $sPagination));
     // build the toggle block ;
     $aToggleItems = array('' => _t('_Simple'), 'extended' => _t('_Extended'));
     foreach ($aToggleItems as $sKey => $sValue) {
         $aToggleEllements[$sValue] = array('href' => $sModeLocation . '&mode=' . $sKey, 'dynamic' => true, 'active' => $this->aDisplayParameters['mode'] == $sKey);
     }
     return array($sOutputHtml . $sEmpty, $aToggleEllements, array(), true);
 }
Пример #3
0
 /**
  * Function will find all needed members by some criteria ;
  *
  * @return  : Html presentation data ;
  */
 function getBlockCode_SearchedMembersBlock()
 {
     // lang keys ;
     $sOutputHtml = '';
     $sPhotoCaption = _t('_With photos only');
     $sOnlineCaption = _t('_online only');
     $sSimpleCaption = _t('_Simple');
     $sExtendCaption = _t('_Extended');
     $aUsedTemplates = array('browse_searched_block.html');
     // collect the SQL parameters ;
     $aWhereParam = array();
     $aWhereParam[] = $this->aParameters['sex'] ? '`Profiles`.`Sex` = "' . $this->aParameters['sex'] . '"' : null;
     if ($this->aParameters['age']) {
         $aAgeTemp = explode('-', $this->aParameters['age']);
         $iFrom = isset($aAgeTemp[0]) ? (int) $aAgeTemp[0] : 0;
         $iTo = isset($aAgeTemp[1]) ? (int) $aAgeTemp[1] : 0;
         unset($aAgeTemp);
         if ($iFrom) {
             $sSign = $iTo ? '>=' : '=';
             $aWhereParam[] = "\n                    ((YEAR(CURDATE())-YEAR(`Profiles`.`DateOfBirth`)) - (RIGHT(CURDATE(),5)<RIGHT(`Profiles`.`DateOfBirth`,5))) {$sSign} {$iFrom}\n                ";
         }
         if ($iTo) {
             $sSign = $iFrom ? '<=' : '=';
             $aWhereParam[] = "\n                    ((YEAR(CURDATE())-YEAR(`Profiles`.`DateOfBirth`)) - (RIGHT(CURDATE(),5)<RIGHT(`Profiles`.`DateOfBirth`,5))) {$sSign} {$iTo}\n                ";
         }
     }
     $aWhereParam[] = $this->aParameters['country'] ? '`Profiles`.`Country` = "' . $this->aParameters['country'] . '"' : null;
     if ($this->aAdditionalParameters['photos_only']) {
         $aWhereParam[] = '`Profiles`.`Avatar` <> 0';
     }
     if ($this->aAdditionalParameters['online_only']) {
         $aWhereParam[] = "(`Profiles`.`DateLastNav` > SUBDATE(NOW(), INTERVAL " . $this->iMemberOnlineTime . " MINUTE)) ";
     }
     $sWhereParam = null;
     foreach ($aWhereParam as $sValue) {
         if ($sValue) {
             $sWhereParam .= ' AND ' . $sValue;
         }
     }
     // make search ;
     $sQuery = "SELECT COUNT(*) AS `Cnt` FROM `Profiles` WHERE {$this->_sSqlActive} {$sWhereParam}";
     $iTotalNum = db_value($sQuery);
     if (!$iTotalNum) {
         $sOutputHtml = MsgBox(_t('_Empty'));
     }
     // init some pagination parameters ;
     $iPerPage = $this->aDisplaySettings['per_page'];
     $iCurPage = $this->aDisplaySettings['page'];
     if ($iCurPage < 1) {
         $iCurPage = 1;
     }
     $sLimitFrom = ($iCurPage - 1) * $iPerPage;
     $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
     // switch template for `simle` and `advanced` mode ;
     $sTemplateName = $this->aDisplaySettings['mode'] == 'extended' ? 'search_profiles_ext.html' : 'search_profiles_sim.html';
     // select sorting parameters ;
     $sSortParam = '`Profiles`.`DateLastNav` DESC';
     if (isset($this->aDisplaySettings['sort'])) {
         switch ($this->aDisplaySettings['sort']) {
             case 'date_reg':
                 $sSortParam = ' `Profiles`.`DateReg` DESC';
                 break;
             case 'rate':
                 $sSortParam = ' `Profiles`.`Rate` DESC, `Profiles`.`RateCount` DESC';
                 break;
             default:
                 $this->aDisplaySettings['sort'] = 'activity';
             case 'activity':
                 $sSortParam = ' `Profiles`.`DateLastNav` DESC';
                 break;
         }
     } else {
         $this->aDisplaySettings['sort'] = 'activity';
     }
     // status uptimization
     $iOnlineTime = (int) getParam("member_online_time");
     $sIsOnlineSQL = ", if(`DateLastNav` > SUBDATE(NOW(), INTERVAL {$iOnlineTime} MINUTE ), 1, 0) AS `is_online`";
     $sQuery = "\n            SELECT\n                `Profiles`.* {$sIsOnlineSQL}\n            FROM\n                `Profiles`\n            WHERE\n                {$this->_sSqlActive}\n                {$sWhereParam}\n            ORDER BY\n                {$sSortParam}\n            {$sqlLimit}\n        ";
     $rResult = db_res($sQuery);
     $iIndex = 0;
     // need for the block divider ;
     $aExtendedCss = array('ext_css_class' => $this->aDisplaySettings['mode'] == 'extended' ? 'search_filled_block' : '');
     while (true == ($aRow = mysql_fetch_assoc($rResult))) {
         // generate the `couple` thumbnail ;
         if ($aRow['Couple']) {
             $aCoupleInfo = getProfileInfo($aRow['Couple']);
             $sOutputHtml .= $this->oSearchProfileTmpl->PrintSearhResult($aRow, $aCoupleInfo, $iIndex % 2 ? $aExtendedCss : array(), $sTemplateName);
         } else {
             $sOutputHtml .= $this->oSearchProfileTmpl->PrintSearhResult($aRow, array(), $iIndex % 2 ? $aExtendedCss : array(), $sTemplateName);
         }
         $iIndex++;
     }
     // # end of search generation ;
     // work with link pagination ;
     if ($this->bPermalinkMode) {
         preg_match("|([^\\?\\&]*)|", $_SERVER['REQUEST_URI'], $aMatches);
         if (isset($aMatches[1]) and $aMatches[1]) {
             $sRequest = $aMatches[1] . '?';
         }
         // need for additional parameters ;
         $aGetParams = array('photos_only', 'online_only', 'sort', 'mode');
         foreach ($aGetParams as $sValue) {
             if (isset($_GET[$sValue])) {
                 $sRequest .= '&' . $sValue . '=' . rawurlencode($_GET[$sValue]);
             }
         }
     } else {
         $sRequest = BX_DOL_URL_ROOT . 'browse.php?';
         // need for additional parameters ;
         $aGetParams = array('sex', 'age', 'country', 'photos_only', 'online_only', 'sort', 'mode');
         foreach ($aGetParams as $sValue) {
             if (isset($_GET[$sValue])) {
                 $sRequest .= '&' . $sValue . '=' . rawurlencode($_GET[$sValue]);
             }
         }
     }
     // cutted al aunecessary parameters ;
     $sRequest = getClearedParam('sort', $sRequest);
     $sRequest = $sRequest . '&page={page}&per_page={per_page}&sort={sorting}';
     // gen pagination block ;
     $oPaginate = new BxDolPaginate(array('page_url' => $sRequest, 'count' => $iTotalNum, 'per_page' => $iPerPage, 'sorting' => $this->aDisplaySettings['sort'], 'page' => $iCurPage, 'per_page_changer' => false, 'page_reloader' => true, 'on_change_page' => null, 'on_change_per_page' => null));
     $sPagination = $oPaginate->getPaginate();
     // gen per page block ;
     $sPerPageBlock = $oPaginate->getPages($iPerPage);
     // prepare to output ;
     $sOutputHtml .= '
         <div class="clear_both"></div>
     ';
     $sRequest = str_replace('{page}', '1', $sRequest);
     $sRequest = str_replace('{per_page}', $iPerPage, $sRequest);
     $sRequest = str_replace('{sorting}', $this->aDisplaySettings['sort'], $sRequest);
     // fill array with sorting params ;
     $aSortingParam = array('activity' => _t('_Latest activity'), 'date_reg' => _t('_FieldCaption_DateReg_View'), 'rate' => _t('_Rate'));
     // gen sorting block ( type of : drop down ) ;
     $sSortBlock = $oPaginate->getSorting($aSortingParam);
     // init some visible parameters ;
     $sPhotosChecked = $this->aAdditionalParameters['photos_only'] ? 'checked="checked"' : null;
     $sOnlineChecked = $this->aAdditionalParameters['online_only'] ? 'checked="checked"' : null;
     // ** cutting all unnecessary get parameters ;
     // link for photos section ;
     $sPhotoLocation = getClearedParam('photos_only', $sRequest);
     // link for online section ;
     $sOnlineLocation = getClearedParam('online_only', $sRequest);
     // link for `mode switcher` ;
     $sModeLocation = getClearedParam('mode', $sRequest);
     $sModeLocation = getClearedParam('per_page', $sModeLocation);
     // ** gen header part - with some display options ;
     // fill array with template's keys ;
     bx_import('BxDolMemberInfo');
     $oMemberInfo = BxDolMemberInfo::getObjectInstance(getParam('sys_member_info_thumb'));
     $sTopControls = $GLOBALS['oSysTemplate']->parseHtmlByName('browse_sb_top_controls.html', array('sort_block' => $sSortBlock, 'bx_if:show_with_photos' => array('condition' => $oMemberInfo->isAvatarSearchAllowed(), 'content' => array('photo_checked' => $sPhotosChecked, 'photo_location' => $sPhotoLocation, 'photo_caption' => $sPhotoCaption)), 'online_checked' => $sOnlineChecked, 'online_location' => $sOnlineLocation, 'online_caption' => $sOnlineCaption, 'per_page_block' => $sPerPageBlock));
     // build template ;
     $sOutputHtml = $GLOBALS['oSysTemplate']->parseHtmlByName($aUsedTemplates[0], array('top_controls' => $sTopControls, 'bx_if:show_sim_css' => array('condition' => $this->aDisplaySettings['mode'] != 'extended', 'content' => array()), 'bx_if:show_ext_css' => array('condition' => $this->aDisplaySettings['mode'] == 'extended', 'content' => array()), 'searched_data' => $sOutputHtml, 'pagination' => $sPagination));
     // generate toggle ellements ;
     $aToggleItems = array('' => _t('_Simple'), 'extended' => _t('_Extended'));
     foreach ($aToggleItems as $sKey => $sValue) {
         $aToggleEllements[$sValue] = array('href' => $sModeLocation . '&mode=' . $sKey, 'dynamic' => true, 'active' => $this->aDisplaySettings['mode'] == $sKey);
     }
     return array($sOutputHtml, $aToggleEllements, array(), true);
 }
Пример #4
0
 function showMatchProfiles($iBlockID)
 {
     $iProfileId = getLoggedId();
     if (!$iProfileId) {
         return array('', MsgBox(_t('_Empty')));
     }
     $sSort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : 'none';
     $aProfiles = getMatchProfiles($iProfileId, false, $sSort);
     if (empty($aProfiles)) {
         return array('', MsgBox(_t('_Empty')));
     }
     $sBaseUri = 'search.php?show=match';
     $sTopLinksUri = '';
     $sPaginateUri = '';
     foreach ($_REQUEST as $sKey => $sVal) {
         switch ($sKey) {
             case 'page':
                 $sPaginateUri .= '&page=' . $sVal;
                 break;
             case 'per_page':
                 $sPaginateUri .= '&per_page=' . $sVal;
                 break;
             case 'sort':
                 $sPaginateUri .= '&sort=' . $sVal;
                 break;
             case 'mode':
                 $sTopLinksUri .= '&mode=' . $sVal;
                 break;
         }
     }
     $aPaginate = array('page_url' => $sBaseUri . $sTopLinksUri . '&page={page}&per_page={per_page}&sort={sorting}', 'info' => true, 'page_links' => true, 'per_page' => isset($_REQUEST['per_page']) ? (int) $_REQUEST['per_page'] : 25, 'sorting' => $sSort, 'count' => count($aProfiles), 'page' => isset($_REQUEST['page']) ? (int) $_REQUEST['page'] : 1);
     $sMode = isset($_REQUEST['mode']) ? $_REQUEST['mode'] : 'simple';
     $oPaginate = new BxDolPaginate($aPaginate);
     $oSearchProfile = new BxBaseSearchProfile();
     $aExtendedCss = array('ext_css_class' => 'search_filled_block');
     $sTemplateName = $sMode == 'extended' ? 'search_profiles_ext.html' : 'search_profiles_sim.html';
     $iIndex = 0;
     $sOutputHtml = '';
     $sOutputMode = isset($_REQUEST['search_result_mode']) && $_REQUEST['search_result_mode'] == 'ext' ? 'ext' : 'sim';
     for ($i = ($aPaginate['page'] - 1) * $aPaginate['per_page']; $i < $aPaginate['page'] * $aPaginate['per_page'] && $i < $aPaginate['count']; $i++) {
         $aProfile = getProfileInfo($aProfiles[$i]);
         if ($aProfile['Couple']) {
             $aCoupleInfo = getProfileInfo($aProfile['Couple']);
             if (!($iIndex % 2)) {
                 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, $aCoupleInfo, null, $sTemplateName);
             } else {
                 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, $aCoupleInfo, $aExtendedCss, $sTemplateName);
             }
         } else {
             if (!($iIndex % 2)) {
                 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, '', null, $sTemplateName);
             } else {
                 $sOutputHtml .= $oSearchProfile->PrintSearhResult($aProfile, '', $aExtendedCss, $sTemplateName);
             }
         }
         $iIndex++;
     }
     // gen sorting block ( type of : drop down );
     $sSortBlock = $oPaginate->getSorting(array('none' => _t('_None'), 'activity' => _t('_Latest activity'), 'date_reg' => _t('_FieldCaption_DateReg_View')));
     $sSortBlock = '<div class="ordered_block">' . $sSortBlock . '</div><div class="clear_both"></div>';
     $sContent = $GLOBALS['oSysTemplate']->parseHtmlByName('designbox_top_controls.html', array('top_controls' => $sSortBlock));
     $sContent .= $GLOBALS['oSysTemplate']->parseHtmlByName('view_profiles.html', array('margin_type' => $sOutputMode == 'sim' ? '-thd' : '', 'content' => $sOutputHtml)) . $oPaginate->getPaginate();
     $aLinks = array(_t('_Simple') => array('href' => $sBaseUri . $sPaginateUri . '&mode=simple', 'dynamic' => true, 'active' => $sMode == 'simple'), _t('_Extended') => array('href' => $sBaseUri . $sPaginateUri . '&mode=extended', 'dynamic' => true, 'active' => $sMode == 'extended'));
     return array($aLinks, $sContent);
 }
Пример #5
0
    function genSearchPagination($iCountProfiles, $iCurrentPage, $iResultsPerPage, $aFilterSortSettings = array(), $sPgnRoot = '')
    {
        $aGetParams = $_GET;
        unset($aGetParams['page']);
        unset($aGetParams['res_per_page']);
        unset($aGetParams['sort']);
        $sRequestString = $this->collectRequestString($aGetParams);
        $sRequestString = BX_DOL_URL_ROOT . strip_tags($sPgnRoot) . '?' . substr($sRequestString, 1);
        $sPaginTmpl = $sRequestString . '&res_per_page={per_page}&page={page}&sort={sorting}';
        // gen pagination block ;
        $oPaginate = new BxDolPaginate(array('page_url' => $sPaginTmpl, 'count' => $iCountProfiles, 'per_page' => $iResultsPerPage, 'sorting' => $aFilterSortSettings['sort'], 'page' => $iCurrentPage, 'per_page_changer' => true, 'page_reloader' => true, 'on_change_page' => null, 'on_change_per_page' => null));
        $sPagination = $oPaginate->getPaginate();
        // fill array with sorting params ;
        $aSortingParam = array('none' => _t('_None'), 'activity' => _t('_Latest activity'), 'date_reg' => _t('_FieldCaption_DateReg_View'));
        // gen sorting block ( type of : drop down ) ;
        $sSortBlock = $oPaginate->getSorting($aSortingParam);
        $sSortElement = <<<EOF
<div class="top_settings_block">
\t<div class="ordered_block">
\t\t{$sSortBlock}
\t</div>
\t<div class="clear_both"></div>
</div>
EOF;
        return array($sPagination, $sSortElement);
    }