/** * @see OW_Rendarable::onBeforeRender */ public function onBeforeRender() { if ($this->entityId !== null) { $this->tagList = $this->service->findEntityTagsWithPopularity($this->entityId, $this->entityType); } else { if ($this->tagsCount === null) { $this->tagsCount = $this->service->getConfig(BOL_TagService::CONFIG_DEFAULT_TAGS_COUNT); } $this->tagList = $this->service->findMostPopularTags($this->entityType, $this->tagsCount); } parent::onBeforeRender(); }
/** * @see OW_Rendarable::onBeforeRender */ public function onBeforeRender() { // find tags to show if ($this->entityId !== null) { $tags = $this->service->findEntityTagsWithPopularity($this->entityId, $this->entityType); } else { if ($this->tagsCount === null) { $this->tagsCount = $this->service->getConfig(BOL_TagService::CONFIG_DEFAULT_EXTENDED_TAGS_COUNT); } $tags = $this->service->findMostPopularTags($this->entityType, $this->tagsCount); } // get font sizes from configs $minFontSize = $this->service->getConfig(BOL_TagService::CONFIG_MIN_FONT_SIZE); $maxFontSize = $this->service->getConfig(BOL_TagService::CONFIG_MAX_FONT_SIZE); // get min and max tag's items count $minCount = null; $maxCount = null; foreach (!empty($tags) ? $tags : array() as $tag) { if ($minCount === null) { $minCount = (int) $tag['itemsCount']; $maxCount = (int) $tag['itemsCount']; } if ((int) $tag['itemsCount'] < $minCount) { $minCount = (int) $tag['itemsCount']; } if ((int) $tag['itemsCount'] > $maxCount) { $maxCount = (int) $tag['itemsCount']; } } // prepare array to assign foreach (!empty($tags) ? $tags : array() as $key => $value) { $tags[$key]['url'] = $this->routeName === null ? OW::getRequest()->buildUrlQueryString($this->url, array('tag' => $value['tagLabel'])) : OW::getRouter()->urlForRoute($this->routeName, array('tag' => $value['tagLabel'])); $fontSize = $maxCount === $minCount ? $maxFontSize / 2 : floor(((int) $value['itemsCount'] - $minCount) / ($maxCount - $minCount) * ($maxFontSize - $minFontSize) + $minFontSize); $tags[$key]['size'] = $fontSize; $tags[$key]['lineHeight'] = $fontSize + 4; } $this->assign('tags', $tags); }