formatting
This commit is contained in:
parent
4dce3a2f07
commit
f5119b20a3
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
}
|
@ -118,21 +118,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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -90,14 +90,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>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,5 @@ class FavoritesTheme extends Themelet
|
||||
<p>Returns images that have been favorited by user 123. </p>
|
||||
</div>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
class FlashFileHandler extends DataHandlerExtension
|
||||
{
|
||||
|
||||
public function onMediaCheckProperties(MediaCheckPropertiesEvent $event)
|
||||
{
|
||||
switch ($event->ext) {
|
||||
|
@ -17,7 +17,6 @@ class MP3FileHandler extends DataHandlerExtension
|
||||
break;
|
||||
}
|
||||
// TODO: Buff out audio format support, length scanning
|
||||
|
||||
}
|
||||
|
||||
protected function create_thumb(string $hash, string $type): bool
|
||||
|
@ -117,5 +117,4 @@ class PixelFileHandler extends DataHandlerExtension
|
||||
</form>
|
||||
", 20);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ use enshrined\svgSanitize\Sanitizer;
|
||||
|
||||
class SVGFileHandler extends DataHandlerExtension
|
||||
{
|
||||
|
||||
public function onMediaCheckProperties(MediaCheckPropertiesEvent $event)
|
||||
{
|
||||
switch ($event->ext) {
|
||||
|
@ -82,7 +82,6 @@ class VideoFileHandler extends DataHandlerExtension
|
||||
&& is_numeric($stream["height"]) && intval($stream["height"]) > ($event->height) ?? 0) {
|
||||
$event->height = intval($stream["height"]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$event->video = $video;
|
||||
@ -97,7 +96,6 @@ class VideoFileHandler extends DataHandlerExtension
|
||||
}
|
||||
}
|
||||
} catch (MediaException $e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,6 @@ class HelpPageListBuildingEvent extends Event
|
||||
{
|
||||
$this->pages[$key] = $name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class HelpPageBuildingEvent extends Event
|
||||
@ -27,10 +26,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;
|
||||
@ -89,6 +87,4 @@ class HelpPages extends Extension
|
||||
global $user;
|
||||
$event->add_link("Help", make_link("help"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,7 +9,8 @@
|
||||
*/
|
||||
|
||||
|
||||
abstract class ImageConfig {
|
||||
abstract class ImageConfig
|
||||
{
|
||||
const THUMB_ENGINE = 'thumb_engine';
|
||||
const THUMB_WIDTH = 'thumb_width';
|
||||
const THUMB_HEIGHT = 'thumb_height';
|
||||
@ -26,7 +27,6 @@ abstract class ImageConfig {
|
||||
|
||||
const COLLISION_MERGE = 'merge';
|
||||
const COLLISION_ERROR = 'error';
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,7 +34,6 @@ abstract class ImageConfig {
|
||||
*/
|
||||
class ImageIO extends Extension
|
||||
{
|
||||
|
||||
const COLLISION_OPTIONS = ['Error'=>ImageConfig::COLLISION_ERROR, 'Merge'=>ImageConfig::COLLISION_MERGE];
|
||||
|
||||
const EXIF_READ_FUNCTION = "exif_read_data";
|
||||
@ -270,7 +269,6 @@ class ImageIO extends Extension
|
||||
} catch (MediaException $e) {
|
||||
log_warning("add_image", "Error while running update_image_media_properties: ".$e->getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
// }}} end add
|
||||
|
||||
|
@ -262,10 +262,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>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ abstract class MediaConfig
|
||||
const CONVERT_PATH = "media_convert_path";
|
||||
const VERSION = "ext_media_version";
|
||||
const MEM_LIMIT = 'media_mem_limit';
|
||||
|
||||
}
|
||||
|
||||
abstract class MediaEngine
|
||||
@ -105,14 +104,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;
|
||||
@ -144,7 +148,6 @@ class MediaCheckPropertiesEvent extends Event
|
||||
$this->file_name = $file_name;
|
||||
$this->ext = $ext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +196,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");
|
||||
}
|
||||
@ -293,7 +296,6 @@ class Media extends Extension
|
||||
$sb->end_table();
|
||||
|
||||
$event->panel->add_block($sb);
|
||||
|
||||
}
|
||||
|
||||
public function onAdminBuilding(AdminBuildingEvent $event)
|
||||
@ -375,7 +377,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:
|
||||
@ -391,7 +394,8 @@ class Media extends Extension
|
||||
$event->ignore_aspect_ratio,
|
||||
$event->target_quality,
|
||||
$event->minimize,
|
||||
$event->allow_upscale);
|
||||
$event->allow_upscale
|
||||
);
|
||||
//}
|
||||
break;
|
||||
default:
|
||||
@ -480,7 +484,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)
|
||||
@ -736,7 +741,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;
|
||||
}
|
||||
@ -759,8 +765,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);
|
||||
@ -847,8 +852,7 @@ class Media extends Extension
|
||||
bool $ignore_aspect_ratio = false,
|
||||
int $output_quality = 80,
|
||||
bool $allow_upscale = true
|
||||
)
|
||||
{
|
||||
) {
|
||||
$width = $info[0];
|
||||
$height = $info[1];
|
||||
|
||||
@ -1047,7 +1051,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
|
||||
@ -1091,7 +1094,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) {
|
||||
@ -1114,7 +1117,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);
|
||||
@ -1139,5 +1142,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>
|
||||
';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -310,7 +310,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>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,6 @@ class PoolAddPostsEvent extends Event
|
||||
$this->pool_id = $pool_id;
|
||||
$this->posts = $posts;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PoolCreationEvent extends Event
|
||||
@ -67,7 +66,6 @@ class PoolCreationEvent extends Event
|
||||
$this->public = $public;
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Pools extends Extension
|
||||
@ -198,7 +196,8 @@ class Pools extends Extension
|
||||
$title,
|
||||
$user,
|
||||
$_POST["public"] === "Y",
|
||||
$_POST["description"]);
|
||||
$_POST["description"]
|
||||
);
|
||||
|
||||
send_event($event);
|
||||
$page->set_mode(PageMode::REDIRECT);
|
||||
@ -461,7 +460,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>
|
||||
|
@ -25,7 +25,8 @@
|
||||
global $_shm_ratings;
|
||||
$_shm_ratings = [];
|
||||
|
||||
class ImageRating {
|
||||
class ImageRating
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@ -56,11 +57,11 @@ class ImageRating {
|
||||
$this->code = $code;
|
||||
$this->search_term = $search_term;
|
||||
$this->order = $order;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function clear_ratings() {
|
||||
function clear_ratings()
|
||||
{
|
||||
global $_shm_ratings;
|
||||
$keys = array_keys($_shm_ratings);
|
||||
foreach ($keys as $key) {
|
||||
@ -71,7 +72,8 @@ function clear_ratings() {
|
||||
}
|
||||
}
|
||||
|
||||
function add_rating(ImageRating $rating) {
|
||||
function add_rating(ImageRating $rating)
|
||||
{
|
||||
global $_shm_ratings;
|
||||
|
||||
if ($rating->code=="?"&&array_key_exists("?", $_shm_ratings)) {
|
||||
@ -110,7 +112,8 @@ class RatingSetEvent extends Event
|
||||
}
|
||||
}
|
||||
|
||||
abstract class RatingsConfig {
|
||||
abstract class RatingsConfig
|
||||
{
|
||||
const VERSION = "ext_ratings2_version";
|
||||
const USER_DEFAULTS = "ratings_default";
|
||||
}
|
||||
@ -160,7 +163,8 @@ class Ratings extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
public function onInitUserConfig(InitUserConfigEvent $event) {
|
||||
public function onInitUserConfig(InitUserConfigEvent $event)
|
||||
{
|
||||
$event->user_config->set_default_array(RatingsConfig::USER_DEFAULTS, self::get_user_class_privs($event->user));
|
||||
}
|
||||
|
||||
@ -169,9 +173,12 @@ class Ratings extends Extension
|
||||
global $user, $user_config;
|
||||
|
||||
$event->add__html(
|
||||
$this->theme->get_user_options($user,
|
||||
$this->theme->get_user_options(
|
||||
$user,
|
||||
self::get_user_default_ratings($user),
|
||||
self::get_user_class_privs($user)));
|
||||
self::get_user_class_privs($user)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function onSetupBuilding(SetupBuildingEvent $event)
|
||||
@ -455,7 +462,6 @@ class Ratings extends Extension
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function get_sorted_ratings(): array
|
||||
|
@ -64,7 +64,8 @@ class RatingsTheme extends Themelet
|
||||
// $page->add_block(new Block("List Controls", $html, "left"));
|
||||
// }
|
||||
|
||||
public function get_selection_rater_html(array $selected_options, bool $multiple = false, array $available_options = null) {
|
||||
public function get_selection_rater_html(array $selected_options, bool $multiple = false, array $available_options = null)
|
||||
{
|
||||
global $_shm_ratings;
|
||||
|
||||
$output = "<select name='rating".($multiple ? "[]' multiple='multiple'" : "' ")." >";
|
||||
|
@ -141,7 +141,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) {
|
||||
@ -191,9 +190,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>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -86,5 +86,4 @@ EOD;
|
||||
$event->add_nav_link("comment_rss", new Link('rss/comments'), "Feed");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -142,20 +142,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)
|
||||
@ -216,7 +229,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)
|
||||
|
@ -26,6 +26,4 @@ class System extends Extension
|
||||
{
|
||||
$event->add_nav_link("system", new Link('system'), "System");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -75,7 +75,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>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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)."
|
||||
|
@ -14,7 +14,6 @@ abstract class TrashConfig
|
||||
|
||||
class Trash extends Extension
|
||||
{
|
||||
|
||||
protected $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::PGSQL];
|
||||
|
||||
public function get_priority(): int
|
||||
@ -117,13 +116,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)
|
||||
{
|
||||
@ -172,7 +172,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>
|
||||
';
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,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;
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ class UserConfig extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
public function onInitUserConfig(InitUserConfigEvent $event) {
|
||||
public function onInitUserConfig(InitUserConfigEvent $event)
|
||||
{
|
||||
global $database, $user_config;
|
||||
|
||||
$user_config = new DatabaseConfig($database, "user_config", "user_id", $event->user->id);
|
||||
@ -44,7 +45,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", "
|
||||
|
@ -17,7 +17,8 @@ class DisplayingImageEvent extends Event
|
||||
return $this->image;
|
||||
}
|
||||
|
||||
public function set_title(String $title) {
|
||||
public function set_title(String $title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user