1 | <?php |
||
31 | class EccubeExtension extends \Twig_Extension |
||
|
|||
32 | { |
||
33 | private $app; |
||
34 | |||
35 | 149 | public function __construct(Application $app) |
|
39 | |||
40 | /** |
||
41 | * Returns a list of functions to add to the existing list. |
||
42 | * |
||
43 | * @return array An array of functions |
||
44 | */ |
||
45 | 66 | public function getFunctions() |
|
53 | |||
54 | /** |
||
55 | * Returns a list of filters. |
||
56 | * |
||
57 | * @return array |
||
58 | */ |
||
59 | 66 | public function getFilters() |
|
69 | |||
70 | /** |
||
71 | * Name of this extension |
||
72 | * |
||
73 | * @return string |
||
74 | */ |
||
75 | 127 | public function getName() |
|
79 | |||
80 | /** |
||
81 | * Name of this extension |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getCalcIncTax($price, $tax_rate, $tax_rule) |
||
89 | |||
90 | /** |
||
91 | * Name of this extension |
||
92 | * |
||
93 | * @param array $menus |
||
94 | * @return array |
||
95 | */ |
||
96 | public function getActiveMenus($menus = array()) |
||
105 | |||
106 | /** |
||
107 | * Name of this extension |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 7 | public function getCsrfTokenForAnchor() |
|
116 | |||
117 | /** |
||
118 | * return No Image filename |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | 1 | public function getNoImageProduct($image) |
|
123 | { |
||
124 | 1 | return empty($image) ? 'no_image_product.jpg' : $image; |
|
125 | } |
||
126 | |||
127 | /** |
||
128 | * Name of this extension |
||
129 | * |
||
130 | * @return string |
||
131 | */ |
||
132 | 1 | public function getDateFormatFilter($date, $value = '', $format = 'Y/m/d') |
|
133 | { |
||
134 | if (is_null($date)) { |
||
135 | 1 | return $value; |
|
136 | } else { |
||
137 | return $date->format($format); |
||
138 | } |
||
139 | } |
||
140 | |||
141 | /** |
||
142 | * Name of this extension |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | 28 | public function getPriceFilter($number, $decimals = 0, $decPoint = '.', $thousandsSep = ',') |
|
153 | |||
154 | /** |
||
155 | * Name of this extension |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getEllipsis($value, $length = 100, $end = '...') |
||
163 | |||
164 | /** |
||
165 | * Name of this extension |
||
166 | * |
||
167 | * @return string |
||
168 | */ |
||
169 | public function getTimeAgo($date) |
||
173 | } |
||
174 |