- March 17, 2008
- 1,353
- 306
- Home Country
-
Netherlands
Hi all,
Because I kinda got crazy of the XML files within MP being so incredibly awfully indented from time to time I wrote a little script to make me my life easier.
It's written in PHP and therefore will only run on machines that have a PHP installation. To get a quick and dirty install of php, apache and mysql you can try out WAMP for example. WAMP installs mysql so be sure you're not installing WAMP on a machine already equipped with MySQL, might cause a little havoc (haven't tried it though)
All you need to configure is the variable $root. The 6th line of the script should be left alone (maybe not if you install MP outside of programfiles) and should be working cross platform. The 8th line you want to change pointing to your skin you want to tidy up.
In the 3th line of the script you can set all folders / files to be excluded.
Enjoy!
Because I kinda got crazy of the XML files within MP being so incredibly awfully indented from time to time I wrote a little script to make me my life easier.
PHP:
<?php
//The files and folders to exclude, leave '.' and '..' in there or you're asking for trouble
$excluded = array('.', '..', '.svn', 'GFX Fixes', 'Media', 'Sounds');
//ask windows for program files path
$root = trim(shell_exec("echo %programfiles%"));
//Set the root to Mediaportal skin folder you want to tidy
$root .= "\Mediaportal\skin\Blue3++";
//Loop through all files and tidy them, write them back to appropriate file
if ($handle = opendir($root)) {
while (false !== ($file = readdir($handle))) {
if (!in_array($file, $excluded)) {
$content = file_get_contents($root . "\\" . $file);
$content = cleanUpXml($content);
file_put_contents($root . "\\" . $file, $content);
}
}
closedir($handle);
}
//Actual tidy function
function cleanUpXml($xmlstr)
{
$tidy = tidy_parse_string($xmlstr, array(
'input-xml' => true,
'output-xml' => true,
'output-encoding' => 'latin1',
'indent' => true,
'wrap' => 0,
'indent-spaces' => 4,
));
$tidy->cleanRepair();
return $tidy->value;
}
?>
It's written in PHP and therefore will only run on machines that have a PHP installation. To get a quick and dirty install of php, apache and mysql you can try out WAMP for example. WAMP installs mysql so be sure you're not installing WAMP on a machine already equipped with MySQL, might cause a little havoc (haven't tried it though)
All you need to configure is the variable $root. The 6th line of the script should be left alone (maybe not if you install MP outside of programfiles) and should be working cross platform. The 8th line you want to change pointing to your skin you want to tidy up.
In the 3th line of the script you can set all folders / files to be excluded.
Enjoy!