array( 'desc' => 'File to process', 'short' => 'f', 'min' => 1, 'max' => 1, ), ); function getAuth() { $ff = HTML_FlexyFramework::get(); if (!$ff->cli) { die("cli only"); } } function get($p,$opts=array()) { $file = realpath($opts['file']); if (!file_exists($file) || !is_writable($file)) { echo "$file: NOT readable or writable\n"; exit; } $c = file_get_contents($file); $old_c = $c; if (strpos($c, '", $c); $c = preg_replace("/DB_DataObject::staticGet\(\"DataObjects_([a-z_]+)\"\s*,/i", "DB_DataObject::factory('\\1')->load(", $c); $c = preg_replace("/DB_DataObject::staticGet\('DataObjects_([a-z_]+)'\s*,/i", "DB_DataObject::factory('\\1')->load(", $c); $c = preg_replace("/DB_DataObject::factory\('([a-z_]+)'\)::/i", "DB_DataObject::factory('\\1')->", $c); $c = preg_replace("/DB_DataObjects::factory/i", "DB_DataObject::factory", $c); // typo... if ($old_c == $c) { echo "$file: SKIP NO CHANGES\n"; exit; } echo "$file: WRITE NEW FILE\n"; file_put_contents($file,$c); exit; } }