Exemplo n.º 1
0
 /**
  * Displays a list of subscriptions the user belongs to.
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function display($tpl = null)
 {
     // Check for acl
     $this->checkAcl('allow_subscription');
     // Do not allow guests to access this page
     if ($this->my->guest) {
         return EB::requireLogin();
     }
     // Set the title of the page
     $this->doc->setTitle(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_PAGE_TITLE'));
     // Add pathway
     if (!EBR::isCurrentActiveMenu('subscription')) {
         $this->setPathway(JText::_('COM_EASYBLOG_SUBSCRIPTIONS_BREADCRUMB'));
     }
     // Ensure that the user has access to manage subscriptions
     if (!$this->acl->get('allow_subscription')) {
         return JError::raiseError(500, JText::_('COM_EASYBLOG_YOU_DO_NOT_HAVE_PERMISSION_TO_VIEW'));
     }
     // Get a list of subscriptions the user has
     $model = EB::model('Subscriptions');
     $result = $model->getSubscriptionsByUser($this->my->id);
     $subscriptions = array();
     $groups = array();
     if ($result) {
         foreach ($result as $row) {
             $type = $row->utype;
             $groups[] = $type;
             if (!isset($subscriptions[$type])) {
                 $subscriptions[$row->utype] = array();
             }
             // Get the formatted type title
             $row->object = $row->getObject();
             $subscriptions[$row->utype][] = $row;
         }
     }
     // Ensure that the groups are unique
     $groups = array_unique($groups);
     $this->set('groups', $groups);
     $this->set('subscriptions', $subscriptions);
     parent::display('subscription/default');
 }
Exemplo n.º 2
0
 /**
  * Displays a list of blog posts on the site filtered by a category.
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function listings()
 {
     // Retrieve sorting options
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     $id = $this->input->get('id', 0, 'int');
     // Try to load the category
     $category = EB::table('Category');
     $category->load($id);
     // If the category isn't found on the site throw an error.
     if (!$id || !$category->id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_CATEGORY_NOT_FOUND'));
     }
     // Set the meta description for the category
     EB::setMeta($category->id, META_TYPE_CATEGORY);
     // Set a canonical link for the category page.
     $this->canonical($category->getExternalPermalink());
     // Get the privacy
     $privacy = $category->checkPrivacy();
     if ($privacy->allowed || EB::isSiteAdmin() || !$this->my->guest && $this->config->get('main_allowguestsubscribe')) {
         $this->doc->addHeadLink($category->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         $this->doc->addHeadLink($category->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
     }
     // Set views breadcrumbs
     $this->setViewBreadcrumb($this->getName());
     // Set the breadcrumb for this category
     if (!EBR::isCurrentActiveMenu('categories', $category->id)) {
         // Always add the final pathway to the category title.
         $this->setPathway($category->title, '');
     }
     //get the nested categories
     $category->childs = null;
     // Build nested childsets
     EB::buildNestedCategories($category->id, $category, false, true);
     // Parameterize initial subcategories to display. Ability to configure from backend.
     $nestedLinks = '';
     $initialLimit = $this->app->getCfg('list_limit') == 0 ? 5 : $this->app->getCfg('list_limit');
     if (count($category->childs) > $initialLimit) {
         $initialNestedLinks = '';
         $initialRow = new stdClass();
         $initialRow->childs = array_slice($category->childs, 0, $initialLimit);
         EB::accessNestedCategories($initialRow, $initialNestedLinks, '0', '', 'link', ', ');
         $moreNestedLinks = '';
         $moreRow = new stdClass();
         $moreRow->childs = array_slice($category->childs, $initialLimit);
         EB::accessNestedCategories($moreRow, $moreNestedLinks, '0', '', 'link', ', ');
         // Hide more nested links until triggered
         $nestedLinks .= $initialNestedLinks;
         $nestedLinks .= '<span class="more-subcategories-toggle" data-more-categories-link> ' . JText::_('COM_EASYBLOG_AND') . ' <a href="javascript:void(0);">' . JText::sprintf('COM_EASYBLOG_OTHER_SUBCATEGORIES', count($category->childs) - $initialLimit) . '</a></span>';
         $nestedLinks .= '<span class="more-subcategories" style="display: none;" data-more-categories>, ' . $moreNestedLinks . '</span>';
     } else {
         EB::accessNestedCategories($category, $nestedLinks, '0', '', 'link', ', ');
     }
     $catIds = array();
     $catIds[] = $category->id;
     EB::accessNestedCategoriesId($category, $catIds);
     $category->nestedLink = $nestedLinks;
     // Get the category model
     $model = EB::model('Category');
     // Get total posts in this category
     $category->cnt = $model->getTotalPostCount($category->id);
     // Get teamblog posts count
     // $teamBlogCount = $model->getTeamBlogCount($category->id);
     $limit = EB::call('Pagination', 'getLimit', array(EBLOG_PAGINATION_CATEGORIES));
     // Get the posts in the category
     $data = $model->getPosts($catIds, $limit);
     // Get the pagination
     $pagination = $model->getPagination();
     // Get allowed categories
     $allowCat = $model->allowAclCategory($category->id);
     // Format the data that we need
     $posts = array();
     // Ensure that the user is really allowed to view the blogs
     if (!empty($data)) {
         $posts = EB::formatter('list', $data);
     }
     // Check isCategorySubscribed
     $isCategorySubscribed = $model->isCategorySubscribedEmail($category->id, $this->my->email);
     // If this category has a different theme, we need to output it differently
     if (!empty($category->theme)) {
         $this->setTheme($category->theme);
     }
     // Set the page title
     $title = EB::getPageTitle(JText::_($category->title));
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Set the return url
     $return = base64_encode($category->getExternalPermalink());
     // Get the pagination
     $pagination = $pagination->getPagesLinks();
     $this->set('allowCat', $allowCat);
     $this->set('category', $category);
     $this->set('sort', $sort);
     $this->set('posts', $posts);
     $this->set('return', $return);
     $this->set('pagination', $pagination);
     // $this->set('teamBlogCount', $teamBlogCount);
     $this->set('privacy', $privacy);
     $this->set('isCategorySubscribed', $isCategorySubscribed);
     parent::display('blogs/categories/item');
 }
Exemplo n.º 3
0
 /**
  * Displays blog posts created by specific users
  *
  * @since	4.0
  * @access	public
  */
 public function listings()
 {
     // Get sorting options
     $sort = $this->input->get('sort', $this->config->get('layout_postorder'), 'cmd');
     $id = $this->input->get('id', 0, 'int');
     // Load the author object
     $author = EB::user($id);
     // Disallow all users from being viewed
     if (!$this->config->get('main_nonblogger_profile') && !EB::isBlogger($author->id) || !$author->id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_INVALID_AUTHOR_ID_PROVIDED'));
     }
     // Get the authors acl
     $acl = EB::acl($author->id);
     // Set meta tags for the author if allowed to
     if ($acl->get('allow_seo')) {
         EB::setMeta($author->id, META_TYPE_BLOGGER, true);
     }
     // Set the breadcrumbs
     if (!EBR::isCurrentActiveMenu('blogger', $author->id) && !EBR::isCurrentActiveMenu('blogger')) {
         $this->setPathway(JText::_('COM_EASYBLOG_BLOGGERS_BREADCRUMB'), EB::_('index.php?option=com_easyblog&view=blogger'));
         $this->setPathway($author->getName());
     }
     // Get the current active menu
     $active = $this->app->getMenu()->getActive();
     // Excluded categories
     $excludeCats = array();
     if (isset($active->params)) {
         $excludeCats = $active->params->get('exclusion');
         // Ensure that this is an array
         if (!is_array($excludeCats) && $excludeCats) {
             $excludeCats = array($excludeCats);
         }
     }
     // Get the blogs model now to retrieve our blog posts
     $model = EB::model('Blog');
     // Get blog posts
     $posts = $model->getBlogsBy('blogger', $author->id, $sort, 0, '', false, false, '', false, false, false, $excludeCats);
     $pagination = $model->getPagination();
     // Format the blogs with our standard formatter
     $posts = EB::formatter('list', $posts);
     // Add canonical urls
     $this->canonical('index.php?option=com_easyblog&view=blogger&layout=listings&id=' . $author->id);
     // Add authors rss links on the header
     if ($this->config->get('main_rss')) {
         if ($this->config->get('main_feedburner') && $this->config->get('main_feedburnerblogger')) {
             $this->doc->addHeadLink(EB::string()->escape($author->getRssLink()), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
         } else {
             // Add rss feed link
             $this->doc->addHeadLink($author->getRSS(), 'alternate', 'rel', array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'));
             $this->doc->addHeadLink($author->getAtom(), 'alternate', 'rel', array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'));
         }
     }
     // Set the title of the page
     $title = EB::getPageTitle($author->getName());
     $this->setPageTitle($title, $pagination, $this->config->get('main_pagetitle_autoappend'));
     // Check if subscribed
     $bloggerModel = EB::model('Blogger');
     $isBloggerSubscribed = $bloggerModel->isBloggerSubscribedEmail($author->id, $this->my->email);
     $return = base64_encode($author->getPermalink());
     $this->set('return', $return);
     $this->set('author', $author);
     $this->set('posts', $posts);
     $this->set('sort', $sort);
     $this->set('isBloggerSubscribed', $isBloggerSubscribed);
     parent::display('authors/item');
 }
Exemplo n.º 4
0
 /**
  * Main display for the blog entry view
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function preview($tpl = null)
 {
     // Get the blog post id from the request
     $id = $this->input->get('uid', '', 'default');
     // Load the blog post now
     $post = EB::post($id);
     // After the post is loaded, set it into the cache
     EB::cache()->insert(array($post));
     // If blog id is not provided correctly, throw a 404 error page
     if (!$id || !$post->id) {
         return JError::raiseError(404, JText::_('COM_EASYBLOG_ENTRY_BLOG_NOT_FOUND'));
     }
     // If the settings requires the user to be logged in, do not allow guests here.
     $post->requiresLoginToRead();
     // Render necessary data on the headers
     $post->renderHeaders();
     // Check if blog is password protected.
     $protected = $this->isProtected($post);
     if ($protected !== false) {
         return;
     }
     // Perform validation checks to see if post is valid
     $exception = $post->checkView();
     if ($exception instanceof EasyBlogException) {
         return JError::raiseError(400, $exception->getMessage());
     }
     // If the viewer is the owner of the blog post, display a proper message
     if ($this->my->id == $post->created_by && !$post->isPublished()) {
         $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_OWNER');
     }
     if (EB::isSiteAdmin() && !$post->isPublished()) {
         $notice = JText::_('COM_EASYBLOG_ENTRY_BLOG_UNPUBLISHED_VISIBLE_TO_ADMIN');
     }
     // Format the post
     $post = EB::formatter('entry', $post);
     // Add bloggers breadcrumbs
     if (!EBR::isCurrentActiveMenu('blogger', $post->author->id) && $this->config->get('layout_blogger_breadcrumb')) {
         $this->setPathway($post->author->getName(), $post->author->getPermalink());
     }
     // Add entry breadcrumb
     if (!EBR::isCurrentActiveMenu('entry', $post->id)) {
         $this->setPathway($post->title, '');
     }
     // Load up the blog model
     $model = EB::model('Blog');
     // Get author's recent posts.
     $recent = $this->getRecentPosts($post);
     // Add canonical URLs for the blog post
     if ($this->config->get('main_canonical_entry')) {
         $this->canonical('index.php?option=com_easyblog&view=entry&id=' . $post->id);
     }
     // Prepare navigation object
     $navigation = $this->prepareNavigation($post);
     // Retrieve Google Adsense codes
     $adsense = EB::adsense()->html($post);
     // If a custom theme is setup for entries in the category, set a different theme
     if (!empty($post->category->theme)) {
         $this->setTheme($post->category->theme);
     }
     // Check if the user subscribed to this post.
     $isBlogSubscribed = $model->isBlogSubscribedEmail($post->id, $this->my->email);
     $theme = EB::template();
     // Prepare related post
     $relatedPosts = array();
     // @TODO: Related posts seems to be missing from the theme file.
     if ($theme->params->get('post_related', true)) {
         $relatedPosts = $model->getRelatedPosts($post->id, $theme->params->get('post_related_limit', 5));
     }
     if (!$post->posttype) {
         $post->posttype = 'standard';
     }
     $this->set('post', $post);
     $this->set('navigation', $navigation);
     $this->set('relatedPosts', $relatedPosts);
     $this->set('recent', $recent);
     $this->set('preview', true);
     $this->set('adsense', $adsense);
     $this->set('isBlogSubscribed', $isBlogSubscribed);
     // Get the menu params associated with this post
     $params = $post->getMenuParams();
     $this->theme->entryParams = $params;
     parent::display('blogs/entry/default');
 }
Exemplo n.º 5
0
 /**
  * Displays blog listings by specific tags on the site
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function tag()
 {
     // Get the tag id
     $id = $this->input->get('id', '', 'default');
     // Add noindex for tags listing by default
     $this->doc->setMetadata('robots', 'noindex,follow');
     // Load the tag object
     $tag = EB::table('Tag');
     $tag->load($id);
     // The tag could be a permalink
     if (!$tag->id) {
         $tag->load($id, true);
     }
     // Set page title
     $this->setPageTitle($tag->getTitle(), '', $this->config->get('main_pagetitle_autoappend'));
     // set meta tags for tags view
     EB::setMeta(META_ID_TAGS, META_TYPE_VIEW, $tag->getTitle() . ' - ' . EB::getPageTitle($this->config->get('main_title')));
     // Set breadcrumb
     if (!EBR::isCurrentActiveMenu('tags')) {
         $this->setPathway(JText::_('COM_EASYBLOG_TAGS_BREADCRUMB'), EBR::_('index.php?option=com_easyblog&view=tags'));
     }
     $this->setPathway($tag->getTitle());
     // Get the blogs model
     $blogModel = EB::model('Blog');
     $tagModel = EB::model('Tags');
     // Get the blog posts now
     $rows = $blogModel->getTaggedBlogs($tag->id, false, '');
     // Get the pagination
     $pagination = $blogModel->getPagination();
     if (is_object($pagination) && method_exists($pagination, 'setAdditionalUrlParam')) {
         $pagination->setAdditionalUrlParam('id', $tag->alias);
     }
     // Get total number of private blog posts
     $privateCount = 0;
     // Get total number of team blog count
     $teamblogCount = 0;
     if ($this->my->guest) {
         $privateCount = $tagModel->getTagPrivateBlogCount($id);
     }
     // Determines if we should get the team blog count
     if (!$this->config->get('main_includeteamblogpost')) {
         $teamblogCount = $tagModel->getTeamBlogCount($id);
     }
     // Format the blog posts using the standard list formatter
     $posts = EB::formatter('list', $rows);
     $return = base64_encode($tag->getPermalink());
     $this->set('return', $return);
     $this->set('tag', $tag);
     $this->set('posts', $posts);
     $this->set('pagination', $pagination);
     $this->set('private', $privateCount);
     $this->set('team', $teamblogCount);
     parent::display('tags/item');
 }