Commit 0a8901de authored by Aria Givi's avatar Aria Givi
Browse files

Daten werden an Template übergeben, parsen der Daten fehlt

parent d49ce171
......@@ -3,7 +3,7 @@
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\LanguageData;
use App\Models\LanguageObject;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
......@@ -100,8 +100,6 @@ class LanguageController extends Controller
if ($exclude !== "") {
try {
$ex = unserialize(base64_decode($exclude));
// var_dump($ex);
// die();
} catch (\ErrorException $e) {
$ex = ['files' => [], 'new' => 0];
}
......@@ -122,7 +120,6 @@ class LanguageController extends Controller
}
# Hier können wir später die bereits bearbeiteten Dateien ausschließen.
foreach ($text as $textname => $languages) {
if ($languages === "") {
continue;
}
......@@ -140,12 +137,10 @@ class LanguageController extends Controller
if (!isset($languages[$to])) {
$fn = $filePath[$filename];
$t = $text;
break;
break 2;
}
}
}
//die();
$t = $this->htmlEscape($t, $to);
$t = $this->createHints($t, $to);
......@@ -166,29 +161,31 @@ class LanguageController extends Controller
$languageFilePath = resource_path() . "/lang/";
$languageFolders = scandir($languageFilePath);
#Enthält zu jeder Sprache ein Objekt mit allen Daten
$languageFiles = [];
$languageObjects = [];
$to = [];
#Erstelle LanguageData-Objekte
#Instanziiere LanguageObject
foreach ($languageFolders as $folder) {
if (is_dir($languageFilePath . $folder) && $folder !== "." && $folder !== "..") {
$languageFiles[$folder] = new LanguageData($folder, $languageFilePath.$folder);
$languageObjects[$folder] = new LanguageObject($folder, $languageFilePath.$folder);
}
}
#Speichere Daten in LanguageData-Objekten
foreach ($languageFiles as $folder => $languageData) {
$di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($languageData->filePath));
#Speichere Daten in LanguageObject
foreach ($languageObjects as $folder => $languageObject) {
$to[] = $folder;
$di = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($languageObject->filePath));
foreach($di as $filename => $file) {
if(!$this->endsWith($filename, ".")) {
$tmp = include $filename;
foreach ($tmp as $key => $value) {
$languageData->saveData(basename($filename), $key, $value);
$languageObject->saveData(basename($filename), $key, $value);
}
}
}
}
#Dekodieren ausgeschlossener Dateien anhand des URL-Parameters
$ex = ['files' => [], 'new' => 0];
if ($exclude !== "") {
try {
......@@ -197,64 +194,46 @@ class LanguageController extends Controller
$ex = ['files' => [], 'new' => 0];
}
}
die();
/*
return view('languages.edit')
->with('texts', $t) //Array mit
->with('filename', $fn) //Pfad zur angezeigten Datei
->with('title', trans('titles.languages.edit'))
->with('langs', $langs) //Ausgangssprache (1 Element)
->with('to', $to) //zu bearbeitende Sprache
->with('langTexts', $langTexts) //Anzahl der vorhandenen Übersetzungen
->with('sum', $sum) //Alle vorhandenen Texte in beiden Sprachen in einem Array
->with('new', $ex["new"]) //
->with('email', $email); //Email-Adresse des Benutzers
*/
/*
foreach ($texts as $filename => $text) {
$has = false;
foreach ($ex['files'] as $file) {
if ($file === $filename) {
$has = true;
}
}
if ($has) {
continue;
}
while ($this->hasToMuchDimensions($text)) {
$text = $this->deMultidimensionalizeArray($text);
}
# Hier können wir später die bereits bearbeiteten Dateien ausschließen.
foreach ($text as $textname => $languages) {
if ($languages === "") {
continue;
}
$complete = true;
foreach ($languages as $lang => $value) {
if ($lang !== $to) {
$langs = array_add($langs, $lang, $lang);
}
if (!isset($languages[$to]) && isset($languages[$lang])) {
$complete = false;
}
}
if (!isset($languages[$to])) {
$fn = $filePath[$filename];
$t = $text;
break;
$t = [];
$fn = "";
#Wähle die erste Datei aus, welche nicht ausgeschlossen worden ist
foreach($languageObjects as $folder => $languageObject) {
foreach($languageObject->stringMap as $languageFileName => $languageFile) {
if(isset($ex[$languageFileName])) {
continue 2;
} else {
$fn = $languageFileName;
break 2;
}
}
}
#Speichere den Inhalt der ausgewählten Datei in Array $t ab
foreach($languageObjects as $folder => $languageObject) {
foreach($languageObject->stringMap as $languageFileName => $languageFile) {
if($languageFileName === $fn) {
$t[$languageObject->language] = $languageFile;
continue 2;
}
}
}
$t = $this->htmlEscape($t, $to);
$t = $this->createHints($t, $to);
*/
foreach($t as $language => $text) {
// foreach($text as $key => $value) {
echo("<p>");
var_dump($text);
echo("</p>");
//}
}
die();
return view('languages.synoptic');
return view('languages.synoptic')
->with('to', $to) #Alle vorhandenen Sprachen
->with('texts', $t) #Array mit Sprachsnippets
->with('filename', $fn) #Name der Datei
->with('title', trans('titles.languages.edit'));
}
private function htmlEscape($t, $to)
......
......@@ -5,13 +5,14 @@ namespace App\Models;
/*
* Beinhaltet zu je einer Sprache Angaben zum Pfad der jeweiligen Datei, sowie die vorhandenen Übersetzungen
*/
class LanguageData
class LanguageObject
{
public $language = "";
public $filePath = "";
public $stringMap = [[]];
#2D-Array der Form [$filename][$key]
public $stringMap;
public function __construct($lang, $path)
{
......@@ -19,6 +20,7 @@ class LanguageData
$this->filePath = $path;
}
#Speichert Daten in $stringMap, entdimensionalisiert ggbf. $value
public function saveData($filename, $key, $value)
{
if(is_array($value)) {
......
......@@ -3,17 +3,17 @@
@section('title', $title )
@section('content')
<h1>{{ trans('languages.header') }}</h1>
<p>{{ trans('languages.beschreibung.1') }}</p>
<p>{{ trans('languages.beschreibung.2') }}</p>
<h1>Übersicht</h1>
<?php /*
<!--
<div class="progress">
<div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="{{ round(100 * (($langTexts[$to]+$new) / count($sum))) }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ round(100 * (($langTexts[$to]+$new) / count($sum))) }}%">
{{ trans('languages.progress', ['uebersetzteTexte'=> ($langTexts[$to]+$new), 'textCount'=>count($sum), 'percentage'=>round(100 * (($langTexts[$to]+$new) / count($sum)))]) }}
</div>
</div>
-->
<h1>{{$filename}}</h1>
</div>
-->
*/?>
<h2>{{$filename}}</h2>
<form id="submit" method="POST">
<input type="hidden" name="filename" value="{{$filename}}" />
</form>
......@@ -21,13 +21,12 @@
<thead>
<tr>
<th>#ID</th>
<th>{{$to}}</th>
@foreach($langs as $lang => $value)
<th>{{$lang}}</th>
@endforeach
@foreach($to as $t)
<th>{{$t}}</th>
@endforeach
</tr>
</thead>
<tbody>
<?php /*<tbody>
@foreach($texts as $name => $langValues)
@if($langValues === "")
<tr>
......@@ -51,7 +50,8 @@
</tr>
@endif
@endforeach
</tbody>
</tbody> */
?>
</table>
<!--
<p>{{ trans('languages.hinweis.1') }}</p>
......@@ -59,7 +59,6 @@
<p>{!! trans('languages.hinweis.3') !!}</p>
<p>{!! trans('languages.email') !!}</p>
-->
<p><input type="email" name="email" form="submit" value="{{$email}}"/></p>
<button class="btn btn-success" type="submit" form="submit">Daten übermitteln</button>
<script type="text/javascript" src="{{ elixir('js/lib.js') }}"></script>
<script type="text/javascript" src="{{ elixir('js/editLanguage.js') }}"></script>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment