function HandleM2MSaveOptions ($pagename, $auth='read') { global $M2MDir, $M2MDataDir; session_start(); $targetformat = $_SESSION['targetformat']; $options = new StylesheetOptions(); $options->readXML("$M2MDir/options/$targetformat.xml"); $options->setRequestValues($_REQUEST); $outdir = "$M2MDataDir/$pagename"; recursive_mkdir($outdir); $options->writeShortXML("$outdir/{$targetformat}opt.xml"); $options->writeStylesheet("$outdir/$targetformat.xsl", "$M2MDir/xsl/{$targetformat}.xsl"); HandleBrowse($pagename, $auth); }
function showOptionsForm ($datadir, $targetFormat, $columns, $dir, $default = false) { global $M2MDir, $M2MUrl; $formats = ConverterFactory::availableTargetFormats(); $options = new StylesheetOptions(); $useroptxml = "{$targetFormat}opt.xml"; if ($default || !file_exists("$datadir/$useroptxml") || (filemtime("$M2MDir/$useroptxml") > filemtime("$datadir/$useroptxml"))) StylesheetOptions::copyXML("$M2MDir/{$targetFormat}opt.xml", "$datadir/$useroptxml"); $options->readXML("$datadir/$useroptxml"); $categories = $options->getCategories(); ?> <script language='JavaScript'> function expand (id, val) { var catElem = document.getElementById('cat'+id); var bodyElem = document.getElementById('catbody'+id); if (catElem && bodyElem) { if (val == 'open') { catElem.className = 'open'; bodyElem.style.display = ''; } else if (val == 'close') { catElem.className = 'close'; bodyElem.style.display = 'none'; } else { catElem.className = (catElem.className == 'open' ? 'close' : 'open'); bodyElem.style.display = (bodyElem.style.display == 'none' ? '' : 'none'); } } } function expandAll (open) { var i; for (i=0; i < <?php echo count($categories); ?> ; i++) expand(i, open ? 'open' : 'close'); } </script> <table class='bgtable' cellpadding="10" width="95%" align="center"><tr><td> <form action='<?php echo $M2MUrl; ?> /options.php' method='post' enctype='multipart/form-data'> <table class='cattable' cellpadding="5" width="100%"> <tr bgcolor='#555555'> <td colspan='<?php echo $columns; ?> '> <div class='title'>Optionen für Zielformat <?php echo $formats[$targetFormat]; ?> </div> <div class='openclose'> <img src='<?php echo $M2MUrl; ?> /images/plus.gif' onClick="expandAll(true)"> <img src='<?php echo $M2MUrl; ?> /images/minus.gif' onClick="expandAll(false)"> </div> </td></tr> <? $catcount = 0; foreach ($categories as $c) { $col = 0; $optclass = 'opt1'; if ($c['title'] == 'hidden') foreach ($c['options'] as $o) echo "<input type='hidden' name='$o[name]' value='$o[value]'>\n"; else { echo "<tr class='catrow'><td colspan='$columns'>"; echo "<a id='cat$catcount' class='open' onClick='expand($catcount)'>$c[title]</a></td></tr>\n"; echo "<tbody id='catbody$catcount'>\n"; foreach ($c['options'] as $o) { if ($col == 0) echo "<tr class='$optclass'>"; echo "<td>"; echo getHtmlInputElement($o['name'], $o['type'], $o['description'], $o['value']) . "</td>\n"; if ($col++ >= $columns-1) { $col = 0; $optclass = ($optclass == 'opt1' ? 'opt2' : 'opt1'); echo "</tr>"; } } for ($col %= $columns; $col > 0; $col = ($col+1) % $columns) echo "<td class='$optclass'></td>"; $catcount++; echo "</tbody>\n"; } } ?> </table></td></tr><tr><td> <input type="hidden" name="targetformat" value="<?php echo $targetFormat; ?> "> <input type="hidden" name="datadir" value="<?php echo $datadir; ?> "> <input type="submit" name="submit" value="OK" class="button"> <input type="reset" name="submit" value="Zurücksetzen" class="button"> <input type="button" value="Abbrechen" class="button" onClick="window.close()"> </td></tr> </form></table> <? }