Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt at externalizing layout from extensions #829

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion ext/artists/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function onImageInfoBoxBuilding(ImageInfoBoxBuildingEvent $event)
global $user;
$artistName = $this->get_artistName_by_imageID($event->image->id);
if (!$user->is_anonymous()) {
$event->add_part($this->theme->get_author_editor_html($artistName), 42);
$event->add_part([$this->theme->get_author_editor_html($artistName)], 42, "Author");
}
}

Expand Down
9 changes: 2 additions & 7 deletions ext/artists/theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,8 @@ public function get_author_editor_html(string $author): string
{
$h_author = html_escape($author);
return "
<tr>
<th>Author</th>
<td>
<span class='view'>$h_author</span>
<input class='edit' type='text' name='tag_edit__author' value='$h_author'>
</td>
</tr>
<span class='view'>$h_author</span>
<input class='edit' type='text' name='tag_edit__author' value='$h_author'>
";
}

Expand Down
4 changes: 2 additions & 2 deletions ext/ban_words/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function onTagSet(TagSetEvent $event)
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Banned Phrases");
$sb->add_label("One per line, lines that start with slashes are treated as regex<br/>");
$sb->add_label("One per line, lines that start with slashes are treated as regex", true);
$sb->add_longtext_option("banned_words");
$failed = [];
foreach ($this->get_words() as $word) {
Expand All @@ -67,7 +67,7 @@ public function onSetupBuilding(SetupBuildingEvent $event)
}
}
if ($failed) {
$sb->add_label("Failed regexes: ".join(", ", $failed));
$sb->add_label("Failed regexes: ".join(", ", $failed), true);
}
}

Expand Down
6 changes: 3 additions & 3 deletions ext/blotter/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public function onDatabaseUpgrade(DatabaseUpgradeEvent $event)
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Blotter");
$sb->add_int_option("blotter_recent", "<br />Number of recent entries to display: ");
$sb->add_text_option("blotter_color", "<br />Color of important updates: (ABCDEF format) ");
$sb->add_choice_option("blotter_position", ["Top of page" => "subheading", "In navigation bar" => "left"], "<br>Position: ");
$sb->add_int_option("blotter_recent", "Number of recent entries to display: ");
$sb->add_text_option("blotter_color", "Color of important updates: (ABCDEF format)");
$sb->add_choice_option("blotter_position", ["Top of page" => "subheading", "In navigation bar" => "left"], "Position: ");
}

public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
Expand Down
4 changes: 1 addition & 3 deletions ext/bulk_download/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Bulk Download");

$sb->start_table();
$sb->add_shorthand_int_option(BulkDownloadConfig::SIZE_LIMIT, "Size Limit", true);
$sb->end_table();
$sb->add_shorthand_int_option(BulkDownloadConfig::SIZE_LIMIT, "Size Limit");
}

public function onBulkAction(BulkActionEvent $event)
Expand Down
21 changes: 8 additions & 13 deletions ext/comment/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,19 +358,14 @@ public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Comment Options");
$sb->add_bool_option("comment_captcha", "Require CAPTCHA for anonymous comments: ");
$sb->add_label("<br>Limit to ");
$sb->add_int_option("comment_limit");
$sb->add_label(" comments per ");
$sb->add_int_option("comment_window");
$sb->add_label(" minutes");
$sb->add_label("<br>Show ");
$sb->add_int_option("comment_count");
$sb->add_label(" recent comments on the index");
$sb->add_label("<br>Show ");
$sb->add_int_option("comment_list_count");
$sb->add_label(" comments per image on the list");
$sb->add_label("<br>Make samefags public ");
$sb->add_bool_option("comment_samefags_public");

$sb->add_int_option("comment_limit", "Limit to ", " comments");
$sb->add_int_option("comment_window", "per", " minutes.");

$sb->add_int_option("comment_count", "Show ", "recent comments on the index.");
$sb->add_int_option("comment_list_count", "Show ", " comments per image on the list.");

$sb->add_bool_option("comment_samefags_public", "Make samefags public ");
}

public function onSearchTermParse(SearchTermParseEvent $event)
Expand Down
12 changes: 5 additions & 7 deletions ext/cron_uploader/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ public function onUserOptionsBuilding(UserOptionsBuildingEvent $event)
$documentation_link = make_http(make_link("cron_upload"));

$sb = $event->panel->create_new_block("Cron Uploader");
$sb->start_table();
$sb->add_text_option(CronUploaderConfig::DIR, "Root dir", true);
$sb->add_bool_option(CronUploaderConfig::STOP_ON_ERROR, "Stop On Error", true);
$sb->add_text_option(CronUploaderConfig::DIR, "Root dir");
$sb->add_bool_option(CronUploaderConfig::STOP_ON_ERROR, "Stop On Error");
$sb->add_choice_option(CronUploaderConfig::LOG_LEVEL, [
LOGGING_LEVEL_NAMES[SCORE_LOG_DEBUG] => SCORE_LOG_DEBUG,
LOGGING_LEVEL_NAMES[SCORE_LOG_INFO] => SCORE_LOG_INFO,
LOGGING_LEVEL_NAMES[SCORE_LOG_WARNING] => SCORE_LOG_WARNING,
LOGGING_LEVEL_NAMES[SCORE_LOG_ERROR] => SCORE_LOG_ERROR,
LOGGING_LEVEL_NAMES[SCORE_LOG_CRITICAL] => SCORE_LOG_CRITICAL,
], "Output Log Level: ", true);
$sb->add_bool_option(CronUploaderConfig::INCLUDE_ALL_LOGS, "Include All Logs", true);
$sb->end_table();
$sb->add_label("<a href='$documentation_link'>Read the documentation</a> for cron setup instructions.");
], "Output Log Level: ");
$sb->add_bool_option(CronUploaderConfig::INCLUDE_ALL_LOGS, "Include All Logs");
$sb->add_label("<a href='$documentation_link'>Read the documentation</a> for cron setup instructions.", true);
}
}

Expand Down
4 changes: 2 additions & 2 deletions ext/custom_html_headers/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ public function onSetupBuilding(SetupBuildingEvent $event)
// custom headers
$sb->add_longtext_option(
"custom_html_headers",
"HTML Code to place within &lt;head&gt;&lt;/head&gt; on all pages<br>"
"HTML Code to place within &lt;head&gt;&lt;/head&gt; on all pages"
);

// modified title
$sb->add_choice_option("sitename_in_title", [
"none" => "none",
"as prefix" => "prefix",
"as suffix" => "suffix"
], "<br>Add website name in title");
], "Add website name in title");
}

public function onInitExt(InitExtEvent $event)
Expand Down
2 changes: 1 addition & 1 deletion ext/downtime/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Downtime");
$sb->add_bool_option("downtime", "Disable non-admin access: ");
$sb->add_longtext_option("downtime_message", "<br>");
$sb->add_longtext_option("downtime_message", "Downtime Message:");
}

public function onPageRequest(PageRequestEvent $event)
Expand Down
6 changes: 2 additions & 4 deletions ext/eokm/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("EOKM Filter");

$sb->start_table();
$sb->add_text_option("eokm_username", "Username", true);
$sb->add_text_option("eokm_password", "Password", true);
$sb->end_table();
$sb->add_text_option("eokm_username", "Username");
$sb->add_text_option("eokm_password", "Password");
}
}
6 changes: 3 additions & 3 deletions ext/forum/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Forum");
$sb->add_int_option("forumTitleSubString", "Title max long: ");
$sb->add_int_option("forumThreadsPerPage", "<br>Threads per page: ");
$sb->add_int_option("forumPostsPerPage", "<br>Posts per page: ");
$sb->add_int_option("forumThreadsPerPage", "Threads per page: ");
$sb->add_int_option("forumPostsPerPage", "Posts per page: ");

$sb->add_int_option("forumMaxCharsPerPost", "<br>Max chars per post: ");
$sb->add_int_option("forumMaxCharsPerPost", "Max chars per post: ");
}

public function onUserPageBuilding(UserPageBuildingEvent $event)
Expand Down
3 changes: 1 addition & 2 deletions ext/google_analytics/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class GoogleAnalytics extends Extension
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Google Analytics");
$sb->add_text_option("google_analytics_id", "Analytics ID: ");
$sb->add_label("<br>(eg. UA-xxxxxxxx-x)");
$sb->add_text_option("google_analytics_id", "Analytics ID: ", "(eg. UA-xxxxxxxx-x)");
}

# Load Analytics tracking code on page request
Expand Down
3 changes: 1 addition & 2 deletions ext/handle_archive/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Archive Handler Options");
$sb->add_text_option("archive_tmp_dir", "Temporary folder: ");
$sb->add_text_option("archive_extract_command", "<br>Extraction command: ");
$sb->add_label("<br>%f for archive, %d for temporary directory");
$sb->add_text_option("archive_extract_command", "Extraction command: ", "%f for archive, %d for temporary directory");
}

public function onDataUpload(DataUploadEvent $event)
Expand Down
10 changes: 4 additions & 6 deletions ext/handle_video/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,10 @@ private function get_options(): array
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Video Options");
$sb->start_table();
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_AUTOPLAY, "Autoplay", true);
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_LOOP, "Loop", true);
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_MUTE, "Mute", true);
$sb->add_multichoice_option(VideoFileHandlerConfig::ENABLED_FORMATS, $this->get_options(), "Enabled Formats", true);
$sb->end_table();
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_AUTOPLAY, "Autoplay");
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_LOOP, "Loop");
$sb->add_bool_option(VideoFileHandlerConfig::PLAYBACK_MUTE, "Mute");
$sb->add_multichoice_option(VideoFileHandlerConfig::ENABLED_FORMATS, $this->get_options(), "Enabled Formats");
}

protected function media_check_properties(MediaCheckPropertiesEvent $event): void
Expand Down
4 changes: 2 additions & 2 deletions ext/home/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public function onSetupBuilding(SetupBuildingEvent $event)

$sb = $event->panel->create_new_block("Home Page");
$sb->add_longtext_option("home_links", 'Page Links (Use BBCode, leave blank for defaults)');
$sb->add_longtext_option("home_text", "<br>Page Text:<br>");
$sb->add_choice_option("home_counter", $counters, "<br>Counter: ");
$sb->add_longtext_option("home_text", "Page Text:");
$sb->add_choice_option("home_counter", $counters, "Counter: ");
}


Expand Down
31 changes: 13 additions & 18 deletions ext/image/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,42 +259,37 @@ public function onSetupBuilding(SetupBuildingEvent $event)
global $config;

$sb = $event->panel->create_new_block("Post Options");
$sb->start_table();
$sb->position = 30;
// advanced only
//$sb->add_text_option(ImageConfig::ILINK, "Image link: ");
//$sb->add_text_option(ImageConfig::TLINK, "<br>Thumbnail link: ");
$sb->add_text_option(ImageConfig::TIP, "Post tooltip", true);
$sb->add_text_option(ImageConfig::INFO, "Post info", true);
$sb->add_choice_option(ImageConfig::UPLOAD_COLLISION_HANDLER, self::COLLISION_OPTIONS, "Upload collision handler", true);
$sb->add_choice_option(ImageConfig::ON_DELETE, self::ON_DELETE_OPTIONS, "On Delete", true);
$sb->add_text_option(ImageConfig::TIP, "Post tooltip");
$sb->add_text_option(ImageConfig::INFO, "Post info");
$sb->add_choice_option(ImageConfig::UPLOAD_COLLISION_HANDLER, self::COLLISION_OPTIONS, "Upload collision handler");
$sb->add_choice_option(ImageConfig::ON_DELETE, self::ON_DELETE_OPTIONS, "On Delete");
if (function_exists(self::EXIF_READ_FUNCTION)) {
$sb->add_bool_option(ImageConfig::SHOW_META, "Show metadata", true);
$sb->add_bool_option(ImageConfig::SHOW_META, "Show metadata");
}
$sb->end_table();

$sb = $event->panel->create_new_block("Thumbnailing");
$sb->start_table();
$sb->add_choice_option(ImageConfig::THUMB_ENGINE, self::THUMBNAIL_ENGINES, "Engine", true);
$sb->add_choice_option(ImageConfig::THUMB_MIME, self::THUMBNAIL_TYPES, "Filetype", true);
$sb->add_choice_option(ImageConfig::THUMB_ENGINE, self::THUMBNAIL_ENGINES, "Engine");
$sb->add_choice_option(ImageConfig::THUMB_MIME, self::THUMBNAIL_TYPES, "Filetype");

$sb->add_int_option(ImageConfig::THUMB_WIDTH, "Max Width", true);
$sb->add_int_option(ImageConfig::THUMB_HEIGHT, "Max Height", true);
$sb->add_int_option(ImageConfig::THUMB_WIDTH, "Max Width");
$sb->add_int_option(ImageConfig::THUMB_HEIGHT, "Max Height");

$options = [];
foreach (MediaEngine::RESIZE_TYPE_SUPPORT[$config->get_string(ImageConfig::THUMB_ENGINE)] as $type) {
$options[$type] = $type;
}

$sb->add_choice_option(ImageConfig::THUMB_FIT, $options, "Fit", true);
$sb->add_choice_option(ImageConfig::THUMB_FIT, $options, "Fit");

$sb->add_int_option(ImageConfig::THUMB_QUALITY, "Quality", true);
$sb->add_int_option(ImageConfig::THUMB_SCALING, "High-DPI Scale %", true);
$sb->add_int_option(ImageConfig::THUMB_QUALITY, "Quality");
$sb->add_int_option(ImageConfig::THUMB_SCALING, "High-DPI Scale %");
if ($config->get_string(ImageConfig::THUMB_MIME)===MimeType::JPEG) {
$sb->add_color_option(ImageConfig::THUMB_ALPHA_COLOR, "Alpha Conversion Color", true);
$sb->add_color_option(ImageConfig::THUMB_ALPHA_COLOR, "Alpha Conversion Color");
}

$sb->end_table();
}

public function onParseLinkTemplate(ParseLinkTemplateEvent $event)
Expand Down
5 changes: 1 addition & 4 deletions ext/image_view_counter/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ public function onImageInfoBoxBuilding(ImageInfoBoxBuildingEvent $event)
["image_id" => $event->image->id]
);

$event->add_part(
"<tr><th>Views:</th><td>$view_count</td></tr>",
38
);
$event->add_part([$view_count], 38, "Views:");
}
}

Expand Down
4 changes: 1 addition & 3 deletions ext/index/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,7 @@ public function onSetupBuilding(SetupBuildingEvent $event)
$sb = $event->panel->create_new_block("Index Options");
$sb->position = 20;

$sb->add_label("Show ");
$sb->add_int_option(IndexConfig::IMAGES);
$sb->add_label(" images on the post list");
$sb->add_int_option(IndexConfig::IMAGES, "Show ", " images on the post list");
}

public function onPageNavBuilding(PageNavBuildingEvent $event)
Expand Down
3 changes: 2 additions & 1 deletion ext/ipban/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,14 @@ public function onSetupBuilding(SetupBuildingEvent $event)
global $config;

$sb = $event->panel->create_new_block("IP Ban");
$sb->add_longtext_option("ipban_message", 'Message to show to banned users:<br>(with $IP, $DATE, $ADMIN, $REASON, and $CONTACT)');
$sb->add_longtext_option("ipban_message", 'Message to show to banned users:');
if ($config->get_string("ipban_message_ghost")) {
$sb->add_longtext_option("ipban_message_ghost", 'Message to show to ghost users:');
}
if ($config->get_string("ipban_message_anon-ghost")) {
$sb->add_longtext_option("ipban_message_anon-ghost", 'Message to show to ghost anons:');
}
$sb->add_label('Flags: $IP, $DATE, $ADMIN, $REASON, $CONTACT', true);
}

public function onPageSubNavBuilding(PageSubNavBuildingEvent $event)
Expand Down
12 changes: 5 additions & 7 deletions ext/media/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,15 @@ public function onSetupBuilding(SetupBuildingEvent $event)
// $sb->add_label("<b style='color:red'>ImageMagick not detected</b>");
// }
// } else {
$sb->start_table();
$sb->add_table_header("Commands");
$sb->add_header("Commands");

$sb->add_text_option(MediaConfig::CONVERT_PATH, "convert", true);
$sb->add_text_option(MediaConfig::CONVERT_PATH, "convert");
// }

$sb->add_text_option(MediaConfig::FFMPEG_PATH, "ffmpeg", true);
$sb->add_text_option(MediaConfig::FFPROBE_PATH, "ffprobe", true);
$sb->add_text_option(MediaConfig::FFMPEG_PATH, "ffmpeg");
$sb->add_text_option(MediaConfig::FFPROBE_PATH, "ffprobe");

$sb->add_shorthand_int_option(MediaConfig::MEM_LIMIT, "Mem limit", true);
$sb->end_table();
$sb->add_shorthand_int_option(MediaConfig::MEM_LIMIT, "Mem limit");
}

public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event)
Expand Down
14 changes: 7 additions & 7 deletions ext/pools/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Pools");
$sb->add_int_option(PoolsConfig::MAX_IMPORT_RESULTS, "Max results on import: ");
$sb->add_int_option(PoolsConfig::IMAGES_PER_PAGE, "<br>Posts per page: ");
$sb->add_int_option(PoolsConfig::LISTS_PER_PAGE, "<br>Index list items per page: ");
$sb->add_int_option(PoolsConfig::UPDATED_PER_PAGE, "<br>Updated list items per page: ");
$sb->add_bool_option(PoolsConfig::INFO_ON_VIEW_IMAGE, "<br>Show pool info on image: ");
$sb->add_bool_option(PoolsConfig::SHOW_NAV_LINKS, "<br>Show 'Prev' & 'Next' links when viewing pool images: ");
$sb->add_bool_option(PoolsConfig::AUTO_INCREMENT_ORDER, "<br>Autoincrement order when post is added to pool:");
//$sb->add_bool_option(PoolsConfig::ADDER_ON_VIEW_IMAGE, "<br>Show pool adder on image: ");
$sb->add_int_option(PoolsConfig::IMAGES_PER_PAGE, "Posts per page: ");
$sb->add_int_option(PoolsConfig::LISTS_PER_PAGE, "Index list items per page: ");
$sb->add_int_option(PoolsConfig::UPDATED_PER_PAGE, "Updated list items per page: ");
$sb->add_bool_option(PoolsConfig::INFO_ON_VIEW_IMAGE, "Show pool info on image: ");
$sb->add_bool_option(PoolsConfig::SHOW_NAV_LINKS, "Show 'Prev' & 'Next' links when viewing pool images: ");
$sb->add_bool_option(PoolsConfig::AUTO_INCREMENT_ORDER, "Autoincrement order when post is added to pool:");
//$sb->add_bool_option(PoolsConfig::ADDER_ON_VIEW_IMAGE, "Show pool adder on image: ");
}

public function onPageNavBuilding(PageNavBuildingEvent $event)
Expand Down
8 changes: 3 additions & 5 deletions ext/post_titles/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function onImageInfoBoxBuilding(ImageInfoBoxBuildingEvent $event)
{
global $user;

$event->add_part($this->theme->get_title_set_html(self::get_title($event->image), $user->can(Permissions::EDIT_IMAGE_TITLE)), 10);
$event->add_part([$this->theme->get_title_set_html(self::get_title($event->image), $user->can(Permissions::EDIT_IMAGE_TITLE))], 10, "Title");
}

public function onImageInfoSet(ImageInfoSetEvent $event)
Expand All @@ -65,10 +65,8 @@ public function onPostTitleSet(PostTitleSetEvent $event)
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Post Titles");
$sb->start_table();
$sb->add_bool_option(PostTitlesConfig::DEFAULT_TO_FILENAME, "Default to filename", true);
$sb->add_bool_option(PostTitlesConfig::SHOW_IN_WINDOW_TITLE, "Show in window title", true);
$sb->end_table();
$sb->add_bool_option(PostTitlesConfig::DEFAULT_TO_FILENAME, "Default to filename");
$sb->add_bool_option(PostTitlesConfig::SHOW_IN_WINDOW_TITLE, "Show in window title");
}

public function onBulkExport(BulkExportEvent $event)
Expand Down
Loading