diff --git a/ext/handle_static/style.css b/ext/handle_static/style.css
index 30315b6c..444fa296 100644
--- a/ext/handle_static/style.css
+++ b/ext/handle_static/style.css
@@ -13,7 +13,7 @@ TD>BUTTON {width: 100%;}
TABLE.form {width: 300px;}
TABLE.form TD, TABLE.form TH {vertical-align: middle;}
TABLE.form TBODY TD {text-align: left;}
-TABLE.form TBODY TH {text-align: right; padding-right: 4px; width: 1%;}
+TABLE.form TBODY TH {text-align: right; padding-right: 4px; width: 1%; white-space: nowrap;}
TABLE.form TD + TH {padding-left: 8px;}
*[onclick],
diff --git a/ext/resize/main.php b/ext/resize/main.php
index a998814e..08036260 100644
--- a/ext/resize/main.php
+++ b/ext/resize/main.php
@@ -11,6 +11,16 @@
* Documentation:
* This extension allows admins to resize images.
*/
+
+abstract class ResizeConfig
+{
+ const ENABLED = 'resize_enabled';
+ const UPLOAD = 'resize_upload';
+ const ENGINE = 'resize_engine';
+ const DEFAULT_WIDTH = 'resize_default_width';
+ const DEFAULT_HEIGHT = 'resize_default_height';
+}
+
/**
* This class handles image resize requests.
*/
@@ -49,15 +59,20 @@ class ResizeImage extends Extension
public function onSetupBuilding(SetupBuildingEvent $event)
{
$sb = new SetupBlock("Image Resize");
- $sb->add_bool_option("resize_enabled", "Allow resizing images: ");
- $sb->add_bool_option("resize_upload", "
Resize on upload: ");
- $sb->add_label("
Preset/Default Width: ");
- $sb->add_int_option("resize_default_width");
- $sb->add_label(" px");
- $sb->add_label("
Preset/Default Height: ");
- $sb->add_int_option("resize_default_height");
- $sb->add_label(" px");
- $sb->add_label("
(enter 0 for no default)");
+ $sb->start_table();
+ $sb->add_bool_option(ResizeConfig::ENABLED, "Allow resizing images: ", true);
+ $sb->add_bool_option(ResizeConfig::UPLOAD, "Resize on upload: ", true);
+ $sb->end_table();
+ $sb->start_table();
+ $sb->add_table_header("Preset/Default Dimensions");
+ $sb->add_label("
Width | ");
+ $sb->add_int_option(ResizeConfig::DEFAULT_WIDTH);
+ $sb->add_label(" | px |
");
+ $sb->add_label("Height | ");
+ $sb->add_int_option(ResizeConfig::DEFAULT_HEIGHT);
+ $sb->add_label(" | px |
");
+ $sb->add_label(" | (enter 0 for no default) |
");
+ $sb->end_table();
$event->panel->add_block($sb);
}
diff --git a/ext/setup/main.php b/ext/setup/main.php
index 23999102..8af9513a 100644
--- a/ext/setup/main.php
+++ b/ext/setup/main.php
@@ -61,6 +61,8 @@ class SetupBlock extends Block
/** @var string */
public $body;
+
+
public function __construct(string $title)
{
$this->header = $title;
@@ -74,38 +76,123 @@ class SetupBlock extends Block
$this->body .= $text;
}
- public function add_text_option(string $name, string $label=null)
+ public function start_table()
{
+ $this->body .= "";
+ }
+ public function start_table_row()
+ {
+ $this->body .= "";
+ }
+ public function end_table_row()
+ {
+ $this->body .= "";
+ }
+ public function start_table_head()
+ {
+ $this->body .= "";
+ }
+ public function end_table_head()
+ {
+ $this->body .= "";
+ }
+ public function add_table_header($content, int $colspan = 2)
+ {
+ $this->start_table_head();
+ $this->start_table_row();
+ $this->add_table_header_cell($content, $colspan);
+ $this->end_table_row();
+ $this->end_table_head();
+ }
+
+ public function start_table_cell(int $colspan = 1)
+ {
+ $this->body .= "";
+ }
+ public function end_table_cell()
+ {
+ $this->body .= " | ";
+ }
+ public function add_table_cell($content, int $colspan = 1)
+ {
+ $this->start_table_cell($colspan);
+ $this->body .= $content;
+ $this->end_table_cell();
+ }
+ public function start_table_header_cell(int $colspan = 1)
+ {
+ $this->body .= "";
+ }
+ public function end_table_header_cell()
+ {
+ $this->body .= " | ";
+ }
+ public function add_table_header_cell($content, int $colspan = 1)
+ {
+ $this->start_table_header_cell($colspan);
+ $this->body .= $content;
+ $this->end_table_header_cell();
+ }
+
+
+
+ private function format_option(string $name, $html, ?string $label, bool $table_row) {
global $config;
- $val = html_escape($config->get_string($name));
+
+ if($table_row) $this->start_table_row();
+ if($table_row) $this->start_table_header_cell();
if (!is_null($label)) {
$this->body .= "";
}
- $this->body .= "\n";
- $this->body .= "\n";
+ if($table_row) $this->end_table_header_cell();
+
+ if($table_row) $this->start_table_cell();
+ $this->body .= $html;
+ if($table_row) $this->end_table_cell();
+ if($table_row) $this->end_table_row();
}
- public function add_longtext_option(string $name, string $label=null)
+ public function add_text_option(string $name, string $label=null, bool $table_row = false)
{
global $config;
$val = html_escape($config->get_string($name));
- if (!is_null($label)) {
- $this->body .= "";
- }
- $rows = max(3, min(10, count(explode("\n", $val))));
- $this->body .= "\n";
- $this->body .= "\n";
+
+ $html = "\n";
+ $html .= "\n";
+
+ $this->format_option($name, $html, $label, $table_row);
}
- public function add_bool_option(string $name, string $label=null)
+ public function add_longtext_option(string $name, string $label=null, bool $table_row = false)
+ {
+ global $config;
+ $val = html_escape($config->get_string($name));
+
+ $rows = max(3, min(10, count(explode("\n", $val))));
+ $html = "\n";
+ $html .= "\n";
+
+ $this->format_option($name, $html, $label, $table_row);
+ }
+
+ public function add_bool_option(string $name, string $label=null, bool $table_row = false)
{
global $config;
$checked = $config->get_bool($name) ? " checked" : "";
+
+ $html = "\n";
if (!is_null($label)) {
- $this->body .= "";
+ $html .= "";
+ $label = null;
}
- $this->body .= "\n";
- $this->body .= "\n";
+
+ $html .= "\n";
+
+ $this->format_option($name, $html, $label, $table_row);
}
// public function add_hidden_option($name, $label=null) {
@@ -114,36 +201,33 @@ class SetupBlock extends Block
// $this->body .= "";
// }
- public function add_int_option(string $name, string $label=null)
+ public function add_int_option(string $name, string $label=null, bool $table_row = false)
{
global $config;
$val = html_escape($config->get_string($name));
- if (!is_null($label)) {
- $this->body .= "";
- }
- $this->body .= "\n";
- $this->body .= "\n";
+
+ $html = "\n";
+ $html .= "\n";
+
+ $this->format_option($name, $html, $label, $table_row);
+
}
- public function add_shorthand_int_option(string $name, string $label=null)
+ public function add_shorthand_int_option(string $name, string $label=null, bool $table_row = false)
{
global $config;
$val = to_shorthand_int($config->get_string($name));
- if (!is_null($label)) {
- $this->body .= "";
- }
- $this->body .= "\n";
- $this->body .= "\n";
+ $html = "\n";
+ $html .= "\n";
+
+ $this->format_option($name, $html, $label, $table_row);
}
- public function add_choice_option(string $name, array $options, string $label=null)
+ public function add_choice_option(string $name, array $options, string $label=null, bool $table_row = false)
{
global $config;
$current = $config->get_string($name);
- if (!is_null($label)) {
- $this->body .= "";
- }
$html = "";
- $this->body .= "\n";
+ $html .= "\n";
- $this->body .= $html;
+ $this->format_option($name, $html, $label, $table_row);
}
- public function add_multichoice_option(string $name, array $options, string $label=null)
+ public function add_multichoice_option(string $name, array $options, string $label=null, bool $table_row = false)
{
global $config;
$current = $config->get_array($name);
- if (!is_null($label)) {
- $this->body .= "";
- }
$html = "";
- $this->body .= "\n";
- $this->body .= "\n"; // setup page auto-layout counts
tags
+ $html .= "\n";
+ $html .= "\n"; // setup page auto-layout counts
tags
- $this->body .= $html;
+ $this->format_option($name, $html, $label, $table_row);
}
}
// }}}
diff --git a/ext/transcode/main.php b/ext/transcode/main.php
index 94520ba0..b47efcb1 100644
--- a/ext/transcode/main.php
+++ b/ext/transcode/main.php
@@ -133,16 +133,18 @@ class TranscodeImage extends Extension
$sb = new SetupBlock("Image Transcode");
- $sb->add_bool_option("transcode_enabled", "Allow transcoding images: ");
- $sb->add_bool_option("transcode_upload", "
Transcode on upload: ");
- $sb->add_choice_option('transcode_engine', self::CONVERSION_ENGINES, "
Transcode engine: ");
+ $sb->start_table();
+ $sb->add_bool_option(TranscodeConfig::ENABLED, "Allow transcoding images: ", true);
+ $sb->add_bool_option(TranscodeConfig::UPLOAD, "Transcode on upload: ", true);
+ $sb->add_choice_option(TranscodeConfig::ENGINE, self::CONVERSION_ENGINES, "Engine", true);
foreach (self::INPUT_FORMATS as $display=>$format) {
if (in_array($format, self::ENGINE_INPUT_SUPPORT[$engine])) {
$outputs = $this->get_supported_output_formats($engine, $format);
- $sb->add_choice_option('transcode_upload_'.$format, $outputs, "
$display to: ");
+ $sb->add_choice_option(TranscodeConfig::UPLOAD_PREFIX.$format, $outputs, "$display", true);
}
}
- $sb->add_int_option("transcode_quality", "
Lossy format quality: ");
+ $sb->add_int_option(TranscodeConfig::QUALITY, "Lossy format quality: ");
+ $sb->end_table();
$event->panel->add_block($sb);
}