Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
MostVisitedPages Class Reference

Public Member Functions

 run ()
 render ($mostvisited)

Public Attributes

 $token
 $piwikServerURL
 $sites
 $count
 $cacheTime

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.

Last visited pages

Definition at line 14 of file MostVisitedPages.php.

Member Function Documentation

MostVisitedPages::run ( )

Find pages, display

Definition at line 56 of file MostVisitedPages.php.

{
if (empty($this->count))
$this->count = Yii::app()->getModule('piwik')->count;
if (empty($this->token))
$this->token = Yii::app()->getModule('piwik')->token;
if (empty($this->piwikServerURL))
$this->piwikServerURL = Yii::app()->getModule('piwik')->piwikServerURL;
if (empty($this->sites))
$this->sites = Yii::app()->getModule('piwik')->sites;
if (empty($this->cacheTime))
$this->cacheTime = Yii::app()->getModule('piwik')->cacheTime;
$mostvisited = array();
$check = Yii::app()->cache->get(md5($this->sites ."_popular"));
if (!empty($check)){
$mostvisited = $check;
} else {
$url = $this->piwikServerURL;
$url .= "/?module=API&method=Actions.getPageUrls";
$url .= "&idSite=".$this->sites."&period=month&date=yesterday";
$url .= "&format=PHP&filter_limit=".$this->count;
$url .= "&filter_sort_column=nb_hits&filter_sort_order=desc";
$url .= "&token_auth=".$this->token;
$fetched = file_get_contents($url);
$content = unserialize($fetched);
if ($this->sites == "all" || strstr($this->sites,',')){
foreach($content as $mysiteid => $mysite){
foreach($mysite as $myline){
$mostvisited[] = $this->calcresult($myline);
}
$key = md5($mysiteid ."_popular");
Yii::app()->cache->set($key, $mostvisited, $this->cacheTime);
}
$key = md5($this->sites ."_popular");
Yii::app()->cache->set($key, $mostvisited, $this->cacheTime);
} else {
foreach($content as $myline){
$mostvisited[] = $this->calcresult($myline);
}
$key = md5($this->sites ."_popular");
Yii::app()->cache->set($key, $mostvisited, $this->cacheTime);
}
}
$this->render($mostvisited);
}

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