Search.php 2.06 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
<?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"]) 
23
24
25
26
27
28
                #	|| ( FOKUS !== "bilder" 
                #		&& ($suma["name"]->__toString() === "qualigo" 
                #			|| $suma["name"]->__toString() === "similar_product_ads" 
                #			|| ( !$overtureEnabled && $suma["name"]->__toString() === "overtureAds" )
               # 			)
               # 		)
29
30
31
32
33
34
35
36
37
38
39
40
41
                	){
                	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) 
42
43
44
45
46
47
                #	|| ( FOKUS !== "bilder" 
                	#	&& ($suma["name"]->__toString() === "qualigo" 
                	#		|| $suma["name"]->__toString() === "similar_product_ads" 
                #			|| ( !$overtureEnabled && $suma["name"]->__toString() === "overtureAds" )
                #			)
              #  		)
48
49
50
51
52
53
54
55
56
57
58
59
                	){
                	if($suma["name"]->__toString() === "overture")
                	{
                		$overtureEnabled = TRUE;
                	}
                    $enabledSearchengines[] = $suma;
                }
            }
        }
        
		$engines = [];
		foreach($enabledSearchengines as $engine){
60
61
            $path = "App\MetaGer\parserSkripte\\" . $engine["name"]->__toString();
			$engines[] = new $path($engine);
62
63
64
65
66
		}

        return $engines;
	}
}