/**
  *
  * Get photos albums tree
  * @return string
  */
 public function albums()
 {
     $album_model = new photosAlbumModel();
     $albums = $album_model->getAlbums(true);
     $tree = new photosViewTree($albums);
     return $tree->display('frontend');
 }
Пример #2
0
 public function execute()
 {
     if ($this->getRights('upload')) {
         $this->executeAction('upload_dialog', new photosUploadAction());
     }
     $album_model = new photosAlbumModel();
     $albums = $album_model->getAlbums();
     $top_level_albums_count = 0;
     foreach ($albums as $a) {
         if (!$a['parent_id']) {
             $top_level_albums_count++;
         }
     }
     /**
      * Extend photo toolbar in photo-page
      * Add extra item to toolbar
      * @event backend_photo_toolbar
      * @return array[string][string]string $return[%plugin_id%]['edit_menu'] Extra item for edit_menu in photo_toolbar
      * @return array[string][string]string $return[%plugin_id%]['share_menu'] Extra item for edit_menu in photo_toolbar
      */
     $this->view->assign('backend_photo_toolbar', wa()->event('backend_photo_toolbar'));
     $tree = new photosViewTree($albums);
     $this->view->assign('albums', $tree->display());
     $this->view->assign('albums_count', count($albums));
     $this->view->assign('top_level_albums_count', $top_level_albums_count);
     $this->view->assign('app_albums', self::getAppAlbums());
     $collection = new photosCollection();
     $collection_rated = new photosCollection('search/rate>0');
     $this->view->assign('count', $collection->count());
     $this->view->assign('rated_count', $collection_rated->count());
     $this->view->assign('last_login_datetime', $this->getConfig()->getLastLoginTime());
     /**
      * Extend sidebar
      * Add extra item to sidebar
      * @event backend_sidebar
      * @return array[string][string]string $return[%plugin_id%]['menu'] Extra item for menu in sidebar
      * @return array[string][string]string $return[%plugin_id%]['section'] Extra section in sidebar
      */
     $this->view->assign('backend_sidebar', wa()->event('backend_sidebar'));
     /**
      * Include plugins js and css
      * @event backend_assets
      * @return array[string]string $return[%plugin_id%] Extra head tag content
      */
     $this->view->assign('backend_assets', wa()->event('backend_assets'));
     $photo_tag_model = new photosTagModel();
     $this->view->assign('cloud', $photo_tag_model->getCloud());
     $this->view->assign('popular_tags', $photo_tag_model->popularTags());
     $this->view->assign('rights', array('upload' => $this->getRights('upload'), 'edit' => $this->getRights('edit')));
     $config = $this->getConfig();
     $this->view->assign('big_size', $config->getSize('big'));
     $this->view->assign('sidebar_width', $config->getSidebarWidth());
 }
 /**
  *
  * Get photos albums tree
  * @param bool $return_html
  * @param bool $custom_params get with custom params or not
  * @return string
  */
 public function albums($return_html = true, $custom_params = true)
 {
     $album_model = new photosAlbumModel();
     $albums = $album_model->getAlbums(true);
     foreach ($albums as &$a) {
         $a['name'] = htmlspecialchars($a['name']);
     }
     unset($a);
     if ($custom_params) {
         $album_params_model = new photosAlbumParamsModel();
         $params = $album_params_model->get(array_keys($albums));
         foreach ($albums as $a_id => &$a) {
             foreach (ifset($params[$a_id], array()) as $k => $v) {
                 if (!isset($a[$k])) {
                     $a[$k] = $v;
                 }
             }
         }
         unset($a);
     }
     if ($return_html) {
         $tree = new photosViewTree($albums);
         return $tree->display('frontend');
     } else {
         foreach ($albums as $album_id => $album) {
             $albums[$album_id]['url'] = photosFrontendAlbum::getLink($album);
             if ($album['parent_id'] && isset($albums[$album['parent_id']])) {
                 $albums[$album['parent_id']]['childs'][] =& $albums[$album_id];
             }
         }
         foreach ($albums as $album_id => $album) {
             if ($album['parent_id']) {
                 unset($albums[$album_id]);
             }
         }
         return $albums;
     }
 }
 public function execute()
 {
     $collection = new photosCollection();
     $hash = '';
     // Specific album?
     if ($id = waRequest::request('album_id', null, 'int')) {
         $album_model = new photosAlbumModel();
         $album = $album_model->getById($id);
         if (!$album) {
             throw new waException(_w('Unknown album'));
         }
         // check rights
         $album_rights_model = new photosAlbumRightsModel();
         if (!$album_rights_model->checkRights($album)) {
             throw new waRightsException(_w("You don't have sufficient access rights"));
         }
         $album['edit_rights'] = $album_rights_model->checkRights($album, true);
         $hash = '/album/' . $id;
     } else {
         if ($app_id = waRequest::request('app_id', '', 'string')) {
             if (wa()->appExists($app_id) && wa()->getUser()->getRights($app_id, 'backend')) {
                 $hash = 'app/' . $app_id;
             } else {
                 throw new waRightsException(_w("You don't have sufficient access rights"));
             }
         }
     }
     // Photos
     $collection = new photosCollection($hash);
     $photos = $collection->getPhotos("*,thumb,thumb_crop,thumb_middle,thumb_big,tags,edit_rights", 0, 100500);
     $photos = photosCollection::extendPhotos($photos);
     // Album tree
     $album_model = new photosAlbumModel();
     $albums = $album_model->getAlbums();
     $albums_tree = new photosViewTree($albums);
     $this->view->assign(array('title' => $collection->getTitle(), 'photos' => $photos, 'albums_tree_html' => $albums_tree->display(), 'app_albums' => photosDefaultLayout::getAppAlbums('blog'), 'hash' => '#/' . trim($hash, '/#') . '/'));
 }