Пример #1
0
 function genSiteServiceMenu()
 {
     $bLogged = isLogged();
     $aMenuItem = array();
     $sMenuPopupId = '';
     $sMenuPopupContent = '';
     if ($bLogged) {
         bx_import('BxTemplMenuService');
         $oMenu = new BxTemplMenuService();
         if ($oMenu->aMenuInfo['memberID'] != 0) {
             $aProfile = getProfileInfo($oMenu->aMenuInfo['memberID']);
         }
         $sThumbSetting = getParam('sys_member_info_thumb_icon');
         bx_import('BxDolMemberInfo');
         $o = BxDolMemberInfo::getObjectInstance($sThumbSetting);
         $sThumbUrl = $o ? $o->get($aProfile) : '';
         $o = BxDolMemberInfo::getObjectInstance($sThumbSetting . '_2x');
         $sThumbTwiceUrl = $o ? $o->get($aProfile) : '';
         if (!$sThumbTwiceUrl) {
             $sThumbTwiceUrl = $sThumbUrl;
         }
         $bThumb = !empty($sThumbUrl);
         $aMenuItem = array('bx_if:show_fu_thumb_image' => array('condition' => $bThumb, 'content' => array('image' => $sThumbUrl, 'image_2x' => $sThumbTwiceUrl)), 'bx_if:show_fu_thumb_icon' => array('condition' => !$bThumb, 'content' => array()), 'thumbnail' => get_member_icon($oMenu->aMenuInfo['memberID']), 'title' => getNickName($oMenu->aMenuInfo['memberID']));
         $sMenuPopupId = 'sys-service-menu-' . time();
         $sMenuPopupContent = $this->transBox($oMenu->getCode());
     }
     return $GLOBALS['oSysTemplate']->parseHtmlByName('extra_service_menu_wrapper.html', array('bx_if:show_for_visitor' => array('condition' => !$bLogged, 'content' => array()), 'bx_if:show_for_user' => array('condition' => $bLogged, 'content' => $aMenuItem), 'menu_popup_id' => $sMenuPopupId, 'menu_popup_content' => $sMenuPopupContent));
 }
Пример #2
0
 function genSiteServiceMenu()
 {
     $bLogged = isLogged();
     $aMenuItem = array();
     $sMenuPopupId = '';
     $sMenuPopupContent = '';
     $bShowVisitor = false;
     bx_import('BxTemplMenuService');
     $oMenu = new BxTemplMenuService();
     if ($bLogged) {
         $aProfile = getProfileInfo($oMenu->aMenuInfo['memberID']);
         $sThumbSetting = getParam('sys_member_info_thumb_icon');
         bx_import('BxDolMemberInfo');
         $o = BxDolMemberInfo::getObjectInstance($sThumbSetting);
         $sThumbUrl = $o ? $o->get($aProfile) : '';
         $bThumb = !empty($sThumbUrl);
         $o = BxDolMemberInfo::getObjectInstance($sThumbSetting . '_2x');
         $sThumbTwiceUrl = $o ? $o->get($aProfile) : '';
         if (!$sThumbTwiceUrl) {
             $sThumbTwiceUrl = $sThumbUrl;
         }
         $aMenuItem = array('bx_if:show_fu_thumb_image' => array('condition' => $bThumb, 'content' => array('image' => $sThumbUrl, 'image_2x' => $sThumbTwiceUrl)), 'bx_if:show_fu_thumb_icon' => array('condition' => !$bThumb, 'content' => array()), 'title' => getNickName($oMenu->aMenuInfo['memberID']));
         $sMenuPopupId = 'sys-service-menu-' . time();
         $sMenuPopupContent = $this->transBox($oMenu->getCode());
     } else {
         $aItems = $oMenu->getItemsArray();
         if (!empty($aItems)) {
             $bShowVisitor = true;
             $bLoginOnly = $aItems[0]['name'] == 'LoginOnly';
             $aMenuItem = array('caption' => $bLoginOnly ? $aItems[0]['caption'] : _t('_sys_sm_join_or_login'), 'icon' => $bLoginOnly ? $aItems[0]['icon'] : 'user', 'script' => $aItems[0]['script'], 'bx_if:show_fu_thumb_image' => array('condition' => false, 'content' => array()), 'bx_if:show_fu_thumb_icon' => array('condition' => false, 'content' => array()), 'title' => '');
         }
     }
     return $GLOBALS['oSysTemplate']->parseHtmlByName('extra_service_menu_wrapper.html', array('bx_if:show_for_visitor' => array('condition' => !$bLogged && $bShowVisitor, 'content' => $aMenuItem), 'bx_if:show_for_user' => array('condition' => $bLogged, 'content' => $aMenuItem), 'menu_popup_id' => $sMenuPopupId, 'menu_popup_content' => $sMenuPopupContent));
 }
Пример #3
0
 /**
  * Get member avatar from profile photos
  */
 public function get($aData)
 {
     switch ($this->_sObject) {
         case 'bx_photos_thumb':
             $sThumb = BxDolService::call('photos', 'profile_photo', array($aData['ID'], 'thumb'), 'Search');
             return $sThumb ? $sThumb : $GLOBALS['oFunctions']->getSexPic($aData['Sex'], 'medium');
         case 'bx_photos_icon':
             $sIcon = BxDolService::call('photos', 'profile_photo', array($aData['ID'], 'icon'), 'Search');
             return $sIcon ? $sIcon : $GLOBALS['oFunctions']->getSexPic($aData['Sex'], 'small');
     }
     return parent::get($aData);
 }
Пример #4
0
 /**
  * Get member avatar from profile photos
  */
 public function get($aData)
 {
     switch ($this->_sObject) {
         case 'bx_photos_thumb_2x':
             return BxDolService::call('photos', 'profile_photo', array($aData['ID'], 'browse'), 'Search');
         case 'bx_photos_thumb':
         case 'bx_photos_icon_2x':
             return BxDolService::call('photos', 'profile_photo', array($aData['ID'], 'thumb'), 'Search');
         case 'bx_photos_icon':
             return BxDolService::call('photos', 'profile_photo', array($aData['ID'], 'icon'), 'Search');
     }
     return parent::get($aData);
 }
Пример #5
0
 function getHomepageInfo2($sUser, $sPwd, $sLang)
 {
     if (!($iId = BxDolXMLRPCUtil::checkLogin($sUser, $sPwd))) {
         return new xmlrpcresp(new xmlrpcval(array('error' => new xmlrpcval(1, "int")), "struct"));
     }
     BxDolXMLRPCUtil::setLanguage($sLang);
     $aRet = BxDolXMLRPCUtil::getUserInfo($iId);
     $aMarkersReplace = array('member_id' => $iId, 'member_username' => rawurlencode($sUser), 'member_password' => $sPwd);
     $aRet['menu'] = new xmlrpcval(BxDolXMLRPCUtil::getMenu('homepage', $aMarkersReplace), 'array');
     bx_import('BxDolMemberInfo');
     $oMemberInfo = BxDolMemberInfo::getObjectInstance(getParam('sys_member_info_thumb'));
     $aRet['search_with_photos'] = new xmlrpcval($oMemberInfo->isAvatarSearchAllowed() ? 1 : 0);
     return new xmlrpcval($aRet, "struct");
 }
Пример #6
0
 function _getMediaAlbumsArray($sType, $iIdProfile, $iIdProfileViewer, $isShowEmptyAlbums = false)
 {
     switch ($sType) {
         case 'photo':
             $sModuleName = 'photos';
             $sType = 'bx_photos';
             $sMemAction = 'BX_PHOTOS_VIEW';
             break;
         case 'video':
             $sModuleName = 'videos';
             $sType = 'bx_videos';
             $sMemAction = 'BX_VIDEOS_VIEW';
             break;
         case 'music':
             $sModuleName = 'sounds';
             $sType = 'bx_sounds';
             $sMemAction = 'BX_SOUNDS_VIEW';
             break;
         default:
             return array();
     }
     if (!BxDolXMLRPCMedia::_isMembershipEnabledFor($iIdProfileViewer, $sMemAction)) {
         return array();
     }
     bx_import('BxDolMemberInfo');
     $oMemberInfo = BxDolMemberInfo::getObjectInstance(getParam('sys_member_info_thumb'));
     $isSetAvatarFromDefaultAlbumOnly = $oMemberInfo->isSetAvatarFromDefaultAlbumOnly();
     bx_import('BxDolAlbums');
     $o = new BxDolAlbums($sType, (int) $iIdProfile);
     $aList = $o->getAlbumList(array('owner' => (int) $iIdProfile, 'show_empty' => $isShowEmptyAlbums), 1, 1000);
     $aRet = array();
     foreach ($aList as $r) {
         if (!BxDolService::call($sModuleName, 'get_album_privacy', array((int) $r['ID'], $iIdProfileViewer), 'Search')) {
             continue;
         }
         if ($isSetAvatarFromDefaultAlbumOnly) {
             bx_import('BxDolAlbums');
             $isDefaulAlbum = $r['Uri'] == BxDolAlbums::getAbumUri(getParam($sType . '_profile_album_name'), $iIdProfile) ? 1 : 0;
         } else {
             $isDefaulAlbum = 1;
         }
         $aRet[] = array('Id' => $r['ID'], 'Title' => $r['Caption'], 'Num' => $r['ObjCount'], 'DefaultAlbum' => $isDefaulAlbum);
     }
     return $aRet;
 }
Пример #7
0
    function getFormsSearch($aParams)
    {
        // original member profile, used for setting default search params
        $aDefaultParams = $aParams['default_params'];
        $sSearchModeName = $this->iAreaID == 10 ? 'quick' : ($this->iAreaID == 11 ? 'adv' : 'simple');
        $sResult = '';
        $iFormCounter = 1;
        // generate blocks
        foreach ($this->aBlocks as $iBlockId => $aBlock) {
            $bAddFlags = true;
            // flags "online only" and "photos only"
            //collect inputs
            $aInputs = array();
            // create search mode hidden input
            $aInputs[] = array('type' => 'hidden', 'name' => 'search_mode', 'value' => $sSearchModeName);
            // generate block input
            $aInputs[] = array('type' => 'block_header', 'caption' => _t($aBlock['Caption']));
            // generate inputs for items of this block
            foreach ($aBlock['Items'] as $iItemId => $aItem) {
                if ($iItemId == 1 or $iItemId == 2) {
                    $bAddFlags = false;
                }
                // do not add flags when username or id available
                // generate input
                $aFormInput = array('name' => $aItem['Name'], 'caption' => _t($aItem['Caption']) != $aItem['Caption'] ? _t($aItem['Caption']) : null, 'info' => _t($aItem['Desc']) != $aItem['Desc'] ? _t($aItem['Desc']) : null, 'value' => empty($aDefaultParams[$aItem['Name']]) ? '' : $aDefaultParams[$aItem['Name']]);
                switch ($aItem['Type']) {
                    case 'text':
                    case 'area':
                        // search in area like simple keyword
                    // search in area like simple keyword
                    case 'html_area':
                        // search in area like simple keyword
                        $aFormInput['type'] = 'text';
                        break;
                    case 'bool':
                        $aFormInput['value'] = 'yes';
                        $aFormInput['type'] = 'checkbox';
                        break;
                    case 'select_one':
                    case 'select_set':
                        switch ($aItem['Control']) {
                            case 'select':
                                $aFormInput['type'] = 'select_box';
                                $aFormInput['attrs']['add_other'] = 'false';
                                break;
                            case 'checkbox':
                                $aFormInput['type'] = $aItem['Name'] == 'LookingFor' ? 'select' : 'checkbox_set';
                                break;
                            default:
                                $aFormInput['type'] = $aItem['Name'] == 'Sex' ? 'checkbox_set' : 'select';
                        }
                        $aFormInput['values'] = $this->convertValues4Input($aItem['Values'], $aItem['UseLKey']);
                        if (is_array($aFormInput['value'])) {
                            $aFormInput['value'] = $aFormInput['value'][0];
                        }
                        break;
                    case 'date':
                    case 'num':
                    case 'range':
                        $aFormInput['type'] = 'doublerange';
                        /* Changed because of realisation of WebForms 2.0 */
                        $aFormInput['attrs'] = array('min' => $aItem['Min'], 'max' => $aItem['Max']);
                        break;
                    case 'system':
                        switch ($aItem['Name']) {
                            case 'ID':
                                $aFormInput['type'] = 'number';
                                $aFormInput['attrs']['min'] = 1;
                                break;
                            case 'Keyword':
                                $aFormInput['type'] = 'text';
                                break;
                            case 'Location':
                                $sLivingWithinC = _t("_living within");
                                $sMilesC = _t("_miles");
                                $sKmC = _t("_kilometers");
                                $sFromZipC = _t("_from zip/postal code");
                                $aFormInput['type'] = 'custom';
                                $aFormInput['content'] = <<<EOF
                                    <div class="location_wrapper">
                                        <div>
                                            <input type="text" name="distance" class="form_input_distance bx-def-round-corners-with-border bx-def-font" />
                                            <select name="metric" class="form_input_select form_input_metric">
                                                <option selected="selected" value="miles">{$sMilesC}</option>
                                                <option value="km">{$sKmC}</option>
                                            </select>
                                        </div>
                                        <div>
                                            {$sFromZipC}
                                            <input type="text" name="zip" class="form_input_zip bx-def-round-corners-with-border bx-def-font" />
                                        </div>
                                    </div>
EOF;
                                break;
                            case 'Couple':
                                if ('on' == getParam('enable_global_couple')) {
                                    $aFormInput['type'] = 'select';
                                    $aFormInput['values'] = array('no' => _t('_Single'), 'yes' => _t('_Couple'));
                                } else {
                                    $aFormInput['type'] = 'hidden';
                                    $aFormInput['value'] = 'no';
                                }
                                break;
                        }
                        break;
                }
                $aInputs[] = $aFormInput;
            }
            if ($bAddFlags) {
                // create input for "online only"
                $aInputs[] = array('type' => 'checkbox', 'name' => 'online_only', 'label' => _t('_online only'), 'checked' => !empty($aDefaultParams['online_only']) && $aDefaultParams['online_only'] == 'on');
                // create input for "with photos only"
                bx_import('BxDolMemberInfo');
                $oMemberInfo = BxDolMemberInfo::getObjectInstance(getParam('sys_member_info_thumb'));
                if ($oMemberInfo->isAvatarSearchAllowed()) {
                    $aInputs[] = array('type' => 'checkbox', 'name' => 'photos_only', 'label' => _t('_With photos only'), 'checked' => !empty($aDefaultParams['photos_only']) && $aDefaultParams['photos_only'] == 'on');
                }
            }
            // create submit button
            $aInputs[] = array('type' => 'submit', 'name' => 'submit', 'value' => _t('_Search'), 'colspan' => true);
            // create form array
            $aForm = array('form_attrs' => array('method' => 'get', 'action' => $GLOBALS['site']['url'] . 'search.php', 'name' => $sSearchModeName . '_search_form' . $iFormCounter), 'inputs' => $aInputs);
            if (isset($aParams['form_attrs']) && is_array($aParams['form_attrs'])) {
                $aForm['form_attrs'] = array_merge($aForm['form_attrs'], $aParams['form_attrs']);
            }
            if (isset($aParams['inputs']) && is_array($aParams['inputs'])) {
                $aForm['inputs'] = array_merge($aForm['inputs'], $aParams['inputs']);
            }
            $oForm = new BxTemplFormView($aForm);
            $sResult .= $oForm->getCode();
            $iFormCounter++;
        }
        // block generation finished
        return $sResult;
    }
Пример #8
0
 function getUserInfo($iId)
 {
     $aProfile = getProfileInfo($iId);
     if (!$aProfile) {
         return false;
     }
     bx_import('BxDolMemberInfo');
     $o = BxDolMemberInfo::getObjectInstance(getParam('sys_member_info_info'));
     return $o ? $o->get($aProfile) : '';
 }
Пример #9
0
 /**
  ** @description : function will generate profiles's cover
  ** @param  : $sCaption (string) caption of returned block
  ** @param  : $bNoDB (boolean) if isset this param block will return with design box
  ** @return : HTML presentation data
  */
 function showBlockCover($sCaption, $bNoDB = false)
 {
     global $p_arr;
     $bProfileOwner = isLogged() && $p_arr['ID'] == getLoggedId();
     $sProfileNickname = getNickName($p_arr['ID']);
     $sProfileThumbnail = '';
     $sProfileThumbnail2x = '';
     $sProfileThumbnailHref = '';
     $bProfileThumbnail = false;
     $bProfileThumbnailHref = false;
     $aProfileThumbnail = BxDolService::call('photos', 'profile_photo', array($p_arr['ID'], 'browse', 'full'), 'Search');
     if (!empty($aProfileThumbnail) && is_array($aProfileThumbnail)) {
         $sProfileThumbnail = $aProfileThumbnail['file_url'];
         $sProfileThumbnailHref = $aProfileThumbnail['view_url'];
         $bProfileThumbnail = true;
         $bProfileThumbnailHref = true;
         $aProfileThumbnail2x = BxDolService::call('photos', 'profile_photo', array($p_arr['ID'], 'browse2x', 'full'), 'Search');
         if (!empty($aProfileThumbnail2x) && is_array($aProfileThumbnail2x)) {
             $sProfileThumbnail2x = $aProfileThumbnail['file_url'];
         }
     }
     if ($bProfileOwner) {
         $sProfileThumbnailHref = BxDolService::call('photos', 'get_manage_profile_photo_url', array($p_arr['ID'], 'profile_album_name'));
         $bProfileThumbnailHref = true;
     }
     $sProfileCover = BxDolService::call('photos', 'profile_cover', array($p_arr['ID'], 'file'), 'Search');
     $bProfileCover = !empty($sProfileCover);
     bx_import('BxDolMemberInfo');
     $o = BxDolMemberInfo::getObjectInstance('sys_status_message');
     $sProfileStatus = $o ? $o->get($p_arr) : '';
     $sBackground = '';
     $sBackgroundClass = '';
     if ($bProfileCover) {
         $sBackground = $sProfileCover;
         $sBackgroundClass = ' sys-pcb-cover';
     } else {
         if ($bProfileThumbnail) {
             $sBackground = $sProfileThumbnail;
             $sBackgroundClass = ' sys-pcb-thumbnail';
         }
     }
     $aTmplVarsMenu = array();
     $aMenuItems = $GLOBALS['oTopMenu']->getSubItems();
     foreach ($aMenuItems as $aMenuItem) {
         $aTmplVarsMenu[] = array('href' => $aMenuItem['Link'], 'bx_if:show_onclick' => array('condition' => !empty($aMenuItem['Onclick']), 'content' => array('onclick' => $aMenuItem['Onclick'])), 'bx_if:show_target' => array('condition' => !empty($aMenuItem['Target']), 'content' => array('target' => $aMenuItem['Target'])), 'caption' => _t($aMenuItem['Caption']));
     }
     $sContent = $GLOBALS['oSysTemplate']->parseHtmlByName('profile_cover.html', array('background_class' => $sBackgroundClass, 'bx_if:show_background' => array('condition' => !empty($sBackground), 'content' => array('background' => $sBackground)), 'bx_if:show_actions' => array('condition' => $bProfileOwner, 'content' => array('href_upload' => BxDolService::call('photos', 'get_album_uploader_url', array($p_arr['ID'], 'profile_cover_album_name')))), 'bx_if:show_thumbnail_image' => array('condition' => $bProfileThumbnail, 'content' => array('thumbnail_href' => $sProfileThumbnailHref, 'thumbnail' => $sProfileThumbnail, 'thumbnail2x' => $sProfileThumbnail2x)), 'bx_if:show_thumbnail_letter_text' => array('condition' => !$bProfileThumbnail && !$bProfileThumbnailHref, 'content' => array('letter' => mb_substr($sProfileNickname, 0, 1))), 'bx_if:show_thumbnail_letter_link' => array('condition' => !$bProfileThumbnail && $bProfileThumbnailHref, 'content' => array('thumbnail_href' => $sProfileThumbnailHref, 'letter' => mb_substr($sProfileNickname, 0, 1))), 'nickname' => $sProfileNickname, 'status' => $sProfileStatus, 'bx_repeat:menu_items' => $aTmplVarsMenu));
     return array($sContent, array(), array(), true);
 }
Пример #10
0
 /**
  * Function will get list with users nicknames ;
  *
  * @param        : $sQuery (string)  - any part of needed nickname ;
  * @param        : $iLimit (integer) - limit of returned rows (optional parameter);
  * @return        : Html presentation data ;
  */
 function getAutoCompleteList($sQuery, $iLimit = 10)
 {
     $aFields = array('NickName');
     bx_import('BxDolMemberInfo');
     $o = BxDolMemberInfo::getObjectInstance(getParam('sys_member_info_name'));
     if ($o) {
         $aFields = $o->getMemberNameFields();
     }
     // init some needed variables ;
     $iLimit = (int) $iLimit;
     $sQuery = process_db_input($sQuery, BX_TAGS_STRIP);
     $sWhere = '';
     foreach ($aFields as $sField) {
         $sWhere .= "`{$sField}` LIKE '%{$sQuery}%' OR ";
     }
     $sWhere .= '0';
     $sQuery = "SELECT `ID`, `NickName` FROM `Profiles` WHERE {$sWhere} LIMIT {$iLimit}";
     $rResult = db_res($sQuery);
     $aOutput = array();
     while (true == ($aRow = mysql_fetch_assoc($rResult))) {
         $aOutput[] = array('id' => $aRow['ID'], 'value' => getNickName($aRow['ID']));
     }
     return json_encode($aOutput);
 }
Пример #11
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);
 }
Пример #12
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);
 }