Refactor admin page

This commit is contained in:
2026-01-13 09:37:24 +01:00
parent 77fcae3450
commit 7c9e289740
9 changed files with 294 additions and 26 deletions

View File

@@ -13,8 +13,20 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin
'paths',
'scratchpad_paths',
'allow_in_comments',
'defaults',
'extensions',
'default_sort',
'default_order',
'default_style',
'default_tableheader',
'default_foldersfirst',
'default_recursive',
'default_titlefile',
'default_cache',
'default_randlinks',
'default_showsize',
'default_showdate',
'default_listsep',
'default_maxheight',
'thumb_placeholder',
'gallery_thumb_scale',
'open_service_url',
@@ -58,8 +70,22 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin
$newConf['scratchpad_paths'] = $scratchpadPaths;
$newConf['allow_in_comments'] = (int)$INPUT->bool('allow_in_comments');
$newConf['defaults'] = $INPUT->str('defaults');
$newConf['extensions'] = $INPUT->str('extensions');
$newConf['default_sort'] = $INPUT->str('default_sort');
$newConf['default_order'] = $INPUT->str('default_order');
$newConf['default_style'] = $INPUT->str('default_style');
$newConf['default_tableheader'] = (int)$INPUT->bool('default_tableheader');
$newConf['default_foldersfirst'] = (int)$INPUT->bool('default_foldersfirst');
$newConf['default_recursive'] = (int)$INPUT->bool('default_recursive');
$newConf['default_titlefile'] = $INPUT->str('default_titlefile');
$newConf['default_cache'] = (int)$INPUT->bool('default_cache');
$newConf['default_randlinks'] = (int)$INPUT->bool('default_randlinks');
$newConf['default_showsize'] = (int)$INPUT->bool('default_showsize');
$newConf['default_showdate'] = (int)$INPUT->bool('default_showdate');
$newConf['default_listsep'] = $INPUT->str('default_listsep');
$newConf['default_maxheight'] = $INPUT->str('default_maxheight');
$newConf['thumb_placeholder'] = $INPUT->str('thumb_placeholder');
$newConf['gallery_thumb_scale'] = $INPUT->str('gallery_thumb_scale');
$newConf['open_service_url'] = $INPUT->str('open_service_url');
@@ -106,16 +132,103 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin
echo '<input type="checkbox" name="allow_in_comments" value="1"' . $checked . ' />';
echo '</label><br />';
// defaults
echo '<label class="block"><span>' . hsc($this->getLang('defaults')) . '</span> ';
echo '<input type="text" class="edit" name="defaults" value="' . hsc((string)$this->getConf('defaults')) . '" />';
echo '</label><br />';
// extensions
echo '<label class="block"><span>' . hsc($this->getLang('extensions')) . '</span> ';
echo '<input type="text" class="edit" name="extensions" value="' . hsc((string)$this->getConf('extensions')) . '" />';
echo '</label><br />';
echo '<h2>' . hsc($this->getLang('listing_defaults')) . '</h2>';
// default_sort
$defaultSort = (string)$this->getConf('default_sort');
echo '<label class="block"><span>' . hsc($this->getLang('default_sort')) . '</span>';
echo '<select name="default_sort" class="edit">';
foreach (['name', 'iname', 'ctime', 'mtime', 'size'] as $opt) {
$sel = ($defaultSort === $opt) ? ' selected="selected"' : '';
echo '<option value="' . hsc($opt) . '"' . $sel . '>' . hsc($opt) . '</option>';
}
echo '</select>';
echo '</label><br />';
// default_order
$defaultOrder = (string)$this->getConf('default_order');
echo '<label class="block"><span>' . hsc($this->getLang('default_order')) . '</span>';
echo '<select name="default_order" class="edit">';
foreach (['asc', 'desc'] as $opt) {
$sel = ($defaultOrder === $opt) ? ' selected="selected"' : '';
echo '<option value="' . hsc($opt) . '"' . $sel . '>' . hsc($opt) . '</option>';
}
echo '</select>';
echo '</label><br />';
// default_style
$defaultStyle = (string)$this->getConf('default_style');
echo '<label class="block"><span>' . hsc($this->getLang('default_style')) . '</span>';
echo '<select name="default_style" class="edit">';
foreach (['list', 'olist', 'table'] as $opt) {
$sel = ($defaultStyle === $opt) ? ' selected="selected"' : '';
echo '<option value="' . hsc($opt) . '"' . $sel . '>' . hsc($opt) . '</option>';
}
echo '</select>';
echo '</label><br />';
// default_tableheader
$checked = $this->getConf('default_tableheader') ? ' checked="checked"' : '';
echo '<label class="block"><span>' . hsc($this->getLang('default_tableheader')) . '</span> ';
echo '<input type="checkbox" name="default_tableheader" value="1"' . $checked . ' />';
echo '</label><br />';
// default_foldersfirst
$checked = $this->getConf('default_foldersfirst') ? ' checked="checked"' : '';
echo '<label class="block"><span>' . hsc($this->getLang('default_foldersfirst')) . '</span> ';
echo '<input type="checkbox" name="default_foldersfirst" value="1"' . $checked . ' />';
echo '</label><br />';
// default_recursive
$checked = $this->getConf('default_recursive') ? ' checked="checked"' : '';
echo '<label class="block"><span>' . hsc($this->getLang('default_recursive')) . '</span> ';
echo '<input type="checkbox" name="default_recursive" value="1"' . $checked . ' />';
echo '</label><br />';
// default_titlefile
echo '<label class="block"><span>' . hsc($this->getLang('default_titlefile')) . '</span>';
echo '<input type="text" class="edit" name="default_titlefile" value="' . hsc((string)$this->getConf('default_titlefile')) . '" />';
echo '</label><br />';
// default_cache
$checked = $this->getConf('default_cache') ? ' checked="checked"' : '';
echo '<label class="block"><span>' . hsc($this->getLang('default_cache')) . '</span> ';
echo '<input type="checkbox" name="default_cache" value="1"' . $checked . ' />';
echo '</label><br />';
// default_randlinks
$checked = $this->getConf('default_randlinks') ? ' checked="checked"' : '';
echo '<label class="block"><span>' . hsc($this->getLang('default_randlinks')) . '</span> ';
echo '<input type="checkbox" name="default_randlinks" value="1"' . $checked . ' />';
echo '</label><br />';
// default_showsize
$checked = $this->getConf('default_showsize') ? ' checked="checked"' : '';
echo '<label class="block"><span>' . hsc($this->getLang('default_showsize')) . '</span> ';
echo '<input type="checkbox" name="default_showsize" value="1"' . $checked . ' />';
echo '</label><br />';
// default_showdate
$checked = $this->getConf('default_showdate') ? ' checked="checked"' : '';
echo '<label class="block"><span>' . hsc($this->getLang('default_showdate')) . '</span> ';
echo '<input type="checkbox" name="default_showdate" value="1"' . $checked . ' />';
echo '</label><br />';
// default_listsep
echo '<label class="block"><span>' . hsc($this->getLang('default_listsep')) . '</span>';
echo '<input type="text" class="edit" name="default_listsep" value="' . hsc((string)$this->getConf('default_listsep')) . '" />';
echo '</label><br />';
// default_maxheight
echo '<label class="block"><span>' . hsc($this->getLang('default_maxheight')) . '</span>';
echo '<input type="number" class="edit" name="default_maxheight" value="' . hsc((string)$this->getConf('default_maxheight')) . '" />';
echo '</label><br />';
// thumb_placeholder
echo '<label class="block"><span>' . hsc($this->getLang('thumb_placeholder')) . '</span> ';
echo '<input type="text" class="edit" name="thumb_placeholder" value="' . hsc((string)$this->getConf('thumb_placeholder')) . '" />';