All you have to do is drop this file into some place in your webroot, in the same folder put the new MODX 1.2.0 XSL file (get it from here). Then create a subfolder called "files", you can have your mods in any way you wish, so it can be any of these:
Code: Select all
./files/install.xml
./files/mymod/install.xml
./files/mymod/contrib/addons/some_addon/install.xml
Code: Select all
<?php
// recursive func to get the all files with a specific extension
function get_files($root, $dir = '', $extension = false)
{
$return = array();
if ($files = scandir($root . $dir))
{
foreach ($files as $file)
{
if ($file === '.' || $file === '..' || $file === '.svn')
{
continue;
}
if (is_file($root . $dir . $file) && ($extension && substr(strrchr($file, '.'), 1) === $extension || !$extension))
{
$return[] = $dir . $file;
}
else if (is_dir($root . $dir . $file . '/'))
{
$return = array_merge($return, get_files($root, $dir . $file . '/', $extension));
}
}
}
return $return;
}
// config
$root_dir = './files/';
$xsl_file = './modx.prosilver.en.xsl';
$phpbb_version = '3.0.1';
// adjust install.xml
foreach (get_files('', $root_dir, 'xml') as $file)
{
$xml_contents = file_get_contents($file);
$xml_contents = preg_replace('#modx-1\.0(\.1|)\.xsd#', 'modx-1.2.0.xsd', $xml_contents);
$xml_contents = preg_replace('#<mod-version>(.*)<major>(.*)</major>(.*)<minor>(.*)</minor>(.*)<revision>(.*)</revision>(.*)</mod-version>#s', '<mod-version>\\2.\\4.\\6</mod-version>', $xml_contents);
$xml_contents = preg_replace('#<target-version>(.*)</target-version>#s', "<target-version>$phpbb_version</target-version>", $xml_contents);
$xml_contents = preg_replace('#<rev-version>(.*)<major>(.*)</major>(.*)<minor>(.*)</minor>(.*)<revision>(.*)</revision>(.*)</rev-version>#s', '<rev-version>\\2.\\4.\\6</rev-version>', $xml_contents);
file_put_contents($file, $xml_contents);
}
// replace xsl
foreach (get_files('', $root_dir, 'xsl') as $file)
{
if (basename($file) === basename($xsl_file))
{
file_put_contents($file, file_get_contents($xsl_file));
}
}
?>