Dotclear

source: inc/public/prepend.php @ 3874:ab8368569446

Revision 3874:ab8368569446, 4.7 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

short notation for array (array() → [])

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

Sites map