Ejemplo n.º 1
0
 public function getImages($offset)
 {
     if (!$this->_images) {
         $this->_images = array();
         try {
             $image = new Media_Model_Gallery_Image_Custom();
             $params = array('limit' => self::DISPLAYED_PER_PAGE);
             if (!empty($offset)) {
                 $params['offset'] = $offset;
             }
             $images = $image->findAll(array('gallery_id' => $this->getImageId()), 'image_id DESC', $params);
         } catch (Exception $e) {
             $images = array();
         }
         foreach ($images as $key => $image) {
             $this->_images[] = new Core_Model_Default(array('offset' => $offset++, 'title' => $image->getTitle(), 'description' => $image->getDescription(), 'author' => null, 'image' => Application_Model_Application::getImagePath() . $image->getData('url')));
         }
     }
     return $this->_images;
 }
Ejemplo n.º 2
0
 public function copyTo($option)
 {
     $images = array();
     if ($this->getTypeId() == 'custom') {
         $image = new Media_Model_Gallery_Image_Custom();
         $images = $image->findAll(array('gallery_id' => $this->getId()));
     }
     $this->getTypeInstance()->setId(null);
     $this->setId(null)->setValueId($option->getId())->save();
     foreach ($images as $image) {
         if (file_exists(BASE_PATH . Application_Model_Application::PATH_IMAGE . $image->getData('url'))) {
             $image_url = Application_Model_Application::PATH_IMAGE . $image->getData('url');
             $file = pathinfo($image_url);
             $filename = $file['basename'];
             $relativePath = $option->getImagePathTo();
             $folder = Core_Model_Directory::getBasePathTo(Application_Model_Application::PATH_IMAGE . '/' . $relativePath);
             if (!is_dir($folder)) {
                 mkdir($folder, 0777, true);
             }
             $img_src = Core_Model_Directory::getBasePathTo($image_url);
             $img_dst = $folder . '/' . $filename;
             if (@copy($img_src, $img_dst)) {
                 $image->setId(null)->setGalleryId($this->getId())->setData('url', $relativePath . '/' . $filename)->save();
             }
         }
     }
     return $this;
 }