//MySQL
/*
-// create engine: server, user, password
+//create engine: server-host, user, password
$db = new MysqlEngine("localhost","smoke","");
-// set database name
+//set database name
$db->setDbName("smoke");
-// set table-prefix (must be non-empty)
+//set table-prefix (must be non-empty, leave the default if in doubt)
$db->setPrefix("smoke2_");
//set this to one of the supported MySQL storage engines for DB creation
+// only change this if your server does not support InnoDB,
+// much of MagicSmoke assumes that the underlying database supports transactions!
$db->setStorageEngine("InnoDB");
//set default character set
+// only change if your database does not support Unicode
$db->setCharacterSet("utf8");
*/
//PGSQL
/*
-// create engine: connection string
+//create engine: connection string, the sub-parameters are:
+// dbname - name of the database
+// user - DB user that is used to log in to the DB server
+// password - DB user password to use (leave out if the user is identified via ident or trust method)
+// host, hostaddr - host on which the DB server runs
+// port - port on that host (leave out for default port)
+// for more see:
+// http://www.php.net/manual/en/function.pg-connect.php
+// http://www.postgresql.org/docs/8.4/interactive/libpq-connect.html
$db = new PGsqlEngine("dbname='smoke' user='smoke'");
-// set table-prefix (must be non-empty)
+//set table-prefix (must be non-empty, leave the default if in doubt)
$db->setPrefix("smoke2_");
-//set this only if you want debug messages on error:
+//set this only if you want debug messages on error (developers only):
//$db->setDebugMode();
*/
private $timezone;
/** private constructor */
- private function __construct()
+ private function __construct($xlang=false)
{
global $template;
$this->templateFolder .= "/";
//collect possible languages for this user
$langs=array();
+ //resetLanguage call
+ if($xlang!==false) $langs[]=$xlang;
// check if cookie is set
if (isset($_COOKIE[COOKIE_LANGUAGE])) {
$langs[]= $_COOKIE[COOKIE_LANGUAGE];
return self::$instance;
}
+ /** resets the singleton instance to a different language */
+ public static function resetLanguage($lang)
+ {
+ self::$instance = new LanguageManager($lang);
+ return self::$instance;
+ }
+
/** returns the configured language template folder*/
public function templateFolder()
{
$d=dirname(__FILE__);
wob_autoclass("EventRender",$d.'/event_listing.php');
wob_autoclass("WebCart",$d.'/cart_listing.php');
+wob_autoclass("TemplateCompiler",$d.'/tcompiler.php');
wob_autoclass("LangFilterExtension",$d.'/twig_extensions.php');
wob_autoclass("SmokeFilterExtension",$d.'/twig_extensions.php');
--- /dev/null
+<?
+
+class TemplateCompiler
+{
+ static public function execute()
+ {
+ global $template;
+ $tpl=$template;
+ $d=dir($template);
+ while(false !== ($entry = $d->read())) {
+ if($entry == "." || $entry == ".." || $entry == ".svn")continue;
+ if(!is_dir($template."/".$entry))continue;
+ echo "<p>entering directory ".$entry."<br>\n";
+ self::compileDir($tpl,$entry);
+ }
+ echo "<p>Done.<p>";
+ exit;
+ }
+
+ static public function compileDir($template,$lng)
+ {
+ global $twig,$basevars;
+ $lang=LanguageManager::resetLanguage($lng);
+ $d=dir($template."/".$lng);
+ $loader=new Twig_Loader_Filesystem($lang->templateFolders());
+ $twig->setLoader($loader);
+ while(false !== ($entry = $d->read())) {
+ if($entry[0] == ".")continue;
+// echo $entry;
+ if(!is_file($template."/".$lng."/".$entry))continue;
+ echo " compiling ".$entry."... ";
+ $twig->loadTemplate($entry)->render($basevars);
+ echo "<br>\n";
+ }
+ }
+}
\ No newline at end of file
{
private $lang;
- public function getFilters()
+ public function __construct()
{
$this->lang=LanguageManager::singleton();
+ }
+
+ public function getFilters()
+ {
return array(
'asMoney' => new Twig_Filter_Method($this, 'getPrice'),
'asDate' => new Twig_Filter_Method($this, 'getDate'),
class SmokeFilterExtension extends Twig_Extension
{
- public function getFilters()
+ public function __construct()
{
$this->lang=LanguageManager::singleton();
+ }
+
+ public function getFilters()
+ {
return array(
'isObject' => new Twig_Filter_Method($this, 'isObject'),
'isFalse' => new Twig_Filter_Method($this, 'isFalse'),
case "setlanguage":
LanguageManager::setLanguage();
break;
+ case "compile":
+ TemplateCompiler::execute();
+ break;
default:
$page=EventRender::createEventList();
break;
xln index.php
xln machine.php
xln translations
+xln .htaccess
xcp(){
a=$TARGET/$1
xcp styles
xcp template
-xcp config.php config.php.template
\ No newline at end of file
+xcp config.php config.php.template
{# Example Template for MagicSmoke
================================
- this one is called to show the cart
+ this one is called to show the cart of a customer
#}
{% extends 'layout.html' %}