예제 #1
0
 function display($tmpl = null)
 {
     if (!$this->config->get('main_rss')) {
         return;
     }
     $model = EB::model('Blog');
     $data = $model->getFeaturedBlog();
     $document = JFactory::getDocument();
     $document->link = EBR::_('index.php?option=com_easyblog&view=featured');
     $document->setTitle(JText::_('COM_EASYBLOG_FEEDS_FEATURED_TITLE'));
     $document->setDescription(JText::sprintf('COM_EASYBLOG_FEEDS_FEATURED_DESC', JURI::root()));
     if (empty($data)) {
         return;
     }
     $uri = JURI::getInstance();
     $scheme = $uri->toString(array('scheme'));
     $scheme = str_replace('://', ':', $scheme);
     foreach ($data as $row) {
         $blog = EB::table('Blog');
         $blog->load($row->id);
         $profile = EB::user($row->created_by);
         $created = EB::date($row->created);
         $row->created = $created->toSql();
         if ($this->config->get('main_rss_content') == 'introtext') {
             $row->text = !empty($row->intro) ? $row->intro : $row->content;
             //read more for feed
             $row->text .= '<br /><a href=' . EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id) . '>Read more</a>';
         } else {
             $row->text = $row->intro . $row->content;
         }
         $row->text = EB::videos()->strip($row->text);
         $row->text = EB::adsense()->stripAdsenseCode($row->text);
         $category = EB::table('Category');
         // Get primary category
         $primaryCategory = $blog->getPrimaryCategory();
         $category->load($primaryCategory->id);
         // Assign to feed item
         $title = $this->escape($row->title);
         $title = html_entity_decode($title);
         // load individual item creator class
         $item = new JFeedItem();
         $item->title = $title;
         $item->link = EBR::_('index.php?option=com_easyblog&view=entry&id=' . $row->id);
         $item->description = $row->text;
         // replace the image source to proper format so that feed reader can view the image correctly.
         $item->description = str_replace('src="//', 'src="' . $scheme . '//', $item->description);
         $item->description = str_replace('href="//', 'href="' . $scheme . '//', $item->description);
         $item->date = $row->created;
         $item->category = $category->getTitle();
         $item->author = $profile->getName();
         $item->authorEmail = $this->getRssEmail($profile);
         $document->addItem($item);
     }
 }
예제 #2
0
 /**
  * Retrieve the extracted content of a blog post that can be formatted to Facebook
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function extractPostData(EasyBlogPost &$post)
 {
     // Prepare the result data
     $data = new stdClass();
     // Get the content's source
     $source = $this->config->get('integrations_facebook_source');
     // Get the blog content
     $data->content = $post->getIntro(true);
     // Get the blog's image to be pushed to Facebook
     $data->image = $post->getImage('thumbnail', true, true);
     // var_dump($data->image);exit;
     // If there's no blog image, try to get the image from the content
     if (!$data->image) {
         // lets get full content.
         $fullcontent = $post->getContent('entry');
         $data->image = EB::string()->getImage($fullcontent);
     }
     // If there's still no image, use author's avatar
     if (!$data->image) {
         $author = $post->getAuthor();
         $data->image = $author->getAvatar();
     }
     // if still no image. lets try to get from placeholder.
     if (!$data->image) {
         $data->image = EB::getPlaceholderImage();
     }
     // Format the content so that it respects the length
     $max = $this->config->get('integrations_facebook_blogs_length');
     // Remove adsense codes
     $data->content = EB::adsense()->strip($data->content);
     if ($max && JString::strlen($data->content) > $max) {
         $data->content = JString::substr($data->content, 0, $max) . JText::_('COM_EASYBLOG_ELLIPSES');
     }
     // Get the url to the blog
     $data->url = EBR::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $post->id, false, true);
     // If blog post is being posted from the back end and SH404 is installed, we should just use the raw urls.
     $sh404exists = EBR::isSh404Enabled();
     if ($this->app->isAdmin() && $sh404exists) {
         $data->url = EB::getExternalLink('index.php?option=com_easyblog&view=entry&id=' . $post->id);
     }
     return $data;
 }
예제 #3
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');
 }
예제 #4
0
 public static function formatBlog($data, $loadComments = false, $removeFeaturedImage = true, $loadVideo = true, $frontpage = false, $loadGallery = true)
 {
     // Ensures that we only proceed to format items if there's real data.
     if (!$data) {
         return $data;
     }
     $app = JFactory::getApplication();
     $params = $app->getParams('com_easyblog');
     $model = EB::model('Blog');
     $config = EB::config();
     // Get the tags relation model
     $modelPT = EB::model('PostTag');
     // Initialize a default array set
     $result = array();
     // Some benchmark says that counting it here would be faster
     $total = count($data);
     for ($i = 0; $i < $total; $i++) {
         $row = $data[$i];
         $blog = EB::table('Blog');
         $blog->bind($row);
         // Since the $blog object does not contain 'team_id', we need to set this here.
         if ($raw->source_type == EASYBLOG_POST_SOURCE_TEAM) {
             $blog->team_id = $row->source_id;
         }
         // Since the $blog object does not contain 'category', we need to set this here.
         $blog->category = $row->category;
         $blog->featuredImage = isset($row->featuredImage) ? $row->featuredImage : '';
         // Load the author's profile
         $author = EB::user($blog->created_by);
         // @Assign dynamic properties that must exist everytime formatBlog is called
         // We can't rely on ->author because CB plugins would mess things up.
         $blog->author = $author;
         $blog->blogger = $author;
         $blog->isFeatured = EB::isFeatured('post', $blog->id);
         $blog->category = empty($blog->category) ? JText::_('COM_EASYBLOG_UNCATEGORIZED') : JText::_($blog->category);
         // @task: Detect password protections.
         $requireVerification = false;
         $tmpTitle = $blog->title;
         if ($config->get('main_password_protect', true) && !empty($blog->blogpassword)) {
             $blog->title = JText::sprintf('COM_EASYBLOG_PASSWORD_PROTECTED_BLOG_TITLE', $blog->title);
             $requireVerification = true;
         }
         // @rule: If user already authenticated with the correct password, we will hide the password
         if ($requireVerification && EB::verifyBlogPassword($blog->blogpassword, $blog->id)) {
             $blog->title = $tmpTitle;
             $blog->blogpassword = '';
         }
         // @rule: Initialize all variables
         $blog->videos = array();
         $blog->galleries = array();
         $blog->albums = array();
         $blog->audios = array();
         // @rule: Before anything get's processed we need to format all the microblog posts first.
         if (!empty($blog->posttype)) {
             self::formatMicroblog($blog);
         }
         // @rule: Detect if the content requires a read more link.
         $blog->readmore = EasyBlogHelper::requireReadmore($blog);
         // @rule: Remove any adsense codes from the content.
         $blog->intro = EB::adsense()->strip($blog->intro);
         $blog->content = EB::adsense()->strip($blog->content);
         // Truncate content
         EB::truncateContent($blog, $loadVideo, $frontpage, $loadGallery);
         // Assign tags to the custom properties.
         $blog->tags = $modelPT->getBlogTags($blog->id);
         // Facebook Like integrations
         $facebookLike = EB::facebook()->getLikeHTML($blog);
         $blog->facebookLike = $facebookLike;
         $result[] = $blog;
     }
     return $result;
 }
예제 #5
0
 /**
  * Prepares the content without intro text.
  *
  * @since	4.0
  * @access	public
  * @return
  */
 public function getContentWithoutIntro($type = 'entry', $triggerPlugin = true)
 {
     $index = 'non-intro-' . $type;
     // echo $this->content;exit;
     // The reason we need to cache the content is to avoid javascripts from the blocks being collected multiple times.
     // Until we solve the issue with the javascript in the block handlers being collected more than once, we need to cache this contents.
     if (isset($this->formattedContents[$index]) && $this->formattedContents[$index]) {
         return $this->formattedContents[$index];
     }
     // If this is a listing type, the contents might need to be truncated
     if ($this->doctype == 'ebd') {
         $document = EB::document($this->document);
         $contents = $document->getContentWithoutIntro();
         // we need this so that content plugins can do their jobs.
         $this->intro = '';
         $this->content = $contents;
     } else {
         // Process videos in the intro
         $this->intro = EB::videos()->processVideos($this->intro);
         $this->content = EB::videos()->processVideos($this->content);
         // Process audio files.
         $this->intro = EB::audio()->process($this->intro);
         $this->content = EB::audio()->process($this->content);
         // Process any adsense codes
         $this->intro = EB::adsense()->process($this->intro, $this->created_by);
         $this->content = EB::adsense()->process($this->content, $this->created_by);
         // Process gallery codes in the content
         $this->intro = EB::gallery()->process($this->intro, $this->created_by);
         $this->content = EB::gallery()->process($this->content, $this->created_by);
         // Process album codes in the content
         $this->intro = EB::album()->process($this->intro, $this->created_by);
         $this->content = EB::album()->process($this->content, $this->created_by);
         $textLen = strip_tags($this->content);
         $textLen = str_replace(array(' ', '&nbsp;', "\n", "\t", "\r", "\r\n"), '', $textLen);
         if (empty($textLen)) {
             $this->content = $this->intro;
         } else {
             $this->intro = '';
         }
     }
     // Trigger plugins to prepare the content.
     if ($triggerPlugin) {
         $this->prepareContent();
     }
     // lets get the contents after content plugins processed the content.
     $contents = $this->content;
     // Cache the item so the document will not be rendered more than once.
     $this->formattedContents[$index] = $contents;
     return $this->formattedContents[$index];
 }
예제 #6
0
 /**
  * Normalize the content for stream display purposes
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return
  */
 public function normalizeContent($content)
 {
     $content = EB::videos()->strip($content);
     $content = EB::adsense()->strip($content);
     $content = JString::substr($content, 0, $this->config->get('integrations_jomsocial_blogs_length', 250)) . ' ' . JText::_('COM_EASYBLOG_ELLIPSES');
     $content = strip_tags($content);
     return $content;
 }