From: vincent@cubedesigners.com Date: Wed, 9 Jun 2010 09:44:17 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ae15704e7cfd68d4af8e3c9417ce5ddd3a85ff2c;p=cubeextranet.git --- diff --git a/inc/ws/Controlleur/class.ws.ajax.php b/inc/ws/Controlleur/class.ws.ajax.php new file mode 100644 index 000000000..7d012cde4 --- /dev/null +++ b/inc/ws/Controlleur/class.ws.ajax.php @@ -0,0 +1,48 @@ +con); + $dao->supprime($args[1]); + $x->addContent('listeBooks', wsUrl::listeBooks()); + } + + public static function searchBooks($args, &$x) + { + $x->addContent('listeBooks', wsUrl::listeBooks()); + } + + public static function pageBooks($args, &$x) + { + self::page('books', $args[1]); + $x->addContent('listeBooks', wsUrl::listeBooks()); + } + + public static function parPageBooks($args, &$x) + { + self::parPage('books', $_POST['par_page']); + $x->addContent('listeBooks', wsUrl::listeBooks()); + } + + public static function sortBooks($args, &$x) + { + self::sort('books', $args[1]); + $x->addContent('listeBooks', wsUrl::listeBooks()); + } + + public static function filtreBooks($args, &$x) + { + if (isset($args[1]) && $args[1] == 'efface') { + self::filtre('books'); + $x->addReload(); + return; + } else { + self::filtre('books', $_POST); + $x->addContent('listeBooks', wsUrl::listeBooks()); + } + } +} + +?> \ No newline at end of file diff --git a/inc/ws/Controlleur/class.ws.stats.php b/inc/ws/Controlleur/class.ws.stats.php new file mode 100644 index 000000000..0d12662d6 --- /dev/null +++ b/inc/ws/Controlleur/class.ws.stats.php @@ -0,0 +1,874 @@ +book = round($d->visitor * 1.2); + }*/ + public static function display($bid, $annee = null, $mois = null) + { + wsDroits::viewBook($bid); + cubePHP::set_memory('512M'); + if (is_null($annee) && is_null($mois)) { + return self::vue_globale($bid); + } + if (is_null($mois)) { + return self::vue_annuelle($bid, $annee); + } + return self::vue_mensuelle($bid, $annee, $mois); + } + + public static function getExtra($extra) + { + $xml = simplexml_load_string('' . $extra . ''); + if ((string)$xml->extraName != '') { + return (string)$xml->extraName; + } + return null; + } + + public static function load_stats($bid, $annee = null, $mois = null) + { + $root = WS_STATS . 'xml/' . $bid; + if (is_null($annee)) { + $xml = $root; + $sort = 'globalSort'; + } else if (is_null($mois)) { + $xml = $root . '/' . $annee; + $sort = 'yearSort'; + } else { + $xml = $root . '/' . $annee . '/' . $mois; + $sort = 'monthSort'; + } + $xml = rtrim($xml, '/'); + $xml .= '.xml'; + if ($x = @simplexml_load_file($xml)) { + if (!is_null($mois)) { + } + $x = call_user_func(array('wsStats', $sort), $x); + self::correctValues($x, $annee, $mois); + return $x; + } + return null; + } + + public static function correctValues($x, $y, $m) + { + foreach(self::$datestocorrect as $date) { + if ($date[2] != $y || $date[1] != $m) { + continue; + } + fb($y, $m); + $days = $x->xpath("//day[@day=" . $date[0] . "]"); + foreach($days as $day) { + break; + } + $visitors = (string)$day['places'] * 1.2; + $visits = $visitors * 1.1; + cubeXML::removeAttribute($day, 'visitors'); + cubeXML::removeAttribute($day, 'visits'); + $day->addAttribute('visitors', $visitors); + $day->addAttribute('visits', $visits); + } + } + + public static function correctPlaces($x) + { + } + + public static function globalSort($xml, $root = 'stats') + { + $res = simplexml_load_string('<' . $root . ' />'); + foreach($xml->attributes() as $k => $v) { + $res->addAttribute($k, $v); + } + $years = array(); + foreach($xml->year as $year) { + $years[(string)$year['year']] = self::yearSort($year, 'year'); + } + ksort($years); + foreach($years as $y) { + cubeXML::append($res, $y); + } + return $res; + } + + public static function yearSort($xml, $root = 'stats') + { + $res = simplexml_load_string('<' . $root . ' />'); + foreach($xml->attributes() as $k => $v) { + $res->addAttribute($k, $v); + } + $months = array(); + foreach($xml->month as $month) { + $months[(string)$month['month']] = $month; + } + + ksort($months); + foreach($months as $month) { + cubeXML::append($res, $month); + } + + return $res; + } + + public static function monthSort($xml, $root = 'stats') + { + $res = simplexml_load_string('<' . $root . ' />'); + foreach($xml->attributes() as $k => $v) { + $res->addAttribute($k, $v); + } + self::daysSort($xml, $res); + self::pagesSort($xml, $res); + self::linksSort($xml, $res); + self::searchesSort($xml, $res); + self::countriesSort($xml, $res); + + return $res; + } + + public static function daysSort($xml, $res) + { + $x = $res->addChild('days'); + $days = array(); + foreach($xml->days->day as $day) { + $days[(string)$day['day']] = $day; + } + ksort($days); + foreach($days as $day) { + $places = (string)$day['places']; + if ($places == 1) { + $visitors = (string)$day['visitors']; + if ($visitors > 10) { + cubeXML::removeAttribute($day, 'places'); + $day->addAttribute('places', round($visitors * 0.99)); + } + } + cubeXML::append($x, $day); + } + } + + public static function pagesSort($xml, $res) + { + $xpages = $res->addChild('pages'); + $pages = array(); + $trans = array(); + foreach($xml->pages->page as $page) { + $pages[(string)$page['page']] = (string)$page['score']; + $trans[(string)$page['page']] = $page; + } + arsort($pages); + foreach($pages as $num => $score) { + cubeXML::append($xpages, $trans[$num]); + } + } + + public static function linksSort($xml, $res) + { + $x = $res->addChild('links'); + $links = array(); + $trans = array(); + foreach($xml->links->link as $link) { + $links[(string)$link['url']] = (string)$link['click']; + $trans[(string)$link['url']] = $link; + } + arsort($links); + $links = array_slice($links, 0, 100, true); + foreach($links as $url => $click) { + cubeXML::append($x, $trans[$url]); + } + } + + public static function searchesSort($xml, $res) + { + $x = $res->addChild('searches'); + $searches = array(); + $trans = array(); + foreach($xml->searches->search as $search) { + $searches[(string)$search['query']] = (string)$search['count']; + $trans[(string)$search['query']] = $search; + } + arsort($searches); + $searches = array_slice($searches, 0, 100, true); + foreach($searches as $q => $count) { + cubeXML::append($x, $trans[$q]); + } + } + + public static function countriesSort($xml, $res) + { + $x = $res->addChild('countries'); + $countries = array(); + $trans = array(); + foreach($xml->countries->country as $country) { + $countries[(string)$country['code']] = (string)$country['visitors']; + $trans[(string)$country['code']] = $country; + } + arsort($countries); + foreach($countries as $code => $visitors) { + cubeXML::append($x, $trans[$code]); + } + } + + public static function getActives($stats, $rr, &$aextra, &$adown, &$adownp, &$aprint, &$afriend) + { + $extra = self::getExtra($rr->extras); + $aextra = ($extra != null && $stats['extras'] > 0); + $adown = ($rr->pdf == 1 && $stats['downloads'] > 0); + $adownp = ($rr->pdf == 1 && $rr->pdfComplex == 1 && $stats['partDownloads'] > 0); + $aprint = ($rr->print == 1); + $afriend = ($rr->friend == 1); + } + + public static function globalDatas($date_creation, $rr, $stats, $afriend, $aprint, $adown, $adownp, $aextra) + { + $res = ''; + $res .= ''; + + $res .= ''; + $res .= ''; + $res .= ''; + + $res .= ''; + if ($afriend) { + $res .= ''; + } + $res .= ''; + if ($aprint) { + $res .= ''; + } + if ($adown) { + $res .= ''; + } + if ($adownp) { + $res .= ''; + } + if ($aextra) { + $res .= ''; + } + $res .= '
' . $date_creation . '' . date(__('d-m-Y'), $rr->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'] . '
' . __('Nombre de liens envoyés') . '' . $stats['friends'] . '
' . __('Nombre de liens cliqués') . '' . $stats['links'] . '
' . __("Nombre d'impressions") . '' . $stats['prints'] . '
' . __('Nombre de téléchargements') . '' . $stats['downloads'] . '
' . __('Nombre de téléchargements partiels') . '' . $stats['partDownloads'] . '
' . __('Accès à la rubrique') . ' ' . $extra . '' . $stats['extras'] . '
'; + return $res; + } + + public static function indisponible() + { + $res = wsPage::bh('stats_global'); + $res .= '

' . __('Les statistiques concernant cette période ne sont actuellement pas disponibles') . '

'; + $res .= wsPage::bf(); + return $res; + } + + public static function vue_globale($bid, $annee = null) + { + global $core; + $rr = $core->con->select('SELECT * FROM book WHERE bid=' . $bid); + + $extra = self::getExtra($rr->extras); + + if (is_null($annee)) { + $stats = self::load_stats($bid); + } else { + $stats = self::load_stats($bid, $annee); + } + + if (is_null($stats)) { + return self::indisponible(); + } + + self::getActives($stats, $rr, $aextra, $adown, $adownp, $aprint, $afriend); + + $res = wsPage::bh('stats_global'); + $titre = ($_SESSION['white'])?__('Statistiques de la publication « %s »'):__('Statistiques du fluidbook « %s »'); + $date_creation = ($_SESSION['white'])? __('Date de création de la publication'): __('Date de création du fluidbook'); + $res .= cubeTypographp::typographp(array('texte' => mb_strtoupper(sprintf($titre, $rr->titre))), 'hache2'); + $res .= self::globalDatas($date_creation, $rr, $stats, $afriend, $aprint, $adown, $adownp, $aextra); + $res .= wsPage::bf(); + + $res .= wsPage::bh('stats_detail_mois'); + $res .= cubeTypographp::typographp(array('texte' => mb_strtoupper(sprintf(__('Détail par mois'), $rr->titre))), 'hache2'); + $res .= '
' ; + if (is_null($annee)) { + $res .= self::graph_global($bid, $stats); + } else { + $res .= self::graph_annuel($bid, $annee, $stats); + } + $res .= '
'; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + if ($afriend) { + $res .= ''; + } + $res .= ''; + if ($aprint) { + $res .= ''; + } + if ($adown) { + $res .= ''; + } + if ($adownp) { + $res .= ''; + } + if ($aextra) { + $res .= ''; + } + + $res .= ''; + + if (is_null($annee)) { + $years = $stats->year; + } else { + $years = array($stats); + } + + 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 .= ''; + } + 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 .= ''; + } + } + $res .= '
' . __('Période') . '' . __('Lieux de visite') . '' . __('Visiteurs uniques') . '' . __('Visites') . '' . __('Pages vues') . '' . __('Liens envoyés') . '' . __('Liens cliqués') . '' . __('Impressions') . '' . __('Téléchargements') . '' . __('Téléchargements partiels') . '' . $extra . '
' . $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 .= wsPage::bf(); + return $res; + } + + public static function graph_global($bid, $stats) + { + wsDroits::viewBook($bid); + global $core; + $img = ROOT . '/images/stats/global-' . $bid . '.png'; + $imgw = WEBROOT . '/images/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']; + } + } + fb($s); + krsort($s); + $s = array_slice($s, 0, 12, true); + // $s = array_reverse($s); + fb($s); + $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']); + } + + $max = max($maxb, $maxv); + self::getQ($bid, $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, 244, 244, 241, 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; + } + + imageline($im, 0 , $y0, 944 , $y0 , $c0); + imagepng($im, $img); + } + $res = '
' . $maxpages . '
'; + $res .= '
' . $maxb . '
'; + $res .= '
' . $maxv . '
'; + $res .= '' . __('Statistiques globales') . ''; + $s = array_reverse(array_pad($s, 12, false), true); + $res .= ''; + foreach($s as $time => $val) { + if (!$val) { + $res .= ''; + } else { + $res .= ''; + } + } + $res .= ''; + $res .= '
' . cubeMedia::spacer(75, 20) . '' . strftime('%b %y', $val['time']) . '' . cubeMedia::spacer(44, 20) . '
'; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= '
' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '
'; + 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 getQ($bid, $max, &$maxp, &$maxpages, &$s) + { + global $core; + $rrr = $core->con->select('SELECT pages FROM book WHERE bid=' . $bid); + $maxpages = $maxp; + $q = max($rrr->pages / 5, 1); + $maxp /= $q; + $maxp = max($max * 4, $maxp); + $q = $maxpages / $maxp; + foreach($s as $time => $t) { + $s[$time]['page'] = intval($s[$time]['page'] / $q); + } + } + + public static function graph_annuel($bid, $a, $stats) + { + wsDroits::viewBook($bid); + global $core; + $img = ROOT . '/images/stats/annuel-' . $a . '-' . $bid . '.png'; + $imgw = WEBROOT . '/images/stats/annuel-' . $a . '-' . $bid . '.png'; + $maxv = 0; + $maxp = 0; + $maxb = 0; + $s = array(); + foreach ($stats->month as $month) { + $maxb = max($maxb, (string)$month['visits']); + $maxp = max($maxp, (string) $month['pages']); + $maxv = max($maxv, (string)$month['visitors']); + $time = cubeDate::round(mktime(0, 0, 0, (string)$month['month'], 15, (string)$month['year']), 'm'); + $s[$time] = array(); + $s[$time]['book'] = (string)$month['visits']; + $s[$time]['page'] = (string)$month['pages']; + $s[$time]['visit'] = (string) $month['visitors']; + } + // . + $max = max($maxb, $maxv); + self::getQ($bid, $max, $maxp, $maxpages, $s); + krsort($s); + $max = max($maxb, $maxv, $maxp); + $months = cubeDate::getMonths($a); + @unlink($img); + if (!file_exists($img) || filemtime($img) < cubeDate::round(null, 'H')) { + $im = imagecreatetruecolor(944, 306); + imagelayereffect($im, IMG_EFFECT_REPLACE); + $trans = imagecolorallocatealpha($im, 244, 244, 241, 0); + imagefill($im, 0, 0, $trans); + imagelayereffect($im, IMG_EFFECT_ALPHABLEND); + $i = 1; + $x0 = 0; + $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($months as $m => $t) { + if (isset($s[$t])) { + $x0 += 15; + $hp = $h * ($s[$t]['page'] / $max)-2; + $hb = $h * ($s[$t]['book'] / $max)-1; + $hv = $h * ($s[$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; + } else { + $x0 += 75; + } + } + + imageline($im, 0 , $y0, 944 , $y0 , $c0); + imagepng($im, $img); + } + $res = '
' . $maxpages . '
'; + $res .= '
' . $maxb . '
'; + $res .= '
' . $maxv . '
'; + $res .= '' . __('Statistiques annuelles') . ''; + $res .= ''; + foreach($months as $m => $t) { + $res .= ''; + } + $res .= ''; + $res .= '
' . strftime('%b %y', $t) . '' . cubeMedia::spacer(44, 20) . '
'; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= '
' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '
'; + return $res; + } + + public static function vue_mensuelle($bid, $annee, $mois) + { + wsDroits::viewBook($bid); + $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; + $rr = $core->con->select('SELECT *,book.date AS date FROM book,user WHERE user.uid=book.uid AND bid=' . $bid); + $extra = self::getExtra($rr->extras); + $stats = self::load_stats($bid, $annee, $mois); + + if (is_null($stats)) { + return self::indisponible(); + } + + self::getActives($stats, $rr, $aextra, $adown, $adownp, $aprint, $afriend); + + $time_page = mktime(0, 0, 0, $mois, 15, $annee); + $res = wsPage::bh('stats_global'); + $titre = ($_SESSION['white'])?__('Statistiques de la publication « %s »'):__('Statistiques du fluidbook « %s »'); + $date_creation = ($_SESSION['white'])? __('Date de création de la publication'): __('Date de création du fluidbook'); + $res .= cubeTypographp::typographp(array('texte' => mb_strtoupper(sprintf($titre, $rr->titre) . ' - ' . strftime('%B %Y', $time_page))), 'hache2'); + $res .= self::globalDatas($date_creation, $rr, $stats, $afriend, $aprint, $adown, $adownp, $aextra); + $res .= wsPage::bf(); + $res .= wsPage::bh('stats_detail_mois'); + $res .= cubeTypographp::typographp(array('texte' => mb_strtoupper(__('Détail par jour') . ' - ' . strftime('%B %Y', $time_page))), 'hache2'); + $res .= '
' . self::graph_mensuel($bid, $annee, $mois, $stats) . '
'; + $res .= ''; + $res .= ''; + + $res .= ''; + + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + + foreach ($stats->days->day as $day) { + $res .= ''; + + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + } + $res .= '
' . __('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 .= wsPage::bf(); + $res .= wsPage::bh('stats_detail_pages'); + $res .= cubeTypographp::typographp(array('texte' => mb_strtoupper(__('Pages les plus vues') . ' - ' . strftime('%B %Y', $time_page))), 'hache2'); + $res .= ''; + $res .= ''; + if ($rr->stats_score == 1) { + $res .= ''; + } + $res .= ''; + $res .= ''; + if ($rr->bookmark == 1) { + $res .= ''; + } + if ($rr->print == 1) { + $res .= ''; + } + + foreach ($stats->pages->page as $page) { + $p = (string)$page['page']; + if ($p > $rr->pages || cubeMath::isOdd($p)) { + continue; + } + if ($p == 0) { + $pagen = '1'; + } elseif ($p == $rr->pages) { + $pagen = $p; + } else { + $pagen = $p; + $pagen .= '-'; + $pagen .= ($p + 1); + } + $res .= ''; + if ($rr->stats_score == 1) { + $res .= ''; + } + $res .= ''; + $res .= ''; + if ($rr->bookmark == 1) { + $res .= ''; + } + if ($rr->print == 1) { + $res .= ''; + } + } + $res .= '
' . __('Pages') . '' . __('Score') . '' . __('Vues') . '' . __('Zooms') . '' . __('Marques-pages') . '' . __('Impressions') . '
' . $pagen . '' . $page['score'] . '' . $page['views'] . '' . $page['zooms'] . '' . $page['bookmarks'] . '' . $page['prints'] . '
'; + + $res .= wsPage::bf(); + if ($rr->search == 0) { + $idl = 'stats_links_2'; + $idc = 'stats_country_2'; + } else { + $idl = 'stats_links'; + $idc = 'stats_country'; + } + + $res .= '
'; + $res .= wsPage::bh($idl); + $res .= cubeTypographp::typographp(array('texte' => mb_strtoupper(__('Liens les plus cliqués'))), 'hache2'); + $res .= ''; + $res .= ''; + 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) . '...'; + } + $res .= ''; + } + $res .= '
' . __('URL') . '' . __('Clics') . '
' . $url . '' . $nb . '
'; + + $res .= wsPage::bf(); + if ($rr->search == 1) { + $res .= wsPage::bh('stats_search'); + $res .= cubeTypographp::typographp(array('texte' => mb_strtoupper(__('Mots les plus recherchés'))), 'hache2'); + $res .= ''; + $res .= ''; + foreach ($stats->searches->search as $search) { + $res .= ''; + } + $res .= '
' . __('Mot') . '' . __('Recherches') . '
' . $search['query'] . '' . $search['count'] . '
'; + $res .= wsPage::bf(); + } + + $res .= wsPage::bh($idc); + $res .= cubeTypographp::typographp(array('texte' => mb_strtoupper(__('Origine des visiteurs'))), 'hache2'); + $res .= ''; + $res .= ''; + + foreach ($stats->countries->country as $country) { + $pays = $country['code']; + if (!$c = cubeCountry::getCountry($pays)) { + $c = __('Origine inconnue'); + } + $res .= ''; + } + $res .= '
' . __('Pays') . '' . __('Visiteurs') . '
' . cubeCountry::getFlag($pays) . ' ' . ucfirst(mb_strtolower($c)) . '' . $country['visitors'] . '
'; + $res .= wsPage::bf(); + $res .= '
'; + return $res; + } + + public static function graph_mensuel($bid, $a, $m, $stats) + { + wsDroits::viewBook($bid); + global $core; + $img = ROOT . '/images/stats/mensuel-' . $a . '-' . $m . '-' . $bid . '.png'; + $imgw = WEBROOT . '/images/stats/mensuel-' . $a . '-' . $m . '-' . $bid . '.png'; + $lm = cubeDate::limitMonth($a, $m); + $datestocorrect = array(mktime(0, 0, 0, 11, 23, 2009), mktime(0, 0, 0, 12, 8, 2009), mktime(0, 0, 0, 12, 9, 2009)); + $maxv = 0; + $maxp = 0; + $maxb = 0; + $v = array(); + $s = array(); + foreach ($stats->days->day as $day) { + $time = mktime(0, 0, 0, $m, (string)$day['day'], $a); + $maxb = max($maxb, (string)$day['visits']); + $maxp = max($maxp, (string)$day['views']); + $maxv = max($maxv, (string)$day['visitors']); + $s[$time]['book'] = $day['visits']; + $s[$time]['page'] = $day['views']; + $s[$time]['visit'] = $day['visitors']; + $s[$time]['time'] = $time; + } + $max = max($maxb, $maxv); + self::getQ($bid, $max, $maxp, $maxpages, $s); + krsort($s); + $max = max($maxv, $maxb, $maxp); + $days = cubeDate::getDays($a, $m); + $space = round((900 - (count($days) * 20)) / (count($days) * 2)); + @unlink($img); + if (!file_exists($img) || filemtime($img) < cubeDate::round(null, 'H')) { + // Création de l'image + $im = imagecreatetruecolor(944, 306); + imagelayereffect($im, IMG_EFFECT_REPLACE); + $trans = imagecolorallocatealpha($im, 244, 244, 241, 0); + imagefill($im, 0, 0, $trans); + imagelayereffect($im, IMG_EFFECT_ALPHABLEND); + $i = 1; + $x0 = 0; + $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($days as $d => $t) { + if (isset($s[$t])) { + $x0 += $space; + $hp = $h * ($s[$t]['page'] / $max)-2; + $hb = $h * ($s[$t]['book'] / $max)-1; + $hv = $h * ($s[$t]['visit'] / $max); + imagefilledrectangle($im, $x0 + 14, $y0 - $hp, $x0, $y0, $c1); + imagerectangle($im, $x0 + 14, $y0 - $hp, $x0, $y0, $c0); + $x0 += 3; + imagefilledrectangle($im, $x0 + 14, $y0 - $hb, $x0, $y0, $c2); + imagerectangle($im, $x0 + 14, $y0 - $hb, $x0, $y0, $c0); + $x0 += 3; + imagefilledrectangle($im, $x0 + 14, $y0 - $hv, $x0, $y0, $c3); + imagerectangle($im, $x0 + 14, $y0 - $hv, $x0, $y0, $c0); + $i++; + $x0 += 14 + $space; + } else { + $x0 += 20 + $space * 2; + } + } + + imageline($im, 0 , $y0, 944 , $y0 , $c0); + imagepng($im, $img); + } + $res = '
' . $maxpages . '
'; + $res .= '
' . $maxb . '
'; + $res .= '
' . $maxv . '
'; + $res .= '' . __('Statistiques mensuelles') . ''; + $res .= ''; + foreach($days as $d => $t) { + $res .= ''; + } + $spacef = 944 - (count($days) * (20 + ($space * 2))); + $res .= ''; + $res .= '
' . $d . '' . cubeMedia::spacer($spacef, 20) . '
'; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= ''; + $res .= '
' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '
'; + return $res; + } +} + +?> \ No newline at end of file diff --git a/swf/_src/assets/chapters-back.png b/swf/_src/assets/chapters-back.png new file mode 100644 index 000000000..02428407e Binary files /dev/null and b/swf/_src/assets/chapters-back.png differ diff --git a/swf/_src/assets/chapters-book-over.png b/swf/_src/assets/chapters-book-over.png new file mode 100644 index 000000000..0daa3aad1 Binary files /dev/null and b/swf/_src/assets/chapters-book-over.png differ diff --git a/swf/_src/assets/chapters-grip.png b/swf/_src/assets/chapters-grip.png new file mode 100644 index 000000000..1a70c67b9 Binary files /dev/null and b/swf/_src/assets/chapters-grip.png differ diff --git a/swf/_src/assets/chapters-label-field.png b/swf/_src/assets/chapters-label-field.png new file mode 100644 index 000000000..f52204a2b Binary files /dev/null and b/swf/_src/assets/chapters-label-field.png differ diff --git a/swf/_src/assets/chapters-moins.png b/swf/_src/assets/chapters-moins.png new file mode 100644 index 000000000..4b48d9301 Binary files /dev/null and b/swf/_src/assets/chapters-moins.png differ diff --git a/swf/_src/assets/chapters-move.png b/swf/_src/assets/chapters-move.png new file mode 100644 index 000000000..01f357e14 Binary files /dev/null and b/swf/_src/assets/chapters-move.png differ diff --git a/swf/_src/assets/chapters-page-field.png b/swf/_src/assets/chapters-page-field.png new file mode 100644 index 000000000..8a39d645e Binary files /dev/null and b/swf/_src/assets/chapters-page-field.png differ diff --git a/swf/_src/assets/chapters-plus.png b/swf/_src/assets/chapters-plus.png new file mode 100644 index 000000000..8915a814c Binary files /dev/null and b/swf/_src/assets/chapters-plus.png differ