Exemple #1
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $searchTerm = SpoonFilter::getPostValue('term', null, '');
     $term = SPOON_CHARSET == 'utf-8' ? SpoonFilter::htmlspecialchars($searchTerm) : SpoonFilter::htmlentities($searchTerm);
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     }
     // previous search result
     $previousTerm = SpoonSession::exists('searchTerm') ? SpoonSession::get('searchTerm') : '';
     SpoonSession::set('searchTerm', '');
     // save this term?
     if ($previousTerm != $term) {
         // format data
         $this->statistics = array();
         $this->statistics['term'] = $term;
         $this->statistics['language'] = FRONTEND_LANGUAGE;
         $this->statistics['time'] = FrontendModel::getUTCDate();
         $this->statistics['data'] = serialize(array('server' => $_SERVER));
         $this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
         // save data
         FrontendSearchModel::save($this->statistics);
     }
     // save current search term in cookie
     SpoonSession::set('searchTerm', $term);
     // output
     $this->output(self::OK);
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $this->loadTemplate();
     $this->validateForm();
     $this->display();
 }
Exemple #3
0
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $term = SpoonFilter::getGetValue('term', null, '');
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     }
     // previous search result
     $previousTerm = SpoonSession::exists('searchTerm') ? SpoonSession::get('searchTerm') : '';
     SpoonSession::set('searchTerm', '');
     // save this term?
     if ($previousTerm != $term) {
         // format data
         $this->statistics = array();
         $this->statistics['term'] = $term;
         $this->statistics['language'] = FRONTEND_LANGUAGE;
         $this->statistics['time'] = FrontendModel::getUTCDate();
         $this->statistics['data'] = serialize(array('server' => $_SERVER));
         $this->statistics['num_results'] = FrontendSearchModel::getTotal($term);
         // save data
         FrontendSearchModel::save($this->statistics);
     }
     // save current search term in cookie
     SpoonSession::set('searchTerm', $term);
     // output
     $this->output(self::OK);
 }
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $term = SpoonFilter::getGetValue('term', null, '');
     $limit = (int) FrontendModel::getModuleSetting('search', 'autocomplete_num_items', 10);
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     }
     // get matches
     $matches = FrontendSearchModel::getStartsWith($term, FRONTEND_LANGUAGE, $limit);
     // get search url
     $url = FrontendNavigation::getURLForBlock('search');
     // loop items and set search url
     foreach ($matches as &$match) {
         $match['url'] = $url . '?form=search&q=' . $match['term'];
     }
     // output
     $this->output(self::OK, $matches);
 }
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent
     parent::execute();
     // load template
     $this->loadTemplate();
     // validate form
     $this->validateForm();
     // display
     $this->display();
 }