-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOccurrenceArray.php
52 lines (45 loc) · 1.36 KB
/
OccurrenceArray.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php namespace ProcessWire;
class OccurrenceArray extends PaginatedArray
{
public function makeBlankItem()
{
return $this->wire(new Occurrence());
}
public function isValidItem($item): bool
{
return $item instanceof Occurrence;
}
/**
* @return false|string
* @throws WireException
*/
public function __toString()
{
$pager = $this->modules->get("MarkupPagerNav");
$pager = $pager->render($this, [
'listClass' => 'uk-pagination MarkupPagerNav',
'linkMarkup' => "<a @click='setPage' data-item='{index}' href=''><span>{out}</span></a>",
]);
$a = [
'dates' => [],
'pagination' => [
'start' => $this->getStart(),
'limit' => $this->getLimit(),
'total' => $this->getTotal(),
'pagination_string' => $this->getPaginationString(),
'markup_pager' => $pager
]
];
foreach ($this->data as $item) {
/** @var $item Occurrence */
$data = [
'formatted' => (string) $item,
'day' => $item->format('d'),
'month' => $item->format('m'),
'year' => $item->format('Y')
];
$a['dates'][] = $data;
}
return json_encode($a, true);
}
}