Removed mass tagger extension
This commit is contained in:
parent
33fff87f39
commit
8f95d23828
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: Mass Tagger
|
||||
* Author: Christian Walde <walde.christian@googlemail.com>, contributions by Shish and Agasa
|
||||
* License: WTFPL
|
||||
* Description: Tag a bunch of images at once
|
||||
* Documentation:
|
||||
* Once enabled, a new "Mass Tagger" box will appear on the left hand side of
|
||||
* post listings, with a button to enable the mass tagger. Once clicked JS will
|
||||
* add buttons to each image to mark them for tagging, and a field for
|
||||
* inputting tags will appear. Once the "Tag" button is clicked, the tags in
|
||||
* the text field will be added to marked images.
|
||||
*/
|
||||
|
||||
class MassTagger extends Extension
|
||||
{
|
||||
public function onPostListBuilding(PostListBuildingEvent $event)
|
||||
{
|
||||
global $config, $page, $user;
|
||||
|
||||
if ($user->is_admin()) {
|
||||
$this->theme->display_mass_tagger($page, $event, $config);
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $page, $user;
|
||||
if ($event->page_matches("mass_tagger/tag") && $user->is_admin()) {
|
||||
if (!isset($_POST['ids']) or !isset($_POST['tag'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tags = Tag::explode($_POST['tag']);
|
||||
|
||||
$pos_tag_array = [];
|
||||
$neg_tag_array = [];
|
||||
foreach ($tags as $new_tag) {
|
||||
if (strpos($new_tag, '-') === 0) {
|
||||
$neg_tag_array[] = substr($new_tag, 1);
|
||||
} else {
|
||||
$pos_tag_array[] = $new_tag;
|
||||
}
|
||||
}
|
||||
|
||||
$ids = explode(':', $_POST['ids']);
|
||||
$ids = array_filter($ids, 'is_numeric');
|
||||
|
||||
$images = array_map("Image::by_id", $ids);
|
||||
|
||||
if (isset($_POST['setadd']) && $_POST['setadd'] == 'set') {
|
||||
foreach ($images as $image) {
|
||||
$image->set_tags($tags);
|
||||
}
|
||||
} else {
|
||||
foreach ($images as $image) {
|
||||
if (!empty($neg_tag_array)) {
|
||||
$img_tags = array_merge($pos_tag_array, $image->get_tag_array());
|
||||
$img_tags = array_diff($img_tags, $neg_tag_array);
|
||||
$image->set_tags($img_tags);
|
||||
} else {
|
||||
$image->set_tags(array_merge($tags, $image->get_tag_array()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$page->set_mode(PageMode::REDIRECT);
|
||||
if (!isset($_SERVER['HTTP_REFERER'])) {
|
||||
$_SERVER['HTTP_REFERER'] = make_link();
|
||||
}
|
||||
$page->set_redirect($_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
|
||||
|
||||
function activate_mass_tagger ( image_link ) {
|
||||
$(".shm-thumb").each(
|
||||
function ( index, block ) {
|
||||
add_mass_tag_button( $(block), image_link );
|
||||
}
|
||||
);
|
||||
$('#mass_tagger_controls').show();
|
||||
$('#mass_tagger_activate').hide();
|
||||
}
|
||||
|
||||
function add_mass_tag_button($block, image_link) {
|
||||
|
||||
var c = function() { toggle_tag(this, $block.data("post-id")); return false; };
|
||||
|
||||
$block.find("A").click(c);
|
||||
$block.click(c); // sometimes the thumbs *is* the A
|
||||
}
|
||||
|
||||
function toggle_tag( button, id ) {
|
||||
id += ":";
|
||||
var list = $('#mass_tagger_ids');
|
||||
var string = list.val();
|
||||
|
||||
if( (string.indexOf(id) == 0) || (string.indexOf(":"+id) > -1) ) {
|
||||
$(button).removeClass('mass-tagger-selected');
|
||||
string = string.replace(id, '');
|
||||
list.val(string);
|
||||
}
|
||||
else {
|
||||
$(button).addClass('mass-tagger-selected');
|
||||
string += id;
|
||||
list.val(string);
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
// Clear the selection, in case it was autocompleted by the browser.
|
||||
$('#mass_tagger_ids').val("");
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
.mass-tagger-selected {
|
||||
border: 3px solid blue;
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
class MassTaggerTheme extends Themelet
|
||||
{
|
||||
public function display_mass_tagger(Page $page, Event $event, $config)
|
||||
{
|
||||
$data_href = get_base_href();
|
||||
$body = "
|
||||
<form action='".make_link("mass_tagger/tag")."' method='POST'>
|
||||
<input id='mass_tagger_activate' type='button' onclick='activate_mass_tagger(\"$data_href\");' value='Activate'/>
|
||||
<div id='mass_tagger_controls' style='display: none;'>
|
||||
Click on images to mark them. Use the 'Index Options' in the Board Config to increase the amount of shown images.
|
||||
<br />
|
||||
<input type='hidden' name='ids' id='mass_tagger_ids' />
|
||||
Set instead of add? <input type='checkbox' name='setadd' value='set' />
|
||||
<label>Tags: <input type='text' name='tag' class='autocomplete_tags' autocomplete='off' /></label>
|
||||
|
||||
<input type='submit' value='Tag Marked Images' />
|
||||
</div>
|
||||
</form>
|
||||
";
|
||||
$block = new Block("Mass Tagger", $body, "left", 50);
|
||||
$page->add_block($block);
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB |
Loading…
x
Reference in New Issue
Block a user