1 | <?php |
||
18 | class ImageStyle extends Command |
||
19 | { |
||
20 | |||
21 | /** |
||
22 | * Image style model class instance |
||
23 | * @var \gplcart\core\models\ImageStyle $image_style |
||
24 | */ |
||
25 | protected $image_style; |
||
26 | |||
27 | /** |
||
28 | * @param ImageStyleModel $image_style |
||
29 | */ |
||
30 | public function __construct(ImageStyleModel $image_style) |
||
36 | |||
37 | /** |
||
38 | * Callback for "imagestyle-update" |
||
39 | */ |
||
40 | public function cmdUpdateImageStyle() |
||
60 | |||
61 | /** |
||
62 | * Callback for "imagestyle-add" |
||
63 | */ |
||
64 | public function cmdAddImageStyle() |
||
74 | |||
75 | /** |
||
76 | * Callback for "imagestyle-delete" command |
||
77 | */ |
||
78 | public function cmdDeleteImageStyle() |
||
92 | |||
93 | /** |
||
94 | * Callback for "imagestyle-clear" command |
||
95 | */ |
||
96 | public function cmdClearImageStyle() |
||
97 | { |
||
98 | $id = $this->getParam(0); |
||
99 | $all = $this->getParam('all'); |
||
100 | |||
101 | if (!isset($id) && empty($all)) { |
||
102 | $this->errorAndExit($this->text('Invalid command')); |
||
103 | } |
||
104 | |||
105 | $result = false; |
||
106 | |||
107 | if (isset($id)) { |
||
108 | |||
109 | if (!is_numeric($id)) { |
||
110 | $this->errorAndExit($this->text('Invalid argument')); |
||
111 | } |
||
112 | |||
113 | $result = $this->image_style->clearCache($id); |
||
114 | } else if (!empty($all)) { |
||
115 | $result = $this->image_style->clearCache(); |
||
116 | } |
||
117 | |||
118 | if (empty($result)) { |
||
119 | $this->errorAndExit($this->text('Unexpected result')); |
||
120 | } |
||
121 | |||
122 | $this->output(); |
||
123 | } |
||
124 | |||
125 | /** |
||
126 | * Callback for "imagestyle-get" command |
||
127 | */ |
||
128 | public function cmdGetImageStyle() |
||
135 | |||
136 | /** |
||
137 | * Returns an array of image styles |
||
138 | * @return array |
||
139 | */ |
||
140 | protected function getListImageStyle() |
||
162 | |||
163 | /** |
||
164 | * Output image styles in a table |
||
165 | * @param array $items |
||
166 | */ |
||
167 | protected function outputFormatTableImageStyle(array $items) |
||
191 | |||
192 | /** |
||
193 | * Adds an image style |
||
194 | */ |
||
195 | protected function addImageStyle() |
||
205 | |||
206 | /** |
||
207 | * Updates an image style |
||
208 | * @param int $imagestyle_id |
||
209 | */ |
||
210 | protected function updateImageStyle($imagestyle_id) |
||
216 | |||
217 | /** |
||
218 | * Add an image style at once |
||
219 | */ |
||
220 | protected function submitAddImageStyle() |
||
227 | |||
228 | /** |
||
229 | * Adds an image style step-by-step |
||
230 | */ |
||
231 | protected function wizardAddImageStyle() |
||
241 | |||
242 | } |
||
243 |