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/contrib/admin/theme.php

84 lines
2.7 KiB
PHP
Raw Normal View History

<?php
class AdminPageTheme extends Themelet {
/*
* Show the basics of a page, for other extensions to add to
*/
2009-01-04 19:54:16 +00:00
public function display_page(Page $page) {
$page->set_title("Admin Tools");
$page->set_heading("Admin Tools");
$page->add_block(new NavBlock());
}
2012-03-10 13:48:56 +00:00
protected function button(/*string*/ $name, /*string*/ $action, /*boolean*/ $protected=false) {
$c_protected = $protected ? " protected" : "";
$html = make_form(make_link("admin_utils"), "POST", false, false, false, "admin$c_protected");
if($protected) {
$html .= "<input type='checkbox' onclick='$(\"#$action\").attr(\"disabled\", !$(this).is(\":checked\"))'>";
}
$html .= "<input type='hidden' value='$action'>";
if($protected) {
$html .= "<input type='submit' id='$action' value='$name' disabled='true'>";
}
else {
$html .= "<input type='submit' id='$action' value='$name'>";
}
$html .= "</form>\n";
return $html;
}
/*
* Show a form which links to admin_utils with POST[action] set to one of:
* 'lowercase all tags'
* 'recount tag use'
* 'purge unused tags'
*/
2009-01-04 19:54:16 +00:00
public function display_form(Page $page) {
2010-05-28 13:26:46 +00:00
global $user;
2012-03-10 13:48:56 +00:00
$html = "";
$html .= $this->button("All tags to lowercase", "lowercase_all_tags", true);
$html .= $this->button("Recount tag use", "recount_tag_user", false);
$html .= $this->button("Purge unused tags", "purge_unused_tags", true);
$html .= $this->button("Download database contents", "database_dump", false);
$html .= $this->button("Reset image IDs", "reset_image_ids", true);
$html .= $this->button("Download all images", "image_dump", false);
$page->add_block(new Block("Misc Admin Tools", $html));
/* First check
Requires you to click the checkbox to enable the delete by query form */
$dbqcheck = 'javascript:$(function() {
if($("#dbqcheck:checked").length != 0){
$("#dbqtags").attr("disabled", false);
$("#dbqsubmit").attr("disabled", false);
}else{
$("#dbqtags").attr("disabled", true);
$("#dbqsubmit").attr("disabled", true);
}
});';
/* Second check
Requires you to confirm the deletion by clicking ok. */
2010-12-23 14:00:50 +00:00
$html = "
<script type='text/javascript'>
function checkform(){
if(confirm('Are you sure you wish to delete all images using these tags?')){
return true;
}else{
return false;
}
}
</script>"
.make_form(make_link("admin_utils"),"post",false,false,"return checkform()")."
<input type='checkbox' id='dbqcheck' name='action' onclick='$dbqcheck'>
2010-12-23 14:00:50 +00:00
<input type='hidden' name='action' value='delete by query'>
<input type='text' id='dbqtags' disabled='true' name='query'>
<input type='submit' id='dbqsubmit' disabled='true' value='Go'>
2010-12-23 14:00:50 +00:00
</form>
";
$page->add_block(new Block("Delete by Query", $html));
}
}
?>