avoid stringy class names
This commit is contained in:
parent
12ca708be8
commit
373be4e05c
14 changed files with 27 additions and 27 deletions
|
@ -245,7 +245,7 @@ abstract class ExtensionInfo
|
||||||
|
|
||||||
public static function load_all_extension_info(): void
|
public static function load_all_extension_info(): void
|
||||||
{
|
{
|
||||||
foreach (get_subclasses_of("Shimmie2\ExtensionInfo") as $class) {
|
foreach (get_subclasses_of(ExtensionInfo::class) as $class) {
|
||||||
$extension_info = new $class();
|
$extension_info = new $class();
|
||||||
if (array_key_exists($extension_info->key, self::$all_info_by_key)) {
|
if (array_key_exists($extension_info->key, self::$all_info_by_key)) {
|
||||||
throw new SCoreException("Extension Info $class with key $extension_info->key has already been loaded");
|
throw new SCoreException("Extension Info $class with key $extension_info->key has already been loaded");
|
||||||
|
@ -399,13 +399,13 @@ abstract class DataHandlerExtension extends Extension
|
||||||
public static function get_all_supported_mimes(): array
|
public static function get_all_supported_mimes(): array
|
||||||
{
|
{
|
||||||
$arr = [];
|
$arr = [];
|
||||||
foreach (get_subclasses_of("Shimmie2\DataHandlerExtension") as $handler) {
|
foreach (get_subclasses_of(DataHandlerExtension::class) as $handler) {
|
||||||
$handler = (new $handler());
|
$handler = (new $handler());
|
||||||
$arr = array_merge($arr, $handler->SUPPORTED_MIME);
|
$arr = array_merge($arr, $handler->SUPPORTED_MIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Not sure how to handle this otherwise, don't want to set up a whole other event for this one class
|
// Not sure how to handle this otherwise, don't want to set up a whole other event for this one class
|
||||||
if (class_exists("Shimmie2\TranscodeImage")) {
|
if (Extension::is_enabled(TranscodeImageInfo::KEY)) {
|
||||||
$arr = array_merge($arr, TranscodeImage::get_enabled_mimes());
|
$arr = array_merge($arr, TranscodeImage::get_enabled_mimes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ function _set_event_listeners(): void
|
||||||
global $_shm_event_listeners;
|
global $_shm_event_listeners;
|
||||||
$_shm_event_listeners = [];
|
$_shm_event_listeners = [];
|
||||||
|
|
||||||
foreach (get_subclasses_of("Shimmie2\Extension") as $class) {
|
foreach (get_subclasses_of(Extension::class) as $class) {
|
||||||
/** @var Extension $extension */
|
/** @var Extension $extension */
|
||||||
$extension = new $class();
|
$extension = new $class();
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class SearchTest extends ShimmiePHPUnitTestCase
|
||||||
array $expected_img_conditions,
|
array $expected_img_conditions,
|
||||||
string $expected_order,
|
string $expected_order,
|
||||||
): void {
|
): void {
|
||||||
$class = new \ReflectionClass('\Shimmie2\Search');
|
$class = new \ReflectionClass(Search::class);
|
||||||
$terms_to_conditions = $class->getMethod("terms_to_conditions");
|
$terms_to_conditions = $class->getMethod("terms_to_conditions");
|
||||||
$terms_to_conditions->setAccessible(true); // Use this if you are running PHP older than 8.1.0
|
$terms_to_conditions->setAccessible(true); // Use this if you are running PHP older than 8.1.0
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ class SearchTest extends ShimmiePHPUnitTestCase
|
||||||
|
|
||||||
Search::$_search_path = [];
|
Search::$_search_path = [];
|
||||||
|
|
||||||
$class = new \ReflectionClass('\Shimmie2\Search');
|
$class = new \ReflectionClass(Search::class);
|
||||||
$build_search_querylet = $class->getMethod("build_search_querylet");
|
$build_search_querylet = $class->getMethod("build_search_querylet");
|
||||||
$build_search_querylet->setAccessible(true); // Use this if you are running PHP older than 8.1.0
|
$build_search_querylet->setAccessible(true); // Use this if you are running PHP older than 8.1.0
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ class UserClass
|
||||||
{
|
{
|
||||||
global $_all_false;
|
global $_all_false;
|
||||||
$perms = [];
|
$perms = [];
|
||||||
foreach ((new \ReflectionClass('\Shimmie2\Permissions'))->getConstants() as $k => $v) {
|
foreach ((new \ReflectionClass(Permissions::class))->getConstants() as $k => $v) {
|
||||||
if ($this->can($v)) {
|
if ($this->can($v)) {
|
||||||
$perms[] = $v;
|
$perms[] = $v;
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ class UserClass
|
||||||
}
|
}
|
||||||
|
|
||||||
$_all_false = [];
|
$_all_false = [];
|
||||||
foreach ((new \ReflectionClass('\Shimmie2\Permissions'))->getConstants() as $k => $v) {
|
foreach ((new \ReflectionClass(Permissions::class))->getConstants() as $k => $v) {
|
||||||
$_all_false[$v] = false;
|
$_all_false[$v] = false;
|
||||||
}
|
}
|
||||||
new UserClass("base", null, $_all_false);
|
new UserClass("base", null, $_all_false);
|
||||||
|
|
|
@ -224,7 +224,7 @@ class BulkActions extends Extension
|
||||||
$size = 0;
|
$size = 0;
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
try {
|
try {
|
||||||
if (class_exists("Shimmie2\ImageBan") && isset($_POST['bulk_ban_reason'])) {
|
if (Extension::is_enabled(ImageBanInfo::KEY) && isset($_POST['bulk_ban_reason'])) {
|
||||||
$reason = $_POST['bulk_ban_reason'];
|
$reason = $_POST['bulk_ban_reason'];
|
||||||
if ($reason) {
|
if ($reason) {
|
||||||
send_event(new AddImageHashBanEvent($post->hash, $reason));
|
send_event(new AddImageHashBanEvent($post->hash, $reason));
|
||||||
|
|
|
@ -51,7 +51,7 @@ class BulkActionsTheme extends Themelet
|
||||||
|
|
||||||
public function render_ban_reason_input(): string
|
public function render_ban_reason_input(): string
|
||||||
{
|
{
|
||||||
if (class_exists("Shimmie2\ImageBan")) {
|
if (Extension::is_enabled(ImageBanInfo::KEY)) {
|
||||||
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)' />";
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -71,10 +71,10 @@ class Home extends Extension
|
||||||
$main_links = $config->get_string('home_links');
|
$main_links = $config->get_string('home_links');
|
||||||
} else {
|
} else {
|
||||||
$main_links = '[url=site://post/list]Posts[/url][url=site://comment/list]Comments[/url][url=site://tags]Tags[/url]';
|
$main_links = '[url=site://post/list]Posts[/url][url=site://comment/list]Comments[/url][url=site://tags]Tags[/url]';
|
||||||
if (class_exists("Shimmie2\Pools")) {
|
if (Extension::is_enabled(PoolsInfo::KEY)) {
|
||||||
$main_links .= '[url=site://pool/list]Pools[/url]';
|
$main_links .= '[url=site://pool/list]Pools[/url]';
|
||||||
}
|
}
|
||||||
if (class_exists("Shimmie2\Wiki")) {
|
if (Extension::is_enabled(WikiInfo::KEY)) {
|
||||||
$main_links .= '[url=site://wiki]Wiki[/url]';
|
$main_links .= '[url=site://wiki]Wiki[/url]';
|
||||||
}
|
}
|
||||||
$main_links .= '[url=site://ext_doc]Documentation[/url]';
|
$main_links .= '[url=site://ext_doc]Documentation[/url]';
|
||||||
|
|
|
@ -113,7 +113,7 @@ and of course start organising your images :-)
|
||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (class_exists('Shimmie2\Wiki') && $config->get_bool(WikiConfig::TAG_SHORTWIKIS)) {
|
if (Extension::is_enabled(WikiInfo::KEY) && $config->get_bool(WikiConfig::TAG_SHORTWIKIS)) {
|
||||||
if (count($this->search_terms) == 1) {
|
if (count($this->search_terms) == 1) {
|
||||||
$st = Tag::implode($this->search_terms);
|
$st = Tag::implode($this->search_terms);
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ and of course start organising your images :-)
|
||||||
$short_wiki_description = $tfe->formatted;
|
$short_wiki_description = $tfe->formatted;
|
||||||
}
|
}
|
||||||
$wikiLink = make_link("wiki/$st");
|
$wikiLink = make_link("wiki/$st");
|
||||||
if (class_exists('Shimmie2\TagCategories')) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$tagcategories = new TagCategories();
|
$tagcategories = new TagCategories();
|
||||||
$tag_category_dict = $tagcategories->getKeyedDict();
|
$tag_category_dict = $tagcategories->getKeyedDict();
|
||||||
$st = $tagcategories->getTagHtml(html_escape($st), $tag_category_dict);
|
$st = $tagcategories->getTagHtml(html_escape($st), $tag_category_dict);
|
||||||
|
|
|
@ -89,7 +89,7 @@ class TagList extends Extension
|
||||||
if ($config->get_int(TagListConfig::LENGTH) > 0) {
|
if ($config->get_int(TagListConfig::LENGTH) > 0) {
|
||||||
$type = $config->get_string(TagListConfig::IMAGE_TYPE);
|
$type = $config->get_string(TagListConfig::IMAGE_TYPE);
|
||||||
if ($type == TagListConfig::TYPE_TAGS || $type == TagListConfig::TYPE_BOTH) {
|
if ($type == TagListConfig::TYPE_TAGS || $type == TagListConfig::TYPE_BOTH) {
|
||||||
if (class_exists("Shimmie2\TagCategories") and $config->get_bool(TagCategoriesConfig::SPLIT_ON_VIEW)) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY) and $config->get_bool(TagCategoriesConfig::SPLIT_ON_VIEW)) {
|
||||||
$this->add_split_tags_block($page, $event->image);
|
$this->add_split_tags_block($page, $event->image);
|
||||||
} else {
|
} else {
|
||||||
$this->add_tags_block($page, $event->image);
|
$this->add_tags_block($page, $event->image);
|
||||||
|
@ -266,7 +266,7 @@ class TagList extends Extension
|
||||||
$html .= $this->build_az();
|
$html .= $this->build_az();
|
||||||
}
|
}
|
||||||
$tag_category_dict = [];
|
$tag_category_dict = [];
|
||||||
if (class_exists('Shimmie2\TagCategories')) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$this->tagcategories = new TagCategories();
|
$this->tagcategories = new TagCategories();
|
||||||
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ class TagList extends Extension
|
||||||
$size = 0.5;
|
$size = 0.5;
|
||||||
}
|
}
|
||||||
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
||||||
if (class_exists('Shimmie2\TagCategories')) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$h_tag_no_underscores = $this->tagcategories->getTagHtml($h_tag, $tag_category_dict);
|
$h_tag_no_underscores = $this->tagcategories->getTagHtml($h_tag, $tag_category_dict);
|
||||||
}
|
}
|
||||||
$html .= " <a style='font-size: {$size}em' href='$link'>$h_tag_no_underscores</a> \n";
|
$html .= " <a style='font-size: {$size}em' href='$link'>$h_tag_no_underscores</a> \n";
|
||||||
|
@ -336,7 +336,7 @@ class TagList extends Extension
|
||||||
mb_internal_encoding('UTF-8');
|
mb_internal_encoding('UTF-8');
|
||||||
|
|
||||||
$tag_category_dict = [];
|
$tag_category_dict = [];
|
||||||
if (class_exists('Shimmie2\TagCategories')) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$this->tagcategories = new TagCategories();
|
$this->tagcategories = new TagCategories();
|
||||||
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ class TagList extends Extension
|
||||||
}
|
}
|
||||||
$link = $this->theme->tag_link($tag);
|
$link = $this->theme->tag_link($tag);
|
||||||
$h_tag = html_escape($tag);
|
$h_tag = html_escape($tag);
|
||||||
if (class_exists('Shimmie2\TagCategories')) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$h_tag = $this->tagcategories->getTagHtml($h_tag, $tag_category_dict, " ($count)");
|
$h_tag = $this->tagcategories->getTagHtml($h_tag, $tag_category_dict, " ($count)");
|
||||||
}
|
}
|
||||||
$html .= "<a href='$link'>$h_tag</a>\n";
|
$html .= "<a href='$link'>$h_tag</a>\n";
|
||||||
|
|
|
@ -74,7 +74,7 @@ class TagListTheme extends Themelet
|
||||||
asort($tag_infos);
|
asort($tag_infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists('Shimmie2\TagCategories')) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$this->tagcategories = new TagCategories();
|
$this->tagcategories = new TagCategories();
|
||||||
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
||||||
} else {
|
} else {
|
||||||
|
@ -136,7 +136,7 @@ class TagListTheme extends Themelet
|
||||||
asort($tag_infos);
|
asort($tag_infos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists('Shimmie2\TagCategories')) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$this->tagcategories = new TagCategories();
|
$this->tagcategories = new TagCategories();
|
||||||
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
$tag_category_dict = $this->tagcategories->getKeyedDict();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -180,7 +180,7 @@ class Upload extends Extension
|
||||||
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event): void
|
public function onPageSubNavBuilding(PageSubNavBuildingEvent $event): void
|
||||||
{
|
{
|
||||||
if ($event->parent == "upload") {
|
if ($event->parent == "upload") {
|
||||||
if (class_exists("Shimmie2\Wiki")) {
|
if (Extension::is_enabled(WikiInfo::KEY)) {
|
||||||
$event->add_nav_link("upload_guidelines", new Link('wiki/upload_guidelines'), "Guidelines");
|
$event->add_nav_link("upload_guidelines", new Link('wiki/upload_guidelines'), "Guidelines");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,7 +200,7 @@ class UserPage extends Extension
|
||||||
$this->theme->display_user_classes(
|
$this->theme->display_user_classes(
|
||||||
$page,
|
$page,
|
||||||
$_shm_user_classes,
|
$_shm_user_classes,
|
||||||
(new \ReflectionClass('\Shimmie2\Permissions'))->getReflectionConstants()
|
(new \ReflectionClass(Permissions::class))->getReflectionConstants()
|
||||||
);
|
);
|
||||||
} elseif ($event->get_arg(0) == "logout") {
|
} elseif ($event->get_arg(0) == "logout") {
|
||||||
$this->page_logout();
|
$this->page_logout();
|
||||||
|
@ -789,7 +789,7 @@ class UserPage extends Extension
|
||||||
|
|
||||||
private function count_log_ips(User $duser): array
|
private function count_log_ips(User $duser): array
|
||||||
{
|
{
|
||||||
if (!class_exists('Shimmie2\LogDatabase')) {
|
if (!Extension::is_enabled(LogDatabaseInfo::KEY)) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
global $database;
|
global $database;
|
||||||
|
|
|
@ -392,7 +392,7 @@ class Wiki extends Extension
|
||||||
$template = $config->get_string(WikiConfig::TAG_PAGE_TEMPLATE);
|
$template = $config->get_string(WikiConfig::TAG_PAGE_TEMPLATE);
|
||||||
|
|
||||||
//CATEGORIES
|
//CATEGORIES
|
||||||
if (class_exists("Shimmie2\TagCategories")) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$tagcategories = new TagCategories();
|
$tagcategories = new TagCategories();
|
||||||
$tag_category_dict = $tagcategories->getKeyedDict();
|
$tag_category_dict = $tagcategories->getKeyedDict();
|
||||||
}
|
}
|
||||||
|
@ -415,7 +415,7 @@ class Wiki extends Extension
|
||||||
$template = format_text($template);
|
$template = format_text($template);
|
||||||
//Things after this line will NOT be escaped!!! Be careful what you add.
|
//Things after this line will NOT be escaped!!! Be careful what you add.
|
||||||
|
|
||||||
if (class_exists("Shimmie2\AutoTagger")) {
|
if (Extension::is_enabled(AutoTaggerInfo::KEY)) {
|
||||||
$auto_tags = $database->get_one("
|
$auto_tags = $database->get_one("
|
||||||
SELECT additional_tags
|
SELECT additional_tags
|
||||||
FROM auto_tag
|
FROM auto_tag
|
||||||
|
|
|
@ -30,7 +30,7 @@ class WikiTheme extends Themelet
|
||||||
|
|
||||||
// see if title is a category'd tag
|
// see if title is a category'd tag
|
||||||
$title_html = html_escape($wiki_page->title);
|
$title_html = html_escape($wiki_page->title);
|
||||||
if (class_exists('Shimmie2\TagCategories')) {
|
if (Extension::is_enabled(TagCategoriesInfo::KEY)) {
|
||||||
$tagcategories = new TagCategories();
|
$tagcategories = new TagCategories();
|
||||||
$tag_category_dict = $tagcategories->getKeyedDict();
|
$tag_category_dict = $tagcategories->getKeyedDict();
|
||||||
$title_html = $tagcategories->getTagHtml($title_html, $tag_category_dict);
|
$title_html = $tagcategories->getTagHtml($title_html, $tag_category_dict);
|
||||||
|
|
Reference in a new issue