php7.1 all the things
This commit is contained in:
parent
189385ff61
commit
5ec3e89884
108 changed files with 400 additions and 1797 deletions
|
@ -23,7 +23,7 @@
|
|||
],
|
||||
|
||||
"require" : {
|
||||
"php" : ">=7.0",
|
||||
"php" : ">=7.1",
|
||||
"ext-pdo": "*",
|
||||
|
||||
"flexihash/flexihash" : "^2.0.0",
|
||||
|
|
|
@ -9,13 +9,8 @@ class BaseThemelet {
|
|||
|
||||
/**
|
||||
* Generic error message display
|
||||
*
|
||||
* @param int $code
|
||||
* @param string $title
|
||||
* @param string $message
|
||||
* @return void
|
||||
*/
|
||||
public function display_error(int $code, string $title, string $message) {
|
||||
public function display_error(int $code, string $title, string $message): void {
|
||||
global $page;
|
||||
$page->set_code($code);
|
||||
$page->set_title($title);
|
||||
|
@ -35,9 +30,8 @@ class BaseThemelet {
|
|||
|
||||
/**
|
||||
* A specific, common error message
|
||||
* @return void
|
||||
*/
|
||||
public function display_permission_denied() {
|
||||
public function display_permission_denied(): void {
|
||||
$this->display_error(403, "Permission Denied", "You do not have permission to access this page");
|
||||
}
|
||||
|
||||
|
@ -45,9 +39,6 @@ class BaseThemelet {
|
|||
/**
|
||||
* Generic thumbnail code; returns HTML rather than adding
|
||||
* a block since thumbs tend to go inside blocks...
|
||||
*
|
||||
* @param Image $image
|
||||
* @return string
|
||||
*/
|
||||
public function build_thumb_html(Image $image): string {
|
||||
global $config;
|
||||
|
|
|
@ -66,9 +66,6 @@ class Block {
|
|||
|
||||
/**
|
||||
* Get the HTML for this block.
|
||||
*
|
||||
* @param bool $hidable
|
||||
* @return string
|
||||
*/
|
||||
public function get_html(bool $hidable=false): string {
|
||||
$h = $this->header;
|
||||
|
|
|
@ -10,44 +10,30 @@ interface Config {
|
|||
* Save the list of name:value pairs to wherever they came from,
|
||||
* so that the next time a page is loaded it will use the new
|
||||
* configuration.
|
||||
*
|
||||
* @param null|string $name
|
||||
* @return void
|
||||
*/
|
||||
public function save(string $name=null);
|
||||
public function save(string $name=null): void;
|
||||
|
||||
//@{ /*--------------------------------- SET ------------------------------------------------------*/
|
||||
/**
|
||||
* Set a configuration option to a new value, regardless of what the value is at the moment.
|
||||
* @param string $name
|
||||
* @param null|int $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_int(string $name, $value);
|
||||
public function set_int(string $name, ?int $value): void;
|
||||
|
||||
/**
|
||||
* Set a configuration option to a new value, regardless of what the value is at the moment.
|
||||
* @param string $name
|
||||
* @param null|string $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_string(string $name, $value);
|
||||
public function set_string(string $name, ?string $value): void;
|
||||
|
||||
/**
|
||||
* Set a configuration option to a new value, regardless of what the value is at the moment.
|
||||
* @param string $name
|
||||
* @param null|bool|string $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_bool(string $name, $value);
|
||||
public function set_bool(string $name, $value): void;
|
||||
|
||||
/**
|
||||
* Set a configuration option to a new value, regardless of what the value is at the moment.
|
||||
* @param string $name
|
||||
* @param array $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_array(string $name, array $value);
|
||||
public function set_array(string $name, array $value): void;
|
||||
//@} /*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@{ /*-------------------------------- SET DEFAULT -----------------------------------------------*/
|
||||
|
@ -58,12 +44,8 @@ interface Config {
|
|||
* This has the advantage that the values will show up in the "advanced" setup
|
||||
* page where they can be modified, while calling get_* with a "default"
|
||||
* parameter won't show up.
|
||||
*
|
||||
* @param string $name
|
||||
* @param int $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_default_int(string $name, int $value);
|
||||
public function set_default_int(string $name, int $value): void;
|
||||
|
||||
/**
|
||||
* Set a configuration option to a new value, if there is no value currently.
|
||||
|
@ -72,12 +54,8 @@ interface Config {
|
|||
* This has the advantage that the values will show up in the "advanced" setup
|
||||
* page where they can be modified, while calling get_* with a "default"
|
||||
* parameter won't show up.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string|null $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_default_string(string $name, string $value);
|
||||
public function set_default_string(string $name, string $value): void;
|
||||
|
||||
/**
|
||||
* Set a configuration option to a new value, if there is no value currently.
|
||||
|
@ -86,12 +64,8 @@ interface Config {
|
|||
* This has the advantage that the values will show up in the "advanced" setup
|
||||
* page where they can be modified, while calling get_* with a "default"
|
||||
* parameter won't show up.
|
||||
*
|
||||
* @param string $name
|
||||
* @param bool $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_default_bool(string $name, bool $value);
|
||||
public function set_default_bool(string $name, bool $value): void;
|
||||
|
||||
/**
|
||||
* Set a configuration option to a new value, if there is no value currently.
|
||||
|
@ -100,46 +74,30 @@ interface Config {
|
|||
* This has the advantage that the values will show up in the "advanced" setup
|
||||
* page where they can be modified, while calling get_* with a "default"
|
||||
* parameter won't show up.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $value
|
||||
* @return void
|
||||
*/
|
||||
public function set_default_array(string $name, array $value);
|
||||
public function set_default_array(string $name, array $value): void;
|
||||
//@} /*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@{ /*--------------------------------- GET ------------------------------------------------------*/
|
||||
/**
|
||||
* Pick a value out of the table by name, cast to the appropriate data type.
|
||||
* @param string $name
|
||||
* @param null|int $default
|
||||
* @return int
|
||||
*/
|
||||
public function get_int(string $name, $default=null);
|
||||
public function get_int(string $name, ?int $default=null): ?int;
|
||||
|
||||
/**
|
||||
* Pick a value out of the table by name, cast to the appropriate data type.
|
||||
* @param string $name
|
||||
* @param null|string $default
|
||||
* @return string
|
||||
*/
|
||||
public function get_string(string $name, $default=null);
|
||||
public function get_string(string $name, ?string $default=null): ?string;
|
||||
|
||||
/**
|
||||
* Pick a value out of the table by name, cast to the appropriate data type.
|
||||
* @param string $name
|
||||
* @param null|bool|string $default
|
||||
* @return bool
|
||||
*/
|
||||
public function get_bool(string $name, $default=null);
|
||||
public function get_bool(string $name, ?bool $default=null): ?bool;
|
||||
|
||||
/**
|
||||
* Pick a value out of the table by name, cast to the appropriate data type.
|
||||
* @param string $name
|
||||
* @param array|null $default
|
||||
* @return array
|
||||
*/
|
||||
public function get_array(string $name, array $default=array());
|
||||
public function get_array(string $name, ?array $default=array()): ?array;
|
||||
//@} /*--------------------------------------------------------------------------------------------*/
|
||||
}
|
||||
|
||||
|
|
|
@ -206,10 +206,6 @@ class Database {
|
|||
|
||||
/**
|
||||
* Execute an SQL query and return a 2D array.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public function get_all(string $query, array $args=array()): array {
|
||||
$_start = microtime(true);
|
||||
|
@ -220,10 +216,6 @@ class Database {
|
|||
|
||||
/**
|
||||
* Execute an SQL query and return a single row.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return array|null
|
||||
*/
|
||||
public function get_row(string $query, array $args=array()) {
|
||||
$_start = microtime(true);
|
||||
|
@ -234,10 +226,6 @@ class Database {
|
|||
|
||||
/**
|
||||
* Execute an SQL query and return the first column of each row.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public function get_col(string $query, array $args=array()): array {
|
||||
$_start = microtime(true);
|
||||
|
@ -252,10 +240,6 @@ class Database {
|
|||
|
||||
/**
|
||||
* Execute an SQL query and return the the first row => the second row.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return array
|
||||
*/
|
||||
public function get_pairs(string $query, array $args=array()): array {
|
||||
$_start = microtime(true);
|
||||
|
@ -270,10 +254,6 @@ class Database {
|
|||
|
||||
/**
|
||||
* Execute an SQL query and return a single value.
|
||||
*
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function get_one(string $query, array $args=array()) {
|
||||
$_start = microtime(true);
|
||||
|
@ -284,9 +264,6 @@ class Database {
|
|||
|
||||
/**
|
||||
* Get the ID of the last inserted row.
|
||||
*
|
||||
* @param string|null $seq
|
||||
* @return int
|
||||
*/
|
||||
public function get_last_insert_id(string $seq): int {
|
||||
if($this->engine->name == "pgsql") {
|
||||
|
@ -299,11 +276,8 @@ class Database {
|
|||
|
||||
/**
|
||||
* Create a table from pseudo-SQL.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $data
|
||||
*/
|
||||
public function create_table(string $name, string $data) {
|
||||
public function create_table(string $name, string $data): void {
|
||||
if(is_null($this->engine)) { $this->connect_engine(); }
|
||||
$data = trim($data, ", \t\n\r\0\x0B"); // mysql doesn't like trailing commas
|
||||
$this->execute($this->engine->create_table_sql($name, $data));
|
||||
|
@ -312,7 +286,6 @@ class Database {
|
|||
/**
|
||||
* Returns the number of tables present in the current database.
|
||||
*
|
||||
* @return int
|
||||
* @throws SCoreException
|
||||
*/
|
||||
public function count_tables(): int {
|
||||
|
|
|
@ -75,9 +75,6 @@ class PageRequestEvent extends Event {
|
|||
* Test if the requested path matches a given pattern.
|
||||
*
|
||||
* If it matches, store the remaining path elements in $args
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function page_matches(string $name): bool {
|
||||
$parts = explode("/", $name);
|
||||
|
@ -98,11 +95,8 @@ class PageRequestEvent extends Event {
|
|||
|
||||
/**
|
||||
* Get the n th argument of the page request (if it exists.)
|
||||
*
|
||||
* @param int $n
|
||||
* @return string|null The argument (string) or NULL
|
||||
*/
|
||||
public function get_arg(int $n) {
|
||||
public function get_arg(int $n): ?string {
|
||||
$offset = $this->part_count + $n;
|
||||
if($offset >= 0 && $offset < $this->arg_count) {
|
||||
return $this->args[$offset];
|
||||
|
@ -114,7 +108,6 @@ class PageRequestEvent extends Event {
|
|||
|
||||
/**
|
||||
* Returns the number of arguments the page request has.
|
||||
* @return int
|
||||
*/
|
||||
public function count_args(): int {
|
||||
return int_escape($this->arg_count - $this->part_count);
|
||||
|
@ -166,7 +159,7 @@ class CommandEvent extends Event {
|
|||
public $args = array();
|
||||
|
||||
/**
|
||||
* @param string[] $args
|
||||
* #param string[] $args
|
||||
*/
|
||||
public function __construct(array $args) {
|
||||
global $user;
|
||||
|
|
|
@ -102,11 +102,8 @@ abstract class Extension {
|
|||
|
||||
/**
|
||||
* Find the theme object for a given extension.
|
||||
*
|
||||
* @param string $base
|
||||
* @return Themelet|null
|
||||
*/
|
||||
private function get_theme_object(string $base) {
|
||||
private function get_theme_object(string $base): ?Themelet {
|
||||
$custom = 'Custom'.$base.'Theme';
|
||||
$normal = $base.'Theme';
|
||||
|
||||
|
@ -124,7 +121,6 @@ abstract class Extension {
|
|||
/**
|
||||
* Override this to change the priority of the extension,
|
||||
* lower numbered ones will receive events first.
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority(): int {
|
||||
return 50;
|
||||
|
|
|
@ -14,9 +14,6 @@ class ImageAdditionEvent extends Event {
|
|||
* Inserts a new image into the database with its associated
|
||||
* information. Also calls TagSetEvent to set the tags for
|
||||
* this new image.
|
||||
*
|
||||
* @see TagSetEvent
|
||||
* @param Image $image The new image to add.
|
||||
*/
|
||||
public function __construct(Image $image) {
|
||||
$this->image = $image;
|
||||
|
@ -43,8 +40,6 @@ class ImageDeletionEvent extends Event {
|
|||
*
|
||||
* Used by things like tags and comments handlers to
|
||||
* clean out related rows in their tables.
|
||||
*
|
||||
* @param Image $image The image being deleted.
|
||||
*/
|
||||
public function __construct(Image $image) {
|
||||
$this->image = $image;
|
||||
|
@ -66,9 +61,6 @@ class ImageReplaceEvent extends Event {
|
|||
* Updates an existing ID in the database to use a new image
|
||||
* file, leaving the tags and such unchanged. Also removes
|
||||
* the old image file and thumbnail from the disk.
|
||||
*
|
||||
* @param int $id The ID of the image to replace.
|
||||
* @param Image $image The image object of the new image to use.
|
||||
*/
|
||||
public function __construct(int $id, Image $image) {
|
||||
$this->id = $id;
|
||||
|
@ -98,10 +90,6 @@ class ThumbnailGenerationEvent extends Event {
|
|||
|
||||
/**
|
||||
* Request a thumbnail be made for an image object
|
||||
*
|
||||
* @param string $hash The unique hash of the image
|
||||
* @param string $type The type of the image
|
||||
* @param bool $force Regenerate the thumbnail even if one already exists
|
||||
*/
|
||||
public function __construct(string $hash, string $type, bool $force=false) {
|
||||
$this->hash = $hash;
|
||||
|
@ -125,17 +113,13 @@ class ParseLinkTemplateEvent extends Event {
|
|||
/** @var \Image */
|
||||
public $image;
|
||||
|
||||
/**
|
||||
* @param string $link The formatted link
|
||||
* @param Image $image The image who's link is being parsed
|
||||
*/
|
||||
public function __construct(string $link, Image $image) {
|
||||
$this->link = $link;
|
||||
$this->original = $link;
|
||||
$this->image = $image;
|
||||
}
|
||||
|
||||
public function replace(string $needle, string $replace) {
|
||||
public function replace(string $needle, string $replace): void {
|
||||
$this->link = str_replace($needle, $replace, $this->link);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,10 +53,8 @@ class Image {
|
|||
/**
|
||||
* One will very rarely construct an image directly, more common
|
||||
* would be to use Image::by_id, Image::by_hash, etc.
|
||||
*
|
||||
* @param null|mixed[] $row
|
||||
*/
|
||||
public function __construct(array $row=null) {
|
||||
public function __construct(?array $row=null) {
|
||||
if(!is_null($row)) {
|
||||
foreach($row as $name => $value) {
|
||||
// some databases use table.name rather than name
|
||||
|
@ -95,11 +93,8 @@ class Image {
|
|||
/**
|
||||
* Search for an array of images
|
||||
*
|
||||
* @param int $start
|
||||
* @param int $limit
|
||||
* @param string[] $tags
|
||||
* @throws SCoreException
|
||||
* @return Image[]
|
||||
* #param string[] $tags
|
||||
* #return Image[]
|
||||
*/
|
||||
public static function find_images(int $start, int $limit, array $tags=array()): array {
|
||||
global $database, $user, $config;
|
||||
|
@ -209,8 +204,7 @@ class Image {
|
|||
/**
|
||||
* Count the number of image results for a given search
|
||||
*
|
||||
* @param string[] $tags
|
||||
* @return int
|
||||
* #param string[] $tags
|
||||
*/
|
||||
public static function count_images(array $tags=array()): int {
|
||||
global $database;
|
||||
|
@ -242,8 +236,7 @@ class Image {
|
|||
/**
|
||||
* Count the number of pages for a given search
|
||||
*
|
||||
* @param string[] $tags
|
||||
* @return float
|
||||
* #param string[] $tags
|
||||
*/
|
||||
public static function count_pages(array $tags=array()): float {
|
||||
global $config;
|
||||
|
@ -260,11 +253,9 @@ class Image {
|
|||
* Rather than simply $this_id + 1, one must take into account
|
||||
* deleted images and search queries
|
||||
*
|
||||
* @param string[] $tags
|
||||
* @param bool $next
|
||||
* @return Image
|
||||
* #param string[] $tags
|
||||
*/
|
||||
public function get_next(array $tags=array(), bool $next=true) {
|
||||
public function get_next(array $tags=array(), bool $next=true): ?Image {
|
||||
global $database;
|
||||
|
||||
if($next) {
|
||||
|
@ -298,26 +289,21 @@ class Image {
|
|||
/**
|
||||
* The reverse of get_next
|
||||
*
|
||||
* @param string[] $tags
|
||||
* @return Image
|
||||
* #param string[] $tags
|
||||
*/
|
||||
public function get_prev(array $tags=array()) {
|
||||
public function get_prev(array $tags=array()): ?Image {
|
||||
return $this->get_next($tags, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the User who owns this Image
|
||||
*
|
||||
* @return User
|
||||
*/
|
||||
public function get_owner() {
|
||||
public function get_owner(): User {
|
||||
return User::by_id($this->owner_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the image's owner.
|
||||
*
|
||||
* @param User $owner
|
||||
*/
|
||||
public function set_owner(User $owner) {
|
||||
global $database;
|
||||
|
@ -327,16 +313,16 @@ class Image {
|
|||
SET owner_id=:owner_id
|
||||
WHERE id=:id
|
||||
", array("owner_id"=>$owner->id, "id"=>$this->id));
|
||||
log_info("core_image", "Owner for Image #{$this->id} set to {$owner->name}", false, array("image_id" => $this->id));
|
||||
log_info("core_image", "Owner for Image #{$this->id} set to {$owner->name}", null, array("image_id" => $this->id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get this image's tags as an array.
|
||||
*
|
||||
* @return string[]
|
||||
* #return string[]
|
||||
*/
|
||||
public function get_tag_array() {
|
||||
public function get_tag_array(): array {
|
||||
global $database;
|
||||
if(!isset($this->tag_array)) {
|
||||
$this->tag_array = $database->get_col("
|
||||
|
@ -352,40 +338,29 @@ class Image {
|
|||
|
||||
/**
|
||||
* Get this image's tags as a string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_tag_list() {
|
||||
public function get_tag_list(): string {
|
||||
return Tag::implode($this->get_tag_array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the full size image
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_image_link() {
|
||||
public function get_image_link(): string {
|
||||
return $this->get_link('image_ilink', '_images/$hash/$id%20-%20$tags.$ext', 'image/$id.$ext');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the thumbnail
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_thumb_link() {
|
||||
public function get_thumb_link(): string {
|
||||
return $this->get_link('image_tlink', '_thumbs/$hash/thumb.jpg', 'thumb/$id.jpg');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check configured template for a link, then try nice URL, then plain URL
|
||||
*
|
||||
* @param string $template
|
||||
* @param string $nice
|
||||
* @param string $plain
|
||||
* @return string
|
||||
*/
|
||||
private function get_link($template, $nice, $plain) {
|
||||
private function get_link(string $template, string $nice, string $plain): string {
|
||||
global $config;
|
||||
|
||||
$image_link = $config->get_string($template);
|
||||
|
@ -407,10 +382,8 @@ class Image {
|
|||
/**
|
||||
* Get the tooltip for this image, formatted according to the
|
||||
* configured template.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_tooltip() {
|
||||
public function get_tooltip(): string {
|
||||
global $config;
|
||||
$tt = $this->parse_link_template($config->get_string('image_tip'), "no_escape");
|
||||
|
||||
|
@ -436,86 +409,67 @@ class Image {
|
|||
|
||||
/**
|
||||
* Figure out where the full size image is on disk.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_image_filename() {
|
||||
public function get_image_filename(): string {
|
||||
return warehouse_path("images", $this->hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out where the thumbnail is on disk.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_thumb_filename() {
|
||||
public function get_thumb_filename(): string {
|
||||
return warehouse_path("thumbs", $this->hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the original filename.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_filename() {
|
||||
public function get_filename(): string {
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the image's mime type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_mime_type() {
|
||||
public function get_mime_type(): string {
|
||||
return getMimeType($this->get_image_filename(), $this->get_ext());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the image's filename extension
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_ext() {
|
||||
public function get_ext(): string {
|
||||
return $this->ext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the image's source URL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_source() {
|
||||
public function get_source(): string {
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the image's source URL
|
||||
*
|
||||
* @param string $new_source
|
||||
*/
|
||||
public function set_source(string $new_source) {
|
||||
public function set_source(string $new_source): void {
|
||||
global $database;
|
||||
$old_source = $this->source;
|
||||
if(empty($new_source)) $new_source = null;
|
||||
if($new_source != $old_source) {
|
||||
$database->execute("UPDATE images SET source=:source WHERE id=:id", array("source"=>$new_source, "id"=>$this->id));
|
||||
log_info("core_image", "Source for Image #{$this->id} set to: $new_source (was $old_source)", false, array("image_id" => $this->id));
|
||||
log_info("core_image", "Source for Image #{$this->id} set to: $new_source (was $old_source)", null, array("image_id" => $this->id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the image is locked.
|
||||
* @return bool
|
||||
*/
|
||||
public function is_locked() {
|
||||
public function is_locked(): bool {
|
||||
return $this->locked;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $tf
|
||||
* @throws SCoreException
|
||||
*/
|
||||
public function set_locked($tf) {
|
||||
public function set_locked(bool $tf) {
|
||||
global $database;
|
||||
$ln = $tf ? "Y" : "N";
|
||||
$sln = $database->scoreql_to_sql('SCORE_BOOL_'.$ln);
|
||||
|
@ -523,7 +477,7 @@ class Image {
|
|||
$sln = str_replace('"', "", $sln);
|
||||
if(bool_escape($sln) !== $this->locked) {
|
||||
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id));
|
||||
log_info("core_image", "Setting Image #{$this->id} lock to: $ln", false, array("image_id" => $this->id));
|
||||
log_info("core_image", "Setting Image #{$this->id} lock to: $ln", null, array("image_id" => $this->id));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -532,7 +486,7 @@ class Image {
|
|||
*
|
||||
* Normally in preparation to set them to a new set.
|
||||
*/
|
||||
public function delete_tags_from_image() {
|
||||
public function delete_tags_from_image(): void {
|
||||
global $database;
|
||||
if($database->get_driver_name() == "mysql") {
|
||||
//mysql < 5.6 has terrible subquery optimization, using EXISTS / JOIN fixes this
|
||||
|
@ -633,10 +587,9 @@ class Image {
|
|||
/**
|
||||
* Send list of metatags to be parsed.
|
||||
*
|
||||
* @param string[] $metatags
|
||||
* @param int $image_id
|
||||
* #param string[] $metatags
|
||||
*/
|
||||
public function parse_metatags($metatags, $image_id) {
|
||||
public function parse_metatags(array $metatags, int $image_id): void {
|
||||
foreach($metatags as $tag) {
|
||||
$ttpe = new TagTermParseEvent($tag, $image_id, TRUE);
|
||||
send_event($ttpe);
|
||||
|
@ -646,11 +599,11 @@ class Image {
|
|||
/**
|
||||
* Delete this image from the database and disk
|
||||
*/
|
||||
public function delete() {
|
||||
public function delete(): void {
|
||||
global $database;
|
||||
$this->delete_tags_from_image();
|
||||
$database->execute("DELETE FROM images WHERE id=:id", array("id"=>$this->id));
|
||||
log_info("core_image", 'Deleted Image #'.$this->id.' ('.$this->hash.')', false, array("image_id" => $this->id));
|
||||
log_info("core_image", 'Deleted Image #'.$this->id.' ('.$this->hash.')', null, array("image_id" => $this->id));
|
||||
|
||||
unlink($this->get_image_filename());
|
||||
unlink($this->get_thumb_filename());
|
||||
|
@ -660,20 +613,13 @@ class Image {
|
|||
* This function removes an image (and thumbnail) from the DISK ONLY.
|
||||
* It DOES NOT remove anything from the database.
|
||||
*/
|
||||
public function remove_image_only() {
|
||||
log_info("core_image", 'Removed Image File ('.$this->hash.')', false, array("image_id" => $this->id));
|
||||
public function remove_image_only(): void {
|
||||
log_info("core_image", 'Removed Image File ('.$this->hash.')', null, array("image_id" => $this->id));
|
||||
@unlink($this->get_image_filename());
|
||||
@unlink($this->get_thumb_filename());
|
||||
}
|
||||
|
||||
/**
|
||||
* Someone please explain this
|
||||
*
|
||||
* @param string $tmpl
|
||||
* @param string $_escape
|
||||
* @return string
|
||||
*/
|
||||
public function parse_link_template($tmpl, $_escape="url_escape", $n=0) {
|
||||
public function parse_link_template(string $tmpl, string $_escape="url_escape", int $n=0): string {
|
||||
global $config;
|
||||
|
||||
// don't bother hitting the database if it won't be used...
|
||||
|
@ -746,8 +692,7 @@ class Image {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string[] $terms
|
||||
* @return \Querylet
|
||||
* #param string[] $terms
|
||||
*/
|
||||
private static function build_search_querylet(array $terms): Querylet {
|
||||
global $database;
|
||||
|
@ -888,8 +833,7 @@ class Image {
|
|||
* All the subqueries are executed every time for every row in the
|
||||
* images table. Yes, MySQL does suck this much.
|
||||
*
|
||||
* @param TagQuerylet[] $tag_querylets
|
||||
* @return Querylet
|
||||
* #param TagQuerylet[] $tag_querylets
|
||||
*/
|
||||
private static function build_accurate_search_querylet(array $tag_querylets): Querylet {
|
||||
global $database;
|
||||
|
@ -950,10 +894,9 @@ class Image {
|
|||
* this function exists because mysql is a turd, see the docs for
|
||||
* build_accurate_search_querylet() for a full explanation
|
||||
*
|
||||
* @param TagQuerylet[] $tag_querylets
|
||||
* @return Querylet
|
||||
* #param TagQuerylet[] $tag_querylets
|
||||
*/
|
||||
private static function build_ugly_search_querylet($tag_querylets) {
|
||||
private static function build_ugly_search_querylet(array $tag_querylets): Querylet {
|
||||
global $database;
|
||||
|
||||
$positive_tag_count = 0;
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
* Move a file from PHP's temporary area into shimmie's image storage
|
||||
* hierarchy, or throw an exception trying.
|
||||
*
|
||||
* @param DataUploadEvent $event
|
||||
* @throws UploadException
|
||||
*/
|
||||
function move_upload_to_archive(DataUploadEvent $event) {
|
||||
|
@ -24,10 +23,9 @@ function move_upload_to_archive(DataUploadEvent $event) {
|
|||
/**
|
||||
* Add a directory full of images
|
||||
*
|
||||
* @param $base string
|
||||
* @return array|string[]
|
||||
* #return string[]
|
||||
*/
|
||||
function add_dir($base) {
|
||||
function add_dir(string $base): array {
|
||||
$results = array();
|
||||
|
||||
foreach(list_files($base) as $full_path) {
|
||||
|
@ -49,13 +47,7 @@ function add_dir($base) {
|
|||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tmpname
|
||||
* @param string $filename
|
||||
* @param string $tags
|
||||
* @throws UploadException
|
||||
*/
|
||||
function add_image($tmpname, $filename, $tags) {
|
||||
function add_image(string $tmpname, string $filename, string $tags): void {
|
||||
assert(file_exists($tmpname));
|
||||
|
||||
$pathinfo = pathinfo($filename);
|
||||
|
@ -78,11 +70,9 @@ function add_image($tmpname, $filename, $tags) {
|
|||
* Given a full size pair of dimensions, return a pair scaled down to fit
|
||||
* into the configured thumbnail square, with ratio intact
|
||||
*
|
||||
* @param int $orig_width
|
||||
* @param int $orig_height
|
||||
* @return integer[]
|
||||
* #return int[]
|
||||
*/
|
||||
function get_thumbnail_size(int $orig_width, int $orig_height) {
|
||||
function get_thumbnail_size(int $orig_width, int $orig_height): array {
|
||||
global $config;
|
||||
|
||||
if($orig_width === 0) $orig_width = 192;
|
||||
|
|
|
@ -18,9 +18,7 @@ class Tag {
|
|||
/**
|
||||
* Turn a human-supplied string into a valid tag array.
|
||||
*
|
||||
* @param string $tags
|
||||
* @param bool $tagme add "tagme" if the string is empty
|
||||
* @return string[]
|
||||
* #return string[]
|
||||
*/
|
||||
public static function explode(string $tags, bool $tagme=true): array {
|
||||
global $database;
|
||||
|
|
|
@ -16,74 +16,29 @@ define("SCORE_LOG_NOTSET", 0);
|
|||
* When parsing a user request, a flash message should give info to the user
|
||||
* When taking action, a log event should be stored by the server
|
||||
* Quite often, both of these happen at once, hence log_*() having $flash
|
||||
*
|
||||
* $flash = null (default) - log to server only, no flash message
|
||||
* $flash = true - show the message to the user as well
|
||||
* $flash = "some string" - log the message, flash the string
|
||||
*
|
||||
* @param string $section
|
||||
* @param int $priority
|
||||
* @param string $message
|
||||
* @param bool|string $flash
|
||||
* @param array $args
|
||||
*/
|
||||
function log_msg(string $section, int $priority, string $message, $flash=false, $args=array()) {
|
||||
function log_msg(string $section, int $priority, string $message, ?string $flash=null, $args=array()) {
|
||||
send_event(new LogEvent($section, $priority, $message, $args));
|
||||
$threshold = defined("CLI_LOG_LEVEL") ? CLI_LOG_LEVEL : 0;
|
||||
|
||||
if((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && ($priority >= $threshold)) {
|
||||
print date("c")." $section: $message\n";
|
||||
}
|
||||
if($flash === true) {
|
||||
flash_message($message);
|
||||
}
|
||||
else if(is_string($flash)) {
|
||||
if(!is_null($flash)) {
|
||||
flash_message($flash);
|
||||
}
|
||||
}
|
||||
|
||||
// More shorthand ways of logging
|
||||
/**
|
||||
* @param string $section
|
||||
* @param string $message
|
||||
* @param bool|string $flash
|
||||
* @param array $args
|
||||
*/
|
||||
function log_debug( string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_DEBUG, $message, $flash, $args);}
|
||||
/**
|
||||
* @param string $section
|
||||
* @param string $message
|
||||
* @param bool|string $flash
|
||||
* @param array $args
|
||||
*/
|
||||
function log_info( string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_INFO, $message, $flash, $args);}
|
||||
/**
|
||||
* @param string $section
|
||||
* @param string $message
|
||||
* @param bool|string $flash
|
||||
* @param array $args
|
||||
*/
|
||||
function log_warning( string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_WARNING, $message, $flash, $args);}
|
||||
/**
|
||||
* @param string $section
|
||||
* @param string $message
|
||||
* @param bool|string $flash
|
||||
* @param array $args
|
||||
*/
|
||||
function log_error( string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_ERROR, $message, $flash, $args);}
|
||||
/**
|
||||
* @param string $section
|
||||
* @param string $message
|
||||
* @param bool|string $flash
|
||||
* @param array $args
|
||||
*/
|
||||
function log_critical(string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args);}
|
||||
function log_debug( string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_DEBUG, $message, $flash, $args);}
|
||||
function log_info( string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_INFO, $message, $flash, $args);}
|
||||
function log_warning( string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_WARNING, $message, $flash, $args);}
|
||||
function log_error( string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_ERROR, $message, $flash, $args);}
|
||||
function log_critical(string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args);}
|
||||
|
||||
|
||||
/**
|
||||
* Get a unique ID for this request, useful for grouping log messages.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_request_id(): string {
|
||||
static $request_id = null;
|
||||
|
|
|
@ -45,7 +45,6 @@ class Page {
|
|||
|
||||
/**
|
||||
* Set what this page should do; "page", "data", or "redirect".
|
||||
* @param string $mode
|
||||
*/
|
||||
public function set_mode(string $mode) {
|
||||
$this->mode = $mode;
|
||||
|
@ -53,7 +52,6 @@ class Page {
|
|||
|
||||
/**
|
||||
* Set the page's MIME type.
|
||||
* @param string $type
|
||||
*/
|
||||
public function set_type(string $type) {
|
||||
$this->type = $type;
|
||||
|
@ -73,7 +71,6 @@ class Page {
|
|||
|
||||
/**
|
||||
* Set the raw data to be sent.
|
||||
* @param string $data
|
||||
*/
|
||||
public function set_data(string $data) {
|
||||
$this->data = $data;
|
||||
|
@ -81,7 +78,6 @@ class Page {
|
|||
|
||||
/**
|
||||
* Set the recommended download filename.
|
||||
* @param string $filename
|
||||
*/
|
||||
public function set_filename(string $filename) {
|
||||
$this->filename = $filename;
|
||||
|
@ -99,7 +95,6 @@ class Page {
|
|||
/**
|
||||
* Set the URL to redirect to (remember to use make_link() if linking
|
||||
* to a page in the same site).
|
||||
* @param string $redirect
|
||||
*/
|
||||
public function set_redirect(string $redirect) {
|
||||
$this->redirect = $redirect;
|
||||
|
@ -140,40 +135,35 @@ class Page {
|
|||
|
||||
/**
|
||||
* Set the HTTP status code
|
||||
* @param int $code
|
||||
*/
|
||||
public function set_code(int $code) {
|
||||
public function set_code(int $code): void {
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
public function set_title(string $title) {
|
||||
public function set_title(string $title): void {
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
public function set_heading(string $heading) {
|
||||
public function set_heading(string $heading): void {
|
||||
$this->heading = $heading;
|
||||
}
|
||||
|
||||
public function set_subheading(string $subheading) {
|
||||
public function set_subheading(string $subheading): void {
|
||||
$this->subheading = $subheading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a line to the HTML head section.
|
||||
* @param string $line
|
||||
* @param int $position
|
||||
*/
|
||||
public function add_html_header(string $line, int $position=50) {
|
||||
public function add_html_header(string $line, int $position=50): void {
|
||||
while(isset($this->html_headers[$position])) $position++;
|
||||
$this->html_headers[$position] = $line;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a http header to be sent to the client.
|
||||
* @param string $line
|
||||
* @param int $position
|
||||
*/
|
||||
public function add_http_header(string $line, int $position=50) {
|
||||
public function add_http_header(string $line, int $position=50): void {
|
||||
while(isset($this->http_headers[$position])) $position++;
|
||||
$this->http_headers[$position] = $line;
|
||||
}
|
||||
|
@ -182,22 +172,13 @@ class Page {
|
|||
* The counterpart for get_cookie, this works like php's
|
||||
* setcookie method, but prepends the site-wide cookie prefix to
|
||||
* the $name argument before doing anything.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param int $time
|
||||
* @param string $path
|
||||
*/
|
||||
public function add_cookie(string $name, $value, $time, $path) {
|
||||
public function add_cookie(string $name, string $value, int $time, string $path): void {
|
||||
$full_name = COOKIE_PREFIX."_".$name;
|
||||
$this->cookies[] = array($full_name, $value, $time, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return string|null
|
||||
*/
|
||||
public function get_cookie(string $name) {
|
||||
public function get_cookie(string $name): ?string {
|
||||
$full_name = COOKIE_PREFIX."_".$name;
|
||||
if(isset($_COOKIE[$full_name])) {
|
||||
return $_COOKIE[$full_name];
|
||||
|
@ -209,7 +190,6 @@ class Page {
|
|||
|
||||
/**
|
||||
* Get all the HTML headers that are currently set and return as a string.
|
||||
* @return string
|
||||
*/
|
||||
public function get_all_html_headers(): string {
|
||||
$data = '';
|
||||
|
@ -223,13 +203,12 @@ class Page {
|
|||
/**
|
||||
* Removes all currently set HTML headers (Be careful..).
|
||||
*/
|
||||
public function delete_all_html_headers() {
|
||||
public function delete_all_html_headers(): void {
|
||||
$this->html_headers = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Block of data to the page.
|
||||
* @param Block $block
|
||||
*/
|
||||
public function add_block(Block $block) {
|
||||
$this->blocks[] = $block;
|
||||
|
@ -242,7 +221,7 @@ class Page {
|
|||
/**
|
||||
* Display the page according to the mode and data given.
|
||||
*/
|
||||
public function display() {
|
||||
public function display(): void {
|
||||
global $page, $user;
|
||||
|
||||
header("HTTP/1.0 {$this->code} Shimmie");
|
||||
|
@ -314,7 +293,7 @@ class Page {
|
|||
*
|
||||
* TODO: This should really be configurable somehow...
|
||||
*/
|
||||
public function add_auto_html_headers() {
|
||||
public function add_auto_html_headers(): void {
|
||||
global $config;
|
||||
|
||||
$data_href = get_base_href();
|
||||
|
|
|
@ -5,10 +5,6 @@
|
|||
|
||||
/**
|
||||
* Remove an item from an array
|
||||
*
|
||||
* @param array $array
|
||||
* @param mixed $to_remove
|
||||
* @return array
|
||||
*/
|
||||
function array_remove(array $array, $to_remove): array {
|
||||
$array = array_unique($array);
|
||||
|
@ -25,10 +21,6 @@ function array_remove(array $array, $to_remove): array {
|
|||
* Adds an item to an array.
|
||||
*
|
||||
* Also removes duplicate values from the array.
|
||||
*
|
||||
* @param array $array
|
||||
* @param mixed $element
|
||||
* @return array
|
||||
*/
|
||||
function array_add(array $array, $element): array {
|
||||
// Could we just use array_push() ?
|
||||
|
@ -40,9 +32,6 @@ function array_add(array $array, $element): array {
|
|||
|
||||
/**
|
||||
* Return the unique elements of an array, case insensitively
|
||||
*
|
||||
* @param array $array
|
||||
* @return array
|
||||
*/
|
||||
function array_iunique(array $array): array {
|
||||
$ok = array();
|
||||
|
@ -64,10 +53,6 @@ function array_iunique(array $array): array {
|
|||
* Figure out if an IP is in a specified range
|
||||
*
|
||||
* from http://uk.php.net/network
|
||||
*
|
||||
* @param string $IP
|
||||
* @param string $CIDR
|
||||
* @return bool
|
||||
*/
|
||||
function ip_in_range(string $IP, string $CIDR): bool {
|
||||
list ($net, $mask) = explode("/", $CIDR);
|
||||
|
@ -87,8 +72,6 @@ function ip_in_range(string $IP, string $CIDR): bool {
|
|||
*
|
||||
* from a patch by Christian Walde; only intended for use in the
|
||||
* "extension manager" extension, but it seems to fit better here
|
||||
*
|
||||
* @param string $f
|
||||
*/
|
||||
function deltree(string $f) {
|
||||
//Because Windows (I know, bad excuse)
|
||||
|
@ -132,9 +115,6 @@ function deltree(string $f) {
|
|||
* Copy an entire file hierarchy
|
||||
*
|
||||
* from a comment on http://uk.php.net/copy
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $target
|
||||
*/
|
||||
function full_copy(string $source, string $target) {
|
||||
if(is_dir($source)) {
|
||||
|
@ -163,10 +143,6 @@ function full_copy(string $source, string $target) {
|
|||
|
||||
/**
|
||||
* Return a list of all the regular files in a directory and subdirectories
|
||||
*
|
||||
* @param string $base
|
||||
* @param string $_sub_dir
|
||||
* @return array file list
|
||||
*/
|
||||
function list_files(string $base, string $_sub_dir=""): array {
|
||||
assert(is_dir($base));
|
||||
|
@ -208,10 +184,9 @@ function list_files(string $base, string $_sub_dir=""): array {
|
|||
if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/function.http-parse-headers.php#112917
|
||||
|
||||
/**
|
||||
* @param string $raw_headers
|
||||
* @return string[]
|
||||
* #return string[]
|
||||
*/
|
||||
function http_parse_headers ($raw_headers){
|
||||
function http_parse_headers (string $raw_headers): array {
|
||||
$headers = array(); // $headers = [];
|
||||
|
||||
foreach (explode("\n", $raw_headers) as $i => $h) {
|
||||
|
@ -236,17 +211,13 @@ if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/func
|
|||
/**
|
||||
* HTTP Headers can sometimes be lowercase which will cause issues.
|
||||
* In cases like these, we need to make sure to check for them if the camelcase version does not exist.
|
||||
*
|
||||
* @param array $headers
|
||||
* @param string $name
|
||||
* @return string|bool
|
||||
*/
|
||||
function findHeader(array $headers, string $name) {
|
||||
function findHeader(array $headers, string $name): ?string {
|
||||
if (!is_array($headers)) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
$header = false;
|
||||
$header = null;
|
||||
|
||||
if(array_key_exists($name, $headers)) {
|
||||
$header = $headers[$name];
|
||||
|
@ -296,10 +267,6 @@ const MIME_TYPE_MAP = [
|
|||
* The contents of this function are taken from the __getMimeType() function
|
||||
* from the "Amazon S3 PHP class" which is Copyright (c) 2008, Donovan Schönknecht
|
||||
* and released under the 'Simplified BSD License'.
|
||||
*
|
||||
* @param string $file File path
|
||||
* @param string $ext
|
||||
* @return string
|
||||
*/
|
||||
function getMimeType(string $file, string $ext=""): string {
|
||||
// Static extension lookup
|
||||
|
@ -332,24 +299,17 @@ function getMimeType(string $file, string $ext=""): string {
|
|||
return 'application/octet-stream';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mime_type
|
||||
* @return bool|string
|
||||
*/
|
||||
function getExtension(string $mime_type) {
|
||||
function getExtension(?string $mime_type): ?string {
|
||||
if(empty($mime_type)){
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
$ext = array_search($mime_type, MIME_TYPE_MAP);
|
||||
return ($ext ? $ext : false);
|
||||
return ($ext ? $ext : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like glob, with support for matching very long patterns with braces.
|
||||
*
|
||||
* @param string $pattern
|
||||
* @return array
|
||||
*/
|
||||
function zglob(string $pattern): array {
|
||||
$results = array();
|
||||
|
@ -375,8 +335,6 @@ function zglob(string $pattern): array {
|
|||
* function should return /gallery
|
||||
*
|
||||
* PHP really, really sucks.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_base_href(): string {
|
||||
if(defined("BASE_HREF")) return BASE_HREF;
|
||||
|
@ -413,31 +371,22 @@ function endsWith(string $haystack, string $needle): bool {
|
|||
|
||||
/**
|
||||
* Make some data safe for printing into HTML
|
||||
*
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
function html_escape($input): string {
|
||||
function html_escape(string $input): string {
|
||||
return htmlentities($input, ENT_QUOTES, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Unescape data that was made safe for printing into HTML
|
||||
*
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
function html_unescape($input): string {
|
||||
function html_unescape(string $input): string {
|
||||
return html_entity_decode($input, ENT_QUOTES, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure some data is safe to be used in integer context
|
||||
*
|
||||
* @param string $input
|
||||
* @return int
|
||||
*/
|
||||
function int_escape($input): int {
|
||||
function int_escape(string $input): int {
|
||||
/*
|
||||
Side note, Casting to an integer is FASTER than using intval.
|
||||
http://hakre.wordpress.com/2010/05/13/php-casting-vs-intval/
|
||||
|
@ -447,11 +396,8 @@ function int_escape($input): int {
|
|||
|
||||
/**
|
||||
* Make sure some data is safe to be used in URL context
|
||||
*
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
function url_escape($input): string {
|
||||
function url_escape(string $input): string {
|
||||
/*
|
||||
Shish: I have a feeling that these three lines are important, possibly for searching for tags with slashes in them like fate/stay_night
|
||||
green-ponies: indeed~
|
||||
|
@ -482,11 +428,8 @@ function url_escape($input): string {
|
|||
|
||||
/**
|
||||
* Make sure some data is safe to be used in SQL context
|
||||
*
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
function sql_escape($input): string {
|
||||
function sql_escape(string $input): string {
|
||||
global $database;
|
||||
return $database->escape($input);
|
||||
}
|
||||
|
@ -494,9 +437,6 @@ function sql_escape($input): string {
|
|||
|
||||
/**
|
||||
* Turn all manner of HTML / INI / JS / DB booleans into a PHP one
|
||||
*
|
||||
* @param mixed $input
|
||||
* @return boolean
|
||||
*/
|
||||
function bool_escape($input): bool {
|
||||
/*
|
||||
|
@ -530,11 +470,8 @@ function bool_escape($input): bool {
|
|||
/**
|
||||
* Some functions require a callback function for escaping,
|
||||
* but we might not want to alter the data
|
||||
*
|
||||
* @param string $input
|
||||
* @return string
|
||||
*/
|
||||
function no_escape($input) {
|
||||
function no_escape(string $input): string {
|
||||
return $input;
|
||||
}
|
||||
|
||||
|
@ -573,14 +510,8 @@ function xml_tag(string $name, array $attrs=array(), array $children=array()): s
|
|||
/**
|
||||
* Original PHP code by Chirp Internet: www.chirp.com.au
|
||||
* Please acknowledge use of this code by including this header.
|
||||
*
|
||||
* @param string $string input data
|
||||
* @param int $limit how long the string should be
|
||||
* @param string $break where to break the string
|
||||
* @param string $pad what to add to the end of the string after truncating
|
||||
* @return string
|
||||
*/
|
||||
function truncate($string, $limit, $break=" ", $pad="...") {
|
||||
function truncate(string $string, int $limit, string $break=" ", string $pad="..."): string{
|
||||
// return with no change if string is shorter than $limit
|
||||
if(strlen($string) <= $limit) return $string;
|
||||
|
||||
|
@ -596,9 +527,6 @@ function truncate($string, $limit, $break=" ", $pad="...") {
|
|||
|
||||
/**
|
||||
* Turn a human readable filesize into an integer, eg 1KB -> 1024
|
||||
*
|
||||
* @param string $limit
|
||||
* @return int
|
||||
*/
|
||||
function parse_shorthand_int(string $limit): int {
|
||||
if(preg_match('/^([\d\.]+)([gmk])?b?$/i', (string)$limit, $m)) {
|
||||
|
@ -622,9 +550,6 @@ function parse_shorthand_int(string $limit): int {
|
|||
|
||||
/**
|
||||
* Turn an integer into a human readable filesize, eg 1024 -> 1KB
|
||||
*
|
||||
* @param integer $int
|
||||
* @return string
|
||||
*/
|
||||
function to_shorthand_int(int $int): string {
|
||||
assert($int >= 0);
|
||||
|
@ -646,10 +571,6 @@ function to_shorthand_int(int $int): string {
|
|||
|
||||
/**
|
||||
* Turn a date into a time, a date, an "X minutes ago...", etc
|
||||
*
|
||||
* @param string $date
|
||||
* @param bool $html
|
||||
* @return string
|
||||
*/
|
||||
function autodate(string $date, bool $html=true): string {
|
||||
$cpu = date('c', strtotime($date));
|
||||
|
@ -659,9 +580,6 @@ function autodate(string $date, bool $html=true): string {
|
|||
|
||||
/**
|
||||
* Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss )
|
||||
*
|
||||
* @param string $dateTime
|
||||
* @return bool
|
||||
*/
|
||||
function isValidDateTime(string $dateTime): bool {
|
||||
if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) {
|
||||
|
@ -675,9 +593,6 @@ function isValidDateTime(string $dateTime): bool {
|
|||
|
||||
/**
|
||||
* Check if a given string is a valid date. ( Format: yyyy-mm-dd )
|
||||
*
|
||||
* @param string $date
|
||||
* @return bool
|
||||
*/
|
||||
function isValidDate(string $date): bool {
|
||||
if (preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $date, $matches)) {
|
||||
|
|
|
@ -57,11 +57,7 @@ function _set_event_listeners() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $event_listeners
|
||||
* @param string $path
|
||||
*/
|
||||
function _dump_event_listeners($event_listeners, $path) {
|
||||
function _dump_event_listeners(array $event_listeners, string $path): void {
|
||||
$p = "<"."?php\n";
|
||||
|
||||
foreach(get_declared_classes() as $class) {
|
||||
|
@ -86,10 +82,6 @@ function _dump_event_listeners($event_listeners, $path) {
|
|||
file_put_contents($path, $p);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ext_name Main class name (eg ImageIO as opposed to ImageIOTheme or ImageIOTest)
|
||||
* @return bool
|
||||
*/
|
||||
function ext_is_live(string $ext_name): bool {
|
||||
if (class_exists($ext_name)) {
|
||||
/** @var Extension $ext */
|
||||
|
@ -106,10 +98,8 @@ $_shm_event_count = 0;
|
|||
|
||||
/**
|
||||
* Send an event to all registered Extensions.
|
||||
*
|
||||
* @param Event $event
|
||||
*/
|
||||
function send_event(Event $event) {
|
||||
function send_event(Event $event): void {
|
||||
global $_shm_event_listeners, $_shm_event_count, $_shm_ctx;
|
||||
if(!isset($_shm_event_listeners[get_class($event)])) return;
|
||||
$method_name = "on".str_replace("Event", "", get_class($event));
|
||||
|
|
|
@ -40,7 +40,7 @@ _d("TIMEZONE", null); // string timezone
|
|||
_d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,handle_static,comment,tag_list,index,tag_edit,alias_editor"); // extensions to always enable
|
||||
_d("EXTRA_EXTS", ""); // string optional extra extensions
|
||||
_d("BASE_URL", null); // string force a specific base URL (default is auto-detect)
|
||||
_d("MIN_PHP_VERSION", '7.0');// string minimum supported PHP version
|
||||
_d("MIN_PHP_VERSION", '7.1');// string minimum supported PHP version
|
||||
_d("SLOW_PAGES", null); // float log pages which take more time than this
|
||||
_d("ENABLED_MODS", "imageboard");
|
||||
|
||||
|
|
|
@ -8,12 +8,8 @@
|
|||
* things like the nice URLs setting.
|
||||
*
|
||||
* eg make_link("post/list") becomes "/v2/index.php?q=post/list"
|
||||
*
|
||||
* @param null|string $page
|
||||
* @param null|string $query
|
||||
* @return string
|
||||
*/
|
||||
function make_link(string $page=null, string $query=null): string {
|
||||
function make_link(?string $page=null, ?string $query=null): string {
|
||||
global $config;
|
||||
|
||||
if(is_null($page)) $page = $config->get_string('main_page');
|
||||
|
@ -47,9 +43,6 @@ function make_link(string $page=null, string $query=null): string {
|
|||
|
||||
/**
|
||||
* Take the current URL and modify some parameters
|
||||
*
|
||||
* @param array $changes
|
||||
* @return string
|
||||
*/
|
||||
function modify_current_url(array $changes): string {
|
||||
return modify_url($_SERVER['QUERY_STRING'], $changes);
|
||||
|
@ -89,11 +82,8 @@ function modify_url(string $url, array $changes): string {
|
|||
|
||||
/**
|
||||
* Turn a relative link into an absolute one, including hostname
|
||||
*
|
||||
* @param string $link
|
||||
* @return string
|
||||
*/
|
||||
function make_http(string $link) {
|
||||
function make_http(string $link): string {
|
||||
if(strpos($link, "://") > 0) {
|
||||
return $link;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param mixed $row
|
||||
* @return User
|
||||
*/
|
||||
function _new_user($row) {
|
||||
function _new_user(array $row): User {
|
||||
return new User($row);
|
||||
}
|
||||
|
||||
|
@ -48,7 +43,6 @@ class User {
|
|||
* One will very rarely construct a user directly, more common
|
||||
* would be to use User::by_id, User::by_session, etc.
|
||||
*
|
||||
* @param mixed[] $row
|
||||
* @throws SCoreException
|
||||
*/
|
||||
public function __construct(array $row) {
|
||||
|
@ -183,8 +177,6 @@ class User {
|
|||
/**
|
||||
* Get a snippet of HTML which will render the user's avatar, be that
|
||||
* a local file, a remote file, a gravatar, a something else, etc.
|
||||
*
|
||||
* @return String of HTML
|
||||
*/
|
||||
public function get_avatar_html(): string {
|
||||
// FIXME: configurable
|
||||
|
@ -212,8 +204,6 @@ class User {
|
|||
* authtok = md5(sesskey, salt), presented to the user in web forms, to make sure that
|
||||
* the form was generated within the session. Salted and re-hashed so that
|
||||
* reading a web page from the user's cache doesn't give access to the session key
|
||||
*
|
||||
* @return string A string containing auth token (MD5sum)
|
||||
*/
|
||||
public function get_auth_token(): string {
|
||||
global $config;
|
||||
|
|
|
@ -41,8 +41,6 @@ class UserClass {
|
|||
/**
|
||||
* Determine if this class of user can perform an action or has ability.
|
||||
*
|
||||
* @param string $ability
|
||||
* @return bool
|
||||
* @throws SCoreException
|
||||
*/
|
||||
public function can(string $ability): bool {
|
||||
|
|
|
@ -5,21 +5,12 @@ require_once "vendor/shish/libcontext-php/context.php";
|
|||
* Misc *
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/**
|
||||
* @param string $file The filename
|
||||
* @return string
|
||||
*/
|
||||
function mtimefile(string $file): string {
|
||||
$data_href = get_base_href();
|
||||
$mtime = filemtime($file);
|
||||
return "$data_href/$file?$mtime";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current theme as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_theme(): string {
|
||||
global $config;
|
||||
$theme = $config->get_string("theme", "default");
|
||||
|
@ -27,11 +18,7 @@ function get_theme(): string {
|
|||
return $theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets contact link as mailto: or http:
|
||||
* @return string|null
|
||||
*/
|
||||
function contact_link() {
|
||||
function contact_link(): ?string {
|
||||
global $config;
|
||||
$text = $config->get_string('contact_link');
|
||||
if(is_null($text)) return null;
|
||||
|
@ -57,8 +44,6 @@ function contact_link() {
|
|||
|
||||
/**
|
||||
* Check if HTTPS is enabled for the server.
|
||||
*
|
||||
* @return bool True if HTTPS is enabled
|
||||
*/
|
||||
function is_https_enabled(): bool {
|
||||
return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off');
|
||||
|
@ -66,12 +51,8 @@ function is_https_enabled(): bool {
|
|||
|
||||
/**
|
||||
* Compare two Block objects, used to sort them before being displayed
|
||||
*
|
||||
* @param Block $a
|
||||
* @param Block $b
|
||||
* @return int
|
||||
*/
|
||||
function blockcmp(Block $a, Block $b) {
|
||||
function blockcmp(Block $a, Block $b): int {
|
||||
if($a->position == $b->position) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -82,8 +63,6 @@ function blockcmp(Block $a, Block $b) {
|
|||
|
||||
/**
|
||||
* Figure out PHP's internal memory limit
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function get_memory_limit(): int {
|
||||
global $config;
|
||||
|
@ -131,9 +110,6 @@ function get_memory_limit(): int {
|
|||
/**
|
||||
* Get the currently active IP, masked to make it not change when the last
|
||||
* octet or two change, for use in session cookies and such
|
||||
*
|
||||
* @param Config $config
|
||||
* @return string
|
||||
*/
|
||||
function get_session_ip(Config $config): string {
|
||||
$mask = $config->get_string("session_hash_mask", "255.255.0.0");
|
||||
|
@ -151,9 +127,6 @@ function get_session_ip(Config $config): string {
|
|||
* Generally one should flash a message in onPageRequest and log a message wherever
|
||||
* the action actually takes place (eg onWhateverElse) - but much of the time, actions
|
||||
* are taken from within onPageRequest...
|
||||
*
|
||||
* @param string $text
|
||||
* @param string $type
|
||||
*/
|
||||
function flash_message(string $text, string $type="info") {
|
||||
global $page;
|
||||
|
@ -168,9 +141,6 @@ function flash_message(string $text, string $type="info") {
|
|||
|
||||
/**
|
||||
* A shorthand way to send a TextFormattingEvent and get the results.
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
function format_text(string $string): string {
|
||||
$tfe = new TextFormattingEvent($string);
|
||||
|
@ -197,12 +167,7 @@ function data_path(string $filename): string {
|
|||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @param string $mfile
|
||||
* @return array|bool
|
||||
*/
|
||||
function transload(string $url, string $mfile) {
|
||||
function transload(string $url, string $mfile): ?array {
|
||||
global $config;
|
||||
|
||||
if($config->get_string("transload_engine") === "curl" && function_exists("curl_init")) {
|
||||
|
@ -241,7 +206,7 @@ function transload(string $url, string $mfile) {
|
|||
$fp_in = @fopen($url, "r");
|
||||
$fp_out = fopen($mfile, "w");
|
||||
if(!$fp_in || !$fp_out) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
$length = 0;
|
||||
while(!feof($fp_in) && $length <= $config->get_int('upload_size')) {
|
||||
|
@ -257,16 +222,13 @@ function transload(string $url, string $mfile) {
|
|||
return $headers;
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active contents of a .php file
|
||||
*
|
||||
* @param string $fname
|
||||
* @return string|null
|
||||
*/
|
||||
function manual_include(string $fname) {
|
||||
function manual_include(string $fname): ?string {
|
||||
static $included = array();
|
||||
|
||||
if(!file_exists($fname)) return null;
|
||||
|
@ -321,8 +283,6 @@ $_shm_load_start = microtime(true);
|
|||
/**
|
||||
* Collects some debug information (execution time, memory usage, queries, etc)
|
||||
* and formats it to stick in the footer of the page.
|
||||
*
|
||||
* @return string debug info to add to the page.
|
||||
*/
|
||||
function get_debug_info(): string {
|
||||
global $config, $_shm_event_count, $database, $_shm_load_start;
|
||||
|
@ -380,8 +340,7 @@ function score_assert_handler($file, $line, $code, $desc = null) {
|
|||
/** @privatesection */
|
||||
|
||||
function _version_check() {
|
||||
if(MIN_PHP_VERSION)
|
||||
{
|
||||
if(MIN_PHP_VERSION) {
|
||||
if(version_compare(phpversion(), MIN_PHP_VERSION, ">=") === FALSE) {
|
||||
print "
|
||||
Shimmie (SCore Engine) does not support versions of PHP lower than ".MIN_PHP_VERSION."
|
||||
|
@ -434,10 +393,6 @@ function _sanitise_environment() {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $_theme
|
||||
* @return string[]
|
||||
*/
|
||||
function _get_themelet_files(string $_theme): array {
|
||||
$base_themelets = array();
|
||||
if(file_exists('themes/'.$_theme.'/custompage.class.php')) $base_themelets[] = 'themes/'.$_theme.'/custompage.class.php';
|
||||
|
@ -453,7 +408,6 @@ function _get_themelet_files(string $_theme): array {
|
|||
|
||||
/**
|
||||
* Used to display fatal errors to the web user.
|
||||
* @param Exception $e
|
||||
*/
|
||||
function _fatal_error(Exception $e) {
|
||||
$version = VERSION;
|
||||
|
@ -485,9 +439,6 @@ function _fatal_error(Exception $e) {
|
|||
*
|
||||
* Necessary because various servers and various clients
|
||||
* think that / is special...
|
||||
*
|
||||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function _decaret(string $str): string {
|
||||
$out = "";
|
||||
|
@ -523,10 +474,7 @@ function _get_user(): User {
|
|||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
function _get_query() {
|
||||
function _get_query(): string {
|
||||
return (@$_POST["q"]?:@$_GET["q"])?:"/";
|
||||
}
|
||||
|
||||
|
@ -535,14 +483,14 @@ function _get_query() {
|
|||
* Code coverage *
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
function _start_coverage() {
|
||||
function _start_coverage(): void {
|
||||
if(function_exists("xdebug_start_code_coverage")) {
|
||||
#xdebug_start_code_coverage(XDEBUG_CC_UNUSED|XDEBUG_CC_DEAD_CODE);
|
||||
xdebug_start_code_coverage(XDEBUG_CC_UNUSED);
|
||||
}
|
||||
}
|
||||
|
||||
function _end_coverage() {
|
||||
function _end_coverage(): void {
|
||||
if(function_exists("xdebug_get_code_coverage")) {
|
||||
// Absolute path is necessary because working directory
|
||||
// inside register_shutdown_function is unpredictable.
|
||||
|
@ -564,10 +512,6 @@ function _end_coverage() {
|
|||
* and a link to ban that IP (if the user is allowed to ban IPs)
|
||||
*
|
||||
* FIXME: also check that IP ban ext is installed
|
||||
*
|
||||
* @param string $ip
|
||||
* @param string $ban_reason
|
||||
* @return string
|
||||
*/
|
||||
function show_ip(string $ip, string $ban_reason): string {
|
||||
global $user;
|
||||
|
@ -580,14 +524,6 @@ function show_ip(string $ip, string $ban_reason): string {
|
|||
|
||||
/**
|
||||
* Make a form tag with relevant auth token and stuff
|
||||
*
|
||||
* @param string $target
|
||||
* @param string $method
|
||||
* @param bool $multipart
|
||||
* @param string $form_id
|
||||
* @param string $onsubmit
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function make_form(string $target, string $method="POST", bool $multipart=False, string $form_id="", string $onsubmit=""): string {
|
||||
global $user;
|
||||
|
|
|
@ -132,7 +132,7 @@ class AdminPage extends Extension {
|
|||
|
||||
$images = Image::find_images(0, 1000000, Tag::explode($query));
|
||||
$count = count($images);
|
||||
log_warning("admin", "Mass-deleting $count images from $query", true);
|
||||
log_warning("admin", "Mass-deleting $count images from $query", "Mass deleted $count images");
|
||||
foreach($images as $image) {
|
||||
if($reason && class_exists("ImageBan")) {
|
||||
send_event(new AddImageHashBanEvent($image->hash, $reason));
|
||||
|
@ -150,14 +150,14 @@ class AdminPage extends Extension {
|
|||
$database->execute($database->scoreql_to_sql(
|
||||
"UPDATE tags SET tag=:tag1 WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag2)"
|
||||
), array("tag1" => $_POST['tag'], "tag2" => $_POST['tag']));
|
||||
log_info("admin", "Fixed the case of ".html_escape($_POST['tag']), true);
|
||||
log_info("admin", "Fixed the case of ".html_escape($_POST['tag']), "Fixed case");
|
||||
return true;
|
||||
}
|
||||
|
||||
private function lowercase_all_tags() {
|
||||
global $database;
|
||||
$database->execute("UPDATE tags SET tag=lower(tag)");
|
||||
log_warning("admin", "Set all tags to lowercase", true);
|
||||
log_warning("admin", "Set all tags to lowercase", "Set all tags to lowercase");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -171,7 +171,7 @@ class AdminPage extends Extension {
|
|||
)
|
||||
");
|
||||
$database->Execute("DELETE FROM tags WHERE count=0");
|
||||
log_warning("admin", "Re-counted tags", true);
|
||||
log_warning("admin", "Re-counted tags", "Re-counted tags");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ class AliasEditor extends Extension {
|
|||
if($user->can("manage_alias_list")) {
|
||||
if(isset($_POST['oldtag'])) {
|
||||
$database->execute("DELETE FROM aliases WHERE oldtag=:oldtag", array("oldtag" => $_POST['oldtag']));
|
||||
log_info("alias_editor", "Deleted alias for ".$_POST['oldtag'], true);
|
||||
log_info("alias_editor", "Deleted alias for ".$_POST['oldtag'], "Deleted alias");
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("alias/list"));
|
||||
|
@ -90,7 +90,7 @@ class AliasEditor extends Extension {
|
|||
$tmp = $_FILES['alias_file']['tmp_name'];
|
||||
$contents = file_get_contents($tmp);
|
||||
$this->add_alias_csv($database, $contents);
|
||||
log_info("alias_editor", "Imported aliases from file", true); # FIXME: how many?
|
||||
log_info("alias_editor", "Imported aliases from file", "Imported aliases"); # FIXME: how many?
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("alias/list"));
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ class AliasEditor extends Extension {
|
|||
}
|
||||
else {
|
||||
$database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", $pair);
|
||||
log_info("alias_editor", "Added alias for {$event->oldtag} -> {$event->newtag}", true);
|
||||
log_info("alias_editor", "Added alias for {$event->oldtag} -> {$event->newtag}", "Added alias");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,6 @@ class AliasEditor extends Extension {
|
|||
* Add alias *after* mass tag editing, else the MTE will
|
||||
* search for the images and be redirected to the alias,
|
||||
* missing out the images tagged with the old tag.
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority(): int {return 60;}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,8 @@ class AliasEditorTheme extends Themelet {
|
|||
* Show a page of aliases.
|
||||
*
|
||||
* Note: $can_manage = whether things like "add new alias" should be shown
|
||||
*
|
||||
* @param array $aliases An array of ($old_tag => $new_tag)
|
||||
* @param int $pageNumber
|
||||
* @param int $totalPages
|
||||
*/
|
||||
public function display_aliases($aliases, $pageNumber, $totalPages) {
|
||||
public function display_aliases(array $aliases, int $pageNumber, int $totalPages): void {
|
||||
global $page, $user;
|
||||
|
||||
$can_manage = $user->can("manage_alias_list");
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
class ArrowkeyNavigation extends Extension {
|
||||
/**
|
||||
* Adds functionality for post/view on images.
|
||||
*
|
||||
* @param DisplayingImageEvent $event
|
||||
*/
|
||||
public function onDisplayingImage(DisplayingImageEvent $event) {
|
||||
$prev_url = make_http(make_link("post/prev/".$event->image->id));
|
||||
|
@ -22,8 +20,6 @@ class ArrowkeyNavigation extends Extension {
|
|||
|
||||
/**
|
||||
* Adds functionality for post/list.
|
||||
*
|
||||
* @param PageRequestEvent $event
|
||||
*/
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
if($event->page_matches("post/list")) {
|
||||
|
@ -36,11 +32,8 @@ class ArrowkeyNavigation extends Extension {
|
|||
|
||||
/**
|
||||
* Adds the javascript to the page with the given urls.
|
||||
*
|
||||
* @param string $prev_url
|
||||
* @param string $next_url
|
||||
*/
|
||||
private function add_arrowkeys_code($prev_url, $next_url) {
|
||||
private function add_arrowkeys_code(string $prev_url, string $next_url) {
|
||||
global $page;
|
||||
|
||||
$page->add_html_header("<script type=\"text/javascript\">
|
||||
|
@ -57,11 +50,8 @@ class ArrowkeyNavigation extends Extension {
|
|||
|
||||
/**
|
||||
* Returns info about the current page number.
|
||||
*
|
||||
* @param PageRequestEvent $event
|
||||
* @return array
|
||||
*/
|
||||
private function get_list_pageinfo(PageRequestEvent $event) {
|
||||
private function get_list_pageinfo(PageRequestEvent $event): array {
|
||||
global $config, $database;
|
||||
|
||||
// get the amount of images per page
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
class ArtistsTheme extends Themelet {
|
||||
|
||||
/**
|
||||
* @param string $author
|
||||
* @return string
|
||||
*/
|
||||
public function get_author_editor_html(string $author) {
|
||||
public function get_author_editor_html(string $author): string {
|
||||
$h_author = html_escape($author);
|
||||
return "
|
||||
<tr>
|
||||
|
@ -18,12 +13,7 @@ class ArtistsTheme extends Themelet {
|
|||
";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $mode
|
||||
* @param null|int $artistID
|
||||
* @param bool $is_admin
|
||||
*/
|
||||
public function sidebar_options(string $mode, $artistID=NULL, $is_admin=FALSE) {
|
||||
public function sidebar_options(string $mode, ?int $artistID=NULL, $is_admin=FALSE): bool {
|
||||
global $page, $user;
|
||||
|
||||
$html = "";
|
||||
|
@ -387,13 +377,7 @@ class ArtistsTheme extends Themelet {
|
|||
$page->add_block(new Block("Artist Images", $artist_images, "main", 20));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $aliases
|
||||
* @param $userIsLogged
|
||||
* @param $userIsAdmin
|
||||
* @return string
|
||||
*/
|
||||
private function render_aliases($aliases, $userIsLogged, $userIsAdmin) {
|
||||
private function render_aliases(array $aliases, bool $userIsLogged, bool $userIsAdmin): string {
|
||||
$html = "";
|
||||
if(count($aliases) > 0) {
|
||||
$aliasViewLink = str_replace("_", " ", $aliases[0]['alias_name']); // no link anymore
|
||||
|
@ -433,13 +417,7 @@ class ArtistsTheme extends Themelet {
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $members
|
||||
* @param $userIsLogged
|
||||
* @param $userIsAdmin
|
||||
* @return string
|
||||
*/
|
||||
private function render_members($members, $userIsLogged, $userIsAdmin) {
|
||||
private function render_members(array $members, bool $userIsLogged, bool $userIsAdmin): string {
|
||||
$html = "";
|
||||
if(count($members) > 0) {
|
||||
$memberViewLink = str_replace("_", " ", $members[0]['name']); // no link anymore
|
||||
|
@ -477,13 +455,7 @@ class ArtistsTheme extends Themelet {
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $urls
|
||||
* @param $userIsLogged
|
||||
* @param $userIsAdmin
|
||||
* @return string
|
||||
*/
|
||||
private function render_urls($urls, $userIsLogged, $userIsAdmin) {
|
||||
private function render_urls(array $urls, bool $userIsLogged, bool $userIsAdmin): string {
|
||||
$html = "";
|
||||
if(count($urls) > 0) {
|
||||
$urlViewLink = "<a href='" . str_replace("_", " ", $urls[0]['url']) . "' target='_blank'>" . str_replace("_", " ", $urls[0]['url']) . "</a>";
|
||||
|
|
|
@ -88,11 +88,8 @@ xanax
|
|||
|
||||
/**
|
||||
* Throws if the comment contains banned words.
|
||||
* @param string $comment
|
||||
* @param CommentPostingException|SCoreException $ex
|
||||
* @throws CommentPostingException|SCoreException if the comment contains banned words.
|
||||
*/
|
||||
private function test_text($comment, $ex) {
|
||||
private function test_text(string $comment, Exception $ex): void {
|
||||
$comment = strtolower($comment);
|
||||
|
||||
foreach($this->get_words() as $word) {
|
||||
|
|
|
@ -54,16 +54,8 @@ class BulkAddCSV extends Extension {
|
|||
|
||||
/**
|
||||
* Generate the necessary DataUploadEvent for a given image and tags.
|
||||
*
|
||||
* @param string $tmpname
|
||||
* @param string $filename
|
||||
* @param string $tags
|
||||
* @param string $source
|
||||
* @param string $rating
|
||||
* @param string $thumbfile
|
||||
* @throws UploadException
|
||||
*/
|
||||
private function add_image($tmpname, $filename, $tags, $source, $rating, $thumbfile) {
|
||||
private function add_image(string $tmpname, string $filename, string $tags, string $source, string $rating, string $thumbfile) {
|
||||
assert(file_exists($tmpname));
|
||||
|
||||
$pathinfo = pathinfo($filename);
|
||||
|
|
|
@ -60,11 +60,7 @@ class Comment {
|
|||
$this->posted = $row['posted'];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return mixed
|
||||
*/
|
||||
public static function count_comments_by_user($user) {
|
||||
public static function count_comments_by_user(User $user): int {
|
||||
global $database;
|
||||
return $database->get_one("
|
||||
SELECT COUNT(*) AS count
|
||||
|
@ -73,10 +69,7 @@ class Comment {
|
|||
", array("owner_id"=>$user->id));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|User
|
||||
*/
|
||||
public function get_owner() {
|
||||
public function get_owner(): User {
|
||||
if(empty($this->owner)) $this->owner = User::by_id($this->owner_id);
|
||||
return $this->owner;
|
||||
}
|
||||
|
@ -326,9 +319,6 @@ class CommentList extends Extension {
|
|||
}
|
||||
|
||||
// page building {{{
|
||||
/**
|
||||
* @param int $current_page
|
||||
*/
|
||||
private function build_page(int $current_page) {
|
||||
global $database, $user;
|
||||
|
||||
|
@ -381,11 +371,9 @@ class CommentList extends Extension {
|
|||
|
||||
// get comments {{{
|
||||
/**
|
||||
* @param string $query
|
||||
* @param array $args
|
||||
* @return Comment[]
|
||||
* #return Comment[]
|
||||
*/
|
||||
private function get_generic_comments($query, $args) {
|
||||
private function get_generic_comments(string $query, array $args): array {
|
||||
global $database;
|
||||
$rows = $database->get_all($query, $args);
|
||||
$comments = array();
|
||||
|
@ -396,10 +384,9 @@ class CommentList extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $count
|
||||
* @return Comment[]
|
||||
* #return Comment[]
|
||||
*/
|
||||
private function get_recent_comments($count) {
|
||||
private function get_recent_comments(int $count): array {
|
||||
return $this->get_generic_comments("
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name, users.email as user_email, users.class as user_class,
|
||||
|
@ -414,12 +401,9 @@ class CommentList extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $user_id
|
||||
* @param int $count
|
||||
* @param int $offset
|
||||
* @return Comment[]
|
||||
* #return Comment[]
|
||||
*/
|
||||
private function get_user_comments(int $user_id, int $count, int $offset=0) {
|
||||
private function get_user_comments(int $user_id, int $count, int $offset=0): array {
|
||||
return $this->get_generic_comments("
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name, users.email as user_email, users.class as user_class,
|
||||
|
@ -435,10 +419,9 @@ class CommentList extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @return Comment[]
|
||||
* #return Comment[]
|
||||
*/
|
||||
private function get_comments(int $image_id) {
|
||||
private function get_comments(int $image_id): array {
|
||||
return $this->get_generic_comments("
|
||||
SELECT
|
||||
users.id as user_id, users.name as user_name, users.email as user_email, users.class as user_class,
|
||||
|
@ -454,10 +437,7 @@ class CommentList extends Extension {
|
|||
// }}}
|
||||
|
||||
// add / remove / edit comments {{{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function is_comment_limit_hit() {
|
||||
private function is_comment_limit_hit(): bool {
|
||||
global $config, $database;
|
||||
|
||||
// sqlite fails at intervals
|
||||
|
@ -479,10 +459,7 @@ class CommentList extends Extension {
|
|||
return (count($result) >= $max);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function hash_match() {
|
||||
private function hash_match(): bool {
|
||||
return ($_POST['hash'] == $this->get_hash());
|
||||
}
|
||||
|
||||
|
@ -492,18 +469,12 @@ class CommentList extends Extension {
|
|||
* many times.
|
||||
*
|
||||
* FIXME: assumes comments are posted via HTTP...
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_hash() {
|
||||
public static function get_hash(): string {
|
||||
return md5($_SERVER['REMOTE_ADDR'] . date("%Y%m%d"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
* @return bool
|
||||
*/
|
||||
private function is_spam_akismet(string $text) {
|
||||
private function is_spam_akismet(string $text): bool {
|
||||
global $config, $user;
|
||||
if(strlen($config->get_string('comment_wordpress_key')) > 0) {
|
||||
$comment = array(
|
||||
|
@ -541,14 +512,9 @@ class CommentList extends Extension {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @param int $comment
|
||||
* @return null
|
||||
*/
|
||||
private function is_dupe(int $image_id, string $comment) {
|
||||
private function is_dupe(int $image_id, string $comment): bool {
|
||||
global $database;
|
||||
return $database->get_row("
|
||||
return (bool)$database->get_row("
|
||||
SELECT *
|
||||
FROM comments
|
||||
WHERE image_id=:image_id AND comment=:comment
|
||||
|
@ -556,12 +522,6 @@ class CommentList extends Extension {
|
|||
}
|
||||
// do some checks
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @param User $user
|
||||
* @param string $comment
|
||||
* @throws CommentPostingException
|
||||
*/
|
||||
private function add_comment_wrapper(int $image_id, User $user, string $comment) {
|
||||
global $database, $page;
|
||||
|
||||
|
@ -582,15 +542,9 @@ class CommentList extends Extension {
|
|||
$snippet = substr($comment, 0, 100);
|
||||
$snippet = str_replace("\n", " ", $snippet);
|
||||
$snippet = str_replace("\r", " ", $snippet);
|
||||
log_info("comment", "Comment #$cid added to Image #$image_id: $snippet", false, array("image_id"=>$image_id, "comment_id"=>$cid));
|
||||
log_info("comment", "Comment #$cid added to Image #$image_id: $snippet", null, array("image_id"=>$image_id, "comment_id"=>$cid));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @param User $user
|
||||
* @param string $comment
|
||||
* @throws CommentPostingException
|
||||
*/
|
||||
private function comment_checks(int $image_id, User $user, string $comment) {
|
||||
global $config, $page;
|
||||
|
||||
|
|
|
@ -19,13 +19,8 @@ class CommentListTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* Display a page with a list of images, and for each image, the image's comments.
|
||||
*
|
||||
* @param array $images
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param bool $can_post
|
||||
*/
|
||||
public function display_comment_list($images, $page_number, $total_pages, $can_post) {
|
||||
public function display_comment_list(array $images, int $page_number, int $total_pages, bool $can_post) {
|
||||
global $config, $page, $user;
|
||||
|
||||
// aaaaaaargh php
|
||||
|
@ -125,9 +120,9 @@ class CommentListTheme extends Themelet {
|
|||
/**
|
||||
* Add some comments to the page, probably in a sidebar.
|
||||
*
|
||||
* @param \Comment[] $comments An array of Comment objects to be shown
|
||||
* #param Comment[] $comments An array of Comment objects to be shown
|
||||
*/
|
||||
public function display_recent_comments($comments) {
|
||||
public function display_recent_comments(array $comments) {
|
||||
global $page;
|
||||
$this->show_anon_id = false;
|
||||
$html = "";
|
||||
|
@ -142,11 +137,9 @@ class CommentListTheme extends Themelet {
|
|||
/**
|
||||
* Show comments for an image.
|
||||
*
|
||||
* @param Image $image
|
||||
* @param \Comment[] $comments
|
||||
* @param bool $postbox
|
||||
* #param Comment[] $comments
|
||||
*/
|
||||
public function display_image_comments(Image $image, $comments, $postbox) {
|
||||
public function display_image_comments(Image $image, array $comments, bool $postbox) {
|
||||
global $page;
|
||||
$this->show_anon_id = true;
|
||||
$html = "";
|
||||
|
@ -163,10 +156,9 @@ class CommentListTheme extends Themelet {
|
|||
/**
|
||||
* Show comments made by a user.
|
||||
*
|
||||
* @param \Comment[] $comments
|
||||
* @param \User $user
|
||||
* #param Comment[] $comments
|
||||
*/
|
||||
public function display_recent_user_comments($comments, User $user) {
|
||||
public function display_recent_user_comments(array $comments, User $user) {
|
||||
global $page;
|
||||
$html = "";
|
||||
foreach($comments as $comment) {
|
||||
|
@ -181,13 +173,7 @@ class CommentListTheme extends Themelet {
|
|||
$page->add_block(new Block("Comments", $html, "left", 70, "comment-list-user"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Comment[] $comments
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param \User $user
|
||||
*/
|
||||
public function display_all_user_comments($comments, $page_number, $total_pages, User $user) {
|
||||
public function display_all_user_comments(array $comments, int $page_number, int $total_pages, User $user) {
|
||||
global $page;
|
||||
|
||||
assert(is_numeric($page_number));
|
||||
|
@ -219,12 +205,7 @@ class CommentListTheme extends Themelet {
|
|||
$this->display_paginator($page, "comment/beta-search/{$user->name}", null, $page_number, $total_pages);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Comment $comment
|
||||
* @param bool $trim
|
||||
* @return string
|
||||
*/
|
||||
protected function comment_to_html(Comment $comment, $trim=false) {
|
||||
protected function comment_to_html(Comment $comment, bool $trim=false): string {
|
||||
global $config, $user;
|
||||
|
||||
$tfe = new TextFormattingEvent($comment->comment);
|
||||
|
@ -299,11 +280,7 @@ class CommentListTheme extends Themelet {
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @return string
|
||||
*/
|
||||
protected function build_postbox(int $image_id) {
|
||||
protected function build_postbox(int $image_id): string {
|
||||
global $config;
|
||||
|
||||
$i_image_id = int_escape($image_id);
|
||||
|
|
|
@ -39,7 +39,6 @@ class CronUploader extends Extension {
|
|||
/**
|
||||
* Checks if the cron upload page has been accessed
|
||||
* and initializes the upload.
|
||||
* @param PageRequestEvent $event
|
||||
*/
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $config, $user;
|
||||
|
@ -213,10 +212,8 @@ class CronUploader extends Extension {
|
|||
|
||||
/**
|
||||
* Returns amount of files & total size of dir.
|
||||
* @param string $path directory name to scan
|
||||
* @return multitype:number
|
||||
*/
|
||||
function scan_dir($path){
|
||||
function scan_dir(string $path): array{
|
||||
$ite=new RecursiveDirectoryIterator($path);
|
||||
|
||||
$bytestotal=0;
|
||||
|
@ -234,10 +231,8 @@ class CronUploader extends Extension {
|
|||
|
||||
/**
|
||||
* Uploads the image & handles everything
|
||||
* @param int $upload_count to upload a non-config amount of imgs
|
||||
* @return boolean returns true if the upload was successful
|
||||
*/
|
||||
public function process_upload($upload_count = 0) {
|
||||
public function process_upload(int $upload_count = 0): bool {
|
||||
global $config;
|
||||
set_time_limit(0);
|
||||
$this->set_dir();
|
||||
|
@ -375,11 +370,8 @@ class CronUploader extends Extension {
|
|||
|
||||
/**
|
||||
* Adds a message to the info being published at the end
|
||||
* @param $text string
|
||||
* @param $addon int Enter a value to modify an existing value (enter value number)
|
||||
* @return int
|
||||
*/
|
||||
private function add_upload_info($text, $addon = 0) {
|
||||
private function add_upload_info(string $text, int $addon = 0): int {
|
||||
$info = $this->upload_info;
|
||||
$time = "[" .date('Y-m-d H:i:s'). "]";
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ class DanbooruApi extends Extension {
|
|||
* - tags: any typical tag query. See Tag#parse_query for details.
|
||||
* - after_id: limit results to tags with an id number after after_id. Useful if you only want to refresh
|
||||
*
|
||||
* @return string
|
||||
* #return string
|
||||
*/
|
||||
private function api_find_tags() {
|
||||
global $database;
|
||||
|
@ -187,8 +187,7 @@ class DanbooruApi extends Extension {
|
|||
* - page: page number
|
||||
* - after_id: limit results to posts added after this id
|
||||
*
|
||||
* @return string
|
||||
* @throws SCoreException
|
||||
* #return string
|
||||
*/
|
||||
private function api_find_posts() {
|
||||
$results = array();
|
||||
|
|
|
@ -3,8 +3,6 @@
|
|||
class DowntimeTheme extends Themelet {
|
||||
/**
|
||||
* Show the admin that downtime mode is enabled
|
||||
*
|
||||
* @param Page $page
|
||||
*/
|
||||
public function display_notification(Page $page) {
|
||||
$page->add_block(new Block("Downtime",
|
||||
|
@ -13,8 +11,6 @@ class DowntimeTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* Display $message and exit
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function display_message(string $message) {
|
||||
global $config, $user, $page;
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
<?php
|
||||
class EmoticonListTheme extends Themelet {
|
||||
/**
|
||||
* @param array $list
|
||||
*/
|
||||
public function display_emotes(array $list) {
|
||||
global $page;
|
||||
$data_href = get_base_href();
|
||||
|
|
|
@ -12,11 +12,7 @@
|
|||
* extensions and read their documentation
|
||||
*/
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @return int
|
||||
*/
|
||||
function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b) {
|
||||
function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int {
|
||||
return strcmp($a->name, $b->name);
|
||||
}
|
||||
|
||||
|
@ -83,11 +79,7 @@ class ExtensionInfo {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fname
|
||||
* @return bool|null
|
||||
*/
|
||||
private function is_enabled(string $fname) {
|
||||
private function is_enabled(string $fname): ?bool {
|
||||
$core = explode(",", CORE_EXTS);
|
||||
$extra = explode(",", EXTRA_EXTS);
|
||||
|
||||
|
@ -105,7 +97,7 @@ class ExtManager extends Extension {
|
|||
if($event->get_arg(0) == "set" && $user->check_auth_token()) {
|
||||
if(is_writable("data/config")) {
|
||||
$this->set_things($_POST);
|
||||
log_warning("ext_manager", "Active extensions changed", true);
|
||||
log_warning("ext_manager", "Active extensions changed", "Active extensions changed");
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("ext_manager"));
|
||||
}
|
||||
|
@ -157,10 +149,9 @@ class ExtManager extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param bool $all
|
||||
* @return ExtensionInfo[]
|
||||
* #return ExtensionInfo[]
|
||||
*/
|
||||
private function get_extensions(bool $all) {
|
||||
private function get_extensions(bool $all): array {
|
||||
$extensions = array();
|
||||
if($all) {
|
||||
$exts = zglob("ext/*/main.php");
|
||||
|
@ -193,9 +184,9 @@ class ExtManager extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string[] $extras
|
||||
* #param string[] $extras
|
||||
*/
|
||||
private function write_config($extras) {
|
||||
private function write_config(array $extras) {
|
||||
file_put_contents(
|
||||
"data/config/extensions.conf.php",
|
||||
'<'.'?php'."\n".
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
class ExtManagerTheme extends Themelet {
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param ExtensionInfo[] $extensions
|
||||
* @param bool $editable
|
||||
* #param ExtensionInfo[] $extensions
|
||||
*/
|
||||
public function display_table(Page $page, array $extensions, bool $editable) {
|
||||
$h_en = $editable ? "<th>Enabled</th>" : "";
|
||||
|
|
|
@ -193,8 +193,7 @@ class Favorites extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @return string[]
|
||||
* #return string[]
|
||||
*/
|
||||
private function list_persons_who_have_favorited(Image $image): array {
|
||||
global $database;
|
||||
|
|
|
@ -1,21 +1,11 @@
|
|||
<?php
|
||||
|
||||
class FeaturedTheme extends Themelet {
|
||||
/**
|
||||
* Show $text on the $page.
|
||||
*
|
||||
* @param Page $page
|
||||
* @param Image $image
|
||||
*/
|
||||
public function display_featured(Page $page, Image $image) {
|
||||
public function display_featured(Page $page, Image $image): void {
|
||||
$page->add_block(new Block("Featured Image", $this->build_featured_html($image), "left", 3));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @return string
|
||||
*/
|
||||
public function get_buttons_html(int $image_id) {
|
||||
public function get_buttons_html(int $image_id): string {
|
||||
global $user;
|
||||
return "
|
||||
".make_form(make_link("featured_image/set"))."
|
||||
|
@ -26,12 +16,7 @@ class FeaturedTheme extends Themelet {
|
|||
";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @param null|string $query
|
||||
* @return string
|
||||
*/
|
||||
public function build_featured_html(Image $image, $query=null) {
|
||||
public function build_featured_html(Image $image, ?string $query=null): string {
|
||||
$i_id = int_escape($image->id);
|
||||
$h_view_link = make_link("post/view/$i_id", $query);
|
||||
$h_thumb_link = $image->get_thumb_link();
|
||||
|
|
|
@ -63,21 +63,12 @@ class SVGFileHandler extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ext
|
||||
* @return bool
|
||||
*/
|
||||
private function supported_ext($ext) {
|
||||
private function supported_ext(string $ext): bool {
|
||||
$exts = array("svg");
|
||||
return in_array(strtolower($ext), $exts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @param mixed[] $metadata
|
||||
* @return Image
|
||||
*/
|
||||
private function create_image_from_data($filename, $metadata) {
|
||||
private function create_image_from_data(string $filename, array $metadata): Image {
|
||||
$image = new Image();
|
||||
|
||||
$msp = new MiniSVGParser($filename);
|
||||
|
@ -94,11 +85,7 @@ class SVGFileHandler extends Extension {
|
|||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @return bool
|
||||
*/
|
||||
private function check_contents($file) {
|
||||
private function check_contents(string $file): bool {
|
||||
if(!file_exists($file)) return false;
|
||||
|
||||
$msp = new MiniSVGParser($file);
|
||||
|
@ -117,8 +104,7 @@ class MiniSVGParser {
|
|||
/** @var int */
|
||||
private $xml_depth=0;
|
||||
|
||||
/** @param string $file */
|
||||
function __construct($file) {
|
||||
function __construct(string $file) {
|
||||
$xml_parser = xml_parser_create();
|
||||
xml_set_element_handler($xml_parser, array($this, "startElement"), array($this, "endElement"));
|
||||
$this->valid = bool_escape(xml_parse($xml_parser, file_get_contents($file), true));
|
||||
|
|
|
@ -49,9 +49,6 @@ class VideoFileHandler extends DataHandlerExtension {
|
|||
|
||||
/**
|
||||
* Generate the Thumbnail image for particular file.
|
||||
*
|
||||
* @param string $hash
|
||||
* @return bool Returns true on successful thumbnail creation.
|
||||
*/
|
||||
protected function create_thumb(string $hash): bool {
|
||||
global $config;
|
||||
|
@ -114,21 +111,12 @@ class VideoFileHandler extends DataHandlerExtension {
|
|||
return $size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $ext
|
||||
* @return bool
|
||||
*/
|
||||
protected function supported_ext(string $ext): bool {
|
||||
$exts = array("flv", "mp4", "m4v", "ogv", "webm");
|
||||
return in_array(strtolower($ext), $exts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $filename
|
||||
* @param mixed[] $metadata
|
||||
* @return Image
|
||||
*/
|
||||
protected function create_image_from_data(string $filename, array $metadata) {
|
||||
protected function create_image_from_data(string $filename, array $metadata): Image {
|
||||
$image = new Image();
|
||||
|
||||
//NOTE: No need to set width/height as we don't use it.
|
||||
|
@ -163,10 +151,6 @@ class VideoFileHandler extends DataHandlerExtension {
|
|||
return $image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tmpname
|
||||
* @return bool
|
||||
*/
|
||||
protected function check_contents(string $tmpname): bool {
|
||||
$success = FALSE;
|
||||
if (file_exists($tmpname)) {
|
||||
|
|
|
@ -3,11 +3,8 @@ class ImageIOTheme extends Themelet {
|
|||
/**
|
||||
* Display a link to delete an image
|
||||
* (Added inline Javascript to confirm the deletion)
|
||||
*
|
||||
* @param $image_id integer The image to delete
|
||||
* @return string
|
||||
*/
|
||||
public function get_deleter_html(int $image_id) {
|
||||
public function get_deleter_html(int $image_id): string {
|
||||
$html = "
|
||||
".make_form(make_link("image/delete"))."
|
||||
<input type='hidden' name='image_id' value='$image_id' />
|
||||
|
@ -20,11 +17,8 @@ class ImageIOTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* Display link to replace the image
|
||||
*
|
||||
* @param $image_id integer The image to replace
|
||||
* @return string
|
||||
*/
|
||||
public function get_replace_html(int $image_id) {
|
||||
public function get_replace_html(int $image_id): string {
|
||||
$html = make_form(make_link("image/replace"))."
|
||||
<input type='hidden' name='image_id' value='$image_id' />
|
||||
<input type='submit' value='Replace' />
|
||||
|
|
|
@ -126,12 +126,7 @@ class ImageBan extends Extension {
|
|||
|
||||
// DB funness
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
* @param int $size
|
||||
* @return array
|
||||
*/
|
||||
public function get_image_hash_bans($page, $size=100) {
|
||||
public function get_image_hash_bans(int $page, int $size=100): array {
|
||||
global $database;
|
||||
|
||||
// FIXME: many
|
||||
|
|
|
@ -58,9 +58,8 @@ class ImageViewCounter extends Extension {
|
|||
|
||||
/**
|
||||
* Adds a view to the item if needed
|
||||
* @param int $imgid
|
||||
*/
|
||||
private function addview($imgid)
|
||||
private function addview(int $imgid)
|
||||
{
|
||||
global $database, $user;
|
||||
|
||||
|
@ -84,9 +83,8 @@ class ImageViewCounter extends Extension {
|
|||
|
||||
/**
|
||||
* Returns true if this IP hasn't recently viewed this image
|
||||
* @param int $imgid
|
||||
*/
|
||||
private function can_add_view($imgid)
|
||||
private function can_add_view(int $imgid)
|
||||
{
|
||||
global $database;
|
||||
|
||||
|
@ -111,9 +109,8 @@ class ImageViewCounter extends Extension {
|
|||
|
||||
/**
|
||||
* Returns the int of the view count from the given image id
|
||||
* @param int $imgid - if not set or 0, return views of all images
|
||||
*/
|
||||
private function get_view_count($imgid = 0)
|
||||
private function get_view_count(int $imgid = 0)
|
||||
{
|
||||
global $database;
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ class PostListBuildingEvent extends Event {
|
|||
public $parts = array();
|
||||
|
||||
/**
|
||||
* @param string[] $search
|
||||
* #param string[] $search
|
||||
*/
|
||||
public function __construct(array $search) {
|
||||
$this->search_terms = $search;
|
||||
|
|
|
@ -3,12 +3,7 @@
|
|||
class IndexTheme extends Themelet {
|
||||
protected $page_number, $total_pages, $search_terms;
|
||||
|
||||
/**
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param string[] $search_terms
|
||||
*/
|
||||
public function set_page($page_number, $total_pages, $search_terms) {
|
||||
public function set_page(int $page_number, int $total_pages, array $search_terms) {
|
||||
$this->page_number = $page_number;
|
||||
$this->total_pages = $total_pages;
|
||||
$this->search_terms = $search_terms;
|
||||
|
@ -33,10 +28,9 @@ and of course start organising your images :-)
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image[] $images
|
||||
* #param Image[] $images
|
||||
*/
|
||||
public function display_page(Page $page, $images) {
|
||||
public function display_page(Page $page, array $images) {
|
||||
$this->display_page_header($page, $images);
|
||||
|
||||
$nav = $this->build_navigation($this->page_number, $this->total_pages, $this->search_terms);
|
||||
|
@ -51,21 +45,18 @@ and of course start organising your images :-)
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string[] $parts
|
||||
* #param string[] $parts
|
||||
*/
|
||||
public function display_admin_block($parts) {
|
||||
public function display_admin_block(array $parts) {
|
||||
global $page;
|
||||
$page->add_block(new Block("List Controls", join("<br>", $parts), "left", 50));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param string[] $search_terms
|
||||
* @return string
|
||||
* #param string[] $search_terms
|
||||
*/
|
||||
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
||||
protected function build_navigation(int $page_number, int $total_pages, array $search_terms): string {
|
||||
$prev = $page_number - 1;
|
||||
$next = $page_number + 1;
|
||||
|
||||
|
@ -91,11 +82,9 @@ and of course start organising your images :-)
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Image[] $images
|
||||
* @param string $query
|
||||
* @return string
|
||||
* #param Image[] $images
|
||||
*/
|
||||
protected function build_table($images, $query) {
|
||||
protected function build_table(array $images, string $query): string {
|
||||
$h_query = html_escape($query);
|
||||
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
||||
foreach($images as $image) {
|
||||
|
@ -106,10 +95,9 @@ and of course start organising your images :-)
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image[] $images
|
||||
* #param Image[] $images
|
||||
*/
|
||||
protected function display_page_header(Page $page, $images) {
|
||||
protected function display_page_header(Page $page, array $images) {
|
||||
global $config;
|
||||
|
||||
if (count($this->search_terms) == 0) {
|
||||
|
@ -130,10 +118,9 @@ and of course start organising your images :-)
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image[] $images
|
||||
* #param Image[] $images
|
||||
*/
|
||||
protected function display_page_images(Page $page, $images) {
|
||||
protected function display_page_images(Page $page, array $images) {
|
||||
if (count($this->search_terms) > 0) {
|
||||
if($this->page_number > 3) {
|
||||
// only index the first pages of each term
|
||||
|
|
|
@ -29,9 +29,9 @@ class NotATag extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string[] $tags_mixed
|
||||
* #param string[] $tags_mixed
|
||||
*/
|
||||
private function scan($tags_mixed) {
|
||||
private function scan(array $tags_mixed) {
|
||||
global $database;
|
||||
|
||||
$tags = array();
|
||||
|
@ -93,12 +93,7 @@ class NotATag extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $page
|
||||
* @param int $size
|
||||
* @return array
|
||||
*/
|
||||
public function get_untags($page, $size=100) {
|
||||
public function get_untags(int $page, int $size=100): array {
|
||||
global $database;
|
||||
|
||||
// FIXME: many
|
||||
|
|
|
@ -211,11 +211,8 @@ class Notes extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE GET ALL NOTES FOR DISPLAYED IMAGE.
|
||||
*
|
||||
* @param int $imageID
|
||||
* @return array
|
||||
*/
|
||||
private function get_notes($imageID) {
|
||||
private function get_notes(int $imageID): array {
|
||||
global $database;
|
||||
|
||||
return $database->get_all(
|
||||
|
@ -360,7 +357,6 @@ class Notes extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE ALL IMAGES THAT HAVE NOTES
|
||||
* @param PageRequestEvent $event
|
||||
*/
|
||||
private function get_notes_list(PageRequestEvent $event) {
|
||||
global $database, $config;
|
||||
|
@ -393,7 +389,6 @@ class Notes extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE GET ALL NOTE REQUESTS
|
||||
* @param PageRequestEvent $event
|
||||
*/
|
||||
private function get_notes_requests(PageRequestEvent $event) {
|
||||
global $config, $database;
|
||||
|
@ -447,7 +442,6 @@ class Notes extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE GET ALL HISTORIES.
|
||||
* @param PageRequestEvent $event
|
||||
*/
|
||||
private function get_histories(PageRequestEvent $event){
|
||||
global $config, $database;
|
||||
|
@ -477,7 +471,6 @@ class Notes extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE THE HISTORY FOR A SPECIFIC NOTE.
|
||||
* @param PageRequestEvent $event
|
||||
*/
|
||||
private function get_history(PageRequestEvent $event){
|
||||
global $config, $database;
|
||||
|
@ -508,10 +501,8 @@ class Notes extends Extension {
|
|||
|
||||
/**
|
||||
* HERE GO BACK IN HISTORY AND SET THE OLD NOTE. IF WAS REMOVED WE RE-ADD IT.
|
||||
* @param int $noteID
|
||||
* @param int $reviewID
|
||||
*/
|
||||
private function revert_history($noteID, $reviewID){
|
||||
private function revert_history(int $noteID, int $reviewID){
|
||||
global $database;
|
||||
|
||||
$history = $database->get_row("SELECT * FROM note_histories WHERE note_id = ? AND review_id = ?", array($noteID, $reviewID));
|
||||
|
|
|
@ -162,7 +162,7 @@ class NumericScore extends Extension {
|
|||
|
||||
public function onNumericScoreSet(NumericScoreSetEvent $event) {
|
||||
global $user;
|
||||
log_debug("numeric_score", "Rated Image #{$event->image_id} as {$event->score}", true, array("image_id"=>$event->image_id));
|
||||
log_debug("numeric_score", "Rated Image #{$event->image_id} as {$event->score}", "Rated Image", array("image_id"=>$event->image_id));
|
||||
$this->add_vote($event->image_id, $user->id, $event->score);
|
||||
}
|
||||
|
||||
|
@ -175,10 +175,7 @@ class NumericScore extends Extension {
|
|||
$this->delete_votes_by($event->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $user_id
|
||||
*/
|
||||
public function delete_votes_by($user_id) {
|
||||
public function delete_votes_by(int $user_id) {
|
||||
global $database;
|
||||
|
||||
$image_ids = $database->get_col("SELECT image_id FROM numeric_score_votes WHERE user_id=?", array($user_id));
|
||||
|
@ -295,12 +292,7 @@ class NumericScore extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @param int $user_id
|
||||
* @param int $score
|
||||
*/
|
||||
private function add_vote($image_id, $user_id, $score) {
|
||||
private function add_vote(int $image_id, int $user_id, int $score) {
|
||||
global $database;
|
||||
$database->execute(
|
||||
"DELETE FROM numeric_score_votes WHERE image_id=:imageid AND user_id=:userid",
|
||||
|
|
|
@ -190,10 +190,6 @@ class _SafeOuroborosImage
|
|||
*/
|
||||
public $sample_width = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param Image $img
|
||||
*/
|
||||
public function __construct(Image $img)
|
||||
{
|
||||
global $config;
|
||||
|
@ -270,10 +266,8 @@ class OuroborosPost extends _SafeOuroborosImage
|
|||
/**
|
||||
* Initialize an OuroborosPost for creation
|
||||
* Mainly just acts as a wrapper and validation layer
|
||||
* @param array $post
|
||||
* @param string $md5
|
||||
*/
|
||||
public function __construct(array $post, $md5 = '')
|
||||
public function __construct(array $post, string $md5 = '')
|
||||
{
|
||||
if (array_key_exists('tags', $post)) {
|
||||
// implode(explode()) to resolve aliases and sanitise
|
||||
|
@ -485,10 +479,8 @@ class OuroborosAPI extends Extension
|
|||
|
||||
/**
|
||||
* Wrapper for post creation
|
||||
* @param OuroborosPost $post
|
||||
* @param string $md5
|
||||
*/
|
||||
protected function postCreate(OuroborosPost $post, $md5 = '')
|
||||
protected function postCreate(OuroborosPost $post, string $md5 = '')
|
||||
{
|
||||
global $config;
|
||||
$handler = $config->get_string("upload_collision_handler");
|
||||
|
@ -575,9 +567,8 @@ class OuroborosAPI extends Extension
|
|||
|
||||
/**
|
||||
* Wrapper for getting a single post
|
||||
* @param int $id
|
||||
*/
|
||||
protected function postShow($id = null)
|
||||
protected function postShow(int $id = null)
|
||||
{
|
||||
if (!is_null($id)) {
|
||||
$post = new _SafeOuroborosImage(Image::by_id($id));
|
||||
|
@ -589,11 +580,9 @@ class OuroborosAPI extends Extension
|
|||
|
||||
/**
|
||||
* Wrapper for getting a list of posts
|
||||
* @param int $limit
|
||||
* @param int $page
|
||||
* @param string[] $tags
|
||||
* #param string[] $tags
|
||||
*/
|
||||
protected function postIndex($limit, $page, $tags)
|
||||
protected function postIndex(int $limit, int $page, array $tags)
|
||||
{
|
||||
$start = ($page - 1) * $limit;
|
||||
$results = Image::find_images(max($start, 0), min($limit, 100), $tags);
|
||||
|
@ -611,17 +600,7 @@ class OuroborosAPI extends Extension
|
|||
* Tag
|
||||
*/
|
||||
|
||||
/**
|
||||
* Wrapper for getting a list of tags
|
||||
* @param int $limit
|
||||
* @param int $page
|
||||
* @param string $order
|
||||
* @param int $id
|
||||
* @param int $after_id
|
||||
* @param string $name
|
||||
* @param string $name_pattern
|
||||
*/
|
||||
protected function tagIndex($limit, $page, $order, $id, $after_id, $name, $name_pattern)
|
||||
protected function tagIndex(int $limit, int $page, string $order, int $id, int $after_id, string $name, string $name_pattern)
|
||||
{
|
||||
global $database, $config;
|
||||
$start = ($page - 1) * $limit;
|
||||
|
@ -680,12 +659,8 @@ class OuroborosAPI extends Extension
|
|||
|
||||
/**
|
||||
* Sends a simple {success,reason} message to browser
|
||||
*
|
||||
* @param int $code HTTP equivalent code for the message
|
||||
* @param string $reason Reason for the code
|
||||
* @param bool $location Is $reason a location? (used mainly for post/create)
|
||||
*/
|
||||
private function sendResponse($code = 200, $reason = '', $location = false)
|
||||
private function sendResponse(int $code = 200, string $reason = '', bool $location = false)
|
||||
{
|
||||
global $page;
|
||||
if ($code == 200) {
|
||||
|
@ -738,13 +713,7 @@ class OuroborosAPI extends Extension
|
|||
$page->set_data($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send data to the browser
|
||||
* @param string $type
|
||||
* @param mixed $data
|
||||
* @param int $offset
|
||||
*/
|
||||
private function sendData($type = '', $data = array(), $offset = 0)
|
||||
private function sendData(string $type = '', array $data = array(), int $offset = 0)
|
||||
{
|
||||
global $page;
|
||||
$response = '';
|
||||
|
@ -777,10 +746,7 @@ class OuroborosAPI extends Extension
|
|||
$page->set_data($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
private function createItemXML(XMLWriter &$xml, $type, $item)
|
||||
private function createItemXML(XMLWriter &$xml, string $type, $item)
|
||||
{
|
||||
$xml->startElement($type);
|
||||
foreach ($item as $key => $val) {
|
||||
|
@ -801,8 +767,6 @@ class OuroborosAPI extends Extension
|
|||
*
|
||||
* Currently checks for either user & session in request or cookies
|
||||
* and initializes a global User
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
private function tryAuth()
|
||||
{
|
||||
|
@ -835,10 +799,8 @@ class OuroborosAPI extends Extension
|
|||
|
||||
/**
|
||||
* Helper for matching API methods from event
|
||||
* @param string $page
|
||||
* @return bool
|
||||
*/
|
||||
private function match($page)
|
||||
private function match(string $page): bool
|
||||
{
|
||||
return (preg_match("%{$page}\.(xml|json)$%", implode('/', $this->event->args), $matches) === 1);
|
||||
}
|
||||
|
|
|
@ -16,10 +16,7 @@ class PoolCreationException extends SCoreException {
|
|||
/** @var string */
|
||||
public $error;
|
||||
|
||||
/**
|
||||
* @param string $error
|
||||
*/
|
||||
public function __construct($error) {
|
||||
public function __construct(string $error) {
|
||||
$this->error = $error;
|
||||
}
|
||||
}
|
||||
|
@ -352,12 +349,8 @@ class Pools extends Extension {
|
|||
* Check if the given user has permission to edit/change the pool.
|
||||
*
|
||||
* TODO: Should the user variable be global?
|
||||
*
|
||||
* @param \User $user
|
||||
* @param array $pool
|
||||
* @return bool
|
||||
*/
|
||||
private function have_permission($user, $pool) {
|
||||
private function have_permission(User $user, array $pool): bool {
|
||||
// If the pool is public and user is logged OR if the user is admin OR if the pool is owned by the user.
|
||||
if ( (($pool['public'] == "Y" || $pool['public'] == "y") && !$user->is_anonymous()) || $user->is_admin() || $user->id == $pool['user_id'])
|
||||
{
|
||||
|
@ -369,9 +362,6 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE GET THE LIST OF POOLS.
|
||||
*
|
||||
* @param \Page $page
|
||||
* @param int $pageNumber
|
||||
*/
|
||||
private function list_pools(Page $page, int $pageNumber) {
|
||||
global $config, $database;
|
||||
|
@ -410,11 +400,8 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE CREATE A NEW POOL
|
||||
*
|
||||
* @return int
|
||||
* @throws PoolCreationException
|
||||
*/
|
||||
private function add_pool() {
|
||||
private function add_pool(): int {
|
||||
global $user, $database;
|
||||
|
||||
if($user->is_anonymous()) {
|
||||
|
@ -442,58 +429,47 @@ class Pools extends Extension {
|
|||
* Retrieve information about pools given multiple pool IDs.
|
||||
*
|
||||
* TODO: What is the difference between this and get_single_pool() other than the db query?
|
||||
*
|
||||
* @param int $poolID Array of integers
|
||||
* @return array
|
||||
*/
|
||||
private function get_pool(int $poolID) {
|
||||
private function get_pool(int $poolID): array {
|
||||
global $database;
|
||||
return $database->get_all("SELECT * FROM pools WHERE id=:id", array("id"=>$poolID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve information about a pool given a pool ID.
|
||||
* @param int $poolID the pool id
|
||||
* @return array Array with only 1 element in the one dimension
|
||||
*/
|
||||
private function get_single_pool(int $poolID) {
|
||||
private function get_single_pool(int $poolID): array {
|
||||
global $database;
|
||||
return $database->get_row("SELECT * FROM pools WHERE id=:id", array("id"=>$poolID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve information about a pool given a pool title.
|
||||
* @param string $poolTitle
|
||||
* @return array Array (with only 1 element in the one dimension)
|
||||
*/
|
||||
private function get_single_pool_from_title(string $poolTitle) {
|
||||
private function get_single_pool_from_title(string $poolTitle): array {
|
||||
global $database;
|
||||
return $database->get_row("SELECT * FROM pools WHERE title=:title", array("title"=>$poolTitle));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all of the pool IDs that an image is in, given an image ID.
|
||||
* @param int $imageID Integer ID for the image
|
||||
* @return int[]
|
||||
* #return int[]
|
||||
*/
|
||||
private function get_pool_ids(int $imageID) {
|
||||
private function get_pool_ids(int $imageID): array {
|
||||
global $database;
|
||||
return $database->get_col("SELECT pool_id FROM pool_images WHERE image_id=:iid", array("iid"=>$imageID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve information about the last pool the given userID created
|
||||
* @param int $userID
|
||||
* @return array
|
||||
*/
|
||||
private function get_last_userpool(int $userID){
|
||||
private function get_last_userpool(int $userID): array {
|
||||
global $database;
|
||||
return $database->get_row("SELECT * FROM pools WHERE user_id=:uid ORDER BY id DESC", array("uid"=>$userID));
|
||||
}
|
||||
|
||||
/**
|
||||
* HERE WE GET THE IMAGES FROM THE TAG ON IMPORT
|
||||
* @param int $pool_id
|
||||
*/
|
||||
private function import_posts(int $pool_id) {
|
||||
global $page, $config;
|
||||
|
@ -509,10 +485,8 @@ class Pools extends Extension {
|
|||
* HERE WE ADD CHECKED IMAGES FROM POOL AND UPDATE THE HISTORY
|
||||
*
|
||||
* TODO: Fix this so that the pool ID and images are passed as Arguments to the function.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function add_posts() {
|
||||
private function add_posts(): int {
|
||||
global $database;
|
||||
|
||||
$poolID = int_escape($_POST['pool_id']);
|
||||
|
@ -545,9 +519,8 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* TODO: Fix this so that the pool ID and images are passed as Arguments to the function.
|
||||
* @return int
|
||||
*/
|
||||
private function order_posts() {
|
||||
private function order_posts(): int {
|
||||
global $database;
|
||||
|
||||
$poolID = int_escape($_POST['pool_id']);
|
||||
|
@ -569,10 +542,8 @@ class Pools extends Extension {
|
|||
* HERE WE REMOVE CHECKED IMAGES FROM POOL AND UPDATE THE HISTORY
|
||||
*
|
||||
* TODO: Fix this so that the pool ID and images are passed as Arguments to the function.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function remove_posts() {
|
||||
private function remove_posts(): int {
|
||||
global $database;
|
||||
|
||||
$poolID = int_escape($_POST['pool_id']);
|
||||
|
@ -590,9 +561,8 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* Allows editing of pool description.
|
||||
* @return int
|
||||
*/
|
||||
private function edit_description() {
|
||||
private function edit_description(): int {
|
||||
global $database;
|
||||
|
||||
$poolID = int_escape($_POST['pool_id']);
|
||||
|
@ -604,13 +574,8 @@ class Pools extends Extension {
|
|||
/**
|
||||
* This function checks if a given image is contained within a given pool.
|
||||
* Used by add_posts()
|
||||
*
|
||||
* @see add_posts()
|
||||
* @param int $poolID
|
||||
* @param int $imageID
|
||||
* @return bool
|
||||
*/
|
||||
private function check_post(int $poolID, int $imageID) {
|
||||
private function check_post(int $poolID, int $imageID): bool {
|
||||
global $database;
|
||||
$result = $database->get_one("SELECT COUNT(*) FROM pool_images WHERE pool_id=:pid AND image_id=:iid", array("pid"=>$poolID, "iid"=>$imageID));
|
||||
return ($result != 0);
|
||||
|
@ -619,11 +584,9 @@ class Pools extends Extension {
|
|||
/**
|
||||
* Gets the previous and next successive images from a pool, given a pool ID and an image ID.
|
||||
*
|
||||
* @param array $pool Array for the given pool
|
||||
* @param int $imageID Integer
|
||||
* @return array Array returning two elements (prev, next) in 1 dimension. Each returns ImageID or NULL if none.
|
||||
* #return int[] Array returning two elements (prev, next) in 1 dimension. Each returns ImageID or NULL if none.
|
||||
*/
|
||||
private function get_nav_posts(array $pool, int $imageID) {
|
||||
private function get_nav_posts(array $pool, int $imageID): array {
|
||||
global $database;
|
||||
|
||||
if (empty($pool) || empty($imageID))
|
||||
|
@ -670,11 +633,8 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* Retrieve all the images in a pool, given a pool ID.
|
||||
*
|
||||
* @param PageRequestEvent $event
|
||||
* @param int $poolID
|
||||
*/
|
||||
private function get_posts($event, int $poolID) {
|
||||
private function get_posts(PageRequestEvent $event, int $poolID) {
|
||||
global $config, $user, $database;
|
||||
|
||||
$pageNumber = int_escape($event->get_arg(2));
|
||||
|
@ -736,10 +696,9 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* This function gets the current order of images from a given pool.
|
||||
* @param int $poolID
|
||||
* @return \Image[] Array of image objects.
|
||||
* #return Image[] Array of image objects.
|
||||
*/
|
||||
private function edit_posts(int $poolID) {
|
||||
private function edit_posts(int $poolID): array {
|
||||
global $database;
|
||||
|
||||
$result = $database->Execute("SELECT image_id FROM pool_images WHERE pool_id=:pid ORDER BY image_order ASC", array("pid"=>$poolID));
|
||||
|
@ -757,10 +716,9 @@ class Pools extends Extension {
|
|||
/**
|
||||
* WE GET THE ORDER OF THE IMAGES BUT HERE WE SEND KEYS ADDED IN ARRAY TO GET THE ORDER IN THE INPUT VALUE.
|
||||
*
|
||||
* @param int $poolID
|
||||
* @return \Image[]
|
||||
* #return Image[]
|
||||
*/
|
||||
private function edit_order(int $poolID) {
|
||||
private function edit_order(int $poolID): array {
|
||||
global $database;
|
||||
|
||||
$result = $database->Execute("SELECT image_id FROM pool_images WHERE pool_id=:pid ORDER BY image_order ASC", array("pid"=>$poolID));
|
||||
|
@ -783,8 +741,6 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE NUKE ENTIRE POOL. WE REMOVE POOLS AND POSTS FROM REMOVED POOL AND HISTORIES ENTRIES FROM REMOVED POOL.
|
||||
*
|
||||
* @param int $poolID
|
||||
*/
|
||||
private function nuke_pool(int $poolID) {
|
||||
global $user, $database;
|
||||
|
@ -804,12 +760,9 @@ class Pools extends Extension {
|
|||
/**
|
||||
* HERE WE ADD A HISTORY ENTRY.
|
||||
*
|
||||
* @param int $poolID
|
||||
* @param int $action Action=1 (one) MEANS ADDED, Action=0 (zero) MEANS REMOVED
|
||||
* @param string $images
|
||||
* @param int $count
|
||||
* $action Action=1 (one) MEANS ADDED, Action=0 (zero) MEANS REMOVED
|
||||
*/
|
||||
private function add_history(int $poolID, $action, $images, $count) {
|
||||
private function add_history(int $poolID, int $action, string $images, int $count) {
|
||||
global $user, $database;
|
||||
|
||||
$database->execute("
|
||||
|
@ -820,7 +773,6 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* HERE WE GET THE HISTORY LIST.
|
||||
* @param int $pageNumber
|
||||
*/
|
||||
private function get_history(int $pageNumber) {
|
||||
global $config, $database;
|
||||
|
@ -853,7 +805,6 @@ class Pools extends Extension {
|
|||
|
||||
/**
|
||||
* HERE GO BACK IN HISTORY AND ADD OR REMOVE POSTS TO POOL.
|
||||
* @param int $historyID
|
||||
*/
|
||||
private function revert_history(int $historyID) {
|
||||
global $database;
|
||||
|
@ -899,13 +850,8 @@ class Pools extends Extension {
|
|||
/**
|
||||
* HERE WE ADD A SIMPLE POST FROM POOL.
|
||||
* USED WITH FOREACH IN revert_history() & onTagTermParse().
|
||||
*
|
||||
* @param int $poolID
|
||||
* @param int $imageID
|
||||
* @param bool $history
|
||||
* @param int $imageOrder
|
||||
*/
|
||||
private function add_post(int $poolID, int $imageID, $history=false, $imageOrder=0) {
|
||||
private function add_post(int $poolID, int $imageID, bool $history=false, int $imageOrder=0) {
|
||||
global $database, $config;
|
||||
|
||||
if(!$this->check_post($poolID, $imageID)) {
|
||||
|
@ -934,12 +880,8 @@ class Pools extends Extension {
|
|||
/**
|
||||
* HERE WE REMOVE A SIMPLE POST FROM POOL.
|
||||
* USED WITH FOREACH IN revert_history() & onTagTermParse().
|
||||
*
|
||||
* @param int $poolID
|
||||
* @param int $imageID
|
||||
* @param bool $history
|
||||
*/
|
||||
private function delete_post(int $poolID, int $imageID, $history=false) {
|
||||
private function delete_post(int $poolID, int $imageID, bool $history=false) {
|
||||
global $database;
|
||||
|
||||
$database->execute("DELETE FROM pool_images WHERE pool_id = :pid AND image_id = :iid", array("pid"=>$poolID, "iid"=>$imageID));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class PoolsTheme extends Themelet {
|
||||
/**
|
||||
* Adds a block to the panel with information on the pool(s) the image is in.
|
||||
* @param array Multidimensional array containing pool id, info & nav IDs.
|
||||
* $navIDs = Multidimensional array containing pool id, info & nav IDs.
|
||||
*/
|
||||
public function pool_info(array $navIDs) {
|
||||
global $page;
|
||||
|
@ -32,12 +32,7 @@ class PoolsTheme extends Themelet {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @param array $pools
|
||||
* @return string
|
||||
*/
|
||||
public function get_adder_html(Image $image, array $pools) {
|
||||
public function get_adder_html(Image $image, array $pools): string {
|
||||
$h = "";
|
||||
foreach($pools as $pool) {
|
||||
$h .= "<option value='".$pool['id']."'>".html_escape($pool['title'])."</option>";
|
||||
|
@ -55,11 +50,6 @@ class PoolsTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* HERE WE SHOWS THE LIST OF POOLS.
|
||||
*
|
||||
* @param Page $page
|
||||
* @param array $pools
|
||||
* @param int $pageNumber
|
||||
* @param int $totalPages
|
||||
*/
|
||||
public function list_pools(Page $page, array $pools, int $pageNumber, int $totalPages) {
|
||||
$html = '
|
||||
|
@ -156,11 +146,6 @@ class PoolsTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* HERE WE DISPLAY THE POOL WITH TITLE DESCRIPTION AND IMAGES WITH PAGINATION.
|
||||
*
|
||||
* @param array $pools
|
||||
* @param array $images
|
||||
* @param int $pageNumber
|
||||
* @param int $totalPages
|
||||
*/
|
||||
public function view_pool(array $pools, array $images, int $pageNumber, int $totalPages) {
|
||||
global $page;
|
||||
|
@ -180,12 +165,8 @@ class PoolsTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* HERE WE DISPLAY THE POOL OPTIONS ON SIDEBAR BUT WE HIDE REMOVE OPTION IF THE USER IS NOT THE OWNER OR ADMIN.
|
||||
*
|
||||
* @param Page $page
|
||||
* @param array $pool
|
||||
* @param bool $check_all
|
||||
*/
|
||||
public function sidebar_options(Page $page, $pool, bool $check_all) {
|
||||
public function sidebar_options(Page $page, array $pool, bool $check_all) {
|
||||
global $user;
|
||||
|
||||
$editor = "\n".make_form( make_link('pool/import') ).'
|
||||
|
@ -243,10 +224,6 @@ class PoolsTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* HERE WE DISPLAY THE RESULT OF THE SEARCH ON IMPORT.
|
||||
*
|
||||
* @param Page $page
|
||||
* @param array $images
|
||||
* @param array $pool
|
||||
*/
|
||||
public function pool_result(Page $page, array $images, array $pool) {
|
||||
|
||||
|
@ -283,10 +260,6 @@ class PoolsTheme extends Themelet {
|
|||
/**
|
||||
* HERE WE DISPLAY THE POOL ORDERER.
|
||||
* WE LIST ALL IMAGES ON POOL WITHOUT PAGINATION AND WITH A TEXT INPUT TO SET A NUMBER AND CHANGE THE ORDER
|
||||
*
|
||||
* @param Page $page
|
||||
* @param array $pools
|
||||
* @param array $images
|
||||
*/
|
||||
public function edit_order(Page $page, array $pools, array $images) {
|
||||
$this->display_top($pools, "Sorting Pool");
|
||||
|
@ -316,10 +289,6 @@ class PoolsTheme extends Themelet {
|
|||
*
|
||||
* WE LIST ALL IMAGES ON POOL WITHOUT PAGINATION AND WITH
|
||||
* A CHECKBOX TO SELECT WHICH IMAGE WE WANT TO REMOVE
|
||||
*
|
||||
* @param Page $page
|
||||
* @param array $pools
|
||||
* @param array $images
|
||||
*/
|
||||
public function edit_pool(Page $page, array $pools, array $images) {
|
||||
/* EDIT POOL DESCRIPTION */
|
||||
|
@ -358,12 +327,8 @@ class PoolsTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* HERE WE DISPLAY THE HISTORY LIST.
|
||||
*
|
||||
* @param array $histories
|
||||
* @param int $pageNumber
|
||||
* @param int $totalPages
|
||||
*/
|
||||
public function show_history($histories, int $pageNumber, int $totalPages) {
|
||||
public function show_history(array $histories, int $pageNumber, int $totalPages) {
|
||||
global $page;
|
||||
$html = '
|
||||
<table id="poolsList" class="zebra">
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
<?php
|
||||
class QRImageTheme extends Themelet {
|
||||
/**
|
||||
* @param string $link
|
||||
*/
|
||||
public function links_block($link) {
|
||||
public function links_block(string $link) {
|
||||
global $page;
|
||||
|
||||
$page->add_block( new Block(
|
||||
|
|
|
@ -1,23 +1,11 @@
|
|||
<?php
|
||||
|
||||
class RandomImageTheme extends Themelet
|
||||
{
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image $image
|
||||
*/
|
||||
public function display_random(Page $page, Image $image)
|
||||
{
|
||||
class RandomImageTheme extends Themelet {
|
||||
public function display_random(Page $page, Image $image) {
|
||||
$page->add_block(new Block("Random Image", $this->build_random_html($image), "left", 8));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @param null|string $query
|
||||
* @return string
|
||||
*/
|
||||
public function build_random_html(Image $image, $query = null)
|
||||
{
|
||||
public function build_random_html(Image $image, ?string $query = null): string {
|
||||
|
||||
$i_id = int_escape($image->id);
|
||||
$h_view_link = make_link("post/view/$i_id", $query);
|
||||
|
|
|
@ -4,17 +4,16 @@ class RandomListTheme extends Themelet {
|
|||
protected $search_terms;
|
||||
|
||||
/**
|
||||
* @param string[] $search_terms
|
||||
* #param string[] $search_terms
|
||||
*/
|
||||
public function set_page($search_terms) {
|
||||
public function set_page(array $search_terms) {
|
||||
$this->search_terms = $search_terms;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image[] $images
|
||||
* #param Image[] $images
|
||||
*/
|
||||
public function display_page(Page $page, $images) {
|
||||
public function display_page(Page $page, array $images) {
|
||||
$page->title = "Random Images";
|
||||
|
||||
$html = "<b>Refresh the page to view more images</b>";
|
||||
|
|
|
@ -36,9 +36,6 @@ class RatingSetEvent extends Event {
|
|||
class Ratings extends Extension {
|
||||
protected $db_support = ['mysql']; // ?
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority(): int {return 50;}
|
||||
|
||||
public function onInitExt(InitExtEvent $event) {
|
||||
|
@ -162,11 +159,7 @@ class Ratings extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \User $user
|
||||
* @return string
|
||||
*/
|
||||
public static function get_user_privs(User $user) {
|
||||
public static function get_user_privs(User $user): string {
|
||||
global $config;
|
||||
|
||||
if($user->is_anonymous()) {
|
||||
|
@ -181,11 +174,7 @@ class Ratings extends Extension {
|
|||
return $sqes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sqes
|
||||
* @return string
|
||||
*/
|
||||
public static function privs_to_sql(string $sqes) {
|
||||
public static function privs_to_sql(string $sqes): string {
|
||||
$arr = array();
|
||||
$length = strlen($sqes);
|
||||
for($i=0; $i<$length; $i++) {
|
||||
|
@ -195,11 +184,7 @@ class Ratings extends Extension {
|
|||
return $set;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $rating
|
||||
* @return string
|
||||
*/
|
||||
public static function rating_to_human(string $rating) {
|
||||
public static function rating_to_human(string $rating): string {
|
||||
switch($rating) {
|
||||
case "s": return "Safe";
|
||||
case "q": return "Questionable";
|
||||
|
@ -208,11 +193,7 @@ class Ratings extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $rating
|
||||
* @return bool
|
||||
*/
|
||||
public static function rating_is_valid(string $rating) {
|
||||
public static function rating_is_valid(string $rating): bool {
|
||||
switch($rating) {
|
||||
case "s":
|
||||
case "q":
|
||||
|
@ -226,10 +207,8 @@ class Ratings extends Extension {
|
|||
|
||||
/**
|
||||
* FIXME: this is a bit ugly and guessey, should have proper options
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function can_rate() {
|
||||
private function can_rate(): bool {
|
||||
global $config, $user;
|
||||
if($user->is_anonymous() && $config->get_string("ext_rating_anon_privs") == "sqeu") return false;
|
||||
if($user->is_admin()) return true;
|
||||
|
@ -238,10 +217,9 @@ class Ratings extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string[] $context
|
||||
* @return bool
|
||||
* #param string[] $context
|
||||
*/
|
||||
private function no_rating_query($context) {
|
||||
private function no_rating_query(array $context): bool {
|
||||
foreach($context as $term) {
|
||||
if(preg_match("/^rating[=|:]/", $term)) {
|
||||
return false;
|
||||
|
@ -270,11 +248,6 @@ class Ratings extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @param string $rating
|
||||
* @param string $old_rating
|
||||
*/
|
||||
private function set_rating(int $image_id, string $rating, string $old_rating) {
|
||||
global $database;
|
||||
if($old_rating != $rating){
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
<?php
|
||||
|
||||
class RatingsTheme extends Themelet {
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @param string $rating
|
||||
* @return string
|
||||
*/
|
||||
public function get_rater_html(int $image_id, string $rating, bool $can_rate) {
|
||||
public function get_rater_html(int $image_id, string $rating, bool $can_rate): string {
|
||||
$s_checked = $rating == 's' ? " checked" : "";
|
||||
$q_checked = $rating == 'q' ? " checked" : "";
|
||||
$e_checked = $rating == 'e' ? " checked" : "";
|
||||
|
@ -31,7 +26,7 @@ class RatingsTheme extends Themelet {
|
|||
return $html;
|
||||
}
|
||||
|
||||
public function display_bulk_rater($terms) {
|
||||
public function display_bulk_rater(string $terms) {
|
||||
global $page;
|
||||
$html = "
|
||||
".make_form(make_link("admin/bulk_rate"))."
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
class RegenThumbTheme extends Themelet {
|
||||
/**
|
||||
* Show a form which offers to regenerate the thumb of an image with ID #$image_id
|
||||
*
|
||||
* @param int|string $image_id
|
||||
* @return string
|
||||
*/
|
||||
public function get_buttons_html($image_id) {
|
||||
public function get_buttons_html(int $image_id): string {
|
||||
return "
|
||||
".make_form(make_link("regen_thumb/one"))."
|
||||
<input type='hidden' name='image_id' value='$image_id'>
|
||||
|
@ -18,9 +15,6 @@ class RegenThumbTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* Show a link to the new thumbnail.
|
||||
*
|
||||
* @param Page $page
|
||||
* @param Image $image
|
||||
*/
|
||||
public function display_results(Page $page, Image $image) {
|
||||
$page->set_title("Thumbnail Regenerated");
|
||||
|
@ -30,7 +24,7 @@ class RegenThumbTheme extends Themelet {
|
|||
$page->add_block(new Block("Thumbnail", $this->build_thumb_html($image)));
|
||||
}
|
||||
|
||||
public function mtr_html($terms) {
|
||||
public function mtr_html(string $terms) {
|
||||
$h_terms = html_escape($terms);
|
||||
$html = make_form(make_link("regen_thumb/mass"), "POST") . "
|
||||
<input type='hidden' name='tags' value='$h_terms'>
|
||||
|
|
|
@ -99,10 +99,6 @@ class Relationships extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $imageID
|
||||
* @param int $parentID
|
||||
*/
|
||||
private function set_parent(int $imageID, int $parentID){
|
||||
global $database;
|
||||
|
||||
|
@ -112,10 +108,6 @@ class Relationships extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $parentID
|
||||
* @param int $childID
|
||||
*/
|
||||
private function set_child(int $parentID, int $childID){
|
||||
global $database;
|
||||
|
||||
|
@ -125,9 +117,6 @@ class Relationships extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $imageID
|
||||
*/
|
||||
private function remove_parent(int $imageID){
|
||||
global $database;
|
||||
$parentID = $database->get_one("SELECT parent_id FROM images WHERE id = :iid", array("iid"=>$imageID));
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
<?php
|
||||
|
||||
class RelationshipsTheme extends Themelet {
|
||||
/**
|
||||
* @param \Image $image
|
||||
*/
|
||||
public function relationship_info($image) {
|
||||
public function relationship_info(Image $image) {
|
||||
global $page, $database;
|
||||
|
||||
if($image->parent_id !== NULL){
|
||||
|
@ -26,7 +23,7 @@ class RelationshipsTheme extends Themelet {
|
|||
}
|
||||
}
|
||||
|
||||
public function get_parent_editor_html(Image $image) {
|
||||
public function get_parent_editor_html(Image $image): string {
|
||||
global $user;
|
||||
|
||||
$h_parent_id = $image->parent_id;
|
||||
|
|
|
@ -94,7 +94,7 @@ class ReportImage extends Extension {
|
|||
|
||||
public function onAddReportedImage(AddReportedImageEvent $event) {
|
||||
global $database;
|
||||
log_info("report_image", "Adding report of Image #{$event->report->image_id} with reason '{$event->report->reason}'", false, array("image_id" => $event->report->image_id));
|
||||
log_info("report_image", "Adding report of Image #{$event->report->image_id} with reason '{$event->report->reason}'", null, array("image_id" => $event->report->image_id));
|
||||
$database->Execute(
|
||||
"INSERT INTO image_reports(image_id, reporter_id, reason)
|
||||
VALUES (?, ?, ?)",
|
||||
|
@ -156,10 +156,7 @@ class ReportImage extends Extension {
|
|||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $user_id
|
||||
*/
|
||||
public function delete_reports_by($user_id) {
|
||||
public function delete_reports_by(int $user_id) {
|
||||
global $database;
|
||||
$database->execute("DELETE FROM image_reports WHERE reporter_id=?", array($user_id));
|
||||
$database->cache->delete("image-report-count");
|
||||
|
@ -182,10 +179,9 @@ class ReportImage extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @return ImageReport[]
|
||||
* #return ImageReport[]
|
||||
*/
|
||||
public function get_reports(Image $image) {
|
||||
public function get_reports(Image $image): array {
|
||||
global $database;
|
||||
|
||||
$rows = $database->get_all("
|
||||
|
@ -200,10 +196,7 @@ class ReportImage extends Extension {
|
|||
return $reps;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get_reported_images() {
|
||||
public function get_reported_images(): array {
|
||||
global $database;
|
||||
|
||||
$all_reports = $database->get_all("
|
||||
|
@ -228,10 +221,7 @@ class ReportImage extends Extension {
|
|||
return $reports;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count_reported_images() {
|
||||
public function count_reported_images(): int {
|
||||
global $database;
|
||||
|
||||
$count = $database->cache->get("image-report-count");
|
||||
|
|
|
@ -11,11 +11,7 @@
|
|||
*/
|
||||
|
||||
class ReportImageTheme extends Themelet {
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param array $reports
|
||||
*/
|
||||
public function display_reported_images(Page $page, $reports) {
|
||||
public function display_reported_images(Page $page, array $reports) {
|
||||
global $config, $user;
|
||||
|
||||
$h_reportedimages = "";
|
||||
|
@ -63,8 +59,7 @@ class ReportImageTheme extends Themelet {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @param ImageReport[] $reports
|
||||
* #param ImageReport[] $reports
|
||||
*/
|
||||
public function display_image_banner(Image $image, array $reports) {
|
||||
global $config, $page;
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
class ImageResizeException extends SCoreException {
|
||||
public $error;
|
||||
|
||||
/** @param string $error */
|
||||
public function __construct($error) {
|
||||
public function __construct(string $error) {
|
||||
$this->error = $error;
|
||||
}
|
||||
}
|
||||
|
@ -158,11 +157,6 @@ class ResizeImage extends Extension {
|
|||
/**
|
||||
* This function could be made much smaller by using the ImageReplaceEvent
|
||||
* ie: Pretend that we are replacing the image with a resized copy.
|
||||
*
|
||||
* @param Image $image_obj
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @throws ImageResizeException
|
||||
*/
|
||||
private function resize_image(Image $image_obj, int $width, int $height) {
|
||||
global $database;
|
||||
|
@ -290,11 +284,8 @@ class ResizeImage extends Extension {
|
|||
*
|
||||
* The factor of 2.5 is simply a rough guideline.
|
||||
* http://stackoverflow.com/questions/527532/reasonable-php-memory-limit-for-image-resize
|
||||
*
|
||||
* @param mixed[] $info
|
||||
* @return int
|
||||
*/
|
||||
private function calc_memory_use($info) {
|
||||
private function calc_memory_use(array $info): int {
|
||||
if (isset($info['bits']) && isset($info['channels'])) {
|
||||
$memory_use = ($info[0] * $info[1] * ($info['bits'] / 8) * $info['channels'] * 2.5) / 1024;
|
||||
}
|
||||
|
@ -307,12 +298,9 @@ class ResizeImage extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Image $image_obj
|
||||
* @param int $width
|
||||
* @param int $height
|
||||
* @return int[]
|
||||
* #return int[]
|
||||
*/
|
||||
private function calc_new_size(Image $image_obj, $width, $height) {
|
||||
private function calc_new_size(Image $image_obj, int $width, int $height): array {
|
||||
/* Calculate the new size of the image */
|
||||
if ($height > 0 && $width > 0) {
|
||||
$new_height = $height;
|
||||
|
|
|
@ -19,10 +19,7 @@ class ImageRotateException extends SCoreException {
|
|||
/** @var string */
|
||||
public $error;
|
||||
|
||||
/**
|
||||
* @param string $error
|
||||
*/
|
||||
public function __construct($error) {
|
||||
public function __construct(string $error) {
|
||||
$this->error = $error;
|
||||
}
|
||||
}
|
||||
|
@ -108,10 +105,6 @@ class RotateImage extends Extension {
|
|||
/**
|
||||
* This function could be made much smaller by using the ImageReplaceEvent
|
||||
* ie: Pretend that we are replacing the image with a rotated copy.
|
||||
*
|
||||
* @param int $image_id
|
||||
* @param int $deg
|
||||
* @throws ImageRotateException
|
||||
*/
|
||||
private function rotate_image(int $image_id, int $deg) {
|
||||
global $database;
|
||||
|
|
|
@ -3,11 +3,8 @@
|
|||
class RotateImageTheme extends Themelet {
|
||||
/**
|
||||
* Display a link to rotate an image.
|
||||
*
|
||||
* @param int $image_id
|
||||
* @return string
|
||||
*/
|
||||
public function get_rotate_html(int $image_id) {
|
||||
public function get_rotate_html(int $image_id): string {
|
||||
$html = "
|
||||
".make_form(make_link('rotate/'.$image_id), 'POST')."
|
||||
<input type='hidden' name='image_id' value='$image_id'>
|
||||
|
@ -21,10 +18,6 @@ class RotateImageTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* Display the error.
|
||||
*
|
||||
* @param Page $page
|
||||
* @param string $title
|
||||
* @param string $message
|
||||
*/
|
||||
public function display_rotate_error(Page $page, string $title, string $message) {
|
||||
$page->set_title("Rotate Image");
|
||||
|
|
|
@ -33,12 +33,7 @@ class RSS_Images extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $images
|
||||
* @param array $search_terms
|
||||
* @param int $page_number
|
||||
*/
|
||||
private function do_rss($images, $search_terms, int $page_number) {
|
||||
private function do_rss(array $images, array $search_terms, int $page_number) {
|
||||
global $page;
|
||||
global $config;
|
||||
$page->set_mode("data");
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
<?php
|
||||
|
||||
class Rule34Theme extends Themelet {
|
||||
/**
|
||||
* @param User $duser
|
||||
* @param bool $current_state
|
||||
* @return string
|
||||
*/
|
||||
public function show_comic_changer(User $duser, $current_state) {
|
||||
public function show_comic_changer(User $duser, bool $current_state): string {
|
||||
global $page;
|
||||
$checked = $current_state ? 'checked="checked"' : '';
|
||||
$html = make_form(make_link("rule34/comic_admin"), "POST");
|
||||
|
|
|
@ -15,9 +15,6 @@ class ConfigSaveEvent extends Event {
|
|||
/** @var \Config */
|
||||
public $config;
|
||||
|
||||
/**
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Config $config) {
|
||||
$this->config = $config;
|
||||
}
|
||||
|
@ -31,9 +28,6 @@ class SetupBuildingEvent extends Event {
|
|||
/** @var \SetupPanel */
|
||||
public $panel;
|
||||
|
||||
/**
|
||||
* @param SetupPanel $panel
|
||||
*/
|
||||
public function __construct(SetupPanel $panel) {
|
||||
$this->panel = $panel;
|
||||
}
|
||||
|
@ -46,9 +40,6 @@ class SetupPanel {
|
|||
/** @var \SetupBlock[] */
|
||||
public $blocks = array();
|
||||
|
||||
/**
|
||||
* @param SetupBlock $block
|
||||
*/
|
||||
public function add_block(SetupBlock $block) {
|
||||
$this->blocks[] = $block;
|
||||
}
|
||||
|
|
|
@ -110,10 +110,9 @@ class ShimmieApi extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $arg
|
||||
* @return string[]
|
||||
* #return string[]
|
||||
*/
|
||||
private function api_get_tags($arg) {
|
||||
private function api_get_tags(string $arg): array {
|
||||
global $database;
|
||||
if (!empty($arg)) {
|
||||
$all = $database->get_all("SELECT tag FROM tags WHERE tag LIKE ?", array($arg . "%"));
|
||||
|
|
|
@ -116,14 +116,9 @@ class XMLSitemap extends Extension
|
|||
|
||||
/**
|
||||
* Adds an array of urls to the sitemap with the given information.
|
||||
*
|
||||
* @param array $urls
|
||||
* @param string $changefreq
|
||||
* @param string $priority
|
||||
* @param string $date
|
||||
*/
|
||||
private function add_sitemap_queue(array $urls, $changefreq = "monthly",
|
||||
$priority = "0.5", $date = "2013-02-01")
|
||||
private function add_sitemap_queue(array $urls, string $changefreq = "monthly",
|
||||
string $priority = "0.5", string $date = "2013-02-01")
|
||||
{
|
||||
foreach ($urls as $url) {
|
||||
$link = make_http(make_link("$url"));
|
||||
|
@ -156,10 +151,8 @@ class XMLSitemap extends Extension
|
|||
|
||||
/**
|
||||
* Returns true if a new sitemap is needed.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function new_sitemap_needed()
|
||||
private function new_sitemap_needed(): bool
|
||||
{
|
||||
if(!file_exists($this->sitemap_filepath)) {
|
||||
return true;
|
||||
|
|
|
@ -115,9 +115,8 @@ class Source_History extends Extension {
|
|||
|
||||
/**
|
||||
* This function is called when a revert request is received.
|
||||
* @param int $revert_id
|
||||
*/
|
||||
private function process_revert_request($revert_id) {
|
||||
private function process_revert_request(int $revert_id) {
|
||||
global $page;
|
||||
|
||||
$revert_id = int_escape($revert_id);
|
||||
|
@ -203,11 +202,7 @@ class Source_History extends Extension {
|
|||
$this->theme->display_revert_ip_results();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $revert_id
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function get_source_history_from_revert(int $revert_id) {
|
||||
public function get_source_history_from_revert(int $revert_id): ?array {
|
||||
global $database;
|
||||
$row = $database->get_row("
|
||||
SELECT source_histories.*, users.name
|
||||
|
@ -217,11 +212,7 @@ class Source_History extends Extension {
|
|||
return ($row ? $row : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @return array
|
||||
*/
|
||||
public function get_source_history_from_id(int $image_id) {
|
||||
public function get_source_history_from_id(int $image_id): array {
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT source_histories.*, users.name
|
||||
|
@ -233,11 +224,7 @@ class Source_History extends Extension {
|
|||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $page_id
|
||||
* @return array
|
||||
*/
|
||||
public function get_global_source_history($page_id) {
|
||||
public function get_global_source_history(int $page_id): array {
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT source_histories.*, users.name
|
||||
|
@ -251,12 +238,8 @@ class Source_History extends Extension {
|
|||
|
||||
/**
|
||||
* This function attempts to revert all changes by a given IP within an (optional) timeframe.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $ip
|
||||
* @param string $date
|
||||
*/
|
||||
public function process_revert_all_changes($name, $ip, $date) {
|
||||
public function process_revert_all_changes(string $name, string $ip, string $date) {
|
||||
global $database;
|
||||
|
||||
$select_code = array();
|
||||
|
@ -351,10 +334,8 @@ class Source_History extends Extension {
|
|||
|
||||
/**
|
||||
* This function is called just before an images source is changed.
|
||||
* @param Image $image
|
||||
* @param string $source
|
||||
*/
|
||||
private function add_source_history($image, $source) {
|
||||
private function add_source_history(Image $image, string $source) {
|
||||
global $database, $config, $user;
|
||||
|
||||
$new_source = $source;
|
||||
|
|
|
@ -2,11 +2,6 @@
|
|||
class Source_HistoryTheme extends Themelet {
|
||||
private $messages = array();
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param int $image_id
|
||||
* @param array $history
|
||||
*/
|
||||
public function display_history_page(Page $page, int $image_id, array $history) {
|
||||
global $user;
|
||||
$start_string = "
|
||||
|
@ -55,11 +50,6 @@ class Source_HistoryTheme extends Themelet {
|
|||
$page->add_block(new Block("Source History", $history_html, "main", 10));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param array $history
|
||||
* @param int $page_number
|
||||
*/
|
||||
public function display_global_page(Page $page, array $history, int $page_number) {
|
||||
$start_string = "
|
||||
<div style='text-align: left'>
|
||||
|
@ -110,7 +100,6 @@ class Source_HistoryTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* Add a section to the admin page.
|
||||
* @param string $validation_msg
|
||||
*/
|
||||
public function display_admin_block(string $validation_msg='') {
|
||||
global $page;
|
||||
|
@ -146,10 +135,6 @@ class Source_HistoryTheme extends Themelet {
|
|||
$page->add_block(new Block("Bulk Revert Results", $html));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* @param string $body
|
||||
*/
|
||||
public function add_status(string $title, string $body) {
|
||||
$this->messages[] = '<p><b>'. $title .'</b><br>'. $body .'</p>';
|
||||
}
|
||||
|
|
|
@ -18,8 +18,7 @@ function dstat($name, $val) {
|
|||
class StatsDInterface extends Extension {
|
||||
public static $stats = array();
|
||||
|
||||
/** @param string $type */
|
||||
private function _stats($type) {
|
||||
private function _stats(string $type) {
|
||||
global $_shm_event_count, $database, $_shm_load_start;
|
||||
$time = microtime(true) - $_shm_load_start;
|
||||
StatsDInterface::$stats["shimmie.$type.hits"] = "1|c";
|
||||
|
@ -81,16 +80,9 @@ class StatsDInterface extends Extension {
|
|||
StatsDInterface::$stats["shimmie_events.info-sets"] = "1|c";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority(): int {return 99;}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @param int $sampleRate
|
||||
*/
|
||||
private function send($data, $sampleRate=1) {
|
||||
private function send(array $data, int $sampleRate=1) {
|
||||
if (!STATSD_HOST) { return; }
|
||||
|
||||
// sampling
|
||||
|
|
|
@ -79,8 +79,7 @@ class TagSetEvent extends Event {
|
|||
public $metatags;
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @param string[] $tags
|
||||
* #param string[] $tags
|
||||
*/
|
||||
public function __construct(Image $image, array $tags) {
|
||||
$this->image = $image;
|
||||
|
@ -237,7 +236,6 @@ class TagEdit extends Extension {
|
|||
|
||||
/**
|
||||
* When an alias is added, oldtag becomes inaccessible.
|
||||
* @param AddAliasEvent $event
|
||||
*/
|
||||
public function onAddAlias(AddAliasEvent $event) {
|
||||
$this->mass_tag_edit($event->oldtag, $event->newtag);
|
||||
|
@ -261,29 +259,17 @@ class TagEdit extends Extension {
|
|||
if(!empty($matches)) $event->metatag = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @return bool
|
||||
*/
|
||||
private function can_tag(Image $image) {
|
||||
private function can_tag(Image $image): bool {
|
||||
global $user;
|
||||
return ($user->can("edit_image_tag") || !$image->is_locked());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @return bool
|
||||
*/
|
||||
private function can_source(Image $image) {
|
||||
private function can_source(Image $image): bool {
|
||||
global $user;
|
||||
return ($user->can("edit_image_source") || !$image->is_locked());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search
|
||||
* @param string $replace
|
||||
*/
|
||||
private function mass_tag_edit($search, $replace) {
|
||||
private function mass_tag_edit(string $search, string $replace) {
|
||||
global $database;
|
||||
|
||||
$search_set = Tag::explode(strtolower($search), false);
|
||||
|
|
|
@ -54,11 +54,7 @@ class TagEditCloud extends Extension {
|
|||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @return string
|
||||
*/
|
||||
private function build_tag_map(Image $image) {
|
||||
private function build_tag_map(Image $image): string {
|
||||
global $database, $config;
|
||||
|
||||
$html = "";
|
||||
|
@ -172,11 +168,7 @@ class TagEditCloud extends Extension {
|
|||
return "<div id='tageditcloud' class='tageditcloud'>{$html}</div>"; // FIXME: stupidasallhell
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @return bool
|
||||
*/
|
||||
private function can_tag(Image $image) {
|
||||
private function can_tag(Image $image): bool {
|
||||
global $user;
|
||||
return ($user->can("edit_image_tag") && (!$image->is_locked() || $user->can("edit_image_lock")));
|
||||
}
|
||||
|
|
|
@ -115,11 +115,8 @@ class Tag_History extends Extension {
|
|||
|
||||
/**
|
||||
* This function is called when a revert request is received.
|
||||
*
|
||||
* @param int $revert_id
|
||||
* @throws ImageDoesNotExist
|
||||
*/
|
||||
private function process_revert_request($revert_id) {
|
||||
private function process_revert_request(int $revert_id) {
|
||||
global $page;
|
||||
|
||||
$revert_id = int_escape($revert_id);
|
||||
|
@ -202,11 +199,7 @@ class Tag_History extends Extension {
|
|||
$this->theme->display_revert_ip_results();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $revert_id
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function get_tag_history_from_revert(int $revert_id) {
|
||||
public function get_tag_history_from_revert(int $revert_id): ?array {
|
||||
global $database;
|
||||
$row = $database->get_row("
|
||||
SELECT tag_histories.*, users.name
|
||||
|
@ -216,11 +209,7 @@ class Tag_History extends Extension {
|
|||
return ($row ? $row : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $image_id
|
||||
* @return array
|
||||
*/
|
||||
public function get_tag_history_from_id(int $image_id) {
|
||||
public function get_tag_history_from_id(int $image_id): array {
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
|
@ -232,11 +221,7 @@ class Tag_History extends Extension {
|
|||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $page_id
|
||||
* @return array
|
||||
*/
|
||||
public function get_global_tag_history($page_id) {
|
||||
public function get_global_tag_history(int $page_id): array {
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
|
@ -250,12 +235,8 @@ class Tag_History extends Extension {
|
|||
|
||||
/**
|
||||
* This function attempts to revert all changes by a given IP within an (optional) timeframe.
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $ip
|
||||
* @param string $date
|
||||
*/
|
||||
public function process_revert_all_changes($name, $ip, $date) {
|
||||
public function process_revert_all_changes(string $name, string $ip, string $date) {
|
||||
global $database;
|
||||
|
||||
$select_code = array();
|
||||
|
@ -350,8 +331,7 @@ class Tag_History extends Extension {
|
|||
/**
|
||||
* This function is called just before an images tag are changed.
|
||||
*
|
||||
* @param Image $image
|
||||
* @param string[] $tags
|
||||
* #param string[] $tags
|
||||
*/
|
||||
private function add_tag_history(Image $image, array $tags) {
|
||||
global $database, $config, $user;
|
||||
|
|
|
@ -7,11 +7,6 @@
|
|||
class Tag_HistoryTheme extends Themelet {
|
||||
private $messages = array();
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param int $image_id
|
||||
* @param array $history
|
||||
*/
|
||||
public function display_history_page(Page $page, int $image_id, array $history) {
|
||||
global $user;
|
||||
$start_string = "
|
||||
|
@ -67,11 +62,6 @@ class Tag_HistoryTheme extends Themelet {
|
|||
$page->add_block(new Block("Tag History", $history_html, "main", 10));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param array $history
|
||||
* @param int $page_number
|
||||
*/
|
||||
public function display_global_page(Page $page, array $history, int $page_number) {
|
||||
$start_string = "
|
||||
<div style='text-align: left'>
|
||||
|
@ -122,8 +112,6 @@ class Tag_HistoryTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* Add a section to the admin page.
|
||||
*
|
||||
* @param string $validation_msg
|
||||
*/
|
||||
public function display_admin_block(string $validation_msg='') {
|
||||
global $page;
|
||||
|
@ -159,10 +147,6 @@ class Tag_HistoryTheme extends Themelet {
|
|||
$page->add_block(new Block("Bulk Revert Results", $html));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $title
|
||||
* @param string $body
|
||||
*/
|
||||
public function add_status(string $title, string $body) {
|
||||
$this->messages[] = '<p><b>'. $title .'</b><br>'. $body .'</p>';
|
||||
}
|
||||
|
|
|
@ -133,11 +133,7 @@ class TagList extends Extension {
|
|||
}
|
||||
// }}}
|
||||
// misc {{{
|
||||
/**
|
||||
* @param string $tag
|
||||
* @return string
|
||||
*/
|
||||
private function tag_link(string $tag) {
|
||||
private function tag_link(string $tag): string {
|
||||
$u_tag = url_escape($tag);
|
||||
return make_link("post/list/$u_tag/1");
|
||||
}
|
||||
|
@ -145,10 +141,8 @@ class TagList extends Extension {
|
|||
/**
|
||||
* Get the minimum number of times a tag needs to be used
|
||||
* in order to be considered in the tag list.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private function get_tags_min() {
|
||||
private function get_tags_min(): int {
|
||||
if(isset($_GET['mincount'])) {
|
||||
return int_escape($_GET['mincount']);
|
||||
}
|
||||
|
@ -158,10 +152,7 @@ class TagList extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function get_starts_with() {
|
||||
private function get_starts_with(): string {
|
||||
global $config;
|
||||
if(isset($_GET['starts_with'])) {
|
||||
return $_GET['starts_with'] . "%";
|
||||
|
@ -176,10 +167,7 @@ class TagList extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function build_az() {
|
||||
private function build_az(): string {
|
||||
global $database;
|
||||
|
||||
$tags_min = $this->get_tags_min();
|
||||
|
@ -203,10 +191,7 @@ class TagList extends Extension {
|
|||
// }}}
|
||||
// maps {{{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function build_navigation() {
|
||||
private function build_navigation(): string {
|
||||
$h_index = "<a href='".make_link()."'>Index</a>";
|
||||
$h_map = "<a href='".make_link("tags/map")."'>Map</a>";
|
||||
$h_alphabetic = "<a href='".make_link("tags/alphabetic")."'>Alphabetic</a>";
|
||||
|
@ -216,10 +201,7 @@ class TagList extends Extension {
|
|||
return "$h_index<br> <br>$h_map<br>$h_alphabetic<br>$h_popularity<br>$h_cats<br> <br>$h_all";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function build_tag_map() {
|
||||
private function build_tag_map(): string {
|
||||
global $config, $database;
|
||||
|
||||
$tags_min = $this->get_tags_min();
|
||||
|
@ -256,10 +238,7 @@ class TagList extends Extension {
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function build_tag_alphabetic() {
|
||||
private function build_tag_alphabetic(): string {
|
||||
global $config, $database;
|
||||
|
||||
$tags_min = $this->get_tags_min();
|
||||
|
@ -315,10 +294,7 @@ class TagList extends Extension {
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function build_tag_popularity() {
|
||||
private function build_tag_popularity(): string {
|
||||
global $database;
|
||||
|
||||
$tags_min = $this->get_tags_min();
|
||||
|
@ -357,10 +333,7 @@ class TagList extends Extension {
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
private function build_tag_list() {
|
||||
private function build_tag_list(): string {
|
||||
global $database;
|
||||
|
||||
//$tags_min = $this->get_tags_min();
|
||||
|
@ -386,10 +359,6 @@ class TagList extends Extension {
|
|||
}
|
||||
// }}}
|
||||
// blocks {{{
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image $image
|
||||
*/
|
||||
private function add_related_block(Page $page, Image $image) {
|
||||
global $database, $config;
|
||||
|
||||
|
@ -421,10 +390,6 @@ class TagList extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image $image
|
||||
*/
|
||||
private function add_split_tags_block(Page $page, Image $image) {
|
||||
global $database;
|
||||
|
||||
|
@ -443,10 +408,6 @@ class TagList extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image $image
|
||||
*/
|
||||
private function add_tags_block(Page $page, Image $image) {
|
||||
global $database;
|
||||
|
||||
|
@ -465,9 +426,6 @@ class TagList extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
*/
|
||||
private function add_popular_block(Page $page) {
|
||||
global $database, $config;
|
||||
|
||||
|
@ -491,8 +449,7 @@ class TagList extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param string[] $search
|
||||
* #param string[] $search
|
||||
*/
|
||||
private function add_refine_block(Page $page, array $search) {
|
||||
global $database, $config;
|
||||
|
|
|
@ -3,26 +3,20 @@
|
|||
class TagListTheme extends Themelet {
|
||||
/** @var string */
|
||||
public $heading = "";
|
||||
/** @var string|string[] */
|
||||
/** @var string */
|
||||
public $list = "";
|
||||
|
||||
public $navigation;
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
*/
|
||||
public function set_heading($text) {
|
||||
public function set_heading(string $text) {
|
||||
$this->heading = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|string[] $list
|
||||
*/
|
||||
public function set_tag_list($list) {
|
||||
public function set_tag_list(string $list) {
|
||||
$this->list = $list;
|
||||
}
|
||||
|
||||
public function set_navigation($nav) {
|
||||
public function set_navigation(string $nav) {
|
||||
$this->navigation = $nav;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,7 @@ class TaggerXML extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/** @param string $s */
|
||||
private function match_tag_list ($s) {
|
||||
private function match_tag_list (string $s) {
|
||||
global $database, $config;
|
||||
|
||||
$max_rows = $config->get_int("ext_tagger_tag_max",30);
|
||||
|
@ -102,8 +101,7 @@ class TaggerXML extends Extension {
|
|||
return $this->list_to_xml($tags,"search",$s,$count);
|
||||
}
|
||||
|
||||
/** @param int $image_id */
|
||||
private function image_tag_list ($image_id) {
|
||||
private function image_tag_list (int $image_id) {
|
||||
global $database;
|
||||
$tags = $database->Execute("
|
||||
SELECT tags.*
|
||||
|
@ -112,13 +110,7 @@ class TaggerXML extends Extension {
|
|||
return $this->list_to_xml($tags,"image",$image_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PDOStatement $tags
|
||||
* @param string $type
|
||||
* @param string $query
|
||||
* @param array $misc
|
||||
*/
|
||||
private function list_to_xml ($tags,$type,$query,$misc=null) {
|
||||
private function list_to_xml (PDOStatement $tags, string $type, string $query, ?array$misc=null): string {
|
||||
$r = $tags->_numOfRows;
|
||||
|
||||
$s_misc = "";
|
||||
|
@ -132,7 +124,7 @@ class TaggerXML extends Extension {
|
|||
return $result."</list>";
|
||||
}
|
||||
|
||||
private function tag_to_xml ($tag) {
|
||||
private function tag_to_xml (string $tag): string {
|
||||
return
|
||||
"<tag ".
|
||||
"id=\"".$tag['id']."\" ".
|
||||
|
@ -141,7 +133,7 @@ class TaggerXML extends Extension {
|
|||
"</tag>";
|
||||
}
|
||||
|
||||
private function count($query,$values) {
|
||||
private function count(string $query, $values) {
|
||||
global $database;
|
||||
return $database->Execute(
|
||||
"SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)'];
|
||||
|
|
|
@ -46,10 +46,7 @@ class Update extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function download_shimmie() {
|
||||
private function download_shimmie(): bool {
|
||||
global $config;
|
||||
|
||||
$commitSHA = $_GET['sha'];
|
||||
|
@ -73,10 +70,7 @@ class Update extends Extension {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function update_shimmie() {
|
||||
private function update_shimmie(): bool {
|
||||
global $config;
|
||||
|
||||
$commitSHA = $_GET['sha'];
|
||||
|
|
|
@ -129,9 +129,6 @@ class Upgrade extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority(): int {return 5;}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,7 @@ class DataUploadEvent extends Event {
|
|||
/**
|
||||
* Some data is being uploaded.
|
||||
* This should be caught by a file handler.
|
||||
* @param string $tmpname The temporary file used for upload.
|
||||
* @param array $metadata Info about the file, should contain at least "filename", "extension", "tags" and "source".
|
||||
* $metadata should contain at least "filename", "extension", "tags" and "source".
|
||||
*/
|
||||
public function __construct(string $tmpname, array $metadata) {
|
||||
assert(file_exists($tmpname));
|
||||
|
@ -59,7 +58,6 @@ class Upload extends Extension {
|
|||
|
||||
/**
|
||||
* Early, so it can stop the DataUploadEvent before any data handlers see it.
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority(): int {return 40;}
|
||||
|
||||
|
@ -234,11 +232,7 @@ class Upload extends Extension {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return string[]
|
||||
*/
|
||||
private function tags_for_upload_slot($id) {
|
||||
private function tags_for_upload_slot(int $id): array {
|
||||
$post_tags = isset($_POST["tags"]) ? $_POST["tags"] : "";
|
||||
|
||||
if(isset($_POST["tags$id"])) {
|
||||
|
@ -261,11 +255,8 @@ class Upload extends Extension {
|
|||
* which is licensed under Creative Commons Attribution 3.0 License
|
||||
*
|
||||
* TODO: Make these messages user/admin editable
|
||||
*
|
||||
* @param int $error_code PHP error code
|
||||
* @return string
|
||||
*/
|
||||
private function upload_error_message($error_code) {
|
||||
private function upload_error_message(int $error_code): string {
|
||||
switch ($error_code) {
|
||||
case UPLOAD_ERR_INI_SIZE:
|
||||
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
|
||||
|
@ -288,13 +279,10 @@ class Upload extends Extension {
|
|||
|
||||
/**
|
||||
* Handle an upload.
|
||||
* @param string[] $file
|
||||
* @param string[] $tags
|
||||
* @param string|null $source
|
||||
* @param int $replace
|
||||
* @return bool TRUE on upload successful.
|
||||
* #param string[] $file
|
||||
* #param string[] $tags
|
||||
*/
|
||||
private function try_upload(array $file, array $tags, string $source=null, int $replace=-1): bool {
|
||||
private function try_upload(array $file, array $tags, ?string $source=null, int $replace=-1): bool {
|
||||
global $page;
|
||||
|
||||
if(empty($source)) $source = null;
|
||||
|
|
|
@ -37,10 +37,7 @@ class UploadTheme extends Themelet {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function h_upload_list_1() {
|
||||
protected function h_upload_list_1(): string {
|
||||
global $config;
|
||||
$upload_list = "";
|
||||
$upload_count = $config->get_int('upload_count');
|
||||
|
@ -86,10 +83,7 @@ class UploadTheme extends Themelet {
|
|||
return $upload_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function h_upload_List_2() {
|
||||
protected function h_upload_List_2(): string {
|
||||
global $config;
|
||||
|
||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||
|
@ -186,10 +180,7 @@ class UploadTheme extends Themelet {
|
|||
return $upload_list;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function h_bookmarklets() {
|
||||
protected function h_bookmarklets(): string {
|
||||
global $config;
|
||||
$link = make_http(make_link("upload"));
|
||||
$main_page = make_http(make_link());
|
||||
|
@ -244,9 +235,6 @@ class UploadTheme extends Themelet {
|
|||
|
||||
/**
|
||||
* Only allows 1 file to be uploaded - for replacing another image file.
|
||||
*
|
||||
* @param Page $page
|
||||
* @param int $image_id
|
||||
*/
|
||||
public function display_replace_page(Page $page, int $image_id) {
|
||||
global $config, $page;
|
||||
|
@ -305,19 +293,11 @@ class UploadTheme extends Themelet {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param string $title
|
||||
* @param string $message
|
||||
*/
|
||||
public function display_upload_error(Page $page, string $title, string $message) {
|
||||
$page->add_block(new Block($title, $message));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function build_upload_block() {
|
||||
protected function build_upload_block(): string {
|
||||
global $config;
|
||||
|
||||
$upload_list = "";
|
||||
|
|
|
@ -10,9 +10,7 @@ class UserPageTheme extends Themelet {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param User[] $users
|
||||
* @param User $user
|
||||
* #param User[] $users
|
||||
*/
|
||||
public function display_user_list(Page $page, array $users, User $user, int $page_num, int $page_total) {
|
||||
$page->set_title("User List");
|
||||
|
|
|
@ -35,8 +35,5 @@ class VarnishPurger extends Extension {
|
|||
$this->curl_purge("post/view/{$event->image->id}");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function get_priority(): int {return 99;}
|
||||
}
|
||||
|
|
|
@ -47,10 +47,7 @@ class ViewImageTheme extends Themelet {
|
|||
return "$h_prev | $h_index | $h_next";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function build_navigation(Image $image) {
|
||||
protected function build_navigation(Image $image): string {
|
||||
$h_pin = $this->build_pin($image);
|
||||
$h_search = "
|
||||
<p><form action='".make_link()."' method='GET'>
|
||||
|
|
|
@ -63,10 +63,7 @@ class WikiPage {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|User
|
||||
*/
|
||||
public function get_owner() {
|
||||
public function get_owner(): User {
|
||||
return User::by_id($this->owner_id);
|
||||
}
|
||||
|
||||
|
@ -190,10 +187,6 @@ class Wiki extends Extension {
|
|||
|
||||
/**
|
||||
* See if the given user is allowed to edit the given page.
|
||||
*
|
||||
* @param User $user
|
||||
* @param WikiPage $page
|
||||
* @return bool
|
||||
*/
|
||||
public static function can_edit(User $user, WikiPage $page): bool {
|
||||
// admins can edit everything
|
||||
|
@ -479,12 +472,8 @@ class Wiki extends Extension {
|
|||
|
||||
/**
|
||||
* callback function to format the diffence-lines with your 'style'
|
||||
* @param integer $nr1
|
||||
* @param integer $nr2
|
||||
* @param string $stat
|
||||
* @return string
|
||||
*/
|
||||
private function formatline( $nr1, $nr2, $stat, &$value ) { #change to $value if problems
|
||||
*/
|
||||
private function formatline(int $nr1, int $nr2, string $stat, &$value ): string { #change to $value if problems
|
||||
if(trim($value) == "") {
|
||||
return "";
|
||||
}
|
||||
|
|
|
@ -4,11 +4,10 @@ class WikiTheme extends Themelet {
|
|||
/**
|
||||
* Show a page.
|
||||
*
|
||||
* @param Page $page The shimmie page object
|
||||
* @param WikiPage $wiki_page The wiki page, has ->title and ->body
|
||||
* @param WikiPage|null $nav_page A wiki page object with navigation, has ->body
|
||||
* $wiki_page The wiki page, has ->title and ->body
|
||||
* $nav_page A wiki page object with navigation, has ->body
|
||||
*/
|
||||
public function display_page(Page $page, WikiPage $wiki_page, WikiPage $nav_page=null) {
|
||||
public function display_page(Page $page, WikiPage $wiki_page, ?WikiPage $nav_page=null) {
|
||||
global $user;
|
||||
|
||||
if(is_null($nav_page)) {
|
||||
|
|
|
@ -23,11 +23,7 @@ class WordFilter extends Extension {
|
|||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $text
|
||||
* @return string
|
||||
*/
|
||||
private function filter(string $text) {
|
||||
private function filter(string $text): string {
|
||||
$map = $this->get_map();
|
||||
foreach($map as $search => $replace) {
|
||||
$search = trim($search);
|
||||
|
@ -44,9 +40,9 @@ class WordFilter extends Extension {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
* #return string[]
|
||||
*/
|
||||
private function get_map() {
|
||||
private function get_map(): array {
|
||||
global $config;
|
||||
$raw = $config->get_string("word_filter");
|
||||
$lines = explode("\n", $raw);
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
<?php
|
||||
|
||||
class CustomCommentListTheme extends CommentListTheme {
|
||||
/**
|
||||
* @param array $images
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param bool $can_post
|
||||
*/
|
||||
public function display_comment_list($images, $page_number, $total_pages, $can_post) {
|
||||
public function display_comment_list(array $images, int $page_number, int $total_pages, bool $can_post) {
|
||||
global $config, $page, $user;
|
||||
|
||||
$page->disable_left();
|
||||
|
@ -88,16 +82,11 @@ class CustomCommentListTheme extends CommentListTheme {
|
|||
}
|
||||
}
|
||||
|
||||
public function display_recent_comments($comments) {
|
||||
public function display_recent_comments(array $comments) {
|
||||
// no recent comments in this theme
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Comment $comment
|
||||
* @param bool $trim
|
||||
* @return string
|
||||
*/
|
||||
protected function comment_to_html(Comment $comment, $trim=false) {
|
||||
protected function comment_to_html(Comment $comment, bool $trim=false): string {
|
||||
global $user;
|
||||
|
||||
$tfe = new TextFormattingEvent($comment->comment);
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
class CustomIndexTheme extends IndexTheme {
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image[] $images
|
||||
* #param Image[] $images
|
||||
*/
|
||||
public function display_page(Page $page, $images) {
|
||||
public function display_page(Page $page, array $images) {
|
||||
global $config;
|
||||
|
||||
if(count($this->search_terms) == 0) {
|
||||
|
@ -38,12 +37,9 @@ class CustomIndexTheme extends IndexTheme {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param string[] $search_terms
|
||||
* @return string
|
||||
* #param string[] $search_terms
|
||||
*/
|
||||
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
||||
protected function build_navigation(int $page_number, int $total_pages, array $search_terms): string {
|
||||
$h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
|
||||
$h_search_link = make_link();
|
||||
$h_search = "
|
||||
|
@ -57,12 +53,7 @@ class CustomIndexTheme extends IndexTheme {
|
|||
return $h_search;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image[] $images
|
||||
* @param string $query
|
||||
* @return string
|
||||
*/
|
||||
protected function build_table($images, $query) {
|
||||
protected function build_table(array $images, string $query): string {
|
||||
$h_query = html_escape($query);
|
||||
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
||||
foreach($images as $image) {
|
||||
|
|
|
@ -234,12 +234,9 @@ EOD;
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $link
|
||||
* @param string $desc
|
||||
* @param string[] $pages_matched
|
||||
* @return string
|
||||
* #param string[] $pages_matched
|
||||
*/
|
||||
private function navlinks($link, $desc, $pages_matched) {
|
||||
private function navlinks(string $link, string $desc, array $pages_matched): string {
|
||||
/**
|
||||
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
|
||||
*/
|
||||
|
|
|
@ -1,54 +1,24 @@
|
|||
<?php
|
||||
class Themelet extends BaseThemelet {
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param string $base
|
||||
* @param string $query
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param bool $show_random
|
||||
*/
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $show_random = FALSE) {
|
||||
public function display_paginator(Page $page, string $base, ?string $query, int $page_number, int $total_pages, bool $show_random = FALSE) {
|
||||
if($total_pages == 0) $total_pages = 1;
|
||||
$body = $this->build_paginator($page_number, $total_pages, $base, $query);
|
||||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $base_url
|
||||
* @param string $query
|
||||
* @param int|string $page
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
private function gen_page_link($base_url, $query, $page, $name) {
|
||||
private function gen_page_link(string $base_url, string $query, string $page, string $name): string {
|
||||
$link = make_link("$base_url/$page", $query);
|
||||
return "<a href='$link'>$name</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $base_url
|
||||
* @param string $query
|
||||
* @param int|string $page
|
||||
* @param int $current_page
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
|
||||
private function gen_page_link_block(string $base_url, string $query, int $page, int $current_page, string $name): string {
|
||||
$paginator = "";
|
||||
if($page == $current_page) $paginator .= "<b>$page</b>";
|
||||
else $paginator .= $this->gen_page_link($base_url, $query, $page, $name);
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $current_page
|
||||
* @param int $total_pages
|
||||
* @param string $base_url
|
||||
* @param string $query
|
||||
* @return string
|
||||
*/
|
||||
private function build_paginator($current_page, $total_pages, $base_url, $query) {
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, string $query): string {
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
|
||||
|
|
|
@ -76,12 +76,7 @@ class CustomUserPageTheme extends UserPageTheme {
|
|||
$page->add_block(new Block("Signup", $html));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param array $uploads
|
||||
* @param array $comments
|
||||
*/
|
||||
public function display_ip_list(Page $page, $uploads, $comments) {
|
||||
public function display_ip_list(Page $page, array $uploads, array $comments) {
|
||||
$html = "<table id='ip-history' style='width: 400px;'>";
|
||||
$html .= "<tr><td>Uploaded from: ";
|
||||
foreach($uploads as $ip => $count) {
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
<?php
|
||||
|
||||
class CustomExtManagerTheme extends ExtManagerTheme {
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param array $extensions
|
||||
* @param bool $editable
|
||||
*/
|
||||
public function display_table(Page $page, array $extensions, bool $editable) {
|
||||
$page->disable_left();
|
||||
parent::display_table($page, $extensions, $editable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param ExtensionInfo $info
|
||||
*/
|
||||
public function display_doc(Page $page, ExtensionInfo $info) {
|
||||
$page->disable_left();
|
||||
parent::display_doc($page, $info);
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
class CustomIndexTheme extends IndexTheme {
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param Image[] $images
|
||||
* #param Image[] $images
|
||||
*/
|
||||
public function display_page(Page $page, $images) {
|
||||
public function display_page(Page $page, array $images) {
|
||||
global $config;
|
||||
|
||||
if(count($this->search_terms) == 0) {
|
||||
|
@ -38,12 +37,9 @@ class CustomIndexTheme extends IndexTheme {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param string[] $search_terms
|
||||
* @return string
|
||||
* #param string[] $search_terms
|
||||
*/
|
||||
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
||||
protected function build_navigation(int $page_number, int $total_pages, array $search_terms): string {
|
||||
$h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
|
||||
$h_search_link = make_link();
|
||||
$h_search = "
|
||||
|
@ -58,11 +54,9 @@ class CustomIndexTheme extends IndexTheme {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param Image[] $images
|
||||
* @param string $query
|
||||
* @return string
|
||||
* #param Image[] $images
|
||||
*/
|
||||
protected function build_table($images, $query) {
|
||||
protected function build_table(array $images, string $query): string {
|
||||
$h_query = html_escape($query);
|
||||
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
||||
foreach($images as $image) {
|
||||
|
|
|
@ -259,16 +259,7 @@ $header_html
|
|||
EOD;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $link
|
||||
* @param string $desc
|
||||
* @param string[] $pages_matched
|
||||
* @return string
|
||||
*/
|
||||
private function navlinks($link, $desc, $pages_matched) {
|
||||
/**
|
||||
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
|
||||
*/
|
||||
private function navlinks(string $link, string $desc, array $pages_matched): string {
|
||||
$html = "";
|
||||
$url = _get_query();
|
||||
|
||||
|
|
|
@ -1,54 +1,24 @@
|
|||
<?php
|
||||
class Themelet extends BaseThemelet {
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param string $base
|
||||
* @param string $query
|
||||
* @param int $page_number
|
||||
* @param int $total_pages
|
||||
* @param bool $show_random
|
||||
*/
|
||||
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages, $show_random = FALSE) {
|
||||
public function display_paginator(Page $page, string $base, ?string $query, int $page_number, int $total_pages, bool $show_random = FALSE) {
|
||||
if($total_pages == 0) $total_pages = 1;
|
||||
$body = $this->build_paginator($page_number, $total_pages, $base, $query);
|
||||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $base_url
|
||||
* @param string $query
|
||||
* @param int|string $page
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
private function gen_page_link($base_url, $query, $page, $name) {
|
||||
private function gen_page_link(string $base_url, string $query, string $page, string $name): string {
|
||||
$link = make_link("$base_url/$page", $query);
|
||||
return "<a href='$link'>$name</a>";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $base_url
|
||||
* @param string $query
|
||||
* @param int|string $page
|
||||
* @param int $current_page
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
|
||||
private function gen_page_link_block(string $base_url, string $query, int $page, int $current_page, string $name): string {
|
||||
$paginator = "";
|
||||
if($page == $current_page) $paginator .= "<b>$page</b>";
|
||||
else $paginator .= $this->gen_page_link($base_url, $query, $page, $name);
|
||||
return $paginator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $current_page
|
||||
* @param int $total_pages
|
||||
* @param string $base_url
|
||||
* @param string $query
|
||||
* @return string
|
||||
*/
|
||||
private function build_paginator($current_page, $total_pages, $base_url, $query) {
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, string $query): string {
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
|
||||
|
|
|
@ -76,12 +76,7 @@ class CustomUserPageTheme extends UserPageTheme {
|
|||
$page->add_block(new Block("Signup", $html));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Page $page
|
||||
* @param array $uploads
|
||||
* @param array $comments
|
||||
*/
|
||||
public function display_ip_list(Page $page, $uploads, $comments) {
|
||||
public function display_ip_list(Page $page, array $uploads, array $comments) {
|
||||
$html = "<table id='ip-history' style='width: 400px;'>";
|
||||
$html .= "<tr><td>Uploaded from: ";
|
||||
foreach($uploads as $ip => $count) {
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
<?php
|
||||
|
||||
class CustomViewImageTheme extends ViewImageTheme {
|
||||
/**
|
||||
* @param Image $image
|
||||
* @param $editor_parts
|
||||
*/
|
||||
public function display_page(Image $image, $editor_parts) {
|
||||
global $page;
|
||||
$page->set_title("Image {$image->id}: ".html_escape($image->get_tag_list()));
|
||||
|
@ -14,11 +10,7 @@ class CustomViewImageTheme extends ViewImageTheme {
|
|||
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 15));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @return string
|
||||
*/
|
||||
private function build_information(Image $image) {
|
||||
private function build_information(Image $image): string {
|
||||
$h_owner = html_escape($image->get_owner()->name);
|
||||
$h_ownerlink = "<a href='".make_link("user/$h_owner")."'>$h_owner</a>";
|
||||
$h_ip = html_escape($image->owner_ip);
|
||||
|
@ -58,11 +50,7 @@ class CustomViewImageTheme extends ViewImageTheme {
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Image $image
|
||||
* @return string
|
||||
*/
|
||||
protected function build_navigation(Image $image) {
|
||||
protected function build_navigation(Image $image): string {
|
||||
//$h_pin = $this->build_pin($image);
|
||||
$h_search = "
|
||||
<form action='".make_link()."' method='GET'>
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
class Layout {
|
||||
/**
|
||||
* turns the Page into HTML
|
||||
*
|
||||
* @param Page $page
|
||||
*/
|
||||
public function display_page(Page $page) {
|
||||
global $config;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue