PluginProbe
Photonic Gallery & Lightbox for Flickr, SmugMug & Others / 3.36
Photonic Gallery & Lightbox for Flickr, SmugMug & Others v3.36
3.36 3.35 3.34 3.33 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 2.31 2.32 2.33 2.34 2.40 2.41 2.42 2.43 2.44 All 141 releases
photonic / Admin / Wizard / Source.php

Source.php in Photonic Gallery & Lightbox for Flickr, SmugMug & Others 3.36, at Admin/Wizard/Source.php

300 lines 10.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Photonic_Plugin\Admin\Wizard;
4
5 abstract class Source {
6 protected string $default_under;
7 protected string $default_from_settings;
8 protected array $allowed_image_sizes;
9 protected array $column_options;
10 protected string $provider;
11 protected string $error_not_found;
12 protected string $error_mandatory;
13 protected string $error_unauthorized;
14 public ?string $api_base;
15
16 protected function __construct() {
17 $this->default_under = esc_html__('Default settings can be configured under: %s', 'photonic');
18 $this->default_from_settings = esc_html__('Default from settings', 'photonic');
19 $this->allowed_image_sizes = [];
20 $this->column_options = [
21 'desc' => esc_html__('Number of columns in output', 'photonic'),
22 'type' => 'select',
23 'options' => [
24 '' => '',
25 'auto' => esc_html__('Automatic (Photonic calculates the columns)', 'photonic'),
26 '1' => 1,
27 '2' => 2,
28 '3' => 3,
29 '4' => 4,
30 '5' => 5,
31 '6' => 6,
32 '7' => 7,
33 '8' => 8,
34 '9' => 9,
35 '10' => 10,
36 ]
37 ];
38
39 $this->error_not_found = esc_html__('Not found.', 'photonic');
40 $this->error_mandatory = esc_html__('Please fill the mandatory fields. Mandatory fields are marked with a red "*".', 'photonic');
41 $this->error_unauthorized = esc_html__('This action is unauthorized. Please ensure that you are logged in and refresh your page if necessary', 'photonic');
42 }
43
44 /**
45 * Gets contents of the second screen for a given provider. The second screen contains the type of content to display for a source.
46 * E.g. "Multiple photos", "Photos in an album" etc.
47 *
48 * @return array
49 */
50 abstract public function get_screen_2(): array;
51
52 /**
53 * Gets contents of the third screen for a given provider. This screen contains the photos, albums etc. resultant from Screen 2.
54 *
55 * @return array
56 */
57 abstract public function get_screen_3(): array;
58
59 /**
60 * Shows the layout selection screen.
61 *
62 * @return array
63 */
64 abstract public function get_screen_4(): array;
65
66 /**
67 * Shows layout-specific options for the gallery.
68 *
69 * @return array
70 */
71 abstract public function get_screen_5(): array;
72
73 /**
74 * Add the thumbnail sizes to the screen for the square, circle and slideshow layouts
75 *
76 * @return array
77 */
78 abstract public function get_square_size_options(): array;
79
80 /**
81 * Add the tile sizes to the screen for the random (justified grid), masonry and mosaic layouts
82 *
83 * @return array
84 */
85 abstract public function get_random_size_options(): array;
86
87 /**
88 * Makes a request to a provider to fetch the contents to be displayed within the Wizard.
89 *
90 * @param $display_type
91 * @param $for
92 * @param $flattened_fields
93 * @return array
94 */
95 abstract public function make_request($display_type, $for, $flattened_fields): array;
96
97 /**
98 * Parses the response from the provider when then wizard tries to get content from it.
99 *
100 * @param $response
101 * @param $display_type
102 * @param null $url
103 * @param array $pagination
104 * @return array
105 */
106 abstract public function process_response($response, $display_type, $url = null, &$pagination = []): array;
107
108 /**
109 * @param $display_type
110 * @return array
111 */
112 abstract public function construct_shortcode_from_screen_selections($display_type): array;
113
114 /**
115 * @param $input
116 * @return array
117 */
118 abstract public function deconstruct_shortcode_to_screen_selections($input): array;
119
120 private function get_title_position_options(): array {
121 $ret = [
122 '' => $this->default_from_settings,
123 'regular' => esc_html__('Normal title display using the HTML "title" attribute', 'photonic'),
124 'below' => esc_html__('Below the thumbnail', 'photonic'),
125 'tooltip' => esc_html__('Using a JavaScript tooltip', 'photonic'),
126 'hover-slideup-show' => esc_html__('Slide up from bottom upon hover', 'photonic'),
127 'slideup-stick' => esc_html__('Cover the lower portion always', 'photonic'),
128 'none' => esc_html__('No title', 'photonic'),
129 ];
130
131 return [
132 'desc' => esc_html__('How do you want the title?', 'photonic'),
133 'type' => 'select',
134 'options' => $ret,
135 'std' => '',
136 ];
137 }
138
139 public function get_slideshow_options(): array {
140 global $photonic_thumbnail_style;
141 return [
142 'slideshow-style' => [
143 'desc' => esc_html__('Slideshow display style', 'photonic'),
144 'type' => 'image-select',
145 'options' => [
146 'strip-below' => esc_html__('Thumbnail strip or buttons below slideshow', 'photonic'),
147 'strip-above' => esc_html__('Thumbnail strip above slideshow', 'photonic'),
148 'strip-right' => esc_html__('OBSOLETE - Thumbnail strip to the right of slideshow - will now default to a strip below the slides', 'photonic'),
149 'no-strip' => esc_html__('No thumbnails or buttons for the slideshow', 'photonic'),
150 ],
151 'std' => $photonic_thumbnail_style,
152 ],
153 'strip-style' => [
154 'desc' => esc_html__('Thumbnails or buttons for the strip?', 'photonic'),
155 'type' => 'image-select',
156 'options' => [
157 'thumbs' => esc_html__('Thumbnails', 'photonic'),
158 'button' => esc_html__('Buttons', 'photonic'),
159 ],
160 'hint' => esc_html__('If you choose "Buttons" those are only shown below the slideshow.', 'photonic'),
161 'std' => 'thumbs',
162 ],
163 'controls' => [
164 'desc' => esc_html__('Slideshow Controls', 'photonic'),
165 'type' => 'select',
166 'options' => [
167 'hide' => esc_html__('Hide', 'photonic'),
168 'show' => esc_html__('Show', 'photonic'),
169 ],
170 'std' => 'show',
171 'hint' => esc_html__('Shows Previous and Next buttons on the slideshow.', 'photonic'),
172 ],
173 'fx' => [
174 'desc' => esc_html__('Slideshow Effects', 'photonic'),
175 'type' => 'select',
176 'options' => [
177 'fade' => esc_html__('Fade', 'photonic'),
178 'slide' => esc_html__('Slide', 'photonic'),
179 ],
180 'hint' => esc_html__('Determines if a photo in a slideshow should fade in or slide in.', 'photonic')
181 ],
182 'timeout' => [
183 'desc' => esc_html__('Time between slides in ms', 'photonic'),
184 'type' => 'text',
185 'std' => '',
186 'hint' => esc_html__('Please enter numbers only', 'photonic')
187 ],
188 'speed' => [
189 'desc' => esc_html__('Time for each transition in ms', 'photonic'),
190 'type' => 'text',
191 'std' => '',
192 'hint' => esc_html__('How fast do you want the fade or slide effect to happen?', 'photonic')
193 ],
194 'pause' => [
195 'desc' => esc_html__('Pause upon hover?', 'photonic'),
196 'type' => 'select',
197 'options' => [
198 '0' => esc_html__('No', 'photonic'),
199 '1' => esc_html__('Yes', 'photonic'),
200 ],
201 'std' => '1',
202 'hint' => esc_html__('Should the slideshow pause when you hover over it?', 'photonic')
203 ],
204 'columns' => [
205 'desc' => esc_html__('Number of columns in slideshow', 'photonic'),
206 'type' => 'select',
207 'options' => [
208 '' => '',
209 '1' => 1,
210 '2' => 2,
211 '3' => 3,
212 '4' => 4,
213 '5' => 5,
214 '6' => 6,
215 '7' => 7,
216 '8' => 8,
217 '9' => 9,
218 '10' => 10,
219 ],
220 'hint' => esc_html__('Pick > 1 for a carousel', 'photonic'),
221 ],
222 'title_position' => $this->get_title_position_options(),
223 ];
224 }
225
226 public function get_square_layout_options(): array {
227 return [
228 'columns' => $this->column_options,
229 $this->provider => $this->get_square_size_options(),
230 'title_position' => $this->get_title_position_options(),
231 'load_mode' => $this->get_load_mode_options(),
232 ];
233 }
234
235 public function get_random_layout_options(): array {
236 return [
237 $this->provider => $this->get_random_size_options(),
238 'title_position' => $this->get_title_position_options(),
239 'load_mode' => $this->get_load_mode_options(),
240 'layout_engine' => $this->get_layout_engine_options(),
241 ];
242 }
243
244 public function get_column_options(): array {
245 return $this->column_options;
246 }
247
248 public function get_header_options($conditions = null): array {
249 $options = [
250 'desc' => esc_html__('Show Header', 'photonic'),
251 'type' => 'select',
252 'options' => [
253 '' => $this->default_from_settings,
254 'none' => esc_html__('No header', 'photonic'),
255 'title' => esc_html__('Title only', 'photonic'),
256 'thumbnail' => esc_html__('Thumbnail only', 'photonic'),
257 'counter' => esc_html__('Counts only', 'photonic'),
258 'title,counter' => esc_html__('Title and counts', 'photonic'),
259 'thumbnail,counter' => esc_html__('Thumbnail and counts', 'photonic'),
260 'thumbnail,title' => esc_html__('Thumbnail and title', 'photonic'),
261 'thumbnail,title,counter' => esc_html__('Thumbnail, title and counts', 'photonic'),
262 ],
263 ];
264 if (!empty($conditions)) {
265 $options['conditions'] = $conditions;
266 }
267 return $options;
268 }
269
270 /**
271 * @return array
272 */
273 private function get_load_mode_options(): array {
274 global $photonic_load_mode;
275 return [
276 'desc' => esc_html__('Gallery loading mode', 'photonic'),
277 'type' => 'select',
278 'options' => [
279 '' => $this->default_from_settings . ' - ' . $photonic_load_mode,
280 'php' => esc_attr__('PHP Mode – Gallery markup is generated by your server before your page is sent to the browser.', 'photonic'),
281 'js' => esc_attr__('JavaScript Mode – Gallery markup is generated by your server after your page is sent to the browser.', 'photonic'),
282 ],
283 'hint' => esc_html__('You can configure Photonic to generate the galleries as a part of your page generation (PHP mode), or after your page has generated and rendered on the site user\'s browser (JS mode). The PHP mode makes your galleries crawl-able by search engines, and the JS mode helps your page load faster (the gallery shows up once it is ready). The JS mode helps if you want to use caching plugins with Google Photos setups.', 'photonic'),
284 ];
285 }
286
287 private function get_layout_engine_options(): array {
288 return [
289 'desc' => esc_html__('Gallery layout processing engine', 'photonic'),
290 'type' => 'select',
291 'options' => [
292 '' => $this->default_from_settings,
293 'css' => esc_attr__('Use CSS to render the gallery.', 'photonic'),
294 'js' => esc_attr__('Use JS to render the gallery.', 'photonic'),
295 ],
296 'hint' => sprintf($this->default_under, '<em>Photonic &rarr; Settings &rarr; &lt;Platform&gt; &rarr; &lt;Platform&gt; Settings &rarr; Layout Processing Mode</em>'),
297 ];
298 }
299 }
300