#!/usr/bin/env php * @copyright 2020 by Ralf Becker */ if (PHP_SAPI !== 'cli') // security precaution: forbit calling as web-page { die('

fix_api.php must NOT be called as web-page --> exiting !!!

'); } // raw replacements $replace = array( '/^app.classes.([a-z0-9_]+)(\s*=\s*AppJS.extend)\(.*^}\);/misU' => function($matches) { return strtr($matches[0], [ 'app.classes.'.$matches[1].$matches[2].'(' => 'class '.ucfirst($matches[1]).'App extends EgwApp', "\n});" => "\n}\n\napp.classes.$matches[1] = ".ucfirst($matches[1])."App;" ]); }, "/^\tappname:\s*'([^']+)',/m" => "\treadonly appname = '$1';", "/^\t([^: ,;(\t]+?):\s*([^()]+?),/m" => "\t\$1 : any = $2;", "/^\t([^:\n]+):\s*function\s*\(.*this._super.(apply|call)\(/msU" => function($matches) { return str_replace('this._super', $matches[1] === 'init' ? 'super' : 'super.'.$matches[1], $matches[0]); }, "/^\t([^:\n]+):\s*function\s*\(/m" => function($matches) { return "\t".($matches[1] === 'init' ? 'constructor' : $matches[1]).'('; }, // TS does not like to call parent constructor with super.apply(this, arguments) and we dont have arguments ... '/\tsuper.apply\(this, *arguments\)/' => "\tsuper()", "/^\t},$/m" => "\t}", '/^ \* @version \$Id[^$]*\$\n/m' => '', '#^ \* @link http://www.egroupware.org#m' => ' * @link: https://www.egroupware.org', ); /** * Add boilerplate for app.js files after header * * @param $app * @param $content * @return string */ function app_js_add($app, $content) { return preg_replace('#^(/\*\*.*\n\ \*/)#Us', <<