Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2010-06-23 07:45:36 +0400
committermatt <matt@59fd770c-687e-43c8-a1e3-f5a4ff64c105>2010-06-23 07:45:36 +0400
commit7e1b5d6b762340cbff1bb928d15815980c7649a7 (patch)
treee07da179b9e1372866d2349777bd1cc6b4c9e8cf /plugins/Live
parent999f46479294713104c962bfe7469e9b6e7a4bbf (diff)
parentc98ea06f2cccec81c6ccce49162a583494e44d91 (diff)
Diffstat (limited to 'plugins/Live')
-rw-r--r--plugins/Live/API.php254
-rw-r--r--plugins/Live/Controller.php181
-rw-r--r--plugins/Live/Live.php51
-rw-r--r--plugins/Live/Visitor.php126
-rw-r--r--plugins/Live/templates/images/download.pngbin0 -> 734 bytes
-rw-r--r--plugins/Live/templates/images/file0.pngbin0 -> 535 bytes
-rw-r--r--plugins/Live/templates/images/file1.pngbin0 -> 683 bytes
-rw-r--r--plugins/Live/templates/images/file2.pngbin0 -> 632 bytes
-rw-r--r--plugins/Live/templates/images/file3.pngbin0 -> 661 bytes
-rw-r--r--plugins/Live/templates/images/file4.pngbin0 -> 596 bytes
-rw-r--r--plugins/Live/templates/images/file5.pngbin0 -> 653 bytes
-rw-r--r--plugins/Live/templates/images/file6.pngbin0 -> 654 bytes
-rw-r--r--plugins/Live/templates/images/file7.pngbin0 -> 637 bytes
-rw-r--r--plugins/Live/templates/images/file8.pngbin0 -> 574 bytes
-rw-r--r--plugins/Live/templates/images/file9.pngbin0 -> 566 bytes
-rw-r--r--plugins/Live/templates/images/goal.pngbin0 -> 672 bytes
-rw-r--r--plugins/Live/templates/images/outboundlink.pngbin0 -> 799 bytes
-rw-r--r--plugins/Live/templates/index.tpl180
-rw-r--r--plugins/Live/templates/lastVisits.tpl40
-rw-r--r--plugins/Live/templates/scripts/spy.js39
-rw-r--r--plugins/Live/templates/structure.tpl5
-rw-r--r--plugins/Live/templates/totalVisits.tpl26
22 files changed, 686 insertions, 216 deletions
diff --git a/plugins/Live/API.php b/plugins/Live/API.php
index 8f688ff23b..b6439a143f 100644
--- a/plugins/Live/API.php
+++ b/plugins/Live/API.php
@@ -11,136 +11,277 @@
*/
/**
- *
+ * @see plugins/Referers/functions.php
+ */
+require_once PIWIK_INCLUDE_PATH . '/plugins/Live/Visitor.php';
+
+/**
* @package Piwik_Live
*/
-class Piwik_Live_API
+class Piwik_Live_API
{
static private $instance = null;
-
/*
* @return Piwik_Live_API
*/
static public function getInstance()
{
if (self::$instance == null)
- {
+ {
$c = __CLASS__;
self::$instance = new $c();
}
return self::$instance;
}
+
+ const TYPE_FETCH_VISITS = 1;
+ const TYPE_FETCH_PAGEVIEWS = 2;
/*
* @return Piwik_DataTable
*/
- public function getLastVisitForVisitor( $visitorId, $idSite = null )
+ public function getLastVisitForVisitor( $visitorId, $idSite )
{
- return $this->getLastVisitsForVisitor($visitorId, $idSite, 1);
+ return $this->getLastVisitsForVisitor($visitorId, $idSite, $limit = 1);
}
-
+
/*
* @return Piwik_DataTable
*/
public function getLastVisitsForVisitor( $visitorId, $idSite, $limit = 10 )
{
- if(is_null($idSite))
- {
- Piwik::checkUserIsSuperUser();
- }
- else
- {
- Piwik::checkUserHasViewAccess($idSite);
- }
- $visitorDetails = self::loadLastVisitorDetailsFromDatabase($visitorId, $idSite, $limit);
- $table = self::getCleanedVisitorsFromDetails($visitorDetails);
+ Piwik::checkUserHasViewAccess($idSite);
+ $visitorDetails = $this->loadLastVisitorDetailsFromDatabase($idSite, $visitorId, $limit);
+ $table = $this->getCleanedVisitorsFromDetails($visitorDetails, $idSite);
return $table;
}
/*
* @return Piwik_DataTable
*/
- public function getLastVisits( $idSite = false, $limit = 10, $minIdVisit = false )
+ public function getLastVisits( $idSite, $limit = 10, $minIdVisit = false )
{
- if(is_null($idSite))
- {
- Piwik::checkUserIsSuperUser();
- }
- else
- {
- Piwik::checkUserHasViewAccess($idSite);
- }
- $visitorDetails = self::loadLastVisitorDetailsFromDatabase(null, $idSite, $limit, $minIdVisit);
- $table = self::getCleanedVisitorsFromDetails($visitorDetails);
+ Piwik::checkUserHasViewAccess($idSite);
+ $visitorDetails = $this->loadLastVisitorDetailsFromDatabase($idSite, $visitorId = null, $limit, $minIdVisit);
+ $table = $this->getCleanedVisitorsFromDetails($visitorDetails, $idSite);
return $table;
}
+
+ /*
+ * @return Piwik_DataTable
+ */
+ public function getLastVisitsDetails( $idSite, $limit = 1000, $minIdVisit = false )
+ {
+ Piwik::checkUserHasViewAccess($idSite);
+ $visitorDetails = $this->loadLastVisitorDetailsFromDatabase($idSite, $visitorId = null, $limit, $minIdVisit);
+ $dataTable = $this->getCleanedVisitorsFromDetails($visitorDetails, $idSite);
+ return $dataTable;
+ }
+
+
+ /*
+ * @return Piwik_DataTable
+ */
+ public function getUsersInLastXMin( $idSite, $minutes = 30 )
+ {
+ Piwik::checkUserHasViewAccess($idSite);
+ $visitorData = $this->loadLastVisitorInLastXTimeFromDatabase($idSite, $minutes, $days = 0, self::TYPE_FETCH_VISITS);
+ return $visitorData;
+ }
+
+ /*
+ * @return Piwik_DataTable
+ */
+ public function getUsersInLastXDays( $idSite, $days = 10 )
+ {
+ Piwik::checkUserHasViewAccess($idSite);
+ $visitorData = $this->loadLastVisitorInLastXTimeFromDatabase($idSite, $minutes = 0, $days, self::TYPE_FETCH_VISITS);
+ return $visitorData;
+ }
+
+ /*
+ * @return array
+ */
+ public function getPageImpressionsInLastXDays($idSite, $days = 10)
+ {
+ Piwik::checkUserHasViewAccess($idSite);
+ $visitorData = $this->loadLastVisitorInLastXTimeFromDatabase($idSite, $minutes = 0, $days, self::TYPE_FETCH_PAGEVIEWS);
+ return $visitorData;
+ }
+
+ /*
+ * @return array
+ */
+ public function getPageImpressionsInLastXMin($idSite, $minutes = 30)
+ {
+ Piwik::checkUserHasViewAccess($idSite);
+ $visitorData = $this->loadLastVisitorInLastXTimeFromDatabase($idSite, $minutes, $days = 0, self::TYPE_FETCH_PAGEVIEWS);
+ return $visitorData;
+ }
/*
* @return Piwik_DataTable
*/
- static private function getCleanedVisitorsFromDetails($visitorDetails)
+ private function getCleanedVisitorsFromDetails($visitorDetails, $idSite)
{
$table = new Piwik_DataTable();
+
foreach($visitorDetails as $visitorDetail)
{
- self::cleanVisitorDetails($visitorDetail);
+ $this->cleanVisitorDetails($visitorDetail);
$visitor = new Piwik_Live_Visitor($visitorDetail);
$visitorDetailsArray = $visitor->getAllVisitorDetails();
- $dateTimeVisit = Piwik_Date::factory($visitorDetailsArray['firstActionTimestamp']);
- //TODO TO FIX
+
+ $site = new Piwik_Site($idSite);
+ $timezone = $site->getTimezone();
+ $dateTimeVisit = Piwik_Date::factory($visitorDetailsArray['firstActionTimestamp'], $timezone);
$visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized('%shortDay% %day% %shortMonth%');
$visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized('%time%');
+
+ // get Detail - 100 single SQL Statements - Performance Issue
+ $idvisit = $visitorDetailsArray['idVisit'];
+
+ $sql = "
+ SELECT DISTINCT " .Piwik_Common::prefixTable('log_action').".name AS pageUrl
+ FROM " .Piwik_Common::prefixTable('log_link_visit_action')."
+ INNER JOIN " .Piwik_Common::prefixTable('log_action')."
+ ON " .Piwik_Common::prefixTable('log_link_visit_action').".idaction_url = " .Piwik_Common::prefixTable('log_action').".idaction
+ WHERE " .Piwik_Common::prefixTable('log_link_visit_action').".idvisit = $idvisit;
+ ";
+
+ $visitorDetailsArray['actionDetails'] = Piwik_FetchAll($sql);
+
+ $sql = "
+ SELECT DISTINCT " .Piwik_Common::prefixTable('log_action').".name AS pageUrl
+ FROM " .Piwik_Common::prefixTable('log_link_visit_action')."
+ INNER JOIN " .Piwik_Common::prefixTable('log_action')."
+ ON " .Piwik_Common::prefixTable('log_link_visit_action').".idaction_name = " .Piwik_Common::prefixTable('log_action').".idaction
+ WHERE " .Piwik_Common::prefixTable('log_link_visit_action').".idvisit = $idvisit;
+ ";
+
+ $visitorDetailsArray['actionDetailsTitle'] = Piwik_FetchAll($sql);
$table->addRowFromArray( array(Piwik_DataTable_Row::COLUMNS => $visitorDetailsArray));
}
+
return $table;
}
-
+
/*
* @return array
*/
- private function loadLastVisitorDetailsFromDatabase($visitorId = null, $idSite = null, $limit = null, $minIdVisit = false )
+ private function loadLastVisitorDetailsFromDatabase($idSite, $visitorId = null, $limit = null, $minIdVisit = false )
{
$where = $whereBind = array();
-
- if(!is_null($idSite))
- {
- $where[] = " idsite = ? ";
- $whereBind[] = $idSite;
- }
-
- if(!is_null($visitorId))
+
+ $where[] = Piwik_Common::prefixTable('log_visit') . ".idsite = ? ";
+ $whereBind[] = $idSite;
+
+ if(!empty($visitorId))
{
- $where[] = " visitor_idcookie = ? ";
+ $where[] = Piwik_Common::prefixTable('log_visit') . ".visitor_idcookie = ? ";
$whereBind[] = $visitorId;
}
-
- if(!is_null($minIdVisit))
+
+ if(!empty($minIdVisit))
{
- $where[] = " idvisit > ? ";
+ $where[] = Piwik_Common::prefixTable('log_visit') . ".idvisit > ? ";
$whereBind[] = $minIdVisit;
}
-
+
$sqlWhere = "";
if(count($where) > 0)
{
$sqlWhere = " WHERE " . join(' AND ', $where);
}
-
- $sql = "SELECT *
- FROM " . Piwik::prefixTable('log_visit') . "
- $sqlWhere
- ORDER BY idvisit DESC
+
+ $sql = "SELECT " . Piwik_Common::prefixTable('log_visit') . ".* ,
+ " . Piwik_Common::prefixTable ( 'goal' ) . ".match_attribute
+ FROM " . Piwik_Common::prefixTable('log_visit') . "
+ LEFT JOIN ".Piwik_Common::prefixTable('log_conversion')."
+ ON " . Piwik_Common::prefixTable('log_visit') . ".idvisit = " . Piwik_Common::prefixTable('log_conversion') . ".idvisit
+ LEFT JOIN ".Piwik_Common::prefixTable('goal')."
+ ON (" . Piwik_Common::prefixTable('goal') . ".idsite = " . Piwik_Common::prefixTable('log_visit') . ".idsite
+ AND " . Piwik_Common::prefixTable('goal') . ".idgoal = " . Piwik_Common::prefixTable('log_conversion') . ".idgoal)
+ AND " . Piwik_Common::prefixTable('goal') . ".deleted = 0
+ $sqlWhere
+ ORDER BY idsite,idvisit DESC
LIMIT $limit";
-
+
return Piwik_FetchAll($sql, $whereBind);
}
- /*
+ /**
+ * Load last Visitors PAGES or DETAILS in MINUTES or DAYS from database
*
+ * @param int $idSite
+ * @param int $minutes
+ * @param int $days
+ * @param int $type self::TYPE_FETCH_VISITS or self::TYPE_FETCH_PAGEVIEWS
+ *
+ * @return mixed
+ */
+ private function loadLastVisitorInLastXTimeFromDatabase($idSite, $minutes = 0, $days = 0, $type = false )
+ {
+ $where = $whereBind = array();
+
+ $where[] = " " . Piwik_Common::prefixTable('log_visit') . ".idsite = ? ";
+ $whereBind[] = $idSite;
+
+ if($minutes != 0)
+ {
+ $timeLimit = mktime(date("H"), date("i") - $minutes, 0, date("m"), date("d"), date("Y"));
+ $where[] = " visit_last_action_time > '".date('Y-m-d H:i:s',$timeLimit)."'";
+ }
+
+ if($days != 0)
+ {
+ $timeLimit = mktime(0, 0, 0, date("m"), date("d") - $days + 1, date("Y"));
+ $where[] = " visit_last_action_time > '".date('Y-m-d H:i:s', $timeLimit)."'";
+ }
+
+ $sqlWhere = "";
+ if(count($where) > 0)
+ {
+ $sqlWhere = " WHERE " . join(' AND ', $where);
+ }
+
+ // Details
+ if($type == self::TYPE_FETCH_VISITS)
+ {
+ $sql = "SELECT " . Piwik_Common::prefixTable('log_visit') . ".idvisit
+ FROM " . Piwik_Common::prefixTable('log_visit') . "
+ $sqlWhere
+ ORDER BY idsite,idvisit DESC";
+ }
+ // Pages
+ elseif($type == self::TYPE_FETCH_PAGEVIEWS)
+ {
+ $sql = "SELECT " . Piwik_Common::prefixTable('log_link_visit_action') . ".idaction_url
+ FROM " . Piwik_Common::prefixTable('log_link_visit_action') . "
+ INNER JOIN " . Piwik_Common::prefixTable('log_visit') . "
+ ON " . Piwik_Common::prefixTable('log_visit') . ".idvisit = " . Piwik_Common::prefixTable('log_link_visit_action') . ".idvisit
+ $sqlWhere";
+ }
+ else
+ {
+ // no $type is set --> ERROR
+ throw new Exception("type parameter is not properly set.");
+ }
+
+ // return $sql by fetching
+ return Piwik_FetchAll($sql, $whereBind);
+ }
+
+
+ /**
+ * Removes fields that are not meant to be displayed (md5 config hash)
+ * Or that the user should only access if he is super user (cookie, IP)
+ *
+ * @return void
*/
- static private function cleanVisitorDetails( &$visitorDetails )
+ private function cleanVisitorDetails( &$visitorDetails )
{
- $toUnset = array('config_md5config');
+ $toUnset = array('config_md5config');
if(!Piwik::isUserIsSuperUser())
{
$toUnset[] = 'visitor_idcookie';
@@ -154,4 +295,5 @@ class Piwik_Live_API
}
}
}
+
}
diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php
index 5c60d5a6e3..c35be89d06 100644
--- a/plugins/Live/Controller.php
+++ b/plugins/Live/Controller.php
@@ -1,57 +1,184 @@
<?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$
- *
+ *
* @category Piwik_Plugins
* @package Piwik_Live
*/
/**
- *
* @package Piwik_Live
*/
class Piwik_Live_Controller extends Piwik_Controller
{
- function widget()
+ function __construct()
+ {
+ parent::__construct();
+ $this->idSite = Piwik_Common::getRequestVar('idSite');
+ $this->minIdVisit = Piwik_Common::getRequestVar('minIdVisit', 0, 'int');
+ }
+
+ function index()
{
- $view = Piwik_View::factory('index');
- $this->setGeneralVariablesView($view);
- $view->visitors = $this->getLastVisits($fetch = true);
+ $this->widget(true);
+ }
+
+ public function widget($fetch = false)
+ {
+ $view = Piwik_View::factory('index');
+ $view->idSite = Piwik_Common::getRequestVar('idSite');
+ $view->visitorsCountHalfHour = $this->getUsersInLastXMin(30);
+ $view->visitorsCountToday = $this->getUsersInLastXDays(1);
+ $view->pisHalfhour = $this->getPageImpressionsInLastXMin(30);
+ $view->pisToday = $this->getPageImpressionsInLastXDays(1);
+ $view->visitors = $this->getLastVisitsStart($fetch = true);
+
echo $view->render();
}
-
- function getLastVisits($fetch = false)
+
+ public function getLastVisitsDetails($fetch = false)
+ {
+ $view = Piwik_ViewDataTable::factory('');
+ $view->init( $this->pluginName,
+ __FUNCTION__,
+ 'Live.getLastVisitsDetails',
+ 'getPagesFromVisitId');
+// All colomns in DB which could be shown
+//'ip', 'idVisit', 'countActions', 'isVisitorReturning', 'country', 'countryFlag', 'continent', 'provider', 'providerUrl', 'idSite',
+//'serverDate', 'visitLength', 'visitLengthPretty', 'firstActionTimestamp', 'lastActionTimestamp', 'refererType', 'refererName',
+//'keywords', 'refererUrl', 'searchEngineUrl', 'searchEngineIcon', 'operatingSystem', 'operatingSystemShortName', 'operatingSystemIcon',
+//'browserFamily', 'browserFamilyDescription', 'browser', 'browserIcon', 'screen', 'resolution', 'screenIcon', 'plugins', 'lastActionDateTime',
+//'serverDatePretty', 'serverTimePretty', 'actionDetails'
+
+ $view->setColumnsToDisplay(array(
+ 'idVisit',
+ 'serverDatePretty',
+ 'serverTimePretty',
+ 'ip',
+ 'countActions',
+ 'visitLengthPretty',
+ 'keywords',
+ 'refererUrl',
+ 'operatingSystemShortName',
+ 'browser',
+ 'screen',
+ 'resolution',
+ 'plugins',
+ ));
+
+ $view->setColumnsTranslations(array(
+ 'idVisit' => Piwik_Translate(''),
+ 'serverDatePretty' => Piwik_Translate('Live_Date'),
+ 'serverTimePretty' => Piwik_Translate('Live_Time'),
+ 'ip' => 'IP',
+ 'countActions' => Piwik_Translate('VisitorInterest_ColumnPagesPerVisit'),
+ 'visitLengthPretty' => Piwik_Translate('VisitorInterest_ColumnVisitDuration'),
+ 'keywords' => Piwik_Translate('Referers_ColumnKeyword'),
+ 'refererUrl' => Piwik_Translate('Live_Referrer_URL'),
+ 'operatingSystemShortName' => Piwik_Translate('UserSettings_ColumnOperatingSystem'),
+ 'browser' => Piwik_Translate('UserSettings_ColumnBrowser'),
+ 'screen' => Piwik_Translate('UserSettings_ColumnTypeOfScreen'),
+ 'resolution' => Piwik_Translate('UserSettings_ColumnResolution'),
+ 'plugins' => Piwik_Translate('UserSettings_ColumnPlugin'),
+ ));
+
+ $view->disableSort();
+ $view->setLimit(10);
+ $view->disableExcludeLowPopulation();
+ $view->setSortedColumn('idVisit', 'ASC');
+ $view->disableSearchBox();
+ // "Include low population" link won't be displayed under this table
+ $view->disableExcludeLowPopulation();
+ // disable the tag cloud, pie charts, bar chart icons
+ $view->disableShowAllViewsIcons();
+ // disable the button "show more datas"
+ $view->disableShowAllColumns();
+
+ return $this->renderView($view, $fetch);
+ }
+
+ function getPagesFromVisitId( $fetch = false)
+ {
+ $view = Piwik_ViewDataTable::factory('');
+ $view->init( $this->pluginName,
+ __FUNCTION__,
+ 'Live.getLastVisitsForVisitor',
+ 'getPagesFromVisitId');
+
+ return $this->renderView($view, $fetch);
+ }
+
+ public function getLastVisitsStart($fetch = false)
{
- $idSite = Piwik_Common::getRequestVar('idSite', null, 'int');
- $minIdVisit = Piwik_Common::getRequestVar('minIdVisit', 0, 'int');
- $limit = 10;
- $api = new Piwik_API_Request("method=Live.getLastVisits&idSite=$idSite&limit=$limit&minIdVisit=$minIdVisit&format=php&serialize=0&disable_generic_filters=1");
-
$view = Piwik_View::factory('lastVisits');
- $visitors = $api->process();
- if($minIdVisit == 0)
- {
- $visitors = array_slice($visitors, 3);
- }
- $view->visitors = $visitors;
- $rendered = $view->render($fetch);
+ $view->idSite = Piwik_Common::getRequestVar('idSite');
+ $view->visitors = $this->getLastVisits(10);
+
+ $rendered = $view->render($fetch);
+
if($fetch)
{
return $rendered;
}
echo $rendered;
}
-
- function index()
+
+ public function getLastVisits($limit = 10)
{
- $view = Piwik_View::factory('structure');
- $this->setGeneralVariablesView($view);
- $view->visitors = $this->getLastVisits($fetch = true);
- echo $view->render();
+ $api = new Piwik_API_Request("method=Live.getLastVisits&idSite=$this->idSite&limit=$limit&format=php&serialize=0&disable_generic_filters=1");
+ $visitors = $api->process();
+
+ return $visitors;
+ }
+
+ public function getUsersInLastXMin($minutes = 30) {
+ $api = new Piwik_API_Request("method=Live.getUsersInLastXMin&idSite=".$this->idSite."&minutes=".$minutes."&format=php&serialize=0&disable_generic_filters=1");
+ $visitors_halfhour = $api->process();
+
+ return count($visitors_halfhour);
+ }
+
+ public function getUsersInLastXDays($days = 1) {
+ $api = new Piwik_API_Request("method=Live.getUsersInLastXDays&idSite=$this->idSite&days=$days&format=php&serialize=0&disable_generic_filters=1");
+ $visitors_today = $api->process();
+
+ return count($visitors_today);
+ }
+
+ public function getPageImpressionsInLastXMin($minutes = 30) {
+ $api = new Piwik_API_Request("method=Live.getPageImpressionsInLastXMin&idSite=$this->idSite&minutes=$minutes&format=php&serialize=0&disable_generic_filters=1");
+ $pis_halfhour = $api->process();
+
+ return count($pis_halfhour);
+ }
+
+ public function getPageImpressionsInLastXDays($days = 1) {
+ $api = new Piwik_API_Request("method=Live.getPageImpressionsInLastXDays&idSite=$this->idSite&days=$days&format=php&serialize=0&disable_generic_filters=1");
+ $pis_today = $api->process();
+
+ return count($pis_today);
+ }
+
+ public function ajaxTotalVisitors($fetch = false)
+ {
+ $view = Piwik_View::factory('totalVisits');
+ $view->idSite = Piwik_Common::getRequestVar('idSite');
+ $view->visitorsCountHalfHour = $this->getUsersInLastXMin(30);
+ $view->visitorsCountToday = $this->getUsersInLastXDays(1);
+ $view->pisHalfhour = $this->getPageImpressionsInLastXMin(30);
+ $view->pisToday = $this->getPageImpressionsInLastXDays(1);
+
+ $rendered = $view->render($fetch);
+
+ if($fetch)
+ {
+ return $rendered;
+ }
+ echo $rendered;
}
}
diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php
index f659a8ae0e..4fbec02c54 100644
--- a/plugins/Live/Live.php
+++ b/plugins/Live/Live.php
@@ -1,30 +1,16 @@
<?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$
- *
+ *
* @category Piwik_Plugins
* @package Piwik_Live
*/
/**
- TODO Live! Plugin
- ====
- - api propre
- - html
- - jquery spy
- - make sure only one query is launched at once or what if requests takes more than 10s to succeed?
- - simple stats above in TEXT
- - Security review
- - blog post, push version
-
-//TODO add api to get actions name/count/first/last/etc
- */
-
-/**
*
* @package Piwik_Live
*/
@@ -33,13 +19,34 @@ class Piwik_Live extends Piwik_Plugin
public function getInformation()
{
return array(
- 'name' => 'Live Visitors',
- 'description' => 'Live Visitors!',
+ 'description' => Piwik_Translate('Live_PluginDescription'),
'author' => 'Piwik',
- 'homepage' => 'http://piwik.org/',
- 'version' => '0.1',
+ 'author_homepage' => 'http://piwik.org/',
+ 'version' => Piwik_Version::VERSION,
);
}
-}
-Piwik_AddWidget('Live!', 'Live Visitors!', 'Live', 'widget');
+ function getListHooksRegistered()
+ {
+ return array(
+ 'template_css_import' => 'css',
+ 'WidgetsList.add' => 'addWidget',
+ 'Menu.add' => 'addMenu',
+ );
+ }
+
+ function css()
+ {
+ echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"themes/default/styles.css\" />\n";
+ }
+
+ function addMenu()
+ {
+ Piwik_AddMenu('General_Visitors', 'Live_VisitorLog', array('module' => 'Live', 'action' => 'getLastVisitsDetails'));
+ }
+
+ public function addWidget() {
+ Piwik_AddWidget('Live!', 'Live Visitors!', 'Live', 'widget');
+ }
+
+}
diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php
index 8887566009..1ac82ebddc 100644
--- a/plugins/Live/Visitor.php
+++ b/plugins/Live/Visitor.php
@@ -1,24 +1,22 @@
<?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$
- *
+ *
* @category Piwik_Plugins
* @package Piwik_Live
*/
-// no direct access
-defined('PIWIK_INCLUDE_PATH') or die;
-
/**
* @see plugins/Referers/functions.php
* @see plugins/UserCountry/functions.php
* @see plugins/UserSettings/functions.php
* @see plugins/Provider/functions.php
*/
+
require_once PIWIK_INCLUDE_PATH . '/plugins/Referers/functions.php';
require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php';
require_once PIWIK_INCLUDE_PATH . '/plugins/UserSettings/functions.php';
@@ -34,7 +32,7 @@ class Piwik_Live_Visitor
{
$this->details = $visitorRawData;
}
-
+
function getAllVisitorDetails()
{
return array(
@@ -53,7 +51,7 @@ class Piwik_Live_Visitor
'visitLengthPretty' => $this->getVisitLengthPretty(),
'firstActionTimestamp' => $this->getTimestampFirstAction(),
'lastActionTimestamp' => $this->getTimestampLastAction(),
-
+
'refererType' => $this->getRefererType(),
'refererName' => $this->getRefererTypeName(),
'keywords' => $this->getKeywords(),
@@ -61,7 +59,7 @@ class Piwik_Live_Visitor
'refererName' => $this->getRefererName(),
'searchEngineUrl' => $this->getSearchEngineUrl(),
'searchEngineIcon' => $this->getSearchEngineIcon(),
-
+
'operatingSystem' => $this->getOperatingSystem(),
'operatingSystemShortName' => $this->getOperatingSystemShortName(),
'operatingSystemIcon' => $this->getOperatingSystemIcon(),
@@ -73,14 +71,18 @@ class Piwik_Live_Visitor
'resolution' => $this->getResolution(),
'screenIcon' => $this->getScreenTypeIcon(),
'plugins' => $this->getPlugins(),
+ 'lastActionDateTime' => $this->getDateTimeLastAction(),
+ 'isVisitorGoalConverted' => $this->isVisitorGoalConverted(),
+ 'goalIcon' => $this->getGoalIcon(),
+ 'goalType' => $this->getGoalType(),
);
}
-
+
function getServerDate()
{
- return $this->details['visit_server_date'];
+ return date('Y-m-d', strtotime($this->details['visit_last_action_time']));
}
-
+
function getIp()
{
if(isset($this->details['location_ip']))
@@ -89,17 +91,17 @@ class Piwik_Live_Visitor
}
return false;
}
-
+
function getIdVisit()
{
return $this->details['idvisit'];
}
-
+
function getIdSite()
{
return $this->details['idsite'];
}
-
+
function getNumberOfActions()
{
return $this->details['visit_total_actions'];
@@ -109,42 +111,42 @@ class Piwik_Live_Visitor
{
return $this->details['visit_total_time'];
}
-
+
function getVisitLengthPretty()
{
return Piwik::getPrettyTimeFromSeconds($this->details['visit_total_time']);
}
-
+
function isVisitorReturning()
{
return $this->details['visitor_returning'];
}
-
+
function getTimestampFirstAction()
{
return strtotime($this->details['visit_first_action_time']);
}
-
+
function getTimestampLastAction()
{
return strtotime($this->details['visit_last_action_time']);
}
-
+
function getCountryName()
{
return Piwik_CountryTranslate($this->details['location_country']);
}
-
+
function getCountryFlag()
{
return Piwik_getFlagFromCode($this->details['location_country']);
}
-
+
function getContinent()
{
return Piwik_ContinentTranslate($this->details['location_continent']);
}
-
+
function getRefererType()
{
$map = array(
@@ -159,27 +161,27 @@ class Piwik_Live_Visitor
}
return $map[Piwik_Common::REFERER_TYPE_DIRECT_ENTRY];
}
-
+
function getRefererTypeName()
{
return Piwik_getRefererTypeLabel($this->details['referer_type']);
}
-
+
function getKeywords()
{
return $this->details['referer_keyword'];
}
-
+
function getRefererUrl()
{
- return $this->details['referer_url'];
+ return $this->details['referer_url'];
}
-
+
function getRefererName()
{
- return $this->details['referer_name'];
+ return $this->details['referer_name'];
}
-
+
function getSearchEngineUrl()
{
if($this->getRefererType() == 'searchEngine'
@@ -189,7 +191,7 @@ class Piwik_Live_Visitor
}
return null;
}
-
+
function getSearchEngineIcon()
{
$searchEngineUrl = $this->getSearchEngineUrl();
@@ -202,7 +204,7 @@ class Piwik_Live_Visitor
function getPlugins()
{
- $plugins = array(
+ $plugins = array(
'config_pdf',
'config_flash',
'config_java',
@@ -216,10 +218,10 @@ class Piwik_Live_Visitor
$return = array();
foreach($plugins as $plugin)
{
- if($this->details[$plugin] == 1)
+ if($this->details[$plugin] == 1)
{
$pluginShortName = substr($plugin, 7);
- $return[] = $pluginShortName;
+ $return[] = $pluginShortName;
}
}
return implode(", ", $return);
@@ -229,12 +231,12 @@ class Piwik_Live_Visitor
{
return Piwik_getOSLabel($this->details['config_os']);
}
-
+
function getOperatingSystemShortName()
{
return Piwik_getOSShortLabel($this->details['config_os']);
}
-
+
function getOperatingSystemIcon()
{
return Piwik_getOSLogo($this->details['config_os']);
@@ -244,44 +246,82 @@ class Piwik_Live_Visitor
{
return Piwik_getBrowserTypeLabel($this->getBrowserFamily());
}
-
+
function getBrowserFamily()
{
return Piwik_getBrowserFamily($this->details['config_browser_name']);
}
-
+
function getBrowser()
{
return Piwik_getBrowserLabel($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
}
-
+
function getBrowserIcon()
{
return Piwik_getBrowsersLogo($this->details['config_browser_name'] . ";" . $this->details['config_browser_version']);
}
-
+
function getScreenType()
{
return Piwik_getScreenTypeFromResolution($this->details['config_resolution']);
}
-
+
function getResolution()
{
return $this->details['config_resolution'];
}
-
+
function getScreenTypeIcon()
{
return Piwik_getScreensLogo($this->getScreenType());
}
-
+
function getProvider()
{
return Piwik_getHostnameName($this->details['location_provider']);
}
-
+
function getProviderUrl()
{
return Piwik_getHostnameUrl($this->details['location_provider']);
}
+
+ function getDateTimeLastAction()
+ {
+ return date('Y-m-d H:i:s', strtotime($this->details['visit_last_action_time']));
+ }
+
+ function isVisitorGoalConverted()
+ {
+ return $this->details['visit_goal_converted'];
+ }
+
+ function getGoalType()
+ {
+ if(isset($this->details['match_attribute'])){
+ return $this->details['match_attribute'];
+ }
+ return false;
+ }
+
+ function getGoalIcon()
+ {
+ if(isset($this->details['match_attribute'])){
+ $goalicon = "";
+ switch ($this->details['match_attribute']) {
+ case "url":
+ $goalicon = "plugins/Live/templates/images/goal.png";
+ break;
+ case "file":
+ $goalicon = "plugins/Live/templates/images/download.png";
+ break;
+ case "external_website":
+ $goalicon = "plugins/Live/templates/images/outboundlink.png";
+ break;
+ }
+ return $goalicon;
+ }
+ return false;
+ }
}
diff --git a/plugins/Live/templates/images/download.png b/plugins/Live/templates/images/download.png
new file mode 100644
index 0000000000..1920b1bb22
--- /dev/null
+++ b/plugins/Live/templates/images/download.png
Binary files differ
diff --git a/plugins/Live/templates/images/file0.png b/plugins/Live/templates/images/file0.png
new file mode 100644
index 0000000000..2c6ce30fe3
--- /dev/null
+++ b/plugins/Live/templates/images/file0.png
Binary files differ
diff --git a/plugins/Live/templates/images/file1.png b/plugins/Live/templates/images/file1.png
new file mode 100644
index 0000000000..074e577058
--- /dev/null
+++ b/plugins/Live/templates/images/file1.png
Binary files differ
diff --git a/plugins/Live/templates/images/file2.png b/plugins/Live/templates/images/file2.png
new file mode 100644
index 0000000000..48aeb390f2
--- /dev/null
+++ b/plugins/Live/templates/images/file2.png
Binary files differ
diff --git a/plugins/Live/templates/images/file3.png b/plugins/Live/templates/images/file3.png
new file mode 100644
index 0000000000..0827cabe17
--- /dev/null
+++ b/plugins/Live/templates/images/file3.png
Binary files differ
diff --git a/plugins/Live/templates/images/file4.png b/plugins/Live/templates/images/file4.png
new file mode 100644
index 0000000000..a4c277981e
--- /dev/null
+++ b/plugins/Live/templates/images/file4.png
Binary files differ
diff --git a/plugins/Live/templates/images/file5.png b/plugins/Live/templates/images/file5.png
new file mode 100644
index 0000000000..5701f2b274
--- /dev/null
+++ b/plugins/Live/templates/images/file5.png
Binary files differ
diff --git a/plugins/Live/templates/images/file6.png b/plugins/Live/templates/images/file6.png
new file mode 100644
index 0000000000..5099a0222d
--- /dev/null
+++ b/plugins/Live/templates/images/file6.png
Binary files differ
diff --git a/plugins/Live/templates/images/file7.png b/plugins/Live/templates/images/file7.png
new file mode 100644
index 0000000000..8559758b56
--- /dev/null
+++ b/plugins/Live/templates/images/file7.png
Binary files differ
diff --git a/plugins/Live/templates/images/file8.png b/plugins/Live/templates/images/file8.png
new file mode 100644
index 0000000000..515bd791d7
--- /dev/null
+++ b/plugins/Live/templates/images/file8.png
Binary files differ
diff --git a/plugins/Live/templates/images/file9.png b/plugins/Live/templates/images/file9.png
new file mode 100644
index 0000000000..c06ec15bdb
--- /dev/null
+++ b/plugins/Live/templates/images/file9.png
Binary files differ
diff --git a/plugins/Live/templates/images/goal.png b/plugins/Live/templates/images/goal.png
new file mode 100644
index 0000000000..e4bc611f87
--- /dev/null
+++ b/plugins/Live/templates/images/goal.png
Binary files differ
diff --git a/plugins/Live/templates/images/outboundlink.png b/plugins/Live/templates/images/outboundlink.png
new file mode 100644
index 0000000000..0010931e2c
--- /dev/null
+++ b/plugins/Live/templates/images/outboundlink.png
Binary files differ
diff --git a/plugins/Live/templates/index.tpl b/plugins/Live/templates/index.tpl
index 5c012ea5cc..617dc91660 100644
--- a/plugins/Live/templates/index.tpl
+++ b/plugins/Live/templates/index.tpl
@@ -1,28 +1,49 @@
-<h2>Live! (alpha)</h2>
{literal}
<script type="text/javascript" src="plugins/Live/templates/scripts/spy.js"></script>
<script type="text/javascript" charset="utf-8">
- $(document).ready(function() {
- $('#visits').spy({
- limit: 10,
- ajax: 'index.php?module=Live&idSite=1&action=getLastVisits',
- timeout: 500,
- customParameterName: 'minIdVisit',
- customParameterValueCallback: lastIdVisit,
- fadeInSpeed: 1400 }
- );
+
+ $(document).ready(function() {
+ if($('#_spyTmp').size() == 0) {
+ $('#visitsLive > div:gt(2)').fadeEachDown(); // initial fade
+ $('#visitsLive').spy({
+ limit: 10,
+ ajax: 'index.php?module=Live&idSite={/literal}{$idSite}{literal}&action=getLastVisitsStart',
+ fadeLast: 2,
+ isDupe: check_for_dupe,
+ timeout: 8000,
+ customParameterName: 'minIdVisit',
+ customParameterValueCallback: lastIdVisit,
+ fadeInSpeed: 600
+ });
+ }
});
-
+
+ // first I'm ensuring that 'last' has been initialised (with last.constructor == Object),
+ // then prev.html() == last.html() will return true if the HTML is the same, or false,
+ // if I have a different entry.
+ function check_for_dupe(prev, last)
+ {
+ if (last.constructor == Object) {
+ return (prev.html() == last.html());
+ }
+ else {
+ return 0;
+ }
+ }
+
function lastIdVisit()
{
- return $('#visits > div:lt(2) .idvisit').html();
+ updateTotalVisits();
+ updateVisitBox();
+ return $('#visitsLive > div:lt(2) .idvisit').html();
}
+
var pauseImage = "plugins/Live/templates/images/pause.gif";
var pauseDisabledImage = "plugins/Live/templates/images/pause_disabled.gif";
var playImage = "plugins/Live/templates/images/play.gif";
var playDisabledImage = "plugins/Live/templates/images/play_disabled.gif";
-
+
function onClickPause()
{
$('#pauseImage').attr('src', pauseImage);
@@ -36,50 +57,127 @@
return playSpy();
}
+ // updates the numbers of total visits in startbox
+ function updateTotalVisits()
+ {
+ $("#visitsTotal").load("index.php?module=Live&idSite={/literal}{$idSite}{literal}&action=ajaxTotalVisitors");
+ }
+
+ // updates the visit table, to refresh the already presented visotors pages
+ function updateVisitBox()
+ {
+ $("#visitsLive").load("index.php?module=Live&idSite={/literal}{$idSite}{literal}&action=getLastVisitsStart");
+ }
+
+ /* TOOLTIP */
+ $('#visitsLive label').tooltip({
+ track: true,
+ delay: 0,
+ showURL: false,
+ showBody: " - ",
+ fade: 250
+ });
+
</script>
<style>
-#visits {
+#visitsLive {
text-align:left;
+ font-size:90%;
}
-#visits .datetime, #visits .country, #visits .referer, #visits .settings, #visits .returning {
- float:left;
- margin-right:10px;
- overflow:hidden;
- padding-left:1px;
- max-width:700px;
+#visitsLive .datetime, #visitsLive .country, #visitsLive .referer, #visitsLive .settings, #visitsLive .returning , #visitsLive .countActions{
+ border-bottom:1px solid #C1DAD7;
+ border-right:1px solid #C1DAD7;
+ padding:5px 5px 5px 12px;
+}
+
+#visitsLive .datetime {
+ background:#D4E3ED url(plugins/CoreHome/templates/images/bg_header.jpg) repeat-x scroll 0 0;
+ border-top:1px solid #C1DAD7;
+ color:#6D929B;
+ margin:0;
+ text-align:left;
}
-#visits .datetime {
- width:110px;
+
+#visitsLive .country {
+ color:#4F6B72;
+ background:#FFFFFF url(plugins/CoreHome/templates/images/bullet1.gif) no-repeat scroll 0 0;
}
-#visits .country {
- width:30px;
+
+#visitsLive .referer {
+ background:#F9FAFA none repeat scroll 0 0;
+ color:#797268;
}
-#visits .referer {
- width:200px;
+
+#visitsLive .pagesTitle {
+ display:block;
+ float:left;
+ padding-top: 3px;
}
-#visits .settings {
- width:100px;
+
+#visitsLive .countActions {
+ background:#FFFFFF none repeat scroll 0 0;
+ color:#4F6B72;
}
-#visits .returning {
- width:30px;
+
+#visitsLive .settings {
+ background:#FFFFFF none repeat scroll 0 0;
+ color:#4F6B72;
}
-#visits .visit {
- border-bottom:1px solid #C1DAD7;
- background-color:#F9FAFA;
- padding:10px;
- line-height:24px;
- height:40px;
+
+#visitsLive .returning {
+ background:#F9FAFA none repeat scroll 0 0;
+ color:#797268;
+}
+
+#visitsLive .visit {
+}
+
+#visitsLive .alt {
}
-#visits .alt {
- background-color:#FFFFFF;
+
+#visitsLive .actions {
+ background:#F9FAFA none repeat scroll 0 0;
+ color:#797268;
+ padding:0px 5px 0px 12px;
}
+
</style>
{/literal}
+<div id="visitsTotal">
+ <table class="dataTable" cellspacing="0">
+ <thead>
+ <tr>
+ <th id="label" class="sortable label" style="cursor: auto;">
+ <div id="thDIV">Period<div></th>
+ <th id="label" class="sortable label" style="cursor: auto;">
+ <div id="thDIV">Visits<div></th>
+ <th id="label" class="sortable label" style="cursor: auto;">
+ <div id="thDIV">PageViews<div></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <tr class="">
+ <td class="columnodd">Today</td>
+ <td class="columnodd">{$visitorsCountToday}</td>
+ <td class="columnodd">{$pisToday}</td>
+ </tr>
+ <tr class="">
+ <td class="columnodd">Last 30 minutes</td>
+ <td class="columnodd">{$visitorsCountHalfHour}</td>
+ <td class="columnodd">{$pisHalfhour}</td>
+ </tr>
+ </tbody>
+ </table>
+</div>
+
+<div id='visitsLive'>
{$visitors}
+</div>
<div>
- <a href="#?" onclick="onClickPause();"><img id="pauseImage" border="0" src="plugins/Live/templates/images/pause_disabled.gif"></a>
- <a href="#?" onclick="onClickPlay();"><img id="playImage" border="0" src="plugins/Live/templates/images/play.gif"></a>
-</div> \ No newline at end of file
+ <a href="javascript:void(0);" onclick="onClickPause();"><img id="pauseImage" border="0" src="plugins/Live/templates/images/pause_disabled.gif" /></a>
+ <a href="javascript:void(0);" onclick="onClickPlay();"><img id="playImage" border="0" src="plugins/Live/templates/images/play.gif" /></a>
+</div>
diff --git a/plugins/Live/templates/lastVisits.tpl b/plugins/Live/templates/lastVisits.tpl
index ac515f2d63..e67ab5ec71 100644
--- a/plugins/Live/templates/lastVisits.tpl
+++ b/plugins/Live/templates/lastVisits.tpl
@@ -1,15 +1,35 @@
-<div id="visits">
{foreach from=$visitors item=visitor}
- <div class="visit{if $visitor.idVisit % 2} alt{/if}">
+ <div id="{$visitor.idVisit}" class="visit{if $visitor.idVisit % 2} alt{/if}">
<div style="display:none" class="idvisit">{$visitor.idVisit}</div>
- <div class="datetime">{$visitor.serverDatePretty}<br/>{$visitor.serverTimePretty}</div>
- <div class="country"><img src="{$visitor.countryFlag}" title="{$visitor.country}, Provider {$visitor.provider}"></div>
- <div class="referer">{if $visitor.refererType != 'directEntry'}from <a href="{$visitor.refererUrl}">{$visitor.refererName}</a> {if !empty($visitor.keywords)}"{$visitor.keywords}"{/if}{/if}</div>
- <div class="settings">
- <img src="{$visitor.browserIcon}" title="{$visitor.browser} with plugins {$visitor.plugins} enabled">
- <img src="{$visitor.operatingSystemIcon}" title="{$visitor.operatingSystem}, {$visitor.resolution}">
+ <div class="datetime">
+ {$visitor.serverDatePretty} - {$visitor.serverTimePretty}
+ &nbsp;<img src="{$visitor.countryFlag}" title="{$visitor.country}, Provider {$visitor.provider}" />
+ &nbsp;<img src="{$visitor.browserIcon}" title="{$visitor.browser} with plugins {$visitor.plugins} enabled" />
+ &nbsp;<img src="{$visitor.operatingSystemIcon}" title="{$visitor.operatingSystem}, {$visitor.resolution}" />
+ &nbsp;{if $visitor.isVisitorGoalConverted}<img src="{$visitor.goalIcon}" title="{$visitor.goalType}" />{/if}
+ {if $visitor.isVisitorReturning}&nbsp;<img src="plugins/Live/templates/images/returningVisitor.gif" title="Returning Visitor" />{/if}
+ &nbsp;<label id="" title="IP: {$visitor.ip} - Duration: {$visitor.visitLengthPretty}">more...</label>
+ </div>
+ <!--<div class="settings"></div>-->
+ <div class="referer">
+ {if $visitor.refererType != 'directEntry'}from <a href="{$visitor.refererUrl}" target="_blank">{if !empty($visitor.searchEngineIcon)}<img src="{$visitor.searchEngineIcon}" /> {/if}{$visitor.refererName}</a>
+ {if !empty($visitor.keywords)}"{$visitor.keywords}"{/if}
+ {/if}
+ {if $visitor.refererType == 'directEntry'}Direct entry{/if}
+ </div>
+ <div id="{$visitor.idVisit}_actions" class="settings">
+ <span class="pagesTitle">Pages:</span>&nbsp;
+ {php} $col = 0; {/php}
+ {foreach from=$visitor.actionDetails item=action}
+ {php}
+ $col++;
+ if ($col>=9)
+ {
+ $col=0;
+ }
+ {/php}
+ <a href="{$action.pageUrl}" target="_blank"><img align="middle" src="plugins/Live/templates/images/file{php} echo $col; {/php}.png" title="{$action.pageUrl}" /></a>
+ {/foreach}
</div>
- <div class="returning">{if $visitor.isVisitorReturning}<img src="plugins/Live/templates/images/returningVisitor.gif" title="Returning Visitor">{/if}</div>
</div>
{/foreach}
-</div>
diff --git a/plugins/Live/templates/scripts/spy.js b/plugins/Live/templates/scripts/spy.js
index c2fb38863c..27454fe029 100644
--- a/plugins/Live/templates/scripts/spy.js
+++ b/plugins/Live/templates/scripts/spy.js
@@ -12,12 +12,12 @@ $.fn.spy = function(settings) {
spy.parsing = 0;
spy.waitTimer = 0;
spy.json = null;
-
+
if (!settings.ajax) {
alert("An AJAX/AJAH URL must be set for the spy to work.");
return;
}
-
+
spy.attachHolder = function() {
// not mad on this, but the only way to parse HTML collections
if (o.method == 'html')
@@ -37,7 +37,7 @@ $.fn.spy = function(settings) {
else
return 0;
}
-
+
spy.parse = function(e, r) {
spy.parsing = 1; // flag to stop pull via ajax
if (o.method == 'html') {
@@ -45,7 +45,7 @@ $.fn.spy = function(settings) {
} else if (o.method == 'json') {
eval('spy.json = ' + r); // convert text to json
}
-
+
if ((o.method == 'json' && spy.json.constructor == Array) || o.method == 'html') {
if (spy.parseItem(e)) {
spy.waitTimer = window.setInterval(function() {
@@ -65,7 +65,7 @@ $.fn.spy = function(settings) {
spy.parsing = 0;
}
}
-
+
// returns true if there's more to parse
spy.parseItem = function(e) {
if (o.method == 'html') {
@@ -74,7 +74,7 @@ $.fn.spy = function(settings) {
if (i.size() > 0) {
i.hide();
spy.addItem(e, i);
- }
+ }
return ($('div#_spyTmp').find('div').size() != 0);
} else {
if (spy.json.length) {
@@ -85,20 +85,21 @@ $.fn.spy = function(settings) {
return (spy.json.length != 0);
}
}
-
+
spy.addItem = function(e, i) {
if (! o.isDupe.call(this, i, spy.last)) {
spy.last = i; // note i is a pointer - so when it gets modified, so does spy.last
- $('#' + e.id + ' > div:gt(' + (o.limit - 1) + ')').remove();
+ $('#' + e.id + ' > div:gt(' + (o.limit - 2) + ')').remove();
+ $('#' + e.id + ' > div:gt(' + (o.limit - o.fadeLast - 2) + ')').fadeEachDown();
o.push.call(e, i);
$('#' + e.id + ' > div:first').fadeIn(o.fadeInSpeed);
}
}
-
+
spy.push = function(r) {
$('#' + this.id).prepend(r);
}
-
+
var o = {
limit: (settings.limit || 10),
ajax: settings.ajax,
@@ -109,7 +110,7 @@ $.fn.spy = function(settings) {
fadeInSpeed: (settings.fadeInSpeed || 'slow'), // 1400 = crawl
customParameterName: settings.customParameterName,
customParameterValueCallback: settings.customParameterValueCallback,
- isDupe: (settings.isDupe || spy.isDupe),
+ isDupe: (settings.isDupe || spy.isDupe)
};
spy.attachHolder();
@@ -125,11 +126,22 @@ $.fn.spy = function(settings) {
$.get(o.ajax, parameters, function(r) {
spy.parse(e, r);
});
- }
+ }
}, o.timeout);
});
};
+$.fn.fadeEachDown = function() {
+ var s = this.size()+5;
+ return this.each(function(i) {
+ var o = 1 - (s == 1 ? 0.5 : 0.85/s*(i+1));
+ var e = this.style;
+ if (window.ActiveXObject)
+ e.filter = "alpha(opacity=" + o*100 + ")";
+ e.opacity = o;
+ });
+};
+
function pauseSpy() {
spyRunning = 0; return false;
}
@@ -137,3 +149,6 @@ function pauseSpy() {
function playSpy() {
spyRunning = 1; return false;
}
+
+
+
diff --git a/plugins/Live/templates/structure.tpl b/plugins/Live/templates/structure.tpl
deleted file mode 100644
index a3bbc0f4f6..0000000000
--- a/plugins/Live/templates/structure.tpl
+++ /dev/null
@@ -1,5 +0,0 @@
-{assign var=showSitesSelection value=true}
-{assign var=showPeriodSelection value=false}
-{include file="CoreAdminHome/templates/header.tpl"}
-{include file="Live/templates/index.tpl"}
-
diff --git a/plugins/Live/templates/totalVisits.tpl b/plugins/Live/templates/totalVisits.tpl
new file mode 100644
index 0000000000..a7294d7853
--- /dev/null
+++ b/plugins/Live/templates/totalVisits.tpl
@@ -0,0 +1,26 @@
+<div id="visitsTotal">
+ <table class="dataTable" cellspacing="0">
+ <thead>
+ <tr>
+ <th id="label" class="sortable label" style="cursor: auto;">
+ <div id="thDIV">{'Live_Date'|translate}</div></th>
+ <th id="label" class="sortable label" style="cursor: auto;">
+ <div id="thDIV">{'General_ColumnNbVisits'|translate}</div></th>
+ <th id="label" class="sortable label" style="cursor: auto;">
+ <div id="thDIV">{'General_ColumnPageviews'|translate}</div></th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr class="">
+ <td class="columnodd">{'General_Today'|translate}</td>
+ <td class="columnodd">{$visitorsCountToday}</td>
+ <td class="columnodd">{$pisToday}</td>
+ </tr>
+ <tr class="">
+ <td class="columnodd">{'Live_Last30Minutes'|translate}</td>
+ <td class="columnodd">{$visitorsCountHalfHour}</td>
+ <td class="columnodd">{$pisHalfhour}</td>
+ </tr>
+ </tbody>
+ </table>
+</div>