Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Move get_boot_conf action to dedicated method (psr-7 compatible).
Browse files Browse the repository at this point in the history
  • Loading branch information
cdujeu committed May 9, 2016
1 parent ab08fe0 commit c19e2a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 132 deletions.
149 changes: 18 additions & 131 deletions core/src/plugins/gui.ajax/class.AJXP_ClientDriver.php
Expand Up @@ -61,6 +61,23 @@ public function loadConfigs($configData)
}
}

/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
*/
public function getBootConf(ServerRequestInterface &$request, ResponseInterface &$response){

$out = array();
Utils::parseApplicationGetParameters($request->getQueryParams(), $out, $_SESSION);
$config = $this->computeBootConf();
$response = $response->withHeader("Content-type", "application/json;charset=UTF-8");
$response->getBody()->write(json_encode($config));

}
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
*/
public function getBootGui(ServerRequestInterface &$request, ResponseInterface &$response){

if (!defined("AJXP_THEME_FOLDER")) {
Expand Down Expand Up @@ -250,137 +267,7 @@ public function switchAction($action, $httpVars, $fileVars)

break;


//------------------------------------
// GET BOOT GUI
//------------------------------------
case "get_boot_gui":

HTMLWriter::internetExplorerMainDocumentHeader();
HTMLWriter::charsetHeader();

if (!is_file(TESTS_RESULT_FILE)) {
$outputArray = array();
$testedParams = array();
$passed = Utils::runTests($outputArray, $testedParams);
if (!$passed && !isset($httpVars["ignore_tests"])) {
Utils::testResultsToTable($outputArray, $testedParams);
die();
} else {
Utils::testResultsToFile($outputArray, $testedParams);
}
}

$root = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$configUrl = ConfService::getCoreConf("SERVER_URL");
if(!empty($configUrl)){
$root = '/'.ltrim(parse_url($configUrl, PHP_URL_PATH), '/');
if(strlen($root) > 1) $root = rtrim($root, '/').'/';
}else{
preg_match ('/ws-(.)*\/|settings|dashboard|welcome|user/', $root, $matches, PREG_OFFSET_CAPTURE);
if(count($matches)){
$capture = $matches[0][1];
$root = substr($root, 0, $capture);
}
}
$START_PARAMETERS = array(
"BOOTER_URL" =>"index.php?get_action=get_boot_conf",
"MAIN_ELEMENT" => "ajxp_desktop",
"APPLICATION_ROOT" => $root,
"REBASE" => $root
);
if (AuthService::usersEnabled()) {
AuthService::preLogUser((isSet($httpVars["remote_session"])?$httpVars["remote_session"]:""));
AuthService::bootSequence($START_PARAMETERS);
if (AuthService::getLoggedUser() != null || AuthService::logUser(null, null) == 1) {
if (AuthService::getDefaultRootId() == -1) {
AuthService::disconnect();
} else {
$loggedUser = AuthService::getLoggedUser();
if(!$loggedUser->canRead(ConfService::getCurrentRepositoryId())
&& AuthService::getDefaultRootId() != ConfService::getCurrentRepositoryId())
{
ConfService::switchRootDir(AuthService::getDefaultRootId());
}
}
}
}

Utils::parseApplicationGetParameters($_GET, $START_PARAMETERS, $_SESSION);

$confErrors = ConfService::getErrors();
if (count($confErrors)) {
$START_PARAMETERS["ALERT"] = implode(", ", array_values($confErrors));
}
// PRECOMPUTE BOOT CONF
if (!preg_match('/MSIE 7/',$_SERVER['HTTP_USER_AGENT']) && !preg_match('/MSIE 8/',$_SERVER['HTTP_USER_AGENT'])) {
$preloadedBootConf = $this->computeBootConf();
Controller::applyHook("loader.filter_boot_conf", array(&$preloadedBootConf));
$START_PARAMETERS["PRELOADED_BOOT_CONF"] = $preloadedBootConf;
}

// PRECOMPUTE REGISTRY
if (!isSet($START_PARAMETERS["FORCE_REGISTRY_RELOAD"])) {
$clone = ConfService::getFilteredXMLRegistry(true, true);
$clonePath = new DOMXPath($clone);
$serverCallbacks = $clonePath->query("//serverCallback|hooks");
foreach ($serverCallbacks as $callback) {
$callback->parentNode->removeChild($callback);
}
$START_PARAMETERS["PRELOADED_REGISTRY"] = XMLWriter::replaceAjxpXmlKeywords($clone->saveXML());
}

$JSON_START_PARAMETERS = json_encode($START_PARAMETERS);
$crtTheme = $this->pluginConf["GUI_THEME"];
$additionalFrameworks = $this->getFilteredOption("JS_RESOURCES_BEFORE");
$ADDITIONAL_FRAMEWORKS = "";
if( !empty($additionalFrameworks) ){
$frameworkList = explode(",", $additionalFrameworks);
foreach($frameworkList as $index => $framework){
$frameworkList[$index] = '<script language="javascript" type="text/javascript" src="'.$framework.'"></script>'."\n";
}
$ADDITIONAL_FRAMEWORKS = implode("", $frameworkList);
}
if (ConfService::getConf("JS_DEBUG")) {
if (!isSet($mess)) {
$mess = ConfService::getMessages();
}
if (is_file(AJXP_INSTALL_PATH."/plugins/gui.ajax/res/themes/$crtTheme/html/gui_debug.html")) {
include(AJXP_INSTALL_PATH."/plugins/gui.ajax/res/themes/$crtTheme/html/gui_debug.html");
} else {
include(AJXP_INSTALL_PATH."/plugins/gui.ajax/res/html/gui_debug.html");
}
} else {
if (is_file(AJXP_INSTALL_PATH."/plugins/gui.ajax/res/themes/$crtTheme/html/gui.html")) {
$content = file_get_contents(AJXP_INSTALL_PATH."/plugins/gui.ajax/res/themes/$crtTheme/html/gui.html");
} else {
$content = file_get_contents(AJXP_INSTALL_PATH."/plugins/gui.ajax/res/html/gui.html");
}
if (preg_match('/MSIE 7/',$_SERVER['HTTP_USER_AGENT'])){
$ADDITIONAL_FRAMEWORKS = "";
}
$content = str_replace("AJXP_ADDITIONAL_JS_FRAMEWORKS", $ADDITIONAL_FRAMEWORKS, $content);
$content = XMLWriter::replaceAjxpXmlKeywords($content, false);
$content = str_replace("AJXP_REBASE", isSet($START_PARAMETERS["REBASE"])?'<base href="'.$START_PARAMETERS["REBASE"].'"/>':"", $content);
if ($JSON_START_PARAMETERS) {
$content = str_replace("//AJXP_JSON_START_PARAMETERS", "startParameters = ".$JSON_START_PARAMETERS.";", $content);
}
print($content);
}
break;
//------------------------------------
// GET CONFIG FOR BOOT
//------------------------------------
case "get_boot_conf":

$out = array();
Utils::parseApplicationGetParameters($_GET, $out, $_SESSION);
$config = $this->computeBootConf();
header("Content-type:application/json;charset=UTF-8");
print(json_encode($config));

break;


default;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/gui.ajax/manifest.xml
Expand Up @@ -191,7 +191,7 @@
</action>
<action name="get_boot_conf" skipSecureToken="true">
<processing>
<serverCallback methodName="switchAction"/>
<serverCallback methodName="getBootConf"/>
</processing>
</action>
</actions>
Expand Down

0 comments on commit c19e2a4

Please sign in to comment.