These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of the Sylius package. |
||
5 | * |
||
6 | * (c) Paweł Jędrzejewski |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Sylius\Bundle\UiBundle\View\Template; |
||
13 | |||
14 | use Pagerfanta\View\Template\Template; |
||
15 | |||
16 | /** |
||
17 | * @author Loïc Frémont <[email protected]> |
||
18 | */ |
||
19 | class SemanticUiTemplate extends Template |
||
20 | { |
||
21 | protected static $defaultOptions = array( |
||
22 | 'prev_message' => '← Previous', |
||
23 | 'next_message' => 'Next →', |
||
24 | 'dots_message' => '…', |
||
25 | 'active_suffix' => '', |
||
26 | 'css_container_class' => 'ui stackable fluid pagination menu', |
||
27 | 'css_item_class' => 'item', |
||
28 | 'css_prev_class' => 'prev', |
||
29 | 'css_next_class' => 'next', |
||
30 | 'css_disabled_class' => 'disabled', |
||
31 | 'css_dots_class' => 'disabled', |
||
32 | 'css_active_class' => 'active', |
||
33 | ); |
||
34 | |||
35 | public function container() |
||
36 | { |
||
37 | return sprintf('<div class="%s">%%pages%%</div>', |
||
38 | $this->option('css_container_class') |
||
39 | ); |
||
40 | } |
||
41 | |||
42 | public function page($page) |
||
43 | { |
||
44 | $text = $page; |
||
45 | |||
46 | return $this->pageWithText($page, $text); |
||
47 | } |
||
48 | |||
49 | public function pageWithText($page, $text) |
||
50 | { |
||
51 | $class = null; |
||
52 | |||
53 | return $this->pageWithTextAndClass($page, $text, $class); |
||
54 | } |
||
55 | |||
56 | private function pageWithTextAndClass($page, $text, $class) |
||
57 | { |
||
58 | $href = $this->generateRoute($page); |
||
59 | |||
60 | return $this->link($class, $href, $text); |
||
61 | } |
||
62 | |||
63 | public function previousDisabled() |
||
64 | { |
||
65 | $class = $this->previousDisabledClass(); |
||
66 | $text = $this->option('prev_message'); |
||
67 | |||
68 | return $this->div($class, $text); |
||
69 | } |
||
70 | |||
71 | private function previousDisabledClass() |
||
72 | { |
||
73 | return $this->option('css_prev_class').' '.$this->option('css_disabled_class'); |
||
74 | } |
||
75 | |||
76 | public function previousEnabled($page) |
||
77 | { |
||
78 | $text = $this->option('prev_message'); |
||
79 | $class = $this->option('css_prev_class'); |
||
80 | |||
81 | return $this->pageWithTextAndClass($page, $text, $class); |
||
82 | } |
||
83 | |||
84 | public function nextDisabled() |
||
85 | { |
||
86 | $class = $this->nextDisabledClass(); |
||
87 | $text = $this->option('next_message'); |
||
88 | |||
89 | return $this->div($class, $text); |
||
90 | } |
||
91 | |||
92 | private function nextDisabledClass() |
||
93 | { |
||
94 | return $this->option('css_next_class').' '.$this->option('css_disabled_class'); |
||
95 | } |
||
96 | |||
97 | public function nextEnabled($page) |
||
98 | { |
||
99 | $text = $this->option('next_message'); |
||
100 | $class = $this->option('css_next_class'); |
||
101 | |||
102 | return $this->pageWithTextAndClass($page, $text, $class); |
||
103 | } |
||
104 | |||
105 | public function first() |
||
106 | { |
||
107 | return $this->page(1); |
||
108 | } |
||
109 | |||
110 | public function last($page) |
||
111 | { |
||
112 | return $this->page($page); |
||
113 | } |
||
114 | |||
115 | public function current($page) |
||
116 | { |
||
117 | $text = trim($page.' '.$this->option('active_suffix')); |
||
118 | $class = $this->option('css_active_class'); |
||
119 | |||
120 | return $this->div($class, $text); |
||
121 | } |
||
122 | |||
123 | public function separator() |
||
124 | { |
||
125 | $class = $this->option('css_dots_class'); |
||
126 | $text = $this->option('dots_message'); |
||
127 | |||
128 | return $this->div($class, $text); |
||
129 | } |
||
130 | |||
131 | private function link($class, $href, $text) |
||
0 ignored issues
–
show
|
|||
132 | { |
||
133 | $item_class = $this->option('css_item_class'); |
||
134 | |||
135 | return sprintf('<a class="%s %s" href="%s">%s</a>', $item_class, $class, $href, $text); |
||
136 | } |
||
137 | |||
138 | private function div($class, $text) |
||
0 ignored issues
–
show
The variable $item_class is not named in camelCase.
This check marks variable names that have not been written in camelCase. In camelCase names are written without any punctuation, the start of each new word being marked
by a capital letter. Thus the name database connection string becomes ![]() |
|||
139 | { |
||
140 | $item_class = $this->option('css_item_class'); |
||
141 | |||
142 | return sprintf('<div class="%s %s">%s</div>', $item_class, $class, $text); |
||
143 | } |
||
144 | } |
||
145 |
This check marks variable names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.