[
'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
[
'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
[
'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
$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 {
$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),
$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;
}
}
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;
{
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]);
+ }
}
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"] {
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:'';
+ }
</style>
@endsection
@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
<h2 class="mt-4">
@foreach (array_keys($table_map['per-page']) as $summary_key)
<td data-name="{{ $summary_key }}"
@if($summary_key === 'page_group')sorttable_customkey="{{ $page_data['page_number'] }}"@endif>
- {!! 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)
+ <div class="with-aliases">
+ @foreach($page_data['page_aliases'] as $alias)
+ <span class="alias"><a target="_blank"
+ href="{!! $fluidbookBaseURL !!}#/page/{{\Fluidbook\Tools\Links\AnchorLink::normalizeAnchor($alias)}}">{{$alias}}</a></span>
+ @endforeach
+ @endif
+ <a class="number" target="_blank"
+ href="{!! $fluidbookBaseURL !!}#/page/{{ $page_data['page_number'] }}">{{$page_data[$summary_key]}}</a>
+ @if(count($page_data['page_aliases'])>0)
+ </div>
+ @endif
+ @else
+ {!! is_int($page_data[$summary_key]) ? $formatter->format($page_data[$summary_key]) : $page_data[$summary_key] !!}
+ @endif
</td>
@endforeach
</tr>