mirror of
https://github.com/easy-wi/developer.git
synced 2025-02-20 11:23:28 +08:00
parent
b4a3850ba6
commit
81ec1f139f
@ -94,7 +94,10 @@ https://github.com/milesj/decoda
|
||||
Released under the MIT license
|
||||
http://opensource.org/licenses/MIT
|
||||
|
||||
|
||||
* Spyc -- A Simple PHP YAML Class
|
||||
https://github.com/mustangostang/spyc/
|
||||
Released under the MIT license
|
||||
http://opensource.org/licenses/MIT
|
||||
|
||||
Shipped with Easy-WI but modified and fitted to Easy-WI:
|
||||
|
||||
|
@ -909,7 +909,7 @@ class AppServer {
|
||||
|
||||
$line = str_replace(array("\r"), '', $line);
|
||||
|
||||
if (preg_match('/^(\[[\w\/\.\-\_]{1,}\]|\[[\w\/\.\-\_]{1,}\] (xml|ini|cfg|lua|json|ddot|yml))$/', $line)) {
|
||||
if (preg_match('/^(\[[\w\/\.\-\_]{1,}\]|\[[\w\/\.\-\_]{1,}\] (xml|ini|cfg|lua|json|ddot|yml|yaml))$/', $line)) {
|
||||
|
||||
$exploded = preg_split("/\s+/", $line, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
@ -927,9 +927,9 @@ class AppServer {
|
||||
|
||||
$splitLine = preg_split("/\s+/", $line, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
} else if ($cvarProtectArray[$configPathAndFile]['type'] == 'yml') {
|
||||
} else if ($cvarProtectArray[$configPathAndFile]['type'] == 'yml' or $cvarProtectArray[$configPathAndFile]['type'] == 'yaml') {
|
||||
|
||||
$splitLine = preg_split("/(?:(?<!-))\s+/", $line);
|
||||
$splitLine = preg_split("/(?:(?<!-))\s*:\s*/", $line);
|
||||
|
||||
} else if (in_array($cvarProtectArray[$configPathAndFile]['type'], array('ini','lua'))) {
|
||||
|
||||
@ -1045,6 +1045,15 @@ class AppServer {
|
||||
private function replaceArrayValues($givenArray, $replacements) {
|
||||
|
||||
foreach(array_keys($givenArray) as $key) {
|
||||
|
||||
if (is_array($givenArray[$key])) {
|
||||
$givenArray[$key] = $this->replaceArrayValues($givenArray[$key], $replacements);
|
||||
}
|
||||
|
||||
if (isset($this->undefinedRequiredVars[$key])) {
|
||||
unset($this->undefinedRequiredVars[$key]);
|
||||
}
|
||||
|
||||
if (isset($replacements[$key])) {
|
||||
$givenArray[$key] = $replacements[$key];
|
||||
}
|
||||
@ -1063,10 +1072,6 @@ class AppServer {
|
||||
|
||||
foreach($array as $key => $value) {
|
||||
|
||||
if (isset($this->undefinedRequiredVars[$key])) {
|
||||
unset($this->undefinedRequiredVars[$key]);
|
||||
}
|
||||
|
||||
if (is_array($value)) {
|
||||
|
||||
foreach($value as $arrayValue) {
|
||||
@ -1107,6 +1112,19 @@ class AppServer {
|
||||
return $iniString;
|
||||
}
|
||||
|
||||
private function replaceYaml($stored, $replacements) {
|
||||
|
||||
$this->undefinedRequiredVars = $replacements;
|
||||
|
||||
$replacedArray = $this->replaceArrayValues($stored, $replacements);
|
||||
|
||||
foreach ($this->undefinedRequiredVars as $key => $value) {
|
||||
$replacedArray[$key] = $value;
|
||||
}
|
||||
|
||||
return Spyc::YAMLDump($replacedArray);
|
||||
}
|
||||
|
||||
private function correctProtectedFiles () {
|
||||
|
||||
$protectedConfigs = $this->protectedSettingsToArray();
|
||||
@ -1152,6 +1170,20 @@ class AppServer {
|
||||
|
||||
$ftpObect->writeContentToTemp($this->replaceIni($parsedConfig, $values['cvars']));
|
||||
|
||||
} else if ($values['type'] === 'yml' or $values['type'] === 'yaml') {
|
||||
|
||||
if (!class_exists('Spyc')) {
|
||||
include(EASYWIDIR . '/third_party/spyc/Spyc.php');
|
||||
}
|
||||
|
||||
$parsedConfig = Spyc::YAMLLoadString($configFileContent);
|
||||
|
||||
if (!$parsedConfig) {
|
||||
$parsedConfig = array();
|
||||
}
|
||||
|
||||
$ftpObect->writeContentToTemp($this->replaceYaml($parsedConfig, $values['cvars']));
|
||||
|
||||
} else {
|
||||
|
||||
$cvarsNotFound = $values['cvars'];
|
||||
@ -1185,16 +1217,6 @@ class AppServer {
|
||||
|
||||
$ftpObect->writeContentToTemp((isset($splitLine[1])) ? $splitLine[0] . $cvar . ' ' . $value : $cvar . ' ' . $value);
|
||||
|
||||
} else if ($values['type'] == 'yml' and preg_match('/^[\s\/]{0,}' . strtolower($cvar) . '\s+(.*)$/', $loweredSingleLine)) {
|
||||
|
||||
$edited = true;
|
||||
|
||||
unset($cvarsNotFound[$cvar]);
|
||||
|
||||
$splitLine = preg_split('/' . $cvar . '/', $singeLine, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$ftpObect->writeContentToTemp((isset($splitLine[1])) ? $splitLine[0] . $cvar . ' ' . $value : $cvar . ' ' . $value);
|
||||
|
||||
} else if ($values['type'] == 'ddot' and preg_match('/^[\s\/]{0,}' . strtolower($cvar) . '[\s+]{0,}\:[\s+]{0,}(.*)$/', $loweredSingleLine)) {
|
||||
|
||||
$edited = true;
|
||||
|
1160
third_party/spyc/Spyc.php
vendored
Normal file
1160
third_party/spyc/Spyc.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user