Fix settings page textarea displays
This commit is contained in:
@@ -111,13 +111,13 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin
|
|||||||
echo '<legend>' . hsc($this->getLang('legend')) . '</legend>';
|
echo '<legend>' . hsc($this->getLang('legend')) . '</legend>';
|
||||||
|
|
||||||
// paths: multiline textarea
|
// paths: multiline textarea
|
||||||
$paths = (string)$this->getConf('paths');
|
$paths = $this->normalizeMultilineDisplay((string)$this->getConf('paths'), 'paths');
|
||||||
echo '<label class="block"><span>' . hsc($this->getLang('paths')) . '</span><br />';
|
echo '<label class="block"><span>' . hsc($this->getLang('paths')) . '</span><br />';
|
||||||
echo '<textarea name="paths" rows="8" cols="80" class="edit">' . hsc($paths) . '</textarea>';
|
echo '<textarea name="paths" rows="8" cols="80" class="edit">' . hsc($paths) . '</textarea>';
|
||||||
echo '</label><br />';
|
echo '</label><br />';
|
||||||
|
|
||||||
// scratchpad_paths: multiline textarea
|
// scratchpad_paths: multiline textarea
|
||||||
$scratchpadPaths = (string)$this->getConf('scratchpad_paths');
|
$scratchpadPaths = $this->normalizeMultilineDisplay((string)$this->getConf('scratchpad_paths'), 'scratchpad_paths');
|
||||||
echo '<label class="block"><span>' . hsc($this->getLang('scratchpad_paths')) . '</span><br />';
|
echo '<label class="block"><span>' . hsc($this->getLang('scratchpad_paths')) . '</span><br />';
|
||||||
echo '<textarea name="scratchpad_paths" rows="6" cols="80" class="edit">' . hsc($scratchpadPaths) . '</textarea>';
|
echo '<textarea name="scratchpad_paths" rows="6" cols="80" class="edit">' . hsc($scratchpadPaths) . '</textarea>';
|
||||||
echo '</label><br />';
|
echo '</label><br />';
|
||||||
@@ -338,4 +338,24 @@ class admin_plugin_luxtools_main extends DokuWiki_Admin_Plugin
|
|||||||
|
|
||||||
return var_export($value, true);
|
return var_export($value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip nowdoc markers from values when displaying in the admin form.
|
||||||
|
*
|
||||||
|
* @param string $value
|
||||||
|
* @param string $key
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function normalizeMultilineDisplay(string $value, string $key): string
|
||||||
|
{
|
||||||
|
$marker = strtoupper('LUXTOOLS_' . preg_replace('/[^A-Z0-9_]/i', '_', $key) . '_EOT');
|
||||||
|
$prefix = "<<<'$marker'\n";
|
||||||
|
$suffix = "\n$marker";
|
||||||
|
|
||||||
|
if (str_starts_with($value, $prefix) && str_ends_with($value, $suffix)) {
|
||||||
|
return substr($value, strlen($prefix), -strlen($suffix));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user