pdledit usability improvements

This commit is contained in:
zotlabs 2017-10-10 16:05:10 -07:00
parent 335536bbbf
commit 6a2c5e0731
2 changed files with 26 additions and 3 deletions

View File

@ -14,7 +14,7 @@ class Pdledit extends \Zotlabs\Web\Controller {
if(! trim($_REQUEST['content'])) { if(! trim($_REQUEST['content'])) {
del_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl'); del_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl');
goaway(z_root() . '/pdledit/' . $_REQUEST['module']); goaway(z_root() . '/pdledit');
} }
set_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl',escape_tags($_REQUEST['content'])); set_pconfig(local_channel(),'system','mod_' . $_REQUEST['module'] . '.pdl',escape_tags($_REQUEST['content']));
build_sync_packet(); build_sync_packet();
@ -35,18 +35,37 @@ class Pdledit extends \Zotlabs\Web\Controller {
return; return;
} }
if(argc() > 2 && argv(2) === 'reset') {
del_pconfig(local_channel(),'system','mod_' . argv(1) . '.pdl');
goaway(z_root() . '/pdledit');
}
if(argc() > 1) if(argc() > 1)
$module = 'mod_' . argv(1) . '.pdl'; $module = 'mod_' . argv(1) . '.pdl';
else { else {
$o .= '<div class="generic-content-wrapper-styled">'; $o .= '<div class="generic-content-wrapper-styled">';
$o .= '<h1>' . t('Edit System Page Description') . '</h1>'; $o .= '<h1>' . t('Edit System Page Description') . '</h1>';
$edited = [];
$r = q("select k from pconfig where uid = %d and cat = 'system' and k like '%s' ",
intval(local_channel()),
dbesc('mod_%.pdl')
);
if($r) {
foreach($r as $rv) {
$edited[] = substr(str_replace('.pdl','',$rv['k']),4);
}
}
$files = glob('Zotlabs/Module/*.php'); $files = glob('Zotlabs/Module/*.php');
if($files) { if($files) {
foreach($files as $f) { foreach($files as $f) {
$name = lcfirst(basename($f,'.php')); $name = lcfirst(basename($f,'.php'));
$x = theme_include('mod_' . $name . '.pdl'); $x = theme_include('mod_' . $name . '.pdl');
if($x) { if($x) {
$o .= '<a href="pdledit/' . $name . '" >' . $name . '</a><br />'; $o .= '<a href="pdledit/' . $name . '" >' . $name . '</a>' . ((in_array($name,$edited)) ? ' ' . t('(modified)') . ' <a href="pdledit/' . $name . '/reset" >' . t('Reset') . '</a>': '' ) . '<br />';
} }
} }
} }
@ -69,6 +88,7 @@ class Pdledit extends \Zotlabs\Web\Controller {
'$header' => t('Edit System Page Description'), '$header' => t('Edit System Page Description'),
'$mname' => t('Module Name:'), '$mname' => t('Module Name:'),
'$help' => t('Layout Help'), '$help' => t('Layout Help'),
'$another' => t('Edit another layout'),
'$module' => argv(1), '$module' => argv(1),
'$content' => htmlspecialchars($t,ENT_COMPAT,'UTF-8'), '$content' => htmlspecialchars($t,ENT_COMPAT,'UTF-8'),
'$submit' => t('Submit') '$submit' => t('Submit')

View File

@ -5,6 +5,9 @@
<br /> <br />
<a href="help/comanche" target="hubzilla-help">{{$help}}</a> <a href="help/comanche" target="hubzilla-help">{{$help}}</a>
<br>
<br>
<a href="pdledit">{{$another}}</a>
<br /> <br />
<br /> <br />