1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24:
25: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
26:
27: 28: 29: 30: 31: 32: 33: 34: 35: 36:
37: function cecParseTemplate($template, cTemplate $templateObj) {
38:
39: global $frame;
40:
41:
42:
43:
44:
45: $prefix = "\n ";
46:
47: $cfg = cRegistry::getConfig();
48: $sessid = (string) cRegistry::getBackendSessionId();
49: $backendPath = cRegistry::getBackendUrl();
50: $backendLang = cRegistry::getBackendLanguage();
51:
52:
53:
54: $languageid = cRegistry::getLanguageId();
55: if ($languageid) {
56: $oLanguage = cRegistry::getLanguage();
57: $encoding = $oLanguage->get('encoding');
58: } else {
59: $encoding = 'utf-8';
60: }
61: $frameNr = (!empty($frame) && is_numeric($frame)) ? $frame : 0;
62:
63:
64:
65: $metaCon = '
66: <meta http-equiv="Content-type" content="text/html;charset=' . $encoding . '">
67: <meta http-equiv="expires" content="0">
68: <meta http-equiv="cache-control" content="no-cache">
69: <meta http-equiv="pragma" content="no-cache">';
70:
71:
72: $jsConfigurationAdded = false;
73: $jsConfiguration = '
74: <script type="text/javascript">
75: (function(Con, $) {
76: Con.sid = "' . $sessid . '";
77: $.extend(Con.cfg, {
78: urlBackend: "' . $backendPath . '",
79: urlHelp: "' . $cfg['help_url'] . '",
80: belang: "' . $backendLang . '",
81: frame: ' . $frameNr . '
82: });
83: })(Con, Con.$);
84: </script>';
85:
86:
87: $cssHeadCon = '';
88: $files = $cfg['backend_template']['css_files'];
89: foreach ($files as $file) {
90: $cssHeadCon .= $prefix . '<link rel="stylesheet" type="text/css" href="' . $file . '">';
91: }
92: $cssHeadCon = $prefix . "<!-- CSS -->" . $cssHeadCon . $prefix . "<!-- /CSS -->";
93:
94:
95: $jsHeadCon = '';
96: $files = $cfg['backend_template']['js_files'];
97: foreach ($files as $file) {
98: if ('_CONFIG_' === $file) {
99: $jsHeadCon .= $jsConfiguration;
100: $jsConfigurationAdded = true;
101: } else {
102: $jsHeadCon .= $prefix . '<script type="text/javascript" src="' . $file . '"></script>';
103: }
104: }
105:
106: if (false === $jsConfigurationAdded) {
107: $jsHeadCon .= $jsConfiguration;
108: }
109:
110: $jsHeadCon = $prefix . "<!-- JS -->" . $jsHeadCon . $prefix . "<!-- /JS -->";
111:
112:
113: $replacements = array(
114: '_SID_' => $sessid,
115: '_PATH_CONTENIDO_FULLHTML_' => $backendPath,
116: '_META_HEAD_CONTENIDO_' => $metaCon,
117: '_CSS_HEAD_CONTENIDO_' => str_replace('{basePath}', '', $cssHeadCon),
118: '_CSS_HEAD_CONTENIDO_FULLHTML_' => str_replace('{basePath}', $backendPath, $cssHeadCon),
119: '_JS_HEAD_CONTENIDO_' => str_replace('{basePath}', '', $jsHeadCon),
120: '_JS_HEAD_CONTENIDO_FULLHTML_' => str_replace('{basePath}', $backendPath, $jsHeadCon),
121: );
122:
123:
124:
125: foreach ($replacements as $key => $value) {
126: $placeholder = '{' . $key . '}';
127: if (!in_array($key, $templateObj->needles) && false !== strpos($template, $placeholder)) {
128: $template = str_replace($placeholder, $value, $template);
129: }
130: }
131:
132: return $template;
133:
134: }
135: