drop php7.3 support, make use of 7.4 features
This commit is contained in:
parent
c558ee3bdb
commit
77f7121e26
296 changed files with 1571 additions and 2039 deletions
2
.github/workflows/test_and_publish.yml
vendored
2
.github/workflows/test_and_publish.yml
vendored
|
@ -22,7 +22,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
php: ['7.3', '7.4', '8.0']
|
php: ['7.4', '8.0']
|
||||||
database: ['pgsql', 'mysql', 'sqlite']
|
database: ['pgsql', 'mysql', 'sqlite']
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
],
|
],
|
||||||
|
|
||||||
"require" : {
|
"require" : {
|
||||||
"php" : "^7.3 | ^8.0",
|
"php" : "^7.4 | ^8.0",
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-fileinfo": "*",
|
"ext-fileinfo": "*",
|
||||||
|
|
|
@ -20,10 +20,8 @@ abstract class PageMode
|
||||||
*/
|
*/
|
||||||
class BasePage
|
class BasePage
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $mode = PageMode::PAGE;
|
||||||
public $mode = PageMode::PAGE;
|
private string $mime;
|
||||||
/** @var string */
|
|
||||||
private $mime;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set what this page should do; "page", "data", or "redirect".
|
* Set what this page should do; "page", "data", or "redirect".
|
||||||
|
@ -52,19 +50,11 @@ class BasePage
|
||||||
|
|
||||||
// ==============================================
|
// ==============================================
|
||||||
|
|
||||||
/** @var string; public only for unit test */
|
public string $data = ""; // public only for unit test
|
||||||
public $data = "";
|
private ?string $file = null;
|
||||||
|
private bool $file_delete = false;
|
||||||
/** @var string */
|
private ?string $filename = null;
|
||||||
private $file = null;
|
private ?string $disposition = null;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $file_delete = false;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $filename = null;
|
|
||||||
|
|
||||||
private $disposition = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the raw data to be sent.
|
* Set the raw data to be sent.
|
||||||
|
@ -91,8 +81,7 @@ class BasePage
|
||||||
|
|
||||||
// ==============================================
|
// ==============================================
|
||||||
|
|
||||||
/** @var string */
|
public string $redirect = "";
|
||||||
public $redirect = "";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the URL to redirect to (remember to use make_link() if linking
|
* Set the URL to redirect to (remember to use make_link() if linking
|
||||||
|
@ -105,32 +94,25 @@ class BasePage
|
||||||
|
|
||||||
// ==============================================
|
// ==============================================
|
||||||
|
|
||||||
/** @var int */
|
public int $code = 200;
|
||||||
public $code = 200;
|
public string $title = "";
|
||||||
|
public string $heading = "";
|
||||||
/** @var string */
|
public string $subheading = "";
|
||||||
public $title = "";
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $heading = "";
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $subheading = "";
|
|
||||||
|
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
public $html_headers = [];
|
public array $html_headers = [];
|
||||||
|
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
public $http_headers = [];
|
public array $http_headers = [];
|
||||||
|
|
||||||
/** @var string[][] */
|
/** @var string[][] */
|
||||||
public $cookies = [];
|
public array $cookies = [];
|
||||||
|
|
||||||
/** @var Block[] */
|
/** @var Block[] */
|
||||||
public $blocks = [];
|
public array $blocks = [];
|
||||||
|
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
public $flash = [];
|
public array $flash = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the HTTP status code
|
* Set the HTTP status code
|
||||||
|
@ -428,7 +410,7 @@ class BasePage
|
||||||
$this->add_html_header("<script defer src='$data_href/$js_cache_file' type='text/javascript'></script>", 44);
|
$this->add_html_header("<script defer src='$data_href/$js_cache_file' type='text/javascript'></script>", 44);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function get_nav_links()
|
protected function get_nav_links(): array
|
||||||
{
|
{
|
||||||
$pnbe = send_event(new PageNavBuildingEvent());
|
$pnbe = send_event(new PageNavBuildingEvent());
|
||||||
|
|
||||||
|
@ -574,7 +556,7 @@ EOD;
|
||||||
|
|
||||||
class PageNavBuildingEvent extends Event
|
class PageNavBuildingEvent extends Event
|
||||||
{
|
{
|
||||||
public $links = [];
|
public array $links = [];
|
||||||
|
|
||||||
public function add_nav_link(string $name, Link $link, string $desc, ?bool $active = null, int $order = 50)
|
public function add_nav_link(string $name, Link $link, string $desc, ?bool $active = null, int $order = 50)
|
||||||
{
|
{
|
||||||
|
@ -584,9 +566,9 @@ class PageNavBuildingEvent extends Event
|
||||||
|
|
||||||
class PageSubNavBuildingEvent extends Event
|
class PageSubNavBuildingEvent extends Event
|
||||||
{
|
{
|
||||||
public $parent;
|
public string $parent;
|
||||||
|
|
||||||
public $links = [];
|
public array $links = [];
|
||||||
|
|
||||||
public function __construct(string $parent)
|
public function __construct(string $parent)
|
||||||
{
|
{
|
||||||
|
@ -602,11 +584,11 @@ class PageSubNavBuildingEvent extends Event
|
||||||
|
|
||||||
class NavLink
|
class NavLink
|
||||||
{
|
{
|
||||||
public $name;
|
public string $name;
|
||||||
public $link;
|
public Link $link;
|
||||||
public $description;
|
public string $description;
|
||||||
public $order;
|
public int $order;
|
||||||
public $active = false;
|
public bool $active = false;
|
||||||
|
|
||||||
public function __construct(String $name, Link $link, String $description, ?bool $active = null, int $order = 50)
|
public function __construct(String $name, Link $link, String $description, ?bool $active = null, int $order = 50)
|
||||||
{
|
{
|
||||||
|
@ -663,7 +645,7 @@ class NavLink
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort_nav_links(NavLink $a, NavLink $b)
|
function sort_nav_links(NavLink $a, NavLink $b): int
|
||||||
{
|
{
|
||||||
return $a->order - $b->order;
|
return $a->order - $b->order;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,49 +9,37 @@ class Block
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The block's title.
|
* The block's title.
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $header;
|
public ?string $header;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The content of the block.
|
* The content of the block.
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $body;
|
public ?string $body;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where the block should be placed. The default theme supports
|
* Where the block should be placed. The default theme supports
|
||||||
* "main" and "left", other themes can add their own areas.
|
* "main" and "left", other themes can add their own areas.
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $section;
|
public string $section;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How far down the section the block should appear, higher
|
* How far down the section the block should appear, higher
|
||||||
* numbers appear lower. The scale is 0-100 by convention,
|
* numbers appear lower. The scale is 0-100 by convention,
|
||||||
* though any number will work.
|
* though any number will work.
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
public $position;
|
public int $position;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A unique ID for the block.
|
* A unique ID for the block.
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $id;
|
public string $id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should this block count as content for the sake of
|
* Should this block count as content for the sake of
|
||||||
* the 404 handler
|
* the 404 handler
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
*/
|
||||||
public $is_content = true;
|
public bool $is_content = true;
|
||||||
|
|
||||||
public function __construct(string $header=null, string $body=null, string $section="main", int $position=50, string $id=null)
|
public function __construct(string $header=null, string $body=null, string $section="main", int $position=50, string $id=null)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +51,9 @@ class Block
|
||||||
if (is_null($id)) {
|
if (is_null($id)) {
|
||||||
$id = (empty($header) ? md5($body ?? '') : $header) . $section;
|
$id = (empty($header) ? md5($body ?? '') : $header) . $section;
|
||||||
}
|
}
|
||||||
$this->id = preg_replace('/[^\w-]/', '', str_replace(' ', '_', $id));
|
$str_id = preg_replace('/[^\w-]/', '', str_replace(' ', '_', $id));
|
||||||
|
assert(is_string($str_id));
|
||||||
|
$this->id = $str_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
interface CacheEngine
|
interface CacheEngine
|
||||||
{
|
{
|
||||||
public function get(string $key);
|
public function get(string $key);
|
||||||
public function set(string $key, $val, int $time=0);
|
public function set(string $key, $val, int $time=0): void;
|
||||||
public function delete(string $key);
|
public function delete(string $key): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
class NoCache implements CacheEngine
|
class NoCache implements CacheEngine
|
||||||
|
@ -12,18 +12,17 @@ class NoCache implements CacheEngine
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public function set(string $key, $val, int $time=0)
|
public function set(string $key, $val, int $time=0): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public function delete(string $key)
|
public function delete(string $key): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class MemcachedCache implements CacheEngine
|
class MemcachedCache implements CacheEngine
|
||||||
{
|
{
|
||||||
/** @var ?Memcached */
|
public ?Memcached $memcache=null;
|
||||||
public $memcache=null;
|
|
||||||
|
|
||||||
public function __construct(string $args)
|
public function __construct(string $args)
|
||||||
{
|
{
|
||||||
|
@ -52,7 +51,7 @@ class MemcachedCache implements CacheEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set(string $key, $val, int $time=0)
|
public function set(string $key, $val, int $time=0): void
|
||||||
{
|
{
|
||||||
$key = urlencode($key);
|
$key = urlencode($key);
|
||||||
|
|
||||||
|
@ -63,7 +62,7 @@ class MemcachedCache implements CacheEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(string $key)
|
public function delete(string $key): void
|
||||||
{
|
{
|
||||||
$key = urlencode($key);
|
$key = urlencode($key);
|
||||||
|
|
||||||
|
@ -87,12 +86,12 @@ class APCCache implements CacheEngine
|
||||||
return apc_fetch($key);
|
return apc_fetch($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set(string $key, $val, int $time=0)
|
public function set(string $key, $val, int $time=0): void
|
||||||
{
|
{
|
||||||
apc_store($key, $val, $time);
|
apc_store($key, $val, $time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(string $key)
|
public function delete(string $key): void
|
||||||
{
|
{
|
||||||
apc_delete($key);
|
apc_delete($key);
|
||||||
}
|
}
|
||||||
|
@ -100,7 +99,7 @@ class APCCache implements CacheEngine
|
||||||
|
|
||||||
class RedisCache implements CacheEngine
|
class RedisCache implements CacheEngine
|
||||||
{
|
{
|
||||||
private $redis=null;
|
private Redis $redis;
|
||||||
|
|
||||||
public function __construct(string $args)
|
public function __construct(string $args)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +115,7 @@ class RedisCache implements CacheEngine
|
||||||
return $this->redis->get($key);
|
return $this->redis->get($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set(string $key, $val, int $time=0)
|
public function set(string $key, $val, int $time=0): void
|
||||||
{
|
{
|
||||||
if ($time > 0) {
|
if ($time > 0) {
|
||||||
$this->redis->setEx($key, $time, $val);
|
$this->redis->setEx($key, $time, $val);
|
||||||
|
@ -125,7 +124,7 @@ class RedisCache implements CacheEngine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete(string $key)
|
public function delete(string $key): void
|
||||||
{
|
{
|
||||||
$this->redis->del($key);
|
$this->redis->del($key);
|
||||||
}
|
}
|
||||||
|
@ -134,9 +133,9 @@ class RedisCache implements CacheEngine
|
||||||
class Cache
|
class Cache
|
||||||
{
|
{
|
||||||
public $engine;
|
public $engine;
|
||||||
public $hits=0;
|
public int $hits=0;
|
||||||
public $misses=0;
|
public int $misses=0;
|
||||||
public $time=0;
|
public int $time=0;
|
||||||
|
|
||||||
public function __construct(?string $dsn)
|
public function __construct(?string $dsn)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
// quotes are only needed if the path to convert contains a space; some other times, quotes break things, see github bug #27
|
// quotes are only needed if the path to convert contains a space; some other times, quotes break things, see github bug #27
|
||||||
class CommandBuilder
|
class CommandBuilder
|
||||||
{
|
{
|
||||||
private $executable;
|
private string $executable;
|
||||||
private $args = [];
|
private array $args = [];
|
||||||
public $output;
|
public array $output;
|
||||||
|
|
||||||
public function __construct(String $executable)
|
public function __construct(String $executable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,7 +130,7 @@ interface Config
|
||||||
*/
|
*/
|
||||||
abstract class BaseConfig implements Config
|
abstract class BaseConfig implements Config
|
||||||
{
|
{
|
||||||
public $values = [];
|
public array $values = [];
|
||||||
|
|
||||||
public function set_int(string $name, ?int $value): void
|
public function set_int(string $name, ?int $value): void
|
||||||
{
|
{
|
||||||
|
@ -256,12 +256,10 @@ abstract class BaseConfig implements Config
|
||||||
*/
|
*/
|
||||||
class DatabaseConfig extends BaseConfig
|
class DatabaseConfig extends BaseConfig
|
||||||
{
|
{
|
||||||
/** @var Database */
|
private Database $database;
|
||||||
private $database = null;
|
private string $table_name;
|
||||||
|
private ?string $sub_column;
|
||||||
private $table_name;
|
private ?string $sub_value;
|
||||||
private $sub_column;
|
|
||||||
private $sub_value;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Database $database,
|
Database $database,
|
||||||
|
|
|
@ -13,30 +13,23 @@ abstract class DatabaseDriver
|
||||||
*/
|
*/
|
||||||
class Database
|
class Database
|
||||||
{
|
{
|
||||||
/** @var string */
|
private string $dsn;
|
||||||
private $dsn;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PDO database connection object, for anyone who wants direct access.
|
* The PDO database connection object, for anyone who wants direct access.
|
||||||
* @var null|PDO
|
|
||||||
*/
|
*/
|
||||||
private $db = null;
|
private ?PDO $db = null;
|
||||||
|
public float $dbtime = 0.0;
|
||||||
/**
|
|
||||||
* @var float
|
|
||||||
*/
|
|
||||||
public $dbtime = 0.0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta info about the database engine.
|
* Meta info about the database engine.
|
||||||
* @var DBEngine|null
|
|
||||||
*/
|
*/
|
||||||
private $engine = null;
|
private ?DBEngine $engine = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* How many queries this DB object has run
|
* How many queries this DB object has run
|
||||||
*/
|
*/
|
||||||
public $query_count = 0;
|
public int $query_count = 0;
|
||||||
|
|
||||||
public function __construct(string $dsn)
|
public function __construct(string $dsn)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,16 +7,15 @@ abstract class SCORE
|
||||||
|
|
||||||
abstract class DBEngine
|
abstract class DBEngine
|
||||||
{
|
{
|
||||||
/** @var null|string */
|
public ?string $name = null;
|
||||||
public $name = null;
|
|
||||||
|
|
||||||
public function init(PDO $db)
|
public function init(PDO $db)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function scoreql_to_sql(string $scoreql): string
|
public function scoreql_to_sql(string $data): string
|
||||||
{
|
{
|
||||||
return $scoreql;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function create_table_sql(string $name, string $data): string
|
public function create_table_sql(string $name, string $data): string
|
||||||
|
@ -33,8 +32,7 @@ abstract class DBEngine
|
||||||
|
|
||||||
class MySQL extends DBEngine
|
class MySQL extends DBEngine
|
||||||
{
|
{
|
||||||
/** @var string */
|
public ?string $name = DatabaseDriver::MYSQL;
|
||||||
public $name = DatabaseDriver::MYSQL;
|
|
||||||
|
|
||||||
public function init(PDO $db)
|
public function init(PDO $db)
|
||||||
{
|
{
|
||||||
|
@ -73,8 +71,7 @@ class MySQL extends DBEngine
|
||||||
|
|
||||||
class PostgreSQL extends DBEngine
|
class PostgreSQL extends DBEngine
|
||||||
{
|
{
|
||||||
/** @var string */
|
public ?string $name = DatabaseDriver::PGSQL;
|
||||||
public $name = DatabaseDriver::PGSQL;
|
|
||||||
|
|
||||||
public function init(PDO $db)
|
public function init(PDO $db)
|
||||||
{
|
{
|
||||||
|
@ -122,19 +119,19 @@ class PostgreSQL extends DBEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
// shimmie functions for export to sqlite
|
// shimmie functions for export to sqlite
|
||||||
function _unix_timestamp($date)
|
function _unix_timestamp($date): int
|
||||||
{
|
{
|
||||||
return strtotime($date);
|
return strtotime($date);
|
||||||
}
|
}
|
||||||
function _now()
|
function _now(): string
|
||||||
{
|
{
|
||||||
return date("Y-m-d H:i:s");
|
return date("Y-m-d H:i:s");
|
||||||
}
|
}
|
||||||
function _floor($a)
|
function _floor($a): float
|
||||||
{
|
{
|
||||||
return floor($a);
|
return floor($a);
|
||||||
}
|
}
|
||||||
function _log($a, $b=null)
|
function _log($a, $b=null): float
|
||||||
{
|
{
|
||||||
if (is_null($b)) {
|
if (is_null($b)) {
|
||||||
return log($a);
|
return log($a);
|
||||||
|
@ -142,35 +139,34 @@ function _log($a, $b=null)
|
||||||
return log($a, $b);
|
return log($a, $b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function _isnull($a)
|
function _isnull($a): bool
|
||||||
{
|
{
|
||||||
return is_null($a);
|
return is_null($a);
|
||||||
}
|
}
|
||||||
function _md5($a)
|
function _md5($a): string
|
||||||
{
|
{
|
||||||
return md5($a);
|
return md5($a);
|
||||||
}
|
}
|
||||||
function _concat($a, $b)
|
function _concat($a, $b): string
|
||||||
{
|
{
|
||||||
return $a . $b;
|
return $a . $b;
|
||||||
}
|
}
|
||||||
function _lower($a)
|
function _lower($a): string
|
||||||
{
|
{
|
||||||
return strtolower($a);
|
return strtolower($a);
|
||||||
}
|
}
|
||||||
function _rand()
|
function _rand(): int
|
||||||
{
|
{
|
||||||
return rand();
|
return rand();
|
||||||
}
|
}
|
||||||
function _ln($n)
|
function _ln($n): float
|
||||||
{
|
{
|
||||||
return log($n);
|
return log($n);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SQLite extends DBEngine
|
class SQLite extends DBEngine
|
||||||
{
|
{
|
||||||
/** @var string */
|
public ?string $name = DatabaseDriver::SQLITE;
|
||||||
public $name = DatabaseDriver::SQLITE;
|
|
||||||
|
|
||||||
public function init(PDO $db)
|
public function init(PDO $db)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,13 +6,13 @@
|
||||||
*/
|
*/
|
||||||
abstract class Event
|
abstract class Event
|
||||||
{
|
{
|
||||||
public $stop_processing = false;
|
public bool $stop_processing = false;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __toString()
|
public function __toString(): string
|
||||||
{
|
{
|
||||||
return var_export($this, true);
|
return var_export($this, true);
|
||||||
}
|
}
|
||||||
|
@ -42,19 +42,11 @@ class InitExtEvent extends Event
|
||||||
class PageRequestEvent extends Event
|
class PageRequestEvent extends Event
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $args;
|
public $args;
|
||||||
|
public int $arg_count;
|
||||||
/**
|
public int $part_count;
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $arg_count;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $part_count;
|
|
||||||
|
|
||||||
public function __construct(string $path)
|
public function __construct(string $path)
|
||||||
{
|
{
|
||||||
|
@ -179,15 +171,12 @@ class PageRequestEvent extends Event
|
||||||
*/
|
*/
|
||||||
class CommandEvent extends Event
|
class CommandEvent extends Event
|
||||||
{
|
{
|
||||||
/**
|
public string $cmd = "help";
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $cmd = "help";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $args = [];
|
public array $args = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* #param string[] $args
|
* #param string[] $args
|
||||||
|
@ -256,24 +245,18 @@ class TextFormattingEvent extends Event
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* For reference
|
* For reference
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $original;
|
public string $original;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* with formatting applied
|
* with formatting applied
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $formatted;
|
public string $formatted;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* with formatting removed
|
* with formatting removed
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $stripped;
|
public string $stripped;
|
||||||
|
|
||||||
public function __construct(string $text)
|
public function __construct(string $text)
|
||||||
{
|
{
|
||||||
|
@ -296,38 +279,30 @@ class LogEvent extends Event
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* a category, normally the extension name
|
* a category, normally the extension name
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $section;
|
public string $section;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See python...
|
* See python...
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
public $priority = 0;
|
public int $priority = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free text to be logged
|
* Free text to be logged
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
*/
|
||||||
public $message;
|
public string $message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time that the event was created
|
* The time that the event was created
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
*/
|
||||||
public $time;
|
public int $time;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extra data to be held separate
|
* Extra data to be held separate
|
||||||
*
|
*
|
||||||
* @var array
|
* @var string[]
|
||||||
*/
|
*/
|
||||||
public $args;
|
public array $args;
|
||||||
|
|
||||||
public function __construct(string $section, int $priority, string $message)
|
public function __construct(string $section, int $priority, string $message)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,11 +7,8 @@
|
||||||
*/
|
*/
|
||||||
class SCoreException extends RuntimeException
|
class SCoreException extends RuntimeException
|
||||||
{
|
{
|
||||||
/** @var string|null */
|
public ?string $query;
|
||||||
public $query;
|
public string $error;
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $error;
|
|
||||||
|
|
||||||
public function __construct(string $msg, ?string $query=null)
|
public function __construct(string $msg, ?string $query=null)
|
||||||
{
|
{
|
||||||
|
@ -23,21 +20,16 @@ class SCoreException extends RuntimeException
|
||||||
|
|
||||||
class InstallerException extends RuntimeException
|
class InstallerException extends RuntimeException
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $title;
|
||||||
public $title;
|
public string $body;
|
||||||
|
public int $exit_code;
|
||||||
|
|
||||||
/** @var string */
|
public function __construct(string $title, string $body, int $exit_code)
|
||||||
public $body;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
public $code;
|
|
||||||
|
|
||||||
public function __construct(string $title, string $body, int $code)
|
|
||||||
{
|
{
|
||||||
parent::__construct($body);
|
parent::__construct($body);
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->body = $body;
|
$this->body = $body;
|
||||||
$this->code = $code;
|
$this->exit_code = $exit_code;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,16 +13,11 @@
|
||||||
*/
|
*/
|
||||||
abstract class Extension
|
abstract class Extension
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $key;
|
||||||
public $key;
|
protected ?Themelet $theme;
|
||||||
|
public ?ExtensionInfo $info;
|
||||||
|
|
||||||
/** @var Themelet */
|
private static array $enabled_extensions = [];
|
||||||
protected $theme;
|
|
||||||
|
|
||||||
/** @var ExtensionInfo */
|
|
||||||
public $info;
|
|
||||||
|
|
||||||
private static $enabled_extensions = [];
|
|
||||||
|
|
||||||
public function __construct($class = null)
|
public function __construct($class = null)
|
||||||
{
|
{
|
||||||
|
@ -122,35 +117,31 @@ abstract class ExtensionInfo
|
||||||
public const LICENSE_MIT = "MIT";
|
public const LICENSE_MIT = "MIT";
|
||||||
public const LICENSE_WTFPL = "WTFPL";
|
public const LICENSE_WTFPL = "WTFPL";
|
||||||
|
|
||||||
|
public const VISIBLE_DEFAULT = "default";
|
||||||
public const VISIBLE_ADMIN = "admin";
|
public const VISIBLE_ADMIN = "admin";
|
||||||
public const VISIBLE_HIDDEN = "hidden";
|
public const VISIBLE_HIDDEN = "hidden";
|
||||||
private const VALID_VISIBILITY = [self::VISIBLE_ADMIN, self::VISIBLE_HIDDEN];
|
private const VALID_VISIBILITY = [self::VISIBLE_DEFAULT, self::VISIBLE_ADMIN, self::VISIBLE_HIDDEN];
|
||||||
|
|
||||||
public $key;
|
public string $key;
|
||||||
|
|
||||||
public $core = false;
|
public bool $core = false;
|
||||||
|
public bool $beta = false;
|
||||||
|
|
||||||
public $beta = false;
|
public string $name;
|
||||||
|
public string $license;
|
||||||
|
public string $description;
|
||||||
|
public array $authors = [];
|
||||||
|
public array $dependencies = [];
|
||||||
|
public array $conflicts = [];
|
||||||
|
public string $visibility = self::VISIBLE_DEFAULT;
|
||||||
|
public ?string $link = null;
|
||||||
|
public ?string $version = null;
|
||||||
|
public ?string $documentation = null;
|
||||||
|
|
||||||
public $name;
|
/** @var string[] which DBs this ext supports (blank for 'all') */
|
||||||
public $authors = [];
|
public array $db_support = [];
|
||||||
public $link;
|
private ?bool $supported = null;
|
||||||
public $license;
|
private ?string $support_info = null;
|
||||||
public $version;
|
|
||||||
public $dependencies = [];
|
|
||||||
public $conflicts = [];
|
|
||||||
public $visibility;
|
|
||||||
public $description;
|
|
||||||
public $documentation;
|
|
||||||
|
|
||||||
/** @var array which DBs this ext supports (blank for 'all') */
|
|
||||||
public $db_support = [];
|
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
private $supported = null;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $support_info = null;
|
|
||||||
|
|
||||||
public function is_supported(): bool
|
public function is_supported(): bool
|
||||||
{
|
{
|
||||||
|
@ -168,9 +159,9 @@ abstract class ExtensionInfo
|
||||||
return $this->support_info;
|
return $this->support_info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static $all_info_by_key = [];
|
private static array $all_info_by_key = [];
|
||||||
private static $all_info_by_class = [];
|
private static array $all_info_by_class = [];
|
||||||
private static $core_extensions = [];
|
private static array $core_extensions = [];
|
||||||
|
|
||||||
protected function __construct()
|
protected function __construct()
|
||||||
{
|
{
|
||||||
|
@ -283,7 +274,7 @@ abstract class FormatterExtension extends Extension
|
||||||
*/
|
*/
|
||||||
abstract class DataHandlerExtension extends Extension
|
abstract class DataHandlerExtension extends Extension
|
||||||
{
|
{
|
||||||
protected $SUPPORTED_MIME = [];
|
protected array $SUPPORTED_MIME = [];
|
||||||
|
|
||||||
protected function move_upload_to_archive(DataUploadEvent $event)
|
protected function move_upload_to_archive(DataUploadEvent $event)
|
||||||
{
|
{
|
||||||
|
@ -335,7 +326,9 @@ abstract class DataHandlerExtension extends Extension
|
||||||
}
|
}
|
||||||
|
|
||||||
send_event(new ImageReplaceEvent($event->replace_id, $image));
|
send_event(new ImageReplaceEvent($event->replace_id, $image));
|
||||||
$event->image_id = $event->replace_id;
|
$_id = $event->replace_id;
|
||||||
|
assert(!is_null($_id));
|
||||||
|
$event->image_id = $_id;
|
||||||
} else {
|
} else {
|
||||||
$image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->hash), $event->metadata);
|
$image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->hash), $event->metadata);
|
||||||
if (is_null($image)) {
|
if (is_null($image)) {
|
||||||
|
|
|
@ -5,13 +5,9 @@
|
||||||
*/
|
*/
|
||||||
class ImageAdditionEvent extends Event
|
class ImageAdditionEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var User */
|
public User $user;
|
||||||
public $user;
|
public Image $image;
|
||||||
|
public bool $merged = false;
|
||||||
/** @var Image */
|
|
||||||
public $image;
|
|
||||||
|
|
||||||
public $merged = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inserts a new image into the database with its associated
|
* Inserts a new image into the database with its associated
|
||||||
|
@ -34,11 +30,8 @@ class ImageAdditionException extends SCoreException
|
||||||
*/
|
*/
|
||||||
class ImageDeletionEvent extends Event
|
class ImageDeletionEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var Image */
|
public Image $image;
|
||||||
public $image;
|
public bool $force = false;
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
public $force = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an image.
|
* Deletes an image.
|
||||||
|
@ -59,10 +52,8 @@ class ImageDeletionEvent extends Event
|
||||||
*/
|
*/
|
||||||
class ImageReplaceEvent extends Event
|
class ImageReplaceEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var int */
|
public int $id;
|
||||||
public $id;
|
public Image $image;
|
||||||
/** @var Image */
|
|
||||||
public $image;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replaces an image.
|
* Replaces an image.
|
||||||
|
@ -88,15 +79,10 @@ class ImageReplaceException extends SCoreException
|
||||||
*/
|
*/
|
||||||
class ThumbnailGenerationEvent extends Event
|
class ThumbnailGenerationEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $hash;
|
||||||
public $hash;
|
public string $mime;
|
||||||
/** @var string */
|
public bool $force;
|
||||||
public $mime;
|
public bool $generated;
|
||||||
/** @var bool */
|
|
||||||
public $force;
|
|
||||||
|
|
||||||
/** @var bool */
|
|
||||||
public $generated;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request a thumbnail be made for an image object
|
* Request a thumbnail be made for an image object
|
||||||
|
@ -121,14 +107,10 @@ class ThumbnailGenerationEvent extends Event
|
||||||
*/
|
*/
|
||||||
class ParseLinkTemplateEvent extends Event
|
class ParseLinkTemplateEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $link;
|
||||||
public $link;
|
public string $text;
|
||||||
/** @var string */
|
public string $original;
|
||||||
public $text;
|
public Image $image;
|
||||||
/** @var string */
|
|
||||||
public $original;
|
|
||||||
/** @var Image */
|
|
||||||
public $image;
|
|
||||||
|
|
||||||
public function __construct(string $link, Image $image)
|
public function __construct(string $link, Image $image)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,68 +13,31 @@ class Image
|
||||||
public const IMAGE_DIR = "images";
|
public const IMAGE_DIR = "images";
|
||||||
public const THUMBNAIL_DIR = "thumbs";
|
public const THUMBNAIL_DIR = "thumbs";
|
||||||
|
|
||||||
/** @var null|int */
|
public ?int $id = null;
|
||||||
public $id = null;
|
public int $height;
|
||||||
|
public int $width;
|
||||||
/** @var int */
|
public string $hash;
|
||||||
public $height;
|
public int $filesize;
|
||||||
|
public string $filename;
|
||||||
/** @var int */
|
private string $ext;
|
||||||
public $width;
|
private string $mime;
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $hash;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
public $filesize;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $filename;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $ext;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
private $mime;
|
|
||||||
|
|
||||||
/** @var string[]|null */
|
/** @var string[]|null */
|
||||||
public $tag_array;
|
public ?array $tag_array;
|
||||||
|
public int $owner_id;
|
||||||
|
public string $owner_ip;
|
||||||
|
public string $posted;
|
||||||
|
public ?string $source;
|
||||||
|
public bool $locked = false;
|
||||||
|
public ?bool $lossless = null;
|
||||||
|
public ?bool $video = null;
|
||||||
|
public ?string $video_codec = null;
|
||||||
|
public ?bool $image = null;
|
||||||
|
public ?bool $audio = null;
|
||||||
|
public ?int $length = null;
|
||||||
|
|
||||||
/** @var int */
|
public static array $bool_props = ["locked", "lossless", "video", "audio", "image"];
|
||||||
public $owner_id;
|
public static array $int_props = ["id", "owner_id", "height", "width", "filesize", "length"];
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $owner_ip;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $posted;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $source;
|
|
||||||
|
|
||||||
/** @var boolean */
|
|
||||||
public $locked = false;
|
|
||||||
|
|
||||||
/** @var boolean */
|
|
||||||
public $lossless = null;
|
|
||||||
|
|
||||||
/** @var boolean */
|
|
||||||
public $video = null;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $video_codec = null;
|
|
||||||
|
|
||||||
/** @var boolean */
|
|
||||||
public $image = null;
|
|
||||||
|
|
||||||
/** @var boolean */
|
|
||||||
public $audio = null;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
public $length = null;
|
|
||||||
|
|
||||||
public static $bool_props = ["locked", "lossless", "video", "audio"];
|
|
||||||
public static $int_props = ["id", "owner_id", "height", "width", "filesize", "length"];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One will very rarely construct an image directly, more common
|
* One will very rarely construct an image directly, more common
|
||||||
|
@ -145,7 +108,7 @@ class Image
|
||||||
|
|
||||||
private static function find_images_internal(int $start = 0, ?int $limit = null, array $tags=[]): iterable
|
private static function find_images_internal(int $start = 0, ?int $limit = null, array $tags=[]): iterable
|
||||||
{
|
{
|
||||||
global $database, $user, $config;
|
global $database, $user;
|
||||||
|
|
||||||
if ($start < 0) {
|
if ($start < 0) {
|
||||||
$start = 0;
|
$start = 0;
|
||||||
|
@ -161,9 +124,7 @@ class Image
|
||||||
}
|
}
|
||||||
|
|
||||||
$querylet = Image::build_search_querylet($tags, $limit, $start);
|
$querylet = Image::build_search_querylet($tags, $limit, $start);
|
||||||
$result = $database->get_all_iterable($querylet->sql, $querylet->variables);
|
return $database->get_all_iterable($querylet->sql, $querylet->variables);
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -625,7 +586,9 @@ class Image
|
||||||
public function set_mime($mime): void
|
public function set_mime($mime): void
|
||||||
{
|
{
|
||||||
$this->mime = $mime;
|
$this->mime = $mime;
|
||||||
$this->ext = FileExtension::get_for_mime($this->get_mime());
|
$ext = FileExtension::get_for_mime($this->get_mime());
|
||||||
|
assert($ext != null);
|
||||||
|
$this->ext = $ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
class Querylet
|
class Querylet
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $sql;
|
||||||
public $sql;
|
public array $variables;
|
||||||
/** @var array */
|
|
||||||
public $variables;
|
|
||||||
|
|
||||||
public function __construct(string $sql, array $variables=[])
|
public function __construct(string $sql, array $variables=[])
|
||||||
{
|
{
|
||||||
|
@ -31,10 +29,8 @@ class Querylet
|
||||||
|
|
||||||
class TagCondition
|
class TagCondition
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $tag;
|
||||||
public $tag;
|
public bool $positive;
|
||||||
/** @var bool */
|
|
||||||
public $positive;
|
|
||||||
|
|
||||||
public function __construct(string $tag, bool $positive)
|
public function __construct(string $tag, bool $positive)
|
||||||
{
|
{
|
||||||
|
@ -45,10 +41,8 @@ class TagCondition
|
||||||
|
|
||||||
class ImgCondition
|
class ImgCondition
|
||||||
{
|
{
|
||||||
/** @var Querylet */
|
public Querylet $qlet;
|
||||||
public $qlet;
|
public bool $positive;
|
||||||
/** @var bool */
|
|
||||||
public $positive;
|
|
||||||
|
|
||||||
public function __construct(Querylet $qlet, bool $positive)
|
public function __construct(Querylet $qlet, bool $positive)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,7 +68,7 @@ function do_install($dsn)
|
||||||
create_tables(new Database($dsn));
|
create_tables(new Database($dsn));
|
||||||
write_config($dsn);
|
write_config($dsn);
|
||||||
} catch (InstallerException $e) {
|
} catch (InstallerException $e) {
|
||||||
die_nicely($e->title, $e->body, $e->code);
|
die_nicely($e->title, $e->body, $e->exit_code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,21 +246,22 @@ function find_header(array $headers, string $name): ?string
|
||||||
|
|
||||||
if (!function_exists('mb_strlen')) {
|
if (!function_exists('mb_strlen')) {
|
||||||
// TODO: we should warn the admin that they are missing multibyte support
|
// TODO: we should warn the admin that they are missing multibyte support
|
||||||
function mb_strlen($str, $encoding)
|
/** @noinspection PhpUnusedParameterInspection */
|
||||||
|
function mb_strlen($str, $encoding): int
|
||||||
{
|
{
|
||||||
return strlen($str);
|
return strlen($str);
|
||||||
}
|
}
|
||||||
function mb_internal_encoding($encoding)
|
function mb_internal_encoding($encoding): void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
function mb_strtolower($str)
|
function mb_strtolower($str): string
|
||||||
{
|
{
|
||||||
return strtolower($str);
|
return strtolower($str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @noinspection PhpUnhandledExceptionInspection */
|
/** @noinspection PhpUnhandledExceptionInspection */
|
||||||
function get_subclasses_of(string $parent)
|
function get_subclasses_of(string $parent): array
|
||||||
{
|
{
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach (get_declared_classes() as $class) {
|
foreach (get_declared_classes() as $class) {
|
||||||
|
@ -327,7 +328,7 @@ function get_base_href(): string
|
||||||
/**
|
/**
|
||||||
* The opposite of the standard library's parse_url
|
* The opposite of the standard library's parse_url
|
||||||
*/
|
*/
|
||||||
function unparse_url($parsed_url)
|
function unparse_url(array $parsed_url): string
|
||||||
{
|
{
|
||||||
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
|
$scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
|
||||||
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
|
$host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
|
||||||
|
@ -345,14 +346,14 @@ function unparse_url($parsed_url)
|
||||||
if (!function_exists('str_starts_with')) {
|
if (!function_exists('str_starts_with')) {
|
||||||
function str_starts_with(string $haystack, string $needle): bool
|
function str_starts_with(string $haystack, string $needle): bool
|
||||||
{
|
{
|
||||||
return \strncmp($haystack, $needle, \strlen($needle)) === 0;
|
return strncmp($haystack, $needle, strlen($needle)) === 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('str_ends_with')) {
|
if (!function_exists('str_ends_with')) {
|
||||||
function str_ends_with(string $haystack, string $needle): bool
|
function str_ends_with(string $haystack, string $needle): bool
|
||||||
{
|
{
|
||||||
return $needle === '' || $needle === \substr($haystack, - \strlen($needle));
|
return $needle === '' || $needle === substr($haystack, - strlen($needle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -520,13 +521,9 @@ function parse_shorthand_int(string $limit): int
|
||||||
/** @noinspection PhpMissingBreakStatementInspection */
|
/** @noinspection PhpMissingBreakStatementInspection */
|
||||||
case 't': $value *= 1024; // fall through
|
case 't': $value *= 1024; // fall through
|
||||||
/** @noinspection PhpMissingBreakStatementInspection */
|
/** @noinspection PhpMissingBreakStatementInspection */
|
||||||
// no break
|
|
||||||
case 'g': $value *= 1024; // fall through
|
case 'g': $value *= 1024; // fall through
|
||||||
/** @noinspection PhpMissingBreakStatementInspection */
|
/** @noinspection PhpMissingBreakStatementInspection */
|
||||||
// no break
|
|
||||||
case 'm': $value *= 1024; // fall through
|
case 'm': $value *= 1024; // fall through
|
||||||
/** @noinspection PhpMissingBreakStatementInspection */
|
|
||||||
// no break
|
|
||||||
case 'k': $value *= 1024; break;
|
case 'k': $value *= 1024; break;
|
||||||
default: $value = -1;
|
default: $value = -1;
|
||||||
}
|
}
|
||||||
|
@ -800,7 +797,7 @@ function iterator_map_to_array(callable $callback, iterator $iter): array
|
||||||
return iterator_to_array(iterator_map($callback, $iter));
|
return iterator_to_array(iterator_map($callback, $iter));
|
||||||
}
|
}
|
||||||
|
|
||||||
function stringer($s)
|
function stringer($s): string
|
||||||
{
|
{
|
||||||
if (is_array($s)) {
|
if (is_array($s)) {
|
||||||
if (isset($s[0])) {
|
if (isset($s[0])) {
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
class Link
|
class Link
|
||||||
{
|
{
|
||||||
public $page;
|
public ?string $page;
|
||||||
public $query;
|
public ?string $query;
|
||||||
|
|
||||||
public function __construct(?string $page=null, ?string $query=null)
|
public function __construct(?string $page=null, ?string $query=null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,22 +15,12 @@ function _new_user(array $row): User
|
||||||
*/
|
*/
|
||||||
class User
|
class User
|
||||||
{
|
{
|
||||||
/** @var int */
|
public int $id;
|
||||||
public $id;
|
public string $name;
|
||||||
|
public ?string $email;
|
||||||
/** @var string */
|
public string $join_date;
|
||||||
public $name;
|
public ?string $passhash;
|
||||||
|
public UserClass $class;
|
||||||
/** @var string */
|
|
||||||
public $email;
|
|
||||||
|
|
||||||
public $join_date;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $passhash;
|
|
||||||
|
|
||||||
/** @var UserClass */
|
|
||||||
public $class;
|
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
* Initialisation *
|
* Initialisation *
|
||||||
|
|
|
@ -10,21 +10,9 @@ $_shm_user_classes = [];
|
||||||
*/
|
*/
|
||||||
class UserClass
|
class UserClass
|
||||||
{
|
{
|
||||||
|
public ?string $name = null;
|
||||||
/**
|
public ?UserClass $parent = null;
|
||||||
* @var ?string
|
public array $abilities = [];
|
||||||
*/
|
|
||||||
public $name = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var ?UserClass
|
|
||||||
*/
|
|
||||||
public $parent = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $abilities = [];
|
|
||||||
|
|
||||||
public function __construct(string $name, string $parent = null, array $abilities = [])
|
public function __construct(string $name, string $parent = null, array $abilities = [])
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,6 +12,7 @@ use function MicroHTML\TFOOT;
|
||||||
use function MicroHTML\TR;
|
use function MicroHTML\TR;
|
||||||
use function MicroHTML\TH;
|
use function MicroHTML\TH;
|
||||||
use function MicroHTML\TD;
|
use function MicroHTML\TD;
|
||||||
|
use MicroHTML\HTMLElement;
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||||
* Misc *
|
* Misc *
|
||||||
|
@ -359,7 +360,7 @@ function path_to_tags(string $path): string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function join_url(string $base, string ...$paths)
|
function join_url(string $base, string ...$paths): string
|
||||||
{
|
{
|
||||||
$output = $base;
|
$output = $base;
|
||||||
foreach ($paths as $path) {
|
foreach ($paths as $path) {
|
||||||
|
@ -410,7 +411,7 @@ function remove_empty_dirs(string $dir): bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($result===true) {
|
if ($result===true) {
|
||||||
$result = $result && rmdir($dir);
|
$result = rmdir($dir);
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -584,7 +585,6 @@ function _get_themelet_files(string $_theme): array
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to display fatal errors to the web user.
|
* Used to display fatal errors to the web user.
|
||||||
* @noinspection PhpPossiblePolymorphicInvocationInspection
|
|
||||||
*/
|
*/
|
||||||
function _fatal_error(Exception $e): void
|
function _fatal_error(Exception $e): void
|
||||||
{
|
{
|
||||||
|
@ -703,7 +703,7 @@ function make_form(string $target, string $method="POST", bool $multipart=false,
|
||||||
return '<form action="'.$target.'" method="'.$method.'" '.$extra.'>'.$extra_inputs;
|
return '<form action="'.$target.'" method="'.$method.'" '.$extra.'>'.$extra_inputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SHM_FORM(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit="")
|
function SHM_FORM(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit=""): HTMLElement
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
@ -728,19 +728,19 @@ function SHM_FORM(string $target, string $method="POST", bool $multipart=false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SHM_SIMPLE_FORM($target, ...$children)
|
function SHM_SIMPLE_FORM($target, ...$children): HTMLElement
|
||||||
{
|
{
|
||||||
$form = SHM_FORM($target);
|
$form = SHM_FORM($target);
|
||||||
$form->appendChild(emptyHTML(...$children));
|
$form->appendChild(emptyHTML(...$children));
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SHM_SUBMIT(string $text)
|
function SHM_SUBMIT(string $text): HTMLElement
|
||||||
{
|
{
|
||||||
return INPUT(["type"=>"submit", "value"=>$text]);
|
return INPUT(["type"=>"submit", "value"=>$text]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SHM_COMMAND_EXAMPLE(string $ex, string $desc)
|
function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement
|
||||||
{
|
{
|
||||||
return DIV(
|
return DIV(
|
||||||
["class"=>"command_example"],
|
["class"=>"command_example"],
|
||||||
|
@ -749,7 +749,7 @@ function SHM_COMMAND_EXAMPLE(string $ex, string $desc)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot)
|
function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot): HTMLElement
|
||||||
{
|
{
|
||||||
if (is_string($foot)) {
|
if (is_string($foot)) {
|
||||||
$foot = TFOOT(TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>$foot]))));
|
$foot = TFOOT(TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>$foot]))));
|
||||||
|
@ -769,16 +769,16 @@ function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot)
|
||||||
}
|
}
|
||||||
|
|
||||||
const BYTE_DENOMINATIONS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
const BYTE_DENOMINATIONS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||||
function human_filesize(int $bytes, $decimals = 2)
|
function human_filesize(int $bytes, $decimals = 2): string
|
||||||
{
|
{
|
||||||
$factor = floor((strlen(strval($bytes)) - 1) / 3);
|
$factor = floor((strlen(strval($bytes)) - 1) / 3);
|
||||||
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @BYTE_DENOMINATIONS[$factor];
|
return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @BYTE_DENOMINATIONS[$factor];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Generates a unique key for the website to prevent unauthorized access.
|
* Generates a unique key for the website to prevent unauthorized access.
|
||||||
*/
|
*/
|
||||||
function generate_key(int $length = 20)
|
function generate_key(int $length = 20): string
|
||||||
{
|
{
|
||||||
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
$randomString = '';
|
$randomString = '';
|
||||||
|
|
|
@ -4,12 +4,12 @@ class AdminPageInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "admin";
|
public const KEY = "admin";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Admin Controls";
|
public string $name = "Admin Controls";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Provides a base for various small admin functions";
|
public string $description = "Provides a base for various small admin functions";
|
||||||
public $core = true;
|
public bool $core = true;
|
||||||
public $visibility = self::VISIBLE_HIDDEN;
|
public string $visibility = self::VISIBLE_HIDDEN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
<?php /** @noinspection PhpUnusedPrivateMethodInspection */
|
<?php declare(strict_types=1);
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sent when the admin page is ready to be added to
|
* Sent when the admin page is ready to be added to
|
||||||
*/
|
*/
|
||||||
class AdminBuildingEvent extends Event
|
class AdminBuildingEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var Page */
|
public Page $page;
|
||||||
public $page;
|
|
||||||
|
|
||||||
public function __construct(Page $page)
|
public function __construct(Page $page)
|
||||||
{
|
{
|
||||||
|
@ -18,10 +16,8 @@ class AdminBuildingEvent extends Event
|
||||||
|
|
||||||
class AdminActionEvent extends Event
|
class AdminActionEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $action;
|
||||||
public $action;
|
public bool $redirect = true;
|
||||||
/** @var bool */
|
|
||||||
public $redirect = true;
|
|
||||||
|
|
||||||
public function __construct(string $action)
|
public function __construct(string $action)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +29,7 @@ class AdminActionEvent extends Event
|
||||||
class AdminPage extends Extension
|
class AdminPage extends Extension
|
||||||
{
|
{
|
||||||
/** @var AdminPageTheme */
|
/** @var AdminPageTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
use function MicroHTML\INPUT;
|
|
||||||
|
|
||||||
class AdminPageTheme extends Themelet
|
class AdminPageTheme extends Themelet
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,12 +4,12 @@ class AliasEditorInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "alias_editor";
|
public const KEY = "alias_editor";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Alias Editor";
|
public string $name = "Alias Editor";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Edit the alias list";
|
public string $description = "Edit the alias list";
|
||||||
public $documentation = 'The list is visible at <a href="$site/alias/list">/alias/list</a>; only site admins can edit it, other people can view and download it';
|
public ?string $documentation = 'The list is visible at <a href="$site/alias/list">/alias/list</a>; only site admins can edit it, other people can view and download it';
|
||||||
public $core = true;
|
public bool $core = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,8 @@ class AliasTable extends Table
|
||||||
|
|
||||||
class AddAliasEvent extends Event
|
class AddAliasEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $oldtag;
|
||||||
public $oldtag;
|
public string $newtag;
|
||||||
/** @var string */
|
|
||||||
public $newtag;
|
|
||||||
|
|
||||||
public function __construct(string $oldtag, string $newtag)
|
public function __construct(string $oldtag, string $newtag)
|
||||||
{
|
{
|
||||||
|
@ -41,7 +39,7 @@ class AddAliasEvent extends Event
|
||||||
|
|
||||||
class DeleteAliasEvent extends Event
|
class DeleteAliasEvent extends Event
|
||||||
{
|
{
|
||||||
public $oldtag;
|
public string $oldtag;
|
||||||
|
|
||||||
public function __construct(string $oldtag)
|
public function __construct(string $oldtag)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +55,7 @@ class AddAliasException extends SCoreException
|
||||||
class AliasEditor extends Extension
|
class AliasEditor extends Extension
|
||||||
{
|
{
|
||||||
/** @var AliasEditorTheme */
|
/** @var AliasEditorTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,9 @@ class ApprovalInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "approval";
|
public const KEY = "approval";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Approval";
|
public string $name = "Approval";
|
||||||
public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
||||||
public $license = self::LICENSE_WTFPL;
|
public string $license = self::LICENSE_WTFPL;
|
||||||
public $description = "Adds an approval step to the upload/import process.";
|
public string $description = "Adds an approval step to the upload/import process.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ abstract class ApprovalConfig
|
||||||
class Approval extends Extension
|
class Approval extends Extension
|
||||||
{
|
{
|
||||||
/** @var ApprovalTheme */
|
/** @var ApprovalTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onInitExt(InitExtEvent $event)
|
public function onInitExt(InitExtEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ use function MicroHTML\INPUT;
|
||||||
|
|
||||||
class ApprovalTheme extends Themelet
|
class ApprovalTheme extends Themelet
|
||||||
{
|
{
|
||||||
public function get_image_admin_html(Image $image)
|
public function get_image_admin_html(Image $image): string
|
||||||
{
|
{
|
||||||
if ($image->approved===true) {
|
if ($image->approved===true) {
|
||||||
$html = SHM_SIMPLE_FORM(
|
$html = SHM_SIMPLE_FORM(
|
||||||
|
@ -24,8 +24,7 @@ class ApprovalTheme extends Themelet
|
||||||
return (string)$html;
|
return (string)$html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_help_html(): string
|
||||||
public function get_help_html()
|
|
||||||
{
|
{
|
||||||
return '<p>Search for posts that are approved/not approved.</p>
|
return '<p>Search for posts that are approved/not approved.</p>
|
||||||
<div class="command_example">
|
<div class="command_example">
|
||||||
|
|
|
@ -4,11 +4,11 @@ class ArtistsInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "artists";
|
public const KEY = "artists";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Artists System";
|
public string $name = "Artists System";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"];
|
public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Simple artists extension";
|
public string $description = "Simple artists extension";
|
||||||
public $beta = true;
|
public bool $beta = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,9 @@
|
||||||
|
|
||||||
class AuthorSetEvent extends Event
|
class AuthorSetEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var Image */
|
public Image $image;
|
||||||
public $image;
|
public User $user;
|
||||||
/** @var User */
|
public string $author;
|
||||||
public $user;
|
|
||||||
/** @var string */
|
|
||||||
public $author;
|
|
||||||
|
|
||||||
public function __construct(Image $image, User $user, string $author)
|
public function __construct(Image $image, User $user, string $author)
|
||||||
{
|
{
|
||||||
|
@ -21,7 +18,7 @@ class AuthorSetEvent extends Event
|
||||||
class Artists extends Extension
|
class Artists extends Extension
|
||||||
{
|
{
|
||||||
/** @var ArtistsTheme */
|
/** @var ArtistsTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onImageInfoSet(ImageInfoSetEvent $event)
|
public function onImageInfoSet(ImageInfoSetEvent $event)
|
||||||
{
|
{
|
||||||
|
@ -683,7 +680,7 @@ class Artists extends Extension
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add_artist()
|
private function add_artist(): int
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
$inputs = validate_input([
|
$inputs = validate_input([
|
||||||
|
|
|
@ -546,7 +546,7 @@ class ArtistsTheme extends Themelet
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_help_html()
|
public function get_help_html(): string
|
||||||
{
|
{
|
||||||
return '<p>Search for posts with a particular artist.</p>
|
return '<p>Search for posts with a particular artist.</p>
|
||||||
<div class="command_example">
|
<div class="command_example">
|
||||||
|
|
|
@ -4,9 +4,9 @@ class AutoTaggerInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "auto_tagger";
|
public const KEY = "auto_tagger";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Auto-Tagger";
|
public string $name = "Auto-Tagger";
|
||||||
public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
||||||
public $license = self::LICENSE_WTFPL;
|
public string $license = self::LICENSE_WTFPL;
|
||||||
public $description = "Provides several automatic tagging functions";
|
public string $description = "Provides several automatic tagging functions";
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,8 @@ class AutoTaggerTable extends Table
|
||||||
|
|
||||||
class AddAutoTagEvent extends Event
|
class AddAutoTagEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $tag;
|
||||||
public $tag;
|
public string $additional_tags;
|
||||||
/** @var string */
|
|
||||||
public $additional_tags;
|
|
||||||
|
|
||||||
public function __construct(string $tag, string $additional_tags)
|
public function __construct(string $tag, string $additional_tags)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +41,7 @@ class AddAutoTagEvent extends Event
|
||||||
|
|
||||||
class DeleteAutoTagEvent extends Event
|
class DeleteAutoTagEvent extends Event
|
||||||
{
|
{
|
||||||
public $tag;
|
public string $tag;
|
||||||
|
|
||||||
public function __construct(string $tag)
|
public function __construct(string $tag)
|
||||||
{
|
{
|
||||||
|
@ -63,7 +61,7 @@ class AddAutoTagException extends SCoreException
|
||||||
class AutoTagger extends Extension
|
class AutoTagger extends Extension
|
||||||
{
|
{
|
||||||
/** @var AutoTaggerTheme */
|
/** @var AutoTaggerTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,8 +4,8 @@ class AutoCompleteInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "autocomplete";
|
public const KEY = "autocomplete";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Autocomplete";
|
public string $name = "Autocomplete";
|
||||||
public $authors = ["Daku"=>"admin@codeanimu.net"];
|
public array $authors = ["Daku"=>"admin@codeanimu.net"];
|
||||||
public $description = "Adds autocomplete to search & tagging.";
|
public string $description = "Adds autocomplete to search & tagging.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class AutoComplete extends Extension
|
class AutoComplete extends Extension
|
||||||
{
|
{
|
||||||
/** @var AutoCompleteTheme */
|
/** @var AutoCompleteTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function get_priority(): int
|
public function get_priority(): int
|
||||||
{
|
{
|
||||||
|
|
|
@ -63,12 +63,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||||
var keyCode = e.keyCode || e.which;
|
var keyCode = e.keyCode || e.which;
|
||||||
|
|
||||||
//Stop tags containing space.
|
//Stop tags containing space.
|
||||||
if(keyCode == 32) {
|
if(keyCode === 32) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
$('.autocomplete_tags').tagit('createTag', $(this).val());
|
$('.autocomplete_tags').tagit('createTag', $(this).val());
|
||||||
$(this).autocomplete('close');
|
$(this).autocomplete('close');
|
||||||
} else if (keyCode == 9) {
|
} else if (keyCode === 9) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
var tag = $('.tagit-autocomplete[style*=\"display: block\"] > li:focus, .tagit-autocomplete[style*=\"display: block\"] > li:first').first();
|
var tag = $('.tagit-autocomplete[style*=\"display: block\"] > li:focus, .tagit-autocomplete[style*=\"display: block\"] > li:first').first();
|
||||||
|
|
|
@ -4,13 +4,13 @@ class BanWordsInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "ban_words";
|
public const KEY = "ban_words";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Comment Word Ban";
|
public string $name = "Comment Word Ban";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "For stopping spam and other comment abuse";
|
public string $description = "For stopping spam and other comment abuse";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Allows an administrator to ban certain words
|
"Allows an administrator to ban certain words
|
||||||
from comments. This can be a very simple but effective way
|
from comments. This can be a very simple but effective way
|
||||||
of stopping spam; just add \"viagra\", \"porn\", etc to the
|
of stopping spam; just add \"viagra\", \"porn\", etc to the
|
||||||
|
|
|
@ -4,14 +4,14 @@ class BBCodeInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "bbcode";
|
public const KEY = "bbcode";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "BBCode";
|
public string $name = "BBCode";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $core = true;
|
public bool $core = true;
|
||||||
public $description = "Turns BBCode into HTML";
|
public string $description = "Turns BBCode into HTML";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
" Basic formatting tags:
|
" Basic formatting tags:
|
||||||
<ul>
|
<ul>
|
||||||
<li>[b]<b>bold</b>[/b]
|
<li>[b]<b>bold</b>[/b]
|
||||||
|
|
|
@ -96,13 +96,13 @@ class BBCodeTest extends ShimmiePHPUnitTestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function filter($in)
|
private function filter($in): string
|
||||||
{
|
{
|
||||||
$bb = new BBCode();
|
$bb = new BBCode();
|
||||||
return $bb->format($in);
|
return $bb->format($in);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function strip($in)
|
private function strip($in): string
|
||||||
{
|
{
|
||||||
$bb = new BBCode();
|
$bb = new BBCode();
|
||||||
return $bb->strip($in);
|
return $bb->strip($in);
|
||||||
|
|
|
@ -4,10 +4,10 @@ class BiographyInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "biography";
|
public const KEY = "biography";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "User Bios";
|
public string $name = "User Bios";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Allow users to write a bit about themselves";
|
public string $description = "Allow users to write a bit about themselves";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
class Biography extends Extension
|
class Biography extends Extension
|
||||||
{
|
{
|
||||||
/** @var BiographyTheme */
|
/** @var BiographyTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onUserPageBuilding(UserPageBuildingEvent $event)
|
public function onUserPageBuilding(UserPageBuildingEvent $event)
|
||||||
{
|
{
|
||||||
global $database, $page, $user;
|
global $page, $user;
|
||||||
$duser = $event->display_user;
|
$duser = $event->display_user;
|
||||||
$duser_config = UserConfig::get_for_user($event->display_user->id);
|
$duser_config = UserConfig::get_for_user($event->display_user->id);
|
||||||
$bio = $duser_config->get_string("biography", "");
|
$bio = $duser_config->get_string("biography", "");
|
||||||
|
@ -21,7 +21,7 @@ class Biography extends Extension
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
global $cache, $database, $page, $user, $user_config;
|
global $page, $user, $user_config;
|
||||||
if ($event->page_matches("biography")) {
|
if ($event->page_matches("biography")) {
|
||||||
if ($user->check_auth_token()) {
|
if ($user->check_auth_token()) {
|
||||||
$user_config->set_string("biography", $_POST['biography']);
|
$user_config->set_string("biography", $_POST['biography']);
|
||||||
|
|
|
@ -3,7 +3,6 @@ class BiographyTest extends ShimmiePHPUnitTestCase
|
||||||
{
|
{
|
||||||
public function testBio()
|
public function testBio()
|
||||||
{
|
{
|
||||||
global $database;
|
|
||||||
$this->log_in_as_user();
|
$this->log_in_as_user();
|
||||||
$this->post_page("biography", ["biography"=>"My bio goes here"]);
|
$this->post_page("biography", ["biography"=>"My bio goes here"]);
|
||||||
$this->get_page("user/" . self::$user_name);
|
$this->get_page("user/" . self::$user_name);
|
||||||
|
|
|
@ -4,10 +4,10 @@ class BlocksInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "blocks";
|
public const KEY = "blocks";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Generic Blocks";
|
public string $name = "Generic Blocks";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Add HTML to some space (News, Ads, etc)";
|
public string $description = "Add HTML to some space (News, Ads, etc)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class Blocks extends Extension
|
class Blocks extends Extension
|
||||||
{
|
{
|
||||||
/** @var BlocksTheme */
|
/** @var BlocksTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,12 +4,12 @@ class BlotterInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "blotter";
|
public const KEY = "blotter";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Blotter";
|
public string $name = "Blotter";
|
||||||
public $url = "http://seemslegit.com/";
|
public string $url = "http://seemslegit.com/";
|
||||||
public $authors = ["Zach Hall"=>"zach@sosguy.net"];
|
public array $authors = ["Zach Hall"=>"zach@sosguy.net"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Displays brief updates about whatever you want on every page.
|
public string $description = "Displays brief updates about whatever you want on every page.
|
||||||
Colors and positioning can be configured to match your site's design.
|
Colors and positioning can be configured to match your site's design.
|
||||||
|
|
||||||
Development TODO at https://github.com/zshall/shimmie2/issues";
|
Development TODO at https://github.com/zshall/shimmie2/issues";
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class Blotter extends Extension
|
class Blotter extends Extension
|
||||||
{
|
{
|
||||||
/** @var BlotterTheme */
|
/** @var BlotterTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onInitExt(InitExtEvent $event)
|
public function onInitExt(InitExtEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ class BlotterTheme extends Themelet
|
||||||
$page->add_block(new Block("Blotter Entries", $html, "main", 10));
|
$page->add_block(new Block("Blotter Entries", $html, "main", 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function display_blotter($entries)
|
public function display_blotter(array $entries): void
|
||||||
{
|
{
|
||||||
global $page, $config;
|
global $page, $config;
|
||||||
$html = $this->get_html_for_blotter($entries);
|
$html = $this->get_html_for_blotter($entries);
|
||||||
|
@ -28,7 +28,7 @@ class BlotterTheme extends Themelet
|
||||||
$page->add_block(new Block(null, $html, $position, 20));
|
$page->add_block(new Block(null, $html, $position, 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_html_for_blotter_editor($entries)
|
private function get_html_for_blotter_editor(array $entries): string
|
||||||
{
|
{
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class BlotterTheme extends Themelet
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_html_for_blotter_page($entries)
|
private function get_html_for_blotter_page(array $entries): string
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This one displays a list of all blotter entries.
|
* This one displays a list of all blotter entries.
|
||||||
|
@ -130,7 +130,7 @@ class BlotterTheme extends Themelet
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_html_for_blotter($entries)
|
private function get_html_for_blotter(array $entries): string
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$i_color = $config->get_string("blotter_color", "#FF0000");
|
$i_color = $config->get_string("blotter_color", "#FF0000");
|
||||||
|
|
|
@ -4,14 +4,14 @@ class BrowserSearchInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "browser_search";
|
public const KEY = "browser_search";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Browser Search";
|
public string $name = "Browser Search";
|
||||||
public $url = "http://atravelinggeek.com/";
|
public string $url = "http://atravelinggeek.com/";
|
||||||
public $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"];
|
public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $version = "0.1c, October 26, 2007";
|
public ?string $version = "0.1c, October 26, 2007";
|
||||||
public $description = "Allows the user to add a browser 'plugin' to search the site with real-time suggestions";
|
public string $description = "Allows the user to add a browser 'plugin' to search the site with real-time suggestions";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Once installed, users with an opensearch compatible browser should see their search box light up with whatever \"click here to add a search engine\" notification they have
|
"Once installed, users with an opensearch compatible browser should see their search box light up with whatever \"click here to add a search engine\" notification they have
|
||||||
|
|
||||||
Some code (and lots of help) by Artanis (Erik Youngren <artanis.00@gmail.com>) from the 'tagger' extension - Used with permission";
|
Some code (and lots of help) by Artanis (Erik Youngren <artanis.00@gmail.com>) from the 'tagger' extension - Used with permission";
|
||||||
|
|
|
@ -4,10 +4,10 @@ class BulkActionsInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "bulk_actions";
|
public const KEY = "bulk_actions";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Bulk Actions";
|
public string $name = "Bulk Actions";
|
||||||
public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
||||||
public $license = self::LICENSE_WTFPL;
|
public string $license = self::LICENSE_WTFPL;
|
||||||
public $description = "Provides query and selection-based bulk action support";
|
public string $description = "Provides query and selection-based bulk action support";
|
||||||
public $documentation = "Provides bulk action section in list view. Allows performing actions against a set of posts based on query or manual selection. Based on Mass Tagger by Christian Walde <walde.christian@googlemail.com>, contributions by Shish and Agasa.";
|
public ?string $documentation = "Provides bulk action section in list view. Allows performing actions against a set of posts based on query or manual selection. Based on Mass Tagger by Christian Walde <walde.christian@googlemail.com>, contributions by Shish and Agasa.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,10 +5,8 @@ class BulkActionException extends SCoreException
|
||||||
}
|
}
|
||||||
class BulkActionBlockBuildingEvent extends Event
|
class BulkActionBlockBuildingEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var array */
|
public array $actions = [];
|
||||||
public $actions = [];
|
public array $search_terms = [];
|
||||||
|
|
||||||
public $search_terms = [];
|
|
||||||
|
|
||||||
public function add_action(String $action, string $button_text, string $access_key = null, String $confirmation_message = "", String $block = "", int $position = 40)
|
public function add_action(String $action, string $button_text, string $access_key = null, String $confirmation_message = "", String $block = "", int $position = 40)
|
||||||
{
|
{
|
||||||
|
@ -38,12 +36,9 @@ class BulkActionBlockBuildingEvent extends Event
|
||||||
|
|
||||||
class BulkActionEvent extends Event
|
class BulkActionEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var string */
|
public string $action;
|
||||||
public $action;
|
public Generator $items;
|
||||||
/** @var array */
|
public bool $redirect = true;
|
||||||
public $items;
|
|
||||||
/** @var bool */
|
|
||||||
public $redirect = true;
|
|
||||||
|
|
||||||
public function __construct(String $action, Generator $items)
|
public function __construct(String $action, Generator $items)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +51,7 @@ class BulkActionEvent extends Event
|
||||||
class BulkActions extends Extension
|
class BulkActions extends Extension
|
||||||
{
|
{
|
||||||
/** @var BulkActionsTheme */
|
/** @var BulkActionsTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPostListBuilding(PostListBuildingEvent $event)
|
public function onPostListBuilding(PostListBuildingEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,13 +8,13 @@ function validate_selections(form, confirmationMessage) {
|
||||||
var queryOnly = false;
|
var queryOnly = false;
|
||||||
if(bulk_selector_active) {
|
if(bulk_selector_active) {
|
||||||
var data = get_selected_items();
|
var data = get_selected_items();
|
||||||
if(data.length==0) {
|
if(data.length===0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var query = $(form).find('input[name="bulk_query"]').val();
|
var query = $(form).find('input[name="bulk_query"]').val();
|
||||||
|
|
||||||
if (query == null || query == "") {
|
if (query == null || query === "") {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
queryOnly = true;
|
queryOnly = true;
|
||||||
|
@ -22,7 +22,7 @@ function validate_selections(form, confirmationMessage) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(confirmationMessage!=null&&confirmationMessage!="") {
|
if(confirmationMessage!=null&&confirmationMessage!=="") {
|
||||||
return confirm(confirmationMessage);
|
return confirm(confirmationMessage);
|
||||||
} else if(queryOnly) {
|
} else if(queryOnly) {
|
||||||
var action = $(form).find('input[name="submit_button"]').val();
|
var action = $(form).find('input[name="submit_button"]').val();
|
||||||
|
@ -59,7 +59,7 @@ function deactivate_bulk_selector() {
|
||||||
|
|
||||||
function get_selected_items() {
|
function get_selected_items() {
|
||||||
var data = $('#bulk_selected_ids').val();
|
var data = $('#bulk_selected_ids').val();
|
||||||
if(data==""||data==null) {
|
if(data===""||data==null) {
|
||||||
data = [];
|
data = [];
|
||||||
} else {
|
} else {
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
|
@ -97,11 +97,11 @@ function toggle_selection( id ) {
|
||||||
var data = get_selected_items();
|
var data = get_selected_items();
|
||||||
if(data.includes(id)) {
|
if(data.includes(id)) {
|
||||||
data.splice(data.indexOf(id),1);
|
data.splice(data.indexOf(id),1);
|
||||||
set_selected_items(data);
|
set_selected_items(data);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
data.push(id);
|
data.push(id);
|
||||||
set_selected_items(data);
|
set_selected_items(data);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ function select_all() {
|
||||||
items.push(id);
|
items.push(id);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
set_selected_items(items);
|
set_selected_items(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_invert() {
|
function select_invert() {
|
||||||
|
@ -131,11 +131,11 @@ function select_invert() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
set_selected_items(items);
|
set_selected_items(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_none() {
|
function select_none() {
|
||||||
set_selected_items([]);
|
set_selected_items([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_range(start, end) {
|
function select_range(start, end) {
|
||||||
|
@ -145,7 +145,7 @@ function select_range(start, end) {
|
||||||
function ( index, block ) {
|
function ( index, block ) {
|
||||||
block = $(block);
|
block = $(block);
|
||||||
var id = block.data("post-id");
|
var id = block.data("post-id");
|
||||||
if(id==start)
|
if(id===start)
|
||||||
selecting = true;
|
selecting = true;
|
||||||
|
|
||||||
if(selecting) {
|
if(selecting) {
|
||||||
|
@ -153,7 +153,7 @@ function select_range(start, end) {
|
||||||
data.push(id);
|
data.push(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(id==end) {
|
if(id===end) {
|
||||||
selecting = false;
|
selecting = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,14 +163,14 @@ function select_range(start, end) {
|
||||||
|
|
||||||
var last_clicked_item;
|
var last_clicked_item;
|
||||||
|
|
||||||
function add_selector_button($block) {
|
function add_selector_button($block) {
|
||||||
var c = function(e) {
|
var c = function(e) {
|
||||||
if(!bulk_selector_active)
|
if(!bulk_selector_active)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
var id = $block.data("post-id");
|
var id = $block.data("post-id");
|
||||||
if(e.shiftKey) {
|
if(e.shiftKey) {
|
||||||
if(last_clicked_item<id) {
|
if(last_clicked_item<id) {
|
||||||
|
@ -182,7 +182,7 @@ function add_selector_button($block) {
|
||||||
last_clicked_item = id;
|
last_clicked_item = id;
|
||||||
toggle_selection(id);
|
toggle_selection(id);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
$block.find("A").click(c);
|
$block.find("A").click(c);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class BulkActionsTheme extends Themelet
|
||||||
$page->add_block($block);
|
$page->add_block($block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render_ban_reason_input()
|
public function render_ban_reason_input(): string
|
||||||
{
|
{
|
||||||
if (class_exists("ImageBan")) {
|
if (class_exists("ImageBan")) {
|
||||||
return "<input type='text' name='bulk_ban_reason' placeholder='Ban reason (leave blank to not ban)' />";
|
return "<input type='text' name='bulk_ban_reason' placeholder='Ban reason (leave blank to not ban)' />";
|
||||||
|
@ -54,13 +54,13 @@ class BulkActionsTheme extends Themelet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render_tag_input()
|
public function render_tag_input(): string
|
||||||
{
|
{
|
||||||
return "<label><input type='checkbox' style='width:13px;' name='bulk_tags_replace' value='true'/>Replace tags</label>" .
|
return "<label><input type='checkbox' style='width:13px;' name='bulk_tags_replace' value='true'/>Replace tags</label>" .
|
||||||
"<input type='text' name='bulk_tags' required='required' placeholder='Enter tags here' />";
|
"<input type='text' name='bulk_tags' required='required' placeholder='Enter tags here' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render_source_input()
|
public function render_source_input(): string
|
||||||
{
|
{
|
||||||
return "<input type='text' name='bulk_source' required='required' placeholder='Enter source here' />";
|
return "<input type='text' name='bulk_source' required='required' placeholder='Enter source here' />";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@ class BulkAddInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "bulk_add";
|
public const KEY = "bulk_add";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Bulk Add";
|
public string $name = "Bulk Add";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Bulk add server-side images";
|
public string $description = "Bulk add server-side images";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Upload the images into a new directory via ftp or similar, go to
|
"Upload the images into a new directory via ftp or similar, go to
|
||||||
shimmie's admin page and put that directory in the bulk add box.
|
shimmie's admin page and put that directory in the bulk add box.
|
||||||
If there are subdirectories, they get used as tags (eg if you
|
If there are subdirectories, they get used as tags (eg if you
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
class BulkAddEvent extends Event
|
class BulkAddEvent extends Event
|
||||||
{
|
{
|
||||||
public $dir;
|
public string $dir;
|
||||||
public $results;
|
public array $results;
|
||||||
|
|
||||||
public function __construct(string $dir)
|
public function __construct(string $dir)
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@ class BulkAddEvent extends Event
|
||||||
class BulkAdd extends Extension
|
class BulkAdd extends Extension
|
||||||
{
|
{
|
||||||
/** @var BulkAddTheme */
|
/** @var BulkAddTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
class BulkAddTheme extends Themelet
|
class BulkAddTheme extends Themelet
|
||||||
{
|
{
|
||||||
private $messages = [];
|
private array $messages = [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show a standard page for results to be put into
|
* Show a standard page for results to be put into
|
||||||
|
|
|
@ -4,13 +4,13 @@ class BulkAddCSVInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "bulk_add_csv";
|
public const KEY = "bulk_add_csv";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Bulk Add CSV";
|
public string $name = "Bulk Add CSV";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = ["velocity37"=>"velocity37@gmail.com"];
|
public array $authors = ["velocity37"=>"velocity37@gmail.com"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Bulk add server-side posts with metadata from CSV file";
|
public string $description = "Bulk add server-side posts with metadata from CSV file";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Modification of \"Bulk Add\" by Shish.<br><br>
|
"Modification of \"Bulk Add\" by Shish.<br><br>
|
||||||
Adds posts from a CSV with the five following values: <br>
|
Adds posts from a CSV with the five following values: <br>
|
||||||
\"/path/to/image.jpg\",\"spaced tags\",\"source\",\"rating s/q/e\",\"/path/thumbnail.jpg\" <br>
|
\"/path/to/image.jpg\",\"spaced tags\",\"source\",\"rating s/q/e\",\"/path/thumbnail.jpg\" <br>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class BulkAddCSV extends Extension
|
class BulkAddCSV extends Extension
|
||||||
{
|
{
|
||||||
/** @var BulkAddCSVTheme */
|
/** @var BulkAddCSVTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
class BulkAddCSVTheme extends Themelet
|
class BulkAddCSVTheme extends Themelet
|
||||||
{
|
{
|
||||||
private $messages = [];
|
private array $messages = [];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show a standard page for results to be put into
|
* Show a standard page for results to be put into
|
||||||
|
|
|
@ -5,10 +5,10 @@ class BulkDownloadInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "bulk_download";
|
public const KEY = "bulk_download";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Bulk Download";
|
public string $name = "Bulk Download";
|
||||||
public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
||||||
public $license = self::LICENSE_WTFPL;
|
public string $license = self::LICENSE_WTFPL;
|
||||||
public $description = "Allows bulk downloading images.";
|
public string $description = "Allows bulk downloading images.";
|
||||||
public $dependencies = [BulkActionsInfo::KEY];
|
public array $dependencies = [BulkActionsInfo::KEY];
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
class BulkExportEvent extends Event
|
class BulkExportEvent extends Event
|
||||||
{
|
{
|
||||||
public $image;
|
public Image $image;
|
||||||
public $fields = [];
|
public array $fields = [];
|
||||||
|
|
||||||
public function __construct(Image $image)
|
public function __construct(Image $image)
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,8 @@ class BulkExportEvent extends Event
|
||||||
|
|
||||||
class BulkImportEvent extends Event
|
class BulkImportEvent extends Event
|
||||||
{
|
{
|
||||||
public $image;
|
public Image $image;
|
||||||
public $fields = [];
|
public array $fields = [];
|
||||||
|
|
||||||
public function __construct(Image $image, $fields)
|
public function __construct(Image $image, $fields)
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,10 +6,10 @@ class BulkImportExportInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "bulk_import_export";
|
public const KEY = "bulk_import_export";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Bulk Import/Export";
|
public string $name = "Bulk Import/Export";
|
||||||
public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
||||||
public $license = self::LICENSE_WTFPL;
|
public string $license = self::LICENSE_WTFPL;
|
||||||
public $description = "Allows bulk exporting/importing of images and associated data.";
|
public string $description = "Allows bulk exporting/importing of images and associated data.";
|
||||||
public $dependencies = [BulkActionsInfo::KEY];
|
public array $dependencies = [BulkActionsInfo::KEY];
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ class BulkImportExport extends DataHandlerExtension
|
||||||
{
|
{
|
||||||
const EXPORT_ACTION_NAME = "bulk_export";
|
const EXPORT_ACTION_NAME = "bulk_export";
|
||||||
const EXPORT_INFO_FILE_NAME = "export.json";
|
const EXPORT_INFO_FILE_NAME = "export.json";
|
||||||
protected $SUPPORTED_MIME = [MimeType::ZIP];
|
protected array $SUPPORTED_MIME = [MimeType::ZIP];
|
||||||
|
|
||||||
|
|
||||||
public function onDataUpload(DataUploadEvent $event)
|
public function onDataUpload(DataUploadEvent $event)
|
||||||
|
@ -159,7 +159,7 @@ class BulkImportExport extends DataHandlerExtension
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function create_thumb(string $hash, string $type): bool
|
protected function create_thumb(string $hash, string $mime): bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ class CommentListInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "comment";
|
public const KEY = "comment";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Post Comments";
|
public string $name = "Post Comments";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Allow users to make comments on images";
|
public string $description = "Allow users to make comments on images";
|
||||||
public $documentation = "Formatting is done with the standard formatting API (normally BBCode)";
|
public ?string $documentation = "Formatting is done with the standard formatting API (normally BBCode)";
|
||||||
public $core = true;
|
public bool $core = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,9 @@ require_once "vendor/ifixit/php-akismet/akismet.class.php";
|
||||||
|
|
||||||
class CommentPostingEvent extends Event
|
class CommentPostingEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var int */
|
public int $image_id;
|
||||||
public $image_id;
|
public User $user;
|
||||||
/** @var User */
|
public string $comment;
|
||||||
public $user;
|
|
||||||
/** @var string */
|
|
||||||
public $comment;
|
|
||||||
|
|
||||||
public function __construct(int $image_id, User $user, string $comment)
|
public function __construct(int $image_id, User $user, string $comment)
|
||||||
{
|
{
|
||||||
|
@ -27,8 +24,7 @@ class CommentPostingEvent extends Event
|
||||||
*/
|
*/
|
||||||
class CommentDeletionEvent extends Event
|
class CommentDeletionEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var int */
|
public int $comment_id;
|
||||||
public $comment_id;
|
|
||||||
|
|
||||||
public function __construct(int $comment_id)
|
public function __construct(int $comment_id)
|
||||||
{
|
{
|
||||||
|
@ -43,46 +39,27 @@ class CommentPostingException extends SCoreException
|
||||||
|
|
||||||
class Comment
|
class Comment
|
||||||
{
|
{
|
||||||
/** @var User */
|
public ?User $owner;
|
||||||
public $owner;
|
public int $owner_id;
|
||||||
|
public string $owner_name;
|
||||||
/** @var int */
|
public ?string $owner_email;
|
||||||
public $owner_id;
|
public string $owner_class;
|
||||||
|
public string $comment;
|
||||||
/** @var string */
|
public int $comment_id;
|
||||||
public $owner_name;
|
public int $image_id;
|
||||||
|
public string $poster_ip;
|
||||||
/** @var string */
|
public string $posted;
|
||||||
public $owner_email;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $owner_class;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $comment;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
public $comment_id;
|
|
||||||
|
|
||||||
/** @var int */
|
|
||||||
public $image_id;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $poster_ip;
|
|
||||||
|
|
||||||
/** @var string */
|
|
||||||
public $posted;
|
|
||||||
|
|
||||||
public function __construct($row)
|
public function __construct($row)
|
||||||
{
|
{
|
||||||
$this->owner = null;
|
$this->owner = null;
|
||||||
$this->owner_id = $row['user_id'];
|
$this->owner_id = (int)$row['user_id'];
|
||||||
$this->owner_name = $row['user_name'];
|
$this->owner_name = $row['user_name'];
|
||||||
$this->owner_email = $row['user_email']; // deprecated
|
$this->owner_email = $row['user_email']; // deprecated
|
||||||
$this->owner_class = $row['user_class'];
|
$this->owner_class = $row['user_class'];
|
||||||
$this->comment = $row['comment'];
|
$this->comment = $row['comment'];
|
||||||
$this->comment_id = $row['comment_id'];
|
$this->comment_id = (int)$row['comment_id'];
|
||||||
$this->image_id = $row['image_id'];
|
$this->image_id = (int)$row['image_id'];
|
||||||
$this->poster_ip = $row['poster_ip'];
|
$this->poster_ip = $row['poster_ip'];
|
||||||
$this->posted = $row['posted'];
|
$this->posted = $row['posted'];
|
||||||
}
|
}
|
||||||
|
@ -109,7 +86,7 @@ class Comment
|
||||||
class CommentList extends Extension
|
class CommentList extends Extension
|
||||||
{
|
{
|
||||||
/** @var CommentListTheme $theme */
|
/** @var CommentListTheme $theme */
|
||||||
public $theme;
|
public ?Themelet $theme;
|
||||||
|
|
||||||
public function onInitExt(InitExtEvent $event)
|
public function onInitExt(InitExtEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
class CommentListTheme extends Themelet
|
class CommentListTheme extends Themelet
|
||||||
{
|
{
|
||||||
private $show_anon_id = false;
|
private bool $show_anon_id = false;
|
||||||
private $anon_id = 1;
|
private int $anon_id = 1;
|
||||||
private $anon_map = [];
|
private array $anon_map = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a page with a list of images, and for each image, the image's comments.
|
* Display a page with a list of images, and for each image, the image's comments.
|
||||||
|
@ -86,7 +86,6 @@ class CommentListTheme extends Themelet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function display_admin_block()
|
public function display_admin_block()
|
||||||
{
|
{
|
||||||
global $page;
|
global $page;
|
||||||
|
@ -104,7 +103,6 @@ class CommentListTheme extends Themelet
|
||||||
$page->add_block(new Block("Mass Comment Delete", $html));
|
$page->add_block(new Block("Mass Comment Delete", $html));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add some comments to the page, probably in a sidebar.
|
* Add some comments to the page, probably in a sidebar.
|
||||||
*
|
*
|
||||||
|
@ -122,7 +120,6 @@ class CommentListTheme extends Themelet
|
||||||
$page->add_block(new Block("Comments", $html, "left", 50, "comment-list-recent"));
|
$page->add_block(new Block("Comments", $html, "left", 50, "comment-list-recent"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show comments for an image.
|
* Show comments for an image.
|
||||||
*
|
*
|
||||||
|
@ -142,7 +139,6 @@ class CommentListTheme extends Themelet
|
||||||
$page->add_block(new Block("Comments", $html, "main", 30, "comment-list-image"));
|
$page->add_block(new Block("Comments", $html, "main", 30, "comment-list-image"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show comments made by a user.
|
* Show comments made by a user.
|
||||||
*
|
*
|
||||||
|
@ -287,7 +283,7 @@ class CommentListTheme extends Themelet
|
||||||
';
|
';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_help_html()
|
public function get_help_html(): string
|
||||||
{
|
{
|
||||||
return '<p>Search for posts containing a certain number of comments, or comments by a particular individual.</p>
|
return '<p>Search for posts containing a certain number of comments, or comments by a particular individual.</p>
|
||||||
<div class="command_example">
|
<div class="command_example">
|
||||||
|
|
|
@ -13,12 +13,12 @@ class CronUploaderInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "cron_uploader";
|
public const KEY = "cron_uploader";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Cron Uploader";
|
public string $name = "Cron Uploader";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = ["YaoiFox"=>"admin@yaoifox.com", "Matthew Barbour"=>"matthew@darkholme.net"];
|
public array $authors = ["YaoiFox"=>"admin@yaoifox.com", "Matthew Barbour"=>"matthew@darkholme.net"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Uploads images automatically using Cron Jobs";
|
public string $description = "Uploads images automatically using Cron Jobs";
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,7 +5,7 @@ require_once "config.php";
|
||||||
class CronUploader extends Extension
|
class CronUploader extends Extension
|
||||||
{
|
{
|
||||||
/** @var CronUploaderTheme */
|
/** @var CronUploaderTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public const NAME = "cron_uploader";
|
public const NAME = "cron_uploader";
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ class CronUploader extends Extension
|
||||||
const UPLOADED_DIR = "uploaded";
|
const UPLOADED_DIR = "uploaded";
|
||||||
const FAILED_DIR = "failed_to_upload";
|
const FAILED_DIR = "failed_to_upload";
|
||||||
|
|
||||||
private static $IMPORT_RUNNING = false;
|
private static bool $IMPORT_RUNNING = false;
|
||||||
|
|
||||||
public function onInitUserConfig(InitUserConfigEvent $event)
|
public function onInitUserConfig(InitUserConfigEvent $event)
|
||||||
{
|
{
|
||||||
|
@ -201,7 +201,7 @@ class CronUploader extends Extension
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function get_cron_url()
|
private function get_cron_url(): string
|
||||||
{
|
{
|
||||||
global $user_config;
|
global $user_config;
|
||||||
|
|
||||||
|
@ -210,12 +210,12 @@ class CronUploader extends Extension
|
||||||
return make_http(make_link("/cron_upload/run", "api_key=".urlencode($user_api_key)));
|
return make_http(make_link("/cron_upload/run", "api_key=".urlencode($user_api_key)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_cron_cmd()
|
private function get_cron_cmd(): string
|
||||||
{
|
{
|
||||||
return "curl --silent " . $this->get_cron_url();
|
return "curl --silent " . $this->get_cron_url();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function display_documentation()
|
private function display_documentation(): void
|
||||||
{
|
{
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
|
@ -261,7 +261,7 @@ class CronUploader extends Extension
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_queue_dir()
|
public function get_queue_dir(): string
|
||||||
{
|
{
|
||||||
global $user_config;
|
global $user_config;
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ class CronUploader extends Extension
|
||||||
return join_path($dir, self::QUEUE_DIR);
|
return join_path($dir, self::QUEUE_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_uploaded_dir()
|
public function get_uploaded_dir(): string
|
||||||
{
|
{
|
||||||
global $user_config;
|
global $user_config;
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ class CronUploader extends Extension
|
||||||
return join_path($dir, self::UPLOADED_DIR);
|
return join_path($dir, self::UPLOADED_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_failed_dir()
|
public function get_failed_dir(): string
|
||||||
{
|
{
|
||||||
global $user_config;
|
global $user_config;
|
||||||
|
|
||||||
|
@ -499,7 +499,7 @@ class CronUploader extends Extension
|
||||||
private const SKIPPABLE_FILES = ['.ds_store','thumbs.db'];
|
private const SKIPPABLE_FILES = ['.ds_store','thumbs.db'];
|
||||||
private const SKIPPABLE_DIRECTORIES = ['__macosx'];
|
private const SKIPPABLE_DIRECTORIES = ['__macosx'];
|
||||||
|
|
||||||
private function is_skippable_dir(string $path)
|
private function is_skippable_dir(string $path): bool
|
||||||
{
|
{
|
||||||
$info = pathinfo($path);
|
$info = pathinfo($path);
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ class CronUploader extends Extension
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function is_skippable_file(string $path)
|
private function is_skippable_file(string $path): bool
|
||||||
{
|
{
|
||||||
$info = pathinfo($path);
|
$info = pathinfo($path);
|
||||||
|
|
||||||
|
|
|
@ -10,8 +10,6 @@ use function MicroHTML\TD;
|
||||||
use function MicroHTML\INPUT;
|
use function MicroHTML\INPUT;
|
||||||
use function MicroHTML\rawHTML;
|
use function MicroHTML\rawHTML;
|
||||||
use function MicroHTML\emptyHTML;
|
use function MicroHTML\emptyHTML;
|
||||||
use function MicroHTML\SELECT;
|
|
||||||
use function MicroHTML\OPTION;
|
|
||||||
|
|
||||||
class CronUploaderTheme extends Themelet
|
class CronUploaderTheme extends Themelet
|
||||||
{
|
{
|
||||||
|
@ -33,7 +31,6 @@ class CronUploaderTheme extends Themelet
|
||||||
|
|
||||||
if (!$config->get_bool(UserConfig::ENABLE_API_KEYS)) {
|
if (!$config->get_bool(UserConfig::ENABLE_API_KEYS)) {
|
||||||
$info_html .= "<b style='color:red'>THIS EXTENSION REQUIRES USER API KEYS TO BE ENABLED IN <a href=''>BOARD ADMIN</a></b>";
|
$info_html .= "<b style='color:red'>THIS EXTENSION REQUIRES USER API KEYS TO BE ENABLED IN <a href=''>BOARD ADMIN</a></b>";
|
||||||
} else {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$info_html .= "<b>Information</b>
|
$info_html .= "<b>Information</b>
|
||||||
|
|
|
@ -4,13 +4,13 @@ class CustomHtmlHeadersInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "custom_html_headers";
|
public const KEY = "custom_html_headers";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Custom HTML Headers";
|
public string $name = "Custom HTML Headers";
|
||||||
public $url = "http://www.drudexsoftware.com";
|
public string $url = "http://www.drudexsoftware.com";
|
||||||
public $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
|
public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Allows admins to modify & set custom <head> content";
|
public string $description = "Allows admins to modify & set custom <head> content";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"When you go to board config you can find a block named Custom HTML Headers.
|
"When you go to board config you can find a block named Custom HTML Headers.
|
||||||
In that block you can simply place any thing you can place within <head></head>
|
In that block you can simply place any thing you can place within <head></head>
|
||||||
|
|
||||||
|
|
|
@ -4,11 +4,11 @@ class DanbooruApiInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "danbooru_api";
|
public const KEY = "danbooru_api";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Danbooru Client API";
|
public string $name = "Danbooru Client API";
|
||||||
public $authors = ["JJS"=>"jsutinen@gmail.com"];
|
public array $authors = ["JJS"=>"jsutinen@gmail.com"];
|
||||||
public $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie";
|
public string $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"<p>Notes:
|
"<p>Notes:
|
||||||
<br>danbooru API based on documentation from danbooru 1.0 -
|
<br>danbooru API based on documentation from danbooru 1.0 -
|
||||||
http://attachr.com/7569
|
http://attachr.com/7569
|
||||||
|
|
|
@ -2,19 +2,19 @@
|
||||||
|
|
||||||
use \MicroHTML\HTMLElement;
|
use \MicroHTML\HTMLElement;
|
||||||
|
|
||||||
function TAGS(...$args)
|
function TAGS(...$args): HTMLElement
|
||||||
{
|
{
|
||||||
return new HTMLElement("tags", $args);
|
return new HTMLElement("tags", $args);
|
||||||
}
|
}
|
||||||
function TAG(...$args)
|
function TAG(...$args): HTMLElement
|
||||||
{
|
{
|
||||||
return new HTMLElement("tag", $args);
|
return new HTMLElement("tag", $args);
|
||||||
}
|
}
|
||||||
function POSTS(...$args)
|
function POSTS(...$args): HTMLElement
|
||||||
{
|
{
|
||||||
return new HTMLElement("posts", $args);
|
return new HTMLElement("posts", $args);
|
||||||
}
|
}
|
||||||
function POST(...$args)
|
function POST(...$args): HTMLElement
|
||||||
{
|
{
|
||||||
return new HTMLElement("post", $args);
|
return new HTMLElement("post", $args);
|
||||||
}
|
}
|
||||||
|
@ -114,11 +114,14 @@ class DanbooruApi extends Extension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Currently disabled to maintain identical functionality to danbooru 1.0's own "broken" find_tags
|
// Currently disabled to maintain identical functionality to danbooru 1.0's own "broken" find_tags
|
||||||
elseif (false && isset($_GET['tags'])) {
|
/*
|
||||||
|
elseif (isset($_GET['tags'])) {
|
||||||
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
|
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
|
||||||
$tags = Tag::explode($_GET['tags']);
|
$tags = Tag::explode($_GET['tags']);
|
||||||
assert(!is_null($start) && !is_null($tags));
|
assert(!is_null($start) && !is_null($tags));
|
||||||
} else {
|
}
|
||||||
|
*/
|
||||||
|
else {
|
||||||
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
|
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
|
||||||
$sqlresult = $database->get_all(
|
$sqlresult = $database->get_all(
|
||||||
"SELECT id,tag,count FROM tags WHERE count > 0 AND id >= :id ORDER BY id DESC",
|
"SELECT id,tag,count FROM tags WHERE count > 0 AND id >= :id ORDER BY id DESC",
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
class ImageDownloadingEvent extends Event
|
class ImageDownloadingEvent extends Event
|
||||||
{
|
{
|
||||||
public $image;
|
public Image $image;
|
||||||
public $mime;
|
public string $mime;
|
||||||
public $path;
|
public string $path;
|
||||||
public $file_modified = false;
|
public bool $file_modified = false;
|
||||||
|
|
||||||
public function __construct(Image $image, String $path, string $mime)
|
public function __construct(Image $image, string $path, string $mime)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->image = $image;
|
$this->image = $image;
|
||||||
|
|
|
@ -4,11 +4,11 @@ class DownloadInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "download";
|
public const KEY = "download";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Download";
|
public string $name = "Download";
|
||||||
public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"];
|
||||||
public $license = self::LICENSE_WTFPL;
|
public string $license = self::LICENSE_WTFPL;
|
||||||
public $description = "System-wide download functions";
|
public string $description = "System-wide download functions";
|
||||||
public $core = true;
|
public bool $core = true;
|
||||||
public $visibility = self::VISIBLE_HIDDEN;
|
public string $visibility = self::VISIBLE_HIDDEN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@ class DowntimeInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "downtime";
|
public const KEY = "downtime";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Downtime";
|
public string $name = "Downtime";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Show a \"down for maintenance\" page";
|
public string $description = "Show a \"down for maintenance\" page";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Once installed there will be some more options on the config page --
|
"Once installed there will be some more options on the config page --
|
||||||
Ticking \"disable non-admin access\" will mean that regular and anonymous
|
Ticking \"disable non-admin access\" will mean that regular and anonymous
|
||||||
users will be blocked from accessing the site, only able to view the
|
users will be blocked from accessing the site, only able to view the
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class Downtime extends Extension
|
class Downtime extends Extension
|
||||||
{
|
{
|
||||||
/** @var DowntimeTheme */
|
/** @var DowntimeTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function get_priority(): int
|
public function get_priority(): int
|
||||||
{
|
{
|
||||||
|
@ -35,7 +35,7 @@ class Downtime extends Extension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function is_safe_page(PageRequestEvent $event)
|
private function is_safe_page(PageRequestEvent $event): bool
|
||||||
{
|
{
|
||||||
if ($event->page_matches("user_admin/login")) {
|
if ($event->page_matches("user_admin/login")) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -4,14 +4,14 @@ class EmoticonsInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "emoticons";
|
public const KEY = "emoticons";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Emoticon Filter";
|
public string $name = "Emoticon Filter";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $dependencies = [EmoticonListInfo::KEY];
|
public array $dependencies = [EmoticonListInfo::KEY];
|
||||||
public $description = "Lets users use graphical smilies";
|
public string $description = "Lets users use graphical smilies";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"This extension will turn colon-something-colon into a link
|
"This extension will turn colon-something-colon into a link
|
||||||
to an image with that something as the name, eg :smile:
|
to an image with that something as the name, eg :smile:
|
||||||
becomes a link to smile.gif
|
becomes a link to smile.gif
|
||||||
|
|
|
@ -4,12 +4,12 @@ class EmoticonListInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "emoticons_list";
|
public const KEY = "emoticons_list";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Emoticon List";
|
public string $name = "Emoticon List";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Lists available graphical smilies";
|
public string $description = "Lists available graphical smilies";
|
||||||
|
|
||||||
public $visibility = self::VISIBLE_HIDDEN;
|
public string $visibility = self::VISIBLE_HIDDEN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
class EmoticonList extends Extension
|
class EmoticonList extends Extension
|
||||||
{
|
{
|
||||||
/** @var EmoticonListTheme */
|
/** @var EmoticonListTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,10 +4,10 @@ class EokmInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "eokm";
|
public const KEY = "eokm";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "EOKM Filter";
|
public string $name = "EOKM Filter";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Check uploads against the EOKM blocklist";
|
public string $description = "Check uploads against the EOKM blocklist";
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ class Eokm extends Extension
|
||||||
$return = curl_exec($ch);
|
$return = curl_exec($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
|
/** @noinspection PhpStatementHasEmptyBodyInspection */
|
||||||
if ($return == "false") {
|
if ($return == "false") {
|
||||||
// all ok
|
// all ok
|
||||||
} elseif ($return == "true") {
|
} elseif ($return == "true") {
|
||||||
|
|
|
@ -4,14 +4,14 @@ class ETInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "et";
|
public const KEY = "et";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "System Info";
|
public string $name = "System Info";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $core = true;
|
public bool $core = true;
|
||||||
public $description = "Show various bits of system information";
|
public string $description = "Show various bits of system information";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Knowing the information that this extension shows can be very useful for debugging. There's also an option to send
|
"Knowing the information that this extension shows can be very useful for debugging. There's also an option to send
|
||||||
your stats to my database, so I can get some idea of how shimmie is used, which servers I need to support, which
|
your stats to my database, so I can get some idea of how shimmie is used, which servers I need to support, which
|
||||||
versions of PHP I should test with, etc.";
|
versions of PHP I should test with, etc.";
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class ET extends Extension
|
class ET extends Extension
|
||||||
{
|
{
|
||||||
/** @var ETTheme */
|
/** @var ETTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
|
@ -116,7 +116,7 @@ class ET extends Extension
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function to_yaml($info)
|
private function to_yaml(array $info): string
|
||||||
{
|
{
|
||||||
$data = "";
|
$data = "";
|
||||||
foreach ($info as $title => $section) {
|
foreach ($info as $title => $section) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ class ETTheme extends Themelet
|
||||||
$page->add_block(new Block("Information:", $this->build_data_form($yaml)));
|
$page->add_block(new Block("Information:", $this->build_data_form($yaml)));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function build_data_form($yaml)
|
protected function build_data_form($yaml): string
|
||||||
{
|
{
|
||||||
return (string)FORM(
|
return (string)FORM(
|
||||||
["action"=>"https://shimmie.shishnet.org/register.php", "method"=>"POST"],
|
["action"=>"https://shimmie.shishnet.org/register.php", "method"=>"POST"],
|
||||||
|
|
|
@ -4,12 +4,12 @@ class ETServerInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "et_server";
|
public const KEY = "et_server";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "System Info Registry";
|
public string $name = "System Info Registry";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Keep track of shimmie registrations";
|
public string $description = "Keep track of shimmie registrations";
|
||||||
public $documentation = "For internal use";
|
public ?string $documentation = "For internal use";
|
||||||
public $visibility = self::VISIBLE_HIDDEN;
|
public string $visibility = self::VISIBLE_HIDDEN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,13 @@ class ExtManagerInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "ext_manager";
|
public const KEY = "ext_manager";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Extension Manager";
|
public string $name = "Extension Manager";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $visibility = self::VISIBLE_ADMIN;
|
public string $visibility = self::VISIBLE_ADMIN;
|
||||||
public $description = "A thing for point & click extension management";
|
public string $description = "A thing for point & click extension management";
|
||||||
public $documentation = "Allows the admin to view a list of all extensions and enable or disable them; also allows users to view the list of activated extensions and read their documentation";
|
public ?string $documentation = "Allows the admin to view a list of all extensions and enable or disable them; also allows users to view the list of activated extensions and read their documentation";
|
||||||
public $core = true;
|
public bool $core = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,8 @@ function __extman_extactive(ExtensionInfo $a): bool
|
||||||
|
|
||||||
class ExtensionAuthor
|
class ExtensionAuthor
|
||||||
{
|
{
|
||||||
public $name;
|
public string $name;
|
||||||
public $email;
|
public ?string $email;
|
||||||
|
|
||||||
public function __construct(string $name, ?string $email)
|
public function __construct(string $name, ?string $email)
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ class ExtensionAuthor
|
||||||
class ExtManager extends Extension
|
class ExtManager extends Extension
|
||||||
{
|
{
|
||||||
/** @var ExtManagerTheme */
|
/** @var ExtManagerTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,12 +4,12 @@ class FavoritesInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "favorites";
|
public const KEY = "favorites";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Favorites";
|
public string $name = "Favorites";
|
||||||
public $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"];
|
public array $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Allow users to favorite images";
|
public string $description = "Allow users to favorite images";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Gives users a \"favorite this image\" button that they can press
|
"Gives users a \"favorite this image\" button that they can press
|
||||||
<p>Favorites for a user can then be retrieved by searching for \"favorited_by=UserName\"
|
<p>Favorites for a user can then be retrieved by searching for \"favorited_by=UserName\"
|
||||||
<p>Popular images can be searched for by eg. \"favorites>5\"
|
<p>Popular images can be searched for by eg. \"favorites>5\"
|
||||||
|
|
|
@ -2,12 +2,9 @@
|
||||||
|
|
||||||
class FavoriteSetEvent extends Event
|
class FavoriteSetEvent extends Event
|
||||||
{
|
{
|
||||||
/** @var int */
|
public int $image_id;
|
||||||
public $image_id;
|
public User $user;
|
||||||
/** @var User */
|
public bool $do_set;
|
||||||
public $user;
|
|
||||||
/** @var bool */
|
|
||||||
public $do_set;
|
|
||||||
|
|
||||||
public function __construct(int $image_id, User $user, bool $do_set)
|
public function __construct(int $image_id, User $user, bool $do_set)
|
||||||
{
|
{
|
||||||
|
@ -24,7 +21,7 @@ class FavoriteSetEvent extends Event
|
||||||
class Favorites extends Extension
|
class Favorites extends Extension
|
||||||
{
|
{
|
||||||
/** @var FavoritesTheme */
|
/** @var FavoritesTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
use function MicroHTML\INPUT;
|
use function MicroHTML\INPUT;
|
||||||
|
use MicroHTML\HTMLElement;
|
||||||
|
|
||||||
class FavoritesTheme extends Themelet
|
class FavoritesTheme extends Themelet
|
||||||
{
|
{
|
||||||
public function get_voter_html(Image $image, $is_favorited)
|
public function get_voter_html(Image $image, bool $is_favorited): HTMLElement
|
||||||
{
|
{
|
||||||
$name = $is_favorited ? "unset" : "set";
|
$name = $is_favorited ? "unset" : "set";
|
||||||
$label = $is_favorited ? "Un-Favorite" : "Favorite";
|
$label = $is_favorited ? "Un-Favorite" : "Favorite";
|
||||||
|
@ -15,7 +16,7 @@ class FavoritesTheme extends Themelet
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function display_people($username_array)
|
public function display_people(array $username_array): void
|
||||||
{
|
{
|
||||||
global $page;
|
global $page;
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ class FavoritesTheme extends Themelet
|
||||||
$page->add_block(new Block("Favorited By", $html, "left", 25));
|
$page->add_block(new Block("Favorited By", $html, "left", 25));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_help_html()
|
public function get_help_html(): string
|
||||||
{
|
{
|
||||||
return '<p>Search for posts that have been favorited a certain number of times, or favorited by a particular individual.</p>
|
return '<p>Search for posts that have been favorited a certain number of times, or favorited by a particular individual.</p>
|
||||||
<div class="command_example">
|
<div class="command_example">
|
||||||
|
|
|
@ -4,13 +4,13 @@ class FeaturedInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "featured";
|
public const KEY = "featured";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Featured Post";
|
public string $name = "Featured Post";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Bring a specific image to the users' attentions";
|
public string $description = "Bring a specific image to the users' attentions";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Once enabled, a new \"feature this\" button will appear next
|
"Once enabled, a new \"feature this\" button will appear next
|
||||||
to the other post control buttons (delete, rotate, etc).
|
to the other post control buttons (delete, rotate, etc).
|
||||||
Clicking it will set the image as the site's current feature,
|
Clicking it will set the image as the site's current feature,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class Featured extends Extension
|
class Featured extends Extension
|
||||||
{
|
{
|
||||||
/** @var FeaturedTheme */
|
/** @var FeaturedTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onInitExt(InitExtEvent $event)
|
public function onInitExt(InitExtEvent $event)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,9 +4,9 @@ class ForumInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "forum";
|
public const KEY = "forum";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Forum";
|
public string $name = "Forum";
|
||||||
public $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"];
|
public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Rough forum extension";
|
public string $description = "Rough forum extension";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ Todo:
|
||||||
class Forum extends Extension
|
class Forum extends Extension
|
||||||
{
|
{
|
||||||
/** @var ForumTheme */
|
/** @var ForumTheme */
|
||||||
protected $theme;
|
protected ?Themelet $theme;
|
||||||
|
|
||||||
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
|
||||||
{
|
{
|
||||||
|
@ -189,15 +189,15 @@ class Forum extends Extension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_total_pages_for_thread(int $threadID)
|
private function get_total_pages_for_thread(int $threadID): int
|
||||||
{
|
{
|
||||||
global $database, $config;
|
global $database, $config;
|
||||||
$result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]);
|
$result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]);
|
||||||
|
|
||||||
return ceil($result["count"] / $config->get_int("forumPostsPerPage"));
|
return (int)ceil($result["count"] / $config->get_int("forumPostsPerPage"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sanity_check_new_thread()
|
private function sanity_check_new_thread(): array
|
||||||
{
|
{
|
||||||
$errors = null;
|
$errors = null;
|
||||||
if (!array_key_exists("title", $_POST)) {
|
if (!array_key_exists("title", $_POST)) {
|
||||||
|
@ -217,7 +217,7 @@ class Forum extends Extension
|
||||||
return [$errors];
|
return [$errors];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sanity_check_new_post()
|
private function sanity_check_new_post(): array
|
||||||
{
|
{
|
||||||
$errors = null;
|
$errors = null;
|
||||||
if (!array_key_exists("threadID", $_POST)) {
|
if (!array_key_exists("threadID", $_POST)) {
|
||||||
|
@ -235,7 +235,7 @@ class Forum extends Extension
|
||||||
return [$errors];
|
return [$errors];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sanity_check_viewed_thread(int $threadID)
|
private function sanity_check_viewed_thread(int $threadID): array
|
||||||
{
|
{
|
||||||
$errors = null;
|
$errors = null;
|
||||||
if (!$this->threadExists($threadID)) {
|
if (!$this->threadExists($threadID)) {
|
||||||
|
@ -244,14 +244,14 @@ class Forum extends Extension
|
||||||
return [$errors];
|
return [$errors];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function get_thread_title(int $threadID)
|
private function get_thread_title(int $threadID): string
|
||||||
{
|
{
|
||||||
global $database;
|
global $database;
|
||||||
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = :id ", ['id'=>$threadID]);
|
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = :id ", ['id'=>$threadID]);
|
||||||
return $result["title"];
|
return $result["title"];
|
||||||
}
|
}
|
||||||
|
|
||||||
private function show_last_threads(Page $page, PageRequestEvent $event, $showAdminOptions = false)
|
private function show_last_threads(Page $page, PageRequestEvent $event, bool $showAdminOptions = false): void
|
||||||
{
|
{
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
$threadsPerPage = $config->get_int('forumThreadsPerPage', 15);
|
$threadsPerPage = $config->get_int('forumThreadsPerPage', 15);
|
||||||
|
@ -278,7 +278,7 @@ class Forum extends Extension
|
||||||
$this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages);
|
$this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function show_posts(PageRequestEvent $event, $showAdminOptions = false)
|
private function show_posts(PageRequestEvent $event, bool $showAdminOptions = false): void
|
||||||
{
|
{
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
$threadID = int_escape($event->get_arg(1));
|
$threadID = int_escape($event->get_arg(1));
|
||||||
|
@ -305,7 +305,7 @@ class Forum extends Extension
|
||||||
$this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages);
|
$this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function save_new_thread(User $user)
|
private function save_new_thread(User $user): int
|
||||||
{
|
{
|
||||||
$title = html_escape($_POST["title"]);
|
$title = html_escape($_POST["title"]);
|
||||||
$sticky = !empty($_POST["sticky"]);
|
$sticky = !empty($_POST["sticky"]);
|
||||||
|
@ -327,7 +327,7 @@ class Forum extends Extension
|
||||||
return $threadID;
|
return $threadID;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function save_new_post(int $threadID, User $user)
|
private function save_new_post(int $threadID, User $user): void
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
$userID = $user->id;
|
$userID = $user->id;
|
||||||
|
@ -349,7 +349,7 @@ class Forum extends Extension
|
||||||
$database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=:id", ['id'=>$threadID]);
|
$database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=:id", ['id'=>$threadID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function retrieve_posts(int $threadID, int $pageNumber)
|
private function retrieve_posts(int $threadID, int $pageNumber): array
|
||||||
{
|
{
|
||||||
global $database, $config;
|
global $database, $config;
|
||||||
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
||||||
|
@ -366,20 +366,20 @@ class Forum extends Extension
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function delete_thread(int $threadID)
|
private function delete_thread(int $threadID): void
|
||||||
{
|
{
|
||||||
global $database;
|
global $database;
|
||||||
$database->execute("DELETE FROM forum_threads WHERE id = :id", ['id'=>$threadID]);
|
$database->execute("DELETE FROM forum_threads WHERE id = :id", ['id'=>$threadID]);
|
||||||
$database->execute("DELETE FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]);
|
$database->execute("DELETE FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function delete_post(int $postID)
|
private function delete_post(int $postID): void
|
||||||
{
|
{
|
||||||
global $database;
|
global $database;
|
||||||
$database->execute("DELETE FROM forum_posts WHERE id = :id", ['id'=>$postID]);
|
$database->execute("DELETE FROM forum_posts WHERE id = :id", ['id'=>$postID]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function threadExists(int $threadID)
|
private function threadExists(int $threadID): bool
|
||||||
{
|
{
|
||||||
global $database;
|
global $database;
|
||||||
$result=$database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id=:id)", ['id'=>$threadID]);
|
$result=$database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id=:id)", ['id'=>$threadID]);
|
||||||
|
|
|
@ -173,7 +173,7 @@ class ForumTheme extends Themelet
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function make_thread_list($threads, $showAdminOptions)
|
private function make_thread_list($threads, $showAdminOptions): string
|
||||||
{
|
{
|
||||||
$html = "<table id='threadList' class='zebra'>".
|
$html = "<table id='threadList' class='zebra'>".
|
||||||
"<thead><tr>".
|
"<thead><tr>".
|
||||||
|
@ -188,7 +188,6 @@ class ForumTheme extends Themelet
|
||||||
|
|
||||||
$html .= "</tr></thead><tbody>";
|
$html .= "</tr></thead><tbody>";
|
||||||
|
|
||||||
|
|
||||||
$current_post = 0;
|
$current_post = 0;
|
||||||
foreach ($threads as $thread) {
|
foreach ($threads as $thread) {
|
||||||
$oe = ($current_post++ % 2 == 0) ? "even" : "odd";
|
$oe = ($current_post++ % 2 == 0) ? "even" : "odd";
|
||||||
|
|
|
@ -4,12 +4,12 @@ class FourOhFourInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "four_oh_four";
|
public const KEY = "four_oh_four";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "404 Detector";
|
public string $name = "404 Detector";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $visibility = self::VISIBLE_HIDDEN;
|
public string $visibility = self::VISIBLE_HIDDEN;
|
||||||
public $description = "If no other extension puts anything onto the page, show 404";
|
public string $description = "If no other extension puts anything onto the page, show 404";
|
||||||
public $core = true;
|
public bool $core = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ class FourOhFour extends Extension
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function count_main($blocks)
|
private function count_main($blocks): int
|
||||||
{
|
{
|
||||||
$n = 0;
|
$n = 0;
|
||||||
foreach ($blocks as $block) {
|
foreach ($blocks as $block) {
|
||||||
|
|
|
@ -4,12 +4,12 @@ class GoogleAnalyticsInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "google_analytics";
|
public const KEY = "google_analytics";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Google Analytics";
|
public string $name = "Google Analytics";
|
||||||
public $url = "http://drudexsoftware.com";
|
public string $url = "http://drudexsoftware.com";
|
||||||
public $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
|
public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
|
||||||
public $license = self::LICENSE_GPLV2;
|
public string $license = self::LICENSE_GPLV2;
|
||||||
public $description = "Integrates Google Analytics tracking";
|
public string $description = "Integrates Google Analytics tracking";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"User has to enter their Google Analytics ID in the Board Config to use this extension.";
|
"User has to enter their Google Analytics ID in the Board Config to use this extension.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ class GoogleAnalytics extends Extension
|
||||||
_gaq.push(['_trackPageview']);
|
_gaq.push(['_trackPageview']);
|
||||||
(function() {
|
(function() {
|
||||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||||
})();</script>");
|
})();</script>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,12 @@ class ArchiveFileHandlerInfo extends ExtensionInfo
|
||||||
{
|
{
|
||||||
public const KEY = "handle_archive";
|
public const KEY = "handle_archive";
|
||||||
|
|
||||||
public $key = self::KEY;
|
public string $key = self::KEY;
|
||||||
public $name = "Handle Archives";
|
public string $name = "Handle Archives";
|
||||||
public $url = self::SHIMMIE_URL;
|
public string $url = self::SHIMMIE_URL;
|
||||||
public $authors = self::SHISH_AUTHOR;
|
public array $authors = self::SHISH_AUTHOR;
|
||||||
public $description = "Allow users to upload archives (zip, etc)";
|
public string $description = "Allow users to upload archives (zip, etc)";
|
||||||
public $documentation =
|
public ?string $documentation =
|
||||||
"Note: requires exec() access and an external unzip command
|
"Note: requires exec() access and an external unzip command
|
||||||
<p>Any command line unzipper should work, some examples:
|
<p>Any command line unzipper should work, some examples:
|
||||||
<p>unzip: <code>unzip -d \"%d\" \"%f\"</code>
|
<p>unzip: <code>unzip -d \"%d\" \"%f\"</code>
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue