remove some dead code
This commit is contained in:
parent
0961ad465f
commit
8a58ede5b3
22 changed files with 25 additions and 82 deletions
|
@ -121,7 +121,7 @@ class Approval extends Extension
|
|||
const SEARCH_REGEXP = "/^approved:(yes|no)/";
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
global $user, $database, $config;
|
||||
global $user, $config;
|
||||
|
||||
if ($config->get_bool(ApprovalConfig::IMAGES)) {
|
||||
$matches = [];
|
||||
|
|
|
@ -314,14 +314,10 @@ class AutoTagger extends Extension
|
|||
$tags_mixed = array_merge($tags_mixed, $new_tags);
|
||||
}
|
||||
|
||||
$results = array_intersect_key(
|
||||
return array_intersect_key(
|
||||
$tags_mixed,
|
||||
array_unique(array_map('strtolower', $tags_mixed))
|
||||
);
|
||||
|
||||
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -193,14 +193,14 @@ class BulkActions extends Extension
|
|||
if (is_iterable($items)) {
|
||||
send_event($bae);
|
||||
}
|
||||
|
||||
if ($bae->redirect) {
|
||||
$page->set_mode(PageMode::REDIRECT);
|
||||
$page->set_redirect(referer_or(make_link()));
|
||||
}
|
||||
} catch (BulkActionException $e) {
|
||||
log_error(BulkActionsInfo::KEY, $e->getMessage(), $e->getMessage());
|
||||
}
|
||||
|
||||
if ($bae->redirect) {
|
||||
$page->set_mode(PageMode::REDIRECT);
|
||||
$page->set_redirect(referer_or(make_link()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ class BulkAddTest extends ShimmiePHPUnitTestCase
|
|||
{
|
||||
send_event(new UserLoginEvent(User::by_name(self::$admin_name)));
|
||||
$bae = send_event(new BulkAddEvent('asdf'));
|
||||
$this->assertContains(
|
||||
$this->assertContainsEquals(
|
||||
"Error, asdf is not a readable directory",
|
||||
$bae->results,
|
||||
implode("\n", $bae->results)
|
||||
|
|
|
@ -21,7 +21,7 @@ class BulkDownload extends Extension
|
|||
|
||||
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event)
|
||||
{
|
||||
global $user, $config;
|
||||
global $user;
|
||||
|
||||
if ($user->can(Permissions::BULK_DOWNLOAD)) {
|
||||
$event->add_action(BulkDownload::DOWNLOAD_ACTION_NAME, "Download ZIP");
|
||||
|
|
|
@ -7,6 +7,7 @@ class BulkExportEvent extends Event
|
|||
|
||||
public function __construct(Image $image)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->image = $image;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +20,7 @@ class BulkImportEvent extends Event
|
|||
|
||||
public function __construct(Image $image, $fields)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->image = $image;
|
||||
$this->fields = $fields;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ class BulkImportExport extends DataHandlerExtension
|
|||
|
||||
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event)
|
||||
{
|
||||
global $user, $config;
|
||||
global $user;
|
||||
|
||||
if ($user->can(Permissions::BULK_EXPORT)) {
|
||||
$event->add_action(self::EXPORT_ACTION_NAME, "Export");
|
||||
|
@ -167,7 +167,6 @@ class BulkImportExport extends DataHandlerExtension
|
|||
private function get_export_data(ZipArchive $zip): ?array
|
||||
{
|
||||
$info = $zip->getStream(self::EXPORT_INFO_FILE_NAME);
|
||||
$json_data = [];
|
||||
if ($info !== false) {
|
||||
try {
|
||||
$json_string = stream_get_contents($info);
|
||||
|
|
|
@ -9,6 +9,7 @@ class ImageDownloadingEvent extends Event
|
|||
|
||||
public function __construct(Image $image, String $path, string $mime)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->image = $image;
|
||||
$this->path = $path;
|
||||
$this->mime = $mime;
|
||||
|
|
|
@ -230,14 +230,10 @@ class Media extends Extension
|
|||
// }
|
||||
}
|
||||
|
||||
|
||||
const CONTENT_SEARCH_TERM_REGEX = "/^content[=|:]((video)|(audio)|(image)|(unknown))$/i";
|
||||
|
||||
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
global $database;
|
||||
|
||||
if (is_null($event->term)) {
|
||||
return;
|
||||
}
|
||||
|
@ -323,10 +319,11 @@ class Media extends Extension
|
|||
global $config;
|
||||
|
||||
$ffmpeg = $config->get_string(MediaConfig::FFMPEG_PATH);
|
||||
if ($ffmpeg == null || $ffmpeg == "") {
|
||||
throw new MediaException("ffmpeg command configured");
|
||||
if (empty($ffmpeg)) {
|
||||
throw new MediaException("ffmpeg command not configured");
|
||||
}
|
||||
|
||||
$ok = false;
|
||||
$inname = warehouse_path(Image::IMAGE_DIR, $hash);
|
||||
$tmpname = tempnam(sys_get_temp_dir(), "shimmie_ffmpeg_thumb");
|
||||
try {
|
||||
|
@ -335,18 +332,6 @@ class Media extends Extension
|
|||
$orig_size = self::video_size($inname);
|
||||
$scaled_size = get_thumbnail_size($orig_size[0], $orig_size[1], true);
|
||||
|
||||
$codec = "mjpeg";
|
||||
$quality = $config->get_int(ImageConfig::THUMB_QUALITY);
|
||||
if ($config->get_string(ImageConfig::THUMB_MIME) == MimeType::WEBP) {
|
||||
$codec = "libwebp";
|
||||
} else {
|
||||
// mjpeg quality ranges from 2-31, with 2 being the best quality.
|
||||
$quality = floor(31 - (31 * ($quality / 100)));
|
||||
if ($quality < 2) {
|
||||
$quality = 2;
|
||||
}
|
||||
}
|
||||
|
||||
$args = [
|
||||
escapeshellarg($ffmpeg),
|
||||
"-y", "-i", escapeshellarg($inname),
|
||||
|
@ -363,18 +348,15 @@ class Media extends Extension
|
|||
|
||||
if ((int)$ret === (int)0) {
|
||||
log_debug('media', "Generating thumbnail with command `$cmd`, returns $ret");
|
||||
|
||||
create_scaled_image($tmpname, $outname, $scaled_size, MimeType::PNG);
|
||||
|
||||
|
||||
return true;
|
||||
$ok = true;
|
||||
} else {
|
||||
log_error('media', "Generating thumbnail with command `$cmd`, returns $ret");
|
||||
return false;
|
||||
}
|
||||
} finally {
|
||||
@unlink($tmpname);
|
||||
}
|
||||
return $ok;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,5 @@
|
|||
<?php declare(strict_types=1);
|
||||
use function MicroHTML\INPUT;
|
||||
use function MicroHTML\TABLE;
|
||||
use function MicroHTML\TR;
|
||||
use function MicroHTML\TH;
|
||||
use function MicroHTML\TD;
|
||||
use function MicroHTML\SELECT;
|
||||
use function MicroHTML\OPTION;
|
||||
|
||||
class MediaTheme extends Themelet
|
||||
{
|
||||
|
|
|
@ -219,8 +219,6 @@ class MimeType
|
|||
|
||||
$output = self::OCTET_STREAM;
|
||||
|
||||
$type = false;
|
||||
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
try {
|
||||
$type = finfo_file($finfo, $file);
|
||||
|
|
|
@ -124,7 +124,7 @@ class PrivateImage extends Extension
|
|||
const SEARCH_REGEXP = "/^private:(yes|no|any)/";
|
||||
public function onSearchTermParse(SearchTermParseEvent $event)
|
||||
{
|
||||
global $user, $database, $user_config;
|
||||
global $user, $user_config;
|
||||
$show_private = $user_config->get_bool(PrivateImageConfig::USER_VIEW_DEFAULT);
|
||||
|
||||
$matches = [];
|
||||
|
@ -200,7 +200,7 @@ class PrivateImage extends Extension
|
|||
|
||||
public static function privatize_image($image_id)
|
||||
{
|
||||
global $database, $user;
|
||||
global $database;
|
||||
|
||||
$database->execute(
|
||||
"UPDATE images SET private = :true WHERE id = :id AND private = :false",
|
||||
|
@ -220,7 +220,7 @@ class PrivateImage extends Extension
|
|||
|
||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
||||
{
|
||||
global $user, $config;
|
||||
global $user;
|
||||
if ($user->can(Permissions::SET_PRIVATE_IMAGE) && $user->id==$event->image->owner_id) {
|
||||
$event->add_part($this->theme->get_image_admin_html($event->image));
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ class PrivateImage extends Extension
|
|||
|
||||
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event)
|
||||
{
|
||||
global $user, $config;
|
||||
global $user;
|
||||
|
||||
if ($user->can(Permissions::SET_PRIVATE_IMAGE)) {
|
||||
$event->add_action("bulk_privatize_image", "Make Private");
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
use function MicroHTML\BR;
|
||||
use function MicroHTML\BUTTON;
|
||||
use function MicroHTML\INPUT;
|
||||
|
||||
class PrivateImageTheme extends Themelet
|
||||
|
|
|
@ -171,12 +171,6 @@ class ResizeImage extends Extension
|
|||
if ($config->get_bool(ResizeConfig::GET_ENABLED) &&
|
||||
$user->can(Permissions::EDIT_FILES) &&
|
||||
$this->can_resize_mime($event->image->get_mime())) {
|
||||
$new_width = $event->image->width;
|
||||
$new_height = $event->image->height;
|
||||
|
||||
$max_height = 0;
|
||||
$max_width = 0;
|
||||
|
||||
if (isset($_GET['max_height'])) {
|
||||
$max_height = int_escape($_GET['max_height']);
|
||||
} else {
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
<?php declare(strict_types=1);
|
||||
use function MicroHTML\UL;
|
||||
use function MicroHTML\LI;
|
||||
use function MicroHTML\A;
|
||||
use function MicroHTML\INPUT;
|
||||
use function MicroHTML\FORM;
|
||||
use function MicroHTML\DIV;
|
||||
use function MicroHTML\LABEL;
|
||||
use function MicroHTML\P;
|
||||
use function MicroHTML\B;
|
||||
use function MicroHTML\SPAN;
|
||||
use function MicroHTML\rawHTML;
|
||||
|
||||
class SourceHistoryTheme extends Themelet
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
<?php declare(strict_types=1);
|
||||
use function MicroHTML\UL;
|
||||
use function MicroHTML\LI;
|
||||
use function MicroHTML\A;
|
||||
use function MicroHTML\INPUT;
|
||||
use function MicroHTML\FORM;
|
||||
use function MicroHTML\DIV;
|
||||
use function MicroHTML\LABEL;
|
||||
use function MicroHTML\P;
|
||||
use function MicroHTML\B;
|
||||
use function MicroHTML\SPAN;
|
||||
use function MicroHTML\rawHTML;
|
||||
|
||||
|
|
|
@ -92,8 +92,6 @@ class TranscodeImage extends Extension
|
|||
|
||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if ($this->get_version(TranscodeConfig::VERSION) < 1) {
|
||||
$old_extensions =[];
|
||||
foreach (array_values(self::INPUT_MIMES) as $mime) {
|
||||
|
|
|
@ -42,7 +42,7 @@ class TranscodeVideo extends Extension
|
|||
|
||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
||||
{
|
||||
global $user, $config;
|
||||
global $user;
|
||||
|
||||
if ($event->image->video===true && $user->can(Permissions::EDIT_FILES)) {
|
||||
$options = self::get_output_options($event->image->get_mime(), $event->image->video_codec);
|
||||
|
@ -54,8 +54,6 @@ class TranscodeVideo extends Extension
|
|||
|
||||
public function onSetupBuilding(SetupBuildingEvent $event)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$sb = new SetupBlock("Video Transcode");
|
||||
$sb->start_table();
|
||||
$sb->add_bool_option(TranscodeVideoConfig::ENABLED, "Allow transcoding images: ", true);
|
||||
|
@ -126,10 +124,9 @@ class TranscodeVideo extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function onBulkActionBlockBuilding(BulkActionBlockBuildingEvent $event)
|
||||
{
|
||||
global $user, $config;
|
||||
global $user;
|
||||
|
||||
if ($user->can(Permissions::EDIT_FILES)) {
|
||||
$event->add_action(
|
||||
|
|
|
@ -32,7 +32,6 @@ class DataUploadEvent extends Event
|
|||
public function __construct(string $tmpname, array $metadata)
|
||||
{
|
||||
parent::__construct();
|
||||
global $config;
|
||||
|
||||
assert(file_exists($tmpname));
|
||||
assert(is_string($metadata["filename"]));
|
||||
|
|
|
@ -227,7 +227,6 @@ class UploadTheme extends Themelet
|
|||
{
|
||||
global $config;
|
||||
|
||||
$upload_count = $config->get_int(UploadConfig::COUNT);
|
||||
$accept = $this->get_accept();
|
||||
|
||||
$max_size = $config->get_int(UploadConfig::SIZE);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
/** @var $user_config Config */
|
||||
/** @var Config */
|
||||
global $user_config;
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
<?php declare(strict_types=1);
|
||||
use function MicroHTML\BR;
|
||||
use function MicroHTML\BUTTON;
|
||||
use function MicroHTML\INPUT;
|
||||
|
||||
class UserConfigTheme extends Themelet
|
||||
{
|
||||
|
|
Reference in a new issue