moduleBase . $module; if($this->svnUrlExists($svnURL)) { $moduleDir = strtok($module,'/'); echo "Linking directory '$moduleDir' to '$svnURL' using svn:externals..."; $this->svnAddExternal(Director::baseFolder(), $moduleDir, $svnURL); echo "Calling SVN update to get the new code..."; $this->svnUpdate(Director::baseFolder()); echo "Rebuilding..."; // todo: we should be able to call the 'model' of the builder rather than its 'controller' // it would make it easier to tailor the output $da = new DevelopmentAdmin(); $da->build(); } else { echo "Can't find '$svnURL' in SVN"; } } else { echo "Bad module '$module'"; } } } } /** * Calls svn update */ protected function svnUpdate($baseDir) { $CLI_baseDir = escapeshellarg($baseDir); `svn update $CLI_baseDir`; } /** * Returns true if the given SVN url exists */ protected function svnUrlExists($svnURL) { $CLI_svnURL = escapeshellarg($svnURL); $info = `svn info --xml $CLI_svnURL`; $xmlInfo = new SimpleXmlElement($info); return $xmlInfo->entry ? true : false; } /** * Add a new entry to the svn externals */ protected function svnAddExternal($baseDir, $externalDir, $externalURL) { $CLI_baseDir = escapeshellarg($baseDir); $oldExternals = trim(`svn propget svn:externals $CLI_baseDir`); $newExternals = "$oldExternals\n$externalDir/ $externalURL"; $CLI_newExternals = escapeshellarg($newExternals); `svn propset svn:externals $CLI_newExternals $CLI_baseDir`; } } ?>