Пример #1
0
 /**
  * show search results
  * 
  * @param int $page show entries on submitted page
  */
 function search_action($page = null)
 {
     ForumPerm::check('search', $this->getId());
     $nav = Navigation::getItem('course/forum2');
     $nav->setImage(Icon::create('forum', 'info'));
     Navigation::activateItem('course/forum2/index');
     // set page to which we shall jump
     if ($page) {
         ForumHelpers::setPage($page);
     }
     $this->section = 'search';
     $this->topic_id = $this->getId();
     $this->show_full_path = true;
     // parse filter-options
     foreach (array('search_title', 'search_content', 'search_author') as $option) {
         $this->options[$option] = Request::option($option);
     }
     $this->searchfor = Request::get('searchfor');
     if (strlen($this->searchfor) < 3) {
         $this->flash['messages'] = array('error' => _('Ihr Suchbegriff muss mindestens 3 Zeichen lang sein und darf nur Buchstaben und Zahlen enthalten!'));
     } else {
         // get search-results
         $list = ForumEntry::getSearchResults($this->getId(), $this->searchfor, $this->options);
         $this->postings = $list['list'];
         $this->number_of_entries = $list['count'];
         $this->highlight = $list['highlight'];
         if (empty($this->postings)) {
             $this->flash['messages'] = array('info' => _('Es wurden keine Beiträge gefunden, die zu Ihren Suchkriterien passen!'));
         }
     }
     // set default layout
     $layout = $GLOBALS['template_factory']->open('layouts/base');
     $this->set_layout($layout);
     // exploit the visitdate for this view
     $this->visitdate = ForumVisit::getLastVisit($this->getId());
     $this->render_action('index');
 }