/** * Returns the index of the current image inside the article. * If the image doesn't belong to the article returns null. * * @return int */ protected function getImageIndex() { $image = CampTemplate::singleton()->context()->image; if (!$image->defined) { return null; } $articleImage = new ArticleImage($this->m_dbObject->getArticleNumber(), $image->number); if (!$articleImage->exists()) { return null; } return $articleImage->getImageArticleIndex(); }
/** * Returns the index of the current image inside the article. * If the image doesn't belong to the article returns null. * * @return int */ protected function getImageIndex() { $image = CampTemplate::singleton()->context()->image; if (!$image->defined) { return null; } $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheKey = $cacheService->getCacheKey(array('ArticleImageIndex', $this->m_dbObject->getArticleNumber(), $image->number), 'article'); if ($cacheService->contains($cacheKey)) { return $cacheService->fetch($cacheKey); } $articleImage = new ArticleImage($this->m_dbObject->getArticleNumber(), $image->number); if (!$articleImage->exists()) { $index = null; } else { $index = $articleImage->getImageArticleIndex(); } $cacheService->save($cacheKey, $index); return $index; }