| 1 |
<?php |
| 2 |
namespace Photonic_Plugin\Admin\Forms; |
| 3 |
|
| 4 |
class Edit_Gallery_Templates { |
| 5 |
private $fields, $providers; |
| 6 |
private static $instance = null; |
| 7 |
|
| 8 |
private function __construct() { |
| 9 |
require_once(PHOTONIC_PATH.'/Admin/Forms/Vanilla_Form.php'); |
| 10 |
$form = Vanilla_Form::get_instance(); |
| 11 |
$this->fields = $form->get_fields(); |
| 12 |
|
| 13 |
$this->providers = ['default', 'flickr', 'google', 'smugmug', 'zenfolio', 'instagram']; |
| 14 |
} |
| 15 |
|
| 16 |
public static function get_instance() { |
| 17 |
if (self::$instance == null) { |
| 18 |
self::$instance = new Edit_Gallery_Templates(); |
| 19 |
} |
| 20 |
return self::$instance; |
| 21 |
} |
| 22 |
|
| 23 |
function render() { |
| 24 |
foreach ($this->providers as $provider) { |
| 25 |
?> |
| 26 |
<script type="text/html" id="tmpl-photonic-editor-<?php echo $provider; ?>"> |
| 27 |
<?php |
| 28 |
$field_list = $this->fields[$provider]['fields']; |
| 29 |
echo "<div class='photonic-form'>\n"; |
| 30 |
echo "<h2>Photonic ".($provider == 'default' ? 'WP' : $provider)." Gallery Settings</h2>\n"; |
| 31 |
foreach ($field_list as $field) { |
| 32 |
echo "\t<label class='setting'>\n"; |
| 33 |
echo "\t\t<span class='label'>{$field['name']} " . (isset($field['req']) && $field['req'] ? '(*)' : '') . " </span>\n"; |
| 34 |
$alt_id = !empty($field['alt_id']) ? " alt_id='{$field['alt_id']}' " : ''; |
| 35 |
switch ($field['type']) { |
| 36 |
case 'text': |
| 37 |
echo "\t\t<input type='text' name='{$field['id']}' value='" . (isset($field['std']) ? $field['std'] : '') . "' $alt_id/>\n"; |
| 38 |
break; |
| 39 |
|
| 40 |
case 'select': |
| 41 |
echo "\t\t<select name='{$field['id']}' $alt_id>\n"; |
| 42 |
$default = isset($field['std']) ? $field['std'] : ''; |
| 43 |
foreach ($field['options'] as $option_name => $option_value) { |
| 44 |
if ($option_name == $default) { |
| 45 |
$selected = 'selected'; |
| 46 |
} |
| 47 |
else { |
| 48 |
$selected = ''; |
| 49 |
} |
| 50 |
echo "\t\t\t<option value='$option_name' $selected>" . esc_attr($option_value) . "</option>\n"; |
| 51 |
} |
| 52 |
echo "\t\t</select>\n"; |
| 53 |
break; |
| 54 |
|
| 55 |
case 'raw': |
| 56 |
echo "\t\t" . $field['std'] . "\n"; |
| 57 |
break; |
| 58 |
} |
| 59 |
echo "\t\t<span class='hint'>" . (isset($field['hint']) ? $field['hint'] : '') . "</span>\n"; |
| 60 |
echo "\t</label>\n"; |
| 61 |
} |
| 62 |
echo "</div>\n"; |
| 63 |
?> |
| 64 |
</script> |
| 65 |
<?php |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
$edit_gallery = Edit_Gallery_Templates::get_instance(); |
| 71 |
$edit_gallery->render(); |
| 72 |
|