Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
PersonalisationModule.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 PersonalisationModule extends CWebModule
13 {
14 
15  public $cacheTime = 0;
16 
17  private $_rule;
18  private $_assetsUrl;
19 
20  /**
21  * Personalisation rule setter
22  *
23  * @param array $config configuration
24  *
25  * @return void
26  */
27  public function setRule($config)
28  {
29  if (is_string($config)) {
30  $config = array('class'=>$config);
31  }
32  $this->_rule = Yii::createComponent($config);
33 
34  }
35 
36  /**
37  * Personalisation rule getter
38  *
39  * @return BasicPersonalisationRule
40  */
41  public function getRule()
42  {
43  return $this->_rule;
44  }
45 
46 
47  /**
48  * Initializes the module.
49  *
50  * @return void
51  */
52  public function init()
53  {
54  $this->setImport(
55  array(
56  'personalisation.components.*',
57  'personalisation.helpers.*',
58  'personalisation.models.*',
59  'personalisation.widgets.*',
60  )
61  );
62  }
63 
64  /**
65  * Publish module assets and return url
66  *
67  * @return string
68  */
69  public function getAssetsUrl()
70  {
71  if (!$this->_assetsUrl) {
72  $this->_assetsUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('personalisation.assets'), true);
73  }
74  return $this->_assetsUrl;
75  }
76 
77  /**
78  * Translates a message to the specified language.
79  *
80  * @param string $str message
81  * @param array $params params
82  * @param string $dic dictionary
83  *
84  * @return string
85  */
86  public static function t($str = '', $params = array(), $dic = 'core')
87  {
88  return Yii::t("PersonalisationModule." . $dic, $str, $params);
89  }
90 
91 }