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() → [])

RevLine 
[0]1<?php
[3731]2/**
3 * @package Dotclear
4 * @subpackage Public
5 *
6 * @copyright Olivier Meunier & Association Dotclear
7 * @copyright GPL-2.0-only
8 */
[0]9
10if (!empty($_GET['pf'])) {
[3730]11    require dirname(__FILE__) . '/../load_plugin_file.php';
12    exit;
[0]13}
14
[3260]15if (!empty($_GET['vf'])) {
[3730]16    require dirname(__FILE__) . '/../load_var_file.php';
17    exit;
[3260]18}
19
[0]20if (!isset($_SERVER['PATH_INFO'])) {
[3730]21    $_SERVER['PATH_INFO'] = '';
[0]22}
23
[3730]24require_once dirname(__FILE__) . '/../prepend.php';
25require_once dirname(__FILE__) . '/rs.extension.php';
[0]26
27# Loading blog
28if (defined('DC_BLOG_ID')) {
[3730]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    }
[0]39}
40
41if ($core->blog->id == null) {
[3730]42    __error(__('Blog is not defined.')
43        , __('Did you change your Blog ID?')
44        , 630);
[0]45}
46
[3730]47if ((boolean) !$core->blog->status) {
48    $core->unsetBlog();
49    __error(__('Blog is offline.')
50        , __('This blog is offline. Please try again later.')
51        , 670);
[0]52}
53
54# Loading media
55try {
[3730]56    $core->media = new dcMedia($core);
[0]57} catch (Exception $e) {}
58
59# Creating template context
60$_ctx = new context();
61try {
[3730]62    $core->tpl = new dcTemplate(DC_TPL_CACHE, '$core->tpl', $core);
[0]63} catch (Exception $e) {
[3730]64    __error(__('Can\'t create template files.')
65        , $e->getMessage()
66        , 640);
[0]67}
68
69# Loading locales
70$_lang = $core->blog->settings->system->lang;
[3730]71$_lang = preg_match('/^[a-z]{2}(-[a-z]{2})?$/', $_lang) ? $_lang : 'en';
[0]72
[1949]73l10n::lang($_lang);
[3730]74if (l10n::set(dirname(__FILE__) . '/../../locales/' . $_lang . '/date') === false && $_lang != 'en') {
75    l10n::set(dirname(__FILE__) . '/../../locales/en/date');
[0]76}
[3730]77l10n::set(dirname(__FILE__) . '/../../locales/' . $_lang . '/public');
78l10n::set(dirname(__FILE__) . '/../../locales/' . $_lang . '/plugins');
[0]79
[3059]80// Set lexical lang
[3730]81dcUtils::setlexicalLang('public', $_lang);
[3059]82
[0]83# Loading plugins
84try {
[3730]85    $core->plugins->loadModules(DC_PLUGINS_ROOT, 'public', $_lang);
[0]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)) {
[3730]94    $__theme = $core->blog->settings->system->theme;
[0]95}
96
97if (!$core->themes->moduleExists($__theme)) {
[3730]98    $__theme = $core->blog->settings->system->theme = 'default';
[0]99}
100
[3730]101$__parent_theme = $core->themes->moduleInfo($__theme, 'parent');
[0]102if ($__parent_theme) {
[3730]103    if (!$core->themes->moduleExists($__parent_theme)) {
104        $__theme        = $core->blog->settings->system->theme        = 'default';
105        $__parent_theme = null;
106    }
[0]107}
[2566]108
[0]109# If theme doesn't exist, stop everything
110if (!$core->themes->moduleExists($__theme)) {
[3730]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);
[0]116}
117
118# Loading _public.php file for selected theme
[3730]119$core->themes->loadNsFile($__theme, 'public');
[0]120
[420]121# Loading translations for selected theme
122if ($__parent_theme) {
[3730]123    $core->themes->loadModuleL10N($__parent_theme, $_lang, 'main');
[420]124}
[3730]125$core->themes->loadModuleL10N($__theme, $_lang, 'main');
[420]126
[0]127# --BEHAVIOR-- publicPrepend
[3730]128$core->callBehavior('publicPrepend', $core);
[0]129
130# Prepare the HTTP cache thing
131$mod_files = get_included_files();
[3874]132$mod_ts    = [];
[3730]133$mod_ts[]  = $core->blog->upddt;
[0]134
[3874]135$__theme_tpl_path = [
[3730]136    $core->blog->themes_path . '/' . $__theme . '/tpl'
[3874]137];
[0]138if ($__parent_theme) {
[3730]139    $__theme_tpl_path[] = $core->blog->themes_path . '/' . $__parent_theme . '/tpl';
[0]140}
[3730]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());
[2541]147} else {
[3730]148    $core->tpl->setPath(
149        $__theme_tpl_path,
150        $core->tpl->getPath());
[2541]151}
[0]152$core->url->mode = $core->blog->settings->system->url_scan;
153
154try {
[3730]155    # --BEHAVIOR-- publicBeforeDocument
156    $core->callBehavior('publicBeforeDocument', $core);
[2566]157
[3730]158    $core->url->getDocument();
[2566]159
[3730]160    # --BEHAVIOR-- publicAfterDocument
161    $core->callBehavior('publicAfterDocument', $core);
[0]162} catch (Exception $e) {
[3730]163    __error($e->getMessage()
164        , __('Something went wrong while loading template file for your blog.')
165        , 660);
[0]166}
Note: See TracBrowser for help on using the repository browser.

Sites map