public function findAction() { if ($gallery_id = $this->getRequest()->getParam("gallery_id")) { try { $offset = $this->getRequest()->getParam('offset', 0); $data = array("collection" => array()); $image = new Media_Model_Gallery_Image(); $image->find($gallery_id); if (!$image->getId() or $image->getValueId() != $this->getCurrentOptionValue()->getId()) { throw new Exception($this->_('An error occurred while loading pictures. Please try later.')); } $images = $image->setOffset($offset)->getImages(); foreach ($images as $key => $link) { $key += $offset; $data["collection"][] = array("offset" => $link->getOffset(), "gallery_id" => $key, "is_visible" => false, "url" => $link->getImage(), "title" => $link->getTitle(), "description" => $link->getDescription(), "author" => $link->getAuthor()); } if ($image->getTypeId() != "custom") { $data["show_load_more"] = count($data["images"]) > 0; } else { $data["show_load_more"] = $key - $offset + 1 > Media_Model_Gallery_Image_Abstract::DISPLAYED_PER_PAGE - 1 ? true : false; } } catch (Exception $e) { $data = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($data); } }
public function findallAction() { if ($value_id = $this->getRequest()->getParam("value_id")) { try { $image = new Media_Model_Gallery_Image(); $images = $image->findAll(array('value_id' => $value_id)); $data = array("galleries" => array()); foreach ($images as $image) { $data["galleries"][] = array("id" => $image->getId(), "name" => $image->getName(), "type" => $image->getTypeId()); } $data["page_title"] = $this->getCurrentOptionValue()->getTabbarName(); $data["header_right_button"]["picto_url"] = $this->_getColorizedImage($this->_getImage('pictos/more.png', true), $this->getApplication()->getBlock('subheader')->getColor()); } catch (Exception $e) { $data = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($data); } }