From: vincent@cubedesigners.com Date: Mon, 15 Nov 2010 13:53:29 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=21a98f9f6fc0aad3ed0af042d786794c39a7aafa;p=cubeextranet.git --- diff --git a/inc/extranet/Controlleur/class.extranet.shortcuts.php b/inc/extranet/Controlleur/class.extranet.shortcuts.php index dbb2487ad..13b118381 100644 --- a/inc/extranet/Controlleur/class.extranet.shortcuts.php +++ b/inc/extranet/Controlleur/class.extranet.shortcuts.php @@ -18,8 +18,8 @@ class extranetShortcuts { // $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 .= '
'.$this->selectedValue.'' ; + $res .= '' . cubeMedia::spacer(155, 18) . ''; $res .= '
'; $res .= '
    '; $last = count($this->values)-1; diff --git a/inc/ws/Controlleur/class.ws.stats.php b/inc/ws/Controlleur/class.ws.stats.php index 8ba762132..4e5518b40 100644 --- a/inc/ws/Controlleur/class.ws.stats.php +++ b/inc/ws/Controlleur/class.ws.stats.php @@ -10,8 +10,16 @@ class wsStats { $global = self::load_stats($bid); + $exporturl = SITE_PATH . 'statsxls/' . $bid; + if (!is_null($annee)) { + $exporturl .= '/' . $annee; + if (!is_null($mois)) { + $exporturl .= '/' . $mois; + } + } + $actions = array(); - $actions[] = '' . $core->typo->Ajouter('Exporter au format Excel') . ''; + $actions[] = '' . $core->typo->Ajouter('Exporter au format Excel') . ''; $years = $global->year; $annees = array('' . __('Toutes') . '' => SITE_PATH . 'stats/' . $bid); @@ -44,7 +52,7 @@ class wsStats { $listeShortcuts[] = $listeMois; } - $res = extranetPage::barre($listeShortcuts, 'filtreStats', 'stats'/*, $actions*/); + $res = extranetPage::barre($listeShortcuts, 'filtreStats', 'stats', $actions); $res .= extranetPage::tMain(); if (is_null($annee) && is_null($mois)) { $res .= self::vue_globale($bid); @@ -57,6 +65,24 @@ class wsStats { return $res; } + public static function exportXLS($bid, $annee = null, $mois = null) + { + $xls = new PHPExcel(); + if (is_null($annee)) { + // Export global + } else if (is_null($mois)) { + // Export annee + } else { + // Export mois + } + + cubeHTTP::forceDownload('stats_' . $bid . '.xls', false); + } + + public static function addSheetFromTable() + { + } + public static function getExtra($extra) { $xml = simplexml_load_string('' . $extra . ''); @@ -257,47 +283,80 @@ class wsStats { $afriend = ($book->parametres->friend == 1); } - public static function globalDatas($titre, $date_creation, $book, $stats, $afriend, $aprint, $adown, $adownp, $aextra) + public static function table($title, $colsTitles, $lines, $class, $firstColMax = true, $firstLineBold = false, $noOdd = false) { global $core; - $res = ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $i = 1; + if (is_string($class)) { + $class = array($class); + } + $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'] . '
    '; + // Titre + $res .= ''; + // Head + if (implode('', $colsTitles) != '') { + $res .= ''; + foreach($colsTitles as $i => $title) { + $max = ($firstColMax && $i == 0)?'':' class="stats_col"'; + $res .= '' . $title . ''; + } + $res . ''; + } + // Body + foreach($lines as $i => $line) { + $odd = cubeMath::isOdd($i)?' class="odd"':''; + if ($firstLineBold && $i == 0) { + $odd = ' class="odd"'; + } elseif ($firstLineBold) { + $odd = ''; + } + if ($noOdd) { + $odd = ''; + } + $res .= ''; + foreach($line as $j => $cell) { + $max = ($firstColMax && $j == 0)?'':' class="stats_col"'; + if ($firstLineBold && $i == 0) { + $cell = '' . $cell . ''; + } + $res .= '' . $cell . ''; + } + $res .= ''; + } + + $res .= '
    ' . $core->typo->Titre($title) . '
    '; + + return $res; + } + + public static function globalDatas($titre, $date_creation, $book, $stats, $afriend, $aprint, $adown, $adownp, $aextra) + { + $colsTitles = array('', ''); + $lines = array(); + $class = array('liste', 'max'); + + $lines[] = array($date_creation, date(__('d-m-Y'), $book->date)); + $lines[] = array(__('Nombre de lieux de visite'), $stats['places']); + $lines[] = array(__('Nombre de visiteurs uniques'), $stats['visitors']); + $lines[] = array(__('Nombre de visites'), $stats['visits']); + $lines[] = array(__('Nombre de pages vues'), $stats['pages']); if ($afriend) { - $odd = $i % 2 == 1?' class="odd"':''; - $i++; - $res .= '' . __('Nombre de liens envoyés') . '' . $stats['friends'] . ''; + $lines[] = array(__('Nombre de liens envoyés'), $stats['friends']); } - $odd = $i % 2 == 1?' class="odd"':''; - $i++; - $res .= '' . __('Nombre de liens cliqués') . '' . $stats['links'] . ''; + $lines[] = array(__('Nombre de liens cliqués'), $stats['links']); if ($aprint) { - $odd = $i % 2 == 1?' class="odd"':''; - $i++; - $res .= '' . __("Nombre d'impressions") . '' . $stats['prints'] . ''; + $lines[] = array(__("Nombre d'impressions"), $stats['prints']); } if ($adown) { - $odd = $i % 2 == 1?' class="odd"':''; - $i++; - $res .= '' . __('Nombre de téléchargements') . '' . $stats['downloads'] . ''; + $lines[] = array(__('Nombre de téléchargements'), $stats['downloads']); } if ($adownp) { - $odd = $i % 2 == 1?' class="odd"':''; - $i++; - $res .= '' . __('Nombre de téléchargements partiels') . '' . $stats['partDownloads'] . ''; + $lines[] = array(__('Nombre de téléchargements partiels'), $stats['partDownloads']); } if ($aextra) { - $odd = $i % 2 == 1?' class="odd"':''; - $i++; - $res .= '' . __('Accès à la rubrique') . ' ' . $extra . '' . $stats['extras'] . ''; + $lines[] = array(__('Accès à la rubrique') . ' ' . $extra, $stats['extras']); } - $res .= ''; - return $res; + + return self::table($titre, $colsTitles , $lines , $class); } public static function indisponible() @@ -336,233 +395,303 @@ class wsStats { $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(); - $tcol = ''; - $cols = 0; - $tcol .= '' . __('Période') . ''; - $tcol .= '' . __('Lieux de visite') . ''; - $tcol .= '' . __('Visiteurs uniques') . ''; - $tcol .= '' . __('Visites') . ''; - $tcol .= '' . __('Pages vues') . ''; - $cols = 5; + $res .= extranetPage::bh(); + $res .= ''; + $res .= ''; + $res .= ''; + $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 .= '
    '; + $res .= self::detailPeriode($book, $stats, $bid, $annee); + $res .= extranetPage::bf(); + return $res; + } + + /** + * wsStats::vue_annuelle() + * + * @param mixed $bid + * @param mixed $annee + * @return + */ + public static function vue_annuelle($bid, $annee) + { + return self::vue_globale($bid, $annee); + } + public static function vue_mensuelle($bid, $annee, $mois) + { + $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 »'); + $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 .= '
    ' ; + $res .= self::graph_mensuel($bid, $annee, $mois, $stats); + $res . '
    '; + $res .= self::detailJour($book, $stats); + $res .= extranetPage::bf(); + // . + $res .= extranetPage::bh('stats_detail_pages'); + $res .= self::detailPages($book, $stats); + $res .= extranetPage::bf(); + // . + if ($book->parametres->search == 0) { + $idl = 'stats_links_2'; + $idc = 'stats_country_2'; + } else { + $idl = 'stats_links'; + $idc = 'stats_country'; + } + + $res .= '
    '; + $res .= extranetPage::bh($idl); + $res .= self::detailLiens($book, $stats); + $res .= extranetPage::bf(); + if ($book->parametres->search == 1) { + $res .= extranetPage::bh('stats_search'); + $res .= self::detailSearch($book, $stats); + $res .= extranetPage::bf(); + } + // Origine + $res .= extranetPage::bh($idc); + $res .= self::detailOrigine($book, $stats); + $res .= extranetPage::bf(); + $res .= '
    '; + return $res; + } + + public static function detailPeriode($book, $stats, $bid, $annee) + { + self::getActives($stats, $book, $aextra, $adown, $adownp, $aprint, $afriend); + + $title = ''; + + $colsTitles = array(__('Période'), __('Lieux de visite'), __('Visiteurs uniques'), __('Visites'), __('Pages vues')); if ($afriend) { - $tcol .= '' . __('Liens envoyés') . ''; - $cols++; + $colsTitles[] = __('Liens envoyés'); } - $tcol .= '' . __('Liens cliqués') . ''; - $cols++; + $colsTitles[] = __('Liens cliqués'); if ($aprint) { - $tcol .= '' . __('Impressions') . ''; - $cols++; + $colsTitles[] = __('Impressions'); } if ($adown) { - $tcol .= '' . __('Téléchargements') . ''; - $cols++; + $colsTitles[] = __('Téléchargements'); } if ($adownp) { - $tcol .= '' . __('Téléchargements partiels') . ''; - $cols++; + $colsTitles[] = __('Téléchargements partiels'); } if ($aextra) { - $tcol .= '' . $extra . ''; - $cols++; + $colsTitles[] = $extra; } - $tcol .= ''; - $res .= extranetPage::bh('stats_detail_mois'); - $res .= ''; - $res .= ''; - $res .= ''; - $res .= $tcol; if (is_null($annee)) { $years = $stats->year; } else { $years = array($stats); } + $lines = array(); + $noOdd = false; foreach($years as $year) { - if (is_null($annee)) { - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - if ($afriend) { - $res .= ''; - } - $res .= ''; - if ($aprint) { - $res .= ''; - } - if ($adown) { - $res .= ''; - } - if ($adownp) { - $res .= ''; - } - if ($aextra) { - $res .= ''; - } - $res .= ''; + if ($year['annee'] != null) { + $lines[] = self::linePeriod($year, $bid, $afriend, $aprint, $adown, $adownp, $aextra); + } else { + $noOdd = true; } + foreach($year->month as $month) { - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - if ($afriend) { - $res .= ''; - } - $res .= ''; - if ($aprint) { - $res .= ''; - } - if ($adown) { - $res .= ''; - } - if ($adownp) { - $res .= ''; - } - if ($aextra) { - $res .= ''; - } - $res .= ''; + $lines[] = self::linePeriod($month, $bid, $afriend, $aprint, $adown, $adownp, $aextra); } } - $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 .= '
    ' . $year['year'] . '' . $year['places'] . '' . $year['visitors'] . '' . $year['visits'] . '' . $year['pages'] . '' . $year['friends'] . '' . $year['links'] . '' . $year['prints'] . '' . $year['downloads'] . '' . $year['partDownloads'] . '' . $year['extras'] . '
    ' . strftime('%B %Y', mktime(0, 0, 0, (string)$month['month'], 15, (string)$month['year'])) . '' . $month['places'] . '' . $month['visitors'] . '' . $month['visits'] . '' . $month['pages'] . '' . $month['friends'] . '' . $month['links'] . '' . $month['prints'] . '' . $month['downloads'] . '' . $month['partDownloads'] . '' . $month['extras'] . '
    '; - $res .= extranetPage::bf(); - return $res; + + return self::table($title, $colsTitles, $lines, array('max', 'liste'), true, false, $noOdd); } - public static function graph_global($bid, $stats) + public static function linePeriod($stats, $bid, $afriend, $aprint, $adown, $adownp, $aextra) { - 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) { - $time = mktime(0, 0, 0, intval((string)$month['month']), 15, (string)$month['year']); - $s[$time]['book'] = $month['visits']; - $s[$time]['page'] = $month['pages']; - $s[$time]['time'] = $time; - $s[$time]['visit'] = $month['visitors']; + $line = array(); + $url = SITE_PATH . 'stats/' . $bid; + if (isset($stats['year'])) { + $url .= '/' . $stats['year']; + if (isset($stats['month'])) { + $url .= '/' . $stats['month']; + $date = strftime('%B %Y', mktime(0, 0, 0, (string)$stats['month'], 15, (string)$stats['year'])); + } else { + $date = (string)$stats['year']; } } - krsort($s); - $s = array_slice($s, 0, 12, true); - $maxv = 0; - $maxp = 0; - $maxb = 0; - foreach($s as $time => $d) { - $maxb = max($maxb, (string) $d['book']); - $maxp = max($maxp, (string)$d['page']); - $maxv = max($maxv, (string) $d['visit']); + $line[] = '' . $date . ''; + $line[] = $stats['places']; + $line[] = $stats['visitors']; + $line[] = $stats['visits']; + $line[] = $stats['pages']; + if ($afriend) { + $line[] = $stats['friends']; + } + $line[] = $stats['links']; + if ($aprint) { + $line[] = $stats['prints']; + } + if ($adown) { + $line[] = $stats['downloads']; + } + if ($adownp) { + $line[] = $stats['partDownloads']; + } + if ($aextra) { + $line[] = $stats['extras']; } - $max = max($maxb, $maxv); - self::getQ($bid, $max, $maxp, $maxpages, $s); - $max = max($maxv, $maxb, $maxp, 1); - if (file_exists($img)) { - unlink($img); + return $line; + } + + public static function detailJour($book, $stats) + { + $colsTitles = array(__('Jour'), __('Lieux de visite'), __('Visiteurs uniques'), __('Visites'), __('Pages vues'), __('Liens cliqués')); + $lines = array(); + + foreach ($stats->days->day as $day) { + $lines[] = array(strftime('%A %d', mktime(0, 0, 0, $mois, (string)$day['day'], $annee)), + $day['places'], + $day['visitors'], + $day['visits'], + $day['views'], + $day['links']); } - if (!file_exists($img) || filemtime($img) < cubeDate::round(null, 'H')) { - $im = imagecreatetruecolor(944, 306); - imagelayereffect($im, IMG_EFFECT_REPLACE); - $trans = imagecolorallocatealpha($im, 255, 255, 255, 0); - imagefill($im, 0, 0, $trans); - imagelayereffect($im, IMG_EFFECT_ALPHABLEND); - $i = 1; - $x0 = 900; - $y0 = 305; - $h = 300; - $c0 = imagecolorallocate($im, 0, 0 , 0); - $c1 = imagecolorallocatealpha($im, 81, 78, 73, 64); - $hp = $h * ($maxp / $max)-2; - $mhp = $y0 - $hp-6; - imagesetstyle($im, array($c1, $c1, $c1, $c1, $c1, $trans, $trans, $trans, $trans)); - imageline($im, 0, $y0 - $hp, 944, $y0 - $hp, IMG_COLOR_STYLED); - $c1 = imagecolorallocate($im, 81, 78, 73); - $c2 = imagecolorallocatealpha($im, 245, 77, 0, 64); - $hb = $h * ($maxb / $max)-1; - $mhb = $y0 - $hb-6; - imagesetstyle($im, array($c2, $c2, $c2, $c2, $c2, $trans, $trans, $trans, $trans)); - imageline($im, 0, $y0 - $hb, 944, $y0 - $hb, IMG_COLOR_STYLED); - $c2 = imagecolorallocate($im, 245, 77, 0); - $c3 = imagecolorallocatealpha($im, 194, 211, 19, 32); - $hv = $h * ($maxv / $max); - $mhv = $y0 - $hv-6; - imagesetstyle($im, array($c3, $c3, $c3, $c3, $c3, $trans, $trans, $trans, $trans)); - imageline($im, 0, $y0 - $hv, 944, $y0 - $hv, IMG_COLOR_STYLED); - $c3 = imagecolorallocate($im, 194, 211, 19); - foreach($s as $t) { - $x0 -= 15; - $hp = $h * ($t['page'] / $max)-2; - $hb = $h * ($t['book'] / $max)-1; - $hv = $h * ($t['visit'] / $max); - imagefilledrectangle($im, $x0-40, $y0 - $hp, $x0, $y0, $c1); - imagerectangle($im, $x0-40, $y0 - $hp, $x0, $y0, $c0); - $x0 -= 5; - imagefilledrectangle($im, $x0-40, $y0 - $hb, $x0, $y0, $c2); - imagerectangle($im, $x0-40, $y0 - $hb, $x0, $y0, $c0); - $x0 -= 5; - imagefilledrectangle($im, $x0-40, $y0 - $hv, $x0, $y0, $c3); - imagerectangle($im, $x0-40, $y0 - $hv, $x0, $y0, $c0); - $i++; - $x0 -= 50; + + return self::table(__('Détail par jour') . ' - ' . strftime('%B %Y', $time_page), $colsTitles, $lines, array('liste', 'max'), true); + } + + public static function detailPages($book, $stats) + { + $colsTitles = array(__('Pages')); + if ($book->parametres->stats_score) { + $colsTitles[] = __('Score'); + } + $colsTitles[] = __('Vues'); + $colsTitles[] = __('Zooms'); + if ($book->parametres->bookmark) { + $colsTitles[] = __('Marques-pages'); + } + if ($book->parametres->print) { + $colsTitles[] = __('Impressions'); + } + + $lines = array(); + foreach ($stats->pages->page as $page) { + $p = (string)$page['page']; + if ($p > $book->pages || cubeMath::isOdd($p)) { + continue; + } + if ($p == 0) { + $pagen = '1'; + } elseif ($p == $book->parametres->pages) { + $pagen = $p; + } else { + $pagen = $p; + $pagen .= '-'; + $pagen .= ($p + 1); } - imageline($im, 0 , $y0, 944 , $y0 , $c0); - imagepng($im, $img); + $line = array($pagen); + + if ($book->parametres->stats_score == 1) { + $line[] = $page['score']; + } + $line[] = $page['views']; + $line[] = $page['zooms']; + + if ($book->parametres->bookmark == 1) { + $line[] = $page['bookmarks'] ; + } + if ($book->parametres->print == 1) { + $line[] = $page['prints']; + } + $lines[] = $line; } - $res = '
    ' . $maxpages . '
    '; - $res .= '
    ' . $maxb . '
    '; - $res .= '
    ' . $maxv . '
    '; - $res .= '
    '; - $s = array_reverse(array_pad($s, 12, false), true); - $res .= ''; - foreach($s as $time => $val) { - if (!$val) { - $res .= ''; + $res .= '
    ' . cubeMedia::spacer(75, 20) . '
    '; + return self::table(__('Détail par page') . ' - ' . strftime('%B %Y', $time_page), $colsTitles, $lines, array('liste', 'max')); + } + + public static function detailLiens($book, $stats) + { + $colsTitles = array(__('URL'), __('Clics')); + $lines = array(); + + foreach ($stats->links->link as $link) { + $uurl = (string)$link['url']; + $nb = (string)$link['click']; + if (stristr($uurl, 'mailto:') || stristr($uurl, 'http://') || stristr($uurl, 'https://')) { + $url = substr($uurl, 7); } else { - $res .= '' . strftime('%b %y', $val['time']) . ''; + $url = $uurl; } + if (strlen($url) > 30) { + $url = substr($url, 0, 30) . '...'; + } + + $lines[] = array('' . $url . '', $nb); } - $res .= '' . cubeMedia::spacer(44, 20) . ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= '
    ' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '
    '; - return $res; + + return self::table(__('Liens les plus cliqués'), $colsTitles, $lines, array('liste', 'max')); } - /** - * wsStats::vue_annuelle() - * - * @param mixed $bid - * @param mixed $annee - * @return - */ - public static function vue_annuelle($bid, $annee) + public static function detailSearch($book, $stats) { - return self::vue_globale($bid, $annee); + $colsTitles = array(__('Mot'), __('Recherches')); + $lines = array(); + + foreach ($stats->searches->search as $search) { + $q = $search['query']; + if (strlen($q) > 25) { + $q = '' . substr($q, 0, 25) . ' ...'; + } + $lines[] = array($q, $search['count']); + } + return self::table(__('Mots les plus recherchés'), $colsTitles, $lines, array('liste', 'max')); + } + + public static function detailOrigine($book, $stats) + { + $colsTitles = array(__('Pays'), __('Visiteurs')); + $lines = array(); + + foreach ($stats->countries->country as $country) { + $pays = $country['code']; + $odd = cubeMath::isOdd($i)?' class="odd"':''; + if (!$c = cubeCountry::getCountry($pays)) { + $c = __('Origine inconnue'); + } + $lines[] = array(cubeCountry::getFlag($pays) . ' ' . ucfirst(mb_strtolower($c)) , $country['visitors']); + $i++; + } + return self::table(__('Origine des visiteurs'), $colsTitles, $lines, array('liste', 'max')); } - public static function getQ($book, $max, &$maxp, &$maxpages, &$s) + public static function getQ($max, &$maxp, &$maxpages, &$s) { $maxpages = $maxp; - $q = max($book->pages / 5, 1); + $q = 1; $maxp /= $q; $maxp = max($max * 4, $maxp); $q = $maxpages / $maxp; @@ -591,7 +720,7 @@ class wsStats { } // . $max = max($maxb, $maxv); - self::getQ($bid, $max, $maxp, $maxpages, $s); + self::getQ($max, $maxp, $maxpages, $s); krsort($s); $max = max($maxb, $maxv, $maxp); $months = cubeDate::getMonths($a); @@ -667,165 +796,108 @@ class wsStats { return $res; } - public static function vue_mensuelle($bid, $annee, $mois) + public static function graph_global($bid, $stats) { - $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 »'); - $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 .= '
    ' . self::graph_mensuel($bid, $annee, $mois, $stats) . '
    '; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $i = 0; - foreach ($stats->days->day as $day) { - $odd = cubeMath::isOdd($i)?' class="odd"':''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= ''; - $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)) . '' . $day['places'] . '' . $day['visitors'] . '' . $day['visits'] . '' . $day['views'] . '' . $day['links'] . '
    '; - $res .= extranetPage::bf(); - $res .= extranetPage::bh('stats_detail_pages'); - $res .= ''; - $res .= ''; - $res .= ''; - if ($book->parametres->stats_score) { - $res .= ''; - } - $res .= ''; - $res .= ''; - if ($book->parametres->bookmark) { - $res .= ''; - } - if ($book->parametres->print) { - $res .= ''; - } - - $i = 0; - foreach ($stats->pages->page as $page) { - $p = (string)$page['page']; - if ($p > $book->pages || cubeMath::isOdd($p)) { - continue; - } - if ($p == 0) { - $pagen = '1'; - } elseif ($p == $book->parametres->pages) { - $pagen = $p; - } else { - $pagen = $p; - $pagen .= '-'; - $pagen .= ($p + 1); - } - $odd = cubeMath::isOdd($i)?' class="odd"':''; - $res .= ''; - if ($book->parametres->stats_score == 1) { - $res .= ''; - } - $res .= ''; - $res .= ''; - if ($book->parametres->bookmark == 1) { - $res .= ''; - } - if ($book->parametres->print == 1) { - $res .= ''; + $img = SYSIMG . '/stats/global-' . $bid . '.png'; + $imgw = IMG . '/stats/global-' . $bid . '.png'; + $s = array(); + foreach ($stats->year as $year) { + foreach($year->month as $month) { + $time = mktime(0, 0, 0, intval((string)$month['month']), 15, (string)$month['year']); + $s[$time]['book'] = $month['visits']; + $s[$time]['page'] = $month['pages']; + $s[$time]['time'] = $time; + $s[$time]['visit'] = $month['visitors']; } - $i++; - } - $res .= '
    ' . $core->typo->Titre(__('Détail par page') . ' - ' . strftime('%B %Y', $time_page)) . '
    ' . __('Pages') . '' . __('Score') . '' . __('Vues') . '' . __('Zooms') . '' . __('Marques-pages') . '' . __('Impressions') . '
    ' . $pagen . '' . $page['score'] . '' . $page['views'] . '' . $page['zooms'] . '' . $page['bookmarks'] . '' . $page['prints'] . '
    '; - $res .= extranetPage::bf(); - if ($book->parametres->search == 0) { - $idl = 'stats_links_2'; - $idc = 'stats_country_2'; - } else { - $idl = 'stats_links'; - $idc = 'stats_country'; } - $res .= '
    '; - $res .= extranetPage::bh($idl); - $res .= ''; - $res .= ''; - $res .= ''; - $i = 0; - foreach ($stats->links->link as $link) { - $uurl = (string)$link['url']; - $nb = (string)$link['click']; - if (stristr($uurl, 'mailto:') || stristr($uurl, 'http://')) { - $url = substr($uurl, 7); - } else { - $url = $uurl; - } - if (strlen($url) > 30) { - $url = substr($url, 0, 30) . '...'; - } - $odd = cubeMath::isOdd($i)?' class="odd"':''; - $res .= ''; - $i++; + krsort($s); + $s = array_slice($s, 0, 12, true); + $maxv = 0; + $maxp = 0; + $maxb = 0; + foreach($s as $time => $d) { + $maxb = max($maxb, (string) $d['book']); + $maxp = max($maxp, (string)$d['page']); + $maxv = max($maxv, (string) $d['visit']); } - $res .= '
    ' . $core->typo->Titre(__('Liens les plus cliqués')) . '
    ' . __('URL') . '' . __('Clics') . '
    ' . $url . '' . $nb . '
    '; - $res .= extranetPage::bf(); - if ($book->parametres->search == 1) { - $res .= extranetPage::bh('stats_search'); - $res .= ''; - $res .= ''; - $res .= ''; - $i = 0; - foreach ($stats->searches->search as $search) { - $q = $search['query']; - if (strlen($q) > 25) { - $q = '' . substr($q, 0, 25) . ' ...'; - } - $odd = cubeMath::isOdd($i)?' class="odd"':''; - $res .= ''; + $max = max($maxb, $maxv); + self::getQ($max, $maxp, $maxpages, $s); + $max = max($maxv, $maxb, $maxp, 1); + if (file_exists($img)) { + unlink($img); + } + if (!file_exists($img) || filemtime($img) < cubeDate::round(null, 'H')) { + $im = imagecreatetruecolor(944, 306); + imagelayereffect($im, IMG_EFFECT_REPLACE); + $trans = imagecolorallocatealpha($im, 255, 255, 255, 0); + imagefill($im, 0, 0, $trans); + imagelayereffect($im, IMG_EFFECT_ALPHABLEND); + $i = 1; + $x0 = 900; + $y0 = 305; + $h = 300; + $c0 = imagecolorallocate($im, 0, 0 , 0); + $c1 = imagecolorallocatealpha($im, 81, 78, 73, 64); + $hp = $h * ($maxp / $max)-2; + $mhp = $y0 - $hp-6; + imagesetstyle($im, array($c1, $c1, $c1, $c1, $c1, $trans, $trans, $trans, $trans)); + imageline($im, 0, $y0 - $hp, 944, $y0 - $hp, IMG_COLOR_STYLED); + $c1 = imagecolorallocate($im, 81, 78, 73); + $c2 = imagecolorallocatealpha($im, 245, 77, 0, 64); + $hb = $h * ($maxb / $max)-1; + $mhb = $y0 - $hb-6; + imagesetstyle($im, array($c2, $c2, $c2, $c2, $c2, $trans, $trans, $trans, $trans)); + imageline($im, 0, $y0 - $hb, 944, $y0 - $hb, IMG_COLOR_STYLED); + $c2 = imagecolorallocate($im, 245, 77, 0); + $c3 = imagecolorallocatealpha($im, 194, 211, 19, 32); + $hv = $h * ($maxv / $max); + $mhv = $y0 - $hv-6; + imagesetstyle($im, array($c3, $c3, $c3, $c3, $c3, $trans, $trans, $trans, $trans)); + imageline($im, 0, $y0 - $hv, 944, $y0 - $hv, IMG_COLOR_STYLED); + $c3 = imagecolorallocate($im, 194, 211, 19); + foreach($s as $t) { + $x0 -= 15; + $hp = $h * ($t['page'] / $max)-2; + $hb = $h * ($t['book'] / $max)-1; + $hv = $h * ($t['visit'] / $max); + imagefilledrectangle($im, $x0-40, $y0 - $hp, $x0, $y0, $c1); + imagerectangle($im, $x0-40, $y0 - $hp, $x0, $y0, $c0); + $x0 -= 5; + imagefilledrectangle($im, $x0-40, $y0 - $hb, $x0, $y0, $c2); + imagerectangle($im, $x0-40, $y0 - $hb, $x0, $y0, $c0); + $x0 -= 5; + imagefilledrectangle($im, $x0-40, $y0 - $hv, $x0, $y0, $c3); + imagerectangle($im, $x0-40, $y0 - $hv, $x0, $y0, $c0); $i++; + $x0 -= 50; } - $res .= '
    ' . $core->typo->Titre(__('Mots les plus recherchés')) . '
    ' . __('Mot') . '' . __('Recherches') . '
    ' . $q . '' . $search['count'] . '
    '; - $res .= extranetPage::bf(); - } - $res .= extranetPage::bh($idc); - $res .= ''; - $res .= ''; - $res .= ''; - $i = 0; - foreach ($stats->countries->country as $country) { - $pays = $country['code']; - $odd = cubeMath::isOdd($i)?' class="odd"':''; - if (!$c = cubeCountry::getCountry($pays)) { - $c = __('Origine inconnue'); + imageline($im, 0 , $y0, 944 , $y0 , $c0); + imagepng($im, $img); + } + $res = '
    ' . $maxpages . '
    '; + $res .= '
    ' . $maxb . '
    '; + $res .= '
    ' . $maxv . '
    '; + $res .= '
    '; + $s = array_reverse(array_pad($s, 12, false), true); + $res .= '
    ' . $core->typo->Titre(__('Origine des visiteurs')) . '
    ' . __('Pays') . '' . __('Visiteurs') . '
    '; + foreach($s as $time => $val) { + if (!$val) { + $res .= ''; + } else { + $res .= ''; } - $res .= ''; - $i++; } - $res .= '
    ' . cubeMedia::spacer(75, 20) . '' . strftime('%b %y', $val['time']) . '' . cubeCountry::getFlag($pays) . ' ' . ucfirst(mb_strtolower($c)) . '' . $country['visitors'] . '
    '; - $res .= extranetPage::bf(); - $res .= '
    '; + $res .= '' . cubeMedia::spacer(44, 20) . ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= '
    ' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '
'; return $res; } @@ -851,7 +923,7 @@ class wsStats { $s[$time]['time'] = $time; } $max = max($maxb, $maxv); - self::getQ($bid, $max, $maxp, $maxpages, $s); + self::getQ($max, $maxp, $maxpages, $s); krsort($s); $max = max($maxv, $maxb, $maxp); $days = cubeDate::getDays($a, $m); diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index fc9bdf678..e6ce17541 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -119,6 +119,12 @@ html{height:100%}' . "\n"; return wsStats::display($bid, $annee, $mois); } + public static function statsxls($args) + { + $bid = (isset($args[1]))?$args[1]:null; + wsStats::exportXLS($bid); + } + public static function editComposition($args) { $fv = array(session_name() => session_id(),