formatting

This commit is contained in:
Shish
2019-09-29 14:30:55 +01:00
parent 56e247faf5
commit a6bb15d859
108 changed files with 424 additions and 429 deletions

View File

@@ -7,7 +7,6 @@ abstract class TrashConfig
class Trash extends Extension
{
public function get_priority(): int
{
// Needs to be early to intercept delete events
@@ -50,7 +49,7 @@ class Trash extends Extension
{
global $user, $page;
if($event->image->trash===true && !$user->can(Permissions::VIEW_TRASH)) {
if ($event->image->trash===true && !$user->can(Permissions::VIEW_TRASH)) {
$page->set_mode(PageMode::REDIRECT);
$page->set_redirect(make_link("post/list"));
}
@@ -58,7 +57,7 @@ class Trash extends Extension
public function onImageDeletion(ImageDeletionEvent $event)
{
if($event->force!==true && $event->image->trash!==true) {
if ($event->force!==true && $event->image->trash!==true) {
self::set_trash($event->image->id, true);
$event->stop_processing = true;
}
@@ -78,7 +77,7 @@ class Trash extends Extension
if (preg_match(self::SEARCH_REGEXP, strtolower($event->term), $matches)) {
if($user->can(Permissions::VIEW_TRASH)) {
if ($user->can(Permissions::VIEW_TRASH)) {
$event->add_querylet(new Querylet($database->scoreql_to_sql("trash = SCORE_BOOL_Y ")));
}
}
@@ -87,8 +86,8 @@ class Trash extends Extension
public function onHelpPageBuilding(HelpPageBuildingEvent $event)
{
global $user;
if($event->key===HelpPages::SEARCH) {
if($user->can(Permissions::VIEW_TRASH)) {
if ($event->key===HelpPages::SEARCH) {
if ($user->can(Permissions::VIEW_TRASH)) {
$block = new Block();
$block->header = "Trash";
$block->body = $this->theme->get_help_html();
@@ -108,18 +107,19 @@ class Trash extends Extension
return true;
}
public static function set_trash($image_id, $trash) {
public static function set_trash($image_id, $trash)
{
global $database;
$database->execute("UPDATE images SET trash = :trash WHERE id = :id",
["trash"=>$database->scoresql_value_prepare($trash),"id"=>$image_id]);
$database->execute(
"UPDATE images SET trash = :trash WHERE id = :id",
["trash"=>$database->scoresql_value_prepare($trash),"id"=>$image_id]
);
}
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
{
global $config, $database, $user;
if($event->image->trash===true && $user->can(Permissions::VIEW_TRASH)) {
if ($event->image->trash===true && $user->can(Permissions::VIEW_TRASH)) {
$event->add_part($this->theme->get_image_admin_html($event->image->id));
}
}
@@ -129,7 +129,7 @@ class Trash extends Extension
global $user;
if ($user->can(Permissions::VIEW_TRASH)&&in_array("in:trash", $event->search_terms)) {
$event->add_action("bulk_trash_restore","(U)ndelete", "u");
$event->add_action("bulk_trash_restore", "(U)ndelete", "u");
}
}
@@ -163,7 +163,5 @@ class Trash extends Extension
$database->Execute("CREATE INDEX images_trash_idx ON images(trash)");
$config->set_int(TrashConfig::VERSION, 1);
}
}
}

View File

@@ -2,7 +2,8 @@
class TrashTheme extends Themelet
{
function get_image_admin_html(int $image_id) {
public function get_image_admin_html(int $image_id)
{
$html = "
".make_form(make_link('trash_restore/'.$image_id), 'POST')."
<input type='hidden' name='image_id' value='$image_id'>
@@ -10,7 +11,8 @@ class TrashTheme extends Themelet
</form>
";
return $html; }
return $html;
}
public function get_help_html()
@@ -21,6 +23,5 @@ class TrashTheme extends Themelet
<p>Returns images that are in the trash.</p>
</div>
';
}
}