From: Vincent Vanwaelscappel Date: Mon, 12 Jun 2023 11:57:52 +0000 (+0200) Subject: wait #6013 @1.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3b1fee8d04256c792b85d6d2427ea5be0d5fcf7a;p=fluidbook-toolbox.git wait #6013 @1.5 --- diff --git a/app/Fluidbook/Compiler/Links.php b/app/Fluidbook/Compiler/Links.php index c08b8cac4..ecc5b7215 100644 --- a/app/Fluidbook/Compiler/Links.php +++ b/app/Fluidbook/Compiler/Links.php @@ -135,7 +135,7 @@ trait Links foreach ($linksCopy as $k => $linkData) { - if ($this->fluidbookSettings->PDFRendererIframe === 'svg' && (($linkData['type'] == Link::IFRAME && stristr($linkData['to'], '.pdf')) || ($linkData['type'] == Link::MULTIMEDIA && stristr($linkData['alternative'], '.pdf')))) { + if ($this->fluidbookSettings->PDFRendererIframe === 'svg' && (($linkData['type'] == Link::IFRAME && stristr($linkData['to'], '.pdf')) || ($linkData['type'] == Link::MULTIMEDIA && stristr($linkData['to'], '.pdf')))) { $ofile = $this->wdir . '/' . $linkData['to']; $dfile = $this->wdir . '/' . $linkData['to'] . '.svg'; if (!file_exists($dfile) || filemtime($dfile) < filemtime($ofile)) { diff --git a/app/Fluidbook/Stats.php b/app/Fluidbook/Stats.php index dbc1e60c1..f90763346 100644 --- a/app/Fluidbook/Stats.php +++ b/app/Fluidbook/Stats.php @@ -265,8 +265,8 @@ class Stats extends Reporting [ 'label' => __('Visites'), 'backgroundColor' => '#f54d00', // Could make bars semi-transparent if desired - 'borderColor'=> '#000000', - 'borderWidth'=> .75, + 'borderColor' => '#000000', + 'borderWidth' => .75, 'data' => $this->_pagesByPeriod->pluck('nb_visits')->toArray(), 'order' => 1, 'bar_offset' => -5, // Negative offset shifts bar to left @@ -275,8 +275,8 @@ class Stats extends Reporting [ 'label' => __('Pages vues'), 'backgroundColor' => '#514e49', - 'borderColor'=> '#000000', - 'borderWidth'=> .75, + 'borderColor' => '#000000', + 'borderWidth' => .75, 'data' => $this->_pagesByPeriod->pluck('nb_hits')->toArray(), 'order' => 2, 'bar_offset' => 5, // Positive offset shifts bar to right @@ -290,8 +290,8 @@ class Stats extends Reporting [ 'label' => __('Visiteurs uniques'), 'backgroundColor' => 'hsl(72 100% 38% / 100%)', - 'borderColor'=> '#000000', - 'borderWidth'=> .75, + 'borderColor' => '#000000', + 'borderWidth' => .75, 'data' => $this->_pagesByPeriod->pluck('nb_uniq_visitors')->toArray(), 'order' => 1, 'bar_offset' => -8, // Negative offset shifts bar to left @@ -528,9 +528,13 @@ class Stats extends Reporting $pageUrls = collect($this->getPageUrls(['period' => 'range', 'flat' => 1])) ->keyBy('label'); + $pagesAlises = $this->fluidbook->getPagesAliases(); + //=== Group and combine page stats with related data $res = []; for ($page_number = 0; $page_number <= $this->fluidbook->getPagesNumber(); $page_number++) { + $aliases = $pagesAlises[$page_number] ?? []; + if ($this->fluidbook->isOnePage()) { $page_group = $page_number; } else { @@ -550,6 +554,7 @@ class Stats extends Reporting $single_page_data = [ 'page_group' => $page_group, + 'page_aliases' => $aliases, 'page_number' => $page_number, // Used by table column sorter 'nb_pageviews' => $pageUrls["/page/$page_number"]['nb_hits'] ?? 0, 'nb_zooms' => data_get($this->_eventsByPage, "zoom.subtable.$page_number.nb_events", 0), @@ -572,12 +577,18 @@ class Stats extends Reporting $res = []; foreach (func_get_args() as $array) { foreach ($array as $k => $v) { - if (!isset($res[$k])) { - $res[$k] = 0; - } - if (is_numeric($v) && !in_array($k, $exclude)) { + + if (is_array($v)) { + if (!isset($res[$k])) { + $res[$k] = []; + } + $res[$k] = array_unique(array_merge($res[$k], $v)); + } else if (is_numeric($v) && !in_array($k, $exclude)) { + if (!isset($res[$k])) { + $res[$k] = 0; + } $res[$k] += $v; - } else { + } else if (!isset($res[$k])) { $res[$k] = $v; } } diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 5caf1c979..8b2003c55 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -11,6 +11,7 @@ use App\Fields\FluidbookStatus; use App\Fields\User; use App\Fluidbook\Compiler\Compiler; use App\Fluidbook\Farm; +use App\Fluidbook\Link\Link; use App\Fluidbook\Link\LinksData; use App\Http\Controllers\Admin\Operations\ChangeownerOperation; use App\Http\Controllers\Admin\Operations\FluidbookPublication\CloneOperation; @@ -778,4 +779,30 @@ class FluidbookPublication extends ToolboxSettingsModel { return !isset($this->assetsDir) || !$this->assetsDir ? $this->id : trim($this->assetsDir); } + + /** + * @return array[] + */ + public function getPagesAliases() + { + $res = []; + for ($i = 1; $i <= $this->getPagesNumber(); $i++) { + $res[$i] = []; + } + $this->getLinksAndRulers($links, $rulers); + foreach ($links as $link) { + if ($link['type'] !== Link::ANCHOR && $link['type'] !== Link::PAGE_LABEL) { + continue; + } + if (!isset($res[$link['page']])) { + continue; + } + $res[$link['page']][] = $link['to']; + } + return $res; + } + + public function getPreviewURL(){ + return route('fluidbook_preview',['version'=>'online','id'=>$this->id,'hash'=>$this->hash]); + } } diff --git a/resources/views/fluidbook_stats/loader.blade.php b/resources/views/fluidbook_stats/loader.blade.php index c3a580f43..268b82e76 100644 --- a/resources/views/fluidbook_stats/loader.blade.php +++ b/resources/views/fluidbook_stats/loader.blade.php @@ -42,8 +42,8 @@ background-color: #fafafa; } - table.stats-details thead th{ - border-bottom: medium solid rgba(0,40,100,.12); + table.stats-details thead th { + border-bottom: medium solid rgba(0, 40, 100, .12); } [data-name="formatted_date"] { @@ -123,6 +123,18 @@ white-space: nowrap; } + .with-aliases .number { + font-size: 75%; + display: block; + font-style: italic; + margin-top: -2px; + } + .with-aliases .alias:after{ + content:', '; + } + .with-aliases .alias:last-of-type:after{ + content:''; + } @endsection diff --git a/resources/views/fluidbook_stats/summary.blade.php b/resources/views/fluidbook_stats/summary.blade.php index 163a5c73e..c5b830247 100644 --- a/resources/views/fluidbook_stats/summary.blade.php +++ b/resources/views/fluidbook_stats/summary.blade.php @@ -4,6 +4,7 @@ @php $tableClasses='stats-details sortable bg-white table table-striped table-hover nowrap rounded shadow-xs border-xs mt-2 dataTable dtr-inline'; + $fluidbookBaseURL=$fluidbook->getPreviewURL(); @endphp

@@ -141,7 +142,22 @@ @foreach (array_keys($table_map['per-page']) as $summary_key) - {!! is_int($page_data[$summary_key]) ? $formatter->format($page_data[$summary_key]) : $page_data[$summary_key] !!} + @if($summary_key === 'page_group') + @if(count($page_data['page_aliases'])>0) +
+ @foreach($page_data['page_aliases'] as $alias) + {{$alias}} + @endforeach + @endif + {{$page_data[$summary_key]}} + @if(count($page_data['page_aliases'])>0) +
+ @endif + @else + {!! is_int($page_data[$summary_key]) ? $formatter->format($page_data[$summary_key]) : $page_data[$summary_key] !!} + @endif @endforeach