FokiLoader.php 1.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
<?php

namespace App\Http\Controllers;

use App;

class FokiLoader
{
    public static function loadFoki()
    {
        $sumaFile = "";
        if (App::isLocale('en')) {
13
            $sumaFile = config_path() . "/sumasEn.xml";
14
15
16
17
        } else {
            $sumaFile = config_path() . "/sumas.xml";
        }

18
        $xml = simplexml_load_file($sumaFile);
19
20
21
22
23
24
25
26
        $sumas = $xml->xpath("suma");

        $foki = [];
        foreach ($sumas as $suma) {
            if ((!isset($suma['disabled']) || $suma['disabled'] === "") && (!isset($suma['userSelectable']) || $suma['userSelectable']->__toString() === "1")) {
                if (isset($suma['type'])) {
                    $f = explode(",", $suma['type']->__toString());
                    foreach ($f as $tmp) {
27
28
                        $displayName = $suma['displayName']->__toString();
                        $url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
29
30
31
                        $foki[$tmp][$suma['name']->__toString()] = ['displayName' => $displayName, 'url' => $url];
                    }
                } else {
32
33
                    $displayName = $suma['displayName']->__toString();
                    $url = isset($suma['homepage']) ? $suma['homepage']->__toString() : "https://metager.de";
34
35
36
37
38
39
40
41
                    $foki["andere"][$suma['name']->__toString()] = ['displayName' => $displayName, 'url' => $url];
                }
            }
        }

        return $foki;
    }
}