예제 #1
0
 /**
  * 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');
 }
예제 #2
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];
 }
예제 #3
0
 /**
  * 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);
 }
예제 #4
0
 /**
  * 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);
 }