Example #1
0
 /**
  * Return URL to stores's view page
  *
  * @param  MGS_Storelocator_Model_Storelocator $storelocator
  * @return string
  */
 public function getStoreUrl($storelocator)
 {
     return $this->getUrl('*/*/view', array('id' => $storelocator->getId()));
 }
Example #2
0
 /**
  * Return URL for resized store Image
  *
  * @param MGS_Storelocator_Model_View $store
  * @param integer $width
  * @param integer $height
  * @return bool|string
  */
 public function resize(MGS_Storelocator_Model_Storelocator $store, $width, $height = null)
 {
     if (!$store->getStoreLogo()) {
         return false;
     }
     if ($width < self::MIN_WIDTH || $width > self::MAX_WIDTH) {
         //return false;
     }
     $width = (int) $width;
     if (!is_null($height)) {
         if ($height < self::MIN_HEIGHT || $height > self::MAX_HEIGHT) {
             //return false;
         }
         $height = (int) $height;
     }
     $imageFile = $store->getStoreLogo();
     $cacheDir = $this->getBaseDir() . DS . 'cache' . DS . $width;
     $cacheUrl = $this->getBaseUrl() . '/' . 'cache' . '/' . $width . '/';
     $io = new Varien_Io_File();
     $io->checkAndCreateFolder($cacheDir);
     $io->open(array('path' => $cacheDir));
     if ($io->fileExists($imageFile)) {
         return $cacheUrl . $imageFile;
     }
     try {
         $image = new Varien_Image($this->getBaseDir() . DS . $imageFile);
         $image->resize($width, $height);
         $image->save($cacheDir . DS . $imageFile);
         return $cacheUrl . $imageFile;
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
 }