Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
AdvancedSearchWidget.php
1 <?php
2  /**
3  * Gentics Portal.Node PHP
4  * Author & Copyright (c) by Gentics Software GmbH
5  * sales@gentics.com
6  * http://www.gentics.com
7  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8  * You must not use this software without a valid license agreement.
9  *
10  * Comment controller class file.
11  *
12  * @author Vitalii Kovalchuk <vitaly.kovalchuk@oberig.com>
13  */
15 {
16 
17  /**
18  * @var string $useAutosuggest defines if Autosuggestion should be used for current widget
19  */
20  public $useAutosuggest = true;
21 
22  /**
23  * @var string $uniqClassName system generated unique css ckass name
24  */
25  public $uniqClassName;
26 
27  /**
28  * @var array $config contains required configuration for AdvancedSearchForm
29  */
30  public $config = array();
31 
32  /**
33  * @var string $landingPage defines action for search form
34  */
35  public $landingPage = '';
36 
37  /**
38  * Overrided autosuggest url
39  *
40  * @public string
41  **/
43 
44  /**
45  * Default called method
46  *
47  * @return void
48  */
49  public function run()
50  {
51  $lang = Yii::app()->language;
52  $this->uniqClassName = uniqid('simpleSearch');
53 
54  /* if we did not configure landing page as widget param then take it from settings */
55  if ($this->landingPage == '') {
56  $this->landingPage = SearchModule::getLandingPage($lang);
57  }
58  $this->_loadConfig();
59 
60  $this->render('AdvancedSearchWidget', array('landingPage' => $this->landingPage));
61  }
62 
63  /**
64  * Loads configuration from module to class attribute
65  *
66  * @return void
67  */
68  private function _loadConfig()
69  {
70  $this->config['mimetype'] = Yii::app()->getModule('search')->mimetype;
71  $this->config['whereToSearch'] = Yii::app()->getModule('search')->whereToSearch;
72  $this->config['searchType'] = Yii::app()->getModule('search')->searchType;
73  $this->config['urlLimiter'] = Yii::app()->getModule('search')->urlLimiter;
74 
75  foreach ($this->config as $type=>$config) {
76  if (isset($config['options'])) {
77  foreach ($config['options'] as $option=>$value) {
78  $this->config[$type]['options'][$option] = SearchModule::t($value);
79  }
80  }
81  }
82  }
83 
84  public function getSecureAutosuggestUrl()
85  {
86  if(empty($this->autosuggestUrl)) {
87  return '';
88  }
89  $sm = Yii::app()->securityManager;
90  return $sm->hashData($this->autosuggestUrl);
91  }
92 }