This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/bulk_add/main.php

53 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2009-08-20 23:37:17 +01:00
/*
* Name: Bulk Add
* Author: Shish <webmaster@shishnet.org>
* Link: http://code.shishnet.org/shimmie2/
* License: GPLv2
* Description: Bulk add server-side images
2009-01-16 00:18:41 -08:00
* Documentation:
2009-01-16 18:25:39 -08:00
* Upload the images into a new directory via ftp or similar, go to
* shimmie's admin page and put that directory in the bulk add box.
* If there are subdirectories, they get used as tags (eg if you
* upload into <code>/home/bob/uploads/holiday/2008/</code> and point
* shimmie at <code>/home/bob/uploads</code>, then images will be
2009-01-16 00:18:41 -08:00
* tagged "holiday 2008")
2010-05-28 11:39:10 +01:00
* <p><b>Note:</b> requires the "admin" extension to be enabled
*/
class BulkAdd extends Extension {
public function onPageRequest(PageRequestEvent $event) {
2009-05-11 14:09:24 -07:00
global $page, $user;
if($event->page_matches("bulk_add")) {
2010-05-28 14:26:46 +01:00
if($user->is_admin() && $user->check_auth_token() && isset($_POST['dir'])) {
set_time_limit(0);
$list = add_dir($_POST['dir']);
if(strlen($list) > 0) {
$this->theme->add_status("Adding files", $list);
}
2009-05-11 14:09:24 -07:00
$this->theme->display_upload_results($page);
}
}
2009-05-11 14:09:24 -07:00
}
public function onCommand(CommandEvent $event) {
if($event->cmd == "help") {
print " bulk-add [directory]\n";
2014-04-06 20:47:01 +01:00
print " Import this directory\n\n";
}
if($event->cmd == "bulk-add") {
if(count($event->args) == 1) {
$list = add_dir($event->args[0]);
if(strlen($list) > 0) {
$this->theme->add_status("Adding files", $list);
}
}
}
}
public function onAdminBuilding(AdminBuildingEvent $event) {
2010-05-28 14:26:46 +01:00
$this->theme->display_admin_block();
}
}