Automad
 All Classes Functions Variables Pages
const.php
1 <?php
2 /*
3  * ....
4  * .: '':.
5  * :::: ':..
6  * ::. ''..
7  * .:'.. ..':.:::' . :. '':.
8  * :. '' '' '. ::::.. ..:
9  * ::::. ..':.. .'''::::: .
10  * :::::::.. '..:::: :. :::: :
11  * ::'':::::::. ':::.'':.:::: :
12  * :.. ''::::::....': '':: :
13  * :::::. '::::: : .. '' .
14  * .''::::::::... ':::.'' ..'' :.''''.
15  * :..:::''::::: :::::...:'' :..:
16  * ::::::. ':::: :::::::: ..:: .
17  * ::::::::.:::: :::::::: :'':.:: .''
18  * ::: '::::::::.' ''::::: :.' '': :
19  * ::: :::::::::..' :::: ::...' .
20  * ::: .:::::::::: :::: :::: .:'
21  * '::' ''::::::: :::: : :: :
22  * ':::: :::: :'' .:
23  * :::: :::: ..''
24  * :::: ..:::: .:''
25  * '''' '''''
26  *
27  *
28  * AUTOMAD
29  *
30  * Copyright (c) 2014 by Marc Anton Dahmen
31  * http://marcdahmen.de
32  *
33  * Licensed under the MIT license.
34  * http://automad.org/license
35  */
36 
37 
38 namespace Automad\Core;
39 
40 
41 defined('AUTOMAD') or die('Direct access not permitted!');
42 
43 
44 
45 
46 // Set config file.
47 define('AM_CONFIG', AM_BASE_DIR . '/config/config.json');
48 
49 // Parse AM_CONFIG to set user overrides for the below defined constants.
50 Config::json(AM_CONFIG);
51 
52 // Define debugging already here to be available when parsing the request.
53 Config::set('AM_DEBUG_ENABLED', false);
54 
55 
56 
57 
58 // Set base URL for all URLs relative to the root.
59 if (isset($_SERVER['HTTP_X_FORWARDED_HOST']) || isset($_SERVER['HTTP_X_FORWARDED_SERVER'])) {
60  // Add domain name in case the site is behind a proxy.
61  define('AM_BASE_URL', '/' . $_SERVER['HTTP_HOST'] . str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']));
62 } else {
63  define('AM_BASE_URL', str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']));
64 }
65 
66 
67 
68 
69 @Debug::log($_SERVER['SERVER_SOFTWARE'], 'Server Software');
70 
71 // Check whether pretty URLs are enabled.
72 if ((strpos(@strtolower($_SERVER['SERVER_SOFTWARE']), 'apache') !== false && file_exists(AM_BASE_DIR . '/.htaccess')) || strpos(@strtolower($_SERVER['SERVER_SOFTWARE']), 'nginx') !== false) {
73  // If .htaccess exists on Apache or the server software is Nginx, assume that pretty URLs are enabled and AM_INDEX is empty.
74  Config::set('AM_INDEX', '');
75  Debug::log('Pretty URLs are enabled.');
76 } else {
77  // For all other environments, AM_INDEX will be defined as fallback and pretty URLs are disabled.
78  Config::set('AM_INDEX', '/index.php');
79  Debug::log('Pretty URLs are disabled');
80 }
81 
82 
83 
84 
85 // Get the requested URL.
86 define('AM_REQUEST', Parse::request());
87 
88 
89 
90 
91 // Define all constants which are not defined yet by the config file.
92 // DIR
93 Config::set('AM_DIR_PAGES', '/pages');
94 Config::set('AM_DIR_SHARED', '/shared');
95 Config::set('AM_DIR_THEMES', '/themes');
96 Config::set('AM_DIR_CACHE', '/cache');
97 Config::set('AM_DIR_CACHE_PAGES', AM_DIR_CACHE . '/pages');
98 Config::set('AM_DIR_CACHE_IMAGES', AM_DIR_CACHE . '/images');
99 Config::set('AM_DIR_TRASH', AM_DIR_CACHE . '/trash');
100 Config::set('AM_DIR_GUI_INC', '/automad/gui/inc');
101 
102 // FILE
103 Config::set('AM_FILE_EXT_DATA', 'txt'); // Changing that constant will also require updating the .htaccess file! (for blocking direct access)
104 Config::set('AM_FILE_PREFIX_CACHE', 'cached'); // Changing that constant will also require updating the .htaccess file! (for blocking direct access)
105 Config::set('AM_FILE_EXT_PAGE_CACHE', 'html');
106 Config::set('AM_FILE_SITE_SETTINGS', AM_BASE_DIR . AM_DIR_SHARED . '/site.' . AM_FILE_EXT_DATA);
107 Config::set('AM_FILE_SITE_MTIME', AM_BASE_DIR . AM_DIR_CACHE . '/' . AM_FILE_PREFIX_CACHE . '_site_mtime');
108 Config::set('AM_FILE_OBJECT_CACHE', AM_BASE_DIR . AM_DIR_CACHE . '/' . AM_FILE_PREFIX_CACHE . '_automad_object');
109 Config::set('AM_FILE_ACCOUNTS', AM_BASE_DIR . '/config/accounts.php');
110 Config::set('AM_ALLOWED_FILE_TYPES', 'css, jpg, zip, png, ico, svg, js, pdf, mp3, gif');
111 
112 // PAGE
113 Config::set('AM_PAGE_NOT_FOUND_TEMPLATE', 'page_not_found');
114 Config::set('AM_PAGE_NOT_FOUND_TITLE', 'Page Not Found!');
115 Config::set('AM_PAGE_RESULTS_TEMPLATE', 'search_results');
116 Config::set('AM_PAGE_RESULTS_TITLE', 'Search Results');
117 Config::set('AM_PAGE_RESULTS_URL', '/search-results');
118 Config::set('AM_PAGE_GUI', '/gui');
119 
120 // CACHE
121 Config::set('AM_CACHE_ENABLED', true);
122 Config::set('AM_CACHE_MONITOR_DELAY', 120);
123 Config::set('AM_CACHE_LIFETIME', 3600);
124 
125 // IMAGE
126 Config::set('AM_IMG_JPG_QUALITY', 90);
127 
128 // LISTING DEFAULTS
129 Config::set('AM_LIST_DEFAULT_SORT_ORDER', 'desc');
130 
131 // TEMPLATE DELIMITERS & CHARACTER CLASSES
132 Config::set('AM_DEL_VAR_OPEN', '{[');
133 Config::set('AM_DEL_VAR_CLOSE', ']}');
134 Config::set('AM_DEL_STATEMENT_OPEN', '{@');
135 Config::set('AM_DEL_STATEMENT_CLOSE', '@}');
136 Config::set('AM_DEL_COMMENT_OPEN', '{*');
137 Config::set('AM_DEL_COMMENT_CLOSE', '*}');
138 // Charachter class for variable keys in text files.
139 Config::set('AM_CHARCLASS_VAR_CONTENT', '[\w\.\-]');
140 // Charachter class for all kind if variable keys, such as text file content, read-only vars and query string keys.
141 Config::set('AM_CHARCLASS_VAR_ALL', '[:\?\w\.\-]');
142 
143 // EXTENSIONS
144 Config::set('AM_NAMESPACE_EXTENSIONS', '\\Extensions');
145 
146 // HTML
147 Config::set('AM_HTML_CLASS_NAV', 'nav');
148 Config::set('AM_HTML_CLASS_PREV', 'prev');
149 Config::set('AM_HTML_CLASS_NEXT', 'next');
150 Config::set('AM_HTML_CLASS_FILTER', 'filter');
151 Config::set('AM_HTML_CLASS_TREE', 'tree');
152 Config::set('AM_HTML_CLASS_IMAGE_WRAPPER', 'img-wrapper');
153 Config::set('AM_HTML_CLASS_LIST', 'list');
154 Config::set('AM_HTML_CLASS_LIST_HEADER', 'list-header');
155 Config::set('AM_HTML_CLASS_LIST_ITEM', 'item');
156 Config::set('AM_HTML_CLASS_LIST_ITEM_IMG', 'img-responsive');
157 Config::set('AM_HTML_CLASS_LIST_ITEM_DATA', 'data');
158 Config::set('AM_HTML_CLASS_SORT', 'sort');
159 Config::set('AM_HTML_CLASS_HOME', 'home');
160 Config::set('AM_HTML_CLASS_CURRENT', 'current');
161 Config::set('AM_HTML_CLASS_CURRENT_PATH', 'currentPath');
162 Config::set('AM_HTML_CLASS_BREADCRUMBS', 'breadcrumbs');
163 Config::set('AM_HTML_CLASS_SEARCH', 'search');
164 Config::set('AM_HTML_CLASS_SEARCH_INPUT', 'search-input');
165 Config::set('AM_HTML_CLASS_SEARCH_BUTTON', 'search-button');
166 Config::set('AM_HTML_STR_BREADCRUMB_SEPARATOR', '&gt;');
167 Config::set('AM_HTML_TEXT_FILTER_ALL', 'All');
168 Config::set('AM_HTML_LIST_MAX_CHARS', 150);
169 
170 // PARSE
171 // Block separator - separates all key/value pairs
172 // Must be used as the only string in a line within the template files.
173 Config::set('AM_PARSE_BLOCK_SEPARATOR', '-');
174 // Pair separator - separates the key from the value
175 Config::set('AM_PARSE_PAIR_SEPARATOR', ':');
176 // Tags/String separator
177 Config::set('AM_PARSE_STR_SEPARATOR', ',');
178 
179 // KEYS
180 // Hidden key (to identify the visibility status of a page in its txt file)
181 Config::set('AM_KEY_HIDDEN', 'hidden');
182 // Tags key (to identify tags in the page's txt file)
183 Config::set('AM_KEY_TAGS', 'tags');
184 // Theme key (to identify a theme in the page's txt file)
185 Config::set('AM_KEY_THEME', 'theme');
186 // Title key (to identify a title in the page's txt file)
187 Config::set('AM_KEY_TITLE', 'title');
188 // Sitename key (to identify the sitename in the site's txt file)
189 Config::set('AM_KEY_SITENAME', 'sitename');
190 // URL key (to identify an URL in the page's txt file)
191 Config::set('AM_KEY_URL', 'url');
192 // System variable keys
193 Config::set('AM_KEY_FILTER', ':filter');
194 Config::set('AM_KEY_TAG', ':tag');
195 Config::set('AM_KEY_FILE', ':file');
196 Config::set('AM_KEY_BASENAME', ':basename');
197 Config::set('AM_KEY_INDEX', ':i');
198 Config::set('AM_KEY_FILELIST_COUNT', ':filelist-count');
199 Config::set('AM_KEY_PAGELIST_COUNT', ':pagelist-count');
200 Config::set('AM_KEY_CURRENT_PAGE', ':current');
201 Config::set('AM_KEY_CURRENT_PATH', ':current-path');
202 Config::set('AM_KEY_LEVEL', ':level');
203 Config::set('AM_KEY_TEMPLATE', ':template');
204 
205 // Version number
206 include AM_BASE_DIR . '/automad/version.php';
207 
208 // License key
209 Config::set('AM_LIC_KEY', '');
210 
211 
212 ?>
static log($element, $description= '')
Definition: debug.php:113
static request()
Definition: parse.php:313
static set($name, $value)
Definition: config.php:77