function getProfilesByDate($sDate) { $sDate = strip_tags($sDate); $aDateParams = explode('/', $sDate); $oSearch = new BxTemplSearchProfile('calendar', (int) $aDateParams[0], (int) $aDateParams[1], (int) $aDateParams[2]); $oSearch->aConstants['linksTempl']['browseAll'] = 'calendar.php?'; $sCode = $oSearch->displayResultBlock(); return $oSearch->displaySearchBox('<div class="search_container">' . $sCode . '</div>', $oSearch->showPagination(false, false, false)); }
function GenSearchResultBlock($aSearchBlocks, $aRequestParams, $aFilterSortSettings = array(), $sPgnRoot = 'profile.php') { if (empty($aSearchBlocks)) { // the request is empty. do not search. return array('', array(), '', ''); } // status uptimization $iOnlineTime = (int) getParam("member_online_time"); $sIsOnlineSQL = ", if(`DateLastNav` > SUBDATE(NOW(), INTERVAL {$iOnlineTime} MINUTE ), 1, 0) AS `is_online`"; $sQuery = 'SELECT DISTINCT SQL_CALC_FOUND_ROWS IF( `Profiles`.`Couple`=0, `Profiles`.`ID`, IF( `Profiles`.`Couple`>`Profiles`.`ID`, `Profiles`.`ID`, `Profiles`.`Couple` ) ) AS `ID` ' . $sIsOnlineSQL . ' FROM `Profiles` '; $sQueryCnt = 'SELECT COUNT(DISTINCT IF( `Profiles`.`Couple`=0, `Profiles`.`ID`, IF( `Profiles`.`Couple`>`Profiles`.`ID`, `Profiles`.`ID`, `Profiles`.`Couple` ) )) AS "Cnt" FROM `Profiles` '; list($aWhere, $sJoin, $sPossibleOrder) = $this->GenSqlConditions($aSearchBlocks, $aRequestParams, $aFilterSortSettings); $sWhere = ' WHERE ' . implode(' AND ', $aWhere); //collect the whole query string $sQuery = $sQuery . $sJoin . $sWhere . $sPossibleOrder; $sQueryCnt = $sQueryCnt . $sJoin . $sWhere . $sPossibleOrder; //echo $sQuery; $iCountProfiles = (int) db_value($sQueryCnt); $sResults = $sTopFilter = ''; if ($iCountProfiles) { //collect pagination $iCurrentPage = isset($_GET['page']) ? (int) $_GET['page'] : 1; $iResultsPerPage = isset($_GET['res_per_page']) ? (int) $_GET['res_per_page'] : 10; if ($iCurrentPage < 1) { $iCurrentPage = 1; } if ($iResultsPerPage < 1) { $iResultsPerPage = 10; } $iTotalPages = ceil($iCountProfiles / $iResultsPerPage); if ($iTotalPages > 1) { if ($iCurrentPage > $iTotalPages) { $iCurrentPage = $iTotalPages; } $sLimitFrom = ($iCurrentPage - 1) * $iResultsPerPage; $sQuery .= " LIMIT {$sLimitFrom}, {$iResultsPerPage}"; list($sPagination, $sTopFilter) = $this->genSearchPagination($iCountProfiles, $iCurrentPage, $iResultsPerPage, $aFilterSortSettings, $sPgnRoot); } else { $sPagination = ''; } //make search $aProfiles = array(); $aProfileStatuses = array(); $rProfiles = db_res($sQuery); while ($aProfile = mysql_fetch_assoc($rProfiles)) { $aProfiles[] = $aProfile['ID']; $aProfileStatuses[$aProfile['ID']] = $aProfile['is_online']; } $sOutputMode = isset($_REQUEST['search_result_mode']) && $_REQUEST['search_result_mode'] == 'ext' ? 'ext' : 'sim'; $aDBTopMenu = array(); foreach (array('sim', 'ext') as $myMode) { switch ($myMode) { case 'sim': $modeTitle = _t('_Simple'); break; case 'ext': $modeTitle = _t('_Extended'); break; } $aGetParams = $_GET; unset($aGetParams['search_result_mode']); $sRequestString = $this->collectRequestString($aGetParams); $aDBTopMenu[$modeTitle] = array('href' => bx_html_attribute($_SERVER['PHP_SELF']) . "?search_result_mode={$myMode}{$sRequestString}", 'dynamic' => true, 'active' => $myMode == $sOutputMode); } if ($sOutputMode == 'sim') { $sBlockWidthSQL = "SELECT `PageWidth`, `ColWidth` FROM `sys_page_compose` WHERE `Page`='profile' AND `Func`='ProfileSearch'"; $aBlockWidthInfo = db_arr($sBlockWidthSQL); $iBlockWidth = (int) (int) $aBlockWidthInfo['PageWidth'] - 20; $iMaxThumbWidth = getParam('max_thumb_width') + 6; $iDestWidth = $iCountProfiles * ($iMaxThumbWidth + 6); if ($iDestWidth > $iBlockWidth) { $iMaxAllowed = (int) floor($iBlockWidth / ($iMaxThumbWidth + 6)); $iDestWidth = $iMaxAllowed * ($iMaxThumbWidth + 6); } } $sWidthCent = $iDestWidth > 0 ? "width:{$iDestWidth}px;" : ''; $sResults .= '<div class="block_rel_100 bx-def-bc-margin' . ($sOutputMode == 'sim' ? '-thd' : '') . '">'; //output search results require_once BX_DIRECTORY_PATH_ROOT . 'templates/tmpl_' . $GLOBALS['tmpl'] . '/scripts/BxTemplSearchProfile.php'; $oBxTemplSearchProfile = new BxTemplSearchProfile(); $iCounter = 0; foreach ($aProfiles as $iProfID) { $aProfileInfo = getProfileInfo($iProfID); //attaching status value $aProfileStatus = array('is_online' => $aProfileStatuses[$iProfID]); $aProfileInfo = array_merge($aProfileStatus, $aProfileInfo); $sResults .= $oBxTemplSearchProfile->displaySearchUnit($aProfileInfo); $iCounter++; } $sResults .= <<<EOF <div id="ajaxy_popup_result_div" style="display: none;"></div> <div class="clear_both"></div> </div> EOF; return array($sResults, $aDBTopMenu, $sPagination, $sTopFilter); } else { return array(MsgBox(_t('_Empty')), array(), '', ''); } }
function _actionBrowseFans($sUri, $sFuncAllowed, $sFuncDbGetFans, $iPerPage, $sUrlBrowse, $sTitle) { if (!($aDataEntry = $this->_preProductTabs($sUri, $sTitle))) { return; } if (!$this->{$sFuncAllowed}($aDataEntry)) { $this->_oTemplate->displayAccessDenied(); return; } $iPage = (int) $_GET['page']; if ($iPage < 1) { $iPage = 1; } $iStart = ($iPage - 1) * $iPerPage; $aProfiles = array(); $iNum = $this->_oDb->{$sFuncDbGetFans}($aProfiles, $aDataEntry[$this->_oDb->_sFieldId], $iStart, $iPerPage); if (!$iNum || !$aProfiles) { $this->_oTemplate->displayNoData(); return; } $iPages = ceil($iNum / $iPerPage); bx_import('BxTemplSearchProfile'); $oBxTemplSearchProfile = new BxTemplSearchProfile(); $sMainContent = ''; foreach ($aProfiles as $aProfile) { $sMainContent .= $oBxTemplSearchProfile->displaySearchUnit($aProfile); } $sRet = $GLOBALS['oFunctions']->centerContent($sMainContent, '.searchrow_block_simple'); $sRet .= '<div class="clear_both"></div>'; bx_import('BxDolPaginate'); $sUrlStart = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . $sUrlBrowse . $aDataEntry[$this->_oDb->_sFieldUri]; $sUrlStart .= false === strpos($sUrlStart, '?') ? '?' : '&'; $oPaginate = new BxDolPaginate(array('page_url' => $sUrlStart . 'page={page}&per_page={per_page}' . (false !== bx_get($this->sFilterName) ? '&' . $this->sFilterName . '=' . bx_get($this->sFilterName) : ''), 'count' => $iNum, 'per_page' => $iPerPage, 'page' => $iPage, 'per_page_changer' => false, 'page_reloader' => true, 'on_change_page' => '', 'on_change_per_page' => "document.location='" . $sUrlStart . "page=1&per_page=' + this.value + '" . (false !== bx_get($this->sFilterName) ? '&' . $this->sFilterName . '=' . bx_get($this->sFilterName) . "';" : "';"))); $sRet .= $oPaginate->getPaginate(); $this->_oTemplate->pageStart(); echo DesignBoxContent($sTitle, $sRet, 11); $this->_oTemplate->pageCode($sTitle, false, false); }
function _blockFans($iPerPage, $sFuncIsAllowed = 'isAllowedViewFans', $sFuncGetFans = 'getFans') { if (!$this->_oMain->{$sFuncIsAllowed}($this->aDataEntry)) { return ''; } $iPage = (int) $_GET['page']; if ($iPage < 1) { $iPage = 1; } $iStart = ($iPage - 1) * $iPerPage; $aProfiles = array(); $iNum = $this->_oDb->{$sFuncGetFans}($aProfiles, $this->aDataEntry[$this->_oDb->_sFieldId], true, $iStart, $iPerPage); if (!$iNum || !$aProfiles) { return MsgBox(_t("_Empty")); } $iPages = ceil($iNum / $iPerPage); bx_import('BxTemplSearchProfile'); $oBxTemplSearchProfile = new BxTemplSearchProfile(); $sMainContent = ''; foreach ($aProfiles as $aProfile) { $sMainContent .= $oBxTemplSearchProfile->displaySearchUnit($aProfile, array('ext_css_class' => 'bx-def-margin-sec-top-auto')); } $ret .= $sMainContent; $aDBBottomMenu = array(); if ($iPages > 1) { $sUrlStart = BX_DOL_URL_ROOT . $this->_oMain->_oConfig->getBaseUri() . "view/" . $this->aDataEntry[$this->_oDb->_sFieldUri]; $sUrlStart .= false === strpos($sUrlStart, '?') ? '?' : '&'; if ($iPage > 1) { $aDBBottomMenu[_t('_Back')] = array('href' => $sUrlStart . "page=" . ($iPage - 1), 'dynamic' => true, 'class' => 'backMembers', 'icon' => getTemplateIcon('sys_back.png'), 'icon_class' => 'left', 'static' => false); } if ($iPage < $iPages) { $aDBBottomMenu[_t('_Next')] = array('href' => $sUrlStart . "page=" . ($iPage + 1), 'dynamic' => true, 'class' => 'moreMembers', 'icon' => getTemplateIcon('sys_next.png'), 'static' => false); } } $ret .= '<div class="clear_both"></div>'; return array($ret, array(), $aDBBottomMenu); }
function _blockFans($iPerPage, $sFuncIsAllowed = 'isAllowedViewFans', $sFuncGetFans = 'getFans') { if (!$this->_oMain->{$sFuncIsAllowed}($this->aDataEntry)) { return ''; } $iPage = (int) $_GET['page']; if ($iPage < 1) { $iPage = 1; } $iStart = ($iPage - 1) * $iPerPage; $aProfiles = array(); $iNum = $this->_oDb->{$sFuncGetFans}($aProfiles, $this->aDataEntry[$this->_oDb->_sFieldId], true, $iStart, $iPerPage); if (!$iNum || !$aProfiles) { return MsgBox(_t("_Empty")); } bx_import('BxTemplSearchProfile'); $oBxTemplSearchProfile = new BxTemplSearchProfile(); $sMainContent = ''; foreach ($aProfiles as $aProfile) { $sMainContent .= $oBxTemplSearchProfile->displaySearchUnit($aProfile, array('ext_css_class' => 'bx-def-margin-sec-top-auto')); } $ret .= $sMainContent; $ret .= '<div class="clear_both"></div>'; $oPaginate = new BxDolPaginate(array('page_url' => 'javascript:void(0);', 'count' => $iNum, 'per_page' => $iPerPage, 'page' => $iPage, 'on_change_page' => 'return !loadDynamicBlock({id}, \'' . bx_append_url_params(BX_DOL_URL_ROOT . $this->_oMain->_oConfig->getBaseUri() . "view/" . $this->aDataEntry[$this->_oDb->_sFieldUri], 'page={page}&per_page={per_page}') . '\');')); $sAjaxPaginate = $oPaginate->getSimplePaginate('', -1, -1, false); return array($ret, array(), $sAjaxPaginate); }
function actionGetHtmlProfiles($sFilter) { $aProfiles = $this->_getProfilesByFilter($sFilter); if (!$aProfiles) { echo MsgBox(_t('_Empty')); return; } if (!$aProfiles) { echo MsgBox(_t('_Empty')); return; } bx_import('BxTemplSearchProfile'); $oBxTemplSearchProfile = new BxTemplSearchProfile(); foreach ($aProfiles as $r) { $aProfileInfo = getProfileInfo($r['id']); $sProfiles .= $oBxTemplSearchProfile->displaySearchUnit($aProfileInfo); } echo $GLOBALS['oFunctions']->centerContent($sProfiles, '.searchrow_block_simple'); }