Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
TagcloudWidget.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  * Widget for viewing navigation tree
11  */
12 
14 {
15  /**
16  * @var $folderIds array contains folder IDs of content to show
17  */
18  public $folderIds = array();
19 
20  /**
21  * language
22  * @var lang
23  */
24  public $lang = '';
25 
26  /**
27  * @var bool $usePersonalisation defines if personalisation should be performed
28  */
29  public $usePersonalisation = true;
30 
31  /**
32  * @var CMS pages with personalizedOverview widget
33  */
34  public $overviewPage = '';
35 
36  /**
37  * @var string tagsSeparator
38  */
39  public $tagsSeparator = ', ';
40 
41  /**
42  * @var string tagstyles
43  */
44  public $tagstyles = array();
45 
46  /**
47  * @var integer the limit of tags number
48  */
49  public $limit = 10;
50  /**
51  * Initializes the widget.
52  *
53  * @return void
54  */
55  public function init()
56  {
57  //die('this is init');
58  }
59 
60  /**
61  * renders view
62  *
63  * @throws Exception
64  * @return void
65  */
66  public function run()
67  {
68  if (!empty($this->folderIds)) {
69  $content = new TagcloudApi();
70  $content->folderIds = $this->folderIds;
71  $content->usePersonalisation = $this->usePersonalisation;
72  $content->lang = substr(Yii::app()->language, 0, 2);
73  $content->tagstyles = !empty($this->tagstyles) ? $this->tagstyles : Yii::app()->getModule('tagcloud')->tagstyles;
74  $content->tagsSeparator = !empty($this->tagsSeparator) ? $this->tagsSeparator : Yii::app()->getModule('tagcloud')->tagsSeparator;
75 
76  if (!empty($this->overviewPage)) {
77  $content->overviewPage = $this->overviewPage;
78 
79  } else if (!empty(Yii::app()->getModule('tagcloud')->overviewPages[$this->lang])) {
80  $content->overviewPage = Yii::app()->getModule('tagcloud')->overviewPages[$this->lang];
81 
82  } else {
83  $content->overviewPage = Yii::app()->getModule('tagcloud')->defaultOverviewPage;
84  }
85 
86  if ($content->run($this->limit) && !empty($content->tags)) {
87 
88  $this->render('TagcloudWidget', array('content'=>$content));
89  }
90 
91  } else {
92  throw new Exception('TagcloudWidget error: folderIds is required parameters and can`t be blank ');
93  }
94  }
95 
96 }