From: konrad Date: Mon, 19 Jul 2010 19:59:45 +0000 (+0000) Subject: restricted template compiler to admin X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=a9f728b8a7d245a3415449dac4fc0850a4803240;p=web%2Fkonrad%2Fsmoke.git restricted template compiler to admin fix some typos in template docu git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@568 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/doc/template.html b/doc/template.html index e493526..8deb1d4 100644 --- a/doc/template.html +++ b/doc/template.html @@ -7,7 +7,7 @@ The web user interface is constructed with templates with just a few dynamic values filled in. Those templates are found in the template/* directories. These templates are normal HTML or text with some special constructs to fill in the blanks.

-Please see the Twig template engine documentation for syntax details. +Please see the Twig template engine documentation for syntax details.

Template Files

diff --git a/www/inc/rendering/tcompiler.php b/www/inc/rendering/tcompiler.php index fb1f5a7..027e60e 100644 --- a/www/inc/rendering/tcompiler.php +++ b/www/inc/rendering/tcompiler.php @@ -1,9 +1,13 @@ entering directory ".$entry."
\n"; self::compileDir($tpl,$entry); } + //done echo "

Done.

"; exit; } - static public function compileDir($template,$lng) + /**compiles all template files of one specific directory*/ + static private function compileDir($template,$lng) { global $twig,$basevars; + //reset the language manager to match the current directories' language $lang=LanguageManager::resetLanguage($lng); + //go through all files $d=dir($template."/".$lng); $loader=new Twig_Loader_Filesystem($lang->templateFolders()); $twig->setLoader($loader); while(false !== ($entry = $d->read())) { + //ignore anything that starts with a dot if($entry[0] == ".")continue; -// echo $entry; + //only handle normal files if(!is_file($template."/".$lng."/".$entry))continue; + //actually load and (implicitly) compile it echo "   compiling ".$entry."... "; $twig->loadTemplate($entry)->render($basevars); echo "
\n"; } } + + /**check whether the user is admin*/ + static private function checkAdmin() + { + global $db; + if(!$db->canAdministrate()) + die("The Administratpr account is turned off. Sorry. Cannot compile templates for you."); + if(!$db->checkAdmin()){ + header("HTTP/1.0 401 Unauthorized"); + header("WWW-Authenticate: Basic realm=\"Smoke Admin Login\""); + echo "Need to login in order to administrate."; + exit; + }else + echo "Compiling all templates I can find...

\n"; + } } \ No newline at end of file