From cf6e1b33ca66a0e0aa72e29813d8c25ada63ebf6 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Tue, 21 Dec 2021 20:01:00 +0000 Subject: [PATCH] wip #4978 @0.5 --- composer.json | 15 ++++- inc/ws/Controlleur/class.ws.maintenance.php | 10 +++ inc/ws/Controlleur/class.ws.stats.php | 66 ++++++++++--------- .../html5/master/class.ws.html5.compiler.php | 10 +++ 4 files changed, 70 insertions(+), 31 deletions(-) diff --git a/composer.json b/composer.json index f8bb31ba3..04d2d8a55 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,22 @@ { + "name": "fluidbook\/workshop", + "description": "Fluidbook Workshop", + "type": "project", + "license": "proprietary", + "minimum-stability": "dev", + "repositories": [ + { + "type": "composer", + "url": "https://composer.cubedesigners.com/" + } + ], + "require": { "php": ">=7.2", "php-mime-mail-parser/php-mime-mail-parser": "2.11.1", "jaybizzle/crawler-detect": "^1.2", "ext-mbstring": "*", - "ext-simplexml": "*" + "ext-simplexml": "*", + "cubist/matomo": "dev-master" } } diff --git a/inc/ws/Controlleur/class.ws.maintenance.php b/inc/ws/Controlleur/class.ws.maintenance.php index 1bece9913..8509a64c3 100644 --- a/inc/ws/Controlleur/class.ws.maintenance.php +++ b/inc/ws/Controlleur/class.ws.maintenance.php @@ -1803,6 +1803,16 @@ class wsMaintenance exit; } + public static function matomo() + { + try { + $reporting = new \Cubist\Matomo\Reporting('https://v3.stats.fluidbook.com/', 'ebe362f44c01bda1ddedb75d7726ff78'); + print_r($reporting->createSiteIfNotExistsOrReturnId('Fluidbook Y', 'https://fluidbook.y')); + } catch (Exception $e) { + print_r($e); + } + } + } diff --git a/inc/ws/Controlleur/class.ws.stats.php b/inc/ws/Controlleur/class.ws.stats.php index 5b60b58f3..b40ed1460 100644 --- a/inc/ws/Controlleur/class.ws.stats.php +++ b/inc/ws/Controlleur/class.ws.stats.php @@ -417,8 +417,8 @@ class wsStats $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 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) { @@ -572,7 +572,7 @@ class wsStats $title = ''; $colsTitles = array(__('Période'), /*__('Lieux de visite'),*/ - __('Visiteurs uniques'), __('Visites'), __('Pages vues')); + /*__('Visiteurs uniques'),*/ __('Visites'), __('Pages vues')); if ($afriend) { $colsTitles[] = __('Liens envoyés'); } @@ -663,7 +663,7 @@ class wsStats $line[] = '' . $date . ''; //$line[] = $stats['places']; - $line[] = $stats['visitors']; + //$line[] = $stats['visitors']; $line[] = $stats['visits']; $line[] = $stats['pages']; if ($afriend) { @@ -689,20 +689,20 @@ class wsStats public static function detailJour($book, $annee, $mois, $stats) { $colsTitles = array(__('Jour'), /*__('Lieux de visite'),*/ - __('Visiteurs uniques'), __('Visites'), __('Pages vues'), __('Liens cliqués')); + /*__('Visiteurs uniques'),*/ __('Visites'), __('Pages vues'), __('Liens cliqués')); $lines = array(); $xlines = 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['visitors'], $day['visits'], $day['views'], $day['links']); $xlines[] = array(strftime('%d', mktime(0, 0, 0, $mois, (string)$day['day'], $annee)), //$day['places'], - $day['visitors'], + //$day['visitors'], $day['visits'], $day['views'], $day['links']); @@ -812,7 +812,7 @@ class wsStats public static function detailOrigine($book, $stats) { - $colsTitles = array(__('Pays'), __('Visiteurs')); + $colsTitles = array(__('Pays'), __('Visits')); $lines = array(); $xlines = array(); $i = 0; @@ -894,9 +894,9 @@ class wsStats $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); +// 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; @@ -909,8 +909,8 @@ class wsStats 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); +// imagefilledrectangle($im, $x0 + 40, $y0 - $hv, $x0, $y0, $c3); +// imagerectangle($im, $x0 + 40, $y0 - $hv, $x0, $y0, $c0); $i++; $x0 += 50; } else { @@ -923,7 +923,7 @@ class wsStats } $res = '
' . $maxpages . '
'; $res .= '
' . $maxb . '
'; - $res .= '
' . $maxv . '
'; + // $res .= '
' . $maxv . '
'; $res .= '
'; $res .= ''; foreach ($months as $m => $t) { @@ -934,7 +934,7 @@ class wsStats $res .= '
'; $res .= ''; $res .= ''; - $res .= ''; + //$res .= ''; $res .= '
' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '' . __('Visiteurs uniques') . '
'; return $res; } @@ -998,9 +998,9 @@ class wsStats $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); +// 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; @@ -1012,18 +1012,17 @@ class wsStats 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); +// 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 .= '
' . $maxv . '
'; $res .= '
'; $s = array_reverse(array_pad($s, 12, false), true); $res .= ''; @@ -1039,7 +1038,7 @@ class wsStats $res .= '
'; $res .= ''; $res .= ''; - $res .= ''; + // $res .= ''; $res .= '
' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '' . __('Visiteurs uniques') . '
'; return $res; } @@ -1099,9 +1098,9 @@ class wsStats $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); +// 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; @@ -1114,8 +1113,8 @@ class wsStats 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); +// imagefilledrectangle($im, $x0 + 14, $y0 - $hv, $x0, $y0, $c3); +// imagerectangle($im, $x0 + 14, $y0 - $hv, $x0, $y0, $c0); $i++; $x0 += 14 + $space; } else { @@ -1128,7 +1127,7 @@ class wsStats } $res = '
' . $maxpages . '
'; $res .= '
' . $maxb . '
'; - $res .= '
' . $maxv . '
'; + // $res .= '
' . $maxv . '
'; $res .= '
'; $res .= ''; foreach ($days as $d => $t) { @@ -1140,7 +1139,7 @@ class wsStats $res .= '
'; $res .= ''; $res .= ''; - $res .= ''; + // $res .= ''; $res .= '
' . __('Pages vues') . '' . __('Visites') . '' . __('Visiteurs uniques') . '' . __('Visiteurs uniques') . '
'; return $res; } @@ -1149,4 +1148,11 @@ class wsStats { `/home/stats/www/FWStats.sh /home/stats/www onlybook=$id`; } + + /** + * @return \Cubist\Matomo\Reporting + */ + public static function getMatomoAPI(){ + return new \Cubist\Matomo\Reporting('https://v3.stats.fluidbook.com/','ebe362f44c01bda1ddedb75d7726ff78'); + } } \ No newline at end of file diff --git a/inc/ws/Util/html5/master/class.ws.html5.compiler.php b/inc/ws/Util/html5/master/class.ws.html5.compiler.php index 2bf4d4dd6..da68ae664 100644 --- a/inc/ws/Util/html5/master/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/master/class.ws.html5.compiler.php @@ -984,6 +984,13 @@ class wsHTML5Compiler protected function writeStats() { global $core; + + if ($this->book->parametres->stats) { + $this->book->parametres->statsMatomo = wsStats::getMatomoAPI()->createSiteIfNotExistsOrReturnId('Fluidbook #' . $this->book_id, 'https://' . $this->book_id . '.fluidbook'); + } else { + $this->book->parametres->statsMatomo = false; + } + if ($this->book->parametres->tagcommander_id) { $id = $this->book->parametres->tagcommander_id; if (!$this->book->parametres->tagcommander_prod) { @@ -1521,6 +1528,9 @@ height="0" width="0" style="display:none;visibility:hidden"> $svg = str_replace('$bookmark-color', wsHTML5::colorToCSS($this->theme->parametres->bookmarkBackgroundColor), $svg); $res = []; $xml = simplexml_load_string($svg); + if (!$xml) { + return $res; + } $xml->registerXPathNamespace('svg', 'http://www.w3.org/2000/svg'); foreach ($xml->xpath('//svg:symbol') as $item) { $res[(string)$item['id']] = $item->asXML(); -- 2.39.5