Modified:
trunk/Classes/Base/WHReflectionClass.php
trunk/Classes/Phaux-base/WHBrowser.php
Log:
Browser can now do the Hierarchy. Need to do AJAX to make is snappy and
add property browsing
Modified: trunk/Classes/Base/WHReflectionClass.php
==============================================================================
--- trunk/Classes/Base/WHReflectionClass.php (original)
+++ trunk/Classes/Base/WHReflectionClass.php Wed Oct 24 19:32:30 2007
@@ -18,4 +18,31 @@
return parent::getMethods();
}
+ /**
+ ** Returns an array of class names that
+ ** are a child of this reflected class
+ */
+ public function childClassNames(){
+ $childClasses = array();
+ foreach(get_declared_classes() as $class){
+ if(get_parent_class($class) == $this->getName()){
+ $childClasses[] = $class;
+ }
+ }
+ return $childClasses;
+ }
+
+ /**
+ ** Returns an array of classes that have not parent
+ */
+ static public function rootClasses(){
+ $rootClasses = array();
+ foreach(get_declared_classes() as $class){
+ if(!get_parent_class($class)){
+ $rootClasses[] = $class;
+ }
+ }
+ return $rootClasses;
+ }
+
}
Modified: trunk/Classes/Phaux-base/WHBrowser.php
==============================================================================
--- trunk/Classes/Phaux-base/WHBrowser.php (original)
+++ trunk/Classes/Phaux-base/WHBrowser.php Wed Oct 24 19:32:30 2007
@@ -1,5 +1,9 @@
<?php
+/**
+** A lot of the logic of this class
+** should be moved into reflection classes
+*/
class WHBrowser extends WHComponent {
public $currentClass = '';
public $currentMethod = '';
@@ -126,7 +130,21 @@
return $methodAndLabel;
}
+ public function classHierarchyWityLabel(){
+ $list = array();
+ foreach(WHReflectionClass::rootClasses() as $class){
+ $this->classAddToListWithLevel($class,$list,0);
+ }
+ return $list;
+ }
+ public function classAddToListWithLevel($class,&$list,$level){
+
foreach(Object::construct('WHReflectionClass',$class)->childClassNames()
as $class){
+ $list[$class] = str_repeat(' ',$level).$class;
+ $this->classAddToListWithLevel($class,$list,$level+1);
+ }
+ return $list;
+ }
public function currentClassReflected(){
if($this->currentClass == ''){
@@ -171,12 +189,23 @@
public function renderClassSelectionOn($html){
return
- $html->form()->with(
- $html->select()->setItems($this->classCategories())->
- size(20)->
+ $html->div()->class('class-limit')->with(
+ $html->form()->with(
+ $html->select()->setItems($this->classCategories())->
+ size(10)->
submitFormOnChange()->
callback($this,'setCurrentCategory')->
setSelectedItem($this->currentCategory)
+ ).
+
+
+ $html->form()->with(
+ $html->select()->itemsAndLabels($this->classHierarchyWityLabel())->
+ size(10)->
+ submitFormOnChange()->
+ callback($this,'setCurrentClass')->
+ setSelectedItem($this->currentClass)
+ )
).
$html->form()->with(
$html->select()->setItems($this->currentClassList())->
@@ -214,6 +243,20 @@
font-size: 12px;
}
.whbrowser select{width:200px;}
+ .whbrowser .class-limit {
+ width:201px;
+ float:left;
+ }
+ .whbrowser .class-limit select{
+ height:125px;
+
+ }
+ .whbrowser select{
+ height:252px;
+ margin:0px;
+ padding:0px;
+
+ }
';
}