protected function _processCollection($collection, $category = false) { /* add category to url */ $categoryUrl = self::$_helper->isCategoryUrl(); /* use short content for posts */ $shortContent = self::$_helper->useShortContent(); /* readMoreCount */ $readMoreCount = (int) self::$_helper->readMoreCount(); /* cache (run-time) all categories related to products */ $this->_prepareRelatedCategories($collection); foreach ($collection as $item) { $this->_prepareData($item)->_prepareDates($item); /* prepare urls depnding on mode */ if ($category && $categoryUrl) { $item->setAddress($this->getBlogUrl(null, array(self::$_catUriParam => $category->getIdentifier(), self::$_postUriParam => $item->getIdentifier()))); } else { $item->setAddress($this->getBlogUrl($item->getIdentifier())); } /* prepare short content fields */ if ($shortContent) { if ($item->getShortContent()) { $item->setPostContent($item->getShortContent() . $this->_getReadMoreLink($item)); } } elseif ($readMoreCount) { $strManager = new Trio_Blog_Helper_Substring(array('input' => self::$_helper->filterWYS($item->getPostContent()))); $content = $strManager->getHtmlSubstr($readMoreCount); if ($strManager->getSymbolsCount() == $readMoreCount) { $content .= $this->_getReadMoreLink($item); } $item->setPostContent($content); } /* add categories the item is related to */ $this->_addCategories($item); } return $collection; }
/** * @test * @dataProvider provider__getHtmlSubstr * */ public function getHtmlSubstr($data) { $strManager = new Trio_Blog_Helper_Substring(array('input' => $data['string'])); $content = $strManager->getHtmlSubstr($data['substr']); $this->assertEquals(mb_strtolower($content, mb_detect_encoding($content)), mb_strtolower($data['expected'], mb_detect_encoding($content))); }