Initial Commit
This commit is contained in:
58
database/php/pear/PHP/UML/Output/Php/DocClass.php
Normal file
58
database/php/pear/PHP/UML/Output/Php/DocClass.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 136 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @since $Date: 2009-12-10 01:35:58 +0100 (jeu., 10 déc. 2009) $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the class renderer
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Output
|
||||
* @subpackage Php
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
class PHP_UML_Output_Php_DocClass extends PHP_UML_Output_Php_DocClassifier
|
||||
{
|
||||
protected function getTypeName()
|
||||
{
|
||||
return 'class';
|
||||
}
|
||||
|
||||
protected function getStyleName()
|
||||
{
|
||||
return 'class';
|
||||
}
|
||||
|
||||
protected function getPrefix()
|
||||
{
|
||||
return self::CLASS_PREFIX;
|
||||
}
|
||||
|
||||
protected function getCurrentElement($i)
|
||||
{
|
||||
return $this->getContextPackage()->classes[$i];
|
||||
}
|
||||
|
||||
protected function getNextElement($i)
|
||||
{
|
||||
return $i+1<count($this->getContextPackage()->classes) ? $this->getContextPackage()->classes[$i+1] : null;
|
||||
}
|
||||
|
||||
protected function getPreviousElement($i)
|
||||
{
|
||||
return $i>0 ? $this->getContextPackage()->classes[$i-1] : null;
|
||||
}
|
||||
}
|
||||
?>
|
||||
168
database/php/pear/PHP/UML/Output/Php/DocClassifier.php
Normal file
168
database/php/pear/PHP/UML/Output/Php/DocClassifier.php
Normal file
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 139 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @since $Date: 2009-12-13 21:48:54 +0100 (dim., 13 déc. 2009) $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the HTML renderer for a classifier (class, interface, datatype)
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Output
|
||||
* @subpackage Php
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
abstract class PHP_UML_Output_Php_DocClassifier extends PHP_UML_Output_Php_DocElement
|
||||
{
|
||||
/**
|
||||
* Return the type name of the classifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getTypeName();
|
||||
|
||||
/**
|
||||
* Return the CSS style name of the classifier
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getStyleName();
|
||||
|
||||
/**
|
||||
* Return the prefix (filename scheme)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract protected function getPrefix();
|
||||
|
||||
/**
|
||||
* Return the current object
|
||||
*
|
||||
* @param int $i Current index in all the elements of the package
|
||||
*
|
||||
* @return PHP_UML_Metamodel_Classifier
|
||||
*/
|
||||
abstract protected function getCurrentElement($i);
|
||||
|
||||
/**
|
||||
* Return the next object
|
||||
*
|
||||
* @param int $i Current index in all the elements of the package
|
||||
*
|
||||
* @return PHP_UML_Metamodel_Classifier
|
||||
*/
|
||||
abstract protected function getNextElement($i);
|
||||
|
||||
/**
|
||||
* Return the previous object
|
||||
*
|
||||
* @param int $i Previous index in all the elements of the package
|
||||
*
|
||||
* @return PHP_UML_Metamodel_Classifier
|
||||
*/
|
||||
abstract protected function getPreviousElement($i);
|
||||
|
||||
/**
|
||||
* Generates and saves the HTML code for a classifier
|
||||
*
|
||||
* @param int $i Index of the element (to be found in the Context object)
|
||||
*/
|
||||
public function render($i)
|
||||
{
|
||||
$p = $this->getCurrentElement($i);
|
||||
|
||||
$nsDeclaration = '';
|
||||
$ns = '';
|
||||
if (isset($p->package)) {
|
||||
$ns = substr($this->getAbsPath($p->package, self::T_NAMESPACE), 0, -1);
|
||||
if (!empty($ns))
|
||||
$nsDeclaration = 'namespace '.$ns.';'.$this->getNl();
|
||||
}
|
||||
|
||||
$header = $this->exporter->getDocblocks() ? '/**'.$this->getNl().
|
||||
' * @author '.PHP_UML_Output_Exporter::APP_NAME.$this->getNl().
|
||||
' * @since '.date("M j, Y, G:i:s O").$this->getNl().
|
||||
(empty($ns) ? '' : ' * @package '.$ns.$this->getNl()).
|
||||
' */' : '';
|
||||
|
||||
$str = $this->getMainBlock($p);
|
||||
$str .= $this->getNl().'{'.$this->getNl();
|
||||
$str .= $this->getPropertyBlock($p);
|
||||
$str .= $this->getNl();
|
||||
$str .= $this->getFunctionBlock($p);
|
||||
$str .= '}';
|
||||
|
||||
$str = $this->replaceInTpl($str, $header, $nsDeclaration, $p->name);
|
||||
|
||||
$this->save($p->name, $str);
|
||||
}
|
||||
|
||||
private function getMainBlock(PHP_UML_Metamodel_Classifier $p)
|
||||
{
|
||||
$allInherited = $this->getAllInherited($p);
|
||||
$nbAllInherited = count($allInherited);
|
||||
|
||||
$allImplemented = $this->getAllImplemented($p);
|
||||
$nbAllImplemented = count($allImplemented);
|
||||
|
||||
$allInheriting = $this->getAllInheriting($p);
|
||||
$nbAllInheriting = count($allInheriting);
|
||||
|
||||
$allImplementing = $this->getAllImplementing($p);
|
||||
$nbAllImplementing = count($allImplementing);
|
||||
|
||||
$typeName = $this->getTypeName();
|
||||
if ($p instanceof PHP_UML_Metamodel_Class) {
|
||||
if ($p->isAbstract)
|
||||
$typeName = 'abstract '.$typeName;
|
||||
if ($p->isReadOnly)
|
||||
$typeName = 'final '.$typeName;
|
||||
}
|
||||
$str = '';
|
||||
|
||||
if (!is_null($p->description)) {
|
||||
$str .= $this->getTagsAsList($p->description);
|
||||
}
|
||||
|
||||
$str .= $typeName.' '.$p->name.' ';
|
||||
|
||||
if (!empty($p->superClass[0])) {
|
||||
$str .= 'extends ';
|
||||
if (is_object($p->superClass[0]))
|
||||
$str .= $this->getLinkTo($p->superClass[0]);
|
||||
else
|
||||
$str .= $this->displayUnresolved($p->superClass[0]);
|
||||
$str .= ' ';
|
||||
}
|
||||
if (isset($p->implements)) {
|
||||
$nbImpl = count($p->implements);
|
||||
if ($nbImpl>0) {
|
||||
$str .= 'implements ';
|
||||
for ($i=0; $i<$nbImpl; $i++) {
|
||||
if (!empty($p->implements[$i])) {
|
||||
if (is_object($p->implements[$i]))
|
||||
$str .= $this->getLinkTo($p->implements[$i]);
|
||||
else
|
||||
$str .= $this->displayUnresolved($p->implements[$i]);
|
||||
if ($i<$nbImpl-1)
|
||||
$str .= ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
}
|
||||
?>
|
||||
361
database/php/pear/PHP/UML/Output/Php/DocElement.php
Normal file
361
database/php/pear/PHP/UML/Output/Php/DocElement.php
Normal file
@@ -0,0 +1,361 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision$
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @since $Date$
|
||||
*/
|
||||
|
||||
/**
|
||||
* General class for an renderer in the PHP implementation
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Output
|
||||
* @subpackage Php
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
abstract class PHP_UML_Output_Php_DocElement extends PHP_UML_Output_ApiRenderer
|
||||
{
|
||||
const FILE_EXT = 'php';
|
||||
const TEMPLATES_DIRNAME = 'templates';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param PHP_UML_Output_ExporterAPI $exporter Reference to an exporter
|
||||
*/
|
||||
public function __construct(PHP_UML_Output_ExporterAPI $exporter)
|
||||
{
|
||||
parent::__construct($exporter);
|
||||
$this->mainTpl = $this->getTemplate('main.php');
|
||||
}
|
||||
|
||||
protected function getDescription(PHP_UML_Metamodel_Stereotype $s, $annotatedElement='')
|
||||
{
|
||||
$tag = PHP_UML_Metamodel_Helper::getStereotypeTag($s, 'description');
|
||||
if (!is_null($tag))
|
||||
return $tag->value;
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the operation's parameters, as a comma-sep list, between brackets
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Operation $operation The operation
|
||||
* @param bool $withType If true, adds an hyperlink
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getParameterList(PHP_UML_Metamodel_Operation $operation, $withType = false)
|
||||
{
|
||||
$str = '(';
|
||||
$n = count($operation->ownedParameter);
|
||||
for ($i=0; $i<$n; $i++) {
|
||||
$parameter = $operation->ownedParameter[$i];
|
||||
if (substr($parameter->direction, 0, 2)=='in') {
|
||||
if ($withType && isset($parameter->type) && !($parameter->type instanceof PHP_UML_Metamodel_Datatype)) {
|
||||
if (is_object($parameter->type))
|
||||
$str .= $this->getLinkTo($parameter->type).' ';
|
||||
else if (strcasecmp($parameter->type, 'array')==0)
|
||||
$str .= $this->displayUnresolved($parameter->type).' ';
|
||||
}
|
||||
if ($parameter->direction=='inout') {
|
||||
$str .= '&';
|
||||
}
|
||||
if ($parameter->name[0] != '$')
|
||||
$str .= '$';
|
||||
$str .= $parameter->name;
|
||||
$str .= $this->getDefaultValue($parameter);
|
||||
if ($i<($n-1))
|
||||
$str .= ', ';
|
||||
}
|
||||
}
|
||||
$str .= ')';
|
||||
return $str;
|
||||
}
|
||||
|
||||
protected function getDefaultValue(PHP_UML_Metamodel_TypedElement $obj)
|
||||
{
|
||||
if ($obj->default!='')
|
||||
return '='.$obj->default;
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a link towards a given element
|
||||
* (since datatypes don't own to a "package", we suppose they are located in
|
||||
* the top package)
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Classifier $t The element
|
||||
* @param string $cssStyle CSS style to use
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getLinkTo(PHP_UML_Metamodel_Classifier $t, $hideDatatype=true)
|
||||
{
|
||||
if ($hideDatatype && ($t instanceof PHP_UML_Metamodel_Datatype))
|
||||
return '';
|
||||
|
||||
$ns = $t instanceof PHP_UML_Metamodel_Datatype ? '' : self::T_NAMESPACE;
|
||||
if (isset($t->package)) {
|
||||
$ns .= $this->getAbsPath($t->package, self::T_NAMESPACE);
|
||||
}
|
||||
return $ns.$t->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders an unresolved type as an HTML span
|
||||
*
|
||||
* @param string $type Type, provided as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function displayUnresolved($type)
|
||||
{
|
||||
return $type;
|
||||
}
|
||||
|
||||
|
||||
protected function getTagsAsList(PHP_UML_Metamodel_Stereotype $s)
|
||||
{
|
||||
return $this->getDocblocks($s, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the properties of a given stereotype.
|
||||
* Docblocks in $ignoredTag are not shown.
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Stereotype $s A stereotype
|
||||
* @param int $nbSpacer Number of spacers to add
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getDocblocks(PHP_UML_Metamodel_Stereotype $s, $nbSpacer = 0)
|
||||
{
|
||||
$str = '';
|
||||
$spacer = str_repeat(chr(9), $nbSpacer);
|
||||
foreach ($s->ownedAttribute as $tag) {
|
||||
if (!(in_array($tag->name, $this->ignoredTag))) {
|
||||
$str .= $spacer;
|
||||
if ($tag->name!='description') {
|
||||
$str .= ' * @'.$tag->name.' ';
|
||||
} else {
|
||||
$str .= ' * ';
|
||||
}
|
||||
if (strlen($tag->value)>0)
|
||||
$str .= str_replace($this->getNl(), $this->getNl().$spacer.' * ', $tag->value);
|
||||
if ($tag->name=='description') {
|
||||
$str .= $this->getNl().$spacer.' *';
|
||||
}
|
||||
$str .= $this->getNl();
|
||||
}
|
||||
}
|
||||
if ($str != '') {
|
||||
$str = $spacer.'/**'.$this->getNl().$str.$spacer.' */'.$this->getNl();
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renders the block "Properties" of a package or a class as HTML
|
||||
*
|
||||
* @param PHP_UML_Metamodel_NamedElement $p A classifier/a package
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getPropertyBlock(PHP_UML_Metamodel_NamedElement $p)
|
||||
{
|
||||
if (empty($p->ownedAttribute))
|
||||
return '';
|
||||
|
||||
$str = '';
|
||||
$spacer = chr(9);
|
||||
foreach ($p->ownedAttribute as $o) {
|
||||
|
||||
if (!is_null($o->description) && $this->exporter->getDocblocks()) {
|
||||
// we add var/return docblocks if they are missing
|
||||
$this->addVarDocblock($o);
|
||||
$str .= $this->getDocblocks($o->description, 1);
|
||||
}
|
||||
|
||||
$str .= $spacer;
|
||||
if ($o->isReadOnly)
|
||||
$str .= 'const ';
|
||||
else {
|
||||
$str .= $o->visibility.' ';
|
||||
if (!$o->isInstantiable)
|
||||
$str .= 'static ';
|
||||
}
|
||||
|
||||
// type display;
|
||||
/*if (is_object($o->type))
|
||||
$str .= $this->getLinkTo($o->type).' ';
|
||||
else
|
||||
$str .= $this->displayUnresolved($o->type);*/
|
||||
if ((!empty($o->name)) && ($o->name[0]!='$' && !$o->isReadOnly))
|
||||
$str .= '$';
|
||||
|
||||
$str .= $o->name.''.$this->getDefaultValue($o).';';
|
||||
|
||||
$str .= $this->getNl().$this->getNl();
|
||||
}
|
||||
$str .= '';
|
||||
return $str;
|
||||
}
|
||||
|
||||
private function addVarDocblock(PHP_UML_Metamodel_Property $o)
|
||||
{
|
||||
$found = false;
|
||||
foreach ($o->description->ownedAttribute as $tag) {
|
||||
if ($tag->name=='var') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$st = new PHP_UML_Metamodel_Stereotype();
|
||||
$st->name = 'var';
|
||||
if (is_object($o->type))
|
||||
$st->value = $this->getLinkTo($o->type, false);
|
||||
else
|
||||
$st->value = $this->displayUnresolved($o->type);
|
||||
$o->description->ownedAttribute[] = $st;
|
||||
}
|
||||
}
|
||||
|
||||
private function addReturnDocblock(PHP_UML_Metamodel_Operation $o)
|
||||
{
|
||||
$found = false;
|
||||
foreach ($o->description->ownedAttribute as $tag) {
|
||||
if ($tag->name=='return') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
$st = new PHP_UML_Metamodel_Stereotype();
|
||||
$st->name = 'return';
|
||||
foreach ($o->ownedParameter as $parameter) {
|
||||
if ($parameter->direction != 'in') {
|
||||
if (is_object($parameter->type))
|
||||
$st->value .= $this->getLinkTo($parameter->type, false).' ';
|
||||
else
|
||||
$st->value .= $this->displayUnresolved($parameter->type);
|
||||
}
|
||||
}
|
||||
$o->description->ownedAttribute[] = $st;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renders the block "Function" of a package or a classifier as HTML
|
||||
*
|
||||
* @param PHP_UML_Metamodel_NamedElement $p A classifier or a package
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFunctionBlock(PHP_UML_Metamodel_NamedElement $p)
|
||||
{
|
||||
if (empty($p->ownedOperation))
|
||||
return'';
|
||||
|
||||
$str = '';
|
||||
$spacer = chr(9);
|
||||
|
||||
foreach ($p->ownedOperation as $o) {
|
||||
|
||||
if (!is_null($o->description) && $this->exporter->getDocblocks()) {
|
||||
$this->addReturnDocblock($o);
|
||||
$str .= $this->getDocblocks($o->description, 1);
|
||||
}
|
||||
|
||||
$str .= $spacer.($o->visibility).' ';
|
||||
if (!$o->isInstantiable)
|
||||
$str .= 'static ';
|
||||
if ($o->isAbstract)
|
||||
$str .= 'abstract ';
|
||||
|
||||
$str .= 'function '.$o->name;
|
||||
|
||||
/*type hint
|
||||
$return = $this->getReturnParam($o);
|
||||
if (is_object($return->type))
|
||||
$str .= $this->getLinkTo($return->type).' ';
|
||||
else
|
||||
$str .= $this->displayUnresolved($return->type);*/
|
||||
$str .= $this->getParameterList($o, true);
|
||||
|
||||
if ($o->isAbstract || $p instanceof PHP_UML_Metamodel_Interface)
|
||||
$str .= ';'.$this->getNl().$this->getNl();
|
||||
else
|
||||
$str .= $this->getNl().$spacer.'{'.$this->getNl().
|
||||
$spacer.'}'.$this->getNl().$this->getNl();
|
||||
}
|
||||
$str .= '';
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTML code for the "File" information tag
|
||||
*
|
||||
* @param PHP_UML_Metamodel_NamedElement $p An element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getFileInfo(PHP_UML_Metamodel_NamedElement $p)
|
||||
{
|
||||
if (!empty($p->file->package))
|
||||
return ''.$this->getAbsPath($p->file->package).$p->file->name.'';
|
||||
else
|
||||
return '';
|
||||
}
|
||||
|
||||
protected function getNl()
|
||||
{
|
||||
return PHP_EOL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace the template's placeholders with their value
|
||||
*
|
||||
* @param string $main Main HTML content (generated by PHP_UML)
|
||||
* @param string $header Navigation HTML content (navig bar)
|
||||
* @param string $ns Title content
|
||||
* @param string $name Element name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function replaceInTpl($main, $header, $ns, $name)
|
||||
{
|
||||
$str = str_replace('#HEADER', $header, $this->mainTpl);
|
||||
$str = str_replace('#NAMESPACE', $ns, $str);
|
||||
$str = str_replace('#DETAIL', $main, $str);
|
||||
$str = str_replace('#NAME', $this->getTypeName().' '.$name, $str);
|
||||
return $str;
|
||||
}
|
||||
|
||||
protected function getTemplateDirectory()
|
||||
{
|
||||
return dirname(__FILE__).DIRECTORY_SEPARATOR.self::TEMPLATES_DIRNAME;
|
||||
}
|
||||
|
||||
protected function save($elementName, $str)
|
||||
{
|
||||
$fic = $this->getContextPackage()->dir.$elementName.'.'.self::FILE_EXT;
|
||||
file_put_contents($fic, $str);
|
||||
}
|
||||
}
|
||||
?>
|
||||
59
database/php/pear/PHP/UML/Output/Php/DocInterface.php
Normal file
59
database/php/pear/PHP/UML/Output/Php/DocInterface.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 136 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @since $Date: 2009-12-10 01:35:58 +0100 (jeu., 10 déc. 2009) $
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implementation of the class renderer
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Output
|
||||
* @subpackage Php
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
class PHP_UML_Output_Php_DocInterface extends PHP_UML_Output_Php_DocClassifier
|
||||
{
|
||||
|
||||
protected function getTypeName()
|
||||
{
|
||||
return 'interface';
|
||||
}
|
||||
|
||||
protected function getStyleName()
|
||||
{
|
||||
return 'interface';
|
||||
}
|
||||
|
||||
protected function getPrefix()
|
||||
{
|
||||
return self::INTERFACE_PREFIX;
|
||||
}
|
||||
|
||||
protected function getCurrentElement($i)
|
||||
{
|
||||
return $this->getContextPackage()->interfaces[$i];
|
||||
}
|
||||
|
||||
protected function getNextElement($i)
|
||||
{
|
||||
return $i+1<count($this->getContextPackage()->interfaces) ? $this->getContextPackage()->interfaces[$i+1] : null;
|
||||
}
|
||||
|
||||
protected function getPreviousElement($i)
|
||||
{
|
||||
return $i>0 ? $this->getContextPackage()->interfaces[$i-1] : null;
|
||||
}
|
||||
}
|
||||
?>
|
||||
113
database/php/pear/PHP/UML/Output/Php/Exporter.php
Normal file
113
database/php/pear/PHP/UML/Output/Php/Exporter.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
/**
|
||||
* PHP_UML
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
* @version SVN: $Revision: 167 $
|
||||
* @link http://pear.php.net/package/PHP_UML
|
||||
* @since $Date: 2011-09-08 02:23:25 +0200 (jeu., 08 sept. 2011) $
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class generates a HTML website from a UML model (a PHP_UML_Metamodel)
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_UML
|
||||
* @subpackage Output
|
||||
* @subpackage Php
|
||||
* @author Baptiste Autin <ohlesbeauxjours@yahoo.fr>
|
||||
* @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
|
||||
*/
|
||||
class PHP_UML_Output_Php_Exporter extends PHP_UML_Output_ExporterAPI
|
||||
{
|
||||
private $docClass;
|
||||
private $docInterface;
|
||||
|
||||
private $docblocks = true;
|
||||
|
||||
/**
|
||||
* Option to add time/id information as comments
|
||||
* @param boolean $value
|
||||
*/
|
||||
/*public function setStamp($value)
|
||||
{
|
||||
$this->stamp = $value;
|
||||
}
|
||||
|
||||
public function getStamp()
|
||||
{
|
||||
return $this->stamp;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Option to add docblocks
|
||||
*
|
||||
* @param boolean $value Set to true to include docblocks
|
||||
*/
|
||||
public function setDocblocks($value)
|
||||
{
|
||||
$this->docblocks = $value;
|
||||
}
|
||||
|
||||
public function getDocblocks()
|
||||
{
|
||||
return $this->docblocks;
|
||||
}
|
||||
|
||||
public function export($outDir)
|
||||
{
|
||||
$userCurrentDir = getcwd();
|
||||
|
||||
if (substr($outDir, -1) != DIRECTORY_SEPARATOR)
|
||||
$outDir .= DIRECTORY_SEPARATOR;
|
||||
parent::export($outDir);
|
||||
|
||||
$this->ctx = new PHP_UML_Output_ApiContextPackage();
|
||||
|
||||
$this->docClass = new PHP_UML_Output_Php_DocClass($this);
|
||||
$this->docInterface = new PHP_UML_Output_Php_DocInterface($this);
|
||||
|
||||
chdir($outDir);
|
||||
|
||||
// we analyse the inheritance/impl relations beforehand:
|
||||
$this->setAllSuperClassifiers($this->structure->packages);
|
||||
$this->treatPackage($this->structure->packages);
|
||||
|
||||
chdir($userCurrentDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recurses into the packages, and generates the detailed files (one file
|
||||
* per class/interface/package)
|
||||
*
|
||||
* @param PHP_UML_Metamodel_Package $pkg Starting package
|
||||
* @param string $dir Filepath leading to the current package
|
||||
* @param string $rpt Relative filepath to the top package
|
||||
*/
|
||||
private function treatPackage(PHP_UML_Metamodel_Package $pkg, $dir='', $rpt='')
|
||||
{
|
||||
$this->initContextPackage($pkg, $dir, $rpt);
|
||||
|
||||
$nbc = count($this->ctx->classes);
|
||||
$nbi = count($this->ctx->interfaces);
|
||||
|
||||
for ($i=0; $i<$nbc; $i++)
|
||||
$this->docClass->render($i);
|
||||
|
||||
for ($i=0; $i<$nbi; $i++)
|
||||
$this->docInterface->render($i);
|
||||
|
||||
foreach ($pkg->nestedPackage as $np) {
|
||||
$npDir = $dir.$np->name;
|
||||
if (!file_exists($npDir))
|
||||
mkdir($npDir);
|
||||
$this->treatPackage($np, $npDir.DIRECTORY_SEPARATOR, '../'.$rpt);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
5
database/php/pear/PHP/UML/Output/Php/templates/main.php
Normal file
5
database/php/pear/PHP/UML/Output/Php/templates/main.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
#HEADER
|
||||
#NAMESPACE
|
||||
#DETAIL
|
||||
?>
|
||||
Reference in New Issue
Block a user