/** * 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'); }
/** * Remove known dirty codes from the content * * @since 4.0 * @access public * @param string * @return */ public function stripCodes(EasyBlogTableBlog &$blog) { // Remove video codes EB::videos()->stripCodes($blog); // Remove audio codes EB::audio()->stripCodes($blog); // Remove gallery codes EB::gallery()->stripCodes($blog); // Remove album codes EB::album()->stripCodes($blog); }
/** * Allows uploading of an audio file to the server temporarily. * * @since 4.0 * @access public * @param string * @return */ public function uploadAudio() { // Check for request forgeries // EB::checkToken(); // Ensure that the user is logged in EB::requireLogin(); // Ensure that the user really has permissions to create blog posts on the site if (!$this->acl->get('add_entry')) { EB::exception('COM_EASYBLOG_NO_PERMISSION_TO_CREATE_BLOG', EASYBLOG_MSG_ERROR)->setGlobal(); return $this->ajax->reject(); } $file = $this->input->files->get('file'); if (!isset($file['tmp_name']) || empty($file['tmp_name'])) { echo JText::_("COM_EASYBLOG_COMPOSER_UNABLE_TO_LOCATE_TEMPORARY_FILE"); exit; } // Upload this file into their respective images folder. $mm = EB::mediamanager(); $path = $mm->getAbsolutePath('/', 'user:'******'/', 'user:'******'user:' . $this->my->id); // Get the audio player which needs to be embedded on the composer. $player = EB::audio()->getPlayer($result->url); $obj = new stdClass(); $obj->title = $result->title; $obj->player = $player; $obj->file = $result->url; $obj->path = $result->path; echo json_encode($obj); exit; }
/** * 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); }
private function prepareContent(&$content) { // See if there's any audio files to process. $audios = EB::audio()->getItems($content); // Get videos attached in the content $videos = $this->getVideos($content); $video = false; if (isset($videos[0])) { $video = $videos[0]; } // Remove videos from the source $content = EB::videos()->strip($content); // Remove audios from the content $content = EB::audio()->strip($content); $this->set('video', $video); $this->set('audios', $audios); $this->set('date', $date); $this->set('permalink', $url); $this->set('blog', $blog); $this->set('actor', $item->actor); $this->set('content', $content); $catUrl = EBR::_('index.php?option=com_easyblog&view=categories&layout=listings&id=' . $blog->category_id, true, null, false, true); $this->set('categorypermalink', $catUrl); $item->title = parent::display('streams/' . $item->verb . '.title'); $item->content = parent::display('streams/' . $item->verb . '.content'); }