]> _ Git - cubeextranet.git/commitdiff
(no commit message)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 15 Nov 2010 13:53:29 +0000 (13:53 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Mon, 15 Nov 2010 13:53:29 +0000 (13:53 +0000)
inc/extranet/Controlleur/class.extranet.shortcuts.php
inc/ws/Controlleur/class.ws.stats.php
inc/ws/Controlleur/class.ws.url.php

index dbb2487ad1dac11eb7852b45fdd7f7ad81634886..13b1183817d3e5bf4a863f009e093467d16ae132 100644 (file)
@@ -18,8 +18,8 @@ class extranetShortcuts {
                // $t = (mb_strlen($titre) > $limit)?mb_substr($titre, 0, $limit-4) . '...':$titre;\r
                $res = '<div class="filtre">';\r
                $res .= '<span>' . $this->titre . '</span>';\r
-               $res .= '<div class="input' . $class . '"><span><strong>'.$this->selectedValue.'</strong></span>' ;\r
-               $res .= '<a href="#" class="bt" title="' . $titre . '">' . cubeMedia::spacer(155, 18) . '</a>';\r
+               $res .= '<div class="input"><span><strong>'.$this->selectedValue.'</strong></span>' ;\r
+               $res .= '<a href="#" class="bt" title="' . $this->titre . '">' . cubeMedia::spacer(155, 18) . '</a>';\r
                $res .= '</div>';\r
                $res .= '<ul>';\r
                $last = count($this->values)-1;\r
index 8ba76213227a7cc7c505f0ae7a721a55aa17e8ab..4e5518b40b32ed593f63df5d22c1c527b583a7c3 100644 (file)
@@ -10,8 +10,16 @@ class wsStats {
 \r
                $global = self::load_stats($bid);\r
 \r
+               $exporturl = SITE_PATH . 'statsxls/' . $bid;\r
+               if (!is_null($annee)) {\r
+                       $exporturl .= '/' . $annee;\r
+                       if (!is_null($mois)) {\r
+                               $exporturl .= '/' . $mois;\r
+                       }\r
+               }\r
+\r
                $actions = array();\r
-               $actions[] = '<a href="' . SITE_PATH . 'stats/' . $bid . '/exportExcel' . '">' . $core->typo->Ajouter('Exporter au format Excel') . '</a>';\r
+               $actions[] = '<a href="' . $exporturl . '">' . $core->typo->Ajouter('Exporter au format Excel') . '</a>';\r
 \r
                $years = $global->year;\r
                $annees = array('<em>' . __('Toutes') . '</em>' => SITE_PATH . 'stats/' . $bid);\r
@@ -44,7 +52,7 @@ class wsStats {
                        $listeShortcuts[] = $listeMois;\r
                }\r
 \r
-               $res = extranetPage::barre($listeShortcuts, 'filtreStats', 'stats'/*, $actions*/);\r
+               $res = extranetPage::barre($listeShortcuts, 'filtreStats', 'stats', $actions);\r
                $res .= extranetPage::tMain();\r
                if (is_null($annee) && is_null($mois)) {\r
                        $res .= self::vue_globale($bid);\r
@@ -57,6 +65,24 @@ class wsStats {
                return $res;\r
        }\r
 \r
+       public static function exportXLS($bid, $annee = null, $mois = null)\r
+       {\r
+               $xls = new PHPExcel();\r
+               if (is_null($annee)) {\r
+                       // Export global\r
+               } else if (is_null($mois)) {\r
+                       // Export annee\r
+               } else {\r
+                       // Export mois\r
+               }\r
+\r
+               cubeHTTP::forceDownload('stats_' . $bid . '.xls', false);\r
+       }\r
+\r
+       public static function addSheetFromTable()\r
+       {\r
+       }\r
+\r
        public static function getExtra($extra)\r
        {\r
                $xml = simplexml_load_string('<extra>' . $extra . '</extra>');\r
@@ -257,47 +283,80 @@ class wsStats {
                $afriend = ($book->parametres->friend == 1);\r
        }\r
 \r
-       public static function globalDatas($titre, $date_creation, $book, $stats, $afriend, $aprint, $adown, $adownp, $aextra)\r
+       public static function table($title, $colsTitles, $lines, $class, $firstColMax = true, $firstLineBold = false, $noOdd = false)\r
        {\r
                global $core;\r
-               $res = '<table class="liste max">';\r
-               $res .= '<tr><th colspan="2">' . $core->typo->Titre($titre) . '</th></tr>';\r
-               $res .= '<tr><td>' . $date_creation . '</td><td class="stats_col">' . date(__('d-m-Y'), $book->date) . '</td></tr>';\r
-               $res .= '<tr class="odd"><td>' . __('Nombre de lieux de visite') . '</td><td class="stats_col">' . $stats['places'] . '</td></tr>';\r
-               $res .= '<tr><td>' . __('Nombre de visiteurs uniques') . '</td><td class="stats_col">' . $stats['visitors'] . '</td></tr>';\r
-               $res .= '<tr class="odd"><td>' . __('Nombre de visites') . '</td><td class="stats_col">' . $stats['visits'] . '</td></tr>';\r
-               $res .= '<tr><td>' . __('Nombre de pages vues') . '</td><td class="stats_col">' . $stats['pages'] . '</td></tr>';\r
-               $i = 1;\r
+               if (is_string($class)) {\r
+                       $class = array($class);\r
+               }\r
+               $res = '<table class="' . implode(' ', $class) . '">';\r
+               // Titre\r
+               $res .= '<tr><th colspan="' . count($colsTitles) . '">' . $core->typo->Titre($title) . '</th></tr>';\r
+               // Head\r
+               if (implode('', $colsTitles) != '') {\r
+                       $res .= '<tr>';\r
+                       foreach($colsTitles as $i => $title) {\r
+                               $max = ($firstColMax && $i == 0)?'':' class="stats_col"';\r
+                               $res .= '<th' . $max . '>' . $title . '</th>';\r
+                       }\r
+                       $res . '</tr>';\r
+               }\r
+               // Body\r
+               foreach($lines as $i => $line) {\r
+                       $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
+                       if ($firstLineBold && $i == 0) {\r
+                               $odd = ' class="odd"';\r
+                       } elseif ($firstLineBold) {\r
+                               $odd = '';\r
+                       }\r
+                       if ($noOdd) {\r
+                               $odd = '';\r
+                       }\r
+                       $res .= '<tr' . $odd . '>';\r
+                       foreach($line as $j => $cell) {\r
+                               $max = ($firstColMax && $j == 0)?'':' class="stats_col"';\r
+                               if ($firstLineBold && $i == 0) {\r
+                                       $cell = '<strong>' . $cell . '</strong>';\r
+                               }\r
+                               $res .= '<td' . $max . '>' . $cell . '</td>';\r
+                       }\r
+                       $res .= '</tr>';\r
+               }\r
+\r
+               $res .= '</table>';\r
+\r
+               return $res;\r
+       }\r
+\r
+       public static function globalDatas($titre, $date_creation, $book, $stats, $afriend, $aprint, $adown, $adownp, $aextra)\r
+       {\r
+               $colsTitles = array('', '');\r
+               $lines = array();\r
+               $class = array('liste', 'max');\r
+\r
+               $lines[] = array($date_creation, date(__('d-m-Y'), $book->date));\r
+               $lines[] = array(__('Nombre de lieux de visite'), $stats['places']);\r
+               $lines[] = array(__('Nombre de visiteurs uniques'), $stats['visitors']);\r
+               $lines[] = array(__('Nombre de visites'), $stats['visits']);\r
+               $lines[] = array(__('Nombre de pages vues'), $stats['pages']);\r
                if ($afriend) {\r
-                       $odd = $i % 2 == 1?' class="odd"':'';\r
-                       $i++;\r
-                       $res .= '<tr' . $odd . '><td>' . __('Nombre de liens envoyés') . '</td><td class="stats_col">' . $stats['friends'] . '</td></tr>';\r
+                       $lines[] = array(__('Nombre de liens envoyés'), $stats['friends']);\r
                }\r
-               $odd = $i % 2 == 1?' class="odd"':'';\r
-               $i++;\r
-               $res .= '<tr' . $odd . '><td>' . __('Nombre de liens cliqués') . '</td><td class="stats_col">' . $stats['links'] . '</td></tr>';\r
+               $lines[] = array(__('Nombre de liens cliqués'), $stats['links']);\r
                if ($aprint) {\r
-                       $odd = $i % 2 == 1?' class="odd"':'';\r
-                       $i++;\r
-                       $res .= '<tr' . $odd . '><td>' . __("Nombre d'impressions") . '</td><td class="stats_col">' . $stats['prints'] . '</td></tr>';\r
+                       $lines[] = array(__("Nombre d'impressions"), $stats['prints']);\r
                }\r
                if ($adown) {\r
-                       $odd = $i % 2 == 1?' class="odd"':'';\r
-                       $i++;\r
-                       $res .= '<tr' . $odd . '><td>' . __('Nombre de téléchargements') . '</td><td class="stats_col">' . $stats['downloads'] . '</td></tr>';\r
+                       $lines[] = array(__('Nombre de téléchargements'), $stats['downloads']);\r
                }\r
                if ($adownp) {\r
-                       $odd = $i % 2 == 1?' class="odd"':'';\r
-                       $i++;\r
-                       $res .= '<tr' . $odd . '><td>' . __('Nombre de téléchargements partiels') . '</td><td class="stats_col">' . $stats['partDownloads'] . '</td></tr>';\r
+                       $lines[] = array(__('Nombre de téléchargements partiels'), $stats['partDownloads']);\r
                }\r
                if ($aextra) {\r
-                       $odd = $i % 2 == 1?' class="odd"':'';\r
-                       $i++;\r
-                       $res .= '<tr' . $odd . '><td>' . __('Accès à la rubrique') . ' ' . $extra . '</td><td class="stats_col">' . $stats['extras'] . '</td></tr>';\r
+                       $lines[] = array(__('Accès à la rubrique') . ' ' . $extra, $stats['extras']);\r
                }\r
-               $res .= '</table>';\r
-               return $res;\r
+\r
+               return self::table($titre, $colsTitles , $lines , $class);\r
        }\r
 \r
        public static function indisponible()\r
@@ -336,233 +395,303 @@ class wsStats {
                $date_creation = __('Date de création de la publication');\r
                $res .= self::globalDatas(sprintf($titre, $book->nom), $date_creation, $book, $stats, $afriend, $aprint, $adown, $adownp, $aextra);\r
                $res .= extranetPage::bf();\r
-               $tcol = '';\r
-               $cols = 0;\r
-               $tcol .= '<tr><th class="stats_col max">' . __('Période') . '</th>';\r
-               $tcol .= '<th class="stats_col">' . __('Lieux de visite') . '</th>';\r
-               $tcol .= '<th class="stats_col">' . __('Visiteurs uniques') . '</th>';\r
-               $tcol .= '<th class="stats_col">' . __('Visites') . '</th>';\r
-               $tcol .= '<th class="stats_col">' . __('Pages vues') . '</th>';\r
-               $cols = 5;\r
+               $res .= extranetPage::bh();\r
+               $res .= '<table class="liste max">';\r
+               $res .= '<tr><th>' . $core->typo->Titre(__('Détail par mois')) . '</th></tr>';\r
+               $res .= '<tr><th>';\r
+               $res .= '<div class="center" style="width:944px;margin:0 auto;position:relative;">' ;\r
+               if (is_null($annee)) {\r
+                       $res .= self::graph_global($bid, $stats);\r
+               } else {\r
+                       $res .= self::graph_annuel($bid, $annee, $stats);\r
+               }\r
+               $res .= '</div>';\r
+               $res .= '</th></tr>';\r
+               $res .= '</table>';\r
+               $res .= self::detailPeriode($book, $stats, $bid, $annee);\r
+               $res .= extranetPage::bf();\r
+               return $res;\r
+       }\r
+\r
+       /**\r
+        * wsStats::vue_annuelle()\r
+        *\r
+        * @param mixed $bid\r
+        * @param mixed $annee\r
+        * @return\r
+        */\r
+       public static function vue_annuelle($bid, $annee)\r
+       {\r
+               return self::vue_globale($bid, $annee);\r
+       }\r
+       public static function vue_mensuelle($bid, $annee, $mois)\r
+       {\r
+               $datestocorrect = array(mktime(0, 0, 0, 11, 23, 2009), mktime(0, 0, 0, 12, 8, 2009), mktime(0, 0, 0, 12, 9, 2009));\r
+               global $core;\r
+               $book = self::getBook($bid);\r
+               $extra = self::getExtra($book->extras);\r
+               $stats = self::load_stats($bid, $annee, $mois);\r
+               if (is_null($stats)) {\r
+                       return self::indisponible();\r
+               }\r
+\r
+               self::getActives($stats, $book, $aextra, $adown, $adownp, $aprint, $afriend);\r
+               $time_page = mktime(0, 0, 0, $mois, 15, $annee);\r
+               $res = extranetPage::bh('stats_global');\r
+               $titre = __('Statistiques de la publication « %s »');\r
+               $date_creation = __('Date de création de la publication');\r
+               $res .= self::globalDatas(sprintf($titre, $book->nom), $date_creation, $book, $stats, $afriend, $aprint, $adown, $adownp, $aextra);\r
+               $res .= extranetPage::bf();\r
+               // .\r
+               $res .= extranetPage::bh('stats_detail_mois');\r
+               $res .= '<div class="center" style="width:944px;position:relative;">' ;\r
+               $res .= self::graph_mensuel($bid, $annee, $mois, $stats);\r
+               $res . '</div>';\r
+               $res .= self::detailJour($book, $stats);\r
+               $res .= extranetPage::bf();\r
+               // .\r
+               $res .= extranetPage::bh('stats_detail_pages');\r
+               $res .= self::detailPages($book, $stats);\r
+               $res .= extranetPage::bf();\r
+               // .\r
+               if ($book->parametres->search == 0) {\r
+                       $idl = 'stats_links_2';\r
+                       $idc = 'stats_country_2';\r
+               } else {\r
+                       $idl = 'stats_links';\r
+                       $idc = 'stats_country';\r
+               }\r
+\r
+               $res .= '<div id="stats_30">';\r
+               $res .= extranetPage::bh($idl);\r
+               $res .= self::detailLiens($book, $stats);\r
+               $res .= extranetPage::bf();\r
+               if ($book->parametres->search == 1) {\r
+                       $res .= extranetPage::bh('stats_search');\r
+                       $res .= self::detailSearch($book, $stats);\r
+                       $res .= extranetPage::bf();\r
+               }\r
+               // Origine\r
+               $res .= extranetPage::bh($idc);\r
+               $res .= self::detailOrigine($book, $stats);\r
+               $res .= extranetPage::bf();\r
+               $res .= '</div>';\r
+               return $res;\r
+       }\r
+\r
+       public static function detailPeriode($book, $stats, $bid, $annee)\r
+       {\r
+               self::getActives($stats, $book, $aextra, $adown, $adownp, $aprint, $afriend);\r
+\r
+               $title = '';\r
+\r
+               $colsTitles = array(__('Période'), __('Lieux de visite'), __('Visiteurs uniques'), __('Visites'), __('Pages vues'));\r
                if ($afriend) {\r
-                       $tcol .= '<th class="stats_col">' . __('Liens envoyés') . '</th>';\r
-                       $cols++;\r
+                       $colsTitles[] = __('Liens envoyés');\r
                }\r
-               $tcol .= '<th class="stats_col">' . __('Liens cliqués') . '</th>';\r
-               $cols++;\r
+               $colsTitles[] = __('Liens cliqués');\r
                if ($aprint) {\r
-                       $tcol .= '<th class="stats_col">' . __('Impressions') . '</th>';\r
-                       $cols++;\r
+                       $colsTitles[] = __('Impressions');\r
                }\r
                if ($adown) {\r
-                       $tcol .= '<th class="stats_col">' . __('Téléchargements') . '</th>';\r
-                       $cols++;\r
+                       $colsTitles[] = __('Téléchargements');\r
                }\r
                if ($adownp) {\r
-                       $tcol .= '<th class="stats_col">' . __('Téléchargements partiels') . '</th>';\r
-                       $cols++;\r
+                       $colsTitles[] = __('Téléchargements partiels');\r
                }\r
                if ($aextra) {\r
-                       $tcol .= '<th class="stats_col">' . $extra . '</th>';\r
-                       $cols++;\r
+                       $colsTitles[] = $extra;\r
                }\r
 \r
-               $tcol .= '</tr>';\r
-               $res .= extranetPage::bh('stats_detail_mois');\r
-               $res .= '<table class="liste max">';\r
-               $res .= '<tr><th colspan="' . $cols . '">' . $core->typo->Titre(__('Détail par mois')) . '</th></tr>';\r
-               $res .= '<tr><th colspan="' . $cols . '">';\r
-               $res .= '<div class="center" style="width:944px;margin:0 auto;position:relative;">' ;\r
-               if (is_null($annee)) {\r
-                       $res .= self::graph_global($bid, $stats);\r
-               } else {\r
-                       $res .= self::graph_annuel($bid, $annee, $stats);\r
-               }\r
-               $res .= '</div>';\r
-               $res .= '</th></tr>';\r
-               $res .= $tcol;\r
                if (is_null($annee)) {\r
                        $years = $stats->year;\r
                } else {\r
                        $years = array($stats);\r
                }\r
 \r
+               $lines = array();\r
+               $noOdd = false;\r
                foreach($years as $year) {\r
-                       if (is_null($annee)) {\r
-                               $res .= '<tr><td><strong><a href="' . SITE_PATH . 'stats/' . $bid . '/' . $year['year'] . '">' . $year['year'] . '</a></strong></td>';\r
-                               $res .= '<td class="stats_col">' . $year['places'] . '</td>';\r
-                               $res .= '<td class="stats_col"><strong>' . $year['visitors'] . '</strong></td>';\r
-                               $res .= '<td class="stats_col"><strong>' . $year['visits'] . '</strong></td>';\r
-                               $res .= '<td class="stats_col"><strong>' . $year['pages'] . '</strong></td>';\r
-                               if ($afriend) {\r
-                                       $res .= '<td class="stats_col"><strong>' . $year['friends'] . '</strong></td>';\r
-                               }\r
-                               $res .= '<td class="stats_col"><strong>' . $year['links'] . '</strong></td>';\r
-                               if ($aprint) {\r
-                                       $res .= '<td class="stats_col"><strong>' . $year['prints'] . '</strong></td>';\r
-                               }\r
-                               if ($adown) {\r
-                                       $res .= '<td class="stats_col"><strong>' . $year['downloads'] . '</strong></td>';\r
-                               }\r
-                               if ($adownp) {\r
-                                       $res .= '<td class="stats_col"><strong>' . $year['partDownloads'] . '</strong></td>';\r
-                               }\r
-                               if ($aextra) {\r
-                                       $res .= '<td class="stats_col"><strong>' . $year['extras'] . '</strong></td>';\r
-                               }\r
-                               $res .= '</tr>';\r
+                       if ($year['annee'] != null) {\r
+                               $lines[] = self::linePeriod($year, $bid, $afriend, $aprint, $adown, $adownp, $aextra);\r
+                       } else {\r
+                               $noOdd = true;\r
                        }\r
+\r
                        foreach($year->month as $month) {\r
-                               $res .= '<tr class="odd"><td><a href="' . SITE_PATH . 'stats/' . $bid . '/' . $month['year'] . '/' . $month['month'] . '">' . strftime('%B %Y', mktime(0, 0, 0, (string)$month['month'], 15, (string)$month['year'])) . '</a></td>';\r
-                               $res .= '<td class="stats_col">' . $month['places'] . '</td>';\r
-                               $res .= '<td class="stats_col">' . $month['visitors'] . '</td>';\r
-                               $res .= '<td class="stats_col">' . $month['visits'] . '</td>';\r
-                               $res .= '<td class="stats_col">' . $month['pages'] . '</td>';\r
-                               if ($afriend) {\r
-                                       $res .= '<td class="stats_col">' . $month['friends'] . '</td>';\r
-                               }\r
-                               $res .= '<td class="stats_col">' . $month['links'] . '</td>';\r
-                               if ($aprint) {\r
-                                       $res .= '<td class="stats_col">' . $month['prints'] . '</td>';\r
-                               }\r
-                               if ($adown) {\r
-                                       $res .= '<td class="stats_col">' . $month['downloads'] . '</td>';\r
-                               }\r
-                               if ($adownp) {\r
-                                       $res .= '<td class="stats_col">' . $month['partDownloads'] . '</td>';\r
-                               }\r
-                               if ($aextra) {\r
-                                       $res .= '<td class="stats_col">' . $month['extras'] . '</td>';\r
-                               }\r
-                               $res .= '</tr>';\r
+                               $lines[] = self::linePeriod($month, $bid, $afriend, $aprint, $adown, $adownp, $aextra);\r
                        }\r
                }\r
-               $res .= '</table>';\r
-               $res .= extranetPage::bf();\r
-               return $res;\r
+\r
+               return self::table($title, $colsTitles, $lines, array('max', 'liste'), true, false, $noOdd);\r
        }\r
 \r
-       public static function graph_global($bid, $stats)\r
+       public static function linePeriod($stats, $bid, $afriend, $aprint, $adown, $adownp, $aextra)\r
        {\r
-               global $core;\r
-               $img = SYSIMG . '/stats/global-' . $bid . '.png';\r
-               $imgw = IMG . '/stats/global-' . $bid . '.png';\r
-               $s = array();\r
-               foreach ($stats->year as $year) {\r
-                       foreach($year->month as $month) {\r
-                               $time = mktime(0, 0, 0, intval((string)$month['month']), 15, (string)$month['year']);\r
-                               $s[$time]['book'] = $month['visits'];\r
-                               $s[$time]['page'] = $month['pages'];\r
-                               $s[$time]['time'] = $time;\r
-                               $s[$time]['visit'] = $month['visitors'];\r
+               $line = array();\r
+               $url = SITE_PATH . 'stats/' . $bid;\r
+               if (isset($stats['year'])) {\r
+                       $url .= '/' . $stats['year'];\r
+                       if (isset($stats['month'])) {\r
+                               $url .= '/' . $stats['month'];\r
+                               $date = strftime('%B %Y', mktime(0, 0, 0, (string)$stats['month'], 15, (string)$stats['year']));\r
+                       } else {\r
+                               $date = (string)$stats['year'];\r
                        }\r
                }\r
 \r
-               krsort($s);\r
-               $s = array_slice($s, 0, 12, true);\r
-               $maxv = 0;\r
-               $maxp = 0;\r
-               $maxb = 0;\r
-               foreach($s as $time => $d) {\r
-                       $maxb = max($maxb, (string) $d['book']);\r
-                       $maxp = max($maxp, (string)$d['page']);\r
-                       $maxv = max($maxv, (string) $d['visit']);\r
+               $line[] = '<a href="' . $url . '">' . $date . '</a>';\r
+               $line[] = $stats['places'];\r
+               $line[] = $stats['visitors'];\r
+               $line[] = $stats['visits'];\r
+               $line[] = $stats['pages'];\r
+               if ($afriend) {\r
+                       $line[] = $stats['friends'];\r
+               }\r
+               $line[] = $stats['links'];\r
+               if ($aprint) {\r
+                       $line[] = $stats['prints'];\r
+               }\r
+               if ($adown) {\r
+                       $line[] = $stats['downloads'];\r
+               }\r
+               if ($adownp) {\r
+                       $line[] = $stats['partDownloads'];\r
+               }\r
+               if ($aextra) {\r
+                       $line[] = $stats['extras'];\r
                }\r
 \r
-               $max = max($maxb, $maxv);\r
-               self::getQ($bid, $max, $maxp, $maxpages, $s);\r
-               $max = max($maxv, $maxb, $maxp, 1);\r
-               if (file_exists($img)) {\r
-                       unlink($img);\r
+               return $line;\r
+       }\r
+\r
+       public static function detailJour($book, $stats)\r
+       {\r
+               $colsTitles = array(__('Jour'), __('Lieux de visite'), __('Visiteurs uniques'), __('Visites'), __('Pages vues'), __('Liens cliqués'));\r
+               $lines = array();\r
+\r
+               foreach ($stats->days->day as $day) {\r
+                       $lines[] = array(strftime('%A %d', mktime(0, 0, 0, $mois, (string)$day['day'], $annee)),\r
+                               $day['places'],\r
+                               $day['visitors'],\r
+                               $day['visits'],\r
+                               $day['views'],\r
+                               $day['links']);\r
                }\r
-               if (!file_exists($img) || filemtime($img) < cubeDate::round(null, 'H')) {\r
-                       $im = imagecreatetruecolor(944, 306);\r
-                       imagelayereffect($im, IMG_EFFECT_REPLACE);\r
-                       $trans = imagecolorallocatealpha($im, 255, 255, 255, 0);\r
-                       imagefill($im, 0, 0, $trans);\r
-                       imagelayereffect($im, IMG_EFFECT_ALPHABLEND);\r
-                       $i = 1;\r
-                       $x0 = 900;\r
-                       $y0 = 305;\r
-                       $h = 300;\r
-                       $c0 = imagecolorallocate($im, 0, 0 , 0);\r
-                       $c1 = imagecolorallocatealpha($im, 81, 78, 73, 64);\r
-                       $hp = $h * ($maxp / $max)-2;\r
-                       $mhp = $y0 - $hp-6;\r
-                       imagesetstyle($im, array($c1, $c1, $c1, $c1, $c1, $trans, $trans, $trans, $trans));\r
-                       imageline($im, 0, $y0 - $hp, 944, $y0 - $hp, IMG_COLOR_STYLED);\r
-                       $c1 = imagecolorallocate($im, 81, 78, 73);\r
-                       $c2 = imagecolorallocatealpha($im, 245, 77, 0, 64);\r
-                       $hb = $h * ($maxb / $max)-1;\r
-                       $mhb = $y0 - $hb-6;\r
-                       imagesetstyle($im, array($c2, $c2, $c2, $c2, $c2, $trans, $trans, $trans, $trans));\r
-                       imageline($im, 0, $y0 - $hb, 944, $y0 - $hb, IMG_COLOR_STYLED);\r
-                       $c2 = imagecolorallocate($im, 245, 77, 0);\r
-                       $c3 = imagecolorallocatealpha($im, 194, 211, 19, 32);\r
-                       $hv = $h * ($maxv / $max);\r
-                       $mhv = $y0 - $hv-6;\r
-                       imagesetstyle($im, array($c3, $c3, $c3, $c3, $c3, $trans, $trans, $trans, $trans));\r
-                       imageline($im, 0, $y0 - $hv, 944, $y0 - $hv, IMG_COLOR_STYLED);\r
-                       $c3 = imagecolorallocate($im, 194, 211, 19);\r
-                       foreach($s as $t) {\r
-                               $x0 -= 15;\r
-                               $hp = $h * ($t['page'] / $max)-2;\r
-                               $hb = $h * ($t['book'] / $max)-1;\r
-                               $hv = $h * ($t['visit'] / $max);\r
-                               imagefilledrectangle($im, $x0-40, $y0 - $hp, $x0, $y0, $c1);\r
-                               imagerectangle($im, $x0-40, $y0 - $hp, $x0, $y0, $c0);\r
-                               $x0 -= 5;\r
-                               imagefilledrectangle($im, $x0-40, $y0 - $hb, $x0, $y0, $c2);\r
-                               imagerectangle($im, $x0-40, $y0 - $hb, $x0, $y0, $c0);\r
-                               $x0 -= 5;\r
-                               imagefilledrectangle($im, $x0-40, $y0 - $hv, $x0, $y0, $c3);\r
-                               imagerectangle($im, $x0-40, $y0 - $hv, $x0, $y0, $c0);\r
-                               $i++;\r
-                               $x0 -= 50;\r
+\r
+               return self::table(__('Détail par jour') . ' - ' . strftime('%B %Y', $time_page), $colsTitles, $lines, array('liste', 'max'), true);\r
+       }\r
+\r
+       public static function detailPages($book, $stats)\r
+       {\r
+               $colsTitles = array(__('Pages'));\r
+               if ($book->parametres->stats_score) {\r
+                       $colsTitles[] = __('Score');\r
+               }\r
+               $colsTitles[] = __('Vues');\r
+               $colsTitles[] = __('Zooms');\r
+               if ($book->parametres->bookmark) {\r
+                       $colsTitles[] = __('Marques-pages');\r
+               }\r
+               if ($book->parametres->print) {\r
+                       $colsTitles[] = __('Impressions');\r
+               }\r
+\r
+               $lines = array();\r
+               foreach ($stats->pages->page as $page) {\r
+                       $p = (string)$page['page'];\r
+                       if ($p > $book->pages || cubeMath::isOdd($p)) {\r
+                               continue;\r
+                       }\r
+                       if ($p == 0) {\r
+                               $pagen = '1';\r
+                       } elseif ($p == $book->parametres->pages) {\r
+                               $pagen = $p;\r
+                       } else {\r
+                               $pagen = $p;\r
+                               $pagen .= '-';\r
+                               $pagen .= ($p + 1);\r
                        }\r
 \r
-                       imageline($im, 0 , $y0, 944 , $y0 , $c0);\r
-                       imagepng($im, $img);\r
+                       $line = array($pagen);\r
+\r
+                       if ($book->parametres->stats_score == 1) {\r
+                               $line[] = $page['score'];\r
+                       }\r
+                       $line[] = $page['views'];\r
+                       $line[] = $page['zooms'];\r
+\r
+                       if ($book->parametres->bookmark == 1) {\r
+                               $line[] = $page['bookmarks'] ;\r
+                       }\r
+                       if ($book->parametres->print == 1) {\r
+                               $line[] = $page['prints'];\r
+                       }\r
+                       $lines[] = $line;\r
                }\r
-               $res = '<div class="graphStats"><div class="graph-note" style="top:' . $mhp . 'px;color:#514e49;">' . $maxpages . '</div>';\r
-               $res .= '<div class="graph-note" style="top:' . $mhb . 'px;color:#f54d00">' . $maxb . '</div>';\r
-               $res .= '<div  class="graph-note" style="top:' . $mhv . 'px;color:#c2d313;">' . $maxv . '</div>';\r
-               $res .= '<div class="graph-container" style="background:url(' . $imgw . ')"></div>';\r
-               $s = array_reverse(array_pad($s, 12, false), true);\r
-               $res .= '<table style="width:944px;max-width:944px;" class="echelle"><tr>';\r
-               foreach($s as $time => $val) {\r
-                       if (!$val) {\r
-                               $res .= '<td style="width:75px;max-width:75px;">' . cubeMedia::spacer(75, 20) . '</td>';\r
+               $res .= '</table>';\r
+               return self::table(__('Détail par page') . ' - ' . strftime('%B %Y', $time_page), $colsTitles, $lines, array('liste', 'max'));\r
+       }\r
+\r
+       public static function detailLiens($book, $stats)\r
+       {\r
+               $colsTitles = array(__('URL'), __('Clics'));\r
+               $lines = array();\r
+\r
+               foreach ($stats->links->link as $link) {\r
+                       $uurl = (string)$link['url'];\r
+                       $nb = (string)$link['click'];\r
+                       if (stristr($uurl, 'mailto:') || stristr($uurl, 'http://') || stristr($uurl, 'https://')) {\r
+                               $url = substr($uurl, 7);\r
                        } else {\r
-                               $res .= '<td style="width:75px;max-width:75px;">' . strftime('%b %y', $val['time']) . '</td>';\r
+                               $url = $uurl;\r
                        }\r
+                       if (strlen($url) > 30) {\r
+                               $url = substr($url, 0, 30) . '...';\r
+                       }\r
+\r
+                       $lines[] = array('<a href="' . $uurl . '" class="blank" title="' . $uurl . '">' . $url . '</a>', $nb);\r
                }\r
-               $res .= '<td style="width:44px;">' . cubeMedia::spacer(44, 20) . '</td>';\r
-               $res .= '</tr></table>';\r
-               $res .= '<table class="legende"><tr>';\r
-               $res .= '<td style="width:12px;background:#514e49;height:12px;"></td><td style="width:10px;"></td><td>' . __('Pages vues') . '</td><td style="width:10px;"></td>';\r
-               $res .= '<td style="width:12px;background:#f54d00;height:12px;"></td><td style="width:10px;"></td><td>' . __('Visites') . '</td><td style="width:10px;"></td>';\r
-               $res .= '<td style="width:12px;background:#c2d313;height:12px;"></td><td style="width:10px;"></td><td>' . __('Visiteurs uniques') . '</td><td style="width:10px;"></td>';\r
-               $res .= '</tr></table></div>';\r
-               return $res;\r
+\r
+               return self::table(__('Liens les plus cliqués'), $colsTitles, $lines, array('liste', 'max'));\r
        }\r
 \r
-       /**\r
-        * wsStats::vue_annuelle()\r
-        *\r
-        * @param mixed $bid\r
-        * @param mixed $annee\r
-        * @return\r
-        */\r
-       public static function vue_annuelle($bid, $annee)\r
+       public static function detailSearch($book, $stats)\r
        {\r
-               return self::vue_globale($bid, $annee);\r
+               $colsTitles = array(__('Mot'), __('Recherches'));\r
+               $lines = array();\r
+\r
+               foreach ($stats->searches->search as $search) {\r
+                       $q = $search['query'];\r
+                       if (strlen($q) > 25) {\r
+                               $q = '<abbr title="' . $q . '">' . substr($q, 0, 25) . ' ...</abbr>';\r
+                       }\r
+                       $lines[] = array($q, $search['count']);\r
+               }\r
+               return self::table(__('Mots les plus recherchés'), $colsTitles, $lines, array('liste', 'max'));\r
+       }\r
+\r
+       public static function detailOrigine($book, $stats)\r
+       {\r
+               $colsTitles = array(__('Pays'), __('Visiteurs'));\r
+               $lines = array();\r
+\r
+               foreach ($stats->countries->country as $country) {\r
+                       $pays = $country['code'];\r
+                       $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
+                       if (!$c = cubeCountry::getCountry($pays)) {\r
+                               $c = __('Origine inconnue');\r
+                       }\r
+                       $lines[] = array(cubeCountry::getFlag($pays) . ' ' . ucfirst(mb_strtolower($c)) , $country['visitors']);\r
+                       $i++;\r
+               }\r
+               return self::table(__('Origine des visiteurs'), $colsTitles, $lines, array('liste', 'max'));\r
        }\r
 \r
-       public static function getQ($book, $max, &$maxp, &$maxpages, &$s)\r
+       public static function getQ($max, &$maxp, &$maxpages, &$s)\r
        {\r
                $maxpages = $maxp;\r
-               $q = max($book->pages / 5, 1);\r
+               $q = 1;\r
                $maxp /= $q;\r
                $maxp = max($max * 4, $maxp);\r
                $q = $maxpages / $maxp;\r
@@ -591,7 +720,7 @@ class wsStats {
                }\r
                // .\r
                $max = max($maxb, $maxv);\r
-               self::getQ($bid, $max, $maxp, $maxpages, $s);\r
+               self::getQ($max, $maxp, $maxpages, $s);\r
                krsort($s);\r
                $max = max($maxb, $maxv, $maxp);\r
                $months = cubeDate::getMonths($a);\r
@@ -667,165 +796,108 @@ class wsStats {
                return $res;\r
        }\r
 \r
-       public static function vue_mensuelle($bid, $annee, $mois)\r
+       public static function graph_global($bid, $stats)\r
        {\r
-               $datestocorrect = array(mktime(0, 0, 0, 11, 23, 2009), mktime(0, 0, 0, 12, 8, 2009), mktime(0, 0, 0, 12, 9, 2009));\r
                global $core;\r
-               $book = self::getBook($bid);\r
-               $extra = self::getExtra($book->extras);\r
-               $stats = self::load_stats($bid, $annee, $mois);\r
-               if (is_null($stats)) {\r
-                       return self::indisponible();\r
-               }\r
-\r
-               self::getActives($stats, $book, $aextra, $adown, $adownp, $aprint, $afriend);\r
-               $time_page = mktime(0, 0, 0, $mois, 15, $annee);\r
-               $res = extranetPage::bh('stats_global');\r
-               $titre = __('Statistiques de la publication « %s »');\r
-               $date_creation = __('Date de création de la publication');\r
-               $res .= self::globalDatas(sprintf($titre, $book->nom), $date_creation, $book, $stats, $afriend, $aprint, $adown, $adownp, $aextra);\r
-               $res .= extranetPage::bf();\r
-               $res .= extranetPage::bh('stats_detail_mois');\r
-               $res .= '<div class="center" style="width:944px;position:relative;">' . self::graph_mensuel($bid, $annee, $mois, $stats) . '</div>';\r
-               $res .= '<table class="liste max">';\r
-               $res .= '<tr><th colspan="5">' . $core->typo->Titre(__('Détail par jour') . ' - ' . strftime('%B %Y', $time_page)) . '</th></tr>';\r
-               $res .= '<tr><th class="stats_col max">' . __('Jour') . '</th>';\r
-               $res .= '<th class="stats_col">' . __('Lieux de visite') . '</th>';\r
-               $res .= '<th class="stats_col">' . __('Visiteurs uniques') . '</th>';\r
-               $res .= '<th class="stats_col">' . __('Visites') . '</th>';\r
-               $res .= '<th class="stats_col">' . __('Pages vues') . '</th>';\r
-               $res .= '<th class="stats_col">' . __('Liens cliqués') . '</th>';\r
-               $res .= '</tr>';\r
-               $i = 0;\r
-               foreach ($stats->days->day as $day) {\r
-                       $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
-                       $res .= '<tr' . $odd . '><td >' . strftime('%A %d', mktime(0, 0, 0, $mois, (string)$day['day'], $annee)) . '</td>';\r
-                       $res .= '<td class="stats_col">' . $day['places'] . '</td>';\r
-                       $res .= '<td class="stats_col">' . $day['visitors'] . '</td>';\r
-                       $res .= '<td class="stats_col">' . $day['visits'] . '</td>';\r
-                       $res .= '<td class="stats_col">' . $day['views'] . '</td>';\r
-                       $res .= '<td class="stats_col">' . $day['links'] . '</td>';\r
-                       $res .= '</tr>';\r
-                       $i++;\r
-               }\r
-               $res .= '</table>';\r
-               $res .= extranetPage::bf();\r
-               $res .= extranetPage::bh('stats_detail_pages');\r
-               $res .= '<table class="liste max">';\r
-               $res .= '<tr><th colspan="5">' . $core->typo->Titre(__('Détail par page') . ' - ' . strftime('%B %Y', $time_page)) . '</th></tr>';\r
-               $res .= '<tr><th class="stats_col max">' . __('Pages') . '</th>';\r
-               if ($book->parametres->stats_score) {\r
-                       $res .= '<th class="stats_col">' . __('Score') . '</th>';\r
-               }\r
-               $res .= '<th class="stats_col">' . __('Vues') . '</th>';\r
-               $res .= '<th class="stats_col">' . __('Zooms') . '</th>';\r
-               if ($book->parametres->bookmark) {\r
-                       $res .= '<th class="stats_col">' . __('Marques-pages') . '</th>';\r
-               }\r
-               if ($book->parametres->print) {\r
-                       $res .= '<th class="stats_col">' . __('Impressions') . '</th></tr>';\r
-               }\r
-\r
-               $i = 0;\r
-               foreach ($stats->pages->page as $page) {\r
-                       $p = (string)$page['page'];\r
-                       if ($p > $book->pages || cubeMath::isOdd($p)) {\r
-                               continue;\r
-                       }\r
-                       if ($p == 0) {\r
-                               $pagen = '1';\r
-                       } elseif ($p == $book->parametres->pages) {\r
-                               $pagen = $p;\r
-                       } else {\r
-                               $pagen = $p;\r
-                               $pagen .= '-';\r
-                               $pagen .= ($p + 1);\r
-                       }\r
-                       $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
-                       $res .= '<tr' . $odd . '><td>' . $pagen . '</td>';\r
-                       if ($book->parametres->stats_score == 1) {\r
-                               $res .= '<td class="center">' . $page['score'] . '</td>';\r
-                       }\r
-                       $res .= '<td class="center">' . $page['views'] . '</td>';\r
-                       $res .= '<td class="center">' . $page['zooms'] . '</td>';\r
-                       if ($book->parametres->bookmark == 1) {\r
-                               $res .= '<td class="center">' . $page['bookmarks'] . '</td>';\r
-                       }\r
-                       if ($book->parametres->print == 1) {\r
-                               $res .= '<td class="center">' . $page['prints'] . '</td></tr>';\r
+               $img = SYSIMG . '/stats/global-' . $bid . '.png';\r
+               $imgw = IMG . '/stats/global-' . $bid . '.png';\r
+               $s = array();\r
+               foreach ($stats->year as $year) {\r
+                       foreach($year->month as $month) {\r
+                               $time = mktime(0, 0, 0, intval((string)$month['month']), 15, (string)$month['year']);\r
+                               $s[$time]['book'] = $month['visits'];\r
+                               $s[$time]['page'] = $month['pages'];\r
+                               $s[$time]['time'] = $time;\r
+                               $s[$time]['visit'] = $month['visitors'];\r
                        }\r
-                       $i++;\r
-               }\r
-               $res .= '</table>';\r
-               $res .= extranetPage::bf();\r
-               if ($book->parametres->search == 0) {\r
-                       $idl = 'stats_links_2';\r
-                       $idc = 'stats_country_2';\r
-               } else {\r
-                       $idl = 'stats_links';\r
-                       $idc = 'stats_country';\r
                }\r
 \r
-               $res .= '<div id="stats_30">';\r
-               $res .= extranetPage::bh($idl);\r
-               $res .= '<table class="liste max">';\r
-               $res .= '<tr><th colspan="2">' . $core->typo->Titre(__('Liens les plus cliqués')) . '</th></tr>';\r
-               $res .= '<tr><th class="max">' . __('URL') . '</th><th class="nowrap">' . __('Clics') . '</th></tr>';\r
-               $i = 0;\r
-               foreach ($stats->links->link as $link) {\r
-                       $uurl = (string)$link['url'];\r
-                       $nb = (string)$link['click'];\r
-                       if (stristr($uurl, 'mailto:') || stristr($uurl, 'http://')) {\r
-                               $url = substr($uurl, 7);\r
-                       } else {\r
-                               $url = $uurl;\r
-                       }\r
-                       if (strlen($url) > 30) {\r
-                               $url = substr($url, 0, 30) . '...';\r
-                       }\r
-                       $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
-                       $res .= '<tr' . $odd . '><td class="max"><a href="' . $uurl . '" class="blank" title="' . $uurl . '">' . $url . '</a></td><td class="nowrap center">' . $nb . '</td></tr>';\r
-                       $i++;\r
+               krsort($s);\r
+               $s = array_slice($s, 0, 12, true);\r
+               $maxv = 0;\r
+               $maxp = 0;\r
+               $maxb = 0;\r
+               foreach($s as $time => $d) {\r
+                       $maxb = max($maxb, (string) $d['book']);\r
+                       $maxp = max($maxp, (string)$d['page']);\r
+                       $maxv = max($maxv, (string) $d['visit']);\r
                }\r
-               $res .= '</table>';\r
-               $res .= extranetPage::bf();\r
-               if ($book->parametres->search == 1) {\r
-                       $res .= extranetPage::bh('stats_search');\r
-                       $res .= '<table class="liste max">';\r
-                       $res .= '<tr><th colspan="2">' . $core->typo->Titre(__('Mots les plus recherchés')) . '</th></tr>';\r
-                       $res .= '<tr><th class="max">' . __('Mot') . '</th><th class="nowrap">' . __('Recherches') . '</th></tr>';\r
-                       $i = 0;\r
-                       foreach ($stats->searches->search as $search) {\r
-                               $q = $search['query'];\r
-                               if (strlen($q) > 25) {\r
-                                       $q = '<abbr title="' . $q . '">' . substr($q, 0, 25) . ' ...</abbr>';\r
-                               }\r
 \r
-                               $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
-                               $res .= '<tr' . $odd . '><td class="max">' . $q . '</td><td class="nowrap center">' . $search['count'] . '</td></tr>';\r
+               $max = max($maxb, $maxv);\r
+               self::getQ($max, $maxp, $maxpages, $s);\r
+               $max = max($maxv, $maxb, $maxp, 1);\r
+               if (file_exists($img)) {\r
+                       unlink($img);\r
+               }\r
+               if (!file_exists($img) || filemtime($img) < cubeDate::round(null, 'H')) {\r
+                       $im = imagecreatetruecolor(944, 306);\r
+                       imagelayereffect($im, IMG_EFFECT_REPLACE);\r
+                       $trans = imagecolorallocatealpha($im, 255, 255, 255, 0);\r
+                       imagefill($im, 0, 0, $trans);\r
+                       imagelayereffect($im, IMG_EFFECT_ALPHABLEND);\r
+                       $i = 1;\r
+                       $x0 = 900;\r
+                       $y0 = 305;\r
+                       $h = 300;\r
+                       $c0 = imagecolorallocate($im, 0, 0 , 0);\r
+                       $c1 = imagecolorallocatealpha($im, 81, 78, 73, 64);\r
+                       $hp = $h * ($maxp / $max)-2;\r
+                       $mhp = $y0 - $hp-6;\r
+                       imagesetstyle($im, array($c1, $c1, $c1, $c1, $c1, $trans, $trans, $trans, $trans));\r
+                       imageline($im, 0, $y0 - $hp, 944, $y0 - $hp, IMG_COLOR_STYLED);\r
+                       $c1 = imagecolorallocate($im, 81, 78, 73);\r
+                       $c2 = imagecolorallocatealpha($im, 245, 77, 0, 64);\r
+                       $hb = $h * ($maxb / $max)-1;\r
+                       $mhb = $y0 - $hb-6;\r
+                       imagesetstyle($im, array($c2, $c2, $c2, $c2, $c2, $trans, $trans, $trans, $trans));\r
+                       imageline($im, 0, $y0 - $hb, 944, $y0 - $hb, IMG_COLOR_STYLED);\r
+                       $c2 = imagecolorallocate($im, 245, 77, 0);\r
+                       $c3 = imagecolorallocatealpha($im, 194, 211, 19, 32);\r
+                       $hv = $h * ($maxv / $max);\r
+                       $mhv = $y0 - $hv-6;\r
+                       imagesetstyle($im, array($c3, $c3, $c3, $c3, $c3, $trans, $trans, $trans, $trans));\r
+                       imageline($im, 0, $y0 - $hv, 944, $y0 - $hv, IMG_COLOR_STYLED);\r
+                       $c3 = imagecolorallocate($im, 194, 211, 19);\r
+                       foreach($s as $t) {\r
+                               $x0 -= 15;\r
+                               $hp = $h * ($t['page'] / $max)-2;\r
+                               $hb = $h * ($t['book'] / $max)-1;\r
+                               $hv = $h * ($t['visit'] / $max);\r
+                               imagefilledrectangle($im, $x0-40, $y0 - $hp, $x0, $y0, $c1);\r
+                               imagerectangle($im, $x0-40, $y0 - $hp, $x0, $y0, $c0);\r
+                               $x0 -= 5;\r
+                               imagefilledrectangle($im, $x0-40, $y0 - $hb, $x0, $y0, $c2);\r
+                               imagerectangle($im, $x0-40, $y0 - $hb, $x0, $y0, $c0);\r
+                               $x0 -= 5;\r
+                               imagefilledrectangle($im, $x0-40, $y0 - $hv, $x0, $y0, $c3);\r
+                               imagerectangle($im, $x0-40, $y0 - $hv, $x0, $y0, $c0);\r
                                $i++;\r
+                               $x0 -= 50;\r
                        }\r
-                       $res .= '</table>';\r
-                       $res .= extranetPage::bf();\r
-               }\r
 \r
-               $res .= extranetPage::bh($idc);\r
-               $res .= '<table class="liste max">';\r
-               $res .= '<tr><th colspan="2">' . $core->typo->Titre(__('Origine des visiteurs')) . '</th></tr>';\r
-               $res .= '<tr><th class="max">' . __('Pays') . '</th><th class="nowrap">' . __('Visiteurs') . '</th></tr>';\r
-               $i = 0;\r
-               foreach ($stats->countries->country as $country) {\r
-                       $pays = $country['code'];\r
-                       $odd = cubeMath::isOdd($i)?' class="odd"':'';\r
-                       if (!$c = cubeCountry::getCountry($pays)) {\r
-                               $c = __('Origine inconnue');\r
+                       imageline($im, 0 , $y0, 944 , $y0 , $c0);\r
+                       imagepng($im, $img);\r
+               }\r
+               $res = '<div class="graphStats"><div class="graph-note" style="top:' . $mhp . 'px;color:#514e49;">' . $maxpages . '</div>';\r
+               $res .= '<div class="graph-note" style="top:' . $mhb . 'px;color:#f54d00">' . $maxb . '</div>';\r
+               $res .= '<div  class="graph-note" style="top:' . $mhv . 'px;color:#c2d313;">' . $maxv . '</div>';\r
+               $res .= '<div class="graph-container" style="background:url(' . $imgw . ')"></div>';\r
+               $s = array_reverse(array_pad($s, 12, false), true);\r
+               $res .= '<table style="width:944px;max-width:944px;" class="echelle"><tr>';\r
+               foreach($s as $time => $val) {\r
+                       if (!$val) {\r
+                               $res .= '<td style="width:75px;max-width:75px;">' . cubeMedia::spacer(75, 20) . '</td>';\r
+                       } else {\r
+                               $res .= '<td style="width:75px;max-width:75px;">' . strftime('%b %y', $val['time']) . '</td>';\r
                        }\r
-                       $res .= '<tr' . $odd . '><td class="max">' . cubeCountry::getFlag($pays) . ' ' . ucfirst(mb_strtolower($c)) . '</td><td class="nowrap center">' . $country['visitors'] . '</td></tr>';\r
-                       $i++;\r
                }\r
-               $res .= '</table>';\r
-               $res .= extranetPage::bf();\r
-               $res .= '</div>';\r
+               $res .= '<td style="width:44px;">' . cubeMedia::spacer(44, 20) . '</td>';\r
+               $res .= '</tr></table>';\r
+               $res .= '<table class="legende"><tr>';\r
+               $res .= '<td style="width:12px;background:#514e49;height:12px;"></td><td style="width:10px;"></td><td>' . __('Pages vues') . '</td><td style="width:10px;"></td>';\r
+               $res .= '<td style="width:12px;background:#f54d00;height:12px;"></td><td style="width:10px;"></td><td>' . __('Visites') . '</td><td style="width:10px;"></td>';\r
+               $res .= '<td style="width:12px;background:#c2d313;height:12px;"></td><td style="width:10px;"></td><td>' . __('Visiteurs uniques') . '</td><td style="width:10px;"></td>';\r
+               $res .= '</tr></table></div>';\r
                return $res;\r
        }\r
 \r
@@ -851,7 +923,7 @@ class wsStats {
                        $s[$time]['time'] = $time;\r
                }\r
                $max = max($maxb, $maxv);\r
-               self::getQ($bid, $max, $maxp, $maxpages, $s);\r
+               self::getQ($max, $maxp, $maxpages, $s);\r
                krsort($s);\r
                $max = max($maxv, $maxb, $maxp);\r
                $days = cubeDate::getDays($a, $m);\r
index fc9bdf678670eebceaefc83d916df37151deef49..e6ce17541e83240eac0fb53376f19765dcd93de3 100644 (file)
@@ -119,6 +119,12 @@ html{height:100%}' . "\n";
                return wsStats::display($bid, $annee, $mois);\r
        }\r
 \r
+       public static function statsxls($args)\r
+       {\r
+               $bid = (isset($args[1]))?$args[1]:null;\r
+               wsStats::exportXLS($bid);\r
+       }\r
+\r
        public static function editComposition($args)\r
        {\r
                $fv = array(session_name() => session_id(),\r