/**
  * Dynamically replace XML keywords with their live values.
  * AJXP_SERVER_ACCESS, AJXP_MIMES_*,AJXP_ALL_MESSAGES, etc.
  * @static
  * @param string $xml
  * @param bool $stripSpaces
  * @return mixed
  */
 public static function replaceAjxpXmlKeywords($xml, $stripSpaces = false)
 {
     $messages = ConfService::getMessages();
     $confMessages = ConfService::getMessagesConf();
     $matches = array();
     if (isset($_SESSION["AJXP_SERVER_PREFIX_URI"])) {
         //$xml = str_replace("AJXP_THEME_FOLDER", $_SESSION["AJXP_SERVER_PREFIX_URI"].AJXP_THEME_FOLDER, $xml);
         $xml = str_replace("AJXP_SERVER_ACCESS", $_SESSION["AJXP_SERVER_PREFIX_URI"] . AJXP_SERVER_ACCESS, $xml);
     } else {
         //$xml = str_replace("AJXP_THEME_FOLDER", AJXP_THEME_FOLDER, $xml);
         $xml = str_replace("AJXP_SERVER_ACCESS", AJXP_SERVER_ACCESS, $xml);
     }
     $xml = str_replace("AJXP_APPLICATION_TITLE", ConfService::getCoreConf("APPLICATION_TITLE"), $xml);
     $xml = str_replace("AJXP_MIMES_EDITABLE", AJXP_Utils::getAjxpMimes("editable"), $xml);
     $xml = str_replace("AJXP_MIMES_IMAGE", AJXP_Utils::getAjxpMimes("image"), $xml);
     $xml = str_replace("AJXP_MIMES_AUDIO", AJXP_Utils::getAjxpMimes("audio"), $xml);
     $xml = str_replace("AJXP_MIMES_ZIP", AJXP_Utils::getAjxpMimes("zip"), $xml);
     $authDriver = ConfService::getAuthDriverImpl();
     if ($authDriver != NULL) {
         $loginRedirect = $authDriver->getLoginRedirect();
         $xml = str_replace("AJXP_LOGIN_REDIRECT", $loginRedirect !== false ? "'" . $loginRedirect . "'" : "false", $xml);
     }
     $xml = str_replace("AJXP_REMOTE_AUTH", "false", $xml);
     $xml = str_replace("AJXP_NOT_REMOTE_AUTH", "true", $xml);
     $xml = str_replace("AJXP_ALL_MESSAGES", "MessageHash=" . json_encode(ConfService::getMessages()) . ";", $xml);
     if (preg_match_all("/AJXP_MESSAGE(\\[.*?\\])/", $xml, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $messId = str_replace("]", "", str_replace("[", "", $match[1]));
             $xml = str_replace("AJXP_MESSAGE[{$messId}]", $messages[$messId], $xml);
         }
     }
     if (preg_match_all("/CONF_MESSAGE(\\[.*?\\])/", $xml, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $messId = str_replace(array("[", "]"), "", $match[1]);
             $message = $messId;
             if (array_key_exists($messId, $confMessages)) {
                 $message = $confMessages[$messId];
             }
             $xml = str_replace("CONF_MESSAGE[{$messId}]", AJXP_Utils::xmlEntities($message), $xml);
         }
     }
     if (preg_match_all("/MIXIN_MESSAGE(\\[.*?\\])/", $xml, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $messId = str_replace(array("[", "]"), "", $match[1]);
             $message = $messId;
             if (array_key_exists($messId, $confMessages)) {
                 $message = $confMessages[$messId];
             }
             $xml = str_replace("MIXIN_MESSAGE[{$messId}]", AJXP_Utils::xmlEntities($message), $xml);
         }
     }
     if ($stripSpaces) {
         $xml = preg_replace("/[\n\r]?/", "", $xml);
         $xml = preg_replace("/\t/", " ", $xml);
     }
     $xml = str_replace(array('xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"', 'xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd"'), "", $xml);
     $tab = array(&$xml);
     AJXP_Controller::applyIncludeHook("xml.filter", $tab);
     return $xml;
 }
 static function replaceAjxpXmlKeywords($xml, $stripSpaces = false)
 {
     $messages = ConfService::getMessages();
     $matches = array();
     $xml = str_replace("AJXP_CLIENT_RESOURCES_FOLDER", CLIENT_RESOURCES_FOLDER, $xml);
     if (isset($_SESSION["AJXP_SERVER_PREFIX_URI"])) {
         $xml = str_replace("AJXP_THEME_FOLDER", $_SESSION["AJXP_SERVER_PREFIX_URI"] . AJXP_THEME_FOLDER, $xml);
         $xml = str_replace("AJXP_SERVER_ACCESS", $_SESSION["AJXP_SERVER_PREFIX_URI"] . SERVER_ACCESS, $xml);
     } else {
         $xml = str_replace("AJXP_THEME_FOLDER", AJXP_THEME_FOLDER, $xml);
         $xml = str_replace("AJXP_SERVER_ACCESS", SERVER_ACCESS, $xml);
     }
     $xml = str_replace("AJXP_MIMES_EDITABLE", AJXP_Utils::getAjxpMimes("editable"), $xml);
     $xml = str_replace("AJXP_MIMES_IMAGE", AJXP_Utils::getAjxpMimes("image"), $xml);
     $xml = str_replace("AJXP_MIMES_AUDIO", AJXP_Utils::getAjxpMimes("audio"), $xml);
     $xml = str_replace("AJXP_MIMES_ZIP", AJXP_Utils::getAjxpMimes("zip"), $xml);
     $loginRedirect = ConfService::getAuthDriverImpl()->getLoginRedirect();
     $xml = str_replace("AJXP_LOGIN_REDIRECT", $loginRedirect !== false ? "'" . $loginRedirect . "'" : "false", $xml);
     $xml = str_replace("AJXP_REMOTE_AUTH", "false", $xml);
     $xml = str_replace("AJXP_NOT_REMOTE_AUTH", "true", $xml);
     $xml = str_replace("AJXP_ALL_MESSAGES", "MessageHash=" . json_encode(ConfService::getMessages()) . ";", $xml);
     if (preg_match_all("/AJXP_MESSAGE(\\[.*?\\])/", $xml, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $messId = str_replace("]", "", str_replace("[", "", $match[1]));
             $xml = str_replace("AJXP_MESSAGE[{$messId}]", $messages[$messId], $xml);
         }
     }
     if ($stripSpaces) {
         $xml = preg_replace("/[\n\r]?/", "", $xml);
         $xml = preg_replace("/\t/", " ", $xml);
     }
     return $xml;
 }