[Cs-content-commits] SF.net SVN: cs-content:[392] trunk/1.0/cs_siteConfig.class.php
PHP Templating & Includes System
Brought to you by:
crazedsanity
From: <cra...@us...> - 2009-06-11 15:22:57
|
Revision: 392 http://cs-content.svn.sourceforge.net/cs-content/?rev=392&view=rev Author: crazedsanity Date: 2009-06-11 15:22:55 +0000 (Thu, 11 Jun 2009) Log Message: ----------- Fix to automatically detect APPURL so it can be added to the config. NOTE::: maybe cs_siteConfig should just set the constant? Seems rather convoluted to derive where their app lives, only to allow them to put the value into a configuration file...? Future consideration, anyway. /cs_siteConfig.class.php: * parse_config(): -- the $specialVars array is created by build_special_vars(). * build_special_vars() [NEW]: -- creates the array of special vars that can be put into the config file, such as the old _DIRNAMEOFFILE_. -- this now creates "_APPURL_", which can be used to define the standard "APPURL" constant required by cs-content when the app is in a non-root subdirectory. Modified Paths: -------------- trunk/1.0/cs_siteConfig.class.php Modified: trunk/1.0/cs_siteConfig.class.php =================================================================== --- trunk/1.0/cs_siteConfig.class.php 2009-06-10 17:40:57 UTC (rev 391) +++ trunk/1.0/cs_siteConfig.class.php 2009-06-11 15:22:55 UTC (rev 392) @@ -161,10 +161,7 @@ private function parse_config() { if(is_object($this->xmlReader)) { $data = $this->xmlReader->get_path($this->xmlReader->get_root_element()); - - $specialVars = array( - '_DIRNAMEOFFILE_' => $this->configDirname - ); + $specialVars = $this->build_special_vars(); $parseThis = array(); @@ -349,6 +346,36 @@ }//end get_valid_sections() //------------------------------------------------------------------------- + + + //------------------------------------------------------------------------- + private function build_special_vars() { + //determine the current "APPURL" (current URL minus hostname and current filename) + { + $appUrl = $_SERVER['SCRIPT_NAME']; + $bits = explode('/', $appUrl); + if(!strlen($bits[0])) { + array_shift($bits); + } + if(count($bits)) { + array_pop($bits); + } + if(!count($bits)) { + $appUrl = '/'; + } + else { + $appUrl = '/'. $this->gfObj->string_from_array($bits, null, '/'); + } + } + + $specialVars = array( + '_DIRNAMEOFFILE_' => $this->configDirname, + '_APPURL_' => $appUrl + ); + return($specialVars); + }//end build_special_vars() + //------------------------------------------------------------------------- + }//end cs_siteConfig ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |