diff --git a/core/_bootstrap.php b/core/_bootstrap.php index a6d65ee3..6467f4d8 100644 --- a/core/_bootstrap.php +++ b/core/_bootstrap.php @@ -22,12 +22,11 @@ $tracer_enabled = constant('TRACE_FILE')!==null; // load base files $_tracer->begin("Bootstrap"); -$_tracer->begin("Opening files"); +$_tracer->begin("Opening core files"); $_shm_files = array_merge( zglob("core/*.php"), zglob("core/{".ENABLED_MODS."}/*.php"), - zglob("ext/{".ENABLED_EXTS."}/info.php"), - zglob("ext/{".ENABLED_EXTS."}/main.php") + zglob("ext/*/info.php") ); foreach ($_shm_files as $_shm_filename) { if (basename($_shm_filename)[0] != "_") { @@ -38,6 +37,22 @@ unset($_shm_files); unset($_shm_filename); $_tracer->end(); +$_tracer->begin("Loading extension info"); +ExtensionInfo::load_all_extension_info(); +Extension::determine_enabled_extensions(); +$_tracer->end(); + +$_tracer->begin("Opening enabled extension files"); +$_shm_files = zglob("ext/{".Extension::get_enabled_extensions_as_string()."}/main.php"); +foreach ($_shm_files as $_shm_filename) { + if (basename($_shm_filename)[0] != "_") { + require_once $_shm_filename; + } +} +unset($_shm_files); +unset($_shm_filename); +$_tracer->end(); + // connect to the database $_tracer->begin("Connecting to DB"); $database = new Database(); @@ -53,8 +68,7 @@ unset($themelet); $page = class_exists("CustomPage") ? new CustomPage() : new Page(); $_tracer->end(); -// hook up event handlers -$_tracer->begin("Loading extensions"); +$_tracer->begin("Loading extensions/event listeners"); _load_event_listeners(); $_tracer->end(); diff --git a/core/extension.php b/core/extension.php index be7b8d24..e97e2d38 100644 --- a/core/extension.php +++ b/core/extension.php @@ -83,32 +83,24 @@ */ abstract class Extension { - /** @var array which DBs this ext supports (blank for 'all') */ - protected $db_support = []; + public $key; /** @var Themelet this theme's Themelet object */ public $theme; public $info; - public function __construct() - { - $class = get_called_class(); - $this->theme = $this->get_theme_object($class); - $this->info = ExtensionInfo::get_for_extension($class); - } + private static $enabled_extensions = []; - public function is_supported(): bool + public function __construct($class = null) { - if($this->info!=null) { - return $this->info->supported; - } else { - global $database; - return ( - empty($this->db_support) || - in_array($database->get_driver_name(), $this->db_support) - ); + $class = $class ?? get_called_class(); + $this->theme = $this->get_theme_object($class); + $this->info = ExtensionInfo::get_for_extension_class($class); + if($this->info===null) { + throw new Exception("Info class not found for extension $class"); } + $this->key = $this->info->key; } /** @@ -136,45 +128,183 @@ abstract class Extension { return 50; } + + public static function determine_enabled_extensions() + { + self::$enabled_extensions = []; + foreach(array_merge(ExtensionInfo::get_core_extensions(), + explode(",", EXTRA_EXTS)) as $key) { + $ext = ExtensionInfo::get_by_key($key); + if($ext===null) { + continue; + } + self::$enabled_extensions[] = $ext->key; + } + } + + public static function is_enabled(string $key): ?bool + { + return in_array($key, self::$enabled_extensions); + } + + public static function get_enabled_extensions(): array + { + return self::$enabled_extensions; + } + public static function get_enabled_extensions_as_string(): string + { + return implode(",",self::$enabled_extensions); + } } abstract class ExtensionInfo { + // Every credit you get costs us RAM. It stops now. + public const SHISH_NAME = "Shish"; + public const SHISH_EMAIL = "webmaster@shishnet.org"; + public const SHIMMIE_URL = "http://code.shishnet.org/shimmie2/"; + public const SHISH_AUTHOR = [self::SHISH_NAME=>self::SHISH_EMAIL]; + + public const LICENSE_GPLV2 = "GPLv2"; + public const LICENSE_MIT = "MIT"; + public const LICENSE_WTFPL = "WTFPL"; + + public const VISIBLE_ADMIN = "admin"; + private const VALID_VISIBILITY = [self::VISIBLE_ADMIN]; + + public $key; + + public $core = false; + + public $beta = false; + public $name; - public $authors; + public $authors = []; public $link; public $license; public $version; public $visibility; public $description; public $documentation; - public $supported; - public $db_support; - public function __construct() - { - $this->supported = $this->is_supported(); - } + /** @var array which DBs this ext supports (blank for 'all') */ + public $db_support = []; + + private $supported = null; + private $support_info = null; public function is_supported(): bool { - global $database; - return ( - empty($this->db_support) || - in_array($database->get_driver_name(), $this->db_support) - ); + if($this->supported===null) { + $this->check_support(); + } + return $this->supported; } - public static function get_for_extension(string $base): ?ExtensionInfo + public function get_support_info(): string + { + if($this->supported===null) { + $this->check_support(); + } + return $this->support_info; + } + + private static $all_info_by_key = []; + private static $all_info_by_class = []; + private static $core_extensions = []; + + protected function __construct() + { + if(empty($this->key)) { + throw new Exception("key field is required"); + } + if(empty($this->name)) { + throw new Exception("name field is required for extension $this->key"); + } + if(!empty($this->visibility)&&!in_array($this->visibility, self::VALID_VISIBILITY)) { + throw new Exception("Invalid visibility for extension $this->key"); + } + if(!is_array($this->db_support)) { + throw new Exception("db_support has to be an array for extension $this->key"); + } + if(!is_array($this->authors)) { + throw new Exception("authors has to be an array for extension $this->key"); + } + } + + public function is_enabled(): bool + { + return Extension::is_enabled($this->key); + } + + private function check_support() + { + global $database; + $this->support_info = ""; + if(!empty($this->db_support)&&!in_array($database->get_driver_name(), $this->db_support)) { + $this->support_info .= "Database not supported. "; + } + // Additional checks here as needed + + $this->supported = empty($this->support_info); + } + + public static function get_all(): array + { + return array_values(self::$all_info_by_key); + } + + public static function get_all_keys(): array + { + return array_keys(self::$all_info_by_key); + } + + public static function get_core_extensions(): array + { + return self::$core_extensions; + } + + public static function get_by_key(string $key): ?ExtensionInfo + { + if(array_key_exists($key, self::$all_info_by_key)) { + return self::$all_info_by_key[$key]; + } else { + return null; + } + } + + public static function get_for_extension_class(string $base): ?ExtensionInfo { $normal = $base.'Info'; - if (class_exists($normal)) { - return new $normal(); + if (array_key_exists($normal, self::$all_info_by_class)) { + return self::$all_info_by_class[$normal]; } else { return null; } } + + public static function load_all_extension_info() + { + + foreach (get_declared_classes() as $class) { + $rclass = new ReflectionClass($class); + if ($rclass->isAbstract()) { + // don't do anything + } elseif (is_subclass_of($class, "ExtensionInfo")) { + $extension_info = new $class(); + if(array_key_exists($extension_info->key, self::$all_info_by_key)) { + throw new Exception("Extension Info $class with key $extension_info->key has already been loaded"); + } + + self::$all_info_by_key[$extension_info->key] = $extension_info; + self::$all_info_by_class[$class] = $extension_info; + if($extension_info->core===true) { + self::$core_extensions[] = $extension_info->key; + } + } + } + } } /** diff --git a/core/page.php b/core/page.php index 7efa2833..49bb0ec9 100644 --- a/core/page.php +++ b/core/page.php @@ -468,7 +468,7 @@ class Page /*** Generate CSS cache files ***/ $css_latest = $config_latest; $css_files = array_merge( - zglob("ext/{" . ENABLED_EXTS . "}/style.css"), + zglob("ext/{" . Extension::get_enabled_extensions_as_string() . "}/style.css"), zglob("themes/$theme_name/style.css") ); foreach ($css_files as $css) { @@ -499,7 +499,7 @@ class Page "vendor/bower-asset/js-cookie/src/js.cookie.js", "ext/handle_static/modernizr-3.3.1.custom.js", ], - zglob("ext/{" . ENABLED_EXTS . "}/script.js"), + zglob("ext/{" . Extension::get_enabled_extensions_as_string() . "}/script.js"), zglob("themes/$theme_name/script.js") ); foreach ($js_files as $js) { diff --git a/core/send_event.php b/core/send_event.php index 8542e08c..10f91c32 100644 --- a/core/send_event.php +++ b/core/send_event.php @@ -44,7 +44,7 @@ function _set_event_listeners(): void $extension = new $class(); // skip extensions which don't support our current database - if (!$extension->is_supported()) { + if (!$extension->info->is_supported()) { continue; } @@ -88,16 +88,6 @@ function _dump_event_listeners(array $event_listeners, string $path): void file_put_contents($path, $p); } -function ext_is_live(string $ext_name): bool -{ - if (class_exists($ext_name)) { - /** @var Extension $ext */ - $ext = new $ext_name(); - return $ext->is_supported(); - } - return false; -} - /** @private */ global $_shm_event_count; @@ -109,7 +99,7 @@ $_shm_event_count = 0; function send_event(Event $event): void { global $tracer_enabled; - + global $_shm_event_listeners, $_shm_event_count, $_tracer; if (!isset($_shm_event_listeners[get_class($event)])) { return; diff --git a/core/sys_config.php b/core/sys_config.php index 5dc80459..8692f97e 100644 --- a/core/sys_config.php +++ b/core/sys_config.php @@ -40,7 +40,6 @@ _d("SEARCH_ACCEL", false); // boolean use search accelerator _d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse _d("VERSION", '2.7-beta'); // string shimmie version _d("TIMEZONE", null); // string timezone -_d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,handle_static,comment,tag_list,index,tag_edit,alias_editor,media,help_pages,system"); // extensions to always enable _d("EXTRA_EXTS", ""); // string optional extra extensions _d("BASE_URL", null); // string force a specific base URL (default is auto-detect) _d("MIN_PHP_VERSION", '7.1');// string minimum supported PHP version @@ -53,4 +52,3 @@ _d("ENABLED_MODS", "imageboard"); * directly, only the things they're built from */ _d("SCORE_VERSION", 'develop/'.VERSION); // string SCore version -_d("ENABLED_EXTS", CORE_EXTS.",".EXTRA_EXTS); diff --git a/ext/admin/info.php b/ext/admin/info.php new file mode 100644 index 00000000..84db9927 --- /dev/null +++ b/ext/admin/info.php @@ -0,0 +1,33 @@ + + * Link: http://code.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Various things to make admins' lives easier + * Documentation: + + */ + +class AdminPageInfo extends ExtensionInfo +{ + public const KEY = "admin"; + + public $key = self::KEY; + public $name = "Admin Controls"; + public $url = self::SHIMMIE_URL; + public $authors = self::SHISH_AUTHOR; + public $license = self::LICENSE_GPLV2; + public $description = "Various things to make admins' lives easier"; + public $documentation = +"Various moderate-level tools for admins; for advanced, obscure, and possibly dangerous tools see the shimmie2-utils script set +
Lowercase all tags:
+
Set all tags to lowercase for consistency
+
Recount tag use:
+
If the counts of images per tag get messed up somehow, this will reset them, and remove any unused tags
+
Database dump:
+
Download the contents of the database in plain text format, useful for backups.
+
Image dump:
+
Download all the images as a .zip file (Requires ZipArchive)";
+}
diff --git a/ext/admin/main.php b/ext/admin/main.php
index 423460c8..dc9e9f63 100644
--- a/ext/admin/main.php
+++ b/ext/admin/main.php
@@ -1,24 +1,4 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Various things to make admins' lives easier
- * Documentation:
- * Various moderate-level tools for admins; for advanced, obscure, and
- * possibly dangerous tools see the shimmie2-utils script set
- *
Lowercase all tags:
- *
Set all tags to lowercase for consistency
- *
Recount tag use:
- *
If the counts of images per tag get messed up somehow, this will
- * reset them, and remove any unused tags
- *
Database dump:
- *
Download the contents of the database in plain text format, useful
- * for backups.
- *
Image dump:
- * Regex bans are also supported, allowing more complicated
+bans like Note that for non-regex matches, only whole words are
+matched, eg banning \"sex\" would block the comment \"get free
+sex call this number\", but allow \"This is a photo of Bob
+from Essex\"";
+}
diff --git a/ext/ban_words/main.php b/ext/ban_words/main.php
index 5e0761b3..c6f636a1 100644
--- a/ext/ban_words/main.php
+++ b/ext/ban_words/main.php
@@ -1,24 +1,4 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: For stopping spam and other comment abuse
- * Documentation:
- * Allows an administrator to ban certain words
- * from comments. This can be a very simple but effective way
- * of stopping spam; just add "viagra", "porn", etc to the
- * banned words list.
- * Regex bans are also supported, allowing more complicated
- * bans like Note that for non-regex matches, only whole words are
- * matched, eg banning "sex" would block the comment "get free
- * sex call this number", but allow "This is a photo of Bob
- * from Essex"
- */
class BanWords extends Extension
{
diff --git a/ext/bbcode/info.php b/ext/bbcode/info.php
new file mode 100644
index 00000000..06798aab
--- /dev/null
+++ b/ext/bbcode/info.php
@@ -0,0 +1,40 @@
+
+ * Link: http://code.shishnet.org/shimmie2/
+ * License: GPLv2
+ * Description: Turns BBCode into HTML
+ */
+
+class BBCodeInfo extends ExtensionInfo
+{
+ public const KEY = "bbcode";
+
+ public $key = self::KEY;
+ public $name = "BBCode";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $core = true;
+ public $description = "Turns BBCode into HTML";
+ public $documentation =
+" Supported tags:
+ Note: requires the \"admin\" extension to be enabled
+";
+}
diff --git a/ext/bulk_add/main.php b/ext/bulk_add/main.php
index 0feaa87b..94a9b7f1 100644
--- a/ext/bulk_add/main.php
+++ b/ext/bulk_add/main.php
@@ -1,19 +1,4 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Bulk add server-side images
- * Documentation:
- * 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.
- * If there are subdirectories, they get used as tags (eg if you
- * upload into Note: requires the "admin" extension to be enabled
- */
class BulkAddEvent extends Event
{
diff --git a/ext/bulk_add_csv/info.php b/ext/bulk_add_csv/info.php
new file mode 100644
index 00000000..a2e6af69
--- /dev/null
+++ b/ext/bulk_add_csv/info.php
@@ -0,0 +1,34 @@
+
+ * License: GPLv2
+ * Description: Bulk add server-side images with metadata from CSV file
+ * Documentation:
+ *
+ *
+ */
+
+class BulkAddCSVInfo extends ExtensionInfo
+{
+ public const KEY = "bulk_add_csv";
+
+ public $key = self::KEY;
+ public $name = "Bulk Add CSV";
+ public $url = self::SHIMMIE_URL;
+ public $authors = ["velocity37"=>"velocity37@gmail.com"];
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Bulk add server-side images with metadata from CSV file";
+ public $documentation =
+"Modification of \"Bulk Add\" by Shish. Note: requires \"Admin Controls\" and optionally \"Image Ratings\" to be enabled Note: requires "Admin Controls" and optionally "Image Ratings" to be enabled Notes:
+ Functions currently implemented:
+ Notes:
- Functions currently implemented:
- Images are stored in /ext/emoticons/default/, and you can
+add more emoticons by uploading images into that folder.";
+}
diff --git a/ext/emoticons/main.php b/ext/emoticons/main.php
index 37d48d73..b3514425 100644
--- a/ext/emoticons/main.php
+++ b/ext/emoticons/main.php
@@ -1,17 +1,5 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Lets users use graphical smilies
- * Documentation:
- * This extension will turn colon-something-colon into a link
- * to an image with that something as the name, eg :smile:
- * becomes a link to smile.gif
- * Images are stored in /ext/emoticons/default/, and you can
- * add more emoticons by uploading images into that folder.
- */
+
/**
* Class Emoticons
diff --git a/ext/et/info.php b/ext/et/info.php
new file mode 100644
index 00000000..3245f10c
--- /dev/null
+++ b/ext/et/info.php
@@ -0,0 +1,25 @@
+
+ * License: GPLv2
+ * Description: Show various bits of system information
+ * Documentation:
+ */
+
+class ETInfo extends ExtensionInfo
+{
+ public const KEY = "et";
+
+ public $key = self::KEY;
+ public $name = "System Info";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Show various bits of system information";
+ public $documentation =
+"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
+versions of PHP I should test with, etc.";
+}
diff --git a/ext/et/main.php b/ext/et/main.php
index 576765dd..f4f058d4 100644
--- a/ext/et/main.php
+++ b/ext/et/main.php
@@ -1,16 +1,4 @@
- * License: GPLv2
- * Description: Show various bits of system information
- * Documentation:
- * 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
- * versions of PHP I should test with, etc.
- */
class ET extends Extension
{
diff --git a/ext/ext_manager/info.php b/ext/ext_manager/info.php
new file mode 100644
index 00000000..80ade6e9
--- /dev/null
+++ b/ext/ext_manager/info.php
@@ -0,0 +1,26 @@
+
+ * Link: http://code.shishnet.org/shimmie2/
+ * License: GPLv2
+ * Visibility: admin
+ * Description: A thing for point & click extension management
+ * Documentation:
+ */
+
+class ExtManagerInfo extends ExtensionInfo
+{
+ public const KEY = "ext_manager";
+
+ public $key = self::KEY;
+ public $name = "Extension Manager";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $visibility = self::VISIBLE_ADMIN;
+ public $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 $core = true;
+}
diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php
index 2af52b42..acb51ca3 100644
--- a/ext/ext_manager/main.php
+++ b/ext/ext_manager/main.php
@@ -1,134 +1,22 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Visibility: admin
- * Description: A thing for point & click extension management
- * 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
- */
-function __extman_extcmp(ExtensionManagerInfo $a, ExtensionManagerInfo $b): int
+
+function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b): int
{
+ if($a->beta===true&&$b->beta===false)
+ return 1;
+ if($a->beta===false&&$b->beta===true)
+ return -1;
+
return strcmp($a->name, $b->name);
}
-class ExtensionManagerInfo
+function __extman_extactive(ExtensionInfo $a): bool
{
- public $ext_name;
- public $name;
- public $link;
- public $authors;
- public $description;
- public $documentation;
- public $version;
- public $visibility;
- public $enabled;
- public $supported;
-
- public function __construct($main)
- {
- $matches = [];
- preg_match("#ext/(.*)/main.php#", $main, $matches);
- $this->ext_name = $matches[1];
- $this->name = $this->ext_name;
- $this->enabled = $this->is_enabled($this->ext_name);
-
- if(file_exists("ext/{$this->ext_name}/info.php")) {
- include_once "ext/{$this->ext_name}/info.php";
- $class = get_class_from_file("ext/{$this->ext_name}/info.php");
- $info = new $class();
-
- $this->name = $info->name;
- $this->link = $info->link;
- foreach ($info->authors as $key=>$value){
- $this->authors[] = new ExtensionAuthor($key, $value);
- }
- $this->description = $info->description;
- $this->documentation = $info->documentation;
- $this->version = $info->version;
- $this->visibility = $info->visibility;
- $this->supported = $info->supported;
- } else {
- $this->authors = [];
-
- $handle = fopen($main, "r");
- if ($handle === null) {
- throw new Exception("Could not open extension file $main");
- }
- try {
- $line = fgets($handle);
-
- while ($line !== false) {
- if (preg_match("/Name: (.*)/", $line, $matches)) {
- $this->name = $matches[1];
- } elseif (preg_match("/Visibility: (.*)/", $line, $matches)) {
- $this->visibility = $matches[1];
- } elseif (preg_match("/Link: (.*)/", $line, $matches)) {
- $this->link = $matches[1];
- if ($this->link[0] == "/") {
- $this->link = make_link(substr($this->link, 1));
- }
- } elseif (preg_match("/Version: (.*)/", $line, $matches)) {
- $this->version = $matches[1];
- } elseif (preg_match("/Authors?: (.*)/", $line, $matches)) {
- $author_list = explode(',', $matches[1]);
- foreach ($author_list as $author) {
- if (preg_match("/(.*) [<\(](.*@.*)[>\)]/", $author, $matches)) {
- $this->authors[] = new ExtensionAuthor($matches[1], $matches[2]);
- } else {
- $this->authors[] = new ExtensionAuthor($author, null);
- }
- }
- } elseif (preg_match("/(.*)Description: ?(.*)/", $line, $matches)) {
- $this->description = $matches[2];
- $start = $matches[1] . " ";
- $start_len = strlen($start);
- while (($line = fgets($handle)) !== false &&
- substr($line, 0, $start_len) == $start) {
- $this->description .= " " . substr($line, $start_len);
- }
- continue;
- } elseif (preg_match("/(.*)Documentation: ?(.*)/", $line, $matches)) {
- $this->documentation = $matches[2];
- $start = $matches[1] . " ";
- $start_len = strlen($start);
- while (($line = fgets($handle)) !== false &&
- substr($line, 0, $start_len) == $start) {
- $this->documentation .= " " . substr($line, $start_len);
- }
- $this->documentation = str_replace('$site', make_http(get_base_href()), $this->documentation);
- continue;
- } elseif (preg_match("/\*\//", $line, $matches)) {
- break;
- }
- $line = fgets($handle);
- }
- } finally {
- fclose($handle);
- }
- }
- }
-
- private function is_enabled(string $fname): ?bool
- {
- $core = explode(",", CORE_EXTS);
- $extra = explode(",", EXTRA_EXTS);
-
- if (in_array($fname, $extra)) {
- return true;
- } // enabled
- if (in_array($fname, $core)) {
- return null;
- } // core
- return false; // not enabled
- }
+ return Extension::is_enabled($a->key);
}
+
class ExtensionAuthor
{
public $name;
@@ -172,7 +60,7 @@ class ExtManager extends Extension
if ($event->page_matches("ext_doc")) {
$ext = $event->get_arg(0);
if (file_exists("ext/$ext/info.php")) {
- $info = new ExtensionManagerInfo("ext/$ext/main.php");
+ $info = ExtensionInfo::get_by_key($ext);
$this->theme->display_doc($page, $info);
} else {
$this->theme->display_table($page, $this->get_extensions(false), false);
@@ -218,14 +106,9 @@ class ExtManager extends Extension
*/
private function get_extensions(bool $all): array
{
- $extensions = [];
- if ($all) {
- $exts = zglob("ext/*/main.php");
- } else {
- $exts = zglob("ext/{" . ENABLED_EXTS . "}/main.php");
- }
- foreach ($exts as $main) {
- $extensions[] = new ExtensionManagerInfo($main);
+ $extensions = ExtensionInfo::get_all();
+ if (!$all) {
+ $extensions = array_filter($extensions,"__extman_extactive");
}
usort($extensions, "__extman_extcmp");
return $extensions;
@@ -233,16 +116,13 @@ class ExtManager extends Extension
private function set_things($settings)
{
- $core = explode(",", CORE_EXTS);
+ $core = ExtensionInfo::get_core_extensions();
$extras = [];
- foreach (glob("ext/*/main.php") as $main) {
+ foreach (ExtensionInfo::get_all_keys() as $key) {
$matches = [];
- preg_match("#ext/(.*)/main.php#", $main, $matches);
- $fname = $matches[1];
-
- if (!in_array($fname, $core) && isset($settings["ext_$fname"])) {
- $extras[] = $fname;
+ if (!in_array($key, $core) && isset($settings["ext_$key"])) {
+ $extras[] = $key;
}
}
diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php
index fcf8b64a..0c1702be 100644
--- a/ext/ext_manager/theme.php
+++ b/ext/ext_manager/theme.php
@@ -26,24 +26,24 @@ class ExtManagerTheme extends Themelet
continue;
}
- $h_name = html_escape(empty($extension->name) ? $extension->ext_name : $extension->name);
+ $h_name = html_escape(($extension->beta===true ? "[BETA] ":"").(empty($extension->name) ? $extension->key : $extension->name));
$h_description = html_escape($extension->description);
- $h_link = make_link("ext_doc/" . url_escape($extension->ext_name));
+ $h_link = make_link("ext_doc/" . url_escape($extension->key));
- $h_enabled = ($extension->enabled === true ? " checked='checked'" : ($extension->enabled === false ? "" : " checked='checked'"));
- $h_disabled = ($extension->supported===false || $extension->enabled===null? " disabled ": " " );
+ $h_enabled = ($extension->is_enabled() === true ? " checked='checked'" : "");
+ $h_disabled = ($extension->is_supported()===false || $extension->core===true? " disabled ": " " );
//baseline_open_in_new_black_18dp.png
- $h_enabled_box = $editable ? " Favorites for a user can then be retrieved by searching for \"favorited_by=UserName\"
+ Popular images can be searched for by eg. \"favorites>5\"
+ Favorite info can be added to an image's filename or tooltip using the \$favorites placeholder";
+}
diff --git a/ext/favorites/main.php b/ext/favorites/main.php
index 950d6178..03d93a3e 100644
--- a/ext/favorites/main.php
+++ b/ext/favorites/main.php
@@ -1,17 +1,4 @@
- * License: GPLv2
- * Description: Allow users to favorite images
- * Documentation:
- * Gives users a "favorite this image" button that they can press
- * Favorites for a user can then be retrieved by searching for
- * "favorited_by=UserName"
- * Popular images can be searched for by eg. "favorites>5"
- * Favorite info can be added to an image's filename or tooltip
- * using the $favorites placeholder
- */
class FavoriteSetEvent extends Event
{
@@ -54,7 +41,7 @@ class Favorites extends Extension
"SELECT COUNT(*) AS ct FROM user_favorites WHERE user_id = :user_id AND image_id = :image_id",
["user_id"=>$user_id, "image_id"=>$image_id]
) > 0;
-
+
$event->add_part($this->theme->get_voter_html($event->image, $is_favorited));
}
}
diff --git a/ext/featured/info.php b/ext/featured/info.php
new file mode 100644
index 00000000..b28277e1
--- /dev/null
+++ b/ext/featured/info.php
@@ -0,0 +1,35 @@
+
+ * Link: http://code.shishnet.org/shimmie2/
+ * License: GPLv2
+ * Description: Bring a specific image to the users' attentions
+ * Documentation:
+ *
+ */
+
+class FeaturedInfo extends ExtensionInfo
+{
+ public const KEY = "featured";
+
+ public $key = self::KEY;
+ public $name = "Featured Image";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Bring a specific image to the users' attentions";
+ public $documentation =
+"Once enabled, a new \"feature this\" button will appear next
+to the other image control buttons (delete, rotate, etc).
+Clicking it will set the image as the site's current feature,
+which will be shown in the side bar of the post list.
+ Viewing a featured image
+ Downloading a featured image
+ Viewing a featured image
- * Downloading a featured image
- *
Download all the images as a .zip file (Requires ZipArchive)
- */
/**
* Sent when the admin page is ready to be added to
diff --git a/ext/admin/theme.php b/ext/admin/theme.php
index 1abe6542..3ad3d6b7 100644
--- a/ext/admin/theme.php
+++ b/ext/admin/theme.php
@@ -60,7 +60,7 @@ class AdminPageTheme extends Themelet
public function dbq_html($terms)
{
- if(ext_is_live("Trash")) {
+ if(Extension::is_enabled(TrashInfo::KEY)) {
$warning = "This delete method will bypass the trash
";
}
if (class_exists("ImageBan")) {
diff --git a/ext/alias_editor/info.php b/ext/alias_editor/info.php
new file mode 100644
index 00000000..4990ac6d
--- /dev/null
+++ b/ext/alias_editor/info.php
@@ -0,0 +1,24 @@
+
+ * Link: http://code.shishnet.org/shimmie2/
+ * License: GPLv2
+ * Description: Edit the alias list
+ * Documentation:
+ */
+
+class AliasEditorInfo extends ExtensionInfo
+{
+ public const KEY = "alias_editor";
+
+ public $key = self::KEY;
+ public $name = "Alias Editor";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Edit the alias list";
+ public $documentation = 'The list is visible at /alias/list; only site admins can edit it, other people can view and download it';
+ public $core = true;
+}
diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php
index 36edbfbb..537b0e63 100644
--- a/ext/alias_editor/main.php
+++ b/ext/alias_editor/main.php
@@ -1,14 +1,4 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Edit the alias list
- * Documentation:
- * The list is visible at /alias/list; only
- * site admins can edit it, other people can view and download it
- */
class AddAliasEvent extends Event
{
diff --git a/ext/arrowkey_navigation/info.php b/ext/arrowkey_navigation/info.php
new file mode 100644
index 00000000..ee6b88f2
--- /dev/null
+++ b/ext/arrowkey_navigation/info.php
@@ -0,0 +1,23 @@
+
+ * Link: http://www.drudexsoftware.com/
+ * License: GPLv2
+ * Description: Allows viewers no navigate between images using the left & right arrow keys.
+ * Documentation:
+ * Simply enable this extention in the extention manager to enable arrow key navigation.
+ */
+class ArrowkeyNavigationInfo extends ExtensionInfo
+{
+ public const KEY = "arrowkey_navigation";
+
+ public $key = self::KEY;
+ public $name = "Arrow Key Navigation";
+ public $url = "http://www.drudexsoftware.com/";
+ public $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Allows viewers no navigate between images using the left & right arrow keys.";
+ public $documentation =
+"Simply enable this extension in the extension manager to enable arrow key navigation.";
+}
diff --git a/ext/arrowkey_navigation/main.php b/ext/arrowkey_navigation/main.php
index 209fbf04..640d2b12 100644
--- a/ext/arrowkey_navigation/main.php
+++ b/ext/arrowkey_navigation/main.php
@@ -1,13 +1,5 @@
- * Link: http://www.drudexsoftware.com/
- * License: GPLv2
- * Description: Allows viewers no navigate between images using the left & right arrow keys.
- * Documentation:
- * Simply enable this extention in the extention manager to enable arrow key navigation.
- */
+
class ArrowkeyNavigation extends Extension
{
/**
diff --git a/ext/artists/info.php b/ext/artists/info.php
new file mode 100644
index 00000000..5da88896
--- /dev/null
+++ b/ext/artists/info.php
@@ -0,0 +1,23 @@
+
+ * Alpha /http:.*\.cn\//
to block links to
+chinese websites, or /.*?http.*?http.*?http.*?http.*?/
+to block comments with four (or more) links in.
+/http:.*\.cn\//
to block links to
- * chinese websites, or /.*?http.*?http.*?http.*?http.*?/
- * to block comments with four (or more) links in.
- *
+
";
+}
diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php
index f7c834f3..fd6c7658 100644
--- a/ext/bbcode/main.php
+++ b/ext/bbcode/main.php
@@ -1,29 +1,5 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Turns BBCode into HTML
- * Documentation:
- * Supported tags:
- * strikethrough[/s]
+
- *
- */
+
class BBCode extends FormatterExtension
{
diff --git a/ext/blocks/info.php b/ext/blocks/info.php
new file mode 100644
index 00000000..23d24604
--- /dev/null
+++ b/ext/blocks/info.php
@@ -0,0 +1,21 @@
+
+ * Link: http://code.shishnet.org/shimmie2/
+ * License: GPLv2
+ * Description: Add HTML to some space (News, Ads, etc)
+ */
+
+class BlocksInfo extends ExtensionInfo
+{
+ public const KEY = "blocks";
+
+ public $key = self::KEY;
+ public $name = "Generic Blocks";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Add HTML to some space (News, Ads, etc)";
+}
diff --git a/ext/blocks/main.php b/ext/blocks/main.php
index 197b5d9f..b172f201 100644
--- a/ext/blocks/main.php
+++ b/ext/blocks/main.php
@@ -1,11 +1,4 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Add HTML to some space (News, Ads, etc)
- */
class Blocks extends Extension
{
diff --git a/ext/blotter/info.php b/ext/blotter/info.php
new file mode 100644
index 00000000..d03891ec
--- /dev/null
+++ b/ext/blotter/info.php
@@ -0,0 +1,22 @@
+ [http://seemslegit.com/]
+ * License: GPLv2
+ * Description:
+ */
+class BlotterInfo extends ExtensionInfo
+{
+ public const KEY = "blotter";
+
+ public $key = self::KEY;
+ public $name = "Blotter";
+ public $url = "http://seemslegit.com/";
+ public $authors = ["Zach Hall"=>"zach@sosguy.net"];
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Displays brief updates about whatever you want on every page.
+Colors and positioning can be configured to match your site's design.
+
+Development TODO at http://github.com/zshall/shimmie2/issues";
+}
diff --git a/ext/blotter/main.php b/ext/blotter/main.php
index 3e18b1a9..12f70fc7 100644
--- a/ext/blotter/main.php
+++ b/ext/blotter/main.php
@@ -1,13 +1,5 @@
[http://seemslegit.com/]
- * License: GPLv2
- * Description: Displays brief updates about whatever you want on every page.
- * Colors and positioning can be configured to match your site's design.
- *
- * Development TODO at http://github.com/zshall/shimmie2/issues
- */
+
class Blotter extends Extension
{
public function onInitExt(InitExtEvent $event)
diff --git a/ext/browser_search/info.php b/ext/browser_search/info.php
new file mode 100644
index 00000000..ba353e4c
--- /dev/null
+++ b/ext/browser_search/info.php
@@ -0,0 +1,30 @@
+
+ * Some code (and lots of help) by Artanis (Erik Youngren strikethrough[/s]
- * /home/bob/uploads/holiday/2008/
and point
+ shimmie at /home/bob/uploads
, then images will be
+ tagged \"holiday 2008\")
+ /home/bob/uploads/holiday/2008/
and point
- * shimmie at /home/bob/uploads
, then images will be
- * tagged "holiday 2008")
- *
+Adds images from a CSV with the five following values:
+\"/path/to/image.jpg\",\"spaced tags\",\"source\",\"rating s/q/e\",\"/path/thumbnail.jpg\"
+e.g. \"/tmp/cat.png\",\"shish oekaki\",\"shimmie.shishnet.org\",\"s\",\"tmp/custom.jpg\"
+Any value but the first may be omitted, but there must be five values per line.
+e.g. \"/why/not/try/bulk_add.jpg\",\"\",\"\",\"\",\"\"
+Image thumbnails will be displayed at the AR of the full image. Thumbnails that are
+normally static (e.g. SWF) will be displayed at the board's max thumbnail size
+Useful for importing tagged images without having to do database manipulation.
+
";
+}
diff --git a/ext/bulk_add_csv/main.php b/ext/bulk_add_csv/main.php
index d1648a7d..a567c1ca 100644
--- a/ext/bulk_add_csv/main.php
+++ b/ext/bulk_add_csv/main.php
@@ -1,22 +1,4 @@
- * License: GPLv2
- * Description: Bulk add server-side images with metadata from CSV file
- * Documentation:
- * Modification of "Bulk Add" by Shish.
- * Adds images from a CSV with the five following values:
- * "/path/to/image.jpg","spaced tags","source","rating s/q/e","/path/thumbnail.jpg"
- * e.g. "/tmp/cat.png","shish oekaki","shimmie.shishnet.org","s","tmp/custom.jpg"
- * Any value but the first may be omitted, but there must be five values per line.
- * e.g. "/why/not/try/bulk_add.jpg","","","",""
- * Image thumbnails will be displayed at the AR of the full image. Thumbnails that are
- * normally static (e.g. SWF) will be displayed at the board's max thumbnail size
- * Useful for importing tagged images without having to do database manipulation.
- *
- *
- */
class BulkAddCSV extends Extension
{
@@ -40,7 +22,7 @@ class BulkAddCSV extends Extension
}
if ($event->cmd == "bulk-add-csv") {
global $user;
-
+
//Nag until CLI is admin by default
if (!$user->is_admin()) {
print "Not running as an admin, which can cause problems.\n";
@@ -96,11 +78,11 @@ class BulkAddCSV extends Extension
$this->theme->add_status("Error", "$csvfile doesn't appear to be a csv file");
return;
}
-
+
$linenum = 1;
$list = "";
$csvhandle = fopen($csvfile, "r");
-
+
while (($csvdata = fgetcsv($csvhandle, 0, ",")) !== false) {
if (count($csvdata) != 5) {
if (strlen($list) > 0) {
@@ -133,7 +115,7 @@ class BulkAddCSV extends Extension
}
$linenum += 1;
}
-
+
if (strlen($list) > 0) {
$this->theme->add_status("Adding $csvfile", $list);
}
diff --git a/ext/bulk_remove/info.php b/ext/bulk_remove/info.php
new file mode 100644
index 00000000..7f90b825
--- /dev/null
+++ b/ext/bulk_remove/info.php
@@ -0,0 +1,23 @@
+
+ * Link: http://www.drudexsoftware.com/
+ * License: GPLv2
+ * Description: Allows admin to delete many images at once through Board Admin.
+ * Documentation:
+ *
+ */
+class BulkRemoveInfo extends ExtensionInfo
+{
+ public const KEY = "bulk_remove";
+
+ public $key = self::KEY;
+ public $name = "Bulk Remove";
+ public $beta = true;
+ public $url = "http://www.drudexsoftware.com/";
+ public $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Allows admin to delete many images at once through Board Admin.";
+}
diff --git a/ext/bulk_remove/main.php b/ext/bulk_remove/main.php
index 75da254b..0509d616 100644
--- a/ext/bulk_remove/main.php
+++ b/ext/bulk_remove/main.php
@@ -1,13 +1,5 @@
- * Link: http://www.drudexsoftware.com/
- * License: GPLv2
- * Description: Allows admin to delete many images at once through Board Admin.
- * Documentation:
- *
- */
+
//todo: removal by tag returns 1 less image in test for some reason, actually a combined search doesn't seem to work for shit either
class BulkRemove extends Extension
@@ -23,7 +15,7 @@ class BulkRemove extends Extension
}
}
}
-
+
public function onAdminBuilding(AdminBuildingEvent $event)
{
global $page;
@@ -55,12 +47,12 @@ class BulkRemove extends Extension
// set vars
$images_for_removal = [];
$error = "";
-
+
$min_id = $_POST['remove_id_min'];
$max_id = $_POST['remove_id_max'];
$tags = $_POST['remove_tags'];
-
-
+
+
// if using id range to remove (comined removal with tags)
if ($min_id != "" && $max_id != "") {
// error if values are not correctly entered
@@ -68,46 +60,46 @@ class BulkRemove extends Extension
intval($max_id) < intval($min_id)) {
$error = "Values not correctly entered for removal between id.";
} else { // if min & max id are valid
-
+
// Grab the list of images & place it in the removing array
foreach (Image::find_images(intval($min_id), intval($max_id)) as $image) {
array_push($images_for_removal, $image);
}
}
}
-
+
// refine previous results or create results from tags
if ($tags != "") {
$tags_arr = explode(" ", $_POST['remove_tags']);
-
+
// Search all images with the specified tags & add to list
foreach (Image::find_images(1, 2147483647, $tags_arr) as $image) {
array_push($images_for_removal, $image);
}
}
-
-
+
+
// if no images were found with the given info
if (count($images_for_removal) == 0) {
$error = "No images selected for removal";
}
-
+
//var_dump($tags_arr);
return [
"error" => $error,
"images_for_removal" => $images_for_removal];
}
-
+
// displays confirmation to admin before removal
private function show_confirm()
{
global $page;
-
+
// set vars
$determined_imgs = $this->determine_images();
$error = $determined_imgs["error"];
$images_for_removal = $determined_imgs["images_for_removal"];
-
+
// if there was an error in determine_images()
if ($error != "") {
$page->add_block(new Block("Cannot remove images", $error));
@@ -115,14 +107,14 @@ class BulkRemove extends Extension
}
// generates the image array & places it in $_POST["bulk_remove_images"]
$_POST["bulk_remove_images"] = $images_for_removal;
-
+
// Display confirmation message
$html = make_form(make_link("bulk_remove")).
"Are you sure you want to PERMANENTLY remove ".
count($images_for_removal) ." images?
";
$page->add_block(new Block("Confirm Removal", $html));
}
-
+
private function do_bulk_remove()
{
global $page;
@@ -133,7 +125,7 @@ class BulkRemove extends Extension
"Please use Board Admin to use bulk remove."
));
}
-
+
//
$image_arr = $_POST["bulk_remove_images"];
}
diff --git a/ext/comment/info.php b/ext/comment/info.php
new file mode 100644
index 00000000..600d1eab
--- /dev/null
+++ b/ext/comment/info.php
@@ -0,0 +1,25 @@
+
+ * Link: http://code.shishnet.org/shimmie2/
+ * License: GPLv2
+ * Description: Allow users to make comments on images
+ * Documentation:
+ * Formatting is done with the standard formatting API (normally BBCode)
+ */
+
+class CommentListInfo extends ExtensionInfo
+{
+ public const KEY = "comment";
+
+ public $key = self::KEY;
+ public $name = "Image Comments";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Allow users to make comments on images";
+ public $documentation = "Formatting is done with the standard formatting API (normally BBCode)";
+ public $core = true;
+}
diff --git a/ext/comment/main.php b/ext/comment/main.php
index f58a3076..619f355e 100644
--- a/ext/comment/main.php
+++ b/ext/comment/main.php
@@ -1,13 +1,4 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Allow users to make comments on images
- * Documentation:
- * Formatting is done with the standard formatting API (normally BBCode)
- */
require_once "vendor/ifixit/php-akismet/akismet.class.php";
@@ -382,7 +373,7 @@ class CommentList extends Extension
global $database, $user;
$where = SPEED_HAX ? "WHERE posted > now() - interval '24 hours'" : "";
-
+
$total_pages = $database->cache->get("comment_pages");
if (empty($total_pages)) {
$total_pages = (int)($database->get_one("
@@ -394,7 +385,7 @@ class CommentList extends Extension
$total_pages = max($total_pages, 1);
$current_page = clamp($current_page, 1, $total_pages);
-
+
$threads_per_page = 10;
$start = $threads_per_page * ($current_page - 1);
@@ -407,13 +398,13 @@ class CommentList extends Extension
LIMIT :limit OFFSET :offset
", ["limit"=>$threads_per_page, "offset"=>$start]);
- $user_ratings = ext_is_live("Ratings") ? Ratings::get_user_privs($user) : "";
+ $user_ratings = Extension::is_enabled(RatingsInfo::KEY) ? Ratings::get_user_privs($user) : "";
$images = [];
while ($row = $result->fetch()) {
$image = Image::by_id($row["image_id"]);
if (
- ext_is_live("Ratings") && !is_null($image) &&
+ Extension::is_enabled(RatingsInfo::KEY) && !is_null($image) &&
strpos($user_ratings, $image->rating) === false
) {
$image = null; // this is "clever", I may live to regret it
diff --git a/ext/cron_uploader/info.php b/ext/cron_uploader/info.php
new file mode 100644
index 00000000..138d1565
--- /dev/null
+++ b/ext/cron_uploader/info.php
@@ -0,0 +1,28 @@
+, Matthew Barbour
danbooru API based on documentation from danbooru 1.0 -
+ http://attachr.com/7569
+
I've only been able to test add_post and find_tags because I use the
+ old danbooru firefox extension for firefox 1.5
+
+
+
+CHANGELOG
+13-OCT-08 8:00PM CST - JJS
+Bugfix - Properly escape source attribute
+
+17-SEP-08 10:00PM CST - JJS
+Bugfix for changed page name checker in PageRequestEvent
+
+13-APR-08 10:00PM CST - JJS
+Properly escape the tags returned in find_tags and find_posts - Caught by ATravelingGeek
+Updated extension info to be a bit more clear about its purpose
+Deleted add_comment code as it didn't do anything anyway
+
+01-MAR-08 7:00PM CST - JJS
+Rewrote to make it compatible with Shimmie trunk again (r723 at least)
+It may or may not support the new file handling stuff correctly, I'm only testing with images and the danbooru uploader for firefox
+
+21-OCT-07 9:07PM CST - JJS
+Turns out I actually did need to implement the new parameter names
+for danbooru api v1.8.1. Now danbooruup should work when used with /api/danbooru/post/create.xml
+Also correctly redirects the url provided by danbooruup in the event
+of a duplicate image.
+
+19-OCT-07 4:46PM CST - JJS
+Add compatibility with danbooru api v1.8.1 style urls
+for find_posts and add_post. NOTE: This does not implement
+the changes to the parameter names, it is simply a
+workaround for the latest danbooruup firefox extension.
+Completely compatibility will probably involve a rewrite with a different URL
+";
+}
diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php
index cb55766f..75a4a535 100644
--- a/ext/danbooru_api/main.php
+++ b/ext/danbooru_api/main.php
@@ -1,51 +1,4 @@
-Description: Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie
-Documentation:
-
danbooru API based on documentation from danbooru 1.0 -
- http://attachr.com/7569
-
I've only been able to test add_post and find_tags because I use the
- old danbooru firefox extension for firefox 1.5
-
-
-
-CHANGELOG
-13-OCT-08 8:00PM CST - JJS
-Bugfix - Properly escape source attribute
-
-17-SEP-08 10:00PM CST - JJS
-Bugfix for changed page name checker in PageRequestEvent
-
-13-APR-08 10:00PM CST - JJS
-Properly escape the tags returned in find_tags and find_posts - Caught by ATravelingGeek
-Updated extension info to be a bit more clear about its purpose
-Deleted add_comment code as it didn't do anything anyway
-
-01-MAR-08 7:00PM CST - JJS
-Rewrote to make it compatible with Shimmie trunk again (r723 at least)
-It may or may not support the new file handling stuff correctly, I'm only testing with images and the danbooru uploader for firefox
-
-21-OCT-07 9:07PM CST - JJS
-Turns out I actually did need to implement the new parameter names
-for danbooru api v1.8.1. Now danbooruup should work when used with /api/danbooru/post/create.xml
-Also correctly redirects the url provided by danbooruup in the event
-of a duplicate image.
-
-19-OCT-07 4:46PM CST - JJS
-Add compatibility with danbooru api v1.8.1 style urls
-for find_posts and add_post. NOTE: This does not implement
-the changes to the parameter names, it is simply a
-workaround for the latest danbooruup firefox extension.
-Completely compatibility will probably involve a rewrite with a different URL
-
-*/
class DanbooruApi extends Extension
{
diff --git a/ext/downtime/info.php b/ext/downtime/info.php
new file mode 100644
index 00000000..fd8df943
--- /dev/null
+++ b/ext/downtime/info.php
@@ -0,0 +1,28 @@
+
+ * Link: http://code.shishnet.org/shimmie2/
+ * License: GPLv2
+ * Description: Show a "down for maintenance" page
+ * Documentation:
+ *
+ */
+
+class DowntimeInfo extends ExtensionInfo
+{
+ public const KEY = "downtime";
+
+ public $key = self::KEY;
+ public $name = "Downtime";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Show a \"down for maintenance\" page";
+ public $documentation =
+"Once installed there will be some more options on the config page --
+Ticking \"disable non-admin access\" will mean that regular and anonymous
+users will be blocked from accessing the site, only able to view the
+message specified in the box.";
+}
diff --git a/ext/downtime/main.php b/ext/downtime/main.php
index 97f8682e..979b119f 100644
--- a/ext/downtime/main.php
+++ b/ext/downtime/main.php
@@ -1,16 +1,4 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Show a "down for maintenance" page
- * Documentation:
- * Once installed there will be some more options on the config page --
- * Ticking "disable non-admin access" will mean that regular and anonymous
- * users will be blocked from accessing the site, only able to view the
- * message specified in the box.
- */
class Downtime extends Extension
{
diff --git a/ext/emoticons/info.php b/ext/emoticons/info.php
new file mode 100644
index 00000000..0e48a602
--- /dev/null
+++ b/ext/emoticons/info.php
@@ -0,0 +1,29 @@
+
+ * Link: http://code.shishnet.org/shimmie2/
+ * License: GPLv2
+ * Description: Lets users use graphical smilies
+ * Documentation:
+ *
+ */
+
+class EmoticonsInfo extends ExtensionInfo
+{
+ public const KEY = "emoticons";
+
+ public $key = self::KEY;
+ public $name = "Emoticon Filter";
+ public $url = self::SHIMMIE_URL;
+ public $authors = self::SHISH_AUTHOR;
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Lets users use graphical smilies";
+ public $documentation =
+"This extension will turn colon-something-colon into a link
+to an image with that something as the name, eg :smile:
+becomes a link to smile.gif
+" : "";
+ $h_enabled_box = $editable ? " " : "";
$h_docs = ($extension->documentation ? "â– " : ""); //TODO: A proper "docs" symbol would be preferred here.
$html .= "
-
+
{$h_enabled_box}
- ";
}
$h_set = $editable ? "
+
{$h_docs}
- {$h_description} " .($extension->supported===false ? "Database not supported" : ""). "
+ {$h_description} ".$extension->get_support_info()."
" : "";
@@ -66,16 +66,16 @@ class ExtManagerTheme extends Themelet
$col_1 = "";
$col_2 = "";
foreach($extensions as $extension) {
- $ext_name = $extension->ext_name;
+ $ext_name = $extension->name;
$h_name = empty($extension->name) ? $ext_name : html_escape($extension->name);
$h_email = html_escape($extension->email);
$h_link = isset($extension->link) ?
"link)."\">Original Site" : "";
$h_doc = isset($extension->documentation) ?
- "ext_name))."\">Documentation" : "";
+ "name))."\">Documentation" : "";
$h_author = html_escape($extension->author);
$h_description = html_escape($extension->description);
- $h_enabled = $extension->enabled ? " checked='checked'" : "";
+ $h_enabled = $extension->is_enabled() ? " checked='checked'" : "";
$h_author_link = empty($h_email) ?
"$h_author" :
"$h_author";
@@ -118,7 +118,7 @@ class ExtManagerTheme extends Themelet
}
*/
- public function display_doc(Page $page, ExtensionManagerInfo $info)
+ public function display_doc(Page $page, ExtensionInfo $info)
{
$author = "";
if (count($info->authors) > 0) {
@@ -127,12 +127,13 @@ class ExtManagerTheme extends Themelet
$author .= "s";
}
$author .= ":";
- foreach ($info->authors as $auth) {
- if (!empty($auth->email)) {
- $author .= "email) . "\">" . html_escape($auth->name) . "";
+ foreach ($info->authors as $auth=>$email) {
+ if (!empty($email)) {
+ $author .= "" . html_escape($auth) . "";
} else {
- $author .= html_escape($auth->name);
+ $author .= html_escape($auth);
}
+ $author .= "
";
}
}
diff --git a/ext/favorites/info.php b/ext/favorites/info.php
new file mode 100644
index 00000000..0e49b8d1
--- /dev/null
+++ b/ext/favorites/info.php
@@ -0,0 +1,25 @@
+
+ * License: GPLv2
+ * Description: Allow users to favorite images
+ * Documentation:
+ */
+
+class FavoritesInfo extends ExtensionInfo
+{
+ public const KEY = "favorites";
+
+ public $key = self::KEY;
+ public $name = "Favorites";
+ public $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"];
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Allow users to favorite images";
+ public $documentation =
+"Gives users a \"favorite this image\" button that they can press
+
Visit /featured_image/view
+
Link to /featured_image/download
. This will give
+the raw data for an image (no HTML). This is useful so that you
+can set your desktop wallpaper to be the download URL, refreshed
+every couple of hours.";
+}
diff --git a/ext/featured/main.php b/ext/featured/main.php
index ae5946dd..42fe7bbb 100644
--- a/ext/featured/main.php
+++ b/ext/featured/main.php
@@ -1,23 +1,4 @@
- * Link: http://code.shishnet.org/shimmie2/
- * License: GPLv2
- * Description: Bring a specific image to the users' attentions
- * Documentation:
- * Once enabled, a new "feature this" button will appear next
- * to the other image control buttons (delete, rotate, etc).
- * Clicking it will set the image as the site's current feature,
- * which will be shown in the side bar of the post list.
- *
Visit /featured_image/view
- *
Link to /featured_image/download
. This will give
- * the raw data for an image (no HTML). This is useful so that you
- * can set your desktop wallpaper to be the download URL, refreshed
- * every couple of hours.
- */
class Featured extends Extension
{
@@ -73,7 +54,7 @@ class Featured extends Extension
$database->cache->set("featured_image_object:$fid", $image, 600);
}
if (!is_null($image)) {
- if (ext_is_live("Ratings")) {
+ if (Extension::is_enabled(RatingsInfo::KEY)) {
if (strpos(Ratings::get_user_privs($user), $image->rating) === false) {
return;
}
diff --git a/ext/forum/info.php b/ext/forum/info.php
new file mode 100644
index 00000000..5671e8b2
--- /dev/null
+++ b/ext/forum/info.php
@@ -0,0 +1,21 @@
+
+ * Alpha
Threads per page: ");
$sb->add_int_option("forumPostsPerPage", "
Posts per page: ");
-
+
$sb->add_int_option("forumMaxCharsPerPost", "
Max chars per post: ");
$event->panel->add_block($sb);
}
-
+
public function onUserPageBuilding(UserPageBuildingEvent $event)
{
global $database;
-
+
$threads_count = $database->get_one("SELECT COUNT(*) FROM forum_threads WHERE user_id=?", [$event->display_user->id]);
$posts_count = $database->get_one("SELECT COUNT(*) FROM forum_posts WHERE user_id=?", [$event->display_user->id]);
-
+
$days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
-
+
$threads_rate = sprintf("%.1f", ($threads_count / $days_old));
$posts_rate = sprintf("%.1f", ($posts_count / $days_old));
-
+
$event->add_stats("Forum threads: $threads_count, $threads_rate per day");
$event->add_stats("Forum posts: $posts_count, $posts_rate per day");
}
@@ -249,7 +241,7 @@ class Forum extends Extension
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = ? ", [$threadID]);
return $result["title"];
}
-
+
private function show_last_threads(Page $page, PageRequestEvent $event, $showAdminOptions = false)
{
global $config, $database;
diff --git a/ext/google_analytics/info.php b/ext/google_analytics/info.php
new file mode 100644
index 00000000..2c38ba63
--- /dev/null
+++ b/ext/google_analytics/info.php
@@ -0,0 +1,24 @@
+
+ * Link: http://drudexsoftware.com
+ * License: GPLv2
+ * Description: Integrates Google Analytics tracking
+ * Documentation:
+ *
+ */
+class google_analyticsInfo extends ExtensionInfo
+{
+ public const KEY = "google_analytics";
+
+ public $key = self::KEY;
+ public $name = "Google Analytics";
+ public $url = "http://drudexsoftware.com";
+ public $authors = ["Drudex Software"=>"support@drudexsoftware.com"];
+ public $license = self::LICENSE_GPLV2;
+ public $description = "Integrates Google Analytics tracking";
+ public $documentation =
+"User has to enter their Google Analytics ID in the Board Config to use this extension.";
+}
diff --git a/ext/google_analytics/main.php b/ext/google_analytics/main.php
index 892e4890..f8ff53e8 100644
--- a/ext/google_analytics/main.php
+++ b/ext/google_analytics/main.php
@@ -1,13 +1,5 @@
- * Link: http://drudexsoftware.com
- * License: GPLv2
- * Description: Integrates Google Analytics tracking
- * Documentation:
- * User has to enter their Google Analytics ID in the Board Config to use this extention.
- */
+
class google_analytics extends Extension
{
# Add analytics to config
@@ -18,12 +10,12 @@ class google_analytics extends Extension
$sb->add_label("
(eg. UA-xxxxxxxx-x)");
$event->panel->add_block($sb);
}
-
+
# Load Analytics tracking code on page request
public function onPageRequest(PageRequestEvent $event)
{
global $config, $page;
-
+
$google_analytics_id = $config->get_string('google_analytics_id', '');
if (stristr($google_analytics_id, "UA-")) {
$page->add_html_header("