3 if (!defined(
'OXTAGCLOUD_MINFONT')) {
4 define(
'OXTAGCLOUD_MINFONT', 100);
5 define(
'OXTAGCLOUD_MAXFONT', 400);
6 define(
'OXTAGCLOUD_MINOCCURENCETOSHOW', 2);
7 define(
'OXTAGCLOUD_STARTPAGECOUNT', 20);
8 define(
'OXTAGCLOUD_EXTENDEDCOUNT', 200);
90 protected $_aMetaChars = array(
'+',
'-',
'>',
'<',
'(',
')',
'~',
'*',
'"',
'\'',
'\\',
'[',
']',
'{',
'}',
';',
':',
'.',
'/',
'|',
'!',
'@',
'#',
'$',
'%',
'^',
'&',
'?',
'=',
'`');
110 $this->_sProductId = $sProductId;
111 $oTagList =
oxNew(
'oxarticletaglist');
112 $oTagList->setArticleId( $sProductId );
140 $this->_iLangId = $iLangId;
152 if ( $this->_iLangId === null ) {
167 $this->_blExtended = $blExtended;
189 $this->_oTagList = $oTagList;
199 return $this->_oTagList;
212 $this->_aCloudArray[$sCacheIdent] = $aTagCloudArray;
224 public function getCloudArray( $sProductId = null, $blExtended = null, $iLang = null )
227 if ( $iLang !== null ) {
231 if ( $sProductId !== null ) {
235 if ( $blExtended !== null ) {
239 if ( !isset( $this->_aCloudArray[ $sCacheIdent ] ) ) {
242 if ( $oTagList === null ) {
243 $oTagList =
oxNew(
'oxTagList');
246 $this->_aCloudArray[$sCacheIdent] = $this->
formCloudArray( $oTagList );
248 return $this->_aCloudArray[$sCacheIdent];
265 $aCloudArray = $myUtils->fromFileCache( $sCacheIdent );
269 if ( $aCloudArray === null ) {
271 $oTagSet = $oTagList->
get();
272 if ( count( $oTagSet->get() ) > $this->
getMaxAmount() ) {
273 $oTagSet->sortByHitCount();
277 $aCloudArray = $oTagSet->get();
279 if ( $sCacheIdent ) {
280 $myUtils->toFileCache( $sCacheIdent, $aCloudArray );
297 if ( is_null($aCloudArray[$sTag]) ) {
303 return floor( $iCurrSize / OXTAGCLOUD_MINFONT ) * OXTAGCLOUD_MINFONT;
314 return OXTAGCLOUD_EXTENDEDCOUNT;
316 return OXTAGCLOUD_STARTPAGECOUNT;
345 if ( ( $oTagList = $this->
getTagList() ) !== null ) {
346 $sCacheId = $oTagList->getCacheId();
349 $myUtils->toFileCache( $this->
_formCacheKey( $sCacheId ), null );
351 $this->_aCloudArray = null;
365 public function getTags( $sArtId = null, $blExtended =
false, $iLang = null )
367 if ( $iLang !== null ) {
371 if ( $sArtId !== null ) {
375 $oTagList =
oxNew(
'oxTagList');
378 if ( $blExtended !== null ) {
382 $oTagSet = $oTagList->get();
386 foreach ( $oTagSet->get() as $sKey => $oTag ) {
387 $aTags[$sKey] = $oTag->getHitCount();
407 $aTags = explode( $this->_sSeparator, $sTags );
411 foreach ( $aTags as $sTag ) {
412 if ( ( $sTag = trim( $sTag ) ) ) {
414 $iLen = $oStr->strlen( $sTag );
415 if ( $iLen > $this->_iTagMaxLength ) {
416 $sTag = $oStr->substr($sTag, 0, $this->_iTagMaxLength);
418 $sTag = trim( $sTag );
419 $aMatches = explode(
' ', $sTag);
420 foreach ( $aMatches as $iKey => $sMatch ) {
421 $sRes .= $oStr->strtolower( $this->
_fixTagLength($sMatch ) ).
" ";
423 $aRes[] = trim( $sRes );
427 return implode( $this->_sSeparator, $aRes );
442 $sTags = $oStr->preg_replace(
"/(\s*\,+\s*)+/",
",", trim( $sTags ) );
445 if ( $oStr->preg_match_all(
"/([\s\,\-]?)([^\s\,\-]+)([\s\,\-]?)/", $sTags, $aMatches ) ) {
446 foreach ( $aMatches[0] as $iKey => $sMatch ) {
447 $sProc = $aMatches[2][$iKey];
448 if ( $oStr->strlen( $sProc ) <= OXTAGCLOUD_MINTAGLENGTH ) {
449 $sProc = rtrim( $sProc,
"_" );
451 $sRes .= $aMatches[1][$iKey] . $sProc . $aMatches[3][$iKey];
455 return trim( $sRes, $this->_sSeparator );
472 $sText = str_replace($this->_aMetaChars,
' ', $sText);
475 $sText = $oStr->preg_replace(
"/\s+/",
" ", trim( $sText ) );
489 $oTags =
oxNew(
'oxtag' );
490 return $oTags->getMaxLength();
505 return $aCloudArray[$sTag]->getLink();
520 return $aCloudArray[$sTag]->getTitle();
534 $oTags =
oxNew(
'oxarticletaglist' );
536 return $oTags->canBeTagged($sTagTitle);
551 $sTag = trim( $sTag );
552 $iLen = $oStr->strlen( $sTag );
554 if ( $iLen < OXTAGCLOUD_MINTAGLENGTH ) {
555 $sTag .= str_repeat(
'_', OXTAGCLOUD_MINTAGLENGTH - $iLen );
573 return $this->_sCacheKey.
"_".$this->
getConfig()->getShopId().
"_".( ( $iLang !== null ) ? $iLang :
oxRegistry::getLang()->getBaseLanguage() ) .
"_".($blExtended?1:0);
586 return $this->_sCacheKey.
"_".$this->
getConfig()->getShopId().
"_".$sExtended.
"_".$sTagListCacheId;
596 if ( $this->_iMaxHit === null ) {
597 $aHits = array_map( array($this,
'_getTagHitCount'), $this->
getCloudArray());
598 $this->_iMaxHit = max( $aHits );
612 return $oTag->getHitCount();
626 if ($iMaxHit <= OXTAGCLOUD_MINOCCURENCETOSHOW || !$iMaxHit) {
627 return OXTAGCLOUD_MINFONT;
630 $iFontDiff = OXTAGCLOUD_MAXFONT - OXTAGCLOUD_MINFONT;
631 $iMaxHitDiff = $iMaxHit - OXTAGCLOUD_MINOCCURENCETOSHOW;
632 $iHitDiff = $iHit - OXTAGCLOUD_MINOCCURENCETOSHOW;
638 $iSize = round($iHitDiff * $iFontDiff / $iMaxHitDiff) + OXTAGCLOUD_MINFONT;
655 if ( is_array( $aTags ) && count( $aTags ) ) {
658 foreach ( $aTags as $sKey => $sTag ) {
660 $sSubQ .=
' union all ';
662 $sSubQ .=
'select '.$oDb->quote( $sKey ).
' as _oxsort, '.$oDb->quote( $sTag ).
' as _oxval';
665 $sViewName = getViewName(
"oxartextends", $iLang );
668 $sSubQ =
"select {$sViewName}.oxtags as _oxsort, 'ox_skip' as _oxval from {$sViewName} limit 1 union $sSubQ";
669 $sQ =
"select _oxtable._oxsort, _oxtable._oxval from ( {$sSubQ} ) as _oxtable order by _oxtable._oxsort desc";
673 $oRs = $oDb->select( $sQ );
674 while ( $oRs && $oRs->recordCount() && !$oRs->EOF ) {
675 if ( $oRs->fields[
'_oxval'] !=
'ox_skip' ) {
676 $aTags[$oRs->fields[
'_oxsort']] = $oRs->fields[
'_oxval'];