Dotclear

source: inc/public/prepend.php @ 852:969647a6c35e

Revision 852:969647a6c35e, 4.0 KB checked in by Dsls <dsls@…>, 13 years ago (diff)

sexy step 3 : no more media.

Line 
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
13if (!empty($_GET['pf'])) {
14     require dirname(__FILE__).'/../load_plugin_file.php';
15     exit;
16}
17
18if (!isset($_SERVER['PATH_INFO'])) {
19     $_SERVER['PATH_INFO'] = '';
20}
21
22require_once dirname(__FILE__).'/../prepend.php';
23require_once dirname(__FILE__).'/rs.extension.php';
24
25# Loading blog
26if (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               ,20);
36     }
37}
38
39if ($core->blog->id == null) {
40     __error(__('Blog is not defined.')
41          ,__('Did you change your Blog ID?')
42          ,30);
43}
44
45if ((boolean)!$core->blog->status) {
46     $core->unsetBlog();
47     __error(__('Blog is offline.')
48          ,__('This blog is offline. Please try again later.')
49          ,70);
50}
51
52# Creating template context
53$_ctx = new context();
54try {
55     $core->tpl = new dcTemplate(DC_TPL_CACHE,'$core->tpl',$core);
56} catch (Exception $e) {
57     __error(__('Can\'t create template files.')
58          ,$e->getMessage()
59          ,40);
60}
61
62# Loading locales
63$_lang = $core->blog->settings->system->lang;
64$_lang = preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$_lang) ? $_lang : 'en';
65
66if (l10n::set(dirname(__FILE__).'/../../locales/'.$_lang.'/date') === false && $_lang != 'en') {
67     l10n::set(dirname(__FILE__).'/../../locales/en/date');
68}
69l10n::set(dirname(__FILE__).'/../../locales/'.$_lang.'/public');
70l10n::set(dirname(__FILE__).'/../../locales/'.$_lang.'/plugins');
71
72# Loading plugins
73try {
74     $core->plugins->loadModules(DC_PLUGINS_ROOT,'public',$_lang);
75} catch (Exception $e) {}
76
77# Loading themes
78$core->themes = new dcThemes($core);
79$core->themes->loadModules($core->blog->themes_path);
80
81# Defining theme if not defined
82if (!isset($__theme)) {
83     $__theme = $core->blog->settings->system->theme;
84}
85
86if (!$core->themes->moduleExists($__theme)) {
87     $__theme = $core->blog->settings->system->theme = 'default';
88}
89
90$__parent_theme = $core->themes->moduleInfo($__theme,'parent');
91if ($__parent_theme) {
92     if (!$core->themes->moduleExists($__parent_theme)) {
93          $__theme = $core->blog->settings->system->theme = 'default';
94          $__parent_theme = null;
95     }
96}
97     
98# If theme doesn't exist, stop everything
99if (!$core->themes->moduleExists($__theme)) {
100     __error(__('Default theme not found.')
101          ,__('This either means you removed your default theme or set a wrong theme '.
102          'path in your blog configuration. Please check theme_path value in '.
103          'about:config module or reinstall default theme. ('.$__theme.')')
104          ,50);
105}
106
107# Loading _public.php file for selected theme
108$core->themes->loadNsFile($__theme,'public');
109
110# Loading translations for selected theme
111if ($__parent_theme) {
112     $core->themes->loadModuleL10N($__parent_theme,$_lang,'main');
113}
114$core->themes->loadModuleL10N($__theme,$_lang,'main');
115
116# --BEHAVIOR-- publicPrepend
117$core->callBehavior('publicPrepend',$core);
118
119# Prepare the HTTP cache thing
120$mod_files = get_included_files();
121$mod_ts = array();
122$mod_ts[] = $core->blog->upddt;
123
124$__theme_tpl_path = array(
125     $core->blog->themes_path.'/'.$__theme.'/tpl'
126);
127if ($__parent_theme) {
128     $__theme_tpl_path[] = $core->blog->themes_path.'/'.$__parent_theme.'/tpl';
129}
130
131$core->tpl->setPath(
132     $__theme_tpl_path,
133     dirname(__FILE__).'/default-templates',
134     $core->tpl->getPath());
135
136$core->url->mode = $core->blog->settings->system->url_scan;
137
138try {
139     # --BEHAVIOR-- publicBeforeDocument
140     $core->callBehavior('publicBeforeDocument',$core);
141     
142     $core->url->getDocument();
143     
144     # --BEHAVIOR-- publicAfterDocument
145     $core->callBehavior('publicAfterDocument',$core);
146} catch (Exception $e) {
147     __error($e->getMessage()
148          ,__('Something went wrong while loading template file for your blog.')
149          ,60);
150}
151?>
Note: See TracBrowser for help on using the repository browser.

Sites map