Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
NavigationWidget.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  * id of the root folder for current widget
17  * @var startfolderId
18  */
19  public $startfolderId = 0;
20 
21  /**
22  * id of the root folder for current widget
23  * @var $activeElement
24  */
25  public $activeElement = 0;
26 
27  /**
28  * says,that ALL leaves are opened
29  * @var isSitemap
30  */
31  public $isSitemap = false;
32 
33  /**
34  * defines is widget is in breadcrumb mode. If it is - then only elements from active path will be shown.
35  * @var isBreadcrumb
36  */
37  public $isBreadcrumb = false;
38 
39  /**
40  * this class will be applied to all List elements for current widget
41  * @var cssClass
42  */
43  public $cssClass = 'navigation';
44 
45  /**
46  * if maxLvl is set ans more then 0, then trre will be limited to this level
47  * @var maxLvl
48  */
49  public $maxLvl = 0;
50 
51  /**
52  * language
53  * @var lang
54  */
55  public $lang = '';
56 
57  /**
58  * Contains array with ids of opened folders
59  * @var $activePath
60  */
61  public $activePath = array();
62 
63  /**
64  * @var $hideFirstLevel bool defines if links of first level should be hidden
65  */
66  public $hideFirstLevel = false;
67 
68  /**
69  * @var bool $usePersonalisation defines if personalisation should be performed
70  */
71  public $usePersonalisation = true;
72 
73  /**
74  * @var array $additionalParams defines additional Parameters to request
75  */
76  public $additionalParams = array();
77 
78  /**
79  * @var string $sortby defines the field for sorting
80  */
81  public $sortby = "sortorder:asc";
82 
83 
84  /**
85  * Initializes the widget.
86  *
87  * @return void
88  */
89  public function init()
90  {
91  //die('this is init');
92  }
93 
94  /**
95  * renders view
96  *
97  * @return void
98  */
99  public function run()
100  {
101  $tree = new NavigationTree($this->startfolderId, $this->activeElement, $this->additionalParams, $this->sortby);
102  if ($tree->data) {
103  $this->activePath = $tree->activePath;
104  $this->lang = substr(Yii::app()->language, 0, 2);
105  //$this->registerAssets();
106  $this->render('NavigationWidget', array('tree'=>$tree));
107  }
108  }
109 
110  /**
111  * Registers assets
112  *
113  * @return void
114  */
115  function registerAssets()
116  {
117  $cs = Yii::app()->getClientScript();
118  $baseUrl = Yii::app()->getModule('navigation')->getAssetsUrl();
119 
120  //$cs->registerScriptFile($likeBaseUrl . '/js/navigation.js');
121  $cs->registerCssFile($baseUrl . '/css/navigation.css');
122  }
123 
124  /**
125  * Registers assets
126  *
127  * @return string
128  */
129  function createCacheKey()
130  {
131  $key = 'startfolderId='.$this->startfolderId;
132  $key .= 'activeElement='.$this->activeElement;
133  $key .= 'isSitemap='.$this->isSitemap;
134  $key .= 'cssClass='.$this->cssClass;
135  $key .= 'maxLvl='.$this->maxLvl;
136  $key .= 'lang='.$this->lang;
137  $key .= 'hideFirstLevel='.$this->hideFirstLevel;
138  $key .= 'usePersonalisation='.(int)$this->usePersonalisation;
139  $key .= NavigationTree::getUpdatetimestampByContentId($this->startfolderId).serialize(PersonalisationAttribute::flatListForUser(intval(Yii::app()->user->id)));
140 
141  return md5($key);
142  }
143 }
144 
145 ?>