From 1fd2fe084b81ce95e4378b3ff441bf365d735c50 Mon Sep 17 00:00:00 2001 From: shish Date: Fri, 11 Apr 2008 05:47:16 +0000 Subject: [PATCH] apply cleanups to 2.2 git-svn-id: file:///home/shish/svn/shimmie2/branches/branch_2.2@807 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/admin_utils/main.php | 69 --------- contrib/admin_utils/theme.php | 24 ---- {ext => contrib}/bulk_add/main.php | 0 {ext => contrib}/bulk_add/theme.php | 0 {ext => contrib}/downtime/main.php | 0 {ext => contrib}/downtime/theme.php | 0 {ext => contrib}/et/main.php | 0 {ext => contrib}/et/theme.php | 0 {ext => contrib}/ipban/main.php | 0 {ext => contrib}/ipban/schema.xml | 4 +- {ext => contrib}/ipban/theme.php | 0 {ext => contrib}/news/main.php | 0 {ext => contrib}/news/theme.php | 0 {ext => contrib}/regen_thumb/main.php | 0 {ext => contrib}/regen_thumb/theme.php | 0 {ext => contrib}/rss_images/main.php | 0 {ext => contrib}/zoom/main.php | 0 {ext => contrib}/zoom/theme.php | 0 ext/admin/main.php | 50 +++++++ ext/admin/theme.php | 20 +++ themes/danbooru/layout.class.php | 1 + .../danbooru}/script.js | 0 themes/default/layout.class.php | 1 + themes/default/script.js | 136 ++++++++++++++++++ 24 files changed, 210 insertions(+), 95 deletions(-) delete mode 100644 contrib/admin_utils/main.php delete mode 100644 contrib/admin_utils/theme.php rename {ext => contrib}/bulk_add/main.php (100%) rename {ext => contrib}/bulk_add/theme.php (100%) rename {ext => contrib}/downtime/main.php (100%) rename {ext => contrib}/downtime/theme.php (100%) rename {ext => contrib}/et/main.php (100%) rename {ext => contrib}/et/theme.php (100%) rename {ext => contrib}/ipban/main.php (100%) rename {ext => contrib}/ipban/schema.xml (86%) rename {ext => contrib}/ipban/theme.php (100%) rename {ext => contrib}/news/main.php (100%) rename {ext => contrib}/news/theme.php (100%) rename {ext => contrib}/regen_thumb/main.php (100%) rename {ext => contrib}/regen_thumb/theme.php (100%) rename {ext => contrib}/rss_images/main.php (100%) rename {ext => contrib}/zoom/main.php (100%) rename {ext => contrib}/zoom/theme.php (100%) rename {ext/core_scripts => themes/danbooru}/script.js (100%) create mode 100644 themes/default/script.js diff --git a/contrib/admin_utils/main.php b/contrib/admin_utils/main.php deleted file mode 100644 index f9f23db4..00000000 --- a/contrib/admin_utils/main.php +++ /dev/null @@ -1,69 +0,0 @@ - - * Link: http://trac.shishnet.org/shimmie2/ - * License: GPLv2 - * Description: Various non-essential utilities - */ - -class AdminUtils extends Extension { - var $theme; - - public function receive_event($event) { - if(is_null($this->theme)) $this->theme = get_theme_object("admin_utils", "AdminUtilsTheme"); - - if(is_a($event, 'PageRequestEvent') && ($event->page_name == "admin_utils")) { - if($event->user->is_admin()) { - set_time_limit(0); - - switch($_POST['action']) { - case 'lowercase all tags': - $this->lowercase_all_tags(); - break; - case 'recount tag use': - $this->recount_tag_use(); - break; - case 'purge unused tags': - $this->purge_unused_tags(); - break; - } - - $event->page->set_mode("redirect"); - $event->page->set_redirect(make_link("admin")); - } - } - - if(is_a($event, 'AdminBuildingEvent')) { - global $page; - $this->theme->display_form($page); - } - } - - private function lowercase_all_tags() { - global $database; - $database->execute("UPDATE tags SET tag=lower(tag)"); - } - private function recount_tag_use() { - global $database; - $database->Execute("UPDATE tags SET count=(SELECT COUNT(image_id) FROM image_tags WHERE tag_id=tags.id GROUP BY tag_id)"); - } - private function purge_unused_tags() { - global $database; - $this->recount_tag_use(); - $database->Execute("DELETE FROM tags WHERE count=0"); - } - private function check_for_orphanned_images() { - $orphans = array(); - foreach(glob("images/*") as $dir) { - foreach(glob("$dir/*") as $file) { - $hash = str_replace("$dir/", "", $file); - if(!$this->db_has_hash($hash)) { - $orphans[] = $hash; - } - } - } - } -} -add_event_listener(new AdminUtils()); -?> diff --git a/contrib/admin_utils/theme.php b/contrib/admin_utils/theme.php deleted file mode 100644 index 4e53f158..00000000 --- a/contrib/admin_utils/theme.php +++ /dev/null @@ -1,24 +0,0 @@ -
- - -
- "; - $page->add_block(new Block("Misc Admin Tools", $html)); - } -} -?> diff --git a/ext/bulk_add/main.php b/contrib/bulk_add/main.php similarity index 100% rename from ext/bulk_add/main.php rename to contrib/bulk_add/main.php diff --git a/ext/bulk_add/theme.php b/contrib/bulk_add/theme.php similarity index 100% rename from ext/bulk_add/theme.php rename to contrib/bulk_add/theme.php diff --git a/ext/downtime/main.php b/contrib/downtime/main.php similarity index 100% rename from ext/downtime/main.php rename to contrib/downtime/main.php diff --git a/ext/downtime/theme.php b/contrib/downtime/theme.php similarity index 100% rename from ext/downtime/theme.php rename to contrib/downtime/theme.php diff --git a/ext/et/main.php b/contrib/et/main.php similarity index 100% rename from ext/et/main.php rename to contrib/et/main.php diff --git a/ext/et/theme.php b/contrib/et/theme.php similarity index 100% rename from ext/et/theme.php rename to contrib/et/theme.php diff --git a/ext/ipban/main.php b/contrib/ipban/main.php similarity index 100% rename from ext/ipban/main.php rename to contrib/ipban/main.php diff --git a/ext/ipban/schema.xml b/contrib/ipban/schema.xml similarity index 86% rename from ext/ipban/schema.xml rename to contrib/ipban/schema.xml index 10a8e68e..168b1cb4 100644 --- a/ext/ipban/schema.xml +++ b/contrib/ipban/schema.xml @@ -5,8 +5,8 @@ - - + + ip DEFAULT CHARSET='utf8' diff --git a/ext/ipban/theme.php b/contrib/ipban/theme.php similarity index 100% rename from ext/ipban/theme.php rename to contrib/ipban/theme.php diff --git a/ext/news/main.php b/contrib/news/main.php similarity index 100% rename from ext/news/main.php rename to contrib/news/main.php diff --git a/ext/news/theme.php b/contrib/news/theme.php similarity index 100% rename from ext/news/theme.php rename to contrib/news/theme.php diff --git a/ext/regen_thumb/main.php b/contrib/regen_thumb/main.php similarity index 100% rename from ext/regen_thumb/main.php rename to contrib/regen_thumb/main.php diff --git a/ext/regen_thumb/theme.php b/contrib/regen_thumb/theme.php similarity index 100% rename from ext/regen_thumb/theme.php rename to contrib/regen_thumb/theme.php diff --git a/ext/rss_images/main.php b/contrib/rss_images/main.php similarity index 100% rename from ext/rss_images/main.php rename to contrib/rss_images/main.php diff --git a/ext/zoom/main.php b/contrib/zoom/main.php similarity index 100% rename from ext/zoom/main.php rename to contrib/zoom/main.php diff --git a/ext/zoom/theme.php b/contrib/zoom/theme.php similarity index 100% rename from ext/zoom/theme.php rename to contrib/zoom/theme.php diff --git a/ext/admin/main.php b/ext/admin/main.php index e5f452e7..ec360bef 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -40,6 +40,27 @@ class AdminPage extends Extension { } } + if(is_a($event, 'PageRequestEvent') && ($event->page_name == "admin_utils")) { + if($event->user->is_admin()) { + set_time_limit(0); + + switch($_POST['action']) { + case 'lowercase all tags': + $this->lowercase_all_tags(); + break; + case 'recount tag use': + $this->recount_tag_use(); + break; + case 'purge unused tags': + $this->purge_unused_tags(); + break; + } + + $event->page->set_mode("redirect"); + $event->page->set_redirect(make_link("admin")); + } + } + if(is_a($event, 'DisplayingImageEvent')) { global $user; if($user->is_admin()) { @@ -49,6 +70,7 @@ class AdminPage extends Extension { if(is_a($event, 'AdminBuildingEvent')) { $this->theme->display_page($event->page); + $this->theme->display_form($event->page); } if(is_a($event, 'UserBlockBuildingEvent')) { @@ -57,6 +79,34 @@ class AdminPage extends Extension { } } } + + private function lowercase_all_tags() { + global $database; + $database->execute("UPDATE tags SET tag=lower(tag)"); + } + + private function recount_tag_use() { + global $database; + $database->Execute("UPDATE tags SET count=(SELECT COUNT(image_id) FROM image_tags WHERE tag_id=tags.id GROUP BY tag_id)"); + } + + private function purge_unused_tags() { + global $database; + $this->recount_tag_use(); + $database->Execute("DELETE FROM tags WHERE count=0"); + } + + private function check_for_orphanned_images() { + $orphans = array(); + foreach(glob("images/*") as $dir) { + foreach(glob("$dir/*") as $file) { + $hash = str_replace("$dir/", "", $file); + if(!$this->db_has_hash($hash)) { + $orphans[] = $hash; + } + } + } + } } add_event_listener(new AdminPage()); ?> diff --git a/ext/admin/theme.php b/ext/admin/theme.php index 172fd49e..6178f74b 100644 --- a/ext/admin/theme.php +++ b/ext/admin/theme.php @@ -25,5 +25,25 @@ class AdminPageTheme extends Themelet { "; $page->add_block(new Block("Admin", $html, "left")); } + + /* + * Show a form which links to admin_utils with POST[action] set to one of: + * 'lowercase all tags' + * 'recount tag use' + * 'purge unused tags' + */ + public function display_form($page) { + $html = " +

+ + +
+ "; + $page->add_block(new Block("Misc Admin Tools", $html)); + } } ?> diff --git a/themes/danbooru/layout.class.php b/themes/danbooru/layout.class.php index 73a9146c..8d858d32 100644 --- a/themes/danbooru/layout.class.php +++ b/themes/danbooru/layout.class.php @@ -126,6 +126,7 @@ class Layout { $header_html + diff --git a/ext/core_scripts/script.js b/themes/danbooru/script.js similarity index 100% rename from ext/core_scripts/script.js rename to themes/danbooru/script.js diff --git a/themes/default/layout.class.php b/themes/default/layout.class.php index a3aa4689..a8d7c2b3 100644 --- a/themes/default/layout.class.php +++ b/themes/default/layout.class.php @@ -50,6 +50,7 @@ class Layout { $header_html + diff --git a/themes/default/script.js b/themes/default/script.js new file mode 100644 index 00000000..3b26466e --- /dev/null +++ b/themes/default/script.js @@ -0,0 +1,136 @@ +var defaultTexts = new Array(); + +window.onload = function(e) { + var sections=get_sections(); + for(var i=0;i