Index: inc/prepend.php
===================================================================
--- inc/prepend.php	(revision 1011)
+++ inc/prepend.php	(revision 1080)
@@ -12,5 +12,5 @@
 
 /* ------------------------------------------------------------------------------------------- */
-#  ClearBricks, DotClear classes auto-loader
+#  ClearBricks, Twig, DotClear classes auto-loader
 if (@is_dir('/usr/lib/clearbricks')) {
 	define('CLEARBRICKS_PATH','/usr/lib/clearbricks');
@@ -46,4 +46,5 @@
 $__autoload['dcWorkspace']			= dirname(__FILE__).'/core/class.dc.workspace.php';
 $__autoload['dcPrefs']				= dirname(__FILE__).'/core/class.dc.prefs.php';
+$__autoload['dcTwigPage']			= dirname(__FILE__).'/core/class.dc.twig.page.php';
 
 $__autoload['rsExtPost']				= dirname(__FILE__).'/core/class.dc.rs.extensions.php';
@@ -52,4 +53,5 @@
 $__autoload['rsExtUser']				= dirname(__FILE__).'/core/class.dc.rs.extensions.php';
 
+$__autoload['dcAdminContext']				= dirname(__FILE__).'/admin/class.dc.admincontext.php';
 $__autoload['dcMenu']				= dirname(__FILE__).'/admin/class.dc.menu.php';
 $__autoload['dcPage']				= dirname(__FILE__).'/admin/lib.dc.page.php';
@@ -63,8 +65,25 @@
 $__autoload['context']				= dirname(__FILE__).'/public/lib.tpl.context.php';
 $__autoload['dcUrlHandlers']			= dirname(__FILE__).'/public/lib.urlhandlers.php';
+$__autoload['dcForm']			= dirname(__FILE__).'/admin/class.dc.form.php';
+$__autoload['dcFormExtension']			= dirname(__FILE__).'/admin/class.dc.form.php';
 
 # Clearbricks extensions
 html::$absolute_regs[] = '/(<param\s+name="movie"\s+value=")(.*?)(")/msu';
 html::$absolute_regs[] = '/(<param\s+name="FlashVars"\s+value=".*?(?:mp3|flv)=)(.*?)(&|")/msu';
+
+if (@is_dir('/usr/lib/twig')) {
+	define('TWIG_PATH','/usr/lib/twig');
+} elseif (is_dir(dirname(__FILE__).'/libs/twig')) {
+	define('TWIG_PATH',dirname(__FILE__).'/libs/twig');
+} elseif (isset($_SERVER['TWIG_PATH']) && is_dir($_SERVER['TWIG_PATH'])) {
+	define('TWIG_PATH',$_SERVER['TWIG_PATH']);
+}
+
+if (!defined('TWIG_PATH') || !is_dir(TWIG_PATH)) {
+	exit('No Twig path defined');
+}
+require TWIG_PATH.'/Autoloader.php';
+Twig_Autoloader::register();
+
 /* ------------------------------------------------------------------------------------------- */
 
@@ -162,22 +181,29 @@
 } catch (Exception $e) {
 	init_prepend_l10n();
-	__error(__('Unable to connect to database')
-		,$e->getCode() == 0 ?
-		sprintf(__('<p>This either means that the username and password information in '.
-		'your <strong>config.php</strong> file is incorrect or we can\'t contact '.
-		'the database server at "<em>%s</em>". This could mean your '.
-		'host\'s database server is down.</p> '.
-		'<ul><li>Are you sure you have the correct username and password?</li>'.
-		'<li>Are you sure that you have typed the correct hostname?</li>'.
-		'<li>Are you sure that the database server is running?</li></ul>'.
-		'<p>If you\'re unsure what these terms mean you should probably contact '.
-		'your host. If you still need help you can always visit the '.
-		'<a href="http://forum.dotclear.net/">Dotclear Support Forums</a>.</p>').
-		(DC_DEBUG ?
-			__('The following error was encountered while trying to read the database:').'</p><ul><li>'.$e->getMessage().'</li></ul>' :	'')
-		,(DC_DBHOST != '' ? DC_DBHOST : 'localhost')
-		)
-		: ''
-		,20);
+	if (!defined('DC_CONTEXT_ADMIN')) {
+		__error(__('Site temporarily unavailable'),
+			__('<p>We apologize for this temporary unavailability.<br />'.
+			'Thank you for your understanding.</p>'),
+			20);
+	} else {
+		__error(__('Unable to connect to database')
+			,$e->getCode() == 0 ?
+			sprintf(__('<p>This either means that the username and password information in '.
+			'your <strong>config.php</strong> file is incorrect or we can\'t contact '.
+			'the database server at "<em>%s</em>". This could mean your '.
+			'host\'s database server is down.</p> '.
+			'<ul><li>Are you sure you have the correct username and password?</li>'.
+			'<li>Are you sure that you have typed the correct hostname?</li>'.
+			'<li>Are you sure that the database server is running?</li></ul>'.
+			'<p>If you\'re unsure what these terms mean you should probably contact '.
+			'your host. If you still need help you can always visit the '.
+			'<a href="http://forum.dotclear.net/">Dotclear Support Forums</a>.</p>').
+			(DC_DEBUG ?
+				__('The following error was encountered while trying to read the database:').'</p><ul><li>'.$e->getMessage().'</li></ul>' :	'')
+			,(DC_DBHOST != '' ? DC_DBHOST : 'localhost')
+			)
+			: ''
+			,20);
+	}
 }
 
