添加 Piwik 到代码库中。
+YUCHENG HU+ git-svn-id: https://svn.code.sf.net/p/hawebs/svn@448 a2543c7e-f6e9-4f8a-8bff-1ffc34733512
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: API.php 1832 2010-02-10 08:14:15Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitTime
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_VisitTime
|
||||
*/
|
||||
class Piwik_VisitTime_API
|
||||
{
|
||||
static private $instance = null;
|
||||
static public function getInstance()
|
||||
{
|
||||
if (self::$instance == null)
|
||||
{
|
||||
$c = __CLASS__;
|
||||
self::$instance = new $c();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
protected function getDataTable($name, $idSite, $period, $date )
|
||||
{
|
||||
Piwik::checkUserHasViewAccess( $idSite );
|
||||
$archive = Piwik_Archive::build($idSite, $period, $date );
|
||||
$dataTable = $archive->getDataTable($name);
|
||||
$dataTable->filter('Sort', array('label', 'asc', true));
|
||||
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getTimeLabel'));
|
||||
$dataTable->queueFilter('ReplaceColumnNames');
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
public function getVisitInformationPerLocalTime( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getDataTable('VisitTime_localTime', $idSite, $period, $date );
|
||||
}
|
||||
|
||||
public function getVisitInformationPerServerTime( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getDataTable('VisitTime_serverTime', $idSite, $period, $date );
|
||||
}
|
||||
}
|
||||
|
||||
function Piwik_getTimeLabel($label)
|
||||
{
|
||||
return sprintf(Piwik_Translate('VisitTime_NHour'), $label);
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: Controller.php 2308 2010-06-16 13:47:41Z matt $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitTime
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_VisitTime
|
||||
*/
|
||||
class Piwik_VisitTime_Controller extends Piwik_Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$view = Piwik_View::factory('index');
|
||||
$view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true);
|
||||
$view->dataTableVisitInformationPerServerTime = $this->getVisitInformationPerServerTime(true);
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
public function getVisitInformationPerServerTime( $fetch = false)
|
||||
{
|
||||
$view = Piwik_ViewDataTable::factory( 'graphVerticalBar');
|
||||
$view->init( $this->pluginName, __FUNCTION__, "VisitTime.getVisitInformationPerServerTime" );
|
||||
|
||||
$view->setColumnsToDisplay( array('label','nb_visits') );
|
||||
$view->setSortedColumn( 'label', 'asc' );
|
||||
$view->setColumnTranslation('label', Piwik_Translate('VisitTime_ColumnServerTime'));
|
||||
$view->setLimit( 24 );
|
||||
$view->setGraphLimit( 24 );
|
||||
$view->disableSearchBox();
|
||||
$view->disableExcludeLowPopulation();
|
||||
$view->disableOffsetInformation();
|
||||
$view->enableShowGoals();
|
||||
|
||||
return $this->renderView($view, $fetch);
|
||||
}
|
||||
|
||||
public function getVisitInformationPerLocalTime( $fetch = false)
|
||||
{
|
||||
$view = Piwik_ViewDataTable::factory( 'graphVerticalBar');
|
||||
$view->init( $this->pluginName, __FUNCTION__, "VisitTime.getVisitInformationPerLocalTime" );
|
||||
$view->setColumnTranslation('label', Piwik_Translate('VisitTime_ColumnLocalTime'));
|
||||
$view->setColumnsToDisplay( array('label','nb_visits') );
|
||||
$view->setSortedColumn( 'label', 'asc' );
|
||||
$view->setLimit( 24 );
|
||||
$view->setGraphLimit( 24 );
|
||||
$view->disableSearchBox();
|
||||
$view->disableExcludeLowPopulation();
|
||||
$view->disableOffsetInformation();
|
||||
|
||||
return $this->renderView($view, $fetch);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: VisitTime.php 2321 2010-06-18 10:46:38Z matt $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitTime
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_VisitTime
|
||||
*/
|
||||
class Piwik_VisitTime extends Piwik_Plugin
|
||||
{
|
||||
public function getInformation()
|
||||
{
|
||||
$info = array(
|
||||
'description' => Piwik_Translate('VisitTime_PluginDescription'),
|
||||
'author' => 'Piwik',
|
||||
'author_homepage' => 'http://piwik.org/',
|
||||
'version' => Piwik_Version::VERSION,
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
|
||||
function getListHooksRegistered()
|
||||
{
|
||||
$hooks = array(
|
||||
'ArchiveProcessing_Day.compute' => 'archiveDay',
|
||||
'ArchiveProcessing_Period.compute' => 'archivePeriod',
|
||||
'WidgetsList.add' => 'addWidgets',
|
||||
'Menu.add' => 'addMenu',
|
||||
'Goals.getAvailableGoalSegments' => 'addGoalSegments',
|
||||
);
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
function addWidgets()
|
||||
{
|
||||
Piwik_AddWidget( 'VisitTime_SubmenuTimes', 'VisitTime_WidgetLocalTime', 'VisitTime', 'getVisitInformationPerLocalTime');
|
||||
Piwik_AddWidget( 'VisitTime_SubmenuTimes', 'VisitTime_WidgetServerTime', 'VisitTime', 'getVisitInformationPerServerTime');
|
||||
}
|
||||
|
||||
function addMenu()
|
||||
{
|
||||
Piwik_AddMenu('General_Visitors', 'VisitTime_SubmenuTimes', array('module' => 'VisitTime', 'action' => 'index'));
|
||||
}
|
||||
|
||||
function addGoalSegments( $notification )
|
||||
{
|
||||
$segments =& $notification->getNotificationObject();
|
||||
$segments[] = array(
|
||||
'group' => Piwik_Translate('VisitTime_ColumnServerTime'),
|
||||
'name' => Piwik_Translate('VisitTime_ColumnServerTime'),
|
||||
'module' => 'VisitTime',
|
||||
'action' => 'getVisitInformationPerServerTime',
|
||||
);
|
||||
}
|
||||
|
||||
function archivePeriod( $notification )
|
||||
{
|
||||
$archiveProcessing = $notification->getNotificationObject();
|
||||
$dataTableToSum = array(
|
||||
'VisitTime_localTime',
|
||||
'VisitTime_serverTime',
|
||||
);
|
||||
$archiveProcessing->archiveDataTable($dataTableToSum);
|
||||
}
|
||||
|
||||
public function archiveDay( $notification )
|
||||
{
|
||||
$archiveProcessing = $notification->getNotificationObject();
|
||||
$this->archiveDayAggregateVisits($archiveProcessing);
|
||||
$this->archiveDayAggregateGoals($archiveProcessing);
|
||||
$this->archiveDayRecordInDatabase($archiveProcessing);
|
||||
}
|
||||
|
||||
protected function archiveDayAggregateVisits($archiveProcessing)
|
||||
{
|
||||
$labelSQL = "HOUR(visitor_localtime)";
|
||||
$this->interestByLocalTime = $archiveProcessing->getArrayInterestForLabel($labelSQL);
|
||||
|
||||
$labelSQL = "HOUR(visit_last_action_time)";
|
||||
$this->interestByServerTime = $archiveProcessing->getArrayInterestForLabel($labelSQL);
|
||||
$this->interestByServerTime = $this->convertServerTimeToLocalTimezone($this->interestByServerTime, $archiveProcessing);
|
||||
}
|
||||
|
||||
protected function convertServerTimeToLocalTimezone($interestByServerTime, $archiveProcessing)
|
||||
{
|
||||
$date = Piwik_Date::factory($archiveProcessing->getStartDatetimeUTC())->toString();
|
||||
$timezone = $archiveProcessing->site->getTimezone();
|
||||
$visitsByHourTz = array();
|
||||
foreach($interestByServerTime as $hour => $stats)
|
||||
{
|
||||
$datetime = $date . ' '.$hour.':00:00';
|
||||
$hourInTz = (int)Piwik_Date::factory($datetime, $timezone)->toString('H');
|
||||
$visitsByHourTz[$hourInTz] = $stats;
|
||||
}
|
||||
return $visitsByHourTz;
|
||||
}
|
||||
|
||||
protected function archiveDayAggregateGoals($archiveProcessing)
|
||||
{
|
||||
$query = $archiveProcessing->queryConversionsBySingleSegment("HOUR(server_time)");
|
||||
$goalByServerTime = array();
|
||||
while($row = $query->fetch())
|
||||
{
|
||||
$goalByServerTime[$row['label']][$row['idgoal']] = $archiveProcessing->getGoalRowFromQueryRow($row);
|
||||
}
|
||||
$goalByServerTime = $this->convertServerTimeToLocalTimezone($goalByServerTime, $archiveProcessing);
|
||||
foreach($goalByServerTime as $hour => $goals)
|
||||
{
|
||||
$this->interestByServerTime[$hour][Piwik_Archive::INDEX_GOALS] = $goals;
|
||||
}
|
||||
$archiveProcessing->enrichConversionsByLabelArray($this->interestByServerTime);
|
||||
}
|
||||
|
||||
protected function archiveDayRecordInDatabase($archiveProcessing)
|
||||
{
|
||||
$tableLocalTime = $archiveProcessing->getDataTableFromArray($this->interestByLocalTime);
|
||||
$this->makeSureAllHoursAreSet($tableLocalTime, $archiveProcessing);
|
||||
$archiveProcessing->insertBlobRecord('VisitTime_localTime', $tableLocalTime->getSerialized());
|
||||
destroy($tableLocalTime);
|
||||
|
||||
$tableServerTime = $archiveProcessing->getDataTableFromArray($this->interestByServerTime);
|
||||
$this->makeSureAllHoursAreSet($tableServerTime, $archiveProcessing);
|
||||
$archiveProcessing->insertBlobRecord('VisitTime_serverTime', $tableServerTime->getSerialized());
|
||||
destroy($tableServerTime);
|
||||
}
|
||||
|
||||
private function makeSureAllHoursAreSet($table, $archiveProcessing)
|
||||
{
|
||||
for($i=0; $i<=23; $i++)
|
||||
{
|
||||
if($table->getRowFromLabel($i) === false)
|
||||
{
|
||||
$row = $archiveProcessing->getNewInterestRowLabeled($i);
|
||||
$table->addRow( $row );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<div id='leftcolumn'>
|
||||
<h2>{'VisitTime_LocalTime'|translate}</h2>
|
||||
{$dataTableVisitInformationPerLocalTime}
|
||||
</div>
|
||||
|
||||
<div id='rightcolumn'>
|
||||
<h2>{'VisitTime_ServerTime'|translate}</h2>
|
||||
{$dataTableVisitInformationPerServerTime}
|
||||
</div>
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: API.php 1832 2010-02-10 08:14:15Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitorInterest
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_VisitorInterest
|
||||
*/
|
||||
class Piwik_VisitorInterest_API
|
||||
{
|
||||
static private $instance = null;
|
||||
static public function getInstance()
|
||||
{
|
||||
if (self::$instance == null)
|
||||
{
|
||||
$c = __CLASS__;
|
||||
self::$instance = new $c();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
protected function getDataTable($name, $idSite, $period, $date)
|
||||
{
|
||||
Piwik::checkUserHasViewAccess( $idSite );
|
||||
$archive = Piwik_Archive::build($idSite, $period, $date );
|
||||
$dataTable = $archive->getDataTable($name);
|
||||
$dataTable->filter('Sort',array(Piwik_Archive::INDEX_NB_VISITS));
|
||||
$dataTable->queueFilter('ReplaceColumnNames');
|
||||
$dataTable->queueFilter('Sort', array('label', 'asc', true));
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
public function getNumberOfVisitsPerVisitDuration( $idSite, $period, $date )
|
||||
{
|
||||
$dataTable = $this->getDataTable('VisitorInterest_timeGap', $idSite, $period, $date);
|
||||
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getDurationLabel'));
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
public function getNumberOfVisitsPerPage( $idSite, $period, $date )
|
||||
{
|
||||
$dataTable = $this->getDataTable('VisitorInterest_pageGap', $idSite, $period, $date);
|
||||
$dataTable->queueFilter('ColumnCallbackReplace', array('label', 'Piwik_getPageGapLabel'));
|
||||
return $dataTable;
|
||||
}
|
||||
}
|
||||
|
||||
function Piwik_getDurationLabel($label)
|
||||
{
|
||||
if(($pos = strpos($label,'-')) !== false)
|
||||
{
|
||||
$min = substr($label, 0, $pos);
|
||||
$max = substr($label, $pos+1);
|
||||
|
||||
if($min == 0 || $min == 30)
|
||||
{
|
||||
$XYSeconds = Piwik_Translate('VisitorInterest_BetweenXYSeconds');
|
||||
return sprintf($XYSeconds, $min, $max);
|
||||
}
|
||||
else
|
||||
{
|
||||
$min = $min / 60;
|
||||
$max = $max / 60;
|
||||
$XYMin = Piwik_Translate('VisitorInterest_BetweenXYMinutes');
|
||||
return sprintf($XYMin, $min, $max);
|
||||
}
|
||||
}
|
||||
if(!is_numeric($label))
|
||||
{
|
||||
return $label;
|
||||
}
|
||||
$time = intval($label) / 60;
|
||||
$plusXMin = Piwik_Translate('VisitorInterest_PlusXMin');
|
||||
return sprintf($plusXMin, $time . urlencode('+'));
|
||||
}
|
||||
|
||||
function Piwik_getPageGapLabel($label)
|
||||
{
|
||||
$return = false;
|
||||
if(($pos = strpos($label,'-')) !== false)
|
||||
{
|
||||
$min = substr($label, 0, $pos);
|
||||
$max = substr($label, $pos+1);
|
||||
|
||||
if($min == $max)
|
||||
{
|
||||
$return = $min;
|
||||
}
|
||||
}
|
||||
if(!$return)
|
||||
{
|
||||
$return = $label;
|
||||
}
|
||||
|
||||
if($return == 1)
|
||||
{
|
||||
return Piwik_Translate('VisitorInterest_OnePage');
|
||||
}
|
||||
|
||||
return sprintf(Piwik_Translate('VisitorInterest_NPages'), $return);
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: Controller.php 1420 2009-08-22 13:23:16Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitorInterest
|
||||
*/
|
||||
|
||||
/**
|
||||
* @package Piwik_VisitorInterest
|
||||
*/
|
||||
class Piwik_VisitorInterest_Controller extends Piwik_Controller
|
||||
{
|
||||
function index()
|
||||
{
|
||||
$view = Piwik_View::factory('index');
|
||||
$view->dataTableNumberOfVisitsPerVisitDuration = $this->getNumberOfVisitsPerVisitDuration(true);
|
||||
$view->dataTableNumberOfVisitsPerPage = $this->getNumberOfVisitsPerPage(true);
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
function getNumberOfVisitsPerVisitDuration( $fetch = false)
|
||||
{
|
||||
$view = Piwik_ViewDataTable::factory( 'cloud' );
|
||||
$view->init( $this->pluginName, __FUNCTION__, "VisitorInterest.getNumberOfVisitsPerVisitDuration" );
|
||||
|
||||
$view->setColumnsToDisplay( array('label','nb_visits') );
|
||||
$view->setSortedColumn( 'label', 'asc' );
|
||||
$view->setColumnTranslation('label', Piwik_Translate('VisitorInterest_ColumnVisitDuration'));
|
||||
$view->disableSort();
|
||||
$view->disableExcludeLowPopulation();
|
||||
$view->disableOffsetInformation();
|
||||
$view->disableSearchBox();
|
||||
$view->disableShowAllColumns();
|
||||
|
||||
return $this->renderView($view, $fetch);
|
||||
}
|
||||
|
||||
function getNumberOfVisitsPerPage( $fetch = false)
|
||||
{
|
||||
$view = Piwik_ViewDataTable::factory( 'cloud' );
|
||||
$view->init( $this->pluginName, __FUNCTION__, "VisitorInterest.getNumberOfVisitsPerPage" );
|
||||
$view->setColumnsToDisplay( array('label','nb_visits') );
|
||||
$view->setSortedColumn( 'nb_visits', 'asc' );
|
||||
$view->setColumnTranslation('label', Piwik_Translate('VisitorInterest_ColumnPagesPerVisit'));
|
||||
$view->disableExcludeLowPopulation();
|
||||
$view->disableOffsetInformation();
|
||||
$view->disableSearchBox();
|
||||
$view->disableSort();
|
||||
$view->disableShowAllColumns();
|
||||
|
||||
return $this->renderView($view, $fetch);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: VisitorInterest.php 2264 2010-06-03 16:53:43Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitorInterest
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_VisitorInterest
|
||||
*/
|
||||
class Piwik_VisitorInterest extends Piwik_Plugin
|
||||
{
|
||||
public function getInformation()
|
||||
{
|
||||
$info = array(
|
||||
'description' => Piwik_Translate('VisitorInterest_PluginDescription'),
|
||||
'author' => 'Piwik',
|
||||
'author_homepage' => 'http://piwik.org/',
|
||||
'version' => Piwik_Version::VERSION,
|
||||
);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function getListHooksRegistered()
|
||||
{
|
||||
$hooks = array(
|
||||
'ArchiveProcessing_Day.compute' => 'archiveDay',
|
||||
'ArchiveProcessing_Period.compute' => 'archivePeriod',
|
||||
'WidgetsList.add' => 'addWidgets',
|
||||
'Menu.add' => 'addMenu',
|
||||
);
|
||||
return $hooks;
|
||||
}
|
||||
|
||||
protected $timeGap = array(
|
||||
array(0, 0.5),
|
||||
array(0.5, 1),
|
||||
array(1, 2),
|
||||
array(2, 4),
|
||||
array(4, 6),
|
||||
array(6, 8),
|
||||
array(8, 11),
|
||||
array(11, 15),
|
||||
array(15)
|
||||
);
|
||||
|
||||
protected $pageGap = array(
|
||||
array(1, 1),
|
||||
array(2, 2),
|
||||
array(3, 3),
|
||||
array(4, 4),
|
||||
array(5, 5),
|
||||
array(6, 7),
|
||||
array(8, 10),
|
||||
array(11, 14),
|
||||
array(15, 20),
|
||||
array(20)
|
||||
);
|
||||
|
||||
function addWidgets()
|
||||
{
|
||||
Piwik_AddWidget( 'General_Visitors', 'VisitorInterest_WidgetLengths', 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration');
|
||||
Piwik_AddWidget( 'General_Visitors', 'VisitorInterest_WidgetPages', 'VisitorInterest', 'getNumberOfVisitsPerPage');
|
||||
}
|
||||
|
||||
function addMenu()
|
||||
{
|
||||
Piwik_RenameMenuEntry('General_Visitors', 'VisitFrequency_SubmenuFrequency',
|
||||
'General_Visitors', 'VisitorInterest_Engagement' );
|
||||
}
|
||||
|
||||
function postLoad()
|
||||
{
|
||||
Piwik_AddAction('template_headerVisitsFrequency', array('Piwik_VisitorInterest','headerVisitsFrequency'));
|
||||
Piwik_AddAction('template_footerVisitsFrequency', array('Piwik_VisitorInterest','footerVisitsFrequency'));
|
||||
}
|
||||
|
||||
|
||||
function archivePeriod( $notification )
|
||||
{
|
||||
$archiveProcessing = $notification->getNotificationObject();
|
||||
|
||||
$dataTableToSum = array(
|
||||
'VisitorInterest_timeGap',
|
||||
'VisitorInterest_pageGap',
|
||||
);
|
||||
$archiveProcessing->archiveDataTable($dataTableToSum);
|
||||
}
|
||||
|
||||
public function archiveDay( $notification )
|
||||
{
|
||||
$this->archiveProcessing = $notification->getNotificationObject();
|
||||
|
||||
$recordName = 'VisitorInterest_timeGap';
|
||||
$tableTimegap = $this->getTableTimeGap();
|
||||
$this->archiveProcessing->insertBlobRecord($recordName, $tableTimegap->getSerialized());
|
||||
|
||||
$recordName = 'VisitorInterest_pageGap';
|
||||
$tablePagegap = $this->getTablePageGap();
|
||||
$this->archiveProcessing->insertBlobRecord($recordName, $tablePagegap->getSerialized());
|
||||
}
|
||||
|
||||
protected function getTablePageGap()
|
||||
{
|
||||
$select = array();
|
||||
foreach($this->pageGap as $gap)
|
||||
{
|
||||
if(count($gap) == 2)
|
||||
{
|
||||
$minGap = $gap[0];
|
||||
$maxGap = $gap[1];
|
||||
$gapName = "'$minGap-$maxGap'";
|
||||
$select[] = "sum(case when visit_total_actions between $minGap and $maxGap then 1 else 0 end) as $gapName ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$minGap = $gap[0];
|
||||
$plusEncoded = urlencode('+');
|
||||
$gapName = "'".$minGap.$plusEncoded."'";
|
||||
$select[] = "sum(case when visit_total_actions > $minGap then 1 else 0 end) as $gapName ";
|
||||
}
|
||||
}
|
||||
$toSelect = implode(" , ", $select);
|
||||
|
||||
return $this->archiveProcessing->getSimpleDataTableFromSelect($toSelect, Piwik_Archive::INDEX_NB_VISITS);
|
||||
}
|
||||
|
||||
protected function getTableTimeGap()
|
||||
{
|
||||
$select = array();
|
||||
foreach($this->timeGap as $gap)
|
||||
{
|
||||
if(count($gap) == 2)
|
||||
{
|
||||
$minGap = $gap[0] * 60;
|
||||
$maxGap = $gap[1] * 60;
|
||||
|
||||
$gapName = "'".$minGap."-".$maxGap."'";
|
||||
$select[] = "sum(case when visit_total_time between $minGap and $maxGap then 1 else 0 end) as $gapName ";
|
||||
}
|
||||
else
|
||||
{
|
||||
$minGap = $gap[0] * 60;
|
||||
$gapName = "'$minGap'";
|
||||
$select[] = "sum(case when visit_total_time > $minGap then 1 else 0 end) as $gapName ";
|
||||
}
|
||||
}
|
||||
$toSelect = implode(" , ", $select);
|
||||
|
||||
$table = $this->archiveProcessing->getSimpleDataTableFromSelect($toSelect, Piwik_Archive::INDEX_NB_VISITS);
|
||||
return $table;
|
||||
}
|
||||
|
||||
static public function headerVisitsFrequency($notification)
|
||||
{
|
||||
$out =& $notification->getNotificationObject();
|
||||
$out = '<div id="leftcolumn">';
|
||||
}
|
||||
|
||||
static public function footerVisitsFrequency($notification)
|
||||
{
|
||||
$out =& $notification->getNotificationObject();
|
||||
$out = '</div>
|
||||
<div id="rightcolumn">
|
||||
';
|
||||
$out .= Piwik_FrontController::getInstance()->fetchDispatch('VisitorInterest','index');
|
||||
$out .= '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
<h2>{'VisitorInterest_VisitsPerDuration'|translate}</h2>
|
||||
{$dataTableNumberOfVisitsPerVisitDuration}
|
||||
|
||||
<h2>{'VisitorInterest_VisitsPerNbOfPages'|translate}</h2>
|
||||
{$dataTableNumberOfVisitsPerPage}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: API.php 2202 2010-05-20 08:49:42Z matt $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitsSummary
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_VisitsSummary
|
||||
*/
|
||||
class Piwik_VisitsSummary_API
|
||||
{
|
||||
static private $instance = null;
|
||||
static public function getInstance()
|
||||
{
|
||||
if (self::$instance == null)
|
||||
{
|
||||
$c = __CLASS__;
|
||||
self::$instance = new $c();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function get( $idSite, $period, $date, $columns = array() )
|
||||
{
|
||||
Piwik::checkUserHasViewAccess( $idSite );
|
||||
$archive = Piwik_Archive::build($idSite, $period, $date );
|
||||
|
||||
$bounceRateRequested = false;
|
||||
if(!empty($columns))
|
||||
{
|
||||
$toFetch = $columns;
|
||||
if(($bounceRateRequested = array_search('bounce_rate', $toFetch)) !== false)
|
||||
{
|
||||
$toFetch = array('nb_visits', 'bounce_count');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$toFetch = array( 'max_actions',
|
||||
'nb_uniq_visitors',
|
||||
'nb_visits',
|
||||
'nb_actions',
|
||||
'sum_visit_length',
|
||||
'bounce_count',
|
||||
'nb_visits_converted',
|
||||
);
|
||||
}
|
||||
$dataTable = $archive->getDataTableFromNumeric($toFetch);
|
||||
if($bounceRateRequested !== false)
|
||||
{
|
||||
$dataTable->filter('ColumnCallbackAddColumnPercentage', array('bounce_rate', 'bounce_count', 'nb_visits', 0));
|
||||
$dataTable->deleteColumns($toFetch);
|
||||
}
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
protected function getNumeric( $idSite, $period, $date, $toFetch )
|
||||
{
|
||||
Piwik::checkUserHasViewAccess( $idSite );
|
||||
$archive = Piwik_Archive::build($idSite, $period, $date );
|
||||
$dataTable = $archive->getNumeric($toFetch);
|
||||
return $dataTable;
|
||||
}
|
||||
|
||||
public function getVisits( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getNumeric( $idSite, $period, $date, 'nb_visits');
|
||||
}
|
||||
|
||||
public function getUniqueVisitors( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getNumeric( $idSite, $period, $date, 'nb_uniq_visitors');
|
||||
}
|
||||
|
||||
public function getActions( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getNumeric( $idSite, $period, $date, 'nb_actions');
|
||||
}
|
||||
|
||||
public function getMaxActions( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getNumeric( $idSite, $period, $date, 'max_actions');
|
||||
}
|
||||
|
||||
public function getBounceCount( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getNumeric( $idSite, $period, $date, 'bounce_count');
|
||||
}
|
||||
|
||||
public function getVisitsConverted( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getNumeric( $idSite, $period, $date, 'nb_visits_converted');
|
||||
}
|
||||
|
||||
public function getSumVisitsLength( $idSite, $period, $date )
|
||||
{
|
||||
return $this->getNumeric( $idSite, $period, $date, 'sum_visit_length');
|
||||
}
|
||||
|
||||
public function getSumVisitsLengthPretty( $idSite, $period, $date )
|
||||
{
|
||||
return Piwik::getPrettyTimeFromSeconds($this->getSumVisitsLength( $idSite, $period, $date ));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: Controller.php 1420 2009-08-22 13:23:16Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitsSummary
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_VisitsSummary
|
||||
*/
|
||||
class Piwik_VisitsSummary_Controller extends Piwik_Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$view = Piwik_View::factory('index');
|
||||
$this->setPeriodVariablesView($view);
|
||||
$view->graphEvolutionVisitsSummary = $this->getEvolutionGraph( true, array('nb_visits') );
|
||||
$this->setSparklinesAndNumbers($view);
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
public function getSparklines()
|
||||
{
|
||||
$view = Piwik_View::factory('sparklines');
|
||||
$this->setSparklinesAndNumbers($view);
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
public function getEvolutionGraph( $fetch = false, $columns = false)
|
||||
{
|
||||
$view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, "VisitsSummary.get");
|
||||
if(empty($columns))
|
||||
{
|
||||
$columns = Piwik_Common::getRequestVar('columns');
|
||||
}
|
||||
$view->setColumnsToDisplay($columns);
|
||||
return $this->renderView($view, $fetch);
|
||||
}
|
||||
|
||||
static public function getVisitsSummary()
|
||||
{
|
||||
$requestString = "method=VisitsSummary.get".
|
||||
"&format=original".
|
||||
// we disable filters for example "search for pattern", in the case this method is called
|
||||
// by a method that already calls the API with some generic filters applied
|
||||
"&disable_generic_filters=1";
|
||||
$request = new Piwik_API_Request($requestString);
|
||||
return $request->process();
|
||||
}
|
||||
|
||||
static public function getVisits()
|
||||
{
|
||||
$requestString = "method=VisitsSummary.getVisits".
|
||||
"&format=original".
|
||||
"&disable_generic_filters=1";
|
||||
$request = new Piwik_API_Request($requestString);
|
||||
return $request->process();
|
||||
}
|
||||
|
||||
protected function setSparklinesAndNumbers($view)
|
||||
{
|
||||
$view->urlSparklineNbVisits = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('nb_visits')));
|
||||
$view->urlSparklineNbActions = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('nb_actions')));
|
||||
$view->urlSparklineSumVisitLength = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('sum_visit_length')));
|
||||
$view->urlSparklineMaxActions = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('max_actions')));
|
||||
$view->urlSparklineBounceRate = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('bounce_rate')));
|
||||
|
||||
$dataTableVisit = self::getVisitsSummary();
|
||||
$dataRow = $dataTableVisit->getFirstRow();
|
||||
if($view->period != 'year')
|
||||
{
|
||||
$view->urlSparklineNbUniqVisitors = $this->getUrlSparkline( 'getEvolutionGraph', array('columns' => array('nb_uniq_visitors')));
|
||||
$view->nbUniqVisitors = $dataRow->getColumn('nb_uniq_visitors');
|
||||
}
|
||||
$nbVisits = $dataRow->getColumn('nb_visits');
|
||||
$view->nbVisits = $nbVisits;
|
||||
$view->nbActions = $dataRow->getColumn('nb_actions');
|
||||
$view->sumVisitLength = $dataRow->getColumn('sum_visit_length');
|
||||
$nbBouncedVisits = $dataRow->getColumn('bounce_count');
|
||||
$view->bounceRate = Piwik::getPercentageSafe($nbBouncedVisits, $nbVisits);
|
||||
$view->maxActions = $dataRow->getColumn('max_actions');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: VisitsSummary.php 2264 2010-06-03 16:53:43Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_VisitsSummary
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_VisitsSummary
|
||||
*/
|
||||
class Piwik_VisitsSummary extends Piwik_Plugin
|
||||
{
|
||||
public function getInformation()
|
||||
{
|
||||
$info = array(
|
||||
'description' => Piwik_Translate('VisitsSummary_PluginDescription'),
|
||||
'author' => 'Piwik',
|
||||
'author_homepage' => 'http://piwik.org/',
|
||||
'version' => Piwik_Version::VERSION,
|
||||
);
|
||||
return $info;
|
||||
}
|
||||
|
||||
function getListHooksRegistered()
|
||||
{
|
||||
return array(
|
||||
'WidgetsList.add' => 'addWidgets',
|
||||
'Menu.add' => 'addMenu',
|
||||
);
|
||||
}
|
||||
|
||||
function addWidgets()
|
||||
{
|
||||
Piwik_AddWidget( 'VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetLastVisits', 'VisitsSummary', 'getEvolutionGraph', array('columns' => array('nb_visits')));
|
||||
Piwik_AddWidget( 'VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetVisits', 'VisitsSummary', 'getSparklines');
|
||||
Piwik_AddWidget( 'VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetOverviewGraph', 'VisitsSummary', 'index');
|
||||
}
|
||||
|
||||
function addMenu()
|
||||
{
|
||||
Piwik_AddMenu('General_Visitors', 'VisitsSummary_SubmenuOverview', array('module' => 'VisitsSummary', 'action' => 'index'), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<script type="text/javascript" src="plugins/CoreHome/templates/sparkline.js"></script>
|
||||
|
||||
<a name="evolutionGraph" graphId="VisitsSummarygetEvolutionGraph"></a>
|
||||
<h2>{'VisitsSummary_EvolutionOverLastPeriods'|translate:$periodsNames.$period.plural}</h2>
|
||||
{$graphEvolutionVisitsSummary}
|
||||
|
||||
<h2>{'VisitsSummary_Report'|translate}</h2>
|
||||
{include file=VisitsSummary/templates/sparklines.tpl}
|
||||
|
||||
<br /><br /><br />
|
||||
<p style='color:lightgrey; size:0.8em;'>
|
||||
{'VisitsSummary_GenerateTime'|translate:$totalTimeGeneration:$totalNumberOfQueries}
|
||||
{if $totalNumberOfQueries != 0}, {'VisitsSummary_GenerateQueries'|translate:$totalNumberOfQueries}{/if}
|
||||
</p>
|
||||
@@ -0,0 +1,13 @@
|
||||
<div id='leftcolumn'>
|
||||
<div class="sparkline">{sparkline src=$urlSparklineNbVisits} {'VisitsSummary_NbVisits'|translate:"<strong>$nbVisits</strong>"}</div>
|
||||
{if isset($urlSparklineNbUniqVisitors)}
|
||||
<div class="sparkline">{sparkline src=$urlSparklineNbUniqVisitors} {'VisitsSummary_NbUniqueVisitors'|translate:"<strong>$nbUniqVisitors</strong>"}</div>
|
||||
{/if}
|
||||
<div class="sparkline">{sparkline src=$urlSparklineNbActions} {'VisitsSummary_NbActionsDescription'|translate:"<strong>$nbActions</strong>"}</div>
|
||||
</div>
|
||||
<div id='rightcolumn'>
|
||||
<div class="sparkline">{sparkline src=$urlSparklineSumVisitLength} {assign var=sumtimeVisitLength value=$sumVisitLength|sumtime} {'VisitsSummary_TotalTime'|translate:"<strong>$sumtimeVisitLength</strong>"}</div>
|
||||
<div class="sparkline">{sparkline src=$urlSparklineMaxActions} {'VisitsSummary_MaxNbActions'|translate:"<strong>$maxActions</strong>"}</div>
|
||||
<div class="sparkline">{sparkline src=$urlSparklineBounceRate} {'VisitsSummary_NbVisitsBounced'|translate:"<strong>$bounceRate%</strong>"}</div>
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: Controller.php 2151 2010-05-07 08:57:27Z matt $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_Widgetize
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_Widgetize
|
||||
*/
|
||||
class Piwik_Widgetize_Controller extends Piwik_Controller
|
||||
{
|
||||
function index()
|
||||
{
|
||||
$view = Piwik_View::factory('index');
|
||||
$view->availableWidgets = json_encode(Piwik_GetWidgetsList());
|
||||
$this->setGeneralVariablesView($view);
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
function testJsInclude1()
|
||||
{
|
||||
$view = Piwik_View::factory('test_jsinclude');
|
||||
$view->url1 = '?module=Widgetize&action=js&moduleToWidgetize=UserSettings&actionToWidgetize=getBrowser&idSite=1&period=day&date=yesterday';
|
||||
$view->url2 = '?module=Widgetize&action=js&moduleToWidgetize=API&actionToWidgetize=index&method=ExamplePlugin.getGoldenRatio&format=original';
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
function testJsInclude2()
|
||||
{
|
||||
$view = Piwik_View::factory('test_jsinclude2');
|
||||
$view->url1 = '?module=Widgetize&action=js&moduleToWidgetize=UserSettings&actionToWidgetize=getBrowser&idSite=1&period=day&date=yesterday';
|
||||
$view->url2 = '?module=Widgetize&action=js&moduleToWidgetize=UserCountry&actionToWidgetize=getCountry&idSite=1&period=day&date=yesterday&viewDataTable=cloud&show_footer=0';
|
||||
$view->url3 = '?module=Widgetize&action=js&moduleToWidgetize=Referers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&viewDataTable=table&show_footer=0';
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
function js()
|
||||
{
|
||||
Piwik_API_Request::reloadAuthUsingTokenAuth();
|
||||
$controllerName = Piwik_Common::getRequestVar('moduleToWidgetize');
|
||||
$actionName = Piwik_Common::getRequestVar('actionToWidgetize');
|
||||
$parameters = array ( $fetch = true );
|
||||
$content = Piwik_FrontController::getInstance()->fetchDispatch( $controllerName, $actionName, $parameters);
|
||||
$view = Piwik_View::factory('js');
|
||||
$view->piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName();
|
||||
$content = str_replace(array("\t","\n","\r\n","\r"), "", $content);
|
||||
$view->content = $content;
|
||||
echo $view->render();
|
||||
}
|
||||
|
||||
function iframe()
|
||||
{
|
||||
Piwik_API_Request::reloadAuthUsingTokenAuth();
|
||||
$controllerName = Piwik_Common::getRequestVar('moduleToWidgetize');
|
||||
$actionName = Piwik_Common::getRequestVar('actionToWidgetize');
|
||||
$parameters = array ( $fetch = true );
|
||||
$outputDataTable = Piwik_FrontController::getInstance()->fetchDispatch( $controllerName, $actionName, $parameters);
|
||||
$view = Piwik_View::factory('iframe');
|
||||
$view->content = $outputDataTable;
|
||||
echo $view->render();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* Piwik - Open source web analytics
|
||||
*
|
||||
* @link http://piwik.org
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later
|
||||
* @version $Id: Widgetize.php 2264 2010-06-03 16:53:43Z vipsoft $
|
||||
*
|
||||
* @category Piwik_Plugins
|
||||
* @package Piwik_Widgetize
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @package Piwik_Widgetize
|
||||
*/
|
||||
class Piwik_Widgetize extends Piwik_Plugin
|
||||
{
|
||||
public function getInformation()
|
||||
{
|
||||
return array(
|
||||
'description' => Piwik_Translate('Widgetize_PluginDescription'),
|
||||
'author' => 'Piwik',
|
||||
'author_homepage' => 'http://piwik.org/',
|
||||
'version' => Piwik_Version::VERSION,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<head>
|
||||
{loadJavascriptTranslations plugins='CoreHome'}
|
||||
{include file="CoreHome/templates/js_global_variables.tpl"}
|
||||
{include file="CoreHome/templates/js_css_includes.tpl"}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="widget">
|
||||
{$content}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,97 @@
|
||||
{assign var=showSitesSelection value=true}
|
||||
{assign var=showPeriodSelection value=true}
|
||||
{include file="CoreHome/templates/header.tpl"}
|
||||
{loadJavascriptTranslations plugins='Dashboard'}
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/styles.css" />
|
||||
<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/datatable.css" />
|
||||
<link rel="stylesheet" type="text/css" href="plugins/CoreHome/templates/cloud.css" />
|
||||
<link rel="stylesheet" type="text/css" href="plugins/Dashboard/templates/dashboard.css" />
|
||||
|
||||
<script type="text/javascript" src="libs/swfobject/swfobject.js"></script>
|
||||
<script type="text/javascript" src="libs/jquery/tooltip/jquery.tooltip.js"></script>
|
||||
<script type="text/javascript" src="libs/jquery/truncate/jquery.truncate.js"></script>
|
||||
<script type="text/javascript" src="libs/jquery/jquery.scrollTo.js"></script>
|
||||
<script type="text/javascript" src="themes/default/common.js"></script>
|
||||
<script type="text/javascript" src="plugins/CoreHome/templates/datatable.js"></script>
|
||||
<script type="text/javascript" src="plugins/Dashboard/templates/widgetMenu.js"></script>
|
||||
|
||||
<script type="text/javascript" src="plugins/Widgetize/templates/widgetize.js"></script>
|
||||
|
||||
{literal}
|
||||
<style>
|
||||
.menu {
|
||||
display: inline;
|
||||
}
|
||||
.formEmbedCode{
|
||||
font-size: 11px;
|
||||
text-decoration: none;
|
||||
background-color: #FBFDFF;
|
||||
border: 1px solid #ECECEC;
|
||||
width:220px;
|
||||
}
|
||||
|
||||
#periodString {
|
||||
margin-left:500px;
|
||||
}
|
||||
|
||||
label {
|
||||
color:#666666;
|
||||
line-height:18px;
|
||||
margin-right:5px;
|
||||
font-weight:bold;
|
||||
padding-bottom:100px;
|
||||
}
|
||||
|
||||
#embedThisWidgetIframe,
|
||||
#embedThisWidgetFlash,
|
||||
#embedThisWidgetEverywhere {
|
||||
margin-top:5px;
|
||||
}
|
||||
|
||||
.menuSelected{
|
||||
font-weight:bold;
|
||||
}
|
||||
</style>
|
||||
{/literal}
|
||||
<script type="text/javascript">
|
||||
piwik.availableWidgets = {$availableWidgets};
|
||||
{literal}
|
||||
$(document).ready( function() {
|
||||
var menu = new widgetMenu();
|
||||
var widgetized = new widgetize();
|
||||
menu.init();
|
||||
menu.registerCallbackOnWidgetLoad( widgetized.callbackAddExportButtonsUnderWidget );
|
||||
menu.registerCallbackOnMenuHover( widgetized.deleteEmbedElements );
|
||||
menu.show();
|
||||
var dashboardUrl = document.location.protocol + '//' + document.location.hostname + document.location.pathname + '?module=Widgetize&action=iframe&moduleToWidgetize=Dashboard&actionToWidgetize=index&idSite=1&period=week&date=yesterday';
|
||||
$('#exportFullDashboard').html(
|
||||
widgetized.getInputFormWithHtml( 'dashboardEmbed', '<iframe src="'+ dashboardUrl +'" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="100%"></iframe>')
|
||||
);
|
||||
$('#linkDashboardUrl').attr('href',dashboardUrl);
|
||||
});
|
||||
|
||||
{/literal}
|
||||
</script>
|
||||
|
||||
<div style="max-width:980px;">
|
||||
<p>With Piwik, you can export your Web Analytics reports on your blog, website, or intranet dashboard... in one click.
|
||||
<p><b>› Widget authentication:</b> If you want your widgets to be viewable by everybody, you first have to set the 'view' permissions
|
||||
to the anonymous user in the <a href='index.php?module=UsersManager'>Users Management section</a>.
|
||||
<br />Alternatively, if you are publishing widgets on a password protected or private page,
|
||||
you don't necessarily have to allow 'anonymous' to view your reports. In this case, you can add the secret token_auth parameter (found in the <a href='{url module=API action=listAllAPI}' target='_blank'>API page</a>) in the widget URL.
|
||||
</p>
|
||||
<p><b>› Widgetize the full dashboard:</b> You can also display the full Piwik dashboard in your application or website in an IFRAME (<a href='' target='_blank' id='linkDashboardUrl'>see example</a>).
|
||||
The date parameter can be set to a specific calendar date, "today", or "yesterday". The period parameter can be set to "day", "week", "month", or "year".
|
||||
The language parameter can be set to the language code of a translation, such as language=fr.
|
||||
For example, for idSite=1 and date=yesterday, you can write: <span id='exportFullDashboard'></span>
|
||||
</p>
|
||||
<p> <b>› Select a report, and copy paste in your page the embed code below the widget:</b>
|
||||
<div id="widgetChooser" style='height:600px'>
|
||||
<div class="subMenu" id="sub1"></div>
|
||||
<div class="subMenu" id="sub2"></div>
|
||||
<div class="subMenu" id="sub3"></div>
|
||||
<div class="menuClear"></div>
|
||||
</div>
|
||||
<div id='iframeDivToExport' style='display:none;'></div>
|
||||
</div>
|
||||
@@ -0,0 +1,19 @@
|
||||
{loadJavascriptTranslations disableOutputScriptTag=1 plugins='CoreHome'}
|
||||
|
||||
document.write('<link rel="stylesheet" type="text/css" href="{$piwikUrl}themes/default/common.css" />');
|
||||
document.write('<link rel="stylesheet" type="text/css" href="{$piwikUrl}plugins/CoreHome/templates/styles.css" />');
|
||||
document.write('<link rel="stylesheet" type="text/css" href="{$piwikUrl}plugins/CoreHome/templates/datatable.css" />');
|
||||
document.write('<link rel="stylesheet" type="text/css" href="{$piwikUrl}plugins/CoreHome/templates/cloud.css" />');
|
||||
|
||||
document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/swfobject/swfobject.js"></scr'+'ipt>');
|
||||
document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/jquery/jquery.js"></scr'+'ipt>');
|
||||
document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/jquery/jquery-ui.js"></scr'+'ipt>');
|
||||
document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/jquery/tooltip/jquery.tooltip.js"></scr'+'ipt>');
|
||||
document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/jquery/truncate/jquery.truncate.js"></scr'+'ipt>');
|
||||
document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}libs/javascript/sprintf.js"></scr'+'ipt>');
|
||||
document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}themes/default/common.js"></scr'+'ipt>');
|
||||
document.write('<scr'+'ipt type="text/javascript" src="{$piwikUrl}plugins/CoreHome/templates/datatable.js"></scr'+'ipt>');
|
||||
|
||||
var content = '{$content|escape:'javascript'}';
|
||||
document.write('<scr'+'ipt type="text/javascript">document.write(content)</scr'+'ipt>');
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>This text is after the JS INCLUDE</p>
|
||||
|
||||
|
||||
<h2>Test tag cloud in a JS include</h2>
|
||||
|
||||
<div style="width:500px">
|
||||
<script type="text/javascript" src="{$url1}"></script>
|
||||
<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
|
||||
</div>
|
||||
<p>This text is after the JS INCLUDE</p>
|
||||
|
||||
<h2>Test calling the API in Javascript</h2>
|
||||
<p>using a javascript include. This is a dirty way (much better to ajax call the API!) but an interesting show case.</P>
|
||||
<script type="text/javascript" src="{$url2}"></script>
|
||||
<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
|
||||
<p>This text is after the JS INCLUDE 2</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,27 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>This text is after the JS INCLUDE</p>
|
||||
|
||||
<h2>Test table in a JS include</h2>
|
||||
|
||||
<script type="text/javascript" src="{$url1}"></script>
|
||||
<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
|
||||
|
||||
<p>This text is after the JS INCLUDE</p>
|
||||
|
||||
<h2>Test another table in a JS include</h2>
|
||||
|
||||
<script type="text/javascript" src="{$url3}"></script>
|
||||
<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
|
||||
|
||||
<p>This text is after the 2nd JS INCLUDE</p>
|
||||
|
||||
<h2>Test tag cloud in a JS include</h2>
|
||||
|
||||
<script type="text/javascript" src="{$url2}"></script>
|
||||
<noscript>Powered by <a href="http://piwik.org">Piwik</a></div></noscript>
|
||||
|
||||
<p>This text is after the JS INCLUDE</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,102 @@
|
||||
function widgetize()
|
||||
{
|
||||
var self = this;
|
||||
|
||||
this.getInputFormWithHtml = function(inputId, htmlEmbed)
|
||||
{
|
||||
return '<input class="formEmbedCode" id="'+inputId+'" value="'+ htmlEmbed.replace(/"/g, '"') +'" onclick="javascript:document.getElementById(\''+inputId+'\').focus();document.getElementById(\''+inputId+'\').select();" readonly="true" type="text" />';
|
||||
}
|
||||
|
||||
this.getEmbedUrl = function( parameters, exportFormat )
|
||||
{
|
||||
copyParameters = {};
|
||||
for(var variableName in parameters) {
|
||||
copyParameters[variableName] = parameters[variableName];
|
||||
}
|
||||
copyParameters['moduleToWidgetize'] = parameters['module'];
|
||||
copyParameters['actionToWidgetize'] = parameters['action'];
|
||||
delete copyParameters['action'];
|
||||
delete copyParameters['module'];
|
||||
var sourceUrl;
|
||||
sourceUrl = document.location.protocol + '//' + document.location.hostname + document.location.pathname + '?';
|
||||
sourceUrl += "module=Widgetize" +
|
||||
"&action="+exportFormat+
|
||||
"&"+piwikHelper.getQueryStringFromParameters(copyParameters)+
|
||||
"&idSite="+piwik.idSite+
|
||||
"&period="+piwik.period+
|
||||
"&date="+piwik.currentDateString+
|
||||
"&disableLink=1";
|
||||
return sourceUrl;
|
||||
}
|
||||
|
||||
this.deleteEmbedElements = function()
|
||||
{
|
||||
$('#exportButtons').remove();
|
||||
}
|
||||
|
||||
this.htmlentities = function(s)
|
||||
{
|
||||
return s.replace( /[<>&]/g, function(m) { return "&" + m.charCodeAt(0) + ";"; });
|
||||
}
|
||||
|
||||
this.callbackAddExportButtonsUnderWidget = function ( widgetUniqueId,
|
||||
loadedWidgetElement)
|
||||
{
|
||||
widget = widgetsHelper.getWidgetObjectFromUniqueId(widgetUniqueId);
|
||||
widgetName = widget["name"];
|
||||
widgetParameters = widget['parameters'];
|
||||
|
||||
self.deleteEmbedElements();
|
||||
var exportButtonsElement = $('<span id="exportButtons">');
|
||||
|
||||
// We first build the HTML code that will load the widget in an IFRAME
|
||||
var widgetIframeHtml = '<div id="widgetIframe">'+
|
||||
'<iframe width="100%" height="350" src="'+
|
||||
self.getEmbedUrl(widgetParameters, "iframe")+
|
||||
'" scrolling="no" frameborder="0" marginheight="0" marginwidth="0">'+
|
||||
'</iframe>'+
|
||||
'</div>';
|
||||
|
||||
// Add the input field containing the widget in an Iframe
|
||||
$(exportButtonsElement).append(
|
||||
'<div id="embedThisWidgetIframe">'+
|
||||
'<label for="embedThisWidgetIframeInput">› Embed Iframe</label>'+
|
||||
'<span id="embedThisWidgetIframeInput">'+
|
||||
self.getInputFormWithHtml('iframeEmbed', widgetIframeHtml)+
|
||||
'</span>'+
|
||||
'</div>'
|
||||
);
|
||||
|
||||
// Add the Flash Export if a flash <embed> is found in the widget
|
||||
$(loadedWidgetElement)
|
||||
.find('embed,object')
|
||||
.each(function() {
|
||||
var htmlEmbed = $(this).parent().html();
|
||||
|
||||
htmlEmbed = htmlEmbed.replace(/ (data=")/, ' $1' + unescape(piwik.piwik_url));
|
||||
htmlEmbed = htmlEmbed.replace(/ (value=")x-(data-file=)/, ' $1$2' + piwik.piwik_url + 'index.php');
|
||||
|
||||
$(exportButtonsElement).append(
|
||||
'<div id="embedThisWidgetFlash">'+
|
||||
'<label for="embedThisWidgetFlashInput">› Embed Flash</label>'+
|
||||
'<span id="embedThisWidgetFlashInput">'+
|
||||
self.getInputFormWithHtml('flashEmbed', htmlEmbed) +
|
||||
'</span>'+
|
||||
'</div>'
|
||||
);
|
||||
});
|
||||
|
||||
// We then replace the div iframeDivToExport with the actual Iframe html
|
||||
$('#iframeDivToExport')
|
||||
.html(widgetIframeHtml);
|
||||
|
||||
// Finally we append the content to the parent widget DIV
|
||||
$(loadedWidgetElement)
|
||||
.parent()
|
||||
.append(exportButtonsElement);
|
||||
|
||||
// JS is buggy at least on IE
|
||||
//var widgetJS = '<script type="text/javascript" src="'+ getEmbedUrl(pluginId, actionId, "js") +'"></scr'+'ipt>';
|
||||
//divEmbedThisWidget.append('<br />Embed JS: '+ getInputFormWithHtml('javascriptEmbed', widgetJS));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user