Does anyone have the skeleton of an Evo-to-Revo porting utility they could share? I’ve read the substitutions on Bob’s guides and came up with what is below. The idea is that if Revo were installed alongside an existing Evo site, then one could hit the Evo database directly and output "new" code. This example (not well written or taking advantage of anything built into Revo) is a stab at that for chunks, though the output would still need to have slashes removed.
Are there other substitutions that I’d need to be aware of?
Matt
<?php
$dbhost = 'localhost';
$dbuser = 'YOUR_USERNAME';
$dbpass = 'YOUR_PASSWORD';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'YOUR_EVO_DATABASE_NAME';
mysql_select_db($dbname);
$result = mysql_query("SELECT * FROM modx_site_htmlsnippets"); //change this to modx_site_snippets
//for snippets
$targets = array(
"[*",
"[+",
"[~",
"[(",
"[!",
"{{",
"*]",
"}}",
"+]",
"~]",
")]",
"!]");
$substitutions = array(
"[[*",
"[[+",
"[[~",
"[[++",
"[[!",
"[[$",
"]]",
"]]",
"]]",
"]]",
"]]",
"]]");
while($row = mysql_fetch_array($result))
{
$text = ($row[snippet]);
$processed = false;
echo $row[name] . "<br />";
foreach($targets as $key => $value)
{
$tgtstr = ($value);
$substr = quotemeta($substitutions[$key]);
$tgtcnt = substr_count($text, $tgtstr);
$pos = strpos($text, $tgtstr);
if ($pos !== false)
{
$processed = true;
echo " target " . $tgtstr . " found. Count = $tgtcnt.<br/>";
for($i=0;$i<=($tgtcnt-1);$i++)
{
$text = str_ireplace($tgtstr,$substr,$text);
}
}
}
if ($processed)
{
echo "<pre>" . htmlentities($text) ."</pre><br/>";
}
else
{
echo "--> No target changes found.<br/>";
}
}
mysql_close($conn);
?>
EDIT : got rid of the Jurassic-era XMP tag ...