Put a block in the sidebar, show untagged photos and ask for them to be tagged.
This commit is contained in:
parent
0db0182e4a
commit
287e7189fd
29
modules/tag_it/controllers/tag_it.php
Normal file
29
modules/tag_it/controllers/tag_it.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?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 Tag_It_Controller extends Controller {
|
||||
public function tags_for($id) {
|
||||
$item = ORM::factory("item", $id);
|
||||
access::required("view", $item);
|
||||
|
||||
$view = new View("tag_it_tags_for.html");
|
||||
$view->tags = tag::item_tags($item);
|
||||
print $view;
|
||||
}
|
||||
}
|
67
modules/tag_it/helpers/tag_it_block.php
Normal file
67
modules/tag_it/helpers/tag_it_block.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?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 tag_it_block_Core {
|
||||
static function get_site_list() {
|
||||
return array("untagged_photo" => t("Tag it"));
|
||||
}
|
||||
|
||||
static function get($block_id, $theme) {
|
||||
if (identity::active_user()->guest) {
|
||||
return;
|
||||
}
|
||||
|
||||
$block = "";
|
||||
switch ($block_id) {
|
||||
case "untagged_photo":
|
||||
$attempts = 0;
|
||||
do {
|
||||
$item = item::random_query()
|
||||
->join("items_tags", "items.id", "items_tags.item_id", "left")
|
||||
->where("items.type", "!=", "album")
|
||||
->where("items_tags.item_id", "IS", null)
|
||||
->find_all(1)
|
||||
->current();
|
||||
} while (!$item && $attempts++ < 3);
|
||||
if ($item && $item->loaded()) {
|
||||
$block = new Block();
|
||||
$block->css_id = "g-tag-it-block";
|
||||
$block->title = t("Tag it");
|
||||
$block->content = new View("tag_it_block.html");
|
||||
$block->content->item = $item;
|
||||
|
||||
$form = new Forge("tags/create/{$item->id}", "", "post",
|
||||
array("id" => "g-tag-it-add-tag-form", "class" => "g-short-form"));
|
||||
$label = $item->is_album() ?
|
||||
t("Add tag to album") :
|
||||
($item->is_photo() ? t("Add tag to photo") : t("Add tag to movie"));
|
||||
|
||||
$group = $form->group("add_tag")->label("Add Tag");
|
||||
$group->input("name")->label($label)->rules("required")->id("name");
|
||||
$group->hidden("item_id")->value($item->id);
|
||||
$group->submit("")->value(t("Add Tag"));
|
||||
|
||||
$block->content->form = $form;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $block;
|
||||
}
|
||||
}
|
3
modules/tag_it/module.info
Normal file
3
modules/tag_it/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Tag It"
|
||||
description = "Present an untagged photo and ask the user to tag it."
|
||||
version = 1
|
28
modules/tag_it/views/tag_it_block.html.php
Normal file
28
modules/tag_it/views/tag_it_block.html.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<script type="text/javascript">
|
||||
$("#g-tag-it-add-tag-form").ready(function() {
|
||||
$("#g-tag-it-add-tag-form input:text").autocomplete(
|
||||
"<?= url::site("tags/autocomplete") ?>", {
|
||||
max: 30,
|
||||
multiple: true,
|
||||
multipleSeparator: ',',
|
||||
cacheLength: 1,
|
||||
selectFirst: false,
|
||||
}
|
||||
);
|
||||
$("#g-tag-it-add-tag-form").ajaxForm({
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
$("#g-tag-it-add-tag-form").resetForm();
|
||||
$("#g-tag-it-tags-container").load("<?= url::site("tag_it/tags_for/{$item->id}") ?>");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<div class="g-tag-it-block">
|
||||
<a href="<?= $item->url() ?>">
|
||||
<?= $item->thumb_img(array("class" => "g-thumbnail")) ?>
|
||||
</a>
|
||||
<p id="g-tag-it-tags-container"></p>
|
||||
<?= $form ?>
|
||||
</div>
|
5
modules/tag_it/views/tag_it_tags_for.html.php
Normal file
5
modules/tag_it/views/tag_it_tags_for.html.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<?= t("Tags:") ?>
|
||||
<? foreach ($tags as $tag): ?>
|
||||
<a href="<?= url::site("tag/{$tag->name}") ?>"><?= $tag->name ?></a>
|
||||
<? endforeach ?>
|
Reference in New Issue
Block a user