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