formatting
This commit is contained in:
parent
56e247faf5
commit
a6bb15d859
108 changed files with 424 additions and 429 deletions
|
@ -313,9 +313,12 @@ class DatabaseConfig extends BaseConfig
|
|||
private $sub_column;
|
||||
private $sub_value;
|
||||
|
||||
public function __construct(Database $database, string $table_name = "config",
|
||||
string $sub_column = null, string $sub_value = null)
|
||||
{
|
||||
public function __construct(
|
||||
Database $database,
|
||||
string $table_name = "config",
|
||||
string $sub_column = null,
|
||||
string $sub_value = null
|
||||
) {
|
||||
$this->database = $database;
|
||||
$this->table_name = $table_name;
|
||||
$this->sub_value = $sub_value;
|
||||
|
@ -371,7 +374,8 @@ class DatabaseConfig extends BaseConfig
|
|||
$args["value"] =$this->values[$name];
|
||||
$this->database->Execute(
|
||||
"INSERT INTO {$this->table_name} (".join(",", $cols).") VALUES (".join(",", $params).")",
|
||||
$args);
|
||||
$args
|
||||
);
|
||||
}
|
||||
// rather than deleting and having some other request(s) do a thundering
|
||||
// herd of race-conditioned updates, just save the updated version once here
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
abstract class SCORE {
|
||||
abstract class SCORE
|
||||
{
|
||||
const AIPK = "SCORE_AIPK";
|
||||
const INET = "SCORE_INET";
|
||||
const BOOL_Y = "SCORE_BOOL_Y";
|
||||
|
|
|
@ -132,8 +132,10 @@ abstract class Extension
|
|||
public static function determine_enabled_extensions()
|
||||
{
|
||||
self::$enabled_extensions = [];
|
||||
foreach(array_merge(ExtensionInfo::get_core_extensions(),
|
||||
explode(",", EXTRA_EXTS)) as $key) {
|
||||
foreach (array_merge(
|
||||
ExtensionInfo::get_core_extensions(),
|
||||
explode(",", EXTRA_EXTS)
|
||||
) as $key) {
|
||||
$ext = ExtensionInfo::get_by_key($key);
|
||||
if ($ext===null) {
|
||||
continue;
|
||||
|
@ -296,7 +298,6 @@ abstract class ExtensionInfo
|
|||
|
||||
public static function load_all_extension_info()
|
||||
{
|
||||
|
||||
foreach (get_declared_classes() as $class) {
|
||||
$rclass = new ReflectionClass($class);
|
||||
if ($rclass->isAbstract()) {
|
||||
|
|
|
@ -835,8 +835,7 @@ class Image
|
|||
|
||||
if (isset($flexihashes[$opts])) {
|
||||
$flexihash = $flexihashes[$opts];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$flexihash = new Flexihash\Flexihash();
|
||||
foreach (explode(",", $opts) as $opt) {
|
||||
$parts = explode("=", $opt);
|
||||
|
|
|
@ -138,7 +138,6 @@ function get_thumbnail_size(int $orig_width, int $orig_height, bool $use_dpi_sca
|
|||
} else {
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_scaled_by_aspect_ratio(int $original_width, int $original_height, int $max_width, int $max_height) : array
|
||||
|
@ -167,7 +166,8 @@ function get_thumbnail_max_size_scaled(): array
|
|||
}
|
||||
|
||||
|
||||
function create_image_thumb(string $hash, string $type, string $engine = null) {
|
||||
function create_image_thumb(string $hash, string $type, string $engine = null)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$inname = warehouse_path(Image::IMAGE_DIR, $hash);
|
||||
|
@ -206,7 +206,7 @@ function format_milliseconds(int $input): string
|
|||
|
||||
$remainder = floor($input / 1000);
|
||||
|
||||
foreach (TIME_UNITS AS $unit=>$conversion) {
|
||||
foreach (TIME_UNITS as $unit=>$conversion) {
|
||||
$count = $remainder % $conversion;
|
||||
$remainder = floor($remainder / $conversion);
|
||||
if ($count==0&&$remainder<1) {
|
||||
|
|
|
@ -372,7 +372,6 @@ class Page
|
|||
header('Accept-Ranges: bytes');
|
||||
|
||||
if (isset($_SERVER['HTTP_RANGE'])) {
|
||||
|
||||
$c_start = $start;
|
||||
$c_end = $end;
|
||||
list(, $range) = explode('=', $_SERVER['HTTP_RANGE'], 2);
|
||||
|
@ -418,9 +417,10 @@ class Page
|
|||
// After flush, we can tell if the client browser has disconnected.
|
||||
// This means we can start sending a large file, and if we detect they disappeared
|
||||
// then we can just stop and not waste any more resources or bandwidth.
|
||||
if (connection_status() != 0)
|
||||
if (connection_status() != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
fclose($fp);
|
||||
}
|
||||
|
@ -580,7 +580,6 @@ class NavLink
|
|||
} else {
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function is_active(array $pages_matched, string $url = null): bool
|
||||
|
|
|
@ -66,5 +66,4 @@ abstract class Permissions
|
|||
public const VIEW_TRASH = "view_trash";
|
||||
|
||||
public const PERFORM_BULK_ACTIONS = "perform_bulk_actions";
|
||||
|
||||
}
|
|
@ -810,12 +810,16 @@ function get_class_from_file(string $file): string
|
|||
$class = $buffer = '';
|
||||
$i = 0;
|
||||
while (!$class) {
|
||||
if (feof($fp)) break;
|
||||
if (feof($fp)) {
|
||||
break;
|
||||
}
|
||||
|
||||
$buffer .= fread($fp, 512);
|
||||
$tokens = token_get_all($buffer);
|
||||
|
||||
if (strpos($buffer, '{') === false) continue;
|
||||
if (strpos($buffer, '{') === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (;$i<count($tokens);$i++) {
|
||||
if ($tokens[$i][0] === T_CLASS) {
|
||||
|
|
|
@ -108,21 +108,29 @@ function send_event(Event $event): void
|
|||
|
||||
// send_event() is performance sensitive, and with the number
|
||||
// of times tracer gets called the time starts to add up
|
||||
if ($tracer_enabled) $_tracer->begin(get_class($event));
|
||||
if ($tracer_enabled) {
|
||||
$_tracer->begin(get_class($event));
|
||||
}
|
||||
// SHIT: http://bugs.php.net/bug.php?id=35106
|
||||
$my_event_listeners = $_shm_event_listeners[get_class($event)];
|
||||
ksort($my_event_listeners);
|
||||
|
||||
foreach ($my_event_listeners as $listener) {
|
||||
if ($tracer_enabled) $_tracer->begin(get_class($listener));
|
||||
if ($tracer_enabled) {
|
||||
$_tracer->begin(get_class($listener));
|
||||
}
|
||||
if (method_exists($listener, $method_name)) {
|
||||
$listener->$method_name($event);
|
||||
}
|
||||
if ($tracer_enabled) $_tracer->end();
|
||||
if ($tracer_enabled) {
|
||||
$_tracer->end();
|
||||
}
|
||||
if ($event->stop_processing===true) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
$_shm_event_count++;
|
||||
if ($tracer_enabled) $_tracer->end();
|
||||
if ($tracer_enabled) {
|
||||
$_tracer->end();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ class PolyfillsTest extends \PHPUnit\Framework\TestCase
|
|||
|
||||
public function test_sanitize_path()
|
||||
{
|
||||
|
||||
$this->assertEquals(
|
||||
"one",
|
||||
sanitize_path("one")
|
||||
|
@ -88,7 +87,6 @@ class PolyfillsTest extends \PHPUnit\Framework\TestCase
|
|||
DIRECTORY_SEPARATOR."one".DIRECTORY_SEPARATOR."two".DIRECTORY_SEPARATOR,
|
||||
sanitize_path("\\/one/\\/\\/two\\/")
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function test_join_path()
|
||||
|
|
|
@ -3,7 +3,6 @@ require_once "core/util.php";
|
|||
|
||||
class UtilTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
|
||||
public function test_warehouse_path()
|
||||
{
|
||||
$hash = "7ac19c10d6859415";
|
||||
|
@ -62,6 +61,5 @@ class UtilTest extends \PHPUnit\Framework\TestCase
|
|||
join_path(DATA_DIR, "base", "7a", "c1", "9c", "10", "d6", "85", "94", "15", $hash),
|
||||
warehouse_path("base", $hash, false, 10)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ class AdminPageTheme extends Themelet
|
|||
$html .= "<input type='submit' value='Set Tag Case'>";
|
||||
$html .= "</form>\n";
|
||||
$page->add_block(new Block("Set Tag Case", $html));
|
||||
|
||||
}
|
||||
|
||||
public function dbq_html($terms)
|
||||
|
@ -75,6 +74,4 @@ class AdminPageTheme extends Themelet
|
|||
";
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -81,14 +81,14 @@ class BulkActions extends Extension
|
|||
}
|
||||
|
||||
if ($user->can(Permissions::BULK_EDIT_IMAGE_TAG)) {
|
||||
|
||||
$event->add_action(
|
||||
"bulk_tag",
|
||||
"Tag",
|
||||
"t",
|
||||
"",
|
||||
$this->theme->render_tag_input(),
|
||||
10);
|
||||
10
|
||||
);
|
||||
}
|
||||
|
||||
if ($user->can(Permissions::BULK_EDIT_IMAGE_SOURCE)) {
|
||||
|
|
|
@ -312,6 +312,5 @@ class CommentListTheme extends Themelet
|
|||
<p>Returns images that have been commented on by user 123. </p>
|
||||
</div>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,4 +28,3 @@ becomes a link to smile.gif
|
|||
<p>Images are stored in /ext/emoticons/default/, and you can
|
||||
add more emoticons by uploading images into that folder.";
|
||||
}
|
||||
|
||||
|
|
|
@ -18,4 +18,3 @@ class Emoticons extends FormatterExtension
|
|||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,12 @@
|
|||
|
||||
function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int
|
||||
{
|
||||
if($a->beta===true&&$b->beta===false)
|
||||
if ($a->beta===true&&$b->beta===false) {
|
||||
return 1;
|
||||
if($a->beta===false&&$b->beta===true)
|
||||
}
|
||||
if ($a->beta===false&&$b->beta===true) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return strcmp($a->name, $b->name);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,5 @@ class FavoritesTheme extends Themelet
|
|||
<p>Returns images that have been favorited by user 123. </p>
|
||||
</div>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class FlashFileHandler extends DataHandlerExtension
|
||||
{
|
||||
|
||||
public function onMediaCheckProperties(MediaCheckPropertiesEvent $event)
|
||||
{
|
||||
switch ($event->ext) {
|
||||
|
|
|
@ -12,7 +12,6 @@ class MP3FileHandler extends DataHandlerExtension
|
|||
break;
|
||||
}
|
||||
// TODO: Buff out audio format support, length scanning
|
||||
|
||||
}
|
||||
|
||||
protected function create_thumb(string $hash, string $type): bool
|
||||
|
|
|
@ -111,5 +111,4 @@ class PixelFileHandler extends DataHandlerExtension
|
|||
</form>
|
||||
", 20);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ use enshrined\svgSanitize\Sanitizer;
|
|||
|
||||
class SVGFileHandler extends DataHandlerExtension
|
||||
{
|
||||
|
||||
public function onMediaCheckProperties(MediaCheckPropertiesEvent $event)
|
||||
{
|
||||
switch ($event->ext) {
|
||||
|
|
|
@ -68,7 +68,6 @@ class VideoFileHandler extends DataHandlerExtension
|
|||
&& is_numeric($stream["height"]) && intval($stream["height"]) > ($event->height) ?? 0) {
|
||||
$event->height = intval($stream["height"]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$event->video = $video;
|
||||
|
@ -83,7 +82,6 @@ class VideoFileHandler extends DataHandlerExtension
|
|||
}
|
||||
}
|
||||
} catch (MediaException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ class HelpPageListBuildingEvent extends Event
|
|||
{
|
||||
$this->pages[$key] = $name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class HelpPageBuildingEvent extends Event
|
||||
|
@ -21,10 +20,9 @@ class HelpPageBuildingEvent extends Event
|
|||
$this->key = $key;
|
||||
}
|
||||
|
||||
function add_block(Block $block, int $position = 50)
|
||||
{
|
||||
if(!array_key_exists("$position",$this->blocks))
|
||||
public function add_block(Block $block, int $position = 50)
|
||||
{
|
||||
if (!array_key_exists("$position", $this->blocks)) {
|
||||
$this->blocks["$position"] = [];
|
||||
}
|
||||
$this->blocks["$position"][] = $block;
|
||||
|
@ -85,8 +83,8 @@ class HelpPages extends Extension
|
|||
$event->add_link("Help", make_link("help"));
|
||||
}
|
||||
|
||||
public function onHelpPageBuilding(HelpPageBuildingEvent $event) {
|
||||
|
||||
public function onHelpPageBuilding(HelpPageBuildingEvent $event)
|
||||
{
|
||||
if ($event->key=="licenses") {
|
||||
$block = new Block("Software Licenses");
|
||||
$block->body = "The code in Shimmie is contributed by numerous authors under multiple licenses. For reference, these licenses are listed below. The base software is in general licensed under the GPLv2 license.";
|
||||
|
@ -472,8 +470,6 @@ SOFTWARE.</pre>";
|
|||
|
||||
</pre>";
|
||||
$event->add_block($block);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class HelpPagesTheme extends Themelet
|
||||
{
|
||||
|
||||
public function display_list_page(array $pages)
|
||||
{
|
||||
global $page;
|
||||
|
@ -27,5 +26,4 @@ class HelpPagesTheme extends Themelet
|
|||
$page->set_title("Help - $title");
|
||||
$page->set_heading("Help - $title");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
abstract class ImageConfig {
|
||||
abstract class ImageConfig
|
||||
{
|
||||
const THUMB_ENGINE = 'thumb_engine';
|
||||
const THUMB_WIDTH = 'thumb_width';
|
||||
const THUMB_HEIGHT = 'thumb_height';
|
||||
|
@ -17,5 +18,4 @@ abstract class ImageConfig {
|
|||
|
||||
const COLLISION_MERGE = 'merge';
|
||||
const COLLISION_ERROR = 'error';
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ require_once "config.php";
|
|||
*/
|
||||
class ImageIO extends Extension
|
||||
{
|
||||
|
||||
const COLLISION_OPTIONS = ['Error'=>ImageConfig::COLLISION_ERROR, 'Merge'=>ImageConfig::COLLISION_MERGE];
|
||||
|
||||
const EXIF_READ_FUNCTION = "exif_read_data";
|
||||
|
@ -243,7 +242,6 @@ class ImageIO extends Extension
|
|||
} catch (MediaException $e) {
|
||||
log_warning("add_image", "Error while running update_image_media_properties: ".$e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
// }}} end add
|
||||
|
||||
|
|
|
@ -108,10 +108,13 @@ class Index extends Extension
|
|||
if (SPEED_HAX) {
|
||||
if (!$user->can("big_search")) {
|
||||
$fast_page_limit = 500;
|
||||
if ($total_pages > $fast_page_limit) $total_pages = $fast_page_limit;
|
||||
if ($total_pages > $fast_page_limit) {
|
||||
$total_pages = $fast_page_limit;
|
||||
}
|
||||
if ($page_number > $fast_page_limit) {
|
||||
$this->theme->display_error(
|
||||
404, "Search limit hit",
|
||||
404,
|
||||
"Search limit hit",
|
||||
"Only $fast_page_limit pages of results are searchable - " .
|
||||
"if you want to find older results, use more specific search terms"
|
||||
);
|
||||
|
|
|
@ -339,6 +339,5 @@ and of course start organising your images :-)
|
|||
</ul>
|
||||
</p>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ abstract class MediaConfig
|
|||
const CONVERT_PATH = "media_convert_path";
|
||||
const VERSION = "ext_media_version";
|
||||
const MEM_LIMIT = 'media_mem_limit';
|
||||
|
||||
}
|
||||
|
||||
abstract class MediaEngine
|
||||
|
@ -98,14 +97,19 @@ class MediaResizeEvent extends Event
|
|||
public $ignore_aspect_ratio;
|
||||
public $allow_upscale;
|
||||
|
||||
public function __construct(String $engine, string $input_path, string $input_type, string $output_path,
|
||||
int $target_width, int $target_height,
|
||||
public function __construct(
|
||||
String $engine,
|
||||
string $input_path,
|
||||
string $input_type,
|
||||
string $output_path,
|
||||
int $target_width,
|
||||
int $target_height,
|
||||
bool $ignore_aspect_ratio = false,
|
||||
string $target_format = null,
|
||||
int $target_quality = 80,
|
||||
bool $minimize = false,
|
||||
bool $allow_upscale = true)
|
||||
{
|
||||
bool $allow_upscale = true
|
||||
) {
|
||||
assert(in_array($engine, MediaEngine::ALL));
|
||||
$this->engine = $engine;
|
||||
$this->input_path = $input_path;
|
||||
|
@ -137,7 +141,6 @@ class MediaCheckPropertiesEvent extends Event
|
|||
$this->file_name = $file_name;
|
||||
$this->ext = $ext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,7 +189,7 @@ class Media extends Extension
|
|||
[0x52, 0x49, 0x46, 0x46, null, null, null, null, 0x57, 0x45, 0x42, 0x50, 0x56, 0x50, 0x38, 0x4C];
|
||||
|
||||
|
||||
static function imagick_available(): bool
|
||||
public static function imagick_available(): bool
|
||||
{
|
||||
return extension_loaded("imagick");
|
||||
}
|
||||
|
@ -286,7 +289,6 @@ class Media extends Extension
|
|||
$sb->end_table();
|
||||
|
||||
$event->panel->add_block($sb);
|
||||
|
||||
}
|
||||
|
||||
public function onAdminBuilding(AdminBuildingEvent $event)
|
||||
|
@ -368,7 +370,8 @@ class Media extends Extension
|
|||
$event->target_format,
|
||||
$event->ignore_aspect_ratio,
|
||||
$event->target_quality,
|
||||
$event->allow_upscale);
|
||||
$event->allow_upscale
|
||||
);
|
||||
|
||||
break;
|
||||
case MediaEngine::IMAGICK:
|
||||
|
@ -384,7 +387,8 @@ class Media extends Extension
|
|||
$event->ignore_aspect_ratio,
|
||||
$event->target_quality,
|
||||
$event->minimize,
|
||||
$event->allow_upscale);
|
||||
$event->allow_upscale
|
||||
);
|
||||
//}
|
||||
break;
|
||||
default:
|
||||
|
@ -473,7 +477,8 @@ class Media extends Extension
|
|||
"video" => $database->scoresql_value_prepare($mcpe->video),
|
||||
"audio" => $database->scoresql_value_prepare($mcpe->audio),
|
||||
"length" => $mcpe->length
|
||||
]);
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function get_images(String $ext = null)
|
||||
|
@ -729,7 +734,8 @@ class Media extends Extension
|
|||
// }
|
||||
// }
|
||||
|
||||
public static function is_lossless(string $filename, string $format) {
|
||||
public static function is_lossless(string $filename, string $format)
|
||||
{
|
||||
if (in_array($format, self::LOSSLESS_FORMATS)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -752,8 +758,7 @@ class Media extends Extension
|
|||
int $output_quality = 80,
|
||||
bool $minimize = false,
|
||||
bool $allow_upscale = true
|
||||
): void
|
||||
{
|
||||
): void {
|
||||
global $config;
|
||||
|
||||
$convert = $config->get_string(MediaConfig::CONVERT_PATH);
|
||||
|
@ -840,8 +845,7 @@ class Media extends Extension
|
|||
bool $ignore_aspect_ratio = false,
|
||||
int $output_quality = 80,
|
||||
bool $allow_upscale = true
|
||||
)
|
||||
{
|
||||
) {
|
||||
$width = $info[0];
|
||||
$height = $info[1];
|
||||
|
||||
|
@ -1040,7 +1044,6 @@ class Media extends Extension
|
|||
} else {
|
||||
throw new MediaException("Unable to open file for byte check: $file_name");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function is_animated_webp(String $image_filename): bool
|
||||
|
@ -1084,7 +1087,7 @@ class Media extends Extension
|
|||
* @param $format
|
||||
* @return string|null The format name that the media extension will recognize.
|
||||
*/
|
||||
static public function normalize_format(string $format, ?bool $lossless = null): ?string
|
||||
public static function normalize_format(string $format, ?bool $lossless = null): ?string
|
||||
{
|
||||
if ($format == "webp") {
|
||||
if ($lossless === true) {
|
||||
|
@ -1107,7 +1110,7 @@ class Media extends Extension
|
|||
* @param string $filename
|
||||
* @return array [width, height]
|
||||
*/
|
||||
static public function video_size(string $filename): array
|
||||
public static function video_size(string $filename): array
|
||||
{
|
||||
global $config;
|
||||
$ffmpeg = $config->get_string(MediaConfig::FFMPEG_PATH);
|
||||
|
@ -1132,5 +1135,4 @@ class Media extends Extension
|
|||
log_debug('Media', "Getting video size with `$cmd`, returns $output -- $size[0], $size[1]");
|
||||
return $size;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,6 +42,5 @@ class MediaTheme extends Themelet
|
|||
</div>
|
||||
<p>These search terms depend on the items being scanned for media content. Automatic scanning was implemented in mid-2019, so items uploaded before, or items uploaded on a system without ffmpeg, will require additional scanning before this will work.</p>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -269,7 +269,5 @@ class NotesTheme extends Themelet
|
|||
<p>Returns images with note(s) by user 123.</p>
|
||||
</div>
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -300,7 +300,6 @@ class NumericScore extends Extension
|
|||
$event->add_nav_link("numeric_score_day", new Link('popular_by_day'), "Popular by Day");
|
||||
$event->add_nav_link("numeric_score_month", new Link('popular_by_month'), "Popular by Month");
|
||||
$event->add_nav_link("numeric_score_year", new Link('popular_by_year'), "Popular by Year");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -132,6 +132,5 @@ class NumericScoreTheme extends Themelet
|
|||
<p>Sorts the search results by score, ascending.</p>
|
||||
</div>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,6 @@ class PoolAddPostsEvent extends Event
|
|||
$this->pool_id = $pool_id;
|
||||
$this->posts = $posts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PoolCreationEvent extends Event
|
||||
|
@ -58,7 +57,6 @@ class PoolCreationEvent extends Event
|
|||
$this->public = $public;
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Pools extends Extension
|
||||
|
@ -189,7 +187,8 @@ class Pools extends Extension
|
|||
$title,
|
||||
$user,
|
||||
$_POST["public"] === "Y",
|
||||
$_POST["description"]);
|
||||
$_POST["description"]
|
||||
);
|
||||
|
||||
send_event($event);
|
||||
$page->set_mode(PageMode::REDIRECT);
|
||||
|
@ -452,7 +451,8 @@ class Pools extends Extension
|
|||
|
||||
if ($this->have_permission($user, $pool)) {
|
||||
send_event(
|
||||
new PoolAddPostsEvent($pool_id,iterator_map_to_array("image_to_id", $event->items)));
|
||||
new PoolAddPostsEvent($pool_id, iterator_map_to_array("image_to_id", $event->items))
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "bulk_pool_add_new":
|
||||
|
|
|
@ -429,6 +429,5 @@ class PoolsTheme extends Themelet
|
|||
<p>Returns images in the "swimming pool" pool. Note that the underscore becomes a space</p>
|
||||
</div>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,8 +3,6 @@ class PostTitlesTheme extends Themelet
|
|||
{
|
||||
public function get_title_set_html(string $title, bool $can_set): string
|
||||
{
|
||||
|
||||
|
||||
$html = "
|
||||
<tr>
|
||||
<th>Title</th>
|
||||
|
|
|
@ -134,7 +134,6 @@ class Relationships extends Extension
|
|||
|
||||
if ($old_parent!=$event->parent_id) {
|
||||
if ($database->get_row("SELECT 1 FROM images WHERE id = :pid", ["pid" => $event->parent_id])) {
|
||||
|
||||
$result = $database->execute("UPDATE images SET parent_id = :pid WHERE id = :cid", ["pid" => $event->parent_id, "cid" => $event->child_id]);
|
||||
|
||||
if ($result->rowCount() > 0) {
|
||||
|
@ -184,9 +183,7 @@ class Relationships extends Extension
|
|||
|
||||
$database->execute(
|
||||
"UPDATE images SET has_children = EXISTS (SELECT 1 FROM images WHERE parent_id = :pid) WHERE id = :pid",
|
||||
["pid"=>$parent_id]);
|
||||
["pid"=>$parent_id]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -72,6 +72,5 @@ class RelationshipsTheme extends Themelet
|
|||
<p>Returns images that have no children.</p>
|
||||
</div>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,5 +19,4 @@ class RSS_CommentsInfo extends ExtensionInfo
|
|||
public $license = self::LICENSE_GPLV2;
|
||||
public $description = "Self explanatory";
|
||||
public $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::SQLITE]; // pgsql has no UNIX_TIMESTAMP
|
||||
|
||||
}
|
||||
|
|
|
@ -77,5 +77,4 @@ EOD;
|
|||
$event->add_nav_link("comment_rss", new Link('rss/comments'), "Feed");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ if ( // kill these glitched requests immediately
|
|||
|
||||
class Rule34 extends Extension
|
||||
{
|
||||
|
||||
public function onImageDeletion(ImageDeletionEvent $event)
|
||||
{
|
||||
global $database;
|
||||
|
|
|
@ -136,20 +136,33 @@ class SetupBlock extends Block
|
|||
|
||||
|
||||
|
||||
private function format_option(string $name, $html, ?string $label, bool $table_row) {
|
||||
private function format_option(string $name, $html, ?string $label, bool $table_row)
|
||||
{
|
||||
global $config;
|
||||
|
||||
if($table_row) $this->start_table_row();
|
||||
if($table_row) $this->start_table_header_cell();
|
||||
if ($table_row) {
|
||||
$this->start_table_row();
|
||||
}
|
||||
if ($table_row) {
|
||||
$this->start_table_header_cell();
|
||||
}
|
||||
if (!is_null($label)) {
|
||||
$this->body .= "<label for='{$name}'>{$label}</label>";
|
||||
}
|
||||
if($table_row) $this->end_table_header_cell();
|
||||
if ($table_row) {
|
||||
$this->end_table_header_cell();
|
||||
}
|
||||
|
||||
if($table_row) $this->start_table_cell();
|
||||
if ($table_row) {
|
||||
$this->start_table_cell();
|
||||
}
|
||||
$this->body .= $html;
|
||||
if($table_row) $this->end_table_cell();
|
||||
if($table_row) $this->end_table_row();
|
||||
if ($table_row) {
|
||||
$this->end_table_cell();
|
||||
}
|
||||
if ($table_row) {
|
||||
$this->end_table_row();
|
||||
}
|
||||
}
|
||||
|
||||
public function add_text_option(string $name, string $label=null, bool $table_row = false)
|
||||
|
@ -210,7 +223,6 @@ class SetupBlock extends Block
|
|||
$html .= "<input type='hidden' name='_type_$name' value='int'>\n";
|
||||
|
||||
$this->format_option($name, $html, $label, $table_row);
|
||||
|
||||
}
|
||||
|
||||
public function add_shorthand_int_option(string $name, string $label=null, bool $table_row = false)
|
||||
|
|
|
@ -20,6 +20,4 @@ class System extends Extension
|
|||
{
|
||||
$event->add_nav_link("system", new Link('system'), "System");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ class TagCategories extends Extension
|
|||
$count = $matches[3];
|
||||
|
||||
$types = $database->get_col(
|
||||
$database->scoreql_to_sql('SELECT SCORE_STRNORM(category) FROM image_tag_categories'));
|
||||
$database->scoreql_to_sql('SELECT SCORE_STRNORM(category) FROM image_tag_categories')
|
||||
);
|
||||
if (in_array($type, $types)) {
|
||||
$event->add_querylet(
|
||||
new Querylet($database->scoreql_to_sql("EXISTS (
|
||||
|
|
|
@ -113,6 +113,5 @@ class TagCategoriesTheme extends Themelet
|
|||
<p>Can use <, <=, >, >=, or =.</p>
|
||||
<p>Category name is not case sensitive, category must exist for search to work.</p>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ class TagListConfig
|
|||
{
|
||||
public const LENGTH = "tag_list_length";
|
||||
public const POPULAR_TAG_LIST_LENGTH = "popular_tag_list_length";
|
||||
public CONSt TAGS_MIN = "tags_min";
|
||||
public const TAGS_MIN = "tags_min";
|
||||
public const INFO_LINK = "info_link";
|
||||
public const IMAGE_TYPE = "tag_list_image_type";
|
||||
public const RELATED_SORT = "tag_list_related_sort";
|
||||
|
|
|
@ -137,15 +137,24 @@ class TagList extends Extension
|
|||
$sb->start_table();
|
||||
$sb->add_text_option(TagListConfig::INFO_LINK, "Tag info link", true);
|
||||
$sb->add_text_option(TagListConfig::OMIT_TAGS, "Omit tags", true);
|
||||
$sb->add_choice_option(TagListConfig::IMAGE_TYPE,
|
||||
$sb->add_choice_option(
|
||||
TagListConfig::IMAGE_TYPE,
|
||||
TagListConfig::TYPE_CHOICES,
|
||||
"Image tag list", true);
|
||||
$sb->add_choice_option(TagListConfig::RELATED_SORT,
|
||||
"Image tag list",
|
||||
true
|
||||
);
|
||||
$sb->add_choice_option(
|
||||
TagListConfig::RELATED_SORT,
|
||||
TagListConfig::SORT_CHOICES,
|
||||
"Sort related list by", true);
|
||||
$sb->add_choice_option(TagListConfig::POPULAR_SORT,
|
||||
"Sort related list by",
|
||||
true
|
||||
);
|
||||
$sb->add_choice_option(
|
||||
TagListConfig::POPULAR_SORT,
|
||||
TagListConfig::SORT_CHOICES,
|
||||
"Sort popular list by", true);
|
||||
"Sort popular list by",
|
||||
true
|
||||
);
|
||||
$sb->add_bool_option("tag_list_numbers", "Show tag counts", true);
|
||||
$sb->end_table();
|
||||
$event->panel->add_block($sb);
|
||||
|
@ -200,13 +209,11 @@ class TagList extends Extension
|
|||
} else {
|
||||
$where[] = " tag LIKE :$arg ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$results = $database->get_col("SELECT id FROM tags WHERE " . implode(" OR ", $where), $args);
|
||||
|
||||
$database->cache->set("tag_list_omitted_tags:" . $tags_config, $results, 600);
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
@ -538,7 +545,6 @@ class TagList extends Extension
|
|||
ORDER BY count DESC
|
||||
LIMIT :popular_tag_list_length
|
||||
";
|
||||
|
||||
} else {
|
||||
$query = "
|
||||
SELECT tag, count
|
||||
|
@ -643,14 +649,12 @@ class TagList extends Extension
|
|||
$related_tags = $database->get_all($query, $args);
|
||||
$database->cache->set("related_tags:$str_search", $related_tags, 60 * 60);
|
||||
}
|
||||
|
||||
}
|
||||
if ($related_tags === false) {
|
||||
return [];
|
||||
} else {
|
||||
return $related_tags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class Tips extends Extension
|
||||
{
|
||||
|
||||
public function onInitExt(InitExtEvent $event)
|
||||
{
|
||||
global $config, $database;
|
||||
|
|
|
@ -10,8 +10,13 @@ class TranscodeImageTheme extends Themelet
|
|||
global $config;
|
||||
|
||||
$html = "
|
||||
".make_form(make_link("transcode/{$image->id}"), 'POST', false, "",
|
||||
"return transcodeSubmit()")."
|
||||
".make_form(
|
||||
make_link("transcode/{$image->id}"),
|
||||
'POST',
|
||||
false,
|
||||
"",
|
||||
"return transcodeSubmit()"
|
||||
)."
|
||||
<input type='hidden' name='image_id' value='{$image->id}'>
|
||||
<input type='hidden' id='image_lossless' name='image_lossless' value='{$image->lossless}'>
|
||||
".$this->get_transcode_picker_html($options)."
|
||||
|
|
|
@ -7,7 +7,6 @@ abstract class TrashConfig
|
|||
|
||||
class Trash extends Extension
|
||||
{
|
||||
|
||||
public function get_priority(): int
|
||||
{
|
||||
// Needs to be early to intercept delete events
|
||||
|
@ -108,13 +107,14 @@ 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)
|
||||
{
|
||||
|
@ -163,7 +163,5 @@ class Trash extends Extension
|
|||
$database->Execute("CREATE INDEX images_trash_idx ON images(trash)");
|
||||
$config->set_int(TrashConfig::VERSION, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,6 @@ class Upgrade extends Extension
|
|||
log_info("upgrade", "Database at version 17");
|
||||
$config->set_bool("in_upgrade", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function get_priority(): int
|
||||
|
|
|
@ -242,7 +242,6 @@ class UserPageTheme extends Themelet
|
|||
$page->set_heading(html_escape($duser->name)."'s Page");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Stats", join("<br>", $stats), "main", 10));
|
||||
|
||||
}
|
||||
|
||||
public function build_options(User $duser, UserOptionsBuildingEvent $event)
|
||||
|
@ -337,7 +336,6 @@ class UserPageTheme extends Themelet
|
|||
foreach ($event->parts as $part) {
|
||||
$html .= $part;
|
||||
}
|
||||
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ class UserConfig extends Extension
|
|||
global $config, $database;
|
||||
|
||||
if ($config->get_int(self::VERSION, 0) < 1) {
|
||||
|
||||
log_info("upgrade", "Adding user config table");
|
||||
|
||||
$database->create_table("user_config", "
|
||||
|
|
|
@ -26,7 +26,8 @@ class DisplayingImageEvent extends Event
|
|||
return $this->image;
|
||||
}
|
||||
|
||||
public function set_title(String $title) {
|
||||
public function set_title(String $title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue