Project

General

Profile

1
<?php
2
/**
3
 *
4
 * @param string $content
5
 * @return string
6
 */
7
    function doFilterScriptVars($content) {
8
        $aFilterSettings = getOutputFilterSettings();
9
        $key = preg_replace('=^.*?filter([^\.\/\\\\]+)(\.[^\.]+)?$=is', '\1', __FILE__);
10
        if ($aFilterSettings[$key]) {
11
            $scriptLink  = '';
12
            if( !preg_match('/<head.*<.*src=\".*\/domReady.js.*>.*<\/head/siU', $content) ) {
13
                  $scriptLink .= "\t".'<script src="'.WB_URL.'/include/jquery/domReady.js" type="text/javascript"></script>'."\n";
14
            }
15
            if (!preg_match('/<head.*<.*var WB_URL.*<\/head/siU', $content) ) {
16
                  $scriptLink .= "\n\t"."<script type=\"text/javascript\">\n"
17
                              ."\t\t"."var URL = '".WB_URL."';\n"
18
                              ."\t\t"."var WB_URL = '".WB_URL."';\n"
19
                              ."\t\t"."var THEME_URL = '".THEME_URL."';\n"
20
                              ."\t\t"."var TEMPLATE_DIR = '".TEMPLATE_DIR."';\n"
21
                              ."\t\t"."var TEMPLATE = '".TEMPLATE."';\n"
22
                              ."\t\t"."var EDITOR = '".WYSIWYG_EDITOR."';\n"
23
                              ."\t"."</script>\n";
24
            }
25
            if ($scriptLink!='') {
26
                  $regex = '/(.*)(<\s*?\/\s*?head\s*>.*)/isU';
27
                  $replace = '$1'.$scriptLink.'$2';
28
                  $content = preg_replace ($regex, $replace, $content);
29
            }
30
        }
31
        return $content;
32
    }
(10-10/12)