better handling of converters, added converters for preview

commands can also be deleted
This commit is contained in:
Uwe Steinmann 2015-06-24 21:25:53 +02:00
parent 2feeb560d1
commit 6b816f4d44
3 changed files with 76 additions and 28 deletions

View File

@ -537,6 +537,21 @@ class Settings { /* {{{ */
$this->_maxExecutionTime = ini_get("max_execution_time");
// XML Path: /configuration/system/advanced/converters
$convertergroups = $xml->xpath('/configuration/advanced/converters');
$this->_converters = array();
foreach($convertergroups as $convertergroup) {
$tabgroup = $convertergroup->attributes();
if(strval($tabgroup['target']))
$target = strval($tabgroup['target']);
else
$target = 'fulltext';
foreach($convertergroup as $converter) {
$tab = $converter->attributes();
$this->_converters[$target][trim(strval($tab['mimeType']))] = trim(strval($converter));
}
}
/*
$converters = $xml->xpath('/configuration/advanced/converters/converter');
$this->_converters = array();
foreach($converters as $converter) {
@ -546,6 +561,7 @@ class Settings { /* {{{ */
else
$this->_converters[trim(strval($tab['target']))][trim(strval($tab['mimeType']))] = trim(strval($converter));
}
*/
// XML Path: /configuration/extensions
$extensions = $xml->xpath('/configuration/extensions/extension');
@ -806,30 +822,31 @@ class Settings { /* {{{ */
$this->setXMLAttributValue($node, "updateNotifyTime", $this->_updateNotifyTime);
$this->setXMLAttributValue($node, "maxExecutionTime", $this->_maxExecutionTime);
// XML Path: /configuration/advanced/converters
foreach($this->_converters['fulltext'] as $mimeType => $cmd)
{
// search XML node
$node = $xml->xpath('/configuration/advanced/converters/converter[@mimeType="'. $mimeType .'"]');
// XML Path: /configuration/advanced/converters
foreach($this->_converters as $type=>$converters) {
foreach($this->_converters[$type] as $mimeType => $cmd) {
// search XML node
$node = $xml->xpath('/configuration/advanced/converters[@target="'.$type.'"]/converter[@mimeType="'. $mimeType .'"]');
if (isset($node))
{
if (count($node)>0)
{
$node = $node[0];
}
else
{
$nodeParent = $xml->xpath('/configuration/advanced/converters');
$node = $nodeParent[0]->addChild("converter");
}
$node[0] = $cmd;
$this->setXMLAttributValue($node, 'mimeType', $mimeType);
} // isset($node)
} // foreach
if (count($node)>0) {
if(trim($cmd)) {
$node = $node[0];
$node[0] = $cmd;
$this->setXMLAttributValue($node, 'mimeType', $mimeType);
} else {
$node = $node[0];
unset($node[0]);
}
} else {
if(trim($cmd)) {
$nodeParent = $xml->xpath('/configuration/advanced/converters[@target="'.$type.'"]');
$node = $nodeParent[0]->addChild("converter");
$node[0] = $cmd;
$this->setXMLAttributValue($node, 'mimeType', $mimeType);
}
}
} // foreach
} // foreach
// XML Path: /configuration/extensions

View File

@ -173,8 +173,24 @@ if ($action == "saveSettings")
$settings->_updateNotifyTime = intval($_POST["updateNotifyTime"]);
$settings->_maxExecutionTime = intval($_POST["maxExecutionTime"]);
// SETTINGS - ADVANCED - INDEX CMD
$settings->_converters['fulltext'] = $_POST["converters"];
// SETTINGS - ADVANCED - INDEX CMD
if(isset($_POST["converters"]["fulltext"]))
$settings->_converters['fulltext'] = $_POST["converters"]["fulltext"];
else
$settings->_converters['fulltext'] = $_POST["converters"];
if(trim($settings->_converters['fulltext']['newmimetype']) &&
trim($settings->_converters['fulltext']['newcmd']))
$settings->_converters['fulltext'][$settings->_converters['fulltext']['newmimetype']] = trim($settings->_converters['fulltext']['newcmd']);
unset($settings->_converters['fulltext']['newmimetype']);
unset($settings->_converters['fulltext']['newcmd']);
if(isset($_POST["converters"]["preview"]))
$settings->_converters['preview'] = $_POST["converters"]["preview"];
if(trim($settings->_converters['preview']['newmimetype']) &&
trim($settings->_converters['preview']['newcmd']))
$settings->_converters['preview'][$settings->_converters['preview']['newmimetype']] = trim($settings->_converters['preview']['newcmd']);
unset($settings->_converters['preview']['newmimetype']);
unset($settings->_converters['preview']['newcmd']);
// SETTINGS - EXTENSIONS
$settings->_extensions = $_POST["extensions"];

View File

@ -606,14 +606,29 @@ if(!is_writeable($settings->_configFilePath)) {
?>
<tr title="<?php echo $mimetype;?>">
<td><?php echo $mimetype;?>:</td>
<td><input type="text" name="converters[<?php echo $mimetype;?>]" value="<?php echo htmlspecialchars($cmd) ?>" size="100" /></td>
<td><input type="text" name="converters[fulltext][<?php echo $mimetype;?>]" value="<?php echo htmlspecialchars($cmd) ?>" size="100" /></td>
</tr>
<?php
}
?>
<tr title="">
<td><input type="text" name="converters_newmimetype" value="" />:</td>
<td><input type="text" name="converters_newcmd" value="" /></td>
<td><input type="text" name="converters[fulltext][newmimetype]" value="" placeholder="<?= getMLText('converter_new_mimetype') ?>"/>:</td>
<td><input type="text" name="converters[fulltext][newcmd]" value="" placeholder="<?= getMLText('converter_new_cmd') ?>"/></td>
</tr>
<tr ><td><b> <?php printMLText("preview_converters");?></b></td> </tr>
<?php
foreach($settings->_converters['preview'] as $mimetype=>$cmd) {
?>
<tr title="<?php echo $mimetype;?>">
<td><?php echo $mimetype;?>:</td>
<td><input type="text" name="converters[preview][<?php echo $mimetype;?>]" value="<?php echo htmlspecialchars($cmd) ?>" size="100" /></td>
</tr>
<?php
}
?>
<tr title="">
<td><input type="text" name="converters[preview][newmimetype]" value="" placeholder="<?= getMLText('converter_new_mimetype') ?>"/>:</td>
<td><input type="text" name="converters[preview][newcmd]" value="" placeholder="<?= getMLText('converter_new_cmd') ?>"/></td>
</tr>
</table>
<?php $this->contentContainerEnd(); ?>