From b794be9be0532b59f589fd19a4b66f2434c07f3d Mon Sep 17 00:00:00 2001
From: Aria <aria@suma-ev.de>
Date: Mon, 8 May 2017 10:22:15 +0200
Subject: [PATCH] =?UTF-8?q?Arbeit=20an=20synoptischer=20=C3=9Cbersicht=20d?=
 =?UTF-8?q?er=20=C3=9Cbersetzungen?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 app/Http/Controllers/LanguageController.php  | 52 +++++++++++++-------
 app/Models/LanguageFile.php                  | 21 ++++++++
 resources/views/languages/synoptic.blade.php |  2 +-
 routes/web.php                               |  2 +-
 4 files changed, 56 insertions(+), 21 deletions(-)
 create mode 100644 app/Models/LanguageFile.php

diff --git a/app/Http/Controllers/LanguageController.php b/app/Http/Controllers/LanguageController.php
index 0b839ce4f..aeccc1164 100644
--- a/app/Http/Controllers/LanguageController.php
+++ b/app/Http/Controllers/LanguageController.php
@@ -3,6 +3,7 @@
 namespace App\Http\Controllers;
 
 use Illuminate\Http\Request;
+use App\Models\LanguageFile;
 use RecursiveDirectoryIterator;
 use RecursiveIteratorIterator;
 
@@ -92,6 +93,7 @@ class LanguageController extends Controller
 
             }
         }
+        die();
         $langs = [];
         $fn    = "";
         $t     = [];
@@ -103,6 +105,7 @@ class LanguageController extends Controller
                 $ex = ['files' => [], 'new' => 0];
             }
         }
+
         foreach ($texts as $filename => $text) {
             $has = false;
             foreach ($ex['files'] as $file) {
@@ -157,43 +160,60 @@ class LanguageController extends Controller
             ->with('email', $email);
     }
 
-    public function createSynopticEditPage(Request $request) 
+    public function createSynopticEditPage(Request $request, $exclude = "") 
     {
         $languageFilePath = resource_path() . "/lang/";
-        $files            = scandir($languageFilePath);
-        $dirs             = [];
-        foreach ($files as $file) {
-            if (is_dir($languageFilePath . $file) && $file !== "." && $file !== "..") {
-                $dirs[$file] = $file;
+        $languageFolders  = scandir($languageFilePath); #relativer Pfad
+        $languageFiles    = [];
+        #Zusammensetzen zu absolutem Pfad
+        foreach ($languageFolders as $folder) {
+            if (is_dir($languageFilePath . $folder) && $folder !== "." && $folder !== "..") {
+                $languageFiles[$folder] = new LanguageFile($languageFilePath.$folder);
             }
+        }
+
 
+        foreach ($languageFiles as $folderName => $languageFile) {
+            
         }
 
+        /*
         $texts = [];
         $langTexts = [];
         $sum       = [];
         $filePath  = [];
+
+
         foreach ($dirs as $dir) {
             # Wir überprüfen nun für jede Datei die Anzahl der vorhandenen Übersetzungen
             $di              = new RecursiveDirectoryIterator($languageFilePath . $dir);
             $langTexts[$dir] = 0;
             foreach (new RecursiveIteratorIterator($di) as $filename => $file) {
+                //var_dump($filename." - ".$file."<br>");
                 if (!$this->endsWith($filename, ".")) {
                     $tmp = include $filename;
                     foreach ($tmp as $key => $value) {
+                        var_dump($key." - ".$value."<br>");
                         $sum                                    = array_merge($sum, $this->getValues([$key => $value], basename($filename)));
                         $texts[basename($filename)][$key][$dir] = $value;
                         $langTexts[$dir] += count($this->getValues([$key => $value]));
                     }
                     //$filePath[basename($filename)] = preg_replace("/lang\/.*?\//si", "lang/$to/", substr($filename, strpos($filename, "lang")));
-
                 }
+            }
+        }*/
+        die();
 
+       /* foreach($texts as $a => $text) {
+            foreach($text as $b => $k) {
+                foreach($k as $c => $d) {
+                    die(var_dump($a." - ".$b." - ".$c." - ".$d));
+                }
             }
         }
-        die(var_dump($texts));
-        return view('languages.synoptic');
-       /* $langs = [];
+        */
+        /*
+        $langs = [];
         $fn    = "";
         $t     = [];
         $ex    = ['files' => [], 'new' => 0];
@@ -204,6 +224,7 @@ class LanguageController extends Controller
                 $ex = ['files' => [], 'new' => 0];
             }
         }
+
         foreach ($texts as $filename => $text) {
             $has = false;
             foreach ($ex['files'] as $file) {
@@ -245,16 +266,9 @@ class LanguageController extends Controller
 
         $t = $this->htmlEscape($t, $to);
         $t = $this->createHints($t, $to);
+    */
 
-        return view('languages.synoptic')
-            ->with('texts', $t)
-            ->with('filename', $fn)
-            ->with('title', trans('titles.languages.edit'))
-            ->with('langs', $langs)
-            ->with('langTexts', $langTexts)
-            ->with('sum', $sum)
-            ->with('new', $ex["new"])*/
-
+        return view('languages.synoptic');
     }
 
     private function htmlEscape($t, $to)
diff --git a/app/Models/LanguageFile.php b/app/Models/LanguageFile.php
new file mode 100644
index 000000000..f99fdb810
--- /dev/null
+++ b/app/Models/LanguageFile.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Models;
+
+/*
+*	Beinhaltet zu je einer Sprache Angaben zum Pfad der jeweiligen Datei, sowie die vorhandenen Ãœbersetzungen
+*/
+class LanguageFile 
+{
+
+	public $filePath = "";
+	public $stringMap = [];
+
+	public function __construct($path) 
+    {
+        $this->filePath = $path;
+    }
+
+
+
+}
\ No newline at end of file
diff --git a/resources/views/languages/synoptic.blade.php b/resources/views/languages/synoptic.blade.php
index 2072b3cfa..7e74a6a9e 100644
--- a/resources/views/languages/synoptic.blade.php
+++ b/resources/views/languages/synoptic.blade.php
@@ -1 +1 @@
-@extends('layouts.subPages')
\ No newline at end of file
+@extends('layouts.subPages')
diff --git a/routes/web.php b/routes/web.php
index 249960333..7bae34efa 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -158,7 +158,7 @@ Route::group(
             return redirect('https://metager.de/klassik/databund');
         });
         Route::get('languages', 'LanguageController@createOverview');
-        Route::get('synoptic', 'LanguageController@createSynopticEditPage');
+        Route::get('synoptic/{exclude?}', 'LanguageController@createSynopticEditPage');
         Route::get('languages/edit/{from}/{to}/{exclude?}/{email?}', 'LanguageController@createEditPage');
         Route::post('languages/edit/{from}/{to}/{exclude?}/{email?}', 'MailController@sendLanguageFile');
         Route::get('berlin', 'StartpageController@berlin');
-- 
GitLab