From 057cd17dd2bfb336d645af92137df40482f92556 Mon Sep 17 00:00:00 2001 From: azett Date: Thu, 16 Jun 2022 12:53:06 +0200 Subject: [PATCH] Added Gallery captions plugin --- .../admin_uploader_gallerycaptions.class.php | 63 +++++++++++++++++++ .../gallerycaptions/lang/lang.de-de.php | 18 ++++++ .../gallerycaptions/lang/lang.en-us.php | 18 ++++++ .../plugin.gallerycaptions.php | 25 ++++++++ fp-plugins/gallerycaptions/res/adminstyle.css | 3 + .../tpls/admin.plugin.gallerycaptions.tpl | 51 +++++++++++++++ 6 files changed, 178 insertions(+) create mode 100644 fp-plugins/gallerycaptions/admin_uploader_gallerycaptions.class.php create mode 100644 fp-plugins/gallerycaptions/lang/lang.de-de.php create mode 100644 fp-plugins/gallerycaptions/lang/lang.en-us.php create mode 100644 fp-plugins/gallerycaptions/plugin.gallerycaptions.php create mode 100644 fp-plugins/gallerycaptions/res/adminstyle.css create mode 100644 fp-plugins/gallerycaptions/tpls/admin.plugin.gallerycaptions.tpl diff --git a/fp-plugins/gallerycaptions/admin_uploader_gallerycaptions.class.php b/fp-plugins/gallerycaptions/admin_uploader_gallerycaptions.class.php new file mode 100644 index 0000000..597ac7a --- /dev/null +++ b/fp-plugins/gallerycaptions/admin_uploader_gallerycaptions.class.php @@ -0,0 +1,63 @@ +smarty->assign('admin_resource', "plugin:gallerycaptions/admin.plugin.gallerycaptions"); + + // fetch all gallery names from the image directory + $allGalleries = gallery_fetch_galleries(); + + // current gallery name + $currentGallery = null; + // user has selected a gallery already + if (isset($_SESSION ['gallerycaptions-selectedgallery'])) { + $currentGallery = $_SESSION ['gallerycaptions-selectedgallery']; + } + // current gallery's images + $currentGalleryImages = gallery_read_images('images/' . $currentGallery); + // current gallery's captions + $captionsOfCurrentGallery = isset($currentGallery) ? gallery_read_captions('images/' . $currentGallery) : null; + + // now assign everything to the Smarty variables + $this->smarty->assign('pluginurl', plugin_geturl('gallerycaptions')); + $this->smarty->assign('galleries', $allGalleries); + $this->smarty->assign('currentgallery', $currentGallery); + $this->smarty->assign('currentgalleryimages', $currentGalleryImages); + $this->smarty->assign('currentgallerycaptions', $captionsOfCurrentGallery); + } + + /** + * + * {@inheritdoc} + * @see AdminPanelAction::onsubmit() + */ + function onsubmit($data = null) { + + // Gallery select button was pressed + if (array_key_exists('gallerycaptions-selectgallery', $_REQUEST)) { + // set selected gallery to the session + $_SESSION ['gallerycaptions-selectedgallery'] = $_REQUEST ['gallerycaptions-gallery']; + } // Save captions button was pressed + elseif (isset($_POST ['gallerycaptions-savecaptions'])) { + gallery_write_captions($_REQUEST ['galleryname'], $_REQUEST ['captions']); + } + + return 2; + } + +} + +admin_addpanelaction('uploader', 'gallerycaptions', true); diff --git a/fp-plugins/gallerycaptions/lang/lang.de-de.php b/fp-plugins/gallerycaptions/lang/lang.de-de.php new file mode 100644 index 0000000..aa37fe7 --- /dev/null +++ b/fp-plugins/gallerycaptions/lang/lang.de-de.php @@ -0,0 +1,18 @@ + 'Galerien: Bildtexte', + 'label_selectgallery' => 'Galerie auswählen:', + 'button_selectgallery' => 'Galerie auswählen', + 'label_editcaptionsforgallery' => 'Bildtext für diese Galerie:', + 'label_noimagesingallery' => 'Diese Galerie enthält noch keine Bilder ¯\_(ツ)_/¯
+
+Lad welche mit dem Uploader hoch, dann ordne sie der Galerie mit dem Media Manager zu!', + 'button_savecaptions' => 'Bildtexte speichern' +); \ No newline at end of file diff --git a/fp-plugins/gallerycaptions/lang/lang.en-us.php b/fp-plugins/gallerycaptions/lang/lang.en-us.php new file mode 100644 index 0000000..8ad7c1e --- /dev/null +++ b/fp-plugins/gallerycaptions/lang/lang.en-us.php @@ -0,0 +1,18 @@ + 'Gallery captions', + 'label_selectgallery' => 'Select gallery to edit:', + 'button_selectgallery' => 'Select gallery', + 'label_editcaptionsforgallery' => 'Edit captions for gallery:', + 'label_noimagesingallery' => 'This gallery doesn´t contain any images yet ¯\_(ツ)_/¯
+
+Upload images via the Uploader, then add them to the gallery using the Media Manager!', + 'button_savecaptions' => 'Save captions' +); \ No newline at end of file diff --git a/fp-plugins/gallerycaptions/plugin.gallerycaptions.php b/fp-plugins/gallerycaptions/plugin.gallerycaptions.php new file mode 100644 index 0000000..06fe27c --- /dev/null +++ b/fp-plugins/gallerycaptions/plugin.gallerycaptions.php @@ -0,0 +1,25 @@ +append('error', 'Sorry, you need FlatPress version ' . PLUGIN_GALLERYCAPTIONS_MINFPVERSION . ' or later in order to run the Gallery captions plugin.'); + // FIXME: Deactivate plugin + } +} diff --git a/fp-plugins/gallerycaptions/res/adminstyle.css b/fp-plugins/gallerycaptions/res/adminstyle.css new file mode 100644 index 0000000..c32db37 --- /dev/null +++ b/fp-plugins/gallerycaptions/res/adminstyle.css @@ -0,0 +1,3 @@ +table.plugin_gallerycaptions_captionstable tr td { padding:1em; } +table.plugin_gallerycaptions_captionstable tr td:first-child { width:1%; } +table.plugin_gallerycaptions_captionstable input {width:95%;} \ No newline at end of file diff --git a/fp-plugins/gallerycaptions/tpls/admin.plugin.gallerycaptions.tpl b/fp-plugins/gallerycaptions/tpls/admin.plugin.gallerycaptions.tpl new file mode 100644 index 0000000..f9bf9d8 --- /dev/null +++ b/fp-plugins/gallerycaptions/tpls/admin.plugin.gallerycaptions.tpl @@ -0,0 +1,51 @@ + +

{$plang.head}

+ +{include file=shared:errorlist.tpl} + +{html_form class=option-set} +

+ {$plang.label_selectgallery} + + +

+{/html_form} + +{if !empty($currentgallery)} +

{$plang.label_editcaptionsforgallery} {$currentgallery}

+ {html_form class=option-set} +

+ {if count($currentgalleryimages) == 0} + {$plang.label_noimagesingallery} + {else} + + + {foreach from="$currentgalleryimages" item="currentfilename"} + + + + + {/foreach} +
+ + {$currentfilename} + +
+ {$currentfilename} +
+ +
+ + {/if} +

+ {/html_form} +{/if} +