public function __construct($view, $orgId, $id, $admin)
 {
     $this->_photoGalleryTable = new FM_Models_FM_PhotoGallery();
     $this->_photos = $this->_photoGalleryTable->getPhotosByKeys(array('orgId' => $orgId));
     //print Zend_Json::encode($this->_photos);
     $this->_albums = FM_Components_Util_PhotoAlbum::getActive($orgId);
     $org = new FM_Components_Organization(array('id' => $orgId));
     $options = $org->getOrgConfig()->getOptions();
     $this->_showAlbum = $options['showPhotoAlbum'];
     $view->headScript()->appendFile('/js/jquery/jquery.jcarousel.js', 'text/javascript');
     $view->headScript()->appendFile('/js/tooltip.js', 'text/javascript');
     $json = Zend_Json::encode($this->_photos);
     $count = count($this->_photos);
     $albums = '';
     $album_array = array();
     foreach ($this->_albums as $key => $value) {
         $ajson = Zend_Json::encode($value->getImages());
         $album_array[$value->getId()] = $value->getImages();
         $acount = count($value->getImages());
         $albums .= $view->partial('widgets/photogallery/widget.phtml', array('org' => $org, 'photos' => array_splice($value->getImages(), 0, 10), 'json' => $ajson, 'admin' => $admin, 'count' => $acount, 'id' => $value->getId(), 'albums' => $this->_albums));
     }
     $album_array = Zend_Json::encode($album_array);
     //print_r($album_array);exit;
     if ($id) {
         //print $albums;exit;
         $view->layout()->{$id} = $view->partial('widgets/photogallery/gallerywrap.phtml', array('admin' => $admin, 'galleries' => $albums, 'albums' => $this->_albums, 'album_array' => $album_array, 'default' => $this->_showAlbum));
         //$view->partial('widgets/photogallery/widget.phtml',
         //array('org'=>$org, 'photos'=>array_splice($this->_photos, 0, 10), 'json'=>$json, 'admin'=>$admin, 'count'=>$count, 'albums'=>$this->_albums));
     }
 }
 public function ajaxdeletephotoalbumAction()
 {
     if (array_key_exists('id', $_POST)) {
         FM_Components_Util_PhotoAlbum::deleteAlbum($_POST['id']);
         $albums = FM_Components_Util_PhotoAlbum::getActive($_POST['orgId']);
         foreach ($albums as $key => $value) {
             $ajson = Zend_Json::encode($value->getImages());
             $album_array[$value->getId()] = $value->getImages();
         }
         print Zend_Json::encode($album_array);
         exit;
     }
 }