|
@@ -14,9 +14,6 @@ define('BX_METATAGS_KEYWORDS_IN_CLOUD', 32); ///< default number of tags in tags
|
|
|
*/
|
|
*/
|
|
|
class BxBaseServiceMetatags extends BxDol
|
|
class BxBaseServiceMetatags extends BxDol
|
|
|
{
|
|
{
|
|
|
- protected $_iKeywordsCloudFontSizeMin = 14;
|
|
|
|
|
- protected $_iKeywordsCloudFontSizeMax = 32;
|
|
|
|
|
-
|
|
|
|
|
public function __construct()
|
|
public function __construct()
|
|
|
{
|
|
{
|
|
|
parent::__construct();
|
|
parent::__construct();
|
|
@@ -29,54 +26,16 @@ class BxBaseServiceMetatags extends BxDol
|
|
|
* @param $iMaxCount number of tags in keywords cloud, by default @see BX_METATAGS_KEYWORDS_IN_CLOUD
|
|
* @param $iMaxCount number of tags in keywords cloud, by default @see BX_METATAGS_KEYWORDS_IN_CLOUD
|
|
|
* @return tags cloud HTML string
|
|
* @return tags cloud HTML string
|
|
|
*/
|
|
*/
|
|
|
- public function serviceKeywordsCloud ($sObject, $mixedSection, $aParams = array())
|
|
|
|
|
|
|
+ public function serviceKeywordsCloud($sObject, $mixedSection, $aParams = array())
|
|
|
{
|
|
{
|
|
|
$iMaxCount = isset($aParams['max_count']) ? (int)$aParams['max_count'] : BX_METATAGS_KEYWORDS_IN_CLOUD;
|
|
$iMaxCount = isset($aParams['max_count']) ? (int)$aParams['max_count'] : BX_METATAGS_KEYWORDS_IN_CLOUD;
|
|
|
$bShowEmpty = isset($aParams['show_empty']) ? (bool)$aParams['show_empty'] : false;
|
|
$bShowEmpty = isset($aParams['show_empty']) ? (bool)$aParams['show_empty'] : false;
|
|
|
- $sBrowseUrl = isset($aParams['browse_url']) ? $aParams['browse_url'] : bx_append_url_params('searchKeyword.php', array(
|
|
|
|
|
- 'type' => 'keyword',
|
|
|
|
|
- 'keyword' => '{keyword}'
|
|
|
|
|
- )) . '{sections}';
|
|
|
|
|
-
|
|
|
|
|
- $o = BxDolMetatags::getObjectInstance($sObject);
|
|
|
|
|
- $aKeywords = $o->keywordsPopularList($iMaxCount);
|
|
|
|
|
- if (!$aKeywords)
|
|
|
|
|
- return $bShowEmpty ? MsgBox(_t('_Empty')) : '';
|
|
|
|
|
-
|
|
|
|
|
- ksort($aKeywords, SORT_LOCALE_STRING);
|
|
|
|
|
-
|
|
|
|
|
- $iFontDiff = floor($this->_iKeywordsCloudFontSizeMax - $this->_iKeywordsCloudFontSizeMin);
|
|
|
|
|
- $iMinRating = min($aKeywords);
|
|
|
|
|
- $iMaxRating = max($aKeywords);
|
|
|
|
|
-
|
|
|
|
|
- $iRatingDiff = $iMaxRating - $iMinRating;
|
|
|
|
|
- $iRatingDiff = $iRatingDiff == 0 ? 1 : $iRatingDiff;
|
|
|
|
|
-
|
|
|
|
|
- $sSectionPart = '';
|
|
|
|
|
- if (is_array($mixedSection))
|
|
|
|
|
- $sSectionPart = '§ion[]=' . implode('§ion[]=', $mixedSection);
|
|
|
|
|
- elseif (is_string($mixedSection))
|
|
|
|
|
- $sSectionPart = '§ion[]=' . $mixedSection;
|
|
|
|
|
-
|
|
|
|
|
- $aUnits = array();
|
|
|
|
|
- foreach($aKeywords as $sKeyword => $iCount) {
|
|
|
|
|
- $aUnits[] = array(
|
|
|
|
|
- 'size' => $this->_iKeywordsCloudFontSizeMin + floor($iFontDiff * (($iCount - $iMinRating) / $iRatingDiff)),
|
|
|
|
|
- 'href' => BX_DOL_URL_ROOT . bx_replace_markers($sBrowseUrl, array(
|
|
|
|
|
- 'keyword' => rawurlencode($sKeyword),
|
|
|
|
|
- 'sections' => $sSectionPart
|
|
|
|
|
- )),
|
|
|
|
|
- 'count' => $iCount,
|
|
|
|
|
- 'keyword' => htmlspecialchars_adv($sKeyword),
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- $aVars = array (
|
|
|
|
|
- 'bx_repeat:units' => $aUnits,
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ $sResult = BxDolMetatags::getObjectInstance($sObject)->getKeywordsCloud($mixedSection, $iMaxCount);
|
|
|
|
|
+ if(empty($sResult))
|
|
|
|
|
+ return $bShowEmpty ? MsgBox(_t('_Empty')) : '';
|
|
|
|
|
|
|
|
- $this->addCssJs();
|
|
|
|
|
- return BxDolTemplate::getInstance()->parseHtmlByName('metatags_keywords_cloud.html', $aVars);
|
|
|
|
|
|
|
+ return $sResult;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -85,32 +44,9 @@ class BxBaseServiceMetatags extends BxDol
|
|
|
* @param $iId content id
|
|
* @param $iId content id
|
|
|
* @return map HTML string
|
|
* @return map HTML string
|
|
|
*/
|
|
*/
|
|
|
- public function serviceLocationsMap ($sObject, $iId, $sMapSize = '1000x144')
|
|
|
|
|
- {
|
|
|
|
|
- $sMapKey = trim(getParam('sys_maps_api_key'));
|
|
|
|
|
-
|
|
|
|
|
- $o = BxDolMetatags::getObjectInstance($sObject);
|
|
|
|
|
- $sLocationHtml = $o->locationsString($iId);
|
|
|
|
|
- if (!$sLocationHtml)
|
|
|
|
|
- return '';
|
|
|
|
|
-
|
|
|
|
|
- $sLocationEncoded = rawurlencode(strip_tags($sLocationHtml));
|
|
|
|
|
- $sProto = (0 == strncmp('https', BX_DOL_URL_ROOT, 5)) ? 'https' : 'http';
|
|
|
|
|
- $iScale = isset($_COOKIE['devicePixelRatio']) && (int)$_COOKIE['devicePixelRatio'] >= 2 ? 2 : 1;
|
|
|
|
|
- $sLang = bx_lang_name();
|
|
|
|
|
- $aVars = array (
|
|
|
|
|
- 'map_img' => $sProto . '://maps.googleapis.com/maps/api/staticmap?center=' . $sLocationEncoded . '&zoom=7&size=' . $sMapSize . '&maptype=roadmap&markers=size:small%7C' . $sLocationEncoded . '&scale=' . $iScale . '&language=' . $sLang . ($sMapKey ? '&key=' . $sMapKey : ''),
|
|
|
|
|
- 'location_string' => $sLocationHtml,
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- $this->addCssJs();
|
|
|
|
|
- return BxDolTemplate::getInstance()->parseHtmlByName('metatags_locations_map.html', $aVars);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- public function addCssJs()
|
|
|
|
|
|
|
+ public function serviceLocationsMap($sObject, $iId, $sMapSize = '1000x144')
|
|
|
{
|
|
{
|
|
|
- $oTemplate = BxDolTemplate::getInstance();
|
|
|
|
|
- $oTemplate->addCss('metatags.css');
|
|
|
|
|
|
|
+ return BxDolMetatags::getObjectInstance($sObject)->getLocationsMap($iId, $sMapSize);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|