Project

General

Profile

1
<?php
2
/**
3
 * doFilterReplaceSysvar
4
 * @param string to modify
5
 * @return string
6
 * Convert the {SYSVAR:xxxx} Placeholders into their real value
7
 */
8
	function doFilterReplaceSysvar($sContent) {
9
        $oReg = WbAdaptor::getInstance();
10
        $aSearches = array();
11
        $aReplacements = array();
12
        // search for all SYSVARs
13
        if (preg_match_all('/\{SYSVAR\:([^\}]+)\}/sU', $sContent, $aMatches)) {
14
            $aMatches = array_unique($aMatches[1], SORT_STRING);
15
            foreach ($aMatches as $sMatch) {
16
                $sTmp = '';
17
                $aTmp = preg_split('/\./', $sMatch);
18
                foreach ($aTmp as $sSysvar) {
19
                    if (!isset($oReg->{$sSysvar})) {
20
                        $sTmp = '';
21
                        break;
22
                    }
23
                    $sTmp .= $oReg->{$sSysvar};
24
                }
25
                if ($sTmp) {
26
                    $aSearches[] = '{SYSVAR:'.$sMatch.'}';
27
                    $aReplacements[] = $sTmp;
28
                }
29
            }
30
            $sContent = str_replace($aSearches, $aReplacements, $sContent);
31
        }
32
		return $sContent;
33
	}
(6-6/7)