Added Gallery captions plugin
This commit is contained in:
parent
db658fac39
commit
057cd17dd2
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* The plugin's configuration panel
|
||||
*
|
||||
* @author zimmermann
|
||||
*
|
||||
*/
|
||||
class admin_uploader_gallerycaptions extends AdminPanelAction {
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritdoc}
|
||||
* @see AdminPanelAction::setup()
|
||||
*/
|
||||
function setup() {
|
||||
// assign this class as resource for the admin area
|
||||
$this->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);
|
18
fp-plugins/gallerycaptions/lang/lang.de-de.php
Normal file
18
fp-plugins/gallerycaptions/lang/lang.de-de.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin area phrases
|
||||
*/
|
||||
// "Plugins" menu entry
|
||||
$lang ['admin'] ['uploader'] ['submenu'] ['gallerycaptions'] = 'Galerien: Bildtexte';
|
||||
|
||||
// Plugin configuration panel
|
||||
$lang ['admin'] ['uploader'] ['gallerycaptions'] = array(
|
||||
'head' => '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 ¯\_(ツ)_/¯<br>
|
||||
<br>
|
||||
Lad welche mit dem <a href="' . BLOG_BASEURL . 'admin.php?p=uploader&action=default' . '">Uploader</a> hoch, dann ordne sie der Galerie mit dem <a href="' . BLOG_BASEURL . 'admin.php?p=uploader&action=mediamanager' . '">Media Manager</a> zu!',
|
||||
'button_savecaptions' => 'Bildtexte speichern'
|
||||
);
|
18
fp-plugins/gallerycaptions/lang/lang.en-us.php
Normal file
18
fp-plugins/gallerycaptions/lang/lang.en-us.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Admin area phrases
|
||||
*/
|
||||
// "Plugins" menu entry
|
||||
$lang ['admin'] ['uploader'] ['submenu'] ['gallerycaptions'] = 'Gallery captions';
|
||||
|
||||
// Plugin configuration panel
|
||||
$lang ['admin'] ['uploader'] ['gallerycaptions'] = array(
|
||||
'head' => '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 ¯\_(ツ)_/¯<br>
|
||||
<br>
|
||||
Upload images via the <a href="' . BLOG_BASEURL . 'admin.php?p=uploader&action=default' . '">Uploader</a>, then add them to the gallery using the <a href="' . BLOG_BASEURL . 'admin.php?p=uploader&action=mediamanager' . '">Media Manager</a>!',
|
||||
'button_savecaptions' => 'Save captions'
|
||||
);
|
25
fp-plugins/gallerycaptions/plugin.gallerycaptions.php
Normal file
25
fp-plugins/gallerycaptions/plugin.gallerycaptions.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Plugin Name: Gallery captions
|
||||
* Version: 1.0
|
||||
* Plugin URI: https://www.flatpress.org
|
||||
* Description: Manages image captions for gallery images; part of the standard distribution.
|
||||
* Author: FlatPress
|
||||
* Author URI: https://www.flatpress.org
|
||||
*/
|
||||
|
||||
// the minimum FlatPress version required
|
||||
const PLUGIN_GALLERYCAPTIONS_MINFPVERSION = '1.3';
|
||||
|
||||
// include the plugin's PHP files
|
||||
if (class_exists('AdminPanelAction')) {
|
||||
include_once dirname(__FILE__) . '/admin_uploader_gallerycaptions.class.php';
|
||||
|
||||
// check if FP instance has the gallery functions
|
||||
if (!function_exists('gallery_read_images')) {
|
||||
global $smarty;
|
||||
$smarty->append('error', 'Sorry, you need FlatPress version ' . PLUGIN_GALLERYCAPTIONS_MINFPVERSION . ' or later in order to run the Gallery captions plugin.');
|
||||
// FIXME: Deactivate plugin
|
||||
}
|
||||
}
|
3
fp-plugins/gallerycaptions/res/adminstyle.css
Normal file
3
fp-plugins/gallerycaptions/res/adminstyle.css
Normal file
@ -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%;}
|
@ -0,0 +1,51 @@
|
||||
<link rel="stylesheet" type="text/css" href="{$pluginurl}res/adminstyle.css" />
|
||||
<h2>{$plang.head}</h2>
|
||||
|
||||
{include file=shared:errorlist.tpl}
|
||||
|
||||
{html_form class=option-set}
|
||||
<p>
|
||||
{$plang.label_selectgallery}
|
||||
<select name='gallerycaptions-gallery'>
|
||||
{foreach from="$galleries" item="galleryname"}
|
||||
<option value="{$galleryname}" {if $galleryname == $currentgallery} selected="selected"{/if}>{$galleryname}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
<input type="submit" name="gallerycaptions-selectgallery" value="{$plang.button_selectgallery}"/>
|
||||
</p>
|
||||
{/html_form}
|
||||
|
||||
{if !empty($currentgallery)}
|
||||
<h4>{$plang.label_editcaptionsforgallery} {$currentgallery}</h4>
|
||||
{html_form class=option-set}
|
||||
<p>
|
||||
{if count($currentgalleryimages) == 0}
|
||||
{$plang.label_noimagesingallery}
|
||||
{else}
|
||||
<input type="hidden" name="galleryname" value="{$currentgallery}">
|
||||
<table class="entrylist plugin_gallerycaptions_captionstable">
|
||||
{foreach from="$currentgalleryimages" item="currentfilename"}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{$smarty.const.BLOG_BASEURL}{$smarty.const.IMAGES_DIR}{$currentgallery}/{$currentfilename}">
|
||||
<img
|
||||
src="{$smarty.const.BLOG_BASEURL}{$smarty.const.IMAGES_DIR}{$currentgallery}/{if defined("THUMB_DIR")}{$smarty.const.THUMB_DIR}/{/if}{$currentfilename}"
|
||||
alt="{$currentfilename}"
|
||||
title="{$currentfilename}"
|
||||
/>
|
||||
</a>
|
||||
<br>
|
||||
{$currentfilename}
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="captions[{$currentfilename}]" value="{if array_key_exists($currentfilename, $currentgallerycaptions)}{$currentgallerycaptions[$currentfilename]|escape}{/if}">
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
<input type="submit" name="gallerycaptions-savecaptions" value="{$plang.button_savecaptions}"/>
|
||||
{/if}
|
||||
</p>
|
||||
{/html_form}
|
||||
{/if}
|
||||
|
Loading…
x
Reference in New Issue
Block a user