summaryrefslogtreecommitdiff
path: root/buildscripts/classtree
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/classtree')
-rw-r--r--buildscripts/classtree/DWExtension.php508
-rw-r--r--buildscripts/classtree/build.php516
2 files changed, 512 insertions, 512 deletions
diff --git a/buildscripts/classtree/DWExtension.php b/buildscripts/classtree/DWExtension.php
index f85f100d..8849efea 100644
--- a/buildscripts/classtree/DWExtension.php
+++ b/buildscripts/classtree/DWExtension.php
@@ -1,255 +1,255 @@
-<?php
-
-/**
- * PradoVTMDocument class
- *
- * @author Stanislav Yordanov <stanprog[at]stanprog.com>
- * @author Qiang Xue <qiang.xue@gmail.com>
- */
-class PradoVTMDocument
-{
- private $_document;
- private $_attributes;
-
- public function __construct($controlName)
- {
- $this->_document = new DOMDocument('1.0', 'utf-8');
- $this->prepareDocument($controlName);
- }
-
- protected function prepareDocument($controlName)
- {
- $this->_document->formatOutput = true;
-
- //--- add <tag>
- $tag = $this->_document->createElement('tag');
- $tag->setAttribute('name',$controlName);
- $tag->setAttribute('casesensitive','yes');
- $this->_document->appendChild($tag);
-
- //--- add <tagformat>
- $tagFormat = $this->_document->createElement('tagformat');
- $tagFormat->setAttribute('nlbeforetag','1');
- $tagFormat->setAttribute('nlaftertag','1');
- $tagFormat->setAttribute('indentcontents','yes');
- $tag->appendChild($tagFormat);
-
- //--- add <tagdialog file="Control.htm" />
- //$tagDialog = $this->_document->createElement('tagdialog');
- //$tagDialog->setAttribute('file',$controlName.'.htm');
- //$tag->appendChild($tagDialog);
-
- $this->_attributes = $this->_document->createElement('attributes');
- $tag->appendChild($this->_attributes);
- }
-
- public function getDocument()
- {
- return $this->_document;
- }
-
- public function addAttribute($attribName, $attribType)
- {
- //--- add <attrib>
- $attrib = $this->_document->createElement('attrib');
- $attrib->setAttribute('name',$attribName);
- if (is_array($attribType))
- {
- $attrib->setAttribute('type','Enumerated');
- foreach ($attribType as $value)
- {
- $option = $this->_document->createElement('attriboption');
- $option->setAttribute('value',$value);
- $option->setAttribute('caption','');
- $attrib->appendChild($option);
- }
- }
- else if($attribType!=='')
- {
- $attrib->setAttribute('type',$attribType);
- }
- $attrib->setAttribute('casesensitive','yes');
- $this->_attributes->appendChild($attrib);
- }
-
- public function addEvent($eventName)
- {
- //--- add <attrib>
- $this->addAttribute($eventName,'');
- //--- add <event>
- $event = $this->_document->createElement('event');
- $event->setAttribute('name',$eventName);
- $this->_attributes->appendChild($event);
- }
-
- public function getXML()
- {
- return $this->_document->saveXML();
- }
-}
-
-/**
- * PradoMXIDocument class
- *
- * @author Stanislav Yordanov <stanprog@stanprog.com>
- * @author Qiang Xue <qiang.xue@gmail.com>
- */
-class PradoMXIDocument
-{
- private $_tagLibraryElement;
- private $_filesElement;
- private $_document;
-
- public function __construct($version)
- {
- $this->_document = new DOMDocument('1.0', 'utf-8');
- $this->prepareDocument($version);
- }
-
- protected function prepareDocument($version)
- {
- $this->_document->formatOutput = true;
- //--- add root element
- $rootElement = $this->_document->createElement('macromedia-extension');
- $rootElement->setAttribute('name','PRADO Taglib');
- $rootElement->setAttribute('version',$version);
- $rootElement->setAttribute('type','Suite');
- $rootElement->setAttribute('requires-restart','true');
- $this->_document->appendChild($rootElement);
- //--- add <author>
- $element = $this->_document->createElement('author');
- $element->setAttribute('name','Stanislav Yordanov, Qiang Xue');
- $rootElement->appendChild($element);
- $time = date('F j, Y, h:i:s a',time());
- //--- add <description>
- $description = <<<EOD
-PRADO $version Tag Library
-Authors: Stanislav Yordanov <stanprog@stanprog.com> and Qiang Xue <qiang.xue@gmail.com>
-Time: $time
-Requirement: Macromedia Dreamweaver MX/MX 2004/8.0 or above
-Description: This suite adds PRADO tag library. The tag library contains PRADO component
-tags, properties and events that are commonly used on PRADO templates.
-EOD;
- $element = $this->_document->createElement('description');
- $element->appendChild($this->_document->createCDATASection($description));
- $rootElement->appendChild($element);
- //--- add <products>
- $productsElement = $this->_document->createElement('products');
- $rootElement->appendChild($productsElement);
- //--- add <product>
- $product = $this->_document->createElement('product');
- $product->setAttribute('name','Dreamweaver');
- $product->setAttribute('version','6');
- $product->setAttribute('primary','false');
- $productsElement->appendChild($product);
- //--- add <ui-access>
- $element = $this->_document->createElement('ui-access');
- $element->appendChild($this->_document->createCDATASection("PRADO"));
- $rootElement->appendChild($element);
- //--- add <files>
- $this->_filesElement = $this->_document->createElement('files');
- $rootElement->appendChild($this->_filesElement);
- //--- add <configuration-changes>
- $configChangeElement = $this->_document->createElement('configuration-changes');
- $rootElement->appendChild($configChangeElement);
- //--- add <taglibrary-changes>
- $tagLibChangeElement = $this->_document->createElement('taglibrary-changes');
- $configChangeElement->appendChild($tagLibChangeElement);
- //--- add <taglibrary-insert>
- $tagLibInsertElement = $this->_document->createElement('taglibrary-insert');
- $tagLibChangeElement->appendChild($tagLibInsertElement);
- //--- add <taglibrary>
- $this->_tagLibraryElement = $element = $this->_document->createElement('taglibrary');
- $element->setAttribute('doctypes','HTML,DWTemplate');
- $element->setAttribute('id','DWTagLibrary_PRADO_tags');
- $element->setAttribute('name','PRADO tags');
- $element->setAttribute('prefix','<com:');
- $element->setAttribute('tagchooser','PRADO/TagChooser.xml');
- $tagLibInsertElement->appendChild($element);
-
- $element = $this->_document->createElement('file');
- $element->setAttribute('name','Configuration/TagLibraries/PRADO/TagChooser.xml');
- $element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/TagChooser.xml');
- $this->_filesElement->appendChild($element);
- }
-
- public function addTag($tagName)
- {
- $element = $this->_document->createElement('file');
- $element->setAttribute('name','Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
- $element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
- $this->_filesElement->appendChild($element);
-
- $element = $this->_document->createElement('tagref');
- $element->setAttribute('file','PRADO/'.$tagName.'.vtm');
- $element->setAttribute('name',$tagName);
- $this->_tagLibraryElement->appendChild($element);
- }
-
- public function getDocument()
- {
- return $this->_document;
- }
-
- public function getXML()
- {
- return $this->_document->saveXML();
- }
-}
-
-/**
- * PradoTagChooser class
- *
- * @author Stanislav Yordanov <stanprog[at]stanprog.com>
- * @author Qiang Xue <qiang.xue@gmail.com>
- */
-class PradoTagChooser
-{
- private $_document;
- private $_tclibrary;
- private $_category;
-
- public function __construct()
- {
- $this->_document = new DOMDocument('1.0', 'utf-8');
- $this->prepareDocument();
- }
-
- protected function prepareDocument()
- {
- $this->_document->standalone = true;
- $this->_document->formatOutput = true;
- $tclibrary = $this->_document->createElement('tclibrary');
- $tclibrary->setAttribute('name','PRADO tags');
- $tclibrary->setAttribute('desc','A collection of all PRADO tags.');
- $tclibrary->setAttribute('reference','PRADO');
- $this->_document->appendChild($tclibrary);
-
- $this->_category = $this->_document->createElement('category');
- $this->_category->setAttribute('name','General');
- $this->_category->setAttribute('icon','Configuration/TagLibraries/Icons/Elements.gif');
- $tclibrary->appendChild($this->_category);
- }
-
- public function addElement($elementName)
- {
- $element = $this->_document->createElement('element');
- $element->setAttribute('name','com:'.$elementName);
- $element->setAttribute('value','<com:'.$elementName.'>');
- $element->setAttribute('reference','PRADO,COM:'.strtoupper($elementName));
- $this->_category->appendChild($element);
- }
-
- public function getXML()
- {
- $this->_document->normalize();
- /*
- $resultXML = $this->_document->saveXML();
- $resultXML = str_replace('&gt;','>',$resultXML);
- $resultXML = str_replace('&lt;','<',$resultXML);
- return $resultXML;
- */
- return $this->_document->saveXML();
- }
-}
+<?php
+
+/**
+ * PradoVTMDocument class
+ *
+ * @author Stanislav Yordanov <stanprog[at]stanprog.com>
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ */
+class PradoVTMDocument
+{
+ private $_document;
+ private $_attributes;
+
+ public function __construct($controlName)
+ {
+ $this->_document = new DOMDocument('1.0', 'utf-8');
+ $this->prepareDocument($controlName);
+ }
+
+ protected function prepareDocument($controlName)
+ {
+ $this->_document->formatOutput = true;
+
+ //--- add <tag>
+ $tag = $this->_document->createElement('tag');
+ $tag->setAttribute('name',$controlName);
+ $tag->setAttribute('casesensitive','yes');
+ $this->_document->appendChild($tag);
+
+ //--- add <tagformat>
+ $tagFormat = $this->_document->createElement('tagformat');
+ $tagFormat->setAttribute('nlbeforetag','1');
+ $tagFormat->setAttribute('nlaftertag','1');
+ $tagFormat->setAttribute('indentcontents','yes');
+ $tag->appendChild($tagFormat);
+
+ //--- add <tagdialog file="Control.htm" />
+ //$tagDialog = $this->_document->createElement('tagdialog');
+ //$tagDialog->setAttribute('file',$controlName.'.htm');
+ //$tag->appendChild($tagDialog);
+
+ $this->_attributes = $this->_document->createElement('attributes');
+ $tag->appendChild($this->_attributes);
+ }
+
+ public function getDocument()
+ {
+ return $this->_document;
+ }
+
+ public function addAttribute($attribName, $attribType)
+ {
+ //--- add <attrib>
+ $attrib = $this->_document->createElement('attrib');
+ $attrib->setAttribute('name',$attribName);
+ if (is_array($attribType))
+ {
+ $attrib->setAttribute('type','Enumerated');
+ foreach ($attribType as $value)
+ {
+ $option = $this->_document->createElement('attriboption');
+ $option->setAttribute('value',$value);
+ $option->setAttribute('caption','');
+ $attrib->appendChild($option);
+ }
+ }
+ else if($attribType!=='')
+ {
+ $attrib->setAttribute('type',$attribType);
+ }
+ $attrib->setAttribute('casesensitive','yes');
+ $this->_attributes->appendChild($attrib);
+ }
+
+ public function addEvent($eventName)
+ {
+ //--- add <attrib>
+ $this->addAttribute($eventName,'');
+ //--- add <event>
+ $event = $this->_document->createElement('event');
+ $event->setAttribute('name',$eventName);
+ $this->_attributes->appendChild($event);
+ }
+
+ public function getXML()
+ {
+ return $this->_document->saveXML();
+ }
+}
+
+/**
+ * PradoMXIDocument class
+ *
+ * @author Stanislav Yordanov <stanprog@stanprog.com>
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ */
+class PradoMXIDocument
+{
+ private $_tagLibraryElement;
+ private $_filesElement;
+ private $_document;
+
+ public function __construct($version)
+ {
+ $this->_document = new DOMDocument('1.0', 'utf-8');
+ $this->prepareDocument($version);
+ }
+
+ protected function prepareDocument($version)
+ {
+ $this->_document->formatOutput = true;
+ //--- add root element
+ $rootElement = $this->_document->createElement('macromedia-extension');
+ $rootElement->setAttribute('name','PRADO Taglib');
+ $rootElement->setAttribute('version',$version);
+ $rootElement->setAttribute('type','Suite');
+ $rootElement->setAttribute('requires-restart','true');
+ $this->_document->appendChild($rootElement);
+ //--- add <author>
+ $element = $this->_document->createElement('author');
+ $element->setAttribute('name','Stanislav Yordanov, Qiang Xue');
+ $rootElement->appendChild($element);
+ $time = date('F j, Y, h:i:s a',time());
+ //--- add <description>
+ $description = <<<EOD
+PRADO $version Tag Library
+Authors: Stanislav Yordanov <stanprog@stanprog.com> and Qiang Xue <qiang.xue@gmail.com>
+Time: $time
+Requirement: Macromedia Dreamweaver MX/MX 2004/8.0 or above
+Description: This suite adds PRADO tag library. The tag library contains PRADO component
+tags, properties and events that are commonly used on PRADO templates.
+EOD;
+ $element = $this->_document->createElement('description');
+ $element->appendChild($this->_document->createCDATASection($description));
+ $rootElement->appendChild($element);
+ //--- add <products>
+ $productsElement = $this->_document->createElement('products');
+ $rootElement->appendChild($productsElement);
+ //--- add <product>
+ $product = $this->_document->createElement('product');
+ $product->setAttribute('name','Dreamweaver');
+ $product->setAttribute('version','6');
+ $product->setAttribute('primary','false');
+ $productsElement->appendChild($product);
+ //--- add <ui-access>
+ $element = $this->_document->createElement('ui-access');
+ $element->appendChild($this->_document->createCDATASection("PRADO"));
+ $rootElement->appendChild($element);
+ //--- add <files>
+ $this->_filesElement = $this->_document->createElement('files');
+ $rootElement->appendChild($this->_filesElement);
+ //--- add <configuration-changes>
+ $configChangeElement = $this->_document->createElement('configuration-changes');
+ $rootElement->appendChild($configChangeElement);
+ //--- add <taglibrary-changes>
+ $tagLibChangeElement = $this->_document->createElement('taglibrary-changes');
+ $configChangeElement->appendChild($tagLibChangeElement);
+ //--- add <taglibrary-insert>
+ $tagLibInsertElement = $this->_document->createElement('taglibrary-insert');
+ $tagLibChangeElement->appendChild($tagLibInsertElement);
+ //--- add <taglibrary>
+ $this->_tagLibraryElement = $element = $this->_document->createElement('taglibrary');
+ $element->setAttribute('doctypes','HTML,DWTemplate');
+ $element->setAttribute('id','DWTagLibrary_PRADO_tags');
+ $element->setAttribute('name','PRADO tags');
+ $element->setAttribute('prefix','<com:');
+ $element->setAttribute('tagchooser','PRADO/TagChooser.xml');
+ $tagLibInsertElement->appendChild($element);
+
+ $element = $this->_document->createElement('file');
+ $element->setAttribute('name','Configuration/TagLibraries/PRADO/TagChooser.xml');
+ $element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/TagChooser.xml');
+ $this->_filesElement->appendChild($element);
+ }
+
+ public function addTag($tagName)
+ {
+ $element = $this->_document->createElement('file');
+ $element->setAttribute('name','Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
+ $element->setAttribute('destination','$dreamweaver/Configuration/TagLibraries/PRADO/'.$tagName.'.vtm');
+ $this->_filesElement->appendChild($element);
+
+ $element = $this->_document->createElement('tagref');
+ $element->setAttribute('file','PRADO/'.$tagName.'.vtm');
+ $element->setAttribute('name',$tagName);
+ $this->_tagLibraryElement->appendChild($element);
+ }
+
+ public function getDocument()
+ {
+ return $this->_document;
+ }
+
+ public function getXML()
+ {
+ return $this->_document->saveXML();
+ }
+}
+
+/**
+ * PradoTagChooser class
+ *
+ * @author Stanislav Yordanov <stanprog[at]stanprog.com>
+ * @author Qiang Xue <qiang.xue@gmail.com>
+ */
+class PradoTagChooser
+{
+ private $_document;
+ private $_tclibrary;
+ private $_category;
+
+ public function __construct()
+ {
+ $this->_document = new DOMDocument('1.0', 'utf-8');
+ $this->prepareDocument();
+ }
+
+ protected function prepareDocument()
+ {
+ $this->_document->standalone = true;
+ $this->_document->formatOutput = true;
+ $tclibrary = $this->_document->createElement('tclibrary');
+ $tclibrary->setAttribute('name','PRADO tags');
+ $tclibrary->setAttribute('desc','A collection of all PRADO tags.');
+ $tclibrary->setAttribute('reference','PRADO');
+ $this->_document->appendChild($tclibrary);
+
+ $this->_category = $this->_document->createElement('category');
+ $this->_category->setAttribute('name','General');
+ $this->_category->setAttribute('icon','Configuration/TagLibraries/Icons/Elements.gif');
+ $tclibrary->appendChild($this->_category);
+ }
+
+ public function addElement($elementName)
+ {
+ $element = $this->_document->createElement('element');
+ $element->setAttribute('name','com:'.$elementName);
+ $element->setAttribute('value','<com:'.$elementName.'>');
+ $element->setAttribute('reference','PRADO,COM:'.strtoupper($elementName));
+ $this->_category->appendChild($element);
+ }
+
+ public function getXML()
+ {
+ $this->_document->normalize();
+ /*
+ $resultXML = $this->_document->saveXML();
+ $resultXML = str_replace('&gt;','>',$resultXML);
+ $resultXML = str_replace('&lt;','<',$resultXML);
+ return $resultXML;
+ */
+ return $this->_document->saveXML();
+ }
+}
?> \ No newline at end of file
diff --git a/buildscripts/classtree/build.php b/buildscripts/classtree/build.php
index c3c3d2f0..fab1b12b 100644
--- a/buildscripts/classtree/build.php
+++ b/buildscripts/classtree/build.php
@@ -1,258 +1,258 @@
-<?php
-
-$basePath=dirname(__FILE__);
-$frameworkPath=realpath($basePath.'/../../framework');
-require_once($frameworkPath.'/prado.php');
-require_once($basePath.'/DWExtension.php');
-
-//the manager class sets up some dependency paths
-Prado::using('System.Data.SqlMap.TSqlMapManager');
-
-$exclusions=array(
- 'pradolite.php',
- 'prado-cli.php',
- 'JSMin.php',
- '.svn',
- '/I18N/core',
- '/3rdParty',
- '/Testing',
- '/Web/UI/WebControls/assets',
- );
-$a=new ClassTreeBuilder($frameworkPath,$exclusions);
-$a->buildTree();
-$a->saveToFile($basePath.'/classes.data');
-$a->saveAsDWExtension($basePath);
-
-class ClassTreeBuilder
-{
- const REGEX_RULES='/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
- private $_frameworkPath;
- private $_exclusions;
- private $_classes=array();
-
- public function __construct($frameworkPath,$exclusions)
- {
- $this->_frameworkPath=realpath($frameworkPath);
- $this->_exclusions=array();
- foreach($exclusions as $exclusion)
- {
- if($exclusion[0]==='/')
- $this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true;
- else
- $this->_exclusions[$exclusion]=true;
- }
- }
-
- public function buildTree()
- {
- $sourceFiles=$this->getSourceFiles($this->_frameworkPath);
- foreach($sourceFiles as $sourceFile)
- $this->parseFile($sourceFile);
- ksort($this->_classes);
- foreach(array_keys($this->_classes) as $className)
- {
- $parentClass=$this->_classes[$className]['ParentClass'];
- if(isset($this->_classes[$parentClass]))
- $this->_classes[$parentClass]['ChildClasses'][]=$className;
- }
- echo "\nClass tree built successfully. Total ".count($this->_classes)." classes found.\n";
- }
-
- public function saveToFile($fileName)
- {
- file_put_contents($fileName,serialize($this->_classes));
- }
-
- public function displayTree()
- {
- $this->displayTreeInternal(array_keys($this->_baseClasses),0);
- }
-
- public function displayTreeInternal($classNames,$level)
- {
- foreach($classNames as $className)
- {
- echo str_repeat(' ',$level*4);
- echo $className.':'.$this->_classes[$className]->Package."\n";
- $this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses),$level+1);
- }
- }
-
- protected function parseFile($sourceFile)
- {
- include_once($sourceFile);
- $classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/');
- echo "Parsing $classFile...\n";
- $content=file_get_contents($sourceFile);
- if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0)
- $package=$matches[1];
- else
- $package='';
- $n=preg_match_all(self::REGEX_RULES,$content,$matches,PREG_SET_ORDER);
- for($i=0;$i<$n;++$i)
- {
- $className=$matches[$i][2];
- if(isset($this->_classes[$className]))
- throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
- $c=new TComponentReflection($className);
- $properties=$c->getProperties();
- $this->parseMethodComments($properties);
- $events=$c->getEvents();
- $this->parseMethodComments($events);
- $methods=$c->getMethods();
- $this->parseMethodComments($methods);
- $this->_classes[$className]=array(
- 'ClassFile'=>$classFile,
- 'Package'=>$package,
- 'ParentClass'=>isset($matches[$i][4])?$matches[$i][4]:'',
- 'ChildClasses'=>array(),
- 'Properties'=>$properties,
- 'Events'=>$events,
- 'Methods'=>$methods);
- }
- }
-
- protected function parseMethodComments(&$methods)
- {
- foreach(array_keys($methods) as $key)
- {
- $method=&$methods[$key];
- $comments=$method['comments'];
- $s='';
- foreach(explode("\n",$comments) as $line)
- {
- $line=trim($line);
- $line=trim($line,'/*');
- $s.=' '.$line;
- }
- $s=trim($s);
- $s=preg_replace('/\{@link.*?([\w\(\)]+)\}/i','$1',$s);
- $pos1=strpos($s,'@');
- $pos2=strpos($s,'.');
- if($pos1===false)
- {
- if($pos2!==false)
- $method['comments']=substr($s,0,$pos2);
- else
- $method['comments']=$s;
- }
- else if($pos1>0)
- {
- if($pos2 && $pos2<$pos1) // use the first line as comment
- $method['comments']=substr($s,0,$pos2);
- else
- $method['comments']=substr($s,0,$pos1);
- }
- else
- {
- $matches=array();
- if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0)
- $method['comments']=$matches[1];
- else
- $method['comments']='';
- }
- }
- }
-
- protected function isValidPath($path)
- {
- if(is_dir($path))
- return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]);
- else
- return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
- }
-
- public function getSourceFiles($path)
- {
- $files=array();
- $folder=opendir($path);
- while($file=readdir($folder))
- {
- if($file==='.' || $file==='..')
- continue;
- $fullPath=realpath($path.'/'.$file);
- if($this->isValidPath($fullPath))
- {
- if(is_file($fullPath))
- $files[]=$fullPath;
- else
- $files=array_merge($files,$this->getSourceFiles($fullPath));
- }
- }
- closedir($folder);
- return $files;
- }
-
- public function saveAsDWExtension($basePath)
- {
- $tagPath=$basePath.'/Configuration/TagLibraries/PRADO';
-
- // prepare the directory to save tag lib
- @mkdir($basePath.'/Configuration');
- @mkdir($basePath.'/Configuration/TagLibraries');
- @mkdir($basePath.'/Configuration/TagLibraries/PRADO');
-
- $docMXI = new PradoMXIDocument(Prado::getVersion());
- $tagChooser = new PradoTagChooser;
-
- $controlClass = new ReflectionClass('TControl');
-
- foreach($this->_classes as $className=>$classInfo)
- {
- $class = new ReflectionClass($className);
- if($class->isInstantiable() && ($className==='TControl' || $class->isSubclassOf($controlClass)))
- {
- $docMXI->addTag($className);
- $tagChooser->addElement($className);
- $docVTM = new PradoVTMDocument($className);
- foreach($classInfo['Properties'] as $name=>$property)
- {
- $type=$property['type'];
- if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle'))
- $this->processObjectType($type,$this->_classes[$type],$name,$docVTM);
- if($property['readonly'] || $property['protected'])
- continue;
- if(($type=$this->checkType($className,$name,$property['type']))!=='')
- $docVTM->addAttribute($name,$type);
- }
- foreach($classInfo['Events'] as $name=>$event)
- {
- $docVTM->addEvent($name);
- }
- file_put_contents($tagPath.'/'.$className.'.vtm',$docVTM->getXML());
- }
- }
-
- file_put_contents($basePath.'/PRADO.mxi',$docMXI->getXML());
- file_put_contents($tagPath.'/TagChooser.xml',$tagChooser->getXML());
-
- }
-
- private function processObjectType($objectType,$objectInfo,$prefix,$doc)
- {
- foreach($objectInfo['Properties'] as $name=>$property)
- {
- if($property['type']==='TFont')
- $this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc);
- if($property['readonly'] || $property['protected'])
- continue;
- if(($type=$this->checkType($objectType,$name,$property['type']))!=='')
- $doc->addAttribute($prefix.'.'.$name,$type);
- }
- }
-
- private function checkType($className,$propertyName,$type)
- {
- if(strrpos($propertyName,'Color')===strlen($propertyName)-5)
- return 'color';
- if($propertyName==='Style')
- return 'style';
- if($type==='boolean')
- return array('true','false');
- if($type==='string' || $type==='integer' || $type==='ITemplate')
- return 'text';
- return '';
- }
-}
-
-?>
+<?php
+
+$basePath=dirname(__FILE__);
+$frameworkPath=realpath($basePath.'/../../framework');
+require_once($frameworkPath.'/prado.php');
+require_once($basePath.'/DWExtension.php');
+
+//the manager class sets up some dependency paths
+Prado::using('System.Data.SqlMap.TSqlMapManager');
+
+$exclusions=array(
+ 'pradolite.php',
+ 'prado-cli.php',
+ 'JSMin.php',
+ '.svn',
+ '/I18N/core',
+ '/3rdParty',
+ '/Testing',
+ '/Web/UI/WebControls/assets',
+ );
+$a=new ClassTreeBuilder($frameworkPath,$exclusions);
+$a->buildTree();
+$a->saveToFile($basePath.'/classes.data');
+$a->saveAsDWExtension($basePath);
+
+class ClassTreeBuilder
+{
+ const REGEX_RULES='/^\s*(abstract\s+)?class\s+(\w+)(\s+extends\s+(\w+)\s*|\s*)/msS';
+ private $_frameworkPath;
+ private $_exclusions;
+ private $_classes=array();
+
+ public function __construct($frameworkPath,$exclusions)
+ {
+ $this->_frameworkPath=realpath($frameworkPath);
+ $this->_exclusions=array();
+ foreach($exclusions as $exclusion)
+ {
+ if($exclusion[0]==='/')
+ $this->_exclusions[realpath($frameworkPath.'/'.$exclusion)]=true;
+ else
+ $this->_exclusions[$exclusion]=true;
+ }
+ }
+
+ public function buildTree()
+ {
+ $sourceFiles=$this->getSourceFiles($this->_frameworkPath);
+ foreach($sourceFiles as $sourceFile)
+ $this->parseFile($sourceFile);
+ ksort($this->_classes);
+ foreach(array_keys($this->_classes) as $className)
+ {
+ $parentClass=$this->_classes[$className]['ParentClass'];
+ if(isset($this->_classes[$parentClass]))
+ $this->_classes[$parentClass]['ChildClasses'][]=$className;
+ }
+ echo "\nClass tree built successfully. Total ".count($this->_classes)." classes found.\n";
+ }
+
+ public function saveToFile($fileName)
+ {
+ file_put_contents($fileName,serialize($this->_classes));
+ }
+
+ public function displayTree()
+ {
+ $this->displayTreeInternal(array_keys($this->_baseClasses),0);
+ }
+
+ public function displayTreeInternal($classNames,$level)
+ {
+ foreach($classNames as $className)
+ {
+ echo str_repeat(' ',$level*4);
+ echo $className.':'.$this->_classes[$className]->Package."\n";
+ $this->displayTreeInternal(array_keys($this->_classes[$className]->ChildClasses),$level+1);
+ }
+ }
+
+ protected function parseFile($sourceFile)
+ {
+ include_once($sourceFile);
+ $classFile=strtr(substr($sourceFile,strlen($this->_frameworkPath)),'\\','/');
+ echo "Parsing $classFile...\n";
+ $content=file_get_contents($sourceFile);
+ if(preg_match('/@package\s+([\w\.]+)\s*/msS',$content,$matches)>0)
+ $package=$matches[1];
+ else
+ $package='';
+ $n=preg_match_all(self::REGEX_RULES,$content,$matches,PREG_SET_ORDER);
+ for($i=0;$i<$n;++$i)
+ {
+ $className=$matches[$i][2];
+ if(isset($this->_classes[$className]))
+ throw new Exception("Class $className is defined in both $sourceFile and ".$this->_classes[$className]->ClassFile);
+ $c=new TComponentReflection($className);
+ $properties=$c->getProperties();
+ $this->parseMethodComments($properties);
+ $events=$c->getEvents();
+ $this->parseMethodComments($events);
+ $methods=$c->getMethods();
+ $this->parseMethodComments($methods);
+ $this->_classes[$className]=array(
+ 'ClassFile'=>$classFile,
+ 'Package'=>$package,
+ 'ParentClass'=>isset($matches[$i][4])?$matches[$i][4]:'',
+ 'ChildClasses'=>array(),
+ 'Properties'=>$properties,
+ 'Events'=>$events,
+ 'Methods'=>$methods);
+ }
+ }
+
+ protected function parseMethodComments(&$methods)
+ {
+ foreach(array_keys($methods) as $key)
+ {
+ $method=&$methods[$key];
+ $comments=$method['comments'];
+ $s='';
+ foreach(explode("\n",$comments) as $line)
+ {
+ $line=trim($line);
+ $line=trim($line,'/*');
+ $s.=' '.$line;
+ }
+ $s=trim($s);
+ $s=preg_replace('/\{@link.*?([\w\(\)]+)\}/i','$1',$s);
+ $pos1=strpos($s,'@');
+ $pos2=strpos($s,'.');
+ if($pos1===false)
+ {
+ if($pos2!==false)
+ $method['comments']=substr($s,0,$pos2);
+ else
+ $method['comments']=$s;
+ }
+ else if($pos1>0)
+ {
+ if($pos2 && $pos2<$pos1) // use the first line as comment
+ $method['comments']=substr($s,0,$pos2);
+ else
+ $method['comments']=substr($s,0,$pos1);
+ }
+ else
+ {
+ $matches=array();
+ if(preg_match('/@return\s+[\w\|]+\s+([^\.]*)/',$s,$matches)>0)
+ $method['comments']=$matches[1];
+ else
+ $method['comments']='';
+ }
+ }
+ }
+
+ protected function isValidPath($path)
+ {
+ if(is_dir($path))
+ return !isset($this->_exclusions[basename($path)]) && !isset($this->_exclusions[$path]);
+ else
+ return basename($path)!==basename($path,'.php') && !isset($this->_exclusions[basename($path)]);
+ }
+
+ public function getSourceFiles($path)
+ {
+ $files=array();
+ $folder=opendir($path);
+ while($file=readdir($folder))
+ {
+ if($file==='.' || $file==='..')
+ continue;
+ $fullPath=realpath($path.'/'.$file);
+ if($this->isValidPath($fullPath))
+ {
+ if(is_file($fullPath))
+ $files[]=$fullPath;
+ else
+ $files=array_merge($files,$this->getSourceFiles($fullPath));
+ }
+ }
+ closedir($folder);
+ return $files;
+ }
+
+ public function saveAsDWExtension($basePath)
+ {
+ $tagPath=$basePath.'/Configuration/TagLibraries/PRADO';
+
+ // prepare the directory to save tag lib
+ @mkdir($basePath.'/Configuration');
+ @mkdir($basePath.'/Configuration/TagLibraries');
+ @mkdir($basePath.'/Configuration/TagLibraries/PRADO');
+
+ $docMXI = new PradoMXIDocument(Prado::getVersion());
+ $tagChooser = new PradoTagChooser;
+
+ $controlClass = new ReflectionClass('TControl');
+
+ foreach($this->_classes as $className=>$classInfo)
+ {
+ $class = new ReflectionClass($className);
+ if($class->isInstantiable() && ($className==='TControl' || $class->isSubclassOf($controlClass)))
+ {
+ $docMXI->addTag($className);
+ $tagChooser->addElement($className);
+ $docVTM = new PradoVTMDocument($className);
+ foreach($classInfo['Properties'] as $name=>$property)
+ {
+ $type=$property['type'];
+ if(isset($this->_classes[$type]) && ($type==='TFont' || strrpos($type,'Style')===strlen($type)-5 && $type!=='TStyle'))
+ $this->processObjectType($type,$this->_classes[$type],$name,$docVTM);
+ if($property['readonly'] || $property['protected'])
+ continue;
+ if(($type=$this->checkType($className,$name,$property['type']))!=='')
+ $docVTM->addAttribute($name,$type);
+ }
+ foreach($classInfo['Events'] as $name=>$event)
+ {
+ $docVTM->addEvent($name);
+ }
+ file_put_contents($tagPath.'/'.$className.'.vtm',$docVTM->getXML());
+ }
+ }
+
+ file_put_contents($basePath.'/PRADO.mxi',$docMXI->getXML());
+ file_put_contents($tagPath.'/TagChooser.xml',$tagChooser->getXML());
+
+ }
+
+ private function processObjectType($objectType,$objectInfo,$prefix,$doc)
+ {
+ foreach($objectInfo['Properties'] as $name=>$property)
+ {
+ if($property['type']==='TFont')
+ $this->processObjectType('TFont',$this->_classes['TFont'],$prefix.'.'.$name,$doc);
+ if($property['readonly'] || $property['protected'])
+ continue;
+ if(($type=$this->checkType($objectType,$name,$property['type']))!=='')
+ $doc->addAttribute($prefix.'.'.$name,$type);
+ }
+ }
+
+ private function checkType($className,$propertyName,$type)
+ {
+ if(strrpos($propertyName,'Color')===strlen($propertyName)-5)
+ return 'color';
+ if($propertyName==='Style')
+ return 'style';
+ if($type==='boolean')
+ return array('true','false');
+ if($type==='string' || $type==='integer' || $type==='ITemplate')
+ return 'text';
+ return '';
+ }
+}
+
+?>