From 622b3324b2c0ce293048d1fd2ba0c2b976fb4597 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 15 Sep 2010 15:34:06 +0000 Subject: [PATCH] --- inc/extranet/Controlleur/_common.php | 1 + .../Controlleur/class.extranet.page.php | 8 +- .../Controlleur/class.extranet.shortcuts.php | 38 +++++ inc/ws/Controlleur/class.ws.stats.php | 142 ++++++++++-------- style/ws/style.css | 6 + 5 files changed, 134 insertions(+), 61 deletions(-) create mode 100644 inc/extranet/Controlleur/class.extranet.shortcuts.php diff --git a/inc/extranet/Controlleur/_common.php b/inc/extranet/Controlleur/_common.php index 04d56d838..d1da641e7 100644 --- a/inc/extranet/Controlleur/_common.php +++ b/inc/extranet/Controlleur/_common.php @@ -6,6 +6,7 @@ $__autoload['extranetPage'] = dirname(__FILE__) . '/class.extranet.page.php'; $__autoload['extranetUrl'] = dirname(__FILE__) . '/class.extranet.url.php'; $__autoload['extranetDroits'] = dirname(__FILE__) . '/class.extranet.droits.php'; $__autoload['extranetFiltre'] = dirname(__FILE__) . '/class.extranet.filtre.php'; +$__autoload['extranetShortcuts'] = dirname(__FILE__) . '/class.extranet.shortcuts.php'; $__autoload['extranetPageChiffres'] = dirname(__FILE__) . '/class.extranet.page.chiffres.php'; ?> \ No newline at end of file diff --git a/inc/extranet/Controlleur/class.extranet.page.php b/inc/extranet/Controlleur/class.extranet.page.php index 00d7fa6d4..4497bfdcc 100644 --- a/inc/extranet/Controlleur/class.extranet.page.php +++ b/inc/extranet/Controlleur/class.extranet.page.php @@ -98,10 +98,16 @@ class extranetPage { if (!is_null($filtres) && is_array($filtres)) { $res .= '
'; + $hasRealFilters = false; foreach($filtres as $filtre) { $res .= $filtre->display(); + if ($filtre instanceof extranetFiltre) { + $hasRealFilters = true; + } + } + if ($hasRealFilters) { + $res .= ''; } - $res .= ''; $res .= '
'; } $res .= ''; diff --git a/inc/extranet/Controlleur/class.extranet.shortcuts.php b/inc/extranet/Controlleur/class.extranet.shortcuts.php new file mode 100644 index 000000000..dbb2487ad --- /dev/null +++ b/inc/extranet/Controlleur/class.extranet.shortcuts.php @@ -0,0 +1,38 @@ +titre = $titre; + $this->values = $values; + $this->selectedValue=$selectedValue; + } + + public function display() + { + // $limit = 20; + // $t = (mb_strlen($titre) > $limit)?mb_substr($titre, 0, $limit-4) . '...':$titre; + $res = '
'; + $res .= '' . $this->titre . ''; + $res .= '
'.$this->selectedValue.'' ; + $res .= '' . cubeMedia::spacer(155, 18) . ''; + $res .= '
'; + $res .= ''; + $res .= '
'; + return $res; + } +} + +?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.stats.php b/inc/ws/Controlleur/class.ws.stats.php index 30d7eb889..8ba762132 100644 --- a/inc/ws/Controlleur/class.ws.stats.php +++ b/inc/ws/Controlleur/class.ws.stats.php @@ -4,9 +4,47 @@ class wsStats { public static function display($bid, $annee = null, $mois = null) { + global $core; + cubePHP::set_memory('512M'); - $res = extranetPage::barre(); + $global = self::load_stats($bid); + + $actions = array(); + $actions[] = '' . $core->typo->Ajouter('Exporter au format Excel') . ''; + + $years = $global->year; + $annees = array('' . __('Toutes') . '' => SITE_PATH . 'stats/' . $bid); + + $listeShortcuts = array(); + + $listeMois = null; + foreach($years as $y) { + $selectedYear = __('Toutes'); + if (!is_null($annee) && $annee == (string)$y['year']) { + $months = $y->month; + $moiss = array('' . __('Tous') . '' => SITE_PATH . 'stats/' . $bid . '/' . (string)$y['year']); + $selectedMonth = __('Tous'); + foreach($months as $m) { + if ((string)$m['month'] == $mois) { + $selectedMonth = cubeDate::getMonth((string)$m['month']); + } + $moiss[cubeDate::getMonth((string)$m['month'])] = SITE_PATH . 'stats/' . $bid . '/' . (string)$y['year'] . '/' . (string)$m['month']; + } + $listeMois = new extranetShortcuts(__('Mois'), $moiss, $selectedMonth); + } + if ((string)$y['year'] == $annee) { + $selectedYear = $annee; + } + $annees[(string)$y['year']] = SITE_PATH . 'stats/' . $bid . '/' . (string)$y['year']; + } + $listeAnnees = new extranetShortcuts(__('Année'), $annees, $selectedYear); + $listeShortcuts[] = $listeAnnees; + if (!is_null($listeMois)) { + $listeShortcuts[] = $listeMois; + } + + $res = extranetPage::barre($listeShortcuts, 'filtreStats', 'stats'/*, $actions*/); $res .= extranetPage::tMain(); if (is_null($annee) && is_null($mois)) { $res .= self::vue_globale($bid); @@ -123,7 +161,6 @@ class wsStats { self::linksSort($xml, $res); self::searchesSort($xml, $res); self::countriesSort($xml, $res); - return $res; } @@ -226,11 +263,9 @@ class wsStats { $res = ''; $res .= ''; $res .= ''; - $res .= ''; $res .= ''; $res .= ''; - $res .= ''; $i = 1; if ($afriend) { @@ -283,10 +318,8 @@ class wsStats { public static function vue_globale($bid, $annee = null) { global $core; - $book = self::getBook($bid); $extra = self::getExtra($book->extras); - if (is_null($annee)) { $stats = self::load_stats($bid); } else { @@ -298,52 +331,56 @@ class wsStats { } self::getActives($stats, $book, $aextra, $adown, $adownp, $aprint, $afriend); - $res = extranetPage::bh('stats_global'); - $titre = __('Statistiques de la publication « %s »'); $date_creation = __('Date de création de la publication'); - $res .= self::globalDatas(sprintf($titre, $book->nom), $date_creation, $book, $stats, $afriend, $aprint, $adown, $adownp, $aextra); $res .= extranetPage::bf(); - - $res .= extranetPage::bh('stats_detail_mois'); - $res .= '
' . $core->typo->Titre($titre) . '
' . $date_creation . '' . date(__('d-m-Y'), $book->date) . '
' . __('Nombre de lieux de visite') . '' . $stats['places'] . '
' . __('Nombre de visiteurs uniques') . '' . $stats['visitors'] . '
' . __('Nombre de visites') . '' . $stats['visits'] . '
' . __('Nombre de pages vues') . '' . $stats['pages'] . '
'; - $res .= ''; - $res .= ''; - - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; + $tcol = ''; + $cols = 0; + $tcol .= ''; + $tcol .= ''; + $tcol .= ''; + $tcol .= ''; + $tcol .= ''; + $cols = 5; if ($afriend) { - $res .= ''; + $tcol .= ''; + $cols++; } - $res .= ''; + $tcol .= ''; + $cols++; if ($aprint) { - $res .= ''; + $tcol .= ''; + $cols++; } if ($adown) { - $res .= ''; + $tcol .= ''; + $cols++; } if ($adownp) { - $res .= ''; + $tcol .= ''; + $cols++; } if ($aextra) { - $res .= ''; + $tcol .= ''; + $cols++; } - $res .= ''; - + $tcol .= ''; + $res .= extranetPage::bh('stats_detail_mois'); + $res .= '
' . $core->typo->Titre(__('Détail par mois')) . '
'; - $res .= '
' ; - if (is_null($annee)) { - $res .= self::graph_global($bid, $stats); - } else { - $res .= self::graph_annuel($bid, $annee, $stats); - } - $res .= '
'; - $res .= '
' . __('Période') . '' . __('Lieux de visite') . '' . __('Visiteurs uniques') . '' . __('Visites') . '' . __('Pages vues') . '
' . __('Période') . '' . __('Lieux de visite') . '' . __('Visiteurs uniques') . '' . __('Visites') . '' . __('Pages vues') . '' . __('Liens envoyés') . '' . __('Liens envoyés') . '' . __('Liens cliqués') . '' . __('Liens cliqués') . '' . __('Impressions') . '' . __('Impressions') . '' . __('Téléchargements') . '' . __('Téléchargements') . '' . __('Téléchargements partiels') . '' . __('Téléchargements partiels') . '' . $extra . '' . $extra . '
'; + $res .= ''; + $res .= ''; + $res .= $tcol; if (is_null($annee)) { $years = $stats->year; } else { @@ -377,7 +414,6 @@ class wsStats { } foreach($year->month as $month) { $res .= ''; - $res .= ''; $res .= ''; $res .= ''; @@ -411,7 +447,6 @@ class wsStats { global $core; $img = SYSIMG . '/stats/global-' . $bid . '.png'; $imgw = IMG . '/stats/global-' . $bid . '.png'; - $s = array(); foreach ($stats->year as $year) { foreach($year->month as $month) { @@ -636,18 +671,14 @@ class wsStats { { $datestocorrect = array(mktime(0, 0, 0, 11, 23, 2009), mktime(0, 0, 0, 12, 8, 2009), mktime(0, 0, 0, 12, 9, 2009)); global $core; - $book = self::getBook($bid); - $extra = self::getExtra($book->extras); $stats = self::load_stats($bid, $annee, $mois); - if (is_null($stats)) { return self::indisponible(); } self::getActives($stats, $book, $aextra, $adown, $adownp, $aprint, $afriend); - $time_page = mktime(0, 0, 0, $mois, 15, $annee); $res = extranetPage::bh('stats_global'); $titre = __('Statistiques de la publication « %s »'); @@ -659,20 +690,16 @@ class wsStats { $res .= '
' . $core->typo->Titre(__('Détail par mois')) . '
'; + $res .= '
' ; + if (is_null($annee)) { + $res .= self::graph_global($bid, $stats); + } else { + $res .= self::graph_annuel($bid, $annee, $stats); + } + $res .= '
'; + $res .= '
' . strftime('%B %Y', mktime(0, 0, 0, (string)$month['month'], 15, (string)$month['year'])) . '' . $month['places'] . '' . $month['visitors'] . '' . $month['visits'] . '
'; $res .= ''; $res .= ''; - $res .= ''; - $res .= ''; $res .= ''; $res .= ''; $res .= ''; $res .= ''; - - $i=0; + $i = 0; foreach ($stats->days->day as $day) { - $odd=cubeMath::isOdd($i)?' class="odd"':''; - $res .= ''; - + $odd = cubeMath::isOdd($i)?' class="odd"':''; + $res .= ''; $res .= ''; $res .= ''; $res .= ''; @@ -682,7 +709,6 @@ class wsStats { $i++; } $res .= '
' . $core->typo->Titre(__('Détail par jour') . ' - ' . strftime('%B %Y', $time_page)) . '
' . __('Jour') . '' . __('Lieux de visite') . '' . __('Visiteurs uniques') . '' . __('Visites') . '' . __('Pages vues') . '' . __('Liens cliqués') . '
' . strftime('%A %d', mktime(0, 0, 0, $mois, (string)$day['day'], $annee)) . '' . strftime('%A %d', mktime(0, 0, 0, $mois, (string)$day['day'], $annee)) . '' . $day['places'] . '' . $day['visitors'] . '' . $day['visits'] . '
'; - $res .= extranetPage::bf(); $res .= extranetPage::bh('stats_detail_pages'); $res .= ''; @@ -700,7 +726,7 @@ class wsStats { $res .= ''; } - $i=0; + $i = 0; foreach ($stats->pages->page as $page) { $p = (string)$page['page']; if ($p > $book->pages || cubeMath::isOdd($p)) { @@ -715,8 +741,8 @@ class wsStats { $pagen .= '-'; $pagen .= ($p + 1); } - $odd=cubeMath::isOdd($i)?' class="odd"':''; - $res .= ''; + $odd = cubeMath::isOdd($i)?' class="odd"':''; + $res .= ''; if ($book->parametres->stats_score == 1) { $res .= ''; } @@ -731,7 +757,6 @@ class wsStats { $i++; } $res .= '
' . __('Impressions') . '
' . $pagen . '' . $pagen . '' . $page['score'] . '
'; - $res .= extranetPage::bf(); if ($book->parametres->search == 0) { $idl = 'stats_links_2'; @@ -743,7 +768,6 @@ class wsStats { $res .= '
'; $res .= extranetPage::bh($idl); - $res .= ''; $res .= ''; $res .= ''; @@ -764,7 +788,6 @@ class wsStats { $i++; } $res .= '
' . $core->typo->Titre(__('Liens les plus cliqués')) . '
' . __('URL') . '' . __('Clics') . '
'; - $res .= extranetPage::bf(); if ($book->parametres->search == 1) { $res .= extranetPage::bh('stats_search'); @@ -773,9 +796,9 @@ class wsStats { $res .= '' . __('Mot') . '' . __('Recherches') . ''; $i = 0; foreach ($stats->searches->search as $search) { - $q=$search['query']; - if(strlen($q)>25){ - $q=''.substr($q,0,25).' ...'; + $q = $search['query']; + if (strlen($q) > 25) { + $q = '' . substr($q, 0, 25) . ' ...'; } $odd = cubeMath::isOdd($i)?' class="odd"':''; @@ -790,7 +813,6 @@ class wsStats { $res .= ''; $res .= ''; $res .= ''; - $i = 0; foreach ($stats->countries->country as $country) { $pays = $country['code']; diff --git a/style/ws/style.css b/style/ws/style.css index cd9999f47..7b1e5667a 100644 --- a/style/ws/style.css +++ b/style/ws/style.css @@ -310,6 +310,12 @@ input[type="text"],input[type="password"],select,textarea{ .filtre .input.active{ font-weight:bold; } +.filtre a{ + color:#5f6162; + text-decoration:none; + height:23px; +} + .filtre ul{ display:none; position:absolute; -- 2.39.5
' . $core->typo->Titre(__('Origine des visiteurs')) . '
' . __('Pays') . '' . __('Visiteurs') . '