Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
SearchModule.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  */
11 
12 class SearchModule extends CWebModule
13 {
14  /**
15  * @var int the number of seconds in which the cached value will expire. 0 means never expire.
16  */
17  public $cacheTime = 360;
18 
19  /**
20  * @var string default landing page(page with SearchResultWidget)
21  */
22  public $defaultLandingPage;
23 
24  /**
25  * @arrays array landing pages for every language(pages with SearchResultWidget in different languages)
26  */
27  public $landingPages;
28 
29  /**
30  * @var string personalisation delimiter. Used to split personalisation string after search request
31  */
32  public $personalisationDelimiter;
33 
34  /**
35  * @var string personalisation delimiter. Used to split personalisation string after search request
36  */
37  public $perPage;
38 
39  /**
40  * @var array configuration for mimetypes
41  */
42  public $mimetype;
43 
44  /**
45  * @var array configuration for where to search
46  */
47  public $whereToSearch;
48 
49  /**
50  * @var array configuration for search type
51  */
52  public $searchType;
53 
54  /**
55  * @var string string that always will be added to search requests
56  */
57  public $staticString = '';
58 
59  /**
60  * @var array configuration for url filtering
61  */
62  public $urlLimiter;
63 
64  /**
65  * gets repository API
66  *
67  * @return void
68  */
69  public function getApi()
70  {
71  return Yii::app()->repositoryApi;
72  }
73 
74  /**
75  * gets value for current sep up of search landing page
76  *
77  * @param string $lang - defines required language
78  *
79  * @return string
80  */
81  public static function getLandingPage($lang)
82  {
83  $dbSetting = Yii::app()->getModule('settings')->get('landingPage_'.$lang);
84  if (!empty($dbSetting)) {
85  /* check if we have landing page for current language set up in DB */
86  $landingPage = $dbSetting;
87  } else {
88  $dbSetting = Yii::app()->getModule('settings')->get('defaultLandingPage');
89  if (!empty($dbSetting)) {
90  /* check if we have default landing page for set up in DB */
91  $landingPage = $dbSetting;
92  } else if (isset(Yii::app()->getModule('search')->landingPages[$lang]) && Yii::app()->getModule('search')->landingPages[$lang] != '') {
93  /* check if we have landing page for current language sep up in config */
94  $landingPage = Yii::app()->getModule('search')->landingPages[$lang];
95  } else if (isset(Yii::app()->getModule('search')->defaultLandingPage) && Yii::app()->getModule('search')->defaultLandingPage != '') {
96  /* check if we have default landing page sep up in config */
97  $landingPage = Yii::app()->getModule('search')->defaultLandingPage;
98  } else {
99  /* take current page url as landing page */
100  $landingPage = '';
101  }
102  }
103 
104  return $landingPage;
105  }
106 
107  /**
108  * Import dependent classes
109  *
110  * @return void
111  */
112  public function init()
113  {
114  // import the module-level components
115  $this->setImport(
116  array(
117  'search.components.*',
118  )
119  );
120  }
121 
122  /**
123  * Translates a message to the specified language.
124  *
125  * @param string $str message
126  * @param array $params params
127  * @param string $dic dictionary
128  *
129  * @return string
130  */
131  public static function t($str = '', $params = array(), $dic = 'search')
132  {
133  return Yii::t("SearchModule." . $dic, $str, $params);
134  }
135 }