Refactored code, sunshine remix

This commit is contained in:
markseu 2019-04-22 11:06:04 +02:00
parent 3279aed045
commit e386c5fd97

View file

@ -188,20 +188,18 @@ class YellowInstall {
// Update content
public function updateContent($language, $name, $location) {
$statusCode = 200;
if ($language!="en") {
$fileName = $this->yellow->lookup->findFileFromLocation($location);
$fileData = strreplaceu("\r\n", "\n", $this->yellow->toolbox->readFile($fileName));
if (!empty($fileData)) {
$titleOld = "Title: ".$this->yellow->text->getText("install{$name}Title", "en");
$titleNew = "Title: ".$this->yellow->text->getText("install{$name}Title", $language);
$textOld = strreplaceu("\\n", "\n", $this->yellow->text->getText("install{$name}Text", "en"));
$textNew = strreplaceu("\\n", "\n", $this->yellow->text->getText("install{$name}Text", $language));
if ($name!="Footer") $fileData = strreplaceu($titleOld, $titleNew, $fileData);
$fileData = strreplaceu($textOld, $textNew, $fileData);
if (!$this->yellow->toolbox->createFile($fileName, $fileData)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
$fileName = $this->yellow->lookup->findFileFromLocation($location);
$fileData = strreplaceu("\r\n", "\n", $this->yellow->toolbox->readFile($fileName));
if (!empty($fileData) && $language!="en") {
$titleOld = "Title: ".$this->yellow->text->getText("install{$name}Title", "en");
$titleNew = "Title: ".$this->yellow->text->getText("install{$name}Title", $language);
$textOld = strreplaceu("\\n", "\n", $this->yellow->text->getText("install{$name}Text", "en"));
$textNew = strreplaceu("\\n", "\n", $this->yellow->text->getText("install{$name}Text", $language));
if ($name!="Footer") $fileData = strreplaceu($titleOld, $titleNew, $fileData);
$fileData = strreplaceu($textOld, $textNew, $fileData);
if (!$this->yellow->toolbox->createFile($fileName, $fileData)) {
$statusCode = 500;
$this->yellow->page->error($statusCode, "Can't write file '$fileName'!");
}
}
return $statusCode;