| @@ -1,30 +1,40 @@ | ||
| 1 | 1 | <?php |
| 2 | + | |
| 2 | 3 | namespace Photonic_Plugin\Options; |
| 3 | 4 | |
| 4 | 5 | abstract class Option_Tab { |
| 5 | - var $options; | |
| 6 | + protected array $options; | |
| 6 | 7 | |
| 8 | + final public static function get_instance() { | |
| 9 | + static $instances = array(); | |
| 10 | + $called_class = get_called_class(); | |
| 11 | + | |
| 12 | + if (!isset($instances[$called_class])) { | |
| 13 | + $instances[$called_class] = new $called_class(); | |
| 14 | + } | |
| 15 | + return $instances[$called_class]; | |
| 16 | + } | |
| 17 | + | |
| 7 | 18 | /** |
| 8 | 19 | * @return array |
| 9 | 20 | */ |
| 10 | - public function get_options() { | |
| 21 | + public function get_options(): array { | |
| 11 | 22 | return $this->options; |
| 12 | 23 | } |
| 13 | 24 | |
| 14 | - function title_styles() { | |
| 15 | - $ret = [ | |
| 16 | - "regular" => "<img src='".trailingslashit(PHOTONIC_URL).'include/images/title-regular.png'."' />Normal title display using the HTML \"title\" attribute", | |
| 17 | - "below" => "<img src='".trailingslashit(PHOTONIC_URL).'include/images/title-below.png'."' />Below the thumbnail (Doesn't work for Random Justified Gallery and Mosaic Layout)", | |
| 18 | - "tooltip" => "<img src='".trailingslashit(PHOTONIC_URL).'include/images/title-jq-tooltip.png'."' />Using a JavaScript tooltip", | |
| 19 | - "hover-slideup-show" => "<img src='".trailingslashit(PHOTONIC_URL).'include/images/title-slideup.png'."' />Slide up from bottom upon hover", | |
| 20 | - "slideup-stick" => "<img src='".trailingslashit(PHOTONIC_URL).'include/images/title-slideup.png'."' />Cover the lower portion always", | |
| 21 | - 'none' => 'No title' | |
| 25 | + public function title_styles(): array { | |
| 26 | + return [ | |
| 27 | + 'regular' => "<img src='" . trailingslashit(PHOTONIC_URL) . 'include/images/title-regular.png' . "' />Normal title display using the HTML \"title\" attribute", | |
| 28 | + 'below' => "<img src='" . trailingslashit(PHOTONIC_URL) . 'include/images/title-below.png' . "' />Below the thumbnail (Doesn't work for Random Justified Gallery and Mosaic Layout)", | |
| 29 | + 'tooltip' => "<img src='" . trailingslashit(PHOTONIC_URL) . 'include/images/title-jq-tooltip.png' . "' />Using a JavaScript tooltip", | |
| 30 | + 'hover-slideup-show' => "<img src='" . trailingslashit(PHOTONIC_URL) . 'include/images/title-slideup.png' . "' />Slide up from bottom upon hover", | |
| 31 | + 'slideup-stick' => "<img src='" . trailingslashit(PHOTONIC_URL) . 'include/images/title-slideup.png' . "' />Cover the lower portion always", | |
| 32 | + 'none' => 'No title' | |
| 22 | 33 | ]; |
| 23 | - return $ret; | |
| 24 | 34 | } |
| 25 | 35 | |
| 26 | - function selection_range($min, $max) { | |
| 36 | + public function selection_range($min, $max): array { | |
| 27 | 37 | $ret = []; |
| 28 | 38 | for ($i = $min; $i <= $max; $i++) { |
| 29 | 39 | $ret[$i] = $i; |
| 30 | 40 | } |
| @@ -29,5 +39,24 @@ | ||
| 29 | 39 | $ret[$i] = $i; |
| 30 | 40 | } |
| 31 | 41 | return $ret; |
| 32 | 42 | } |
| 33 | -} | |
| 43 | + | |
| 44 | + public function get_layout_engine_options(string $option_id, string $option_grouping): array { | |
| 45 | + return [ | |
| 46 | + 'name' => "Layout processing engine", | |
| 47 | + 'desc' => "When possible, Photonic tries to use CSS to build the layouts. | |
| 48 | + This has the advantage of being fast and can work well with lazy-loading and AJAX-based plugins, particularly if the loading mode (<em>Photonic → Settings → Generic Options → Advanced → Loading Mode</em>) is PHP. | |
| 49 | + <br/><br/>The downside is that CSS-based rendering is occasionally incorrect, particularly if the source has incorrect sizes. | |
| 50 | + If this is a frequent issue, you can default to a JS-generated layout (which is always more accurate). This can be managed individually for each gallery. | |
| 51 | + <br/><br/>In case some of the images in a gallery have missing size metadata, the JS mode will be used, regardless of this selection. | |
| 52 | + <br/><br/>Pick your default processor:", | |
| 53 | + 'id' => $option_id, | |
| 54 | + 'grouping' => $option_grouping, | |
| 55 | + 'type' => 'select', | |
| 56 | + 'options' => [ | |
| 57 | + 'css' => 'Use CSS unless overridden by a gallery individually', | |
| 58 | + 'js' => 'Use JS unless overridden by a gallery individually', | |
| 59 | + ] | |
| 60 | + ]; | |
| 61 | + } | |
| 62 | +} | |