[Cs-content-commits] SF.net SVN: cs-content:[452] trunk/1.0/contentSystem.class.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-08-20 16:33:08
|
Revision: 452 http://cs-content.svn.sourceforge.net/cs-content/?rev=452&view=rev Author: crazedsanity Date: 2009-08-20 16:32:56 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Set some commonly-used template vars. /contentSystem.class.php: * initialize_locals(): -- add an array of commonly-used vars::: ++ date ++ time ++ curYear ++ curDate ++ curMonth ++ timezone ++ DOMAIN ++ PHP_SELF ++ REQUEST_URI ++ FULL_URL ++ error_msg -- use a simple foreach loop to set them into templateObj. Modified Paths: -------------- trunk/1.0/contentSystem.class.php Modified: trunk/1.0/contentSystem.class.php =================================================================== --- trunk/1.0/contentSystem.class.php 2009-08-20 16:13:49 UTC (rev 451) +++ trunk/1.0/contentSystem.class.php 2009-08-20 16:32:56 UTC (rev 452) @@ -149,10 +149,24 @@ $this->templateObj = new cs_genericPage(FALSE, $root ."/templates/main.shared.tmpl"); //setup some default template vars. - $this->templateObj->add_template_var('date', date('m-d-Y')); - $this->templateObj->add_template_var('time', date('H:i:s')); - $this->templateObj->add_template_var('curYear', date('Y')); + $defaultVars = array( + 'date' => date('m-d-Y'), + 'time' => date('H:i:s'), + 'curYear' => date('Y'), + 'curDate' => date("F j, Y"), + 'curMonth' => date("m"), + 'timezone' => date("T"), + 'DOMAIN' => $_SERVER['SERVER_NAME'], + 'PHP_SELF' => $_SERVER['SCRIPT_NAME'], + 'REQUEST_URI' => $_SERVER['REQUEST_URI'], + 'FULL_URL' => $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME'], + 'error_msg' => "" + ); + foreach($defaultVars as $k=>$v) { + $this->templateObj->add_template_var($k, $v); + } + $myUrl = '/'; if(strlen($this->section) && $this->section !== 0) { $myUrl = '/'. $this->section; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |