Example #1
0
 public function sGetImageLink($hash, $imageSize = null)
 {
     if (!empty($hash)) {
         $sql = "SELECT articleID FROM s_articles_img WHERE img =?";
         $articleId = Shopware()->Db()->fetchOne($sql, array($hash));
         $imageSize = intval($imageSize);
         $image = $this->getArticleRepository()->getArticleCoverImageQuery($articleId)->getOneOrNullResult(\Doctrine\ORM\AbstractQuery::HYDRATE_ARRAY);
         if (empty($image)) {
             return "";
         }
         //first we get all thumbnail sizes of the article album
         $sizes = $this->articleMediaAlbum->getSettings()->getThumbnailSize();
         //now we get the configured image and thumbnail dir.
         $imageDir = 'http://' . $this->shop->getHost() . $this->request->getBasePath() . '/media/image/';
         $thumbDir = $imageDir . 'thumbnail/';
         foreach ($sizes as $key => $size) {
             if (strpos($size, 'x') === 0) {
                 $size = $size . 'x' . $size;
             }
             $imageData[$key] = $thumbDir . $image['path'] . '_' . $size . '.' . $image['extension'];
         }
         if (!empty($imageData)) {
             return $imageData[$imageSize];
         }
     }
     return "";
 }
Example #2
0
 /**
  * Set or remove given $noCacheTag from cookie
  *
  * @param $noCacheTag
  * @param  bool $remove
  * @return void
  */
 public function setNoCacheTag($noCacheTag, $remove = false)
 {
     static $noCacheTags, $shopId;
     if (!isset($noCacheTags)) {
         if ($this->request->getCookie('nocache')) {
             $noCacheTags = $this->request->getCookie('nocache');
             $noCacheTags = explode(', ', $noCacheTags);
         } else {
             $noCacheTags = array();
         }
         $shopId = Shopware()->Shop()->getId();
     }
     if (!empty($noCacheTag)) {
         $noCacheTag .= '-' . $shopId;
     }
     if (empty($noCacheTag)) {
         $newCacheTags = array();
     } elseif ($remove && in_array($noCacheTag, $noCacheTags)) {
         // remove $noCacheTag from $newCacheTags
         $newCacheTags = array_diff($noCacheTags, array($noCacheTag));
     } elseif (!$remove && !in_array($noCacheTag, $noCacheTags)) {
         // add $noCacheTag to $newCacheTags
         $newCacheTags = $noCacheTags;
         $newCacheTags[] = $noCacheTag;
     }
     if (isset($newCacheTags)) {
         $this->response->setCookie('nocache', implode(', ', $newCacheTags), 0, $this->request->getBasePath() . '/', $this->request->getHttpHost() == 'localhost' ? null : $this->request->getHttpHost());
     }
 }