Added:
trunk/Classes/REServe/REText.php
trunk/HtmlRoot/resource.php
Modified:
trunk/Classes/Phaux-base/WHConfiguration.php
trunk/Classes/Phaux-base/WHSession.php
trunk/Configuration/base.ini
trunk/Configuration/navigationtest.ini
trunk/HtmlRoot/phaux.php
trunk/HtmlRoot/scripts-standard/standardScript.js
Log:
reserve text, new resource locater, and some clean up of phaux.php
Modified: trunk/Classes/Phaux-base/WHConfiguration.php
==============================================================================
--- trunk/Classes/Phaux-base/WHConfiguration.php (original)
+++ trunk/Classes/Phaux-base/WHConfiguration.php Mon Oct 8 12:03:55 2007
@@ -74,6 +74,53 @@
return $this->configValueBySubjectAndKey('general','use_cookie');
}
+ public function sessionClass(){
+ return $this->configValueBySubjectAndKey('general','session_class');
+ }
+
+ public function mainClass(){
+ return $this->configValueBySubjectAndKey('general','main_class');
+ }
+
+ public function redirectAfterCallback(){
+ return $this->configValueBySubjectAndKey('general','redirect_after_callback');
+ }
+
+ public function styles(){
+ return $this->configValues['styles'];
+ }
+
+ public function scripts(){
+ return $this->configValues['scripts'];
+ }
+
+ public function renderClass(){
+ return $this->configValueBySubjectAndKey('general','render_class');
+ }
+
+ /*
+ **Supplying the path would be a good idea as well
+ */
+ static function parseConfigurationFileForApp($appName){
+ $base_configuration = parse_ini_file("../Configuration/base.ini",TRUE);
+ if(eregi('^[A-Z_0-9_.]*$', $appName) && file_exists('../Configuration/'.$appName.'.ini')){
+ $new_conf = parse_ini_file('../Configuration/'.$appName.'.ini',TRUE);
+ foreach($new_conf as $section => $values){
+ if(isset($base_configuration[$section]) && is_array($base_configuration[$section])){
+ $new_conf[$section] = array_merge($base_configuration[$section],$values);
+ }
+ }
+ foreach($base_configuration as $section =>$values){
+ if(!isset($new_conf[$section])){
+ $new_conf[$section] = $values;
+ }
+ }
+ return $new_conf;
+ }
+ return NULL;
+ }
+
+
static function startUpOnAppWithIni($app,$app_configuration){
ini_set("session.use_cookies",$app_configuration['general']['use_cookie']);
@@ -85,5 +132,22 @@
setConfigValues($app_configuration);
return $configuration;
+ }
+
+ static function currentApplicationName(){
+ if(!isset($_REQUEST['app'])){
+ $path_portions = explode('/', $_SERVER['PATH_INFO']);
+ $app = $path_portions[1];
+ $_REQUEST['app'] = $app;
+ }else{
+ $app = $_REQUEST['app'];
+ }
+ return $app;
+ }
+
+ static function render404(){
+ header("HTTP/1.0 404 Not Found");
+ echo("<h1>No such application $app </h1>");
+ exit;
}
}
Modified: trunk/Classes/Phaux-base/WHSession.php
==============================================================================
--- trunk/Classes/Phaux-base/WHSession.php (original)
+++ trunk/Classes/Phaux-base/WHSession.php Mon Oct 8 12:03:55 2007
@@ -167,7 +167,6 @@
}
public function configuration(){
-
return $_SESSION[$this->appName]['configuration'];
}
Added: trunk/Classes/REServe/REText.php
==============================================================================
--- (empty file)
+++ trunk/Classes/REServe/REText.php Mon Oct 8 12:03:55 2007
@@ -0,0 +1,7 @@
+<?php
+
+class REText extends REString {
+ public static function reServeType(){
+ return "text";
+ }
+}
\ No newline at end of file
Modified: trunk/Configuration/base.ini
==============================================================================
--- trunk/Configuration/base.ini (original)
+++ trunk/Configuration/base.ini Mon Oct 8 12:03:55 2007
@@ -24,7 +24,8 @@
secure=0 #Not yet used
[includes]
-RECall="../Classes/Phaux-base/phaux-base.php"
+#Now assumed
+#Phaux ../Classes/Phaux-base/phaux-base.php
Render="../Classes/Phaux-render/phaux-render.php"
[styles]
@@ -33,4 +34,7 @@
kalseyTabs="styles-standard/kalseyTabs.css"
[scripts]
-standard="scripts-standard/standardScript.js"
\ No newline at end of file
+standard="scripts-standard/standardScript.js"
+
+#Dicectories were you keep css/js/images should be listed here
+[resources]
\ No newline at end of file
Modified: trunk/Configuration/navigationtest.ini
==============================================================================
--- trunk/Configuration/navigationtest.ini (original)
+++ trunk/Configuration/navigationtest.ini Mon Oct 8 12:03:55 2007
@@ -1,6 +1,6 @@
[general]
main_class="WHNavigationTest"
-
+use_cookie="0"
[includes]
Phaux-test="../Classes/Phaux-test/phaux-test.php"
Phaux-extras="../Classes/Phaux-extras/phaux-extras.php"
Modified: trunk/HtmlRoot/phaux.php
==============================================================================
--- trunk/HtmlRoot/phaux.php (original)
+++ trunk/HtmlRoot/phaux.php Mon Oct 8 12:03:55 2007
@@ -20,67 +20,46 @@
}
include("../Classes/Base/base.php");
+include("../Classes/Phaux-base/phaux-base.php");
$errorHandler = Object::construct("WHErrorHandler")->start();
-$base_configuration = parse_ini_file("../Configuration/base.ini",TRUE);
$app_configurations = array();
-if(!isset($_REQUEST['app'])){
- $path_portions = explode('/', $_SERVER['PATH_INFO']);
- $app = $path_portions[1];
- $_REQUEST['app'] = $app;
-}else{
- $app = $_REQUEST['app'];
-}
-//var_dump($_SERVER);
+$app = WHConfiguration::currentApplicationName();
/* FIXME
** Currently Phaux parses the INI file on every request
** This is excessive. We should only parse the ini file
** at the start of a session and use the configuration
** from the last session if present
+**
+** The problem is that we can't restore the session untill
+** the includes have been processes and the includes
+** are stored in the session and in the INI files
*/
-if(eregi('^[A-Z_0-9_.]*$', $app) && file_exists('../Configuration/'.$app.'.ini')){
- $app_configurations[$app] = $base_configuration;
- $new_conf = parse_ini_file('../Configuration/'.$app.'.ini',TRUE);
-
- foreach($new_conf as $section => $values){
- if(isset($base_configuration[$section]) && is_array($base_configuration[$section])){
- $new_conf[$section] = array_merge($base_configuration[$section],$values);
- }
- }
- foreach($base_configuration as $section =>$values){
- if(!isset($new_conf[$section])){
- $new_conf[$section] = $values;
- }
- }
-
- $app_configurations[$app] = $new_conf;
-}
+$app_configurations[$app] = WHConfiguration::parseConfigurationFileForApp($app);
if($app_configurations[$app] == NULL){
- header("HTTP/1.0 404 Not Found");
- echo("<h1>No such application $app </h1>");
$errorHandler->end();
- exit;
+ WHConfiguration::render404();
}else{
-
-
+
+ /*
+ **We must include before we construct the configuration
+ */
foreach($app_configurations[$app]['includes'] as $var => $value){
- include("$value");
- }
+ include($value);
+ }
- ini_set("session.use_cookies",$app_configurations[$app]['general']['use_cookie']);
- ini_set("session.name","SID");
-
$configuration_class = $app_configurations[$app]['general']['configuration_class'];
$configuration = Object::construct($configuration_class);
$configuration->setApplicationName($app)->
setConfigValues($app_configurations[$app]);
-
- $session_class = $app_configurations[$app]['general']['session_class'];
-
+ ini_set("session.use_cookies",$configuration->useCookie());
+ ini_set("session.name","SID");
+
+ $session_class = $configuration->sessionClass();
$session = call_user_func(array(
Object::construct($session_class),
"startSessionOnAppWithConfiguration"),$app,$configuration);
@@ -138,7 +117,7 @@
}
if(!isset($_SESSION[$app]['mainComponent'])){
- $main_class = $app_configurations[$app]['general']['main_class'];
+ $main_class = $configuration->mainClass();
$_SESSION[$app]['mainComponent'] = Object::construct($main_class);
if($configuration->debugMode()){
$_SESSION[$app]['mainComponent']->addDecoration(
@@ -158,7 +137,7 @@
if($REDIRECT){
- if($app_configurations[$app]['general']['redirect_after_callback'] == 1){
+ if($configuration->redirectAfterCallback() == 1){
$_SESSION[$app]['session']->save();
$urlExtra = $htmlRoot->getExtraUrl();
header("Location: ".$_SESSION[$app]['session']->url().$urlExtra);
@@ -174,11 +153,11 @@
}
}
-foreach($app_configurations[$app]['styles'] as $var => $value){
+foreach($configuration->styles() as $var => $value){
$htmlRoot->needsStyle($value);
}
-foreach($app_configurations[$app]['scripts'] as $var => $value){
+foreach($configuration->scripts() as $var => $value){
$htmlRoot->needsScript($value);
}
@@ -192,7 +171,7 @@
}
}
-$html = WHHtmlCanvas::construct($app_configurations[$app]['general']['render_class']);
+$html = WHHtmlCanvas::construct($configuration->renderClass());
if(!isset($_REQUEST['_lu']) || $_REQUEST['_lu'] == ""){
Added: trunk/HtmlRoot/resource.php
==============================================================================
--- (empty file)
+++ trunk/HtmlRoot/resource.php Mon Oct 8 12:03:55 2007
@@ -0,0 +1,50 @@
+<?php
+/*
+** This file will serve up resoureces that are outside
+** your sourece directory.
+** Specify the resource directories in your ini file
+** under the section resources
+*/
+include("../Classes/Base/base.php");
+include("../Classes/Phaux-base/phaux-base.php");
+$app = WHConfiguration::currentApplicationName();
+if(!$app){
+ WHConfiguration::render404();
+}
+$config = WHConfiguration::parseConfigurationFileForApp($app);
+$resourceDirs = $config['resources'];
+$path_portions = explode('/', $_SERVER['PATH_INFO']);
+$resource = $path_portions[2];
+
+if(!eregi('^[A-Z_0-9_.]*$', $resource)){
+ WHConfiguration::render404();
+ exit;
+}
+
+$typesForExt = array('css'=>'text/css',
+ 'html'=>'text/html',
+ 'jpg'=>'image/jpeg',
+ 'gif'=>'image/gif',
+ 'png'=>'image/png');
+
+foreach($resourceDirs as $dir){
+ if(is_file($dir.'/'.$resource)){
+ $offset = 3600 * 24;
+ header('Expires: ' . gmdate("D, d M Y H:i:s", time() + $offset) . ' GMT');
+ header('Cache-control: public, must-revalidate');
+ header('Content-Length: '.filesize($dir.'/'.$resource));
+ $gmt_mtime = gmdate('D, d M Y H:i:s', filemtime($dir.'/'.$resource)
) . ' GMT';
+ header('Last-Modified: '.$gmt_mtime);
+ $eparts = explode('.',$resource);
+ $ext = $eparts[count($eparts)-1];
+ $mime = $typesForExt[$ext];
+ if(!$mime){
+ $mime = 'application/octet-stream';
+ }
+ header('Content-Type: '.$mime);
+ readfile($dir.'/'.$resource);
+ }
+
+}
+
+WHConfiguration::render404();
\ No newline at end of file
Modified: trunk/HtmlRoot/scripts-standard/standardScript.js
==============================================================================
--- trunk/HtmlRoot/scripts-standard/standardScript.js (original)
+++ trunk/HtmlRoot/scripts-standard/standardScript.js Mon Oct 8
12:03:55 2007
@@ -181,6 +181,7 @@
}
}else /*if (child.tagName == "innerHtml")*/ {
var elementId = child.getAttribute("id");
+
var element = document.getElementById(elementId);
if(child.firstChild.data){
element.innerHTML = child.firstChild.data;