Beispiel #1
0
function getConfigByName($currentEnv, $type, $name)
{
    /*  if(DRUPAL_ROOT) {
    		$cwd = DRUPAL_ROOT; 
    	} else { 
    		$cwd = getcwd(); 
    	}  */
    $cwd = getcwd();
    $fileContents = file_get_contents($cwd . "/sites/default/config/phresco-env-config.xml");
    $file = getOriginalString($fileContents);
    $document = new DOMDocument();
    $document->loadXML($file);
    $xmlDoc = $document->documentElement;
    $xml = simplexml_load_string($file);
    foreach ($xmlDoc->childNodes as $envNode) {
        if ($envNode->nodeName == "environment") {
            $env = $envNode->getAttribute("name");
            $envDefault = $envNode->getAttribute("default");
            if ($currentEnv != "") {
                if ($currentEnv == $env) {
                    if ($name != "") {
                        $result = $xml->xpath("//environment[@name='" . $env . "']//" . $type . "[@name='" . $name . "']");
                    } else {
                        $result = $xml->xpath("//environment[@name='" . $env . "']//" . $type . " ");
                    }
                    return $result;
                }
            } else {
                if ($envDefault == "true") {
                    if ($name != "") {
                        $result = $xml->xpath("//environment[@name='" . $env . "']//" . $type . "[@name='" . $name . "']");
                    } else {
                        $result = $xml->xpath("//environment[@name='" . $env . "']//" . $type . " ");
                    }
                    return $result;
                }
            }
        }
    }
}
Beispiel #2
0
function getConfigByName($currentEnv, $type, $name)
{
    global $baseurl;
    $self = $_SERVER['PHP_SELF'];
    $deploydir = explode("/", $self);
    $host = "http://" . $_SERVER["HTTP_HOST"] . "/" . $deploydir[1] . "/";
    $fileContents = file_get_contents($host . 'config/phresco-env-config.xml');
    $file = getOriginalString($fileContents);
    $document = new DOMDocument();
    $document->loadXML($file);
    $xmlDoc = $document->documentElement;
    $xml = simplexml_load_string($file);
    foreach ($xmlDoc->childNodes as $envNode) {
        if ($envNode->nodeName == "environment") {
            $env = $envNode->getAttribute("name");
            $envDefault = $envNode->getAttribute("default");
            if ($currentEnv != "") {
                if ($currentEnv == $env) {
                    if ($name != "") {
                        $result = $xml->xpath("//environment[@name='" . $env . "']//" . $type . "[@name='" . $name . "']");
                    } else {
                        $result = $xml->xpath("//environment[@name='" . $env . "']//" . $type . " ");
                    }
                    return $result;
                }
            } else {
                if ($envDefault == "true") {
                    if ($name != "") {
                        $result = $xml->xpath("//environment[@name='" . $env . "']//" . $type . "[@name='" . $name . "']");
                    } else {
                        $result = $xml->xpath("//environment[@name='" . $env . "']//" . $type . " ");
                    }
                    return $result;
                }
            }
        }
    }
}