+ foreach ($matches[2] as $key => $cmd) {
+ // Init replacer variable
+ $replacer = '';
+
+ // Is the extension installed or code provided?
+ // @TODO This whole if-block is very static
+ if ($cmd == 'code') {
+ // Code asked for
+ $code = str_replace($matches[0][$key], "\" . getCode('" . $matches[4][$key] . "') . \"", $code);
+ } elseif (substr($cmd, 0, 3) == 'url') {
+ // Do we have JS-mode?
+ if (substr($cmd, -2, 2) == 'js') $outputMode = 1;
+
+ // Handle an URL here
+ $replacer = "\" . encodeUrl(\"" . $matches[4][$key] . "\", " . $outputMode . ") . \"";
+
+ // Replace it
+ $code = str_replace($matches[0][$key], $replacer, $code);
+ } elseif (substr($cmd, 0, 6) == 'server') {
+ // Get data from $_SERVER by their respective functions
+ $serverCmd = explode(',', $cmd);
+ $serverCmd = $serverCmd[1];
+
+ // This will make 'foo_bar' to detectFooBar()
+ $functionName = "'detect' . implode('', array_map('ucfirst', explode('_', '" . $serverCmd . "')))";
+
+ // Replace it
+ $code = str_replace($matches[0][$key], "\" . call_user_func(" . $functionName . ") . \"", $code);
+ } elseif (substr($cmd, 0, 4) == 'user') {
+ // Extract user command
+ $userCmdArray = explode(',', $cmd);
+ $userCmd = $userCmdArray[1];
+
+ // Use current userid by default
+ $functionName = 'getMemberId()';
+
+ // User-related data, so is there a userid?
+ if (!empty($matches[4][$key])) {
+ // Do we have a userid or $userid?
+ if ($matches[4][$key] == '$userid') {
+ // Use dynamic call
+ $functionName = "getFetchedUserData('userid', \$userid, '" . $userCmd . "')";
+ } elseif ($matches[4][$key] > 0) {
+ // User data found
+ $functionName = "getFetchedUserData('userid', " . $matches[4][$key] . ", " . $userCmd . "')";
+ } // END - if
+ } // END - if
+
+ // Do we have another function to run (e.g. translations)
+ if (isset($userCmdArray[2])) {
+ // Surround the original function call with it
+ $functionName = $userCmdArray[2] . '(' . $functionName . ')';
+ } // END - if
+
+ // Now replace the code
+ $code = str_replace($matches[0][$key], "\" . " . $functionName . " . \"", $code);
+ } elseif (substr($cmd, 0, 3) == 'ext') {
+ // Get the extension command
+ $extCmd = explode(',', $cmd);
+ $extCmd = $extCmd[1];