Search.php 1.98 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php

namespace App\MetaGer;
use Illuminate\Http\Request;
use App\MetaGer\Searchengine;

class Search
{
	public static function loadSearchEngines(Request $request)
	{

        # Überprüfe, welche Sumas eingeschaltet sind
        $xml = simplexml_load_file(SUMA_FILE);
        $enabledSearchengines = [];
        $overtureEnabled = FALSE;
        
        if(FOKUS === "angepasst")
        {
            $sumas = $xml->xpath("suma");
            foreach($sumas as $suma)
            {
                if($request->has($suma["service"]) 
                	|| ( FOKUS !== "bilder" 
                		&& ($suma["name"]->__toString() === "qualigo" 
                			|| $suma["name"]->__toString() === "similar_product_ads" 
                			|| ( !$overtureEnabled && $suma["name"]->__toString() === "overtureAds" )
                			)
                		)
                	){
                	if($suma["name"]->__toString() === "overture")
                	{
                		$overtureEnabled = TRUE;
                	}
                    $enabledSearchengines[] = $suma;
                }
            }
        }else{
            $sumas = $xml->xpath("suma");
            foreach($sumas as $suma){
                $types = explode(",",$suma["type"]);
                if(in_array(FOKUS, $types) 
                	|| ( FOKUS !== "bilder" 
                		&& ($suma["name"]->__toString() === "qualigo" 
                			|| $suma["name"]->__toString() === "similar_product_ads" 
                			|| ( !$overtureEnabled && $suma["name"]->__toString() === "overtureAds" )
                			)
                		)
                	){
                	if($suma["name"]->__toString() === "overture")
                	{
                		$overtureEnabled = TRUE;
                	}
                    $enabledSearchengines[] = $suma;
                }
            }
        }
        
		$engines = [];
		foreach($enabledSearchengines as $engine){
			$engines[] = new Searchengine($engine);
		}

        return $engines;
	}
}