Exemplo n.º 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);
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $this->loadTemplate();
     $this->validateForm();
     $this->display();
 }
Exemplo n.º 4
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, '');
     $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);
 }
Exemplo n.º 5
0
 /**
  * Set the language
  *
  * @return	void
  * @param	string $value	The (interface-)language, will be used to parse labels.
  */
 public function setLanguage($value)
 {
     // get the possible languages
     $possibleLanguages = FrontendLanguage::getActiveLanguages();
     // validate
     if (!in_array($value, $possibleLanguages)) {
         // only 1 active language?
         if (!SITE_MULTILANGUAGE && count($possibleLanguages) == 1) {
             $this->language = array_shift($possibleLanguages);
         } else {
             // create fake action
             $fakeAction = new FrontendBaseAJAXAction('', '');
             // output error
             $fakeAction->output(FrontendBaseAJAXAction::BAD_REQUEST, null, 'Language not provided.');
         }
     } else {
         $this->language = (string) $value;
     }
     // define constant
     define('FRONTEND_LANGUAGE', $this->language);
     // set the locale (we need this for the labels)
     FrontendLanguage::setLocale($this->language);
 }
Exemplo n.º 6
0
 /**
  * Execute the action
  *
  * @return	void
  */
 public function execute()
 {
     // call parent
     parent::execute();
     // load template
     $this->loadTemplate();
     // validate form
     $this->validateForm();
     // display
     $this->display();
 }