Exemple #1
0
 function getTagsView($aTotalTags, $sHrefTempl)
 {
     global $oTemplConfig;
     global $oSysTemplate;
     if (empty($aTotalTags)) {
         return MsgBox(_t('_Empty'));
     }
     $iMinFontSize = $oTemplConfig->iTagsMinFontSize;
     $iMaxFontSize = $oTemplConfig->iTagsMaxFontSize;
     $iFontDiff = $iMaxFontSize - $iMinFontSize;
     $iMinRating = min($aTotalTags);
     $iMaxRating = max($aTotalTags);
     $iRatingDiff = $iMaxRating - $iMinRating;
     $iRatingDiff = $iRatingDiff == 0 ? 1 : $iRatingDiff;
     $sCode = '<div class="tags_wrapper">';
     $aUnit = array();
     foreach ($aTotalTags as $sTag => $iCount) {
         $aUnit['tagSize'] = $iMinFontSize + round($iFontDiff * (($iCount - $iMinRating) / $iRatingDiff));
         $aUnit['tagHref'] = str_replace('{tag}', urlencode(title2uri($sTag)), $sHrefTempl);
         $aUnit['countCapt'] = _t('_Count');
         $aUnit['countNum'] = $iCount;
         $aUnit['tag'] = htmlspecialchars_adv($sTag);
         if ($this->_sTagTmplContent) {
             $sCode .= $oSysTemplate->parseHtmlByContent($this->_sTagTmplContent, $aUnit);
         } else {
             $sCode .= $oSysTemplate->parseHtmlByName($this->_sTagTmplName, $aUnit);
         }
     }
     $sCode .= '</div>';
     $sCode .= '<div class="clear_both"></div>';
     return $sCode;
 }
 function getCategoriesView($aTotalCategories, $sHrefTempl, $iColumns)
 {
     global $oSysTemplate;
     if (empty($aTotalCategories)) {
         return MsgBox(_t('_Empty'));
     }
     if (!$iColumns) {
         $iColumns = 1;
     }
     $iCount = count($aTotalCategories);
     $iRowCount = floor($iCount / $iColumns) + ($iCount % $iColumns ? 1 : 0);
     $iWidthPr = floor(100 / $iColumns);
     $i = 0;
     $sCode = '<div class="categories_wrapper bx-def-bc-margin bx-def-font-large">';
     foreach ($aTotalCategories as $sCategory => $iCatCount) {
         if (!($i % $iRowCount)) {
             if ($i) {
                 $sCode .= '</div>';
             }
             $sCode .= '<div class="categories_col" style="width: ' . $iWidthPr . '%">';
         }
         $aUnit['catHref'] = str_replace('{tag}', rawurlencode(title2uri($sCategory)), $sHrefTempl);
         $aUnit['category'] = htmlspecialchars_adv($sCategory);
         $aUnit['count'] = $iCatCount;
         if ($this->_sCategTmplContent) {
             $sCode .= $oSysTemplate->parseHtmlByContent($this->_sCategTmplContent, $aUnit);
         } else {
             $sCode .= $oSysTemplate->parseHtmlByName($this->_sCategTmplName, $aUnit);
         }
         $i++;
     }
     $sCode .= '</div></div>';
     return $sCode;
 }
Exemple #3
0
function getLinkSet($sLinkString, $sUrlPrefix, $sDivider = ';,', $bUriConvert = false)
{
    $aSet = preg_split('/[' . $sDivider . ']/', $sLinkString, 0, PREG_SPLIT_NO_EMPTY);
    $sFinalSet = '';
    foreach ($aSet as $sKey) {
        $sLink = $sUrlPrefix . urlencode($bUriConvert ? title2uri($sKey) : $sKey);
        $sFinalSet .= '<a href="' . $sUrlPrefix . urlencode(title2uri(trim($sKey))) . '">' . $sKey . '</a> ';
    }
    return trim($sFinalSet, ' ');
}
 function __construct($sMode = '', $sValue = '', $sValue2 = '', $sValue3 = '')
 {
     switch ($sMode) {
         case 'pending':
             if (false !== bx_get('bx_store_filter')) {
                 $this->aCurrent['restriction']['keyword'] = array('value' => process_db_input(bx_get('bx_store_filter'), BX_TAGS_STRIP), 'field' => '', 'operator' => 'against');
             }
             $this->aCurrent['restriction']['activeStatus']['value'] = 'pending';
             $this->sBrowseUrl = "administration";
             $this->aCurrent['title'] = _t('_bx_store_page_title_pending_approval');
             unset($this->aCurrent['rss']);
             break;
         case 'my_pending':
             $oMain = $this->getMain();
             $this->aCurrent['restriction']['owner']['value'] = $oMain->_iProfileId;
             $this->aCurrent['restriction']['activeStatus']['value'] = 'pending';
             $this->sBrowseUrl = "browse/user/" . getNickName($oMain->_iProfileId);
             $this->aCurrent['title'] = _t('_bx_store_page_title_pending_approval');
             unset($this->aCurrent['rss']);
             break;
         case 'search':
             if ($sValue) {
                 $this->aCurrent['restriction']['keyword'] = array('value' => $sValue, 'field' => '', 'operator' => 'against');
             }
             if ($sValue2) {
                 $this->aCurrent['join']['category'] = array('type' => 'inner', 'table' => 'sys_categories', 'mainField' => 'id', 'onField' => 'ID', 'joinFields' => '');
                 $this->aCurrent['restriction']['category_type']['value'] = $this->aCurrent['name'];
                 $this->aCurrent['restriction']['category']['value'] = $sValue2;
                 if (is_array($sValue2)) {
                     $this->aCurrent['restriction']['category']['operator'] = 'in';
                 }
             }
             $sValue = $GLOBALS['MySQL']->unescape($sValue);
             $sValue2 = $GLOBALS['MySQL']->unescape($sValue2);
             $this->sBrowseUrl = "search/{$sValue}/" . (is_array($sValue2) ? implode(',', $sValue2) : $sValue2);
             $this->aCurrent['title'] = _t('_bx_store_page_title_search_results') . ' ' . (is_array($sValue2) ? implode(', ', $sValue2) : $sValue2) . ' ' . $sValue;
             unset($this->aCurrent['rss']);
             break;
         case 'user':
             $iProfileId = $GLOBALS['oBxStoreModule']->_oDb->getProfileIdByNickName($sValue, false);
             $GLOBALS['oTopMenu']->setCurrentProfileID($iProfileId);
             // select profile subtab, instead of module tab
             if (!$iProfileId) {
                 $this->isError = true;
             } else {
                 $this->aCurrent['restriction']['owner']['value'] = $iProfileId;
             }
             $sValue = $GLOBALS['MySQL']->unescape($sValue);
             $this->sBrowseUrl = "browse/user/{$sValue}";
             $iProfileId = getID($sValue);
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_by_author', $iProfileId ? getNickName($iProfileId) : $sValue);
             if (bx_get('rss')) {
                 $aData = getProfileInfo($iProfileId);
                 if ($aData['Avatar']) {
                     $a = array('ID' => $aData['author_id'], 'Avatar' => $aData['thumb']);
                     $aImage = BxDolService::call('photos', 'get_image', array($a, 'browse'), 'Search');
                     if (!$aImage['no_image']) {
                         $this->aCurrent['rss']['image'] = $aImage['file'];
                     }
                 }
             }
             break;
         case 'admin':
             $this->aCurrent['restriction']['owner']['value'] = 0;
             $this->sBrowseUrl = "browse/admin";
             $this->aCurrent['title'] = _t('_bx_store_page_title_admin_products');
             break;
         case 'category':
             $this->aCurrent['join']['category'] = array('type' => 'inner', 'table' => 'sys_categories', 'mainField' => 'id', 'onField' => 'ID', 'joinFields' => '');
             $this->aCurrent['restriction']['category_type']['value'] = $this->aCurrent['name'];
             $this->aCurrent['restriction']['category']['value'] = $sValue;
             $sValue = $GLOBALS['MySQL']->unescape($sValue);
             $this->sBrowseUrl = "browse/category/" . title2uri($sValue);
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_by_category', $sValue);
             break;
         case 'tag':
             $this->aCurrent['restriction']['tag']['value'] = $sValue;
             $sValue = $GLOBALS['MySQL']->unescape($sValue);
             $this->sBrowseUrl = "browse/tag/" . title2uri($sValue);
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_by_tag', $sValue);
             break;
         case 'free':
             $this->aCurrent['restriction']['price'] = array('value' => 'Free', 'field' => 'price_range', 'operator' => '=');
             $this->sBrowseUrl = "browse/free";
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_free_products') . ' ' . $sValue;
             break;
         case 'recent':
             $this->sBrowseUrl = 'browse/recent';
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_recent');
             break;
         case 'top':
             $this->sBrowseUrl = 'browse/top';
             $this->aCurrent['sorting'] = 'top';
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_top_rated');
             break;
         case 'popular':
             $this->sBrowseUrl = 'browse/popular';
             $this->aCurrent['sorting'] = 'popular';
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_popular');
             break;
         case 'featured':
             $this->aCurrent['restriction']['featured'] = array('value' => 1, 'field' => 'featured', 'operator' => '=');
             $this->sBrowseUrl = 'browse/featured';
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_featured');
             break;
         case 'calendar':
             $this->aCurrent['restriction']['calendar-min'] = array('value' => "UNIX_TIMESTAMP('{$sValue}-{$sValue2}-{$sValue3} 00:00:00')", 'field' => 'created', 'operator' => '>=', 'no_quote_value' => true);
             $this->aCurrent['restriction']['calendar-max'] = array('value' => "UNIX_TIMESTAMP('{$sValue}-{$sValue2}-{$sValue3} 23:59:59')", 'field' => 'created', 'operator' => '<=', 'no_quote_value' => true);
             $this->sEventsBrowseUrl = "browse/calendar/{$sValue}/{$sValue2}/{$sValue3}";
             $this->aCurrent['title'] = _t('_bx_store_page_title_browse_by_day', getLocaleDate(strtotime("{$sValue}-{$sValue2}-{$sValue3}"), BX_DOL_LOCALE_DATE_SHORT));
             break;
         case '':
             $this->sBrowseUrl = 'browse/';
             $this->aCurrent['title'] = _t('_bx_store');
             unset($this->aCurrent['rss']);
             break;
         default:
             $this->isError = true;
     }
     $oMain = $this->getMain();
     $this->aCurrent['paginate']['perPage'] = $oMain->_oDb->getParam('bx_store_perpage_browse');
     if (isset($this->aCurrent['rss'])) {
         $this->aCurrent['rss']['link'] = BX_DOL_URL_ROOT . $oMain->_oConfig->getBaseUri() . $this->sBrowseUrl;
     }
     if (bx_get('rss')) {
         $this->aCurrent['ownFields'][] = 'desc';
         $this->aCurrent['ownFields'][] = 'created';
         $this->aCurrent['paginate']['perPage'] = $oMain->_oDb->getParam('bx_store_max_rss_num');
     }
     bx_store_import('Voting', $this->getModuleArray());
     $oVotingView = new BxStoreVoting('bx_store', 0);
     $this->oVotingView = $oVotingView->isEnabled() ? $oVotingView : null;
     $this->sFilterName = 'bx_store_filter';
     parent::__construct();
 }
    /**
     * Generate a Block of searching result by Tag (GET is tagKey)
     *
     * @return HTML presentation of data
     */
    function GenSearchResult()
    {
        if (!$this->isAllowedBlogPostSearch(true)) {
            return $this->_oTemplate->displayAccessDenied();
        }
        $iCheckedMemberID = $this->_iVisitorID;
        $bNoProfileMode = false !== bx_get('ownerID') || false !== bx_get('blogOwnerName') ? false : true;
        $sRetHtml = '';
        $sSearchedTag = uri2title(process_db_input(bx_get('tagKey'), BX_TAGS_STRIP));
        $iMemberID = $this->defineUserId();
        $sTagsC = _t('_Tags');
        $sNoBlogC = _t('_bx_blog_No_blogs_available');
        require_once $this->_oConfig->getClassPath() . 'BxBlogsSearchUnit.php';
        $oTmpBlogSearch = new BxBlogsSearchUnit($this);
        $oTmpBlogSearch->PerformObligatoryInit($this, 4);
        $oTmpBlogSearch->aCurrent['restriction']['tag2']['value'] = $sSearchedTag;
        $oTmpBlogSearch->aCurrent['paginate']['perPage'] = $this->_oConfig->getPerPage();
        if ($iMemberID > 0) {
            $oTmpBlogSearch->aCurrent['restriction']['owner']['value'] = $iMemberID;
        }
        if ($iMemberID != 0 && $iMemberID == $iCheckedMemberID || $this->isAdmin() == true) {
            $oTmpBlogSearch->aCurrent['restriction']['activeStatus'] = '';
        }
        $sBlogPostsVal = $oTmpBlogSearch->displayResultBlock();
        $sBlogPostsVal = '<div class="blogs-view bx-def-bc-padding">' . $sBlogPostsVal . '</div>';
        $oTmpBlogSearch->aCurrent['paginate']['page_url'] = $oTmpBlogSearch->getCurrentUrl('tag', 0, title2uri($sSearchedTag));
        $sBlogPostsVal .= $oTmpBlogSearch->showPagination3();
        $sBlogPosts = $oTmpBlogSearch->aCurrent['paginate']['totalNum'] == 0 ? MsgBox(_t('_Empty')) : $sBlogPostsVal;
        $sContentSect = DesignBoxContent($sTagsC . ' - ' . $sSearchedTag, $sBlogPostsVal, 1);
        if ($bNoProfileMode == false) {
            $sRightSect = '';
            if ($iMemberID > -1) {
                $aBlogsRes = $this->_oDb->getBlogInfo($iMemberID);
                if (!$aBlogsRes) {
                    $sNoBlogC = MsgBox($sNoBlogC);
                    $sRetHtml = <<<EOF
<div class="{$sWidthClass}">
    {$sNoBlogC}
</div>
<div class="clear_both"></div>
EOF;
                } else {
                    $sRightSect = $this->GenMemberDescrAndCat($aBlogsRes);
                    $sWidthClass = $iMemberID > 0 ? 'cls_info_left' : 'cls_res_thumb';
                    $sRetHtml = $this->Templater($sContentSect, $sRightSect, $sWidthClass);
                }
            } else {
                $sRetHtml = MsgBox(_t('_Profile Not found Ex'));
            }
        } else {
            $sRetHtml = <<<EOF
<div class="{$sWidthClass}">
    {$sContentSect}
</div>
<div class="clear_both"></div>
EOF;
        }
        return $sRetHtml;
    }
Exemple #6
0
    /**
     * Compose result of searching Advertisements by Tag
     *
     * @param $sTag	selected tag string
     * @return HTML result
     */
    function PrintAdvertisementsByTag($sTag)
    {
        $sSiteUrl = BX_DOL_URL_ROOT;
        $sSafeTag = addslashes(trim(strtolower($sTag)));
        $sTagResultC = _t('_bx_ads_search_results_by_tag');
        $sBrowseAllAds = _t('_bx_ads_Browse_All_Ads');
        $sHomeLink = $this->bUseFriendlyLinks ? BX_DOL_URL_ROOT . 'ads/' : "{$this->sCurrBrowsedFile}?Browse=1";
        $sBreadCrumbs = <<<EOF
<a href="{$sHomeLink}">{$sBrowseAllAds}</a> / {$sTagResultC} - {$sSafeTag}
EOF;
        require_once $this->_oConfig->getClassPath() . 'BxAdsSearchUnit.php';
        $oTmpAdsSearch = new BxAdsSearchUnit();
        if ($iRandLim > 0) {
            $oTmpAdsSearch->aCurrent['paginate']['perPage'] = (int) $iRandLim;
        } else {
            $oTmpAdsSearch->aCurrent['paginate']['perPage'] = 10;
        }
        $oTmpAdsSearch->aCurrent['sorting'] = 'last';
        $oTmpAdsSearch->aCurrent['restriction']['tag']['value'] = $sSafeTag;
        $sAdsByTags = $oTmpAdsSearch->displayResultBlock();
        if ($oTmpAdsSearch->aCurrent['paginate']['totalNum'] == 0) {
            $sAdsByTags = MsgBox(_t('_Empty'));
        } else {
            // Prepare link to pagination
            $sSafeTagS = title2uri($sSafeTag);
            if ($this->bUseFriendlyLinks == false) {
                $sRequest = $this->sHomeUrl . "classifieds_tags.php?tag={$sSafeTagS}&page={page}&per_page={per_page}";
            } else {
                $sRequest = BX_DOL_URL_ROOT . "ads/tag/{$sSafeTagS}/{per_page}/{page}";
            }
            // End of prepare link to pagination
            $oTmpAdsSearch->aCurrent['paginate']['page_url'] = $sRequest;
            $sAdsByTags .= $oTmpAdsSearch->showPagination();
        }
        return DesignBoxContent($sBreadCrumbs, $sAdsByTags, 1);
    }
    function displaySearchUnit($aResSQL)
    {
        $iVisitorID = getLoggedId();
        $oMain = $this->getBlogsMain();
        $iPostID = (int) $aResSQL['id'];
        $sBlogsImagesUrl = BX_BLOGS_IMAGES_URL;
        $bPossibleToView = $oMain->oPrivacy->check('view', $iPostID, $oMain->_iVisitorID);
        if (!$bPossibleToView) {
            if ($this->sMobileWrapper) {
                return $this->_wrapMobileUnit($oMain->_oTemplate->parseHtmlByTemplateName('browse_unit_private_mobile', array()), $iPostID, $oMain);
            } else {
                return $oMain->_oTemplate->parseHtmlByName('browse_unit_private.html', array('extra_css_class' => ''));
            }
        }
        $sCategories = $aResSQL['Categories'];
        $aCategories = $oMain->getTagLinks($aResSQL['Categories'], 'category', CATEGORIES_DIVIDER);
        $sStyle = '';
        $sFriendStyle = '';
        $sPostVote = '';
        $sPostMode = '';
        $sVotePostRating = $this->oRate->getJustVotingElement(0, 0, $aResSQL['Rate']);
        $aProfileInfo = getProfileInfo($aResSQL['ownerId']);
        $sAuthorTitle = process_line_output(getNickName($aProfileInfo['ID']));
        $sAuthorUsername = getUsername($aProfileInfo['ID']);
        $sAuthorLink = getProfileLink($aProfileInfo['ID']);
        $sCategoryName = $aResSQL['Categories'];
        $sPostLink = $this->getCurrentUrl('file', $iPostID, $aResSQL['uri']) . $sCategoryUrlAdd;
        $sAllCategoriesLinks = '';
        if (count($aCategories) > 0) {
            foreach ($aCategories as $iKey => $sCatValue) {
                $sCatLink = $this->getCurrentUrl('category', title2uri($sCatValue), title2uri($sCatValue), array('ownerId' => $aResSQL['ownerId'], 'ownerName' => $sAuthorUsername));
                $sCatName = process_line_output($sCatValue);
                $aAllCategoriesLinks[] = '<a href="' . $sCatLink . '">' . $sCatName . '</a>';
            }
            $aAllCategoriesLinkHrefs = implode(", ", $aAllCategoriesLinks);
            $sAllCategoriesLinks = <<<EOF
<span class="margined">
    <span>{$aAllCategoriesLinkHrefs}</span>
</span>
EOF;
        }
        $sAdminCheck = $sAdminStatus = '';
        if ($this->bShowCheckboxes) {
            $sAdminCheck = <<<EOF
<div class="browseCheckbox"><input id="ch{$iPostID}" type="checkbox" name="bposts[]" value="{$iPostID}" /></div>
EOF;
            $sPostStatus = process_line_output($aResSQL['PostStatus']);
            $sAdminStatus = <<<EOF
&nbsp;({$sPostStatus})
EOF;
        }
        $sPostCaption = process_line_output($aResSQL['title']);
        $sPostCaptionHref = <<<EOF
<a class="unit_title bx-def-font-h2" href="{$sPostLink}">{$sPostCaption}</a>{$sAdminStatus}
EOF;
        if ($this->iPostViewType == 3 || $this->sMobileWrapper) {
            $sFriendStyle = "2";
            $sPostMode = '_post';
            $sPostCaptionHref = '<div class="unit_title bx-def-font-h2">' . $sPostCaption . '</div>';
        }
        $sDateTime = defineTimeInterval($aResSQL['date']);
        //$oCmtsView = new BxTemplCmtsView ('blogposts', (int)$iPostID);
        $iCommentsCnt = (int) $aResSQL['CommentsCount'];
        $sTagsCommas = $aResSQL['tag'];
        //$aTags = split(',', $sTagsCommas);
        $aTags = preg_split("/[;,]/", $sTagsCommas);
        //search by tag skiping
        if ($this->sSearchedTag != '' && in_array($this->sSearchedTag, $aTags) == false) {
            return;
        }
        $sTagsHrefs = '';
        $aTagsHrefs = array();
        foreach ($aTags as $sTagKey) {
            if ($sTagKey != '') {
                $sTagLink = $this->getCurrentUrl('tag', $iPostID, htmlspecialchars(title2uri($sTagKey)));
                $sTagsHrefAny = <<<EOF
<a href="{$sTagLink}" title="{$sTagKey}">{$sTagKey}</a>
EOF;
                $aTagsHrefs[] = $sTagsHrefAny;
            }
        }
        $sTagsHrefs = implode(", ", $aTagsHrefs);
        $sTags = <<<EOF
<span class="margined">
    <span>{$sTagsHrefs}</span>
</span>
EOF;
        $sPostText = $aResSQL['bodyText'];
        $bOwner = $iVisitorID == $aResSQL['ownerId'] ? true : false;
        $sOwnerThumb = $sPostPicture = $sPreviewPicture = '';
        if ($aResSQL['PostPhoto'] && $this->iPostViewType == 3) {
            $oMain->_oTemplate->addJs('plugins/fancybox/|jquery.fancybox.js');
            $oMain->_oTemplate->addCss('plugins/fancybox/|jquery.fancybox.css');
            $sPostPicture = $oMain->_oTemplate->parseHtmlByName('picture_preview.html', array('img_url_big' => $sBlogsImagesUrl . 'orig_' . $aResSQL['PostPhoto'], 'img_url_small' => $sBlogsImagesUrl . 'big_' . $aResSQL['PostPhoto']));
        }
        if ($aResSQL['PostPhoto'] && ($this->iPostViewType == 1 || $this->iPostViewType == 4 || $this->iPostViewType == 5)) {
            $sStyle = 'padding-right:' . ($this->iThumbSize + 10) . 'px; min-height:' . $this->iThumbSize . 'px;';
            $sPreviewPicture = '<div class="unit_img"><img class="bx-def-shadow bx-def-round-corners" src="' . $sBlogsImagesUrl . 'big_' . $aResSQL['PostPhoto'] . '" /></div>';
        }
        if ($this->iPostViewType == 4) {
            $sOwnerThumb = $GLOBALS['oFunctions']->getMemberIcon($aResSQL['ownerId'], 'left');
        }
        if ($this->iPostViewType == 4 || $this->iPostViewType == 1 || $this->iPostViewType == 5) {
            $iBlogLimitChars = (int) getParam('max_blog_preview');
            $sPostText = trim(strip_tags($sPostText));
            if (mb_strlen($sPostText) > $iBlogLimitChars) {
                $sPostText = mb_substr($sPostText, 0, $iBlogLimitChars);
                $sLinkMore = $this->sMobileWrapper ? '' : ' <a title="' . htmlspecialchars_adv(_t('_Read more')) . '" href="' . $sPostLink . '">&hellip;</a>';
            }
            $sPostText = htmlspecialchars_adv($sPostText) . $sLinkMore;
        }
        $aUnitReplace = array('checkbox' => $sAdminCheck, 'post_caption' => $sPostCaptionHref, 'author_title' => $sAuthorTitle, 'author_username' => $sAuthorUsername, 'author_link' => $sAuthorLink, 'post_date' => $sDateTime, 'all_categories' => $sAllCategoriesLinks, 'comments_count' => $iCommentsCnt, 'post_tags' => $sTags, 'friend_style' => $sFriendStyle, 'post_uthumb' => $sOwnerThumb, 'post_picture2' => $sPostPicture, 'preview_picture' => $sPreviewPicture, 'post_description' => $sPostText, 'post_vote' => $sVotePostRating, 'post_mode' => $sPostMode, 'style' => $sStyle, 'bx_if:full' => array('condition' => $this->iPostViewType != 5, 'content' => array('author_title' => $sAuthorTitle, 'author_username' => $sAuthorUsername, 'author_link' => $sAuthorLink, 'post_date' => $sDateTime)));
        if ($this->sMobileWrapper) {
            return $this->_wrapMobileUnit($oMain->_oTemplate->parseHtmlByTemplateName('blogpost_unit_mobile', $aUnitReplace), $iPostID, $oMain);
        } else {
            return $oMain->_oTemplate->parseHtmlByTemplateName('blogpost_unit', $aUnitReplace);
        }
    }
 function getTagContent($sTag = '', $iPage = 1, $iPerPage = 0)
 {
     $sTag = uri2title(process_db_input($sTag, BX_TAGS_STRIP));
     $iPage = (int) $iPage;
     $iPerPage = (int) $iPerPage;
     $sTagDisplay = $GLOBALS['MySQL']->unescape($sTag);
     return array($sTagDisplay, $this->getSearchContent(array('tag' => $sTag), 'tag/' . title2uri($sTagDisplay) . '/', $iPage, $iPerPage));
 }
 function _parseAnything($s, $sDiv, $sLinkStart, $sClassName = '')
 {
     $sRet = '';
     $a = explode($sDiv, $s);
     $sClass = $sClassName ? 'class="' . $sClassName . '"' : '';
     foreach ($a as $sName) {
         $sRet .= '<a ' . $sClass . ' href="' . $sLinkStart . title2uri($sName) . '">' . $sName . '</a> ';
     }
     return $sRet;
 }
Exemple #10
0
 /**
  * Function will search poll used the recived category name;
  *
  * @param  : $sCategory (string) - poll's category;
  * @param  : $sExtraParam (string) - extra URI params;
  * @param  : $bUseInitPart (boolean) - if isset this param, function will add poll's js part;
  * @return : (text) - html presentation data;
  */
 function searchCategories($sCategory, $sExtraParam = null, $bUseInitPart = true)
 {
     $sOutputCode = null;
     //concat init part;
     if ($bUseInitPart) {
         $sOutputCode = $this->getInitPollPage();
     }
     $this->oSearch->aCurrent['restriction']['category']['value'] = $sCategory;
     $sExtraParam .= '&category=' . urlencode(title2uri($sCategory));
     $sOutputCode .= $this->showSearchResult(_t('_bx_poll_browse_category') . ': ' . htmlspecialchars_adv($sCategory), $sExtraParam);
     return $sOutputCode;
 }
 function displayList($aParams)
 {
     $sSampleType = $aParams['sample_type'];
     $iViewerType = $aParams['viewer_type'];
     $iStart = isset($aParams['start']) ? (int) $aParams['start'] : -1;
     $iPerPage = isset($aParams['count']) ? (int) $aParams['count'] : -1;
     $bShowEmpty = isset($aParams['show_empty']) ? $aParams['show_empty'] : true;
     $bAdminPanel = $iViewerType == BX_TD_VIEWER_TYPE_ADMIN && (isset($aParams['admin_panel']) && $aParams['admin_panel'] || $sSampleType == 'admin');
     $sModuleUri = $this->_oConfig->getUri();
     $aEntries = $this->_oDb->getEntries($aParams);
     if (empty($aEntries)) {
         return $bShowEmpty ? MsgBox(_t('_' . $sModuleUri . '_msg_no_results')) : "";
     }
     $oTags = new BxDolTags();
     $oCategories = new BxDolCategories();
     //--- Language translations ---//
     $sLKLinkPublish = _t('_' . $sModuleUri . '_lcaption_publish');
     $sLKLinkEdit = _t('_' . $sModuleUri . '_lcaption_edit');
     $sLKLinkDelete = _t('_' . $sModuleUri . '_lcaption_delete');
     $sBaseUri = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri();
     $sJsMainObject = $this->_oConfig->getJsObject();
     $aResult['sample'] = $sSampleType;
     $aResult['bx_repeat:entries'] = array();
     foreach ($aEntries as $aEntry) {
         $sVotes = "";
         if ($this->_oConfig->isVotesEnabled()) {
             $oVotes = $this->_oModule->_createObjectVoting($aEntry['id']);
             $sVotes = $oVotes->getJustVotingElement(0, $aEntry['id']);
         }
         $aTags = $oTags->explodeTags($aEntry['tags']);
         $aCategories = $oCategories->explodeTags($aEntry['categories']);
         $aTagItems = array();
         foreach ($aTags as $sTag) {
             $sTag = trim($sTag);
             $aTagItems[] = array('href' => $sBaseUri . 'tag/' . title2uri($sTag), 'title' => $sTag);
         }
         $aCategoryItems = array();
         foreach ($aCategories as $sCategory) {
             $sCategory = trim($sCategory);
             $aCategoryItems[] = array('href' => $sBaseUri . 'category/' . title2uri($sCategory), 'title' => $sCategory);
         }
         $aResult['bx_repeat:entries'][] = array('id' => $this->_oConfig->getSystemPrefix() . $aEntry['id'], 'caption' => str_replace("\$", "&#36;", $aEntry['caption']), 'class' => !in_array($sSampleType, array('view')) ? ' ' . $this->sCssPrefix . '-text-snippet' : '', 'date' => getLocaleDate($aEntry['when_uts'], BX_DOL_LOCALE_DATE), 'comments' => (int) $aEntry['cmts_count'], 'bx_repeat:categories' => $aCategoryItems, 'bx_repeat:tags' => $aTagItems, 'content' => str_replace("\$", "&#36;", $aEntry['content']), 'link' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'view/' . $aEntry['uri'], 'voting' => $sVotes, 'bx_if:checkbox' => array('condition' => $bAdminPanel, 'content' => array('id' => $aEntry['id'])), 'bx_if:status' => array('condition' => $iViewerType == BX_TD_VIEWER_TYPE_ADMIN, 'content' => array('status' => _t('_' . $sModuleUri . '_status_' . $aEntry['status']))), 'bx_if:featured' => array('condition' => $iViewerType == BX_TD_VIEWER_TYPE_ADMIN && (int) $aEntry['featured'] == 1, 'content' => array()), 'bx_if:edit_link' => array('condition' => $iViewerType == BX_TD_VIEWER_TYPE_ADMIN, 'content' => array('edit_link_url' => BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'admin/' . $aEntry['uri'], 'edit_link_caption' => $sLKLinkEdit)));
     }
     $aResult['paginate'] = '';
     if (!in_array($sSampleType, array('id', 'uri', 'view', 'search_unit'))) {
         if (!empty($sSampleType)) {
             $this->_updatePaginate($aParams);
         }
         $aResult['paginate'] = $this->oPaginate->getPaginate($iStart, $iPerPage);
     }
     $aResult['loading'] = LoadingBox($sModuleUri . '-' . $sSampleType . '-loading');
     $sRes = $this->parseHtmlByName('list.html', $aResult);
     return $sRes;
 }
Exemple #12
0
    function getPostCategoriesBlock()
    {
        $iMemberID = (int) $this->aViewingPostInfo['OwnerID'];
        $sOwnerNickname = getNickName($iMemberID);
        $aProf = array('Permalink' => $sOwnerNickname, 'Link' => $iMemberID);
        $sOwnerAddAp = $iMemberID == $this->_iVisitorID || $this->isAllowedApprove() || $this->isAllowedPostEdit(-1) || $this->isAllowedPostDelete(-1) ? '' : "AND `PostStatus`='approval'";
        $sStatusFilter = $this->isAdmin() == true ? '' : $sOwnerAddAp;
        $sNewC = ucfirst(_t('_new'));
        $sCategoriesC = _t('_bx_blog_Categories');
        $sPostsCL = strtolower(_t('_bx_blog_Posts'));
        $sFolderIcon = $this->_oTemplate->getIconUrl('folder_small.png');
        $sCategories = '';
        $oCategories = new BxDolCategories();
        $aAllCategories = $oCategories->getCategoriesList('bx_blogs', $iMemberID);
        if (is_array($aAllCategories) && count($aAllCategories) > 0) {
            foreach ($aAllCategories as $iCatID => $sCategoryName) {
                $sCategoryNameS = addslashes($sCategoryName);
                $iCountCatPost = $this->_oDb->getPostsCntInCategory($sCategoryNameS, $sStatusFilter, $iMemberID);
                if ($iCountCatPost == 0) {
                    continue;
                }
                $sCatName = process_line_output($sCategoryName);
                $sSpacerName = $this->sSpacerPath;
                $aCat = array('Permalink' => title2uri($sCategoryName), 'Link' => title2uri($sCategoryName));
                $sCatLink = $this->genBlogLink('show_member_blog', $aProf, $aCat);
                $sCategories .= <<<EOF
<div class="cls_result_row">
\t<div class="cls_res_thumb margined" >
\t\t<div class="thumbnail_block" style="border-width:0px;">
\t\t\t<span style="vertical-align:middle;">
\t\t\t\t<img class="cls_categ_icon" src="{$sFolderIcon}" alt="" />
\t\t\t</span>
\t\t</div>
\t</div>
\t<div class="cls_categ_name">
\t\t<a href="{$sCatLink}">{$sCatName}</a>&nbsp;<span class="blog_author">({$iCountCatPost} {$sPostsCL})</span>
\t</div>
\t<!-- {$sCatActions} -->
\t<div class="clear_both"></div>
</div>
EOF;
            }
        }
        $sCategoriesActions = '';
        if ($this->_iVisitorID == $iMemberID && $iMemberID > 0 || $this->bAdminMode == true) {
            $sCategoriesActions = BxDolPageView::getBlockCaptionMenu(mktime(), array('cat_new' => array('href' => bx_html_attribute($_SERVER['PHP_SELF']) . "?action=add_category&ownerID={$iMemberID}", 'title' => $sNewC, 'active' => 0)));
        }
        $sCategoriesVal = <<<EOF
<div class="blog-cat-view">
\t{$sCategories}
</div>
EOF;
        return DesignBoxContent($sCategoriesC, $sCategoriesVal, 1, $sCategoriesActions);
    }
    function displaySearchUnit($aResSQL)
    {
        $iVisitorID = (int) $_COOKIE['memberID'];
        $oMain = $this->getBlogsMain();
        $sTagsSmallIcon = $sClockIcon = $sCommentsIcon = $sCategoryIcon = '';
        if ($oMain->_oTemplate) {
            $sTagsSmallIcon = $oMain->_oTemplate->getIconUrl('tgs.png');
            $sClockIcon = $oMain->_oTemplate->getIconUrl('clock.png');
            $sCommentsIcon = $oMain->_oTemplate->getIconUrl('comments.png');
            $sCategoryIcon = $oMain->_oTemplate->getIconUrl('folder_small.png');
        }
        $iPostID = (int) $aResSQL['id'];
        $sBlogsImagesUrl = BX_BLOGS_IMAGES_URL;
        $bPossibleToView = $oMain->oPrivacy->check('view', $iPostID, $oMain->_iVisitorID);
        if (!$bPossibleToView) {
            return $oMain->_oTemplate->parseHtmlByName('browse_unit_private.html', array('extra_css_class' => ''));
        }
        $sCategories = $aResSQL['Categories'];
        $aCategories = $oMain->getTagLinks($aResSQL['Categories'], 'category', CATEGORIES_DIVIDER);
        $sFriendStyle = '';
        $sPostVote = '';
        $sPostMode = '';
        $sVotePostRating = $this->oRate->getJustVotingElement(0, 0, $aResSQL['Rate']);
        $aProfileInfo = getProfileInfo($aResSQL['ownerId']);
        $sOwnerNickname = process_line_output($aProfileInfo['NickName']);
        $sCategoryName = $aResSQL['Categories'];
        $sPostLink = $this->getCurrentUrl('file', $iPostID, $aResSQL['uri']) . $sCategoryUrlAdd;
        $sAllCategoriesLinks = '';
        if (count($aCategories) > 0) {
            foreach ($aCategories as $iKey => $sCatValue) {
                $sCatLink = $this->getCurrentUrl('category', title2uri($sCatValue), title2uri($sCatValue), array('ownerId' => $aResSQL['ownerId'], 'ownerName' => $sOwnerNickname));
                $sCatName = process_line_output($sCatValue);
                $aAllCategoriesLinks[] = '<a href="' . $sCatLink . '">' . $sCatName . '</a>';
            }
            $aAllCategoriesLinkHrefs = implode(", ", $aAllCategoriesLinks);
            $sAllCategoriesLinks = <<<EOF
<span class="margined">
\t<span>{$aAllCategoriesLinkHrefs}</span>
</span>
EOF;
        }
        $sAdminCheck = $sAdminStatus = '';
        if ($this->bShowCheckboxes) {
            $sAdminCheck = <<<EOF
<div class="browseCheckbox"><input id="ch{$iPostID}" type="checkbox" name="bposts[]" value="{$iPostID}" /></div>
EOF;
            $sPostStatus = process_line_output($aResSQL['PostStatus']);
            $sAdminStatus = <<<EOF
&nbsp;({$sPostStatus})
EOF;
        }
        $sPostCaption = process_line_output($aResSQL['title']);
        $sPostCaptionHref = <<<EOF
<a class="actions" href="{$sPostLink}">{$sPostCaption}</a>{$sAdminStatus}
EOF;
        if ($this->iPostViewType == 3) {
            $sFriendStyle = "2";
            $sPostMode = '_post';
            $sPostCaptionHref = '<div class="actions">' . $sPostCaption . '</div>';
        }
        $sDateTime = defineTimeInterval($aResSQL['date']);
        //$oCmtsView = new BxTemplCmtsView ('blogposts', (int)$iPostID);
        $iCommentsCnt = (int) $aResSQL['CommentsCount'];
        $sAuthor = '';
        if ($this->iPostViewType == 2) {
            $sAuthor = getProfileLink($aResSQL['ownerId']);
            $sAuthor = '<a href="' . $sAuthor . '">' . $sOwnerNickname . '</a>';
        }
        $sTagsCommas = $aResSQL['tag'];
        //$aTags = split(',', $sTagsCommas);
        $aTags = preg_split("/[;,]/", $sTagsCommas);
        //search by tag skiping
        if ($this->sSearchedTag != '' && in_array($this->sSearchedTag, $aTags) == false) {
            return;
        }
        $sTagsHrefs = '';
        $aTagsHrefs = array();
        foreach ($aTags as $sTagKey) {
            if ($sTagKey != '') {
                $sTagLink = $this->getCurrentUrl('tag', $iPostID, htmlspecialchars(title2uri($sTagKey)));
                $sTagsHrefAny = <<<EOF
<a href="{$sTagLink}" title="{$sTagKey}">{$sTagKey}</a>
EOF;
                $aTagsHrefs[] = $sTagsHrefAny;
            }
        }
        $sTagsHrefs = implode(", ", $aTagsHrefs);
        $sTags = <<<EOF
<span class="margined">
\t<span>{$sTagsHrefs}</span>
</span>
EOF;
        $sPostText = process_html_output($aResSQL['bodyText']);
        //$sPostText = addslashes( clear_xss( trim( process_pass_data($aResSQL['bodyText']))));
        $bFriend = is_friends($iVisitorID, $aResSQL['ownerId']);
        $bOwner = $iVisitorID == $aResSQL['ownerId'] ? true : false;
        $sOwnerThumb = $sPostPicture = '';
        if ($aResSQL['PostPhoto'] && $this->iPostViewType == 3) {
            $sSpacerName = getTemplateIcon('spacer.gif');
            $sPostPicture = <<<EOF
<div class="marg_both_left">
\t<img alt="{$aResSQL['PostPhoto']}" style="width:{$this->iThumbSize}px; height:{$this->iThumbSize}px; background-image: url({$sBlogsImagesUrl}big_{$aResSQL['PostPhoto']});cursor:pointer;" src="{$sSpacerName}" onclick="javascript: window.open( '{$sBlogsImagesUrl}orig_{$aResSQL['PostPhoto']}', 'blog post', 'width={$this->iImgSize}, height={$this->iImgSize}, menubar=no,status=no,resizable=yes,scrollbars=yes,toolbar=no,location=no' );" />
</div>
EOF;
        }
        if ($this->iPostViewType == 4) {
            $sOwnerThumb = $GLOBALS['oFunctions']->getMemberIcon($aResSQL['ownerId'], 'left');
        }
        if ($this->iPostViewType == 4 || $this->iPostViewType == 1) {
            $iBlogLimitChars = (int) getParam('max_blog_preview');
            $iBlogLimitChars = 200;
            if (strlen($aResSQL['bodyText']) > $iBlogLimitChars) {
                //$sLinkMore = "... <a href=\"".$sPostLink."\">"._t('_Read more')."</a>";
                $sLinkMore = '';
                $sPostText = html_entity_decode(process_line_output($aResSQL['bodyText']));
                $sPostText = mb_substr(strip_tags($sPostText), 0, $iBlogLimitChars);
            }
        }
        $aUnitReplace = array();
        $aUnitReplace['checkbox'] = $sAdminCheck;
        $aUnitReplace['post_caption'] = $sPostCaptionHref;
        $aUnitReplace['author'] = $sAuthor;
        $aUnitReplace['clock_icon'] = $sClockIcon;
        $aUnitReplace['post_date'] = strtolower($sDateTime);
        $aUnitReplace['category_icon'] = $sCategoryIcon;
        $aUnitReplace['all_categories'] = $sAllCategoriesLinks;
        $aUnitReplace['comments_icon'] = $sCommentsIcon;
        $aUnitReplace['comments_count'] = $iCommentsCnt;
        $aUnitReplace['post_tags'] = $sTags;
        $aUnitReplace['friend_style'] = $sFriendStyle;
        $aUnitReplace['post_uthumb'] = $sOwnerThumb;
        $aUnitReplace['post_picture2'] = $sPostPicture;
        $aUnitReplace['post_description'] = $sPostText;
        $aUnitReplace['post_vote'] = $sVotePostRating;
        $aUnitReplace['post_mode'] = $sPostMode;
        return $oMain->_oTemplate->parseHtmlByTemplateName('blogpost_unit', $aUnitReplace);
    }
Exemple #14
0
 /**
  * @see title2uri
  * @dataProvider providerForTitleToUri
  */
 function testTitleToUri($sIn, $sOut)
 {
     $this->assertEquals(title2uri($sIn), $sOut);
 }