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