|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace Formularium\Frontend\Bulma\Renderable; |
|
4
|
|
|
|
|
5
|
|
|
use Formularium\Field; |
|
6
|
|
|
use Formularium\Renderable; |
|
7
|
|
|
use Formularium\HTMLElement; |
|
8
|
|
|
|
|
9
|
|
|
class Renderable_pagination extends Renderable_constant |
|
10
|
|
|
{ |
|
11
|
|
|
public function viewable($value, Field $field, HTMLElement $previous): HTMLElement |
|
12
|
|
|
{ |
|
13
|
|
|
return $this->fix($value, $field, $previous); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
public function editable($value, Field $field, HTMLElement $previous): HTMLElement |
|
17
|
|
|
{ |
|
18
|
|
|
return $this->fix($value, $field, $previous); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param mixed $value |
|
23
|
|
|
* @param Field $field |
|
24
|
|
|
* @param HTMLElement $previous |
|
25
|
|
|
* @return HTMLElement |
|
26
|
|
|
*/ |
|
27
|
|
|
protected function fix($value, Field $field, HTMLElement $previous): HTMLElement |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
foreach ($previous->get('.formularium-pagination-wrapper') as $e) { |
|
30
|
|
|
$e->addAttribute('class', 'pagination'); |
|
31
|
|
|
} |
|
32
|
|
|
foreach ($previous->get('.formularium-disabled') as $e) { |
|
33
|
|
|
$e->addAttribute('class', 'disabled'); |
|
34
|
|
|
} |
|
35
|
|
|
foreach ($previous->get('.formularium-ellipsis') as $e) { |
|
36
|
|
|
foreach ($e->getContent() as $e2) { |
|
37
|
|
|
$e2->setAttribute('class', 'pagination-ellipsis') |
|
38
|
|
|
->setTag('span'); |
|
39
|
|
|
} |
|
40
|
|
|
} |
|
41
|
|
|
foreach ($previous->get('.formularium-pagination-link') as $e) { |
|
42
|
|
|
$e->addAttribute('class', 'pagination-link'); |
|
43
|
|
|
} |
|
44
|
|
|
foreach ($previous->get('.formularium-pagination-current') as $e) { |
|
45
|
|
|
foreach ($e->getContent() as $e2) { |
|
46
|
|
|
$e2->addAttribute('class', 'is-current'); |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
foreach ($previous->get('.formularium-pagination') as $e) { |
|
50
|
|
|
$e->addAttribute('class', 'pagination-list'); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$size = $field->getExtension(Renderable::SIZE, ''); |
|
54
|
|
|
switch ($size) { |
|
55
|
|
|
case Renderable::SIZE_LARGE: |
|
56
|
|
|
foreach ($previous->get('.formularium-pagination') as $e) { |
|
57
|
|
|
$e->addAttribute('class', 'is-large'); |
|
58
|
|
|
} |
|
59
|
|
|
break; |
|
60
|
|
|
case Renderable::SIZE_SMALL: |
|
61
|
|
|
foreach ($previous->get('.formularium-pagination') as $e) { |
|
62
|
|
|
$e->addAttribute('class', 'is-small'); |
|
63
|
|
|
} |
|
64
|
|
|
break; |
|
65
|
|
|
} |
|
66
|
|
|
return $previous; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.