Support.php 1.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 1/28/16
 * Time: 8:05 AM
 */

namespace qfq;

require_once(__DIR__ . '/Sanatize.php');

class Support {

15
16
17
18
    /**
     * @param array $queryArray Empty or prefilled assoc array with url parameter
     */
    public static function appendTypo3ParameterToArray(array &$queryArray) {
19
20
//        if (isset($_GET['id']))
//            $queryArray['id'] = self::getCurrentPage();
21
22
        if (isset($GLOBALS["TSFE"]->id))
            $queryArray['id'] = $GLOBALS["TSFE"]->id;
23
24
25
26
27
28
29
30
31

        if (isset($_GET['L']))
            $queryArray['L'] = $_GET['L'];

        if (isset($_GET['type']))
            $queryArray['type'] = $_GET['type'];

    }

32
    /**
33
34
     * Builds a urlencoded query string of an assoc array.
     *
35
     * @param array $queryArray
36
     * @return string Querystring (e.g.: id=23&type=99
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
     */
    public static function arrayToQueryString(array $queryArray) {
        $items = array();

        foreach ($queryArray as $key => $value) {
            if (is_int($key)) {
                $items[] = urlencode($value);
            } else {
                $items[] = $key . '=' . urlencode($value);
            }
        }

        return implode('&', $items);
    }
}