/** * * 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'); }
public function execute() { $parent_id = waRequest::get('parent_id'); $depth = waRequest::get('depth', null, 'int'); $album_model = new photosAlbumModel(); $albums = $album_model->getAlbums(); foreach ($albums as $album_id => $album) { if ($album['parent_id'] && isset($albums[$album['parent_id']])) { $albums[$album['parent_id']]['albums'][] =& $albums[$album_id]; } } if (!$parent_id) { foreach ($albums as $album_id => $album) { if ($album['parent_id']) { unset($albums[$album_id]); } } $albums = array_values($albums); } else { $albums = array($albums[$parent_id]); } if ($depth !== null) { $albums = array('albums' => $albums); $this->cutOffSubtree($albums, $depth + 1); $albums = $albums['albums']; } $this->response = $albums; $this->response['_element'] = 'album'; }
public function execute() { $album_model = new photosAlbumModel(); $albums = $album_model->getAlbums(false, photosAlbumModel::TYPE_STATIC, $this->getRights('edit') ? false : true, false); $this->view->assign('albums', $albums); $group_model = new waGroupModel(); $groups = $group_model->getNames(); $this->view->assign('groups', $groups); }
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()); }
public function execute() { $album_id = waRequest::get('id', null, waRequest::TYPE_INT); $album_model = new photosAlbumModel(); $albums = $album_model->getAlbums(); $album = ifset($albums[$album_id]); if (!$album_id || !$album) { throw new waException(_w('Unknown album')); } $collection = new photosCollection('/album/' . $album_id); $this->view->assign('album', $album); $this->view->assign('photos_count', $collection->count()); $this->view->assign('offspring', $this->getOffspringIds($albums, $album_id)); }
public function execute() { // Load albums $album_model = new photosAlbumModel(); $albums = $album_model->getAlbums(); // We only care about root-level albums foreach ($albums as $aid => $a) { if ($a['parent_id']) { unset($albums[$aid]); continue; } } // Load cover photos $album_model->keyPhotos($albums); $this->view->assign(array('sidebar_width' => wa('photos')->getConfig()->getSidebarWidth(), 'albums' => $albums)); }
public function execute() { if ($id = waRequest::get('id', waRequest::TYPE_INT)) { $photo_model = new photosPhotoModel(); $photo = $photo_model->getById($id); $album_photos_model = new photosAlbumPhotosModel(); $photo_albums = $album_photos_model->getByPhoto($id); } else { $photo = null; $photo_albums = array(); } $this->view->assign('photo_albums', $photo_albums); $album_model = new photosAlbumModel(); $albums = $album_model->getAlbums(false, photosAlbumModel::TYPE_STATIC, $this->getRights('edit') ? false : true, false); $this->view->assign('albums', $albums); $this->view->assign('photo', $photo); }
/** * * 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, '/#') . '/')); }
public function execute() { $post_id = waRequest::get('id', null, waRequest::TYPE_INT); $blog_model = new blogBlogModel(); $blogs = $blog_model->getAvailable(); if (!$blogs) { $this->setTemplate('BlogNotFound'); return; } $blogs = $blog_model->prepareView($blogs); $post_model = new blogPostModel(); if ($post_id) { // edit post $post = $post_model->getById($post_id); if (!$post) { throw new waException(_w('Post not found'), 404); } //check rights if (blogHelper::checkRights($post['blog_id']) < blogRightConfig::RIGHT_FULL && $post['contact_id'] != $this->getUser()->getId()) { throw new waRightsException(_w('Access denied')); } $post['datetime'] = $post['datetime'] >= 1971 ? $post['datetime'] : ''; $blog_id = $post['blog_id']; $blog = $blogs[$blog_id]; $title = trim(sprintf(_w('Editing post %s'), $post['title'])); } else { // add post $date = waRequest::get('date', ''); $blog = $this->getAllowedBlog($blogs, wa()->getStorage()->read('blog_last_id')); if (!$blog) { throw new waRightsException(_w('Access denied')); } $blog_id = $blog['id']; $post = array('status' => $date ? blogPostModel::STATUS_DEADLINE : blogPostModel::STATUS_DRAFT, 'title' => $this->getRequest()->post('title', '', waRequest::TYPE_STRING_TRIM), 'text' => $this->getRequest()->post('text', '', waRequest::TYPE_STRING_TRIM), 'continued_text' => null, 'categories' => array(), 'contact_id' => wa()->getUser()->getId(), 'blog_id' => $blog_id) + $post_model->getEmptyRow(); $title = _w('Adding new post'); } // Album tree $albums = array(); $photos_frontend_url = null; if (blogPhotosBridge::isAvailable()) { if ($post['album_link_type'] != 'photos') { $post['album_link_type'] = 'blog'; } wa('photos'); $album_model = new photosAlbumModel(); $albums = $album_model->getAlbums(); foreach ($albums as &$a) { if ($a['status'] == 1) { $a['frontend_link'] = photosFrontendAlbum::getLink($a); } else { $a['frontend_link'] = ''; } } unset($a); } // Frontend URLs for this post $album_link_type = $post['album_link_type']; $post['album_link_type'] = 'blog'; $all_links = blogPostModel::getPureUrls($post); $post['album_link_type'] = $album_link_type; $post['other_links'] = $all_links; $post['link'] = array_shift($post['other_links']); $post['remaining_time'] = null; if ($post['status'] == blogPostModel::STATUS_SCHEDULED && $post['datetime']) { $post['remaining_time'] = $this->calculateRemainingTime($post['datetime']); } if ($blog['rights'] >= blogRightConfig::RIGHT_FULL) { $users = blogHelper::getAuthors($post['blog_id']); } else { $user = $this->getUser(); $users = array($user->getId() => $user->getName()); } // preview hash for all type of drafts if ($post['status'] != blogPostModel::STATUS_PUBLISHED) { $options = array('contact_id' => $post['contact_id'], 'blog_id' => $blog_id, 'post_id' => $post['id'], 'user_id' => wa()->getUser()->getId()); $preview_hash = blogPostModel::getPreviewHash($options); $this->view->assign('preview_hash', base64_encode($preview_hash . $options['user_id'])); } $this->view->assign('albums', $albums); $this->view->assign('no_settlements', !wa()->getRouteUrl('blog/')); $this->view->assign('params', $this->getPostParams($post['id'])); $this->view->assign('blog', $blog); $this->view->assign('users', $users); $this->view->assign('blogs', $blogs); $allow_change_blog = 0; foreach ($blogs as $blog_item) { if ($blog_item['rights'] >= blogRightConfig::RIGHT_READ_WRITE) { ++$allow_change_blog; } } $this->view->assign('allow_change_blog', $allow_change_blog); $this->view->assign('post_id', $post_id); $this->view->assign('datetime_timezone', waDateTime::date("T", null, wa()->getUser()->getTimezone())); /** * Backend post edit page * UI hook allow extends post edit page * @event backend_post_edit * @param array[string]mixed $post * @param array[string]int $post['id'] * @param array[string]int $post['blog_id'] * @return array[string][string]string $return[%plugin_id%]['sidebar'] Plugin sidebar html output * @return array[string][string]string $return[%plugin_id%]['toolbar'] Plugin toolbar html output * @return array[string][string]string $return[%plugin_id%]['editor_tab'] Plugin editor tab html output */ $this->view->assign('backend_post_edit', wa()->event('backend_post_edit', $post, array('sidebar', 'toolbar', 'editor_tab'))); $app_settings = new waAppSettingsModel(); $show_comments = $app_settings->get($this->getApp(), 'show_comments', true); $this->view->assign('show_comments', $show_comments); $this->view->assign('post', $post); /** * @deprecated * For backward compatibility reason */ $this->view->assign('cron_schedule_time', waSystem::getSetting('cron_schedule', 0, 'blog')); $this->view->assign('last_schedule_cron_time', waSystem::getSetting('last_schedule_cron_time', 0, 'blog')); $this->view->assign('cron_command', 'php ' . wa()->getConfig()->getRootPath() . '/cli.php blog schedule'); $this->setLayout(new blogDefaultLayout()); $this->getResponse()->setTitle($title); }