Caption an entire album at once.
This commit is contained in:
parent
7a1e32b7e1
commit
d302da9f40
53
modules/captionator/controllers/captionator.php
Normal file
53
modules/captionator/controllers/captionator.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class Captionator_Controller extends Controller {
|
||||||
|
function dialog($album_id) {
|
||||||
|
$album = ORM::factory("item", $album_id);
|
||||||
|
access::required("view", $album);
|
||||||
|
access::required("edit", $album);
|
||||||
|
|
||||||
|
$v = new Theme_View("page.html", "collection", "captionator");
|
||||||
|
$v->content = new View("captionator_dialog.html");
|
||||||
|
$v->content->album = $album;
|
||||||
|
print $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
function save($album_id) {
|
||||||
|
access::verify_csrf();
|
||||||
|
|
||||||
|
$album = ORM::factory("item", $album_id);
|
||||||
|
access::required("edit", $album);
|
||||||
|
|
||||||
|
if (Input::instance()->post("save")) {
|
||||||
|
$titles = Input::instance()->post("title");
|
||||||
|
$descriptions = Input::instance()->post("description");
|
||||||
|
foreach (array_keys($titles) as $id) {
|
||||||
|
$item = ORM::factory("item", $id);
|
||||||
|
if ($item->loaded() && access::can("edit", $item)) {
|
||||||
|
$item->title = $titles[$id];
|
||||||
|
$item->description = $descriptions[$id];
|
||||||
|
$item->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message::success(t("Captions saved"));
|
||||||
|
}
|
||||||
|
url::redirect($album->parent()->abs_url());
|
||||||
|
}
|
||||||
|
}
|
33
modules/captionator/helpers/captionator_event.php
Normal file
33
modules/captionator/helpers/captionator_event.php
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.");
|
||||||
|
/**
|
||||||
|
* Gallery - a web based photo album viewer and editor
|
||||||
|
* Copyright (C) 2000-2010 Bharat Mediratta
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or (at
|
||||||
|
* your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
class captionator_event_Core {
|
||||||
|
static function site_menu($menu, $theme) {
|
||||||
|
$item = $theme->item();
|
||||||
|
|
||||||
|
if ($item && $item->is_album() && access::can("edit", $item)) {
|
||||||
|
$menu->get("options_menu")
|
||||||
|
->append(Menu::factory("link")
|
||||||
|
->id("captionator")
|
||||||
|
->label(t("Caption album"))
|
||||||
|
->css_id("g-menu-captionator-link")
|
||||||
|
->url(url::site("captionator/dialog/{$item->id}")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
modules/captionator/module.info
Normal file
3
modules/captionator/module.info
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
name = "Captionator"
|
||||||
|
description = "Caption all photos, movies and albums in an album at once."
|
||||||
|
version = 1
|
37
modules/captionator/views/captionator_dialog.html.php
Normal file
37
modules/captionator/views/captionator_dialog.html.php
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||||
|
<div id="g-captionator-dialog">
|
||||||
|
<form action="<?= url::site("captionator/save/{$album->id}") ?>" method="post" id="g-captionator-form">
|
||||||
|
<?= access::csrf_form_field() ?>
|
||||||
|
<fieldset>
|
||||||
|
<legend>
|
||||||
|
<?= t("Add captions for photos in <b>%album_name</b>", array("album_name" => $album->name)) ?>
|
||||||
|
</legend>
|
||||||
|
|
||||||
|
<? foreach ($album->viewable()->children() as $child): ?>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td style="width: 140px">
|
||||||
|
<?= $child->thumb_img(array(), 140, true) ?>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<label for="title[<?= $child->id ?>]"> <?= t("Title") ?> </label>
|
||||||
|
<input type="text" name="title[<?= $child->id ?>]" value="<?= $child->title ?>"/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<label for="description[<?= $child->id ?>]"> <?= t("Description") ?> </label>
|
||||||
|
<textarea style="height: 5em" name="description[<?= $child->id ?>]"><?= $child->description ?></textarea>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<? endforeach ?>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset>
|
||||||
|
<input type="submit" name="cancel" value="<?= t("Cancel") ?>"/>
|
||||||
|
<input type="submit" name="save" value="<?= t("Save") ?>"/>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
Reference in New Issue
Block a user