Modified:
trunk/Classes/Phaux-base/WHComponent.php
trunk/Classes/Phaux-base/WHDialog.php
trunk/HtmlRoot/resource.php
trunk/HtmlRoot/scripts-standard/standardScript.js
Log:
Fixed multiple inclusion of style and script (and compacted the
functionality of both)
Modified: trunk/Classes/Phaux-base/WHComponent.php
==============================================================================
--- trunk/Classes/Phaux-base/WHComponent.php (original)
+++ trunk/Classes/Phaux-base/WHComponent.php Wed Oct 10 19:05:42 2007
@@ -242,59 +242,54 @@
return '';
}
- public function styleOfThisAndChildren(){
- $return = $this->thisOrDialog()->style();
+
+ /*
+ ** Brevity over clearity? You be the judge
+ ** I am trying desperately not to be clever while
+ ** managing to do something clever.
+ */
+ public function &addKeyOfThisAndChildrenToArray(&$anArray,$methodKey){
+ $anArray[$this->thisOrDialog()->getClass()] = $this->thisOrDialog()->$methodKey();
foreach($this->thisOrDialog()->children() as $child){
- $return .= $child->thisOrDialog()->styles();
+ $child->thisOrDialog()->addKeyToArray($anArray,$methodKey);
}
- return $return;
+ return $anArray;
}
- public function styleOfDecorations(){
- $return = '';
+ public function &addKeyOfDecorationsToArray(&$anArray,$methodKey){
if($this->thisOrDialog() !== $this){
- $return .= $this->thisOrDialog()->styleOfDecorations();
+ $this->thisOrDialog()->addKeyOfDecorationsToArray($anArray,$methodKey);
}
foreach($this->decorations as $decoration){
- $return .= $decoration->styleOfThisAndChildren();
-
+ $decoration->addKeyOfThisAndChildrenToArray($anArray,$methodKey);
}
- return $return;
+ return $anArray;
+ }
+
+ public function &addKeyToArray(&$anArray,$methodKey){
+ $this->addKeyOfThisAndChildrenToArray($anArray,$methodKey);
+ $this->addKeyOfDecorationsToArray($anArray,$methodKey);
+ return $anArray;
}
public function styles(){
- return $this->styleOfThisAndChildren() .
- $this->styleOfDecorations();
+ $array = array();
+ $this->addKeyToArray($array,'style');
+ return implode(' ',$array);
}
- public function updateRoot($anHtmlRoot){
- if($anHtmlRoot->title() == ""){
- $anHtmlRoot->setTitle("Phaux");
- }
- foreach($this->decorations() as $decoration){
- $decoration->updateRoot($anHtmlRoot);
- }
- return $this;
- }
-
-
- final function updateRootWithChildren($anHtmlRoot){
- if($this->dialog != NULL){
- $this->updateRoot($anHtmlRoot);
- }
- $this->thisOrDialog()->updateRoot($anHtmlRoot);
- foreach($this->thisOrDialog()->children() as $child){
- $child->thisOrDialog()->updateRootWithChildren($anHtmlRoot);
- }
-
- return $this;
- }
-
public function script(){
return "";
}
+ public function scripts(){
+ $array = array();
+ $this->addKeyToArray($array,'script');
+ return implode(' ',$array);
+ }
+
+
public function styleLink(){
if($this->style() != ""){
return "<link type=\"text/css\" ".
@@ -313,30 +308,28 @@
}
}
- public function scriptOfThisAndChildren(){
- $return = $this->thisOrDialog()->script();
- foreach($this->thisOrDialog()->children() as $child){
- $return .= $child->thisOrDialog()->scripts();
- }
-
- return $return;
- }
- public function scriptOfDecorations(){
- $return = '';
- if($this->thisOrDialog() !== $this){
- $return .= $this->thisOrDialog()->scriptOfDecorations();
+ public function updateRoot($anHtmlRoot){
+ if($anHtmlRoot->title() == ""){
+ $anHtmlRoot->setTitle("Phaux");
}
- foreach($this->thisOrDialog()->decorations() as $decoration){
- $return .= $decoration->script();
+ foreach($this->decorations() as $decoration){
+ $decoration->updateRoot($anHtmlRoot);
}
- return $return;
+ return $this;
}
-
- public function scripts(){
- return $this->scriptOfThisAndChildren() .
- $this->scriptOfDecorations();
-
+
+
+ final function updateRootWithChildren($anHtmlRoot){
+ if($this->dialog != NULL){
+ $this->updateRoot($anHtmlRoot);
+ }
+ $this->thisOrDialog()->updateRoot($anHtmlRoot);
+ foreach($this->thisOrDialog()->children() as $child){
+ $child->thisOrDialog()->updateRootWithChildren($anHtmlRoot);
+ }
+
+ return $this;
}
}
Modified: trunk/Classes/Phaux-base/WHDialog.php
==============================================================================
--- trunk/Classes/Phaux-base/WHDialog.php (original)
+++ trunk/Classes/Phaux-base/WHDialog.php Wed Oct 10 19:05:42 2007
@@ -1,7 +1,7 @@
<?php
abstract class WHDialog extends WHComponent{
protected $errors = array();
-
+
public function addValidationError($aString){
$this->errors[] = $aString;
}
@@ -32,7 +32,7 @@
$buttons = $this->buttons();
return $buttons[$label];
}
-
+
/*
**Does not work
*/
@@ -53,6 +53,8 @@
}
}
+
+
public function renderButtonsOn($html){
Modified: trunk/HtmlRoot/resource.php
==============================================================================
--- trunk/HtmlRoot/resource.php (original)
+++ trunk/HtmlRoot/resource.php Wed Oct 10 19:05:42 2007
@@ -30,7 +30,7 @@
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('Expires: Thu, 15 Apr 2010 20:00:00 GMT');
header('Cache-control: public');
header('Content-Length: '.filesize($dir.'/'.$resource));
$gmt_mtime = gmdate('D, d M Y H:i:s', filemtime($dir.'/'.$resource)
) . ' GMT';
Modified: trunk/HtmlRoot/scripts-standard/standardScript.js
==============================================================================
--- trunk/HtmlRoot/scripts-standard/standardScript.js (original)
+++ trunk/HtmlRoot/scripts-standard/standardScript.js Wed Oct 10
19:05:42 2007
@@ -190,6 +190,7 @@
for(i=0; i < child.childNodes.length; i++) {
iHtml = iHtml + xmlAsString(child.childNodes[i]);
}
+
element.innerHTML = iHtml;
}