Added:
trunk/Classes/Phaux-base/WHBrowser.php
Modified:
trunk/Classes/Phaux-base/WHComponent.php
trunk/Classes/Phaux-base/WHSessionSize.php
trunk/Classes/Phaux-base/phaux-base.php
trunk/Classes/Phaux-render/WHSelectTag.php
trunk/Classes/Phaux-test/WHNavigationTest.php
Log:
The start of a source browser
Added: trunk/Classes/Phaux-base/WHBrowser.php
==============================================================================
--- (empty file)
+++ trunk/Classes/Phaux-base/WHBrowser.php Tue Oct 23 19:53:41 2007
@@ -0,0 +1,127 @@
+<?php
+
+class WHBrowser extends WHComponent {
+ public $currentClass = '';
+ public $currentMethod = '';
+
+
+ public function setCurrentClass($aString){
+ $this->currentMethod = '';
+ $this->currentClass = $aString;
+ return $this;
+ }
+ public function currentClass(){
+ return $this->currentClass;
+ }
+
+ public function setCurrentMethod($aString){
+ $this->currentMethod = $aString;
+ return $this;
+ }
+ public function currentMethod(){
+ return $this->currentMethod;
+ }
+
+
+ public function classList(){
+ $classes = get_declared_classes();
+ asort($classes);
+ return $classes;
+ }
+
+ public function methodList(){
+ if($this->currentClass == ''){
+ return array();
+ }
+ /*
+ ** Reflection objects can't survive serialization
+ ** so we need to use the strings
+ */
+
+ $methods = $this->currentClassReflected()->getMethods();
+ $methodNames = array();
+ foreach($methods as $method){
+ $methodNames[] = $method->getName();
+ }
+ asort($methodNames);
+ return $methodNames;
+ }
+
+ public function currentClassReflected(){
+ if($this->currentClass == ''){
+ $this->error('You need to set the class string with setCurrentClass first');
+ }
+
+ return Object::construct('ReflectionClass',$this->currentClass);
+ }
+ public function currentMethodReflected(){
+ if($this->currentMethod == ''){
+ $this->error('You need to set the method string with
setCurrentMethod first');
+ }
+
+ /*
+ ** Shudder This just feals like procedural code
+ */
+ return new ReflectionMethod($this->currentClass,$this->currentMethod);
+ }
+
+
+ public function currentMethodComment(){
+ return $this->currentMethodReflected->getDocComment();
+ }
+ public function currentClassComment(){
+ return $this->currentClassReflected()->getDocComment();
+ }
+ public function currentMethodSource(){
+ if($this->currentMethod == ''){
+ return '';
+ }
+ $classSource = file($this->currentMethodReflected()->getFileName());
+
+ return $this->currentMethodReflected()->getDocComment(). " \n".
+ implode('',array_slice($classSource,$this->currentMethodReflected()->getStartLine()-1,
+ $this->currentMethodReflected()->getEndLine() -
+ $this->currentMethodReflected()->getStartLine()+1));
+
+ }
+
+ public function renderClassSelectionOn($html){
+ return $html->form()->with(
+ $html->select()->setItems($this->classList())->
+ size(10)->
+ submitFormOnChange()->
+ callback($this,'setCurrentClass')->
+ setSelectedItem($this->currentClass)
+ ).
+ $html->form()->with(
+ $html->select()->setItems($this->methodList())->
+ size(10)->
+ submitFormOnChange()->
+ callback($this,'setCurrentMethod')->
+ setSelectedItem($this->currentMethod)
+ );
+ }
+
+ public function renderMethodSourceOn($html){
+ return $html->div()->class('whbrowser-source')->
+ with(highlight_string("<?php\n".
+ $this->currentMethodSource(),true));
+ }
+
+ public function renderContentOn($html){
+ return $html->div()->class('whbrowser')->with(
+ $this->renderClassSelectionOn($html).
+ $this->renderMethodSourceOn($html)
+ );
+ }
+
+ public function style(){
+ return '
+ .whbrowser form{display:inline;}
+ .whbrowser-source {
+ font-size: 14px;
+ }
+ ';
+ }
+
+}
\ No newline at end of file
Modified: trunk/Classes/Phaux-base/WHComponent.php
==============================================================================
--- trunk/Classes/Phaux-base/WHComponent.php (original)
+++ trunk/Classes/Phaux-base/WHComponent.php Tue Oct 23 19:53:41 2007
@@ -71,10 +71,7 @@
return $return;
}
- public function renderContentOn($html){
- $this->subclassResponsibility("renderContentOn");
- return $this;
- }
+ abstract public function renderContentOn($html);
public function callDialog($aComponent){
@@ -213,11 +210,16 @@
if(is_object($this->parentComponent)){
$this->parentComponent->restoreSelf();
}
+ return $this;
}
public function restoreSelf(){
$this->dialog = NULL;
- $this->dialogCallback = NULL;
+ /*
+ **This was wrong ?
+ */
+ //$this->dialogCallback = NULL;
+ return $this;
}
public function thisOrDialog(){
Modified: trunk/Classes/Phaux-base/WHSessionSize.php
==============================================================================
--- trunk/Classes/Phaux-base/WHSessionSize.php (original)
+++ trunk/Classes/Phaux-base/WHSessionSize.php Tue Oct 23 19:53:41 2007
@@ -71,7 +71,9 @@
if(!isset($this->summaryTable[$object->getClass()])){
$this->summaryTable[$object->getClass()] = array();
}
-
+ if(!isset($this->summaryTable[$object->getClass()]['total'])){
+ $this->summaryTable[$object->getClass()]['total'] = 0;
+ }
++$this->summaryTable[$object->getClass()]['total'];
foreach($object->objectVars() as $var => $value){
@@ -81,6 +83,9 @@
}elseif(is_array($value)){
$this->processArrayForObject($value,$object);
}elseif(!is_resource($value) && !is_null($value)){
+ if(!isset($this->summaryTable[$object->getClass()]['size'])){
+ $this->summaryTable[$object->getClass()]['size'] = 0;
+ }
$this->summaryTable[$object->getClass()]['size'] += $this->sizeForVar($value);
}
}
Modified: trunk/Classes/Phaux-base/phaux-base.php
==============================================================================
--- trunk/Classes/Phaux-base/phaux-base.php (original)
+++ trunk/Classes/Phaux-base/phaux-base.php Tue Oct 23 19:53:41 2007
@@ -24,4 +24,5 @@
include('WHPathDecoration.php');
include('WHWorkspace.php');
include('WHModelDecoration.php');
-include('WHMessageDecoration.php');
\ No newline at end of file
+include('WHMessageDecoration.php');
+include('WHBrowser.php');
\ No newline at end of file
Modified: trunk/Classes/Phaux-render/WHSelectTag.php
==============================================================================
--- trunk/Classes/Phaux-render/WHSelectTag.php (original)
+++ trunk/Classes/Phaux-render/WHSelectTag.php Tue Oct 23 19:53:41 2007
@@ -35,7 +35,7 @@
return $this;
}
- /*
+ /**
**This must be run after all items have been added to the select
** and before you call with()
** You can not set the callback for a select before adding the items
@@ -54,7 +54,7 @@
return $this;
}
- /*
+ /**
** anArray should look like
** "label"=>$item
*/
@@ -65,7 +65,7 @@
return $this;
}
- /*
+ /**
** anArray should look like
** $item=>"label"
*/
@@ -82,10 +82,12 @@
if($this->methodForLabel != NULL
&& is_object($anItem)
- && $anItem->hasMethod($this->methodForLabel)){
-
- return $anItem->perform($this->methodForLabel,array());
+ && method_exists($anItem,$this->methodForLabel)){
+ $m = $this->methodForLabel;
+
+ return $anItem->$m();
}
+
return $anItem;
}
$label = $this->labels[$this->indexForItem($anItem)];
Modified: trunk/Classes/Phaux-test/WHNavigationTest.php
==============================================================================
--- trunk/Classes/Phaux-test/WHNavigationTest.php (original)
+++ trunk/Classes/Phaux-test/WHNavigationTest.php Tue Oct 23 19:53:41 2007
@@ -15,7 +15,8 @@
addWithLabel(Object::construct("WHDialogTest"),"Dialog test")->
addWithLabel(Object::construct("WHLiveTest"),"AJAX Test")->
addWithLabel(Object::construct("WHExceptionTest"),"Exception Text")->
- addWithLabel($this->plotTest(),'Plot Test');
+ addWithLabel($this->plotTest(),'Plot Test')->
+ addWithLabel(Object::construct('WHBrowser'),'Browser Test');
return $this;
}