Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
PersonalizedContentWidget Class Reference
Inheritance diagram for PersonalizedContentWidget:
BaseJuiWidget

Public Member Functions

 init ()
 run ()
 loadBaseHref ()
- Public Member Functions inherited from BaseJuiWidget
 getViewFile ($viewName)

Public Attributes

 $folderIds = array()
 $tplString = ''
 $lang = ''
 $offset = 0
 $totalQty = 0
 $perPage = null
 $baseHref = ''
 $usePersonalisation = true
 $gccRequestParams
 $sorting

Detailed Description

Gentics Portal.Node PHP Author & Copyright (c) by Gentics Software GmbH sales.nosp@m.@gen.nosp@m.tics..nosp@m.com http://www.gentics.com Licenses can be found in the LICENSE.txt file in the root-folder of this installation You must not use this software without a valid license agreement.

Widget for viewing navigation tree

Definition at line 13 of file PersonalizedContentWidget.php.

Member Function Documentation

PersonalizedContentWidget::init ( )

Initializes the widget.

Returns
void

Definition at line 73 of file PersonalizedContentWidget.php.

{
//die('this is init');
}
PersonalizedContentWidget::loadBaseHref ( )

Finds out current base href

Returns
void

Definition at line 145 of file PersonalizedContentWidget.php.

Referenced by run().

{
$this->baseHref = Yii::app()->request->pathInfo;
if (!empty(Yii::app()->request->queryString)) {
$getParams = explode('&', Yii::app()->request->queryString);
$params = array();
foreach ($getParams as $param) {
$param = explode('=', $param);
if ($param[0]=='offset') {
continue;
}
$params[] = $param[0].'='.$param[1];
}
if (!empty($params)) {
$this->baseHref .= '?'.implode('&', $params).'&';
} else {
$this->baseHref .= '?';
}
} else {
$this->baseHref .= '?';
}
$this->baseHref = Yii::app()->CreateUrl($this->baseHref);
}
PersonalizedContentWidget::run ( )

renders view

Exceptions
Exception
Returns
void

Definition at line 84 of file PersonalizedContentWidget.php.

References loadBaseHref().

{
$tag = '';
if (!empty($_GET['folderIds']) && !empty($_GET['tag'])) {
preg_match_all('/([0-9]+)/', $_GET['folderIds'], $folderIds);
array_walk(
$folderIds[0],
function(&$item)
{
$item = '10002.'.$item;
}
);
$this->folderIds = $folderIds[0];
$tag = $_GET['tag'];
}
/*
* Get values from widget option for PersonalizedContent
* if it is set otherwise it will be taken from module
*/
$gccRequestParams = null;
if(isset($this->gccRequestParams)){
$gccRequestParams = $this->gccRequestParams;
}
$sorting = null;
if(isset($this->sorting)){
$sorting = $this->sorting;
}
if (!empty($this->folderIds) && !empty($this->tplString)) {
$content = new PersonalizedContent($this->folderIds, $this->usePersonalisation, $tag, $gccRequestParams , $sorting);
} else {
throw new Exception('PersonalizedContentWidget error: folderIds and tplString are required parameters and can`t be blank ');
}
$this->loadBaseHref();
$this->offset = (int)Yii::app()->request->getQuery('offset', 0);
if (!empty($content->data)) {
$this->totalQty = count($content->data);
$this->perPage = (isset($this->perPage) && $this->perPage > 0)? $this->perPage : Yii::app()->getModule('personalizedContent')->perPage;
/* check if offet is in range of results quantity */
if ($this->offset>=$this->totalQty || $this->offset<0) {
$this->offset = 0;
}
/* calculating pagination */
$content->data = array_slice($content->data, $this->offset, $this->perPage);
$this->lang = substr(Yii::app()->language, 0, 2);
$this->render('PersonalizedContentWidget', array('contentList'=>$content->data));
}
}

The documentation for this class was generated from the following file: