diff options
author | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-12-03 05:50:14 +0300 |
---|---|---|
committer | vipsoft <vipsoft@59fd770c-687e-43c8-a1e3-f5a4ff64c105> | 2009-12-03 05:50:14 +0300 |
commit | 906fd38bb6bedc4fbe73892ed0b6dc66073906fa (patch) | |
tree | 6a42af5d4b2cee76e28f24194f59fde2d490335c /plugins | |
parent | 0ea7d6d4cf5e9e408152cb05c7f8f1cc02b9f66b (diff) |
refs #44 - check in updated Live plugin by jr-ewing
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Live/API.php | 335 | ||||
-rw-r--r-- | plugins/Live/Controller.php | 138 | ||||
-rw-r--r-- | plugins/Live/Live.php | 30 | ||||
-rw-r--r-- | plugins/Live/Visitor.php | 7 | ||||
-rw-r--r-- | plugins/Live/templates/images/file0.png | bin | 0 -> 535 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file1.png | bin | 0 -> 683 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file2.png | bin | 0 -> 632 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file3.png | bin | 0 -> 661 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file4.png | bin | 0 -> 596 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file5.png | bin | 0 -> 653 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file6.png | bin | 0 -> 654 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file7.png | bin | 0 -> 637 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file8.png | bin | 0 -> 574 bytes | |||
-rw-r--r-- | plugins/Live/templates/images/file9.png | bin | 0 -> 566 bytes | |||
-rw-r--r-- | plugins/Live/templates/index.tpl | 161 | ||||
-rw-r--r-- | plugins/Live/templates/lastVisits.tpl | 40 | ||||
-rw-r--r-- | plugins/Live/templates/scripts/spy.js | 17 | ||||
-rw-r--r-- | plugins/Live/templates/structure.tpl | 5 |
18 files changed, 654 insertions, 79 deletions
diff --git a/plugins/Live/API.php b/plugins/Live/API.php index 8f688ff23b..488455d39c 100644 --- a/plugins/Live/API.php +++ b/plugins/Live/API.php @@ -10,10 +10,14 @@ * @package Piwik_Live */ +// no direct access +defined('PIWIK_INCLUDE_PATH') or die; + /** - * - * @package Piwik_Live + * @see plugins/Referers/functions.php */ +require_once PIWIK_INCLUDE_PATH . '/plugins/Live/Visitor.php'; + class Piwik_Live_API { static private $instance = null; @@ -62,6 +66,8 @@ class Piwik_Live_API */ public function getLastVisits( $idSite = false, $limit = 10, $minIdVisit = false ) { + // for checking given vars + // echo $idSite.'|'.$limit.'|'.$minIdVisit.'<br>'; if(is_null($idSite)) { Piwik::checkUserIsSuperUser(); @@ -72,8 +78,38 @@ class Piwik_Live_API } $visitorDetails = self::loadLastVisitorDetailsFromDatabase(null, $idSite, $limit, $minIdVisit); $table = self::getCleanedVisitorsFromDetails($visitorDetails); +// var_dump($table); return $table; } + + /* + * @return Piwik_DataTable + */ + public function getLastVisitsDetails( $idSite = false, $limit = 1000, $minIdVisit = false ) + { + // for checking given vars + // echo $idSite.'|'.$limit.'|'.$minIdVisit.'<br>'; + if(is_null($idSite)) + { + Piwik::checkUserIsSuperUser(); + } + else + { + Piwik::checkUserHasViewAccess($idSite); + } + $visitorDetails = self::loadLastVisitorDetailsFromDatabase(null, $idSite, $limit, $minIdVisit); + $dataTable = self::getCleanedVisitorsFromDetails($visitorDetails); +//echo "hallo"; +// +// $dataTable->queueFilter('ColumnCallbackAddMetadata', array('operatingSystem', 'icon', 'Piwik_Live_Visitor::getVisitLength()')); + +// echo "<pre>"; +// var_dump($dataTable[0]); +// echo "</pre>"; + + return $dataTable; + } + /* * @return Piwik_DataTable @@ -90,6 +126,18 @@ class Piwik_Live_API //TODO TO FIX $visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized('%shortDay% %day% %shortMonth%'); $visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized('%time%'); + + // get Detail + $idvisit = $visitorDetailsArray['idVisit']; + $sql = "SELECT DISTINCT`" .Piwik::prefixTable('log_action')."`.`name` AS pageUrl + FROM `" .Piwik::prefixTable('log_visit')."` + INNER JOIN `" .Piwik::prefixTable('log_link_visit_action')."` ON `" .Piwik::prefixTable('log_visit')."`.`idvisit` = `" .Piwik::prefixTable('log_link_visit_action')."`.`idvisit` + INNER JOIN `" .Piwik::prefixTable('log_action')."` ON `" .Piwik::prefixTable('log_link_visit_action')."`.`idaction` = `" .Piwik::prefixTable('log_action')."`.`idaction` + WHERE `" .Piwik::prefixTable('log_visit')."`.`idvisit` = $idvisit; + "; + + $visitorDetailsArray['actionDetails'] = Piwik_FetchAll($sql); + $table->addRowFromArray( array(Piwik_DataTable_Row::COLUMNS => $visitorDetailsArray)); } return $table; @@ -100,6 +148,8 @@ class Piwik_Live_API */ private function loadLastVisitorDetailsFromDatabase($visitorId = null, $idSite = null, $limit = null, $minIdVisit = false ) { + // for checking given vars + // echo $visitorId.'|'.$idSite.'|'.$limit.'|'.$minIdVisit.'<br>'; $where = $whereBind = array(); if(!is_null($idSite)) @@ -126,7 +176,7 @@ class Piwik_Live_API $sqlWhere = " WHERE " . join(' AND ', $where); } - $sql = "SELECT * + $sql = "SELECT * FROM " . Piwik::prefixTable('log_visit') . " $sqlWhere ORDER BY idvisit DESC @@ -154,4 +204,283 @@ class Piwik_Live_API } } } + + + + /* + * @return Piwik_DataTable + */ + public function getUsersInLastXMin( $idSite = false, $limit = 10, $minIdVisit = false, $minutes = 30 ) + { + if(is_null($idSite)) + { + Piwik::checkUserIsSuperUser(); + } + else + { + Piwik::checkUserHasViewAccess($idSite); + } + $visitorDetails = self::loadLastVisitorDetailsInLastXMinFromDatabase(null, $idSite, $limit, $minIdVisit, $minutes); + + $table = self::getCleanedVisitorsFromDetails($visitorDetails); + return $table; + } + + /* + * @return Piwik_DataTable + */ + public function getUsersInLastXDays( $idSite = false, $limit = 10, $minIdVisit = false, $days = 10 ) + { + + if(is_null($idSite)) + { + Piwik::checkUserIsSuperUser(); + } + else + { + Piwik::checkUserHasViewAccess($idSite); + } + $visitorDetails = self::loadLastVisitorDetailsInLastXDaysFromDatabase(null, $idSite, $limit, $minIdVisit, $days); + + $table = self::getCleanedVisitorsFromDetails($visitorDetails); + + return $table; + } + + /* + * @return array + */ + public function getPageImpressionsInLastXDays($idSite = false, $limit = 10, $minIdVisit = false, $days = 10){ + // for checking given vars + #echo $idSite.'|'.$limit.'|'.$minIdVisit.'|'.$days.'<br>'; + + if(is_null($idSite)) + { + Piwik::checkUserIsSuperUser(); + } + else + { + Piwik::checkUserHasViewAccess($idSite); + } + $pageDetails = self::loadLastVisitedPagesInLastXDaysFromDatabase(null, $idSite, $limit, $minIdVisit, $days); + + $i = -1; + foreach ($pageDetails as $detail) { + $i++; + if(strlen($pageDetails[$i]['name']) > 30) { + $pageDetails[$i]['name'] = substr($pageDetails[$i]['name'] , 0, 30 - 3).'...'; + } + } + + return $pageDetails; + } + + /* + * @return array + */ + public function getPageImpressionsInLastXMin($idSite = false, $limit = 10, $minIdVisit = false, $minutes = 30){ + + if(is_null($idSite)) + { + Piwik::checkUserIsSuperUser(); + } + else + { + Piwik::checkUserHasViewAccess($idSite); + } + $pageDetails = self::loadLastVisitedPagesInLastXMinFromDatabase(null, $idSite, $limit, $minIdVisit, $minutes); + + $i = -1; + foreach ($pageDetails as $detail) { + $i++; + if(strlen($pageDetails[$i]['name']) > 30) { + $pageDetails[$i]['name'] = substr($pageDetails[$i]['name'] , 0, 30 - 3).'...'; + } + } + return $pageDetails; + } + + + + + /* + * @return array + */ + private function loadLastVisitorDetailsInLastXMinFromDatabase($visitorId = null, $idSite = null, $limit = 1000, $minIdVisit = false, $minutes = 0 ) + { + $where = $whereBind = array(); + + if(!is_null($idSite)) + { + $where[] = " idsite = ? "; + $whereBind[] = $idSite; + } + + if(!is_null($visitorId)) + { + $where[] = " visitor_idcookie = ? "; + $whereBind[] = $visitorId; + } + + if(!is_null($minIdVisit)) + { + $where[] = " idvisit > ? "; + $whereBind[] = $minIdVisit; + } + + 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)."'"; + } + + $sqlWhere = ""; + if(count($where) > 0) + { + $sqlWhere = " WHERE " . join(' AND ', $where); + } + + $sql = "SELECT * + FROM " . Piwik::prefixTable('log_visit') . " + $sqlWhere + ORDER BY idvisit DESC + LIMIT " . $limit; + return Piwik_FetchAll($sql, $whereBind); + } + + /* + * @return array + */ + private function loadLastVisitorDetailsInLastXDaysFromDatabase($visitorId = null, $idSite = null, $limit = 1000, $minIdVisit = false, $days = 0 ) + { + $where = $whereBind = array(); + + if(!is_null($idSite)) + { + $where[] = " idsite = ? "; + $whereBind[] = $idSite; + } + + if(!is_null($visitorId)) + { + $where[] = " visitor_idcookie = ? "; + $whereBind[] = $visitorId; + } + + if(!is_null($minIdVisit)) + { + $where[] = " idvisit > ? "; + $whereBind[] = $minIdVisit; + } + + 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); + } + + $sql = "SELECT * + FROM " . Piwik::prefixTable('log_visit') . " + $sqlWhere + ORDER BY idvisit DESC + LIMIT " . $limit; + + return Piwik_FetchAll($sql, $whereBind); + } + + /* + * @return array + */ + private function loadLastVisitedPagesInLastXMinFromDatabase($visitorId = null, $idSite = null, $limit = null, $minIdVisit = false, $minutes = 0 ) + { + $where = $whereBind = array(); + + if(!is_null($idSite)) + { + $where[] = " idsite = ? "; + $whereBind[] = $idSite; + } + + if(!is_null($visitorId)) + { + $where[] = " visitor_idcookie = ? "; + $whereBind[] = $visitorId; + } + + if(!is_null($minIdVisit)) + { + $where[] = Piwik::prefixTable('log_visit') .".idvisit > ? "; + $whereBind[] = $minIdVisit; + } + + 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)."'"; + } + + $sqlWhere = ""; + if(count($where) > 0) + { + $sqlWhere = " WHERE " . join(' AND ', $where); + } + + $sql = "SELECT " . Piwik::prefixTable('log_link_visit_action') . ".`idaction`," . Piwik::prefixTable('log_action') . ".`idaction`, " . Piwik::prefixTable('log_action') . ".`name` , " . Piwik::prefixTable('log_visit') . ".* + FROM " . Piwik::prefixTable('log_link_visit_action') . " + INNER JOIN " . Piwik::prefixTable('log_action') . " ON " . Piwik::prefixTable('log_link_visit_action') . ".`idaction`= " . Piwik::prefixTable('log_action') . ".`idaction` + INNER JOIN " . Piwik::prefixTable('log_visit') . " ON " . Piwik::prefixTable('log_visit') . ".`idvisit` = " . Piwik::prefixTable('log_link_visit_action') . ".`idvisit` + $sqlWhere"; + return Piwik_FetchAll($sql, $whereBind); + } + + /* + * @return array + */ + private function loadLastVisitedPagesInLastXDaysFromDatabase($visitorId = null, $idSite = null, $limit = null, $minIdVisit = false, $days = 0 ) + { + $where = $whereBind = array(); + + if(!is_null($idSite)) + { + $where[] = " idsite = ? "; + $whereBind[] = $idSite; + } + + if(!is_null($visitorId)) + { + $where[] = " visitor_idcookie = ? "; + $whereBind[] = $visitorId; + } + + 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); + } + + $sql = "SELECT " . Piwik::prefixTable('log_link_visit_action') . ".`idaction`, " . Piwik::prefixTable('log_action') . ".`idaction`, " . Piwik::prefixTable('log_action') . ".`name` , " . Piwik::prefixTable('log_link_visit_action') . ".* + FROM " . Piwik::prefixTable('log_link_visit_action') . " + INNER JOIN " . Piwik::prefixTable('log_action') . " ON " . Piwik::prefixTable('log_link_visit_action') . ".`idaction`= " . Piwik::prefixTable('log_action') . ".`idaction` + INNER JOIN " . Piwik::prefixTable('log_visit') . " ON " . Piwik::prefixTable('log_visit') . ".idvisit=" . Piwik::prefixTable('log_link_visit_action') . ".idvisit + $sqlWhere"; + + return Piwik_FetchAll($sql, $whereBind); + } + } diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php index 5c60d5a6e3..a58cf3f7a3 100644 --- a/plugins/Live/Controller.php +++ b/plugins/Live/Controller.php @@ -16,42 +16,140 @@ */ class Piwik_Live_Controller extends Piwik_Controller { - function widget() + + function __construct() { - $view = Piwik_View::factory('index'); + 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); + $view->visitors = $this->getLastVisitsStart(true); + echo $view->render(); + } + + public function widget($fetch = false) + { + $view = Piwik_View::factory('index'); + $this->setGeneralVariablesView($view); + $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) { - $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_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('label', 'idVisit', 'serverDatePretty', 'serverTimePretty', 'ip', 'countActions', 'visitLengthPretty', 'keywords', 'refererUrl', + 'operatingSystemShortName', 'browser', 'screen', 'resolution', 'plugins' + ) ); + $view->disableSort(); + $view->setLimit(10); + $view->disableExcludeLowPopulation(); + $view->setSortedColumn('idVisit', 'ASC'); + + return $this->renderView($view, $fetch); + } + + + function getPagesFromVisitId( $fetch = false) + { + $view = Piwik_ViewDataTable::factory(''); + $view->init( $this->pluginName, + __FUNCTION__, + 'Live.getLastVisitsForVisitor', + 'getPagesFromVisitId'); + + #$view->disableSearchBox(); + #$view->disableExcludeLowPopulation(); + #$view->setColumnsToDisplay( array('label','nb_visits') ); + #$view->setColumnTranslation('label', Piwik_Translate('Referers_ColumnKeyword')); + + return $this->renderView($view, $fetch); + } + + public function getLastVisitsStart($fetch = false) + { $view = Piwik_View::factory('lastVisits'); - $visitors = $api->process(); - if($minIdVisit == 0) - { - $visitors = array_slice($visitors, 3); - } - $view->visitors = $visitors; + $view->visitors = $this->getLastVisits(10); + $rendered = $view->render($fetch); if($fetch) { return $rendered; } - echo $rendered; + echo $rendered; + } + + public function getLastVisits($limit = 10) + { + $api = new Piwik_API_Request("method=Live.getLastVisits&idSite=$this->idSite&limit=$limit&minIdVisit=$this->minIdVisit&format=php&serialize=0&disable_generic_filters=1"); + $visitors = $api->process(); + + return $visitors; } - function index() + public function getUsersInLastXMin($minutes = 30) { + $api = new Piwik_API_Request("method=Live.getUsersInLastXMin&idSite=".$this->idSite."&limit=10000&minIdVisit=".$this->minIdVisit."&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&limit=50000&minIdVisit=$this->minIdVisit&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&limit=10000&minIdVisit=$this->minIdVisit&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&limit=50000&minIdVisit=$this->minIdVisit&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('structure'); + $view = Piwik_View::factory('totalVisits'); $this->setGeneralVariablesView($view); - $view->visitors = $this->getLastVisits($fetch = true); - echo $view->render(); - } + $view->visitorsCountHalfHour = $this->getUsersInLastXMin(30); + $view->visitorsCountToday = $this->getUsersInLastXDays(1); + $view->pisHalfhour = $this->getPageImpressionsInLastXMin(30); + $view->pisToday = $this->getPageImpressionsInLastXDays(1); + + echo $view->render(); + } + } diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php index f659a8ae0e..fd3dac4cca 100644 --- a/plugins/Live/Live.php +++ b/plugins/Live/Live.php @@ -37,9 +37,31 @@ class Piwik_Live extends Piwik_Plugin 'description' => 'Live Visitors!', 'author' => 'Piwik', 'homepage' => 'http://piwik.org/', - 'version' => '0.1', + 'version' => '0.5', ); } -} - -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', 'VisitorLog', array('module' => 'Live', 'action' => 'getLastVisitsDetails')); + } + + public function addWidget() { + Piwik_AddWidget('Live!', 'Live Visitors!', 'Live', 'widget'); + } + +}
\ No newline at end of file diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php index 8887566009..6afce54ddb 100644 --- a/plugins/Live/Visitor.php +++ b/plugins/Live/Visitor.php @@ -19,6 +19,7 @@ defined('PIWIK_INCLUDE_PATH') or die; * @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'; @@ -73,6 +74,7 @@ class Piwik_Live_Visitor 'resolution' => $this->getResolution(), 'screenIcon' => $this->getScreenTypeIcon(), 'plugins' => $this->getPlugins(), + 'lastActionDateTime' => $this->getDateTimeLastAction(), ); } @@ -284,4 +286,9 @@ class Piwik_Live_Visitor { return Piwik_getHostnameUrl($this->details['location_provider']); } + + function getDateTimeLastAction() + { + return date('Y-m-d H:i:s', strtotime($this->details['visit_last_action_time'])); + } } diff --git a/plugins/Live/templates/images/file0.png b/plugins/Live/templates/images/file0.png Binary files differnew file mode 100644 index 0000000000..2c6ce30fe3 --- /dev/null +++ b/plugins/Live/templates/images/file0.png diff --git a/plugins/Live/templates/images/file1.png b/plugins/Live/templates/images/file1.png Binary files differnew file mode 100644 index 0000000000..074e577058 --- /dev/null +++ b/plugins/Live/templates/images/file1.png diff --git a/plugins/Live/templates/images/file2.png b/plugins/Live/templates/images/file2.png Binary files differnew file mode 100644 index 0000000000..48aeb390f2 --- /dev/null +++ b/plugins/Live/templates/images/file2.png diff --git a/plugins/Live/templates/images/file3.png b/plugins/Live/templates/images/file3.png Binary files differnew file mode 100644 index 0000000000..0827cabe17 --- /dev/null +++ b/plugins/Live/templates/images/file3.png diff --git a/plugins/Live/templates/images/file4.png b/plugins/Live/templates/images/file4.png Binary files differnew file mode 100644 index 0000000000..a4c277981e --- /dev/null +++ b/plugins/Live/templates/images/file4.png diff --git a/plugins/Live/templates/images/file5.png b/plugins/Live/templates/images/file5.png Binary files differnew file mode 100644 index 0000000000..5701f2b274 --- /dev/null +++ b/plugins/Live/templates/images/file5.png diff --git a/plugins/Live/templates/images/file6.png b/plugins/Live/templates/images/file6.png Binary files differnew file mode 100644 index 0000000000..5099a0222d --- /dev/null +++ b/plugins/Live/templates/images/file6.png diff --git a/plugins/Live/templates/images/file7.png b/plugins/Live/templates/images/file7.png Binary files differnew file mode 100644 index 0000000000..8559758b56 --- /dev/null +++ b/plugins/Live/templates/images/file7.png diff --git a/plugins/Live/templates/images/file8.png b/plugins/Live/templates/images/file8.png Binary files differnew file mode 100644 index 0000000000..515bd791d7 --- /dev/null +++ b/plugins/Live/templates/images/file8.png diff --git a/plugins/Live/templates/images/file9.png b/plugins/Live/templates/images/file9.png Binary files differnew file mode 100644 index 0000000000..c06ec15bdb --- /dev/null +++ b/plugins/Live/templates/images/file9.png diff --git a/plugins/Live/templates/index.tpl b/plugins/Live/templates/index.tpl index 5c012ea5cc..a2cd448123 100644 --- a/plugins/Live/templates/index.tpl +++ b/plugins/Live/templates/index.tpl @@ -1,23 +1,45 @@ -<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({ + + $('#visitsLive > div:gt(2)').fadeEachDown(); // initial fade + $('#visitsLive').spy({ limit: 10, - ajax: 'index.php?module=Live&idSite=1&action=getLastVisits', - timeout: 500, + ajax: 'index.php?module=Live&idSite={/literal}{$idSite}{literal}&action=getLastVisitsStart', + fadeLast: 2, + isDupes : check_for_dupe, + timeout: 20000, customParameterName: 'minIdVisit', - customParameterValueCallback: lastIdVisit, - fadeInSpeed: 1400 } - ); - }); - + customParameterValueCallback: lastIdVisit, + fadeInSpeed: 1400 }); + }); + + // 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"; @@ -35,51 +57,116 @@ $('#pauseImage').attr('src', pauseDisabledImage); 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"); + } </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; } -#visits .datetime { - width:110px; + +#visitsLive .datetime { + background:#D4E3ED url(images/bg_header.jpg) repeat-x scroll 0 0; + border-top:1px solid #C1DAD7; + color:#6D929B; + margin:0; + text-align:left; } -#visits .country { - width:30px; + +#visitsLive .country { + color:#4F6B72; + background:#FFFFFF url(images/bullet1.gif) no-repeat scroll 0 0; +} + +#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> + <thead> + <tr> + <tr class="subDataTable"> + <td class="columnodd">Today</td> + <td class="columnodd">{$visitorsCountToday}</td> + <td class="columnodd">{$pisToday}</td> + </tr> + <tr class="subDataTable"> + <td class="columnodd">Last 30 minutes</td> + <td class="columnodd">{$visitorsCountHalfHour}</td> + <td class="columnodd">{$pisHalfhour}</td> + </tr> + </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> + <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>
\ No newline at end of file diff --git a/plugins/Live/templates/lastVisits.tpl b/plugins/Live/templates/lastVisits.tpl index ac515f2d63..f57304d9a5 100644 --- a/plugins/Live/templates/lastVisits.tpl +++ b/plugins/Live/templates/lastVisits.tpl @@ -1,15 +1,37 @@ -<div id="visits"> {foreach from=$visitors item=visitor} <div class="visit{if $visitor.idVisit % 2} alt{/if}"> + <!--<div class="idvisit">{$visitor.idVisit}</div>--> <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} + <img src="{$visitor.countryFlag}" title="{$visitor.country}, Provider {$visitor.provider}"> + <img src="{$visitor.browserIcon}" title="{$visitor.browser} with plugins {$visitor.plugins} enabled"> + <img src="{$visitor.operatingSystemIcon}" title="{$visitor.operatingSystem}, {$visitor.resolution}"> + </div> + <div class="settings"> + {$visitor.ip} + {if $visitor.isVisitorReturning}<img src="plugins/Live/templates/images/returningVisitor.gif" title="Returning Visitor">{/if} + </div> + <div class="referer"> + {if $visitor.refererType != 'directEntry'}from <a href="{$visitor.refererUrl}"><img src="{$visitor.searchEngineIcon}"> {$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="actions"> + <span class="pagesTitle">Pages:</span> + {php} $col = 0; {/php} + {foreach from=$visitor.actionDetails item=action} + {php} + $col++; + if ($col>=9) + { + $col=0; + } + {/php} + <img align="middle" src="plugins/Live/templates/images/file{php} echo $col; {/php}.png" title="{$action.pageUrl}"> + {/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..ad0f7473d3 100644 --- a/plugins/Live/templates/scripts/spy.js +++ b/plugins/Live/templates/scripts/spy.js @@ -89,7 +89,8 @@ $.fn.spy = function(settings) { 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); } @@ -130,6 +131,17 @@ $.fn.spy = function(settings) { }); }; +$.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"} - |