6 find . | grep php | awk '{ print "php admin.php Core/Process/FixCode -f " $1 }' | sh
9 require_once 'Pman.php';
11 class Pman_Core_Process_FixDataObjectCtor extends Pman
13 static $cli_desc = "Coverts old code using replacements";
15 static $cli_opts = array(
17 'desc' => 'File to process',
27 $ff = HTML_FlexyFramework::get();
37 function get($p,$opts=array())
39 $file = realpath($opts['file']);
40 if (!file_exists($file) || !is_writable($file)) {
41 echo "$file: NOT readable or writable\n";
45 $c = file_get_contents($file);
47 if (strpos($c, '<?php') === false) {
48 echo "$file: NOT PHP\n";
51 $c = preg_replace("/new DataObjects_([a-z_]+)/i", "DB_DataObject::factory('\\1')", $c);
53 /// this one tends t hit a few odd comment examples..
54 //$c = preg_replace("/DataObjects_([a-z_]+)::/i", "DB_DataObject::factory('\\1')->", $c);
56 $c = preg_replace("/DB_DataObject::staticGet\(\"DataObjects_([a-z_]+)\"\s*,/i", "DB_DataObject::factory('\\1')->load(", $c);
57 $c = preg_replace("/DB_DataObject::staticGet\('DataObjects_([a-z_]+)'\s*,/i", "DB_DataObject::factory('\\1')->load(", $c);
60 $c = preg_replace("/DB_DataObject::factory\('([a-z_]+)'\)::/i", "DB_DataObject::factory('\\1')->", $c);
61 $c = preg_replace("/DB_DataObjects::factory/i", "DB_DataObject::factory", $c); // typo...
66 echo "$file: SKIP NO CHANGES\n";
69 echo "$file: WRITE NEW FILE\n";
70 file_put_contents($file,$c);