modx.evo.custom /manager/cacheextender/files/document.parser.class.inc.insert.php

Language PHP Lines 68
MD5 Hash 02870b0b3aea5a4c30ece55953619909
Repository https://github.com/good-web-master/modx.evo.custom.git View Raw File
 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
66
67
/*
*	Modified by thebat053
*	CacheExtender 0.1a
*	CacheExtender revision:<cacheextender_revision>
*/
	var $cacheExtender = true; //modified by thebat053

    function rewriteUrls($documentSource) {
        // rewrite the urls
        if ($this->config['friendly_urls'] == 1) {
        	$in= '!\[\~([0-9]+)\~\]!ise'; // Use preg_replace with /e to make it evaluate PHP
			preg_match_all ($in, $documentSource, $matches);
            $aliases= array ();
			foreach ($matches[1] as $match){
				$item = $this->aliasListing[$match];
                $aliases[$match]= (strlen($item['path']) > 0 ? $item['path'] . '/' : '') . $item['alias'];
			}
            $isfriendly= ($this->config['friendly_alias_urls'] == 1 ? 1 : 0);
            $pref= $this->config['friendly_url_prefix'];
            $suff= $this->config['friendly_url_suffix'];
            $thealias= '$aliases[\\1]';
            $found_friendlyurl= "\$this->makeFriendlyURL('$pref','$suff',$thealias)";
            $not_found_friendlyurl= "\$this->makeFriendlyURL('$pref','$suff','" . '\\1' . "')";
            $out= "({$isfriendly} && isset({$thealias}) ? {$found_friendlyurl} : {$not_found_friendlyurl})";
            $documentSource= preg_replace($in, $out, $documentSource);
        } else {
            $in= '!\[\~([0-9]+)\~\]!is';
            $out= "index.php?id=" . '\1';
            $documentSource= preg_replace($in, $out, $documentSource);
        }
        return $documentSource;
    }


	function getChildIds($id, $depth = 10, $children = array(), $strictchilds = null){
		if(!is_array($id))
			$id = array($id);
		foreach($id as $chid){
			$children += $this->getChildIdsRec($chid, $depth, array(), $strictchilds);
		}

		return $children;
	}

    function getChildIdsRec($id, $depth, $children = array(), $strictchilds = null) {
        // Get all the children for this parent node
        if (isset($this->documentMap_cache[$id])) {
            $depth--;
            $tmp = $this->documentMap_cache[$id];
			foreach ($tmp as $childId) {
				if($strictchilds)
                	if(!in_array($childId, $strictchilds))
                    	continue;
                $pkey = (strlen($this->aliasListing[$childId]['path']) ? "{$this->aliasListing[$childId]['path']}/" : '') . $this->aliasListing[$childId]['alias'];
                if (!strlen($pkey)) $pkey = "{$childId}";
                    $children[$pkey] = $childId;

                if ($depth || $depth < 0) {
                    $children += $this->getChildIdsRec($childId, $depth, array(), $strictchilds);
                }
            }
        }
        return $children;
    }
/*
*	End of modification
*/
Back to Top