tags(image_id,tag) split into image_tags(image_id,tag_id) and tags(id,tag,count)
git-svn-id: file:///home/shish/svn/shimmie2/trunk@227 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
@ -22,6 +22,12 @@ class AdminUtils extends Extension {
|
||||
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;
|
||||
}
|
||||
|
||||
global $page;
|
||||
@ -41,6 +47,15 @@ class AdminUtils extends Extension {
|
||||
global $database;
|
||||
$database->execute("UPDATE tags SET tag=lower(tag)");
|
||||
}
|
||||
private function recout_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) {
|
||||
|
@ -1,11 +1,15 @@
|
||||
<?php
|
||||
|
||||
class AdminUtilsTheme extends Themelet {
|
||||
public function display_form() {
|
||||
public function display_form($page) {
|
||||
$html = "
|
||||
<p><form action='".make_link("admin_utils")."' method='POST'>
|
||||
<input type='hidden' name='action' value='lowercase all tags'>
|
||||
<input type='submit' value='Lowercase All Tags'>
|
||||
<select name='action'>
|
||||
<option value='lowercase all tags'>All tags to lowercase</option>
|
||||
<option value='recount tag use'>Recount tag use</option>
|
||||
<option value='purge unused tags'>Purge unused tags</option>
|
||||
</select>
|
||||
<input type='submit' value='Go'>
|
||||
</form>
|
||||
";
|
||||
$page->add_block(new Block("Misc Admin Tools", $html));
|
||||
|
Reference in New Issue
Block a user