1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
7 | # Licensed under the GPL version 2.0 license. |
---|
8 | # See LICENSE file or |
---|
9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
10 | # |
---|
11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
12 | |
---|
13 | if (!empty($_GET['pf'])) { |
---|
14 | require dirname(__FILE__) . '/../load_plugin_file.php'; |
---|
15 | exit; |
---|
16 | } |
---|
17 | |
---|
18 | if (!empty($_GET['vf'])) { |
---|
19 | require dirname(__FILE__) . '/../load_var_file.php'; |
---|
20 | exit; |
---|
21 | } |
---|
22 | |
---|
23 | if (!isset($_SERVER['PATH_INFO'])) { |
---|
24 | $_SERVER['PATH_INFO'] = ''; |
---|
25 | } |
---|
26 | |
---|
27 | require_once dirname(__FILE__) . '/../prepend.php'; |
---|
28 | require_once dirname(__FILE__) . '/rs.extension.php'; |
---|
29 | |
---|
30 | # Loading blog |
---|
31 | if (defined('DC_BLOG_ID')) { |
---|
32 | try { |
---|
33 | $core->setBlog(DC_BLOG_ID); |
---|
34 | } catch (Exception $e) { |
---|
35 | init_prepend_l10n(); |
---|
36 | __error(__('Database problem') |
---|
37 | , DC_DEBUG ? |
---|
38 | __('The following error was encountered while trying to read the database:') . '</p><ul><li>' . $e->getMessage() . '</li></ul>' : |
---|
39 | __('Something went wrong while trying to read the database.') |
---|
40 | , 620); |
---|
41 | } |
---|
42 | } |
---|
43 | |
---|
44 | if ($core->blog->id == null) { |
---|
45 | __error(__('Blog is not defined.') |
---|
46 | , __('Did you change your Blog ID?') |
---|
47 | , 630); |
---|
48 | } |
---|
49 | |
---|
50 | if ((boolean) !$core->blog->status) { |
---|
51 | $core->unsetBlog(); |
---|
52 | __error(__('Blog is offline.') |
---|
53 | , __('This blog is offline. Please try again later.') |
---|
54 | , 670); |
---|
55 | } |
---|
56 | |
---|
57 | # Loading media |
---|
58 | try { |
---|
59 | $core->media = new dcMedia($core); |
---|
60 | } catch (Exception $e) {} |
---|
61 | |
---|
62 | # Creating template context |
---|
63 | $_ctx = new context(); |
---|
64 | try { |
---|
65 | $core->tpl = new dcTemplate(DC_TPL_CACHE, '$core->tpl', $core); |
---|
66 | } catch (Exception $e) { |
---|
67 | __error(__('Can\'t create template files.') |
---|
68 | , $e->getMessage() |
---|
69 | , 640); |
---|
70 | } |
---|
71 | |
---|
72 | # Loading locales |
---|
73 | $_lang = $core->blog->settings->system->lang; |
---|
74 | $_lang = preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_lang) ? $_lang : 'en'; |
---|
75 | |
---|
76 | l10n::lang($_lang); |
---|
77 | if (l10n::set(dirname(__FILE__) . '/../../locales/' . $_lang . '/date') === false && $_lang != 'en') { |
---|
78 | l10n::set(dirname(__FILE__) . '/../../locales/en/date'); |
---|
79 | } |
---|
80 | l10n::set(dirname(__FILE__) . '/../../locales/' . $_lang . '/public'); |
---|
81 | l10n::set(dirname(__FILE__) . '/../../locales/' . $_lang . '/plugins'); |
---|
82 | |
---|
83 | // Set lexical lang |
---|
84 | dcUtils::setlexicalLang('public', $_lang); |
---|
85 | |
---|
86 | # Loading plugins |
---|
87 | try { |
---|
88 | $core->plugins->loadModules(DC_PLUGINS_ROOT, 'public', $_lang); |
---|
89 | } catch (Exception $e) {} |
---|
90 | |
---|
91 | # Loading themes |
---|
92 | $core->themes = new dcThemes($core); |
---|
93 | $core->themes->loadModules($core->blog->themes_path); |
---|
94 | |
---|
95 | # Defining theme if not defined |
---|
96 | if (!isset($__theme)) { |
---|
97 | $__theme = $core->blog->settings->system->theme; |
---|
98 | } |
---|
99 | |
---|
100 | if (!$core->themes->moduleExists($__theme)) { |
---|
101 | $__theme = $core->blog->settings->system->theme = 'default'; |
---|
102 | } |
---|
103 | |
---|
104 | $__parent_theme = $core->themes->moduleInfo($__theme, 'parent'); |
---|
105 | if ($__parent_theme) { |
---|
106 | if (!$core->themes->moduleExists($__parent_theme)) { |
---|
107 | $__theme = $core->blog->settings->system->theme = 'default'; |
---|
108 | $__parent_theme = null; |
---|
109 | } |
---|
110 | } |
---|
111 | |
---|
112 | # If theme doesn't exist, stop everything |
---|
113 | if (!$core->themes->moduleExists($__theme)) { |
---|
114 | __error(__('Default theme not found.') |
---|
115 | , __('This either means you removed your default theme or set a wrong theme ' . |
---|
116 | 'path in your blog configuration. Please check theme_path value in ' . |
---|
117 | 'about:config module or reinstall default theme. (' . $__theme . ')') |
---|
118 | , 650); |
---|
119 | } |
---|
120 | |
---|
121 | # Loading _public.php file for selected theme |
---|
122 | $core->themes->loadNsFile($__theme, 'public'); |
---|
123 | |
---|
124 | # Loading translations for selected theme |
---|
125 | if ($__parent_theme) { |
---|
126 | $core->themes->loadModuleL10N($__parent_theme, $_lang, 'main'); |
---|
127 | } |
---|
128 | $core->themes->loadModuleL10N($__theme, $_lang, 'main'); |
---|
129 | |
---|
130 | # --BEHAVIOR-- publicPrepend |
---|
131 | $core->callBehavior('publicPrepend', $core); |
---|
132 | |
---|
133 | # Prepare the HTTP cache thing |
---|
134 | $mod_files = get_included_files(); |
---|
135 | $mod_ts = array(); |
---|
136 | $mod_ts[] = $core->blog->upddt; |
---|
137 | |
---|
138 | $__theme_tpl_path = array( |
---|
139 | $core->blog->themes_path . '/' . $__theme . '/tpl' |
---|
140 | ); |
---|
141 | if ($__parent_theme) { |
---|
142 | $__theme_tpl_path[] = $core->blog->themes_path . '/' . $__parent_theme . '/tpl'; |
---|
143 | } |
---|
144 | $tplset = $core->themes->moduleInfo($core->blog->settings->system->theme, 'tplset'); |
---|
145 | if (!empty($tplset) && is_dir(dirname(__FILE__) . '/default-templates/' . $tplset)) { |
---|
146 | $core->tpl->setPath( |
---|
147 | $__theme_tpl_path, |
---|
148 | dirname(__FILE__) . '/default-templates/' . $tplset, |
---|
149 | $core->tpl->getPath()); |
---|
150 | } else { |
---|
151 | $core->tpl->setPath( |
---|
152 | $__theme_tpl_path, |
---|
153 | $core->tpl->getPath()); |
---|
154 | } |
---|
155 | $core->url->mode = $core->blog->settings->system->url_scan; |
---|
156 | |
---|
157 | try { |
---|
158 | # --BEHAVIOR-- publicBeforeDocument |
---|
159 | $core->callBehavior('publicBeforeDocument', $core); |
---|
160 | |
---|
161 | $core->url->getDocument(); |
---|
162 | |
---|
163 | # --BEHAVIOR-- publicAfterDocument |
---|
164 | $core->callBehavior('publicAfterDocument', $core); |
---|
165 | } catch (Exception $e) { |
---|
166 | __error($e->getMessage() |
---|
167 | , __('Something went wrong while loading template file for your blog.') |
---|
168 | , 660); |
---|
169 | } |
---|