Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
LikeModule.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  * Like module class file.
11  */
12 class LikeModule extends CWebModule
13 {
14 
15  /**
16  * @var string
17  */
18  public $defaultController = 'like';
19 
20  /**
21  * Action for liking/unliking content
22  * @var likeAction
23  */
24  public $likeAction;
25 
26  /**
27  * ID of the content that has to be liked/unliked
28  * @var contentId
29  */
30  public $contentId;
31 
32  /**
33  * Defines how many likers should be shown in div on mouseover. Default is 10
34  * @var lastLikesQty
35  */
36  public $lastLikesQty = 10;
37 
38  /**
39  * Defines how many likers should be shown in div on mouseover. Default is 3
40  * @var topLikesQty
41  */
42  public $topLikesQty = 3;
43 
44  /**
45  * @var int the number of seconds in which the cached value will expire. 0 means never expire.
46  */
47  public $cacheTime = 60;
48 
49  private $_assetsUrl;
50  /**
51  * page contained UserLoginWidget
52  *
53  * @return mixed
54  */
55  public function getLoginUrl()
56  {
57  return is_array(Yii::app()->getModule('user')->loginUrl) ? Yii::app()->getModule('user')->loginUrl[0] : Yii::app()->getModule('user')->loginUrl;
58  }
59 
60  /**
61  * Initialize widget. Import like models.
62  *
63  * @return void
64  */
65  public function init()
66  {
67  // import the module-level models and components
68  $this->setImport(
69  array(
70  'like.models.*',
71  )
72  );
73  }
74 
75  /**
76  * Translates a message to the specified language.
77  *
78  * @param string $str message
79  * @param array $params params
80  * @param string $dic dictionary
81  *
82  * @return string
83  */
84  public static function t($str = '', $params = array(), $dic = 'like')
85  {
86  return Yii::t("LikeModule." . $dic, $str, $params);
87  }
88 
89 
90  /**
91  * Returns path to assets for current module
92  *
93  * @return string
94  */
95  public function getAssetsUrl()
96  {
97  if (!$this->_assetsUrl) {
98  $this->_assetsUrl = Yii::app()->assetManager->publish(Yii::getPathOfAlias('like.views.asset'), true);
99  }
100  return $this->_assetsUrl;
101  }
102 }