예제 #1
0
 public static function handleRequest()
 {
     $GLOBALS['Session']->requireAccountLevel('Developer');
     \Emergence_FS::cacheTree('site-root/site-admin');
     return static::respond('siteAdminIndex', array('scripts' => array_filter(\Emergence_FS::getAggregateChildren('site-root/site-admin'), function ($script) {
         return $script->Handle != '_index.php';
     })));
 }
예제 #2
0
<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    Site::$autoPull = true;
    Site::$debug = true;
    set_time_limit(0);
    $trees = array('dwoo-plugins', 'event-handlers', 'ext-library', 'html-templates', 'js-library', 'php-classes', 'php-config', 'phpunit-tests', 'php-migrations', 'site-root', 'sencha-workspace/.sencha', 'sencha-workspace/microloaders', 'sencha-workspace/pages', 'sencha-workspace/packages', 'sencha-workspace/EmergenceEditor', 'sencha-workspace/EmergencePullTool', 'sencha-workspace/ContentEditor');
    $message = "";
    foreach ($_POST['collections'] as $collection) {
        $filesCached = Emergence_FS::cacheTree($collection, true);
        $message .= sprintf('Precached %03u files in %s' . PHP_EOL, $filesCached, $collection);
    }
}
RequestHandler::respond('precache', array('message' => $message));
예제 #3
0
    } elseif (!$treeOptions['path']) {
        $treeOptions['path'] = $srcPath;
    }
    $treeOptions['exclude'][] = '#(^|/)\\.git(/|$)#';
    if (is_file($treeOptions['path'])) {
        $sha1 = sha1_file($treeOptions['path']);
        $existingNode = Site::resolvePath($srcPath);
        if (!$existingNode || $existingNode->SHA1 != $sha1) {
            $fileRecord = SiteFile::createFromPath($srcPath, null, $existingNode ? $existingNode->ID : null);
            SiteFile::saveRecordData($fileRecord, fopen($treeOptions['path'], 'r'), $sha1);
            Benchmark::mark("importing file {$srcPath} from {$treeOptions['path']}");
        } else {
            Benchmark::mark("skipped unchanged file {$srcPath} from {$treeOptions['path']}");
        }
    } else {
        $cachedFiles = Emergence_FS::cacheTree($srcPath);
        Benchmark::mark("precached {$srcPath}: " . $cachedFiles);
        $exportResult = Emergence_FS::importTree($treeOptions['path'], $srcPath, $treeOptions);
        Benchmark::mark("importing directory {$srcPath} from {$treeOptions['path']}: " . http_build_query($exportResult));
    }
}
// commit changes
#$repo->git('add --all');
#
#$repo->git(sprintf(
#	'commit -n -m "%s" --author="%s <%s>"'
#	,addslashes($_POST['message'])
#	,$GLOBALS['Session']->Person->FullName
#	,$GLOBALS['Session']->Person->Email
#));
#Benchmark::mark("committed all changes");
예제 #4
0
// ... framework
$cachedFiles = Emergence_FS::cacheTree($frameworkPath);
Benchmark::mark("precached {$frameworkPath}");
$exportResult = Emergence_FS::exportTree($frameworkPath, $frameworkTmpPath);
Benchmark::mark("exported {$frameworkPath} to {$frameworkTmpPath}: " . http_build_query($exportResult));
// ... app
$cachedFiles = Emergence_FS::cacheTree($appPath);
Benchmark::mark("precached {$appPath}");
$exportResult = Emergence_FS::exportTree($appPath, $appTmpPath);
Benchmark::mark("exported {$appPath} to {$appTmpPath}: " . http_build_query($exportResult));
// write any libraries from classpath
$classPaths = explode(',', $App->getBuildCfg('app.classpath'));
foreach ($classPaths as $classPath) {
    if (substr($classPath, 0, 2) == 'x/') {
        $classPathSource = 'ext-library' . substr($classPath, 1);
        $cachedFiles = Emergence_FS::cacheTree($classPathSource);
        Benchmark::mark("precached {$cachedFiles} files from {$classPathSource}");
        $exportResult = Emergence_FS::exportTree($classPathSource, "{$appTmpPath}/{$classPath}");
        Benchmark::mark("exported {$classPathSource} to {$appTmpPath}/{$classPath}: " . http_build_query($exportResult));
    }
}
// change into app's directory
chdir($appTmpPath);
Benchmark::mark("chdir to: {$appTmpPath}");
// prepare and run upgrade command
$upgradeCmd = Sencha::buildCmd($cmdVersion, 'app upgrade --noframework');
Benchmark::mark("running upgrade CMD: {$upgradeCmd}");
passthru($upgradeCmd, $upgradeCmdStatus);
Benchmark::mark("Upgrade CMD finished: exitCode={$upgradeCmdStatus}");
// import results
Benchmark::mark("importing {$appTmpPath}");
예제 #5
0
$buildTmpPath = "{$tmpPath}/build/{$appName}/production";
Benchmark::mark("created tmp: {$tmpPath}");
// precache and write workspace config
$cachedFiles = Emergence_FS::cacheTree($workspaceConfigPath);
Benchmark::mark("precached {$cachedFiles} files in {$workspaceConfigPath}");
$exportResult = Emergence_FS::exportTree($workspaceConfigPath, $workspaceConfigTmpPath);
Benchmark::mark("exported {$workspaceConfigPath} to {$workspaceConfigTmpPath}: " . http_build_query($exportResult));
// ... packages
if (!($requiredPackages = $App->getAppCfg('requires')) || !is_array($requiredPackages)) {
    $requiredPackages = array();
}
if (($themeName = $App->getBuildCfg('app.theme')) && !in_array($themeName, $requiredPackages)) {
    $requiredPackages[] = $themeName;
}
foreach ($requiredPackages as $packageName) {
    $cachedFiles = Emergence_FS::cacheTree("{$packagesPath}/{$packageName}");
    Benchmark::mark("precached {$cachedFiles} files in {$packagesPath}/{$packageName}");
    $exportResult = Emergence_FS::exportTree("{$packagesPath}/{$packageName}", "{$packagesTmpPath}/{$packageName}");
    Benchmark::mark("exported {$packagesPath} to {$packagesTmpPath}/{$packageName}: " . http_build_query($exportResult));
}
// ... framework
$exportResult = Emergence_FS::exportTree($frameworkPath, $frameworkTmpPath);
Benchmark::mark("exported {$frameworkPath} to {$frameworkTmpPath}: " . http_build_query($exportResult));
// ... app
$exportResult = Emergence_FS::exportTree($appPath, $appTmpPath);
Benchmark::mark("exported {$appPath} to {$appTmpPath}: " . http_build_query($exportResult));
// ... last production build
mkdir($buildTmpPath, 0777, true);
$exportResult = Emergence_FS::exportTree($buildPath, $buildTmpPath);
Benchmark::mark("exported {$buildPath} to {$buildTmpPath}: " . http_build_query($exportResult));
// write any libraries from classpath
 public static function getSourceNodes($paths, $root, $contentType = null)
 {
     $paths = static::splitMultipath($paths);
     if (is_string($root)) {
         $root = Site::splitPath($root);
     }
     $sourceFiles = array();
     foreach ($paths as $path) {
         $path = array_merge($root, $path);
         list($filename) = array_slice($path, -1);
         if ($filename == '*') {
             array_pop($path);
             Emergence_FS::cacheTree($path);
             foreach (Emergence_FS::getTreeFiles($path, false, $contentType ? array('Type' => $contentType) : null) as $path => $fileData) {
                 $sourceFiles[$path] = $fileData;
             }
         } else {
             $node = Site::resolvePath($path);
             if (!$node || !is_a($node, 'SiteFile')) {
                 throw new Exception('Source file "' . implode('/', $path) . '" does not exist', self::ERROR_NOT_FOUND);
             }
             if ($node->Type != $contentType) {
                 throw new Exception('Source file "' . implode('/', $path) . '" does not match requested content type "' . $contentType . '"', self::ERROR_TYPE_MISMATCH);
             }
             $sourceFiles[join('/', $path)] = array('ID' => $node->ID, 'SHA1' => $node->SHA1);
         }
     }
     return $sourceFiles;
 }
$GLOBALS['Session']->requireAccountLevel('Developer');
set_time_limit(0);
Benchmark::startLive();
// get framework
if (empty($_REQUEST['framework'])) {
    die('Parameter framework required');
}
$framework = $_REQUEST['framework'];
Benchmark::mark("configured request: framework={$framework}");
// get temporary directory
$tmpPath = Emergence_FS::getTmpDir();
Benchmark::mark("created tmp: {$tmpPath}");
// write workspace
$workspacePath = 'sencha-workspace';
Benchmark::mark("precaching workspace: {$workspacePath}");
$cachedFiles = Emergence_FS::cacheTree($workspacePath);
Benchmark::mark("precaching finished: {$cachedFiles} files loaded/updated");
Benchmark::mark("exporting workspace: {$workspacePath} to {$tmpPath}");
$exportResult = Emergence_FS::exportTree($workspacePath, $tmpPath);
Benchmark::mark("exported finished: " . http_build_query($exportResult));
// begin cmd
set_time_limit(0);
$cmd = Sencha::buildCmd($framework, 'generate workspace', $tmpPath);
Benchmark::mark("running CMD: {$cmd}");
passthru($cmd, $cmdStatus);
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
// import app
if ($cmdStatus == 0) {
    $destPath = 'sencha-workspace';
    Benchmark::mark("importing to: {$destPath}");
    $filesImported = Emergence_FS::importTree($tmpPath, $destPath);
예제 #8
0
<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
?>
<html>
    <body>
    <?php 
if (empty($_GET['suite'])) {
    ?>
        <h1>Available PHPUnit Test Suites</h1>
        <ul>
        <?php 
    Emergence_FS::cacheTree('phpunit-tests');
    foreach (Emergence_FS::getAggregateChildren('phpunit-tests') as $testsSubNode) {
        if (!is_a($testsSubNode, 'SiteCollection')) {
            continue;
        }
        print "<li><a href='?suite={$testsSubNode->Handle}'>{$testsSubNode->Handle}</a> <form action='/phpunit/run?suite={$testsSubNode->Handle}' method='POST' style='display:inline'><input type='submit' value='Run All Tests'></form></li>";
    }
    ?>
        </ul>
    <?php 
} elseif (count($testNodes = Emergence_FS::getAggregateChildren("phpunit-tests/{$_GET['suite']}"))) {
    ?>
        <h1>Tests in suite <?php 
    echo htmlspecialchars($_GET['suite']);
    ?>
</h1>
        <form action="/phpunit/run?suite=<?php 
    echo urlencode($_GET['suite']);
    ?>
예제 #9
0
 public static function loadConfig($className)
 {
     $cacheKey = 'class-config:' . $className;
     if (!($configFileIds = Cache::fetch($cacheKey))) {
         $configFileIds = array();
         // look for primary config file
         if ($lastNsPos = strrpos($className, '\\')) {
             $namespace = substr($className, 0, $lastNsPos);
             $className = substr($className, $lastNsPos + 1);
             $path = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
         } else {
             $path = '';
         }
         $path .= str_replace('_', DIRECTORY_SEPARATOR, $className);
         $configFileNode = Site::resolvePath("php-config/{$path}.config.php");
         // Fall back on looking for Old_School_Underscore_Namespacing in root
         if (!$configFileNode && empty($namespace) && $path != $className) {
             $configFileNode = Site::resolvePath("php-config/{$className}.config.php");
         }
         if ($configFileNode && $configFileNode->MIMEType == 'application/php') {
             $configFileIds[] = $configFileNode->ID;
         }
         // look for composite config files
         $collectionPath = "php-config/{$path}.config.d";
         Emergence_FS::cacheTree($collectionPath);
         foreach (Emergence_FS::getAggregateChildren($collectionPath) as $filename => $node) {
             if ($node->Type == 'application/php') {
                 $configFileIds[] = $node->ID;
             }
         }
         Cache::store($cacheKey, $configFileIds);
     }
     foreach ($configFileIds as $id) {
         require SiteFile::getRealPathByID($id);
     }
 }
예제 #10
0
<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
set_time_limit(0);
Benchmark::startLive();
if (!($framework = $_GET['framework'])) {
    die('parameter "framework" missing');
}
if (!($frameworkVersion = $_GET['version'])) {
    die('parameter "version" missing');
}
$cachedFiles = Emergence_FS::cacheTree("sencha-workspace/{$framework}-{$frameworkVersion}");
Benchmark::mark("precached {$cachedFiles} files in sencha-workspace/{$framework}-{$frameworkVersion}");
<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
set_time_limit(0);
Benchmark::startLive();
foreach (Sencha::$frameworks as $framework => $frameworkConfig) {
    $cachedFiles = Emergence_FS::cacheTree("sencha-workspace/{$framework}-{$frameworkConfig['defaultVersion']}");
    Benchmark::mark("precached sencha-workspace/{$framework}-{$frameworkConfig['defaultVersion']}");
}
// precache workspace config
$cachedFiles = Emergence_FS::cacheTree('sencha-workspace/.sencha');
Benchmark::mark("precached sencha-workspace/.sencha");
예제 #12
0
<?php

$GLOBALS['Session']->requireAccountLevel('Developer');
set_time_limit(0);
Benchmark::startLive();
// precache workspace config
$cachedFiles = Emergence_FS::cacheTree('sencha-workspace/.sencha');
Benchmark::mark("precached sencha-workspace/.sencha");
// precache workspace packages
$cachedFiles = Emergence_FS::cacheTree('sencha-workspace/packages');
Benchmark::mark("precached sencha-workspace/packages");
// precache workspace microloaders
$cachedFiles = Emergence_FS::cacheTree('sencha-workspace/microloaders');
Benchmark::mark("precached sencha-workspace/microloaders");
예제 #13
0
$fontsPath = "{$rootPath}/fonts";
// get temporary directory and set paths
$tmpPath = Emergence_FS::getTmpDir();
$sassTmpPath = "{$tmpPath}/sass";
$imgTmpPath = "{$tmpPath}/img";
$fontsTmpPath = "{$tmpPath}/fonts";
$cssTmpPath = "{$tmpPath}/css";
Benchmark::mark("created tmp: {$tmpPath}");
// grab resources to work with
Emergence_FS::cacheTree($sassPath);
$exportResult = Emergence_FS::exportTree($sassPath, $sassTmpPath);
Benchmark::mark("exported {$sassPath} to {$sassTmpPath}: " . http_build_query($exportResult));
Emergence_FS::cacheTree($imgPath);
$exportResult = Emergence_FS::exportTree($imgPath, $imgTmpPath);
Benchmark::mark("exported {$imgPath} to {$imgTmpPath}: " . http_build_query($exportResult));
Emergence_FS::cacheTree($fontsPath);
$exportResult = Emergence_FS::exportTree($fontsPath, $fontsTmpPath);
Benchmark::mark("exported {$fontsPath} to {$fontsTmpPath}: " . http_build_query($exportResult));
// begin cmd
chdir($sassTmpPath);
Benchmark::mark("chdir to: {$sassTmpPath}");
$cmd = 'compass compile 2>&1';
Benchmark::mark("running CMD: {$cmd}");
passthru($cmd, $cmdStatus);
Benchmark::mark("CMD finished: exitCode={$cmdStatus}");
// import build
if ($cmdStatus == 0) {
    Benchmark::mark("importing {$cssTmpPath}");
    $importResults = Emergence_FS::importTree($cssTmpPath, "site-root/css", array('transferDelete' => false));
    Benchmark::mark("imported files: " . http_build_query($importResults));
}
예제 #14
0
Benchmark::startLive();
// get requested test suite
$testSuite = empty($_GET['suite']) ? 'emergence.read-only' : $_GET['suite'];
// set paths
$testsPath = "phpunit-tests";
$suitePath = "{$testsPath}/{$testSuite}";
if (!Site::resolvePath($suitePath)) {
    die('Requested test suite not found');
}
// get temporary directory and set paths
$tmpPath = Emergence_FS::getTmpDir();
$suiteTmpPath = "{$tmpPath}/{$testSuite}";
$configTmpPath = "{$tmpPath}/phpunit.xml";
Benchmark::mark("created tmp: {$tmpPath}");
// export tests
Emergence_FS::cacheTree($suitePath);
$exportResult = Emergence_FS::exportTree($suitePath, $suiteTmpPath);
Benchmark::mark("exported {$suitePath} to {$suiteTmpPath}: " . http_build_query($exportResult));
// write phpunit configuration
$timezone = date_default_timezone_get();
// bootstrap path
$bootstrapPath = dirname($_SERVER['SCRIPT_FILENAME']) . '/phpunit.php';
file_put_contents($configTmpPath, <<<EOT
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="{$bootstrapPath}"
         convertErrorsToExceptions="false"
         convertNoticesToExceptions="false"
         convertWarningsToExceptions="false"
         stopOnError="false">
    <php>
        <ini name="date.timezone" value="{$timezone}" />
예제 #15
0
function Dwoo_Plugin_sencha_bootstrap(Dwoo_Core $dwoo, $App = null, $classPaths = array(), $packages = array(), $patchLoader = true, $framework = 'ext', $frameworkVersion = null, $packageRequirers = null)
{
    // retrieve app if available
    if (!$App) {
        $App = $dwoo->data['App'];
    }
    // load workspace classpaths
    $classPaths = array_merge($classPaths, explode(',', Sencha::getWorkspaceCfg('workspace.classpath')));
    // if app provided, load classpaths and packages
    if ($App) {
        $framework = $App->getFramework();
        $frameworkVersion = $App->getFrameworkVersion();
        $appPath = 'sencha-workspace/' . $App->getName();
        // recursively merge app's required packages and their required packages into packages list
        $packages = array_merge($packages, $App->getRequiredPackages(false));
        // false to skip crawling decendents, we'll do it here later
        // add theme to packages list
        if ($themeName = $App->getBuildCfg('app.theme')) {
            $packages[] = $themeName;
        }
        // include classpath files
        $classPaths = array_merge($classPaths, explode(',', $App->getBuildCfg('app.classpath')));
        // include override files
        if ($overridesPath = $App->getBuildCfg('app.overrides')) {
            $classPaths = array_merge($classPaths, explode(',', $overridesPath));
        }
    }
    // pull package requirements from source files
    if (!empty($packageRequirers)) {
        if (is_string($packageRequirers)) {
            $packageRequirers = array($packageRequirers);
        }
        foreach ($packageRequirers as $packageRequirer) {
            if ($sourceNode = Site::resolvePath($packageRequirer)) {
                $packages = array_merge($packages, Sencha::getRequiredPackagesForSourceFile($sourceNode->RealPath));
            }
        }
    }
    // apply default framework version and normalize
    if (!$frameworkVersion) {
        $frameworkVersion = Sencha::$frameworks[$framework]['defaultVersion'];
    }
    $frameworkVersion = Sencha::normalizeFrameworkVersion($framework, $frameworkVersion);
    $frameworkPath = "sencha-workspace/{$framework}-{$frameworkVersion}";
    // initialize output state
    $manifest = array();
    $autoLoadPaths = array();
    // set framework path if patching loader
    if ($patchLoader) {
        $manifest['Ext'] = "/app/{$framework}-{$frameworkVersion}/src";
    }
    // add paths for packages
    $packages = array_unique(Sencha::crawlRequiredPackages(array_unique($packages), $framework, $frameworkVersion));
    foreach ($packages as $packageName) {
        // check workspace and framework package dirs
        $packagePath = "sencha-workspace/packages/{$packageName}";
        if (!Site::resolvePath($packagePath)) {
            $packagePath = "{$frameworkPath}/packages/{$packageName}";
            if (!Site::resolvePath($packagePath)) {
                throw new Exception("Source for package {$packageName} not found in workspace or framework");
            }
        }
        array_push($classPaths, "{$packagePath}/src", "{$packagePath}/overrides");
    }
    // include classpaths from packages
    $classPaths = array_merge($classPaths, Sencha::aggregateClassPathsForPackages($packages));
    // filter classpaths
    $classPaths = array_unique(array_filter($classPaths));
    // build list of all source trees, resolving CMD variables and children
    $sources = array();
    foreach ($classPaths as $classPath) {
        if (strpos($classPath, '${workspace.dir}/x/') === 0) {
            $classPath = substr($classPath, 19);
            $manifest[str_replace('/', '.', $classPath)] = '/app/x/' . $classPath;
            $classPath = 'ext-library/' . $classPath;
        } elseif (strpos($classPath, 'ext-library/') === 0) {
            $classPath = substr($classPath, 12);
            $manifest[str_replace('/', '.', $classPath)] = '/app/x/' . $classPath;
            $classPath = 'ext-library/' . $classPath;
        } elseif (strpos($classPath, '${app.dir}/') === 0) {
            $classPath = $appPath . substr($classPath, 10);
        } elseif (strpos($classPath, '${ext.dir}/') === 0) {
            $classPath = $frameworkPath . substr($classPath, 10);
        } elseif (strpos($classPath, '${touch.dir}/') === 0) {
            $classPath = $frameworkPath . substr($classPath, 12);
        }
        Emergence_FS::cacheTree($classPath);
        $sources = array_merge($sources, Emergence_FS::getTreeFiles($classPath, false, array('Type' => 'application/javascript')));
    }
    // skip patching loader if manifest will be empty
    if (empty($sources)) {
        return '';
    }
    // process all source files and build manifest and list of classes to automatically load
    foreach ($sources as $path => &$source) {
        $autoLoad = false;
        $addToManifest = true;
        // rewrite path to canonican external URL
        if ($appPath && strpos($path, "{$appPath}/") === 0) {
            $webPath = '/app/' . substr($path, 17);
            // app overrides should automatically be loaded
            if (substr($path, strlen($appPath), 11) == '/overrides/') {
                $autoLoad = true;
                $addToManifest = false;
            }
        } elseif (strpos($path, 'ext-library/') === 0) {
            $webPath = '/app/x' . substr($path, 11);
        } elseif (strpos($path, 'sencha-workspace/packages/') === 0) {
            $webPath = '/app/' . substr($path, 17);
            // package overrides should automatically be loaded
            if (substr($path, strpos($path, '/', 26), 11) == '/overrides/') {
                $autoLoad = true;
                $addToManifest = false;
            }
        } elseif (strpos($path, $frameworkPath) === 0) {
            $webPath = "/app/{$framework}-{$frameworkVersion}/" . substr($path, strlen($frameworkPath) + 1);
            // package overrides should automatically be loaded
            if (substr($path, strpos($path, '/', strlen($frameworkPath) + 10), 11) == '/overrides/') {
                $autoLoad = true;
                $addToManifest = false;
            }
        } elseif (strpos($path, 'sencha-workspace/pages/') === 0) {
            $webPath = '/app/' . substr($path, 17);
        } elseif (strpos($path, $frameworkPath) === 0) {
            $webPath = '/app/' . substr($path, 17);
        } else {
            // this class was not in a recognized externally loadable collection
            continue;
        }
        // discover class name
        $sourceCacheKey = "sencha-class-name/{$source['SHA1']}";
        if (!($source['Class'] = Cache::fetch($sourceCacheKey))) {
            $sourceNode = Site::resolvePath($path);
            $sourceReadHandle = $sourceNode->get();
            while (($line = fgets($sourceReadHandle, 4096)) !== false) {
                if (preg_match('/^\\s*(Ext\\.define\\(\\s*([\'"])([^\\2]+)\\2|\\/\\/\\s*@define[ \\t]+(\\S+))/i', $line, $matches)) {
                    $source['Class'] = empty($matches[4]) ? $matches[3] : $matches[4];
                    break;
                }
            }
            fclose($sourceReadHandle);
            // cache class name
            Cache::store($sourceCacheKey, $source['Class']);
        }
        // skip if class name could not be determined
        if (!$source['Class']) {
            continue;
        }
        // apply fingerprint signature to path
        $webPath = "{$webPath}?_sha1={$source['SHA1']}";
        // map class name to path
        if ($addToManifest) {
            $manifest[$source['Class']] = $webPath;
        }
        // add path to autoLoad list
        if ($autoLoad) {
            $autoLoadPaths[] = $webPath;
        }
    }
    // build loader overrides
    $loaderPatch = '';
    if ($patchLoader) {
        $loaderPatch .= 'Ext.Loader.setConfig("disableCaching", false);';
        $loaderPatch .= 'function _versionScriptUrl(url) {' . 'if (url[0] != "/") {' . 'url = window.location.pathname + url;' . 'while (url.match(/\\/\\.\\.\\//)) url = url.replace(/\\/[^\\/]+\\/\\.\\./g, "");' . '}' . 'if(!url.match(/\\?_sha1=/)) {' . 'console.warn("Fingerprinted URL not found for %o, it will be loaded with a cache-buster", url);' . 'url += "?" + dcParam + "=" + now;' . '}' . 'return url;' . '}';
        $loaderPatch .= 'function _overrideMethod(cls, method, override) {' . 'var parent = cls[method] || Ext.emptyFn;' . 'cls[method] = function() {' . 'var me = this;' . 'callArgs = Array.prototype.slice.call(arguments, 0);' . 'callArgs.unshift(function() {' . 'parent.apply(me, arguments);' . '});' . 'return override.apply(this, callArgs);' . '};' . '}';
        #        if (Sencha::isVersionNewer('5', $frameworkVersion)) {
        if ($framework == 'ext') {
            $loaderPatch .= '_overrideMethod(Ext.Loader, "loadScript", function(parent, options) {' . 'if (typeof options == "string") {' . 'options = _versionScriptUrl(options);' . '} else {' . 'options.url = _versionScriptUrl(options.url);' . '}' . 'return parent(options);' . '});';
        } else {
            $loaderPatch .= '_overrideMethod(Ext.Loader, "loadScriptFile", function(parent, url, onLoad, onError, scope, synchronous) {' . 'return parent(_versionScriptUrl(url), onLoad, onError, scope, synchronous);' . '});';
        }
    }
    // output loader patch and manifest
    return '<script type="text/javascript">(function(){' . 'var dcParam = Ext.Loader.getConfig("disableCachingParam")' . ',now = Ext.Date.now();' . $loaderPatch . 'Ext.Loader.addClassPathMappings(' . json_encode($manifest) . ');' . '})()</script>' . (count($autoLoadPaths) ? implode('', array_map(function ($url) {
        return '<script type="text/javascript" src="' . $url . '"></script>';
    }, $autoLoadPaths)) : '');
}