output = '';
if (!checkSecurityToken()) return;
if (!is_array($_REQUEST['cmd'])) return;
// echo '
' . print_r($_REQUEST, 1) . '
';
global $INPUT;
$ini = $INPUT->str('ini_file','none');
$tpl = $INPUT->str('tpl_file','none');
$nosave = $INPUT->str('nosave','none');
$userepl = $INPUT->str('userrelpl','none');
$tplns = $this->getConf('default_tplns');
$user = $INPUT->server->str('REMOTE_USER', 'none');
$this->help = false;
switch (key($_REQUEST['cmd'])) {
case 'submit' :
$this->output = 'submit';
if(!empty($_REQUEST['id'])) {
if($tpl == 'none') {
$this->output = "The -p (--page) option requires a template";
return;
}
$cmdL = '-p ' .$_REQUEST['id'] . " -t $tplns:$tpl";
if($userepl != 'none') {
$cmdL .= " -u \"$userepl\" ";
}
$cmdL .= " -s admin ";
if($nosave == 'on') {
$cmdL .= " -n true ";
}
if($user != 'none') {
$cmdL .= " -c $user ";
}
$this->output = shell_exec(NEWPAGETPL_CMDL . $cmdL) ;
$this->help = true;
}
else if($ini != 'none') {
$cmdL = " -i $ini";
if($userepl != 'none') {
$cmdL .= " -u \"$userepl\" ";
}
$cmdL .= " -s admin ";
if($nosave != 'none') {
$cmdL .= " -n $nosave ";
}
if($user != 'none') {
$cmdL .= " -c $user ";
}
$this->output = shell_exec(NEWPAGETPL_CMDL . $cmdL) ;
$this->help = true;
}
$this->output = preg_replace("/\n+/","
", $this->output);
break;
case 'help':
$this->help = true;
$this->output = shell_exec(NEWPAGETPL_CMDL .'-h') ;
$this->output = preg_replace("/\n\n/","
", htmlentities($this->output));
$this->output = preg_replace("/(-\w\,\s+--\w+)/","$1",$this->output);
$this->output = preg_replace("/browser]]/","browser]]",$this->output);
$this->output = preg_replace("/OPTIONS:/","OPTIONS:
",$this->output);
$this->output = preg_replace("/https:\/\/www.dokuwiki.org\/plugin:newpagetemplate/",
"" .
'https://www.dokuwiki.org/plugin:newpagetemplate',$this->output);
break;
}
}
/**
* output appropriate html
*/
function html()
{
ptln('' );
ptln(' ' . $this->locale_xhtml('howto'));
ptln('
');
ptln('');
if($this->help) {
$display = "block";
}
else $display = "none";
ptln('
' . $this->output);
ptln(' ');
ptln('
');
}
function ini_files()
{
$lib = DOKU_INC . 'lib/plugins/newpagetemplate/';
$files = scandir($lib);
$opt_str = "";
foreach ($files as $file) {
if (preg_match("/\.ini$/", $file)) {
$opt_str .= "";
}
}
return ($opt_str);
}
function templates() {
$tplns = $this->getConf('default_tplns');
$pages = DOKU_INC . 'data/pages/' . $tplns;
$files = scandir($pages);
$opt_str = "";
foreach ($files as $file) {
if (preg_match("/\.txt$/", $file)) {
list($id,$ext) = explode('.',$file);
$opt_str .= "";
}
}
return ($opt_str);
}
}