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