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); } }
public static function getMedia(&$row, $params, $size = array()) { $media = ''; $type = 'image'; //default to image only. switch ($type) { case 'video': $row->intro = EB::videos()->processVideos($row->intro); $row->content = EB::videos()->processVideos($row->content); break; case 'audio': $row->intro = EasyBlogHelper::getHelper('Audio')->process($row->intro); $row->content = EasyBlogHelper::getHelper('Audio')->process($row->content); break; case 'image': $imgSize = ''; if (!empty($size)) { if (isset($size['width']) && isset($size['height'])) { $width = $size['width'] != 'auto' ? $size['width'] . 'px' : 'auto'; $height = $size['height'] != 'auto' ? $size['height'] . 'px' : 'auto'; $imgSize = ' style="width: ' . $width . ' !important; height:' . $height . ' !important;"'; } } if ($row->getImage()) { $media = $row->getImage('small'); if (!empty($imgSize)) { $media = str_replace('<img', '<img ' . $imgSize . ' ', $media); } } if (empty($media)) { $media = self::getFeaturedImage($row, $params); if (!empty($imgSize)) { $media = str_replace('<img', '<img ' . $imgSize . ' ', $media); } } else { $media = '<img src=" ' . $media . '" class="blog-image" style="margin: 0 5px 5px 0;border: 1px solid #ccc;padding:3px;" ' . $imgSize . '/>'; } break; default: break; } if ($type != 'image') { // remove images. $pattern = '#<img[^>]*>#i'; preg_match($pattern, $row->intro . $row->content, $matches); if (isset($matches[0])) { // After extracting the image, remove that image from the post. $row->intro = str_ireplace($matches[0], '', $row->intro); $row->content = str_ireplace($matches[0], '', $row->intro); } } return $media; }
/** * Legacy method for installations prior to 3.5 * * @deprecated 3.5 * @since 3.5 */ public function processVideos($content, $created_by) { return EB::videos()->processVideos($content); }
/** * Default search view for EasyBlog * * @since 4.0 * @access public * @param string * @return */ public function display($tmpl = null) { // Set the meta tags for search EB::setMeta(META_ID_SEARCH, META_TYPE_SEARCH); // Set the page title $title = EasyBlogHelper::getPageTitle(JText::_('COM_EASYBLOG_SEARCH_PAGE_TITLE')); $this->setPageTitle($title); // Set the view's breadcrumbs $this->setViewBreadcrumb('search'); // Get any existing query $query = $this->input->get('query', '', 'default'); $Itemid = $this->input->get('Itemid', '', 'int'); $posts = array(); $pagination = ''; if (!empty($query)) { // Get the model $model = EB::model('Search'); $result = $model->getData(); $total = count($result); if ($total > 0) { $searchworda = preg_replace('#\\xE3\\x80\\x80#s', ' ', $query); $searchwords = preg_split("/\\s+/u", $searchworda); $needle = $searchwords[0]; $searchwords = array_unique($searchwords); // var_dump($result[0]); // Format the post $posts = EB::formatter('list', $result); // var_dump($posts[0]); // exit; // Remove all unecessary codes from the output foreach ($posts as &$row) { // var_dump($row->content); // Strip videos $row->intro = EB::videos()->strip($row->intro); $row->content = EB::videos()->strip($row->content); // strip gallery $row->intro = EB::gallery()->strip($row->intro); $row->content = EB::gallery()->strip($row->content); // strip jomsocial album $row->intro = EB::album()->strip($row->intro); $row->content = EB::album()->strip($row->content); // strip audio $row->intro = EB::audio()->strip($row->intro); $row->content = EB::audio()->strip($row->content); // Format the content so that we can apply our search highlighting $content = preg_replace('/\\s+/', ' ', strip_tags($row->content)); if (empty($content)) { $content = preg_replace('/\\s+/', ' ', strip_tags($row->intro)); } // We only want a snippet of the content $content = JString::substr(strip_tags($content), 0, 350); $pattern = '#('; $x = 0; foreach ($searchwords as $key => $value) { $pattern .= $x == 0 ? '' : '|'; $pattern .= preg_quote($value, '#'); $x++; } $pattern .= ')#iu'; $row->title = preg_replace($pattern, '<span class="search-highlight">\\0</span>', $row->title); $row->content = preg_replace($pattern, '<span class="search-highlight">\\0</span>', $content); } } $pagination = $model->getPagination(); } $this->set('query', $query); $this->set('posts', $posts); $this->set('pagination', $pagination); $this->set('Itemid', $Itemid); parent::display('search/default'); }
/** * Retrieves the video embed content * * @since 5.0 * @access public * @param string * @return */ public function getVideo() { $link = $this->input->get('link', '', 'default'); // Get the embedded codes for the video $lib = EB::videos(); $embed = $lib->getProviderEmbedCodes($link); return $this->ajax->resolve($embed); }
/** * Truncate's blog post with the respective settings. * * @access public */ public static function truncateContent(&$row, $loadVideo = false, $frontpage = false, $loadGallery = true) { $config = EasyBlogHelper::getConfig(); $truncate = true; $maxCharacter = $config->get('layout_maxlengthasintrotext', 150); // @task: Maximum characters should not be lesser than 0 $maxCharacter = $maxCharacter <= 0 ? 150 : $maxCharacter; // Check if truncation is really necessary because if introtext is already present, just use it. if (!empty($row->intro) && !empty($row->content)) { // We do not want the script to truncate anything since we'll just be using the intro part. $truncate = false; } // @task: If truncation is not necessary or the intro text is empty, let's just use the content. if (!$config->get('layout_blogasintrotext') || !$truncate) { //here we process the video and get the links. if ($loadVideo) { $row->intro = EB::videos()->processVideos($row->intro); $row->content = EB::videos()->processVideos($row->content); } // @rule: Process audio files. $row->intro = EasyBlogHelper::getHelper('Audio')->process($row->intro); $row->content = EasyBlogHelper::getHelper('Audio')->process($row->content); if (($config->get('main_image_gallery_frontpage') && $frontpage || !$frontpage) && $loadGallery) { $row->intro = EasyBlogHelper::getHelper('Gallery')->process($row->intro, $row->created_by); $row->content = EasyBlogHelper::getHelper('Gallery')->process($row->content, $row->created_by); // Process jomsocial albums $row->intro = EasyBlogHelper::getHelper('Album')->process($row->intro, $row->created_by); $row->content = EasyBlogHelper::getHelper('Album')->process($row->content, $row->created_by); } // @task: Strip out video tags $row->intro = EB::videos()->strip($row->intro); $row->content = EB::videos()->strip($row->content); // @task: Strip out audio tags $row->intro = EasyBlogHelper::getHelper('Audio')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Audio')->strip($row->content); // @task: Strip out gallery tags $row->intro = EasyBlogHelper::getHelper('Gallery')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Gallery')->strip($row->content); // @task: Strip out album tags $row->intro = EasyBlogHelper::getHelper('Album')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Album')->strip($row->content); // @rule: Once the gallery is already processed above, we will need to strip out the gallery contents since it may contain some unwanted codes // @2.0: <input class="easyblog-gallery" // @3.5: {ebgallery:'name'} $row->intro = EasyBlogHelper::removeGallery($row->intro); $row->content = EasyBlogHelper::removeGallery($row->content); if ($frontpage && $config->get('main_truncate_image_position') == 'hidden') { // Need to remove images, and videos. $row->intro = self::strip_only($row->intro, '<img>'); $row->content = self::strip_only($row->content, '<img>'); } $row->text = empty($row->intro) ? $row->content : $row->intro; return $row; } // @rule: If this is a normal blog post, we match them manually if (isset($row->posttype) && (!$row->posttype || empty($row->posttype))) { // @rule: Try to match all videos from the blog post first. $row->videos = EB::videos()->getHTMLArray($row->intro . $row->content); // @rule: $row->galleries = EasyBlogHelper::getHelper('Gallery')->getHTMLArray($row->intro . $row->content); // @rule: $row->audios = EasyBlogHelper::getHelper('Audio')->getHTMLArray($row->intro . $row->content); // @rule: $row->albums = EasyBlogHelper::getHelper('Album')->getHTMLArray($row->intro . $row->content); } // @task: Here we need to strip out all items that are embedded since they are now not required because they'll be truncated. // @task: Strip out video tags $row->intro = EB::videos()->strip($row->intro); $row->content = EB::videos()->strip($row->content); // @task: Strip out audio tags $row->intro = EasyBlogHelper::getHelper('Audio')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Audio')->strip($row->content); // @task: Strip out gallery tags $row->intro = EasyBlogHelper::getHelper('Gallery')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Gallery')->strip($row->content); // @task: Strip out album tags $row->intro = EasyBlogHelper::getHelper('Album')->strip($row->intro); $row->content = EasyBlogHelper::getHelper('Album')->strip($row->content); // This is the combined content of the intro and the fulltext $content = $row->intro . $row->content; //var_dump($row );exit; if ($config->get('main_truncate_ellipses') && isset($row->readmore) && $row->readmore) { $row->text .= JText::_('COM_EASYBLOG_ELLIPSES'); } if (isset($row->posttype) && (!$row->posttype || empty($row->posttype))) { // @task: Determine the position of media items that should be included in the content. $embedHTML = ''; $embedVideoHTML = ''; $imgHTML = ''; if (!empty($row->galleries)) { $embedHTML .= implode('', $row->galleries); } if (!empty($row->audios)) { $embedHTML .= implode('', $row->audios); } if (!empty($row->videos)) { $embedVideoHTML = implode('', $row->videos); } if (!empty($row->albums)) { $embedHTML .= implode('', $row->albums); } // images if ($config->get('main_truncate_image_position') == 'top' && !empty($imgHTML)) { $row->text = $imgHTML . $row->text; } else { if ($config->get('main_truncate_image_position') == 'bottom' && !empty($imgHTML)) { $row->text = $row->text . $imgHTML; } } // videos if ($config->get('main_truncate_video_position') == 'top' && !empty($embedVideoHTML)) { $row->text = $embedVideoHTML . '<br />' . $row->text; } else { if ($config->get('main_truncate_video_position') == 'bottom' && !empty($embedVideoHTML)) { $row->text = $row->text . '<br />' . $embedVideoHTML; } } // @task: Prepend the other media items in the start of the blog posts. if ($config->get('main_truncate_media_position') == 'top' && !empty($embedHTML)) { $row->text = $embedHTML . $row->text; } else { if ($config->get('main_truncate_media_position') == 'bottom' && !empty($embedHTML)) { $row->text .= $embedHTML; } } } return $row; }
public function map(&$blog) { parent::map($blog); // @task: Process blog triggers here. // @rule: Process videos $blog->intro = EB::videos()->processVideos($blog->intro); $blog->content = EB::videos()->processVideos($blog->content); $blogger = EB::user($blog->created_by); // Assign custom variables $blog->author = $blogger; $themes = EB::template(); $themes->set('blog', $blog); $themes->set('blogger', $blogger); $content = $themes->output('site/blogs/entry/weever'); $this->set('html', $content); return $this; }
/** * 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(' ', ' ', "\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]; }
/** * Remove known dirty codes from the content * * @since 4.0 * @access public * @param string * @return */ public function stripCodes(EasyBlogPost &$post) { // Remove video codes EB::videos()->stripCodes($post); // Remove audio codes EB::audio()->stripCodes($post); // Remove gallery codes EB::gallery()->stripCodes($post); // Remove album codes EB::album()->stripCodes($post); }
/** * Retrieves the video links from the content and remove the links from the content * * @since 5.0 * @access public * @param string * @return */ public static function getAndRemoveVideo($content) { $lib = EB::videos(); // Retrieve all videos from the content $videos = $lib->getVideoObjects($content, true); // Strip out all video codes from the content $content = $lib->strip($content); $obj = new stdClass(); $obj->content = $content; $obj->videos = $videos; return $obj; }
/** * 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; }
/** * Process message **/ function processMessage($message, $blog) { $config = EasyBlogHelper::getConfig(); $message = empty($message) ? $config->get('main_linkedin_message') : $message; $search = array(); $replace = array(); //replace title if (preg_match_all("/.*?(\\{title\\})/is", $message, $matches)) { $search[] = '{title}'; $replace[] = $blog->title; } //replace title if (preg_match_all("/.*?(\\{introtext\\})/is", $message, $matches)) { $introtext = empty($blog->intro) ? '' : strip_tags($blog->intro); $introtext = EB::videos()->strip($introtext); $search[] = '{introtext}'; $replace[] = $introtext; } //replace category if (preg_match_all("/.*?(\\{category\\})/is", $message, $matches)) { $category = EB::table('Category'); $category->load($blog->category_id); $search[] = '{category}'; $replace[] = $category->title; } //replace link if (preg_match_all("/.*?(\\{link\\})/is", $message, $matches)) { $link = EasyBlogRouter::getRoutedURL('index.php?option=com_easyblog&view=entry&id=' . $blog->id, false, true); $search[] = '{link}'; $replace[] = $link; } $message = JString::str_ireplace($search, $replace, $message); return $message; }
/** * Retrieves video from blog post content * * @since 4.0 * @access public * @param string * @return */ public function getVideo() { // Retrieve video that can be used for pinterest $video = ''; $videoObj = EB::videos()->getVideoObjects($this->post->content); if ($videoObj && !empty($videoObj)) { $video = $videoObj[0]->video; } return $video; }
private function getVideo($content) { $videos = EB::videos()->getVideoObjects($content); if (isset($videos[0])) { return $videos[0]; } return false; }