home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / CSVdia2codeConverter.inc < prev    next >
Encoding:
Text File  |  2004-03-24  |  10.5 KB  |  378 lines

  1. <?php
  2. //
  3. // +------------------------------------------------------------------------+
  4. // | phpDocumentor                                                          |
  5. // +------------------------------------------------------------------------+
  6. // | CSVdia2code Converter Copyright 2003, Harald Fielker                   |
  7. // | Copyright (c) 2000-2003 Joshua Eichorn, Gregory Beaver                 |
  8. // | Email         jeichorn@phpdoc.org, cellog@phpdoc.org                   |
  9. // | Web           http://www.phpdoc.org                                    |
  10. // | Mirror        http://phpdocu.sourceforge.net/                          |
  11. // | PEAR          http://pear.php.net/package-info.php?pacid=137           |
  12. // +------------------------------------------------------------------------+
  13. // | This source file is subject to version 3.00 of the PHP License,        |
  14. // | that is available at http://www.php.net/license/3_0.txt.               |
  15. // | If you did not receive a copy of the PHP license and are unable to     |
  16. // | obtain it through the world-wide-web, please send a note to            |
  17. // | license@php.net so we can mail you a copy immediately.                 |
  18. // +------------------------------------------------------------------------+
  19. //
  20. /**
  21.  * @package Converters
  22.  * @subpackage CSVdia2code
  23.  */
  24. /**
  25.  * CSV output converter.
  26.  *
  27.  * @package Converters
  28.  * @subpackage CSVdia2code
  29.  * @author Harald Fielker (fielker@informatik.fh-augsburg.de)
  30.  * @since 1.2
  31.  * @version $Id: CSVdia2codeConverter.inc,v 1.4.2.2 2003/07/30 00:39:45 CelloG Exp $
  32.  */
  33. class CSVdia2codeConverter extends Converter
  34. {
  35.     var $name = 'dia2code';
  36.     var $output = 'CSV';
  37.     var $csv_array=array();
  38.     /**
  39.      * @see Converter::Converter()
  40.      */
  41.     function CSVdia2codeConverter(&$allp, &$packp, &$classes, &$procpages, $po, $pp, $qm, $targetDir, $templateDir, $title)
  42.     {
  43.         Converter::Converter($allp, $packp, $classes, $procpages, $po, $pp, $qm, $targetDir, $templateDir, $title);
  44.     }
  45.     
  46.     function writeSource($path, $value)
  47.     {
  48.     }
  49.     
  50.     function writeExample($title, $path, $source)
  51.     {
  52.     }
  53.     
  54.     function getExampleLink($path, $title)
  55.     {
  56.         return '';
  57.     }
  58.     
  59.     function getSourceLink($path)
  60.     {
  61.         return '';
  62.     }
  63.     
  64.     function returnSee(&$element, $eltext = false)
  65.     {
  66.         $el = '';
  67.         switch($element->type)
  68.         {
  69.             case 'tutorial' :
  70.             $section = $element->section;
  71.             if (!empty($section)) $section = '#'.$section;
  72.             return '{@tutorial '.$element->name.$section.'}';
  73.             break;
  74.             case 'method' :
  75.             case 'var' :
  76.             $el .= $element->class.'::';
  77.             case 'page' :
  78.             case 'define' :
  79.             case 'class' :
  80.             case 'function' :
  81.             case 'global' :
  82.             default :
  83.             $el .= $element->name;
  84.             if ($element->type == 'function' || $element->type == 'method') $el .= '()';
  85.             break;
  86.         }
  87.         if ($eltext)
  88.         return '{@link '.$el.' '.$eltext.'}';
  89.         else
  90.         return '{@link '.$el.'}';
  91.     }
  92.     
  93.     function returnLink($link,$text)
  94.     {
  95.         return '{@link '.$link.' '.$text.'}';
  96.     }
  97.     
  98.     function Convert_RIC($name, $contents)
  99.     {
  100.     }
  101.  
  102.     function convertDocBlock(&$element)
  103.     {
  104.     }
  105.     
  106.     function convertParams(&$element)
  107.     {
  108.     }
  109.     
  110.     function convertGlobal(&$element)
  111.     {
  112.     }
  113.     
  114.     function convertMethod(&$element)
  115.     {
  116.         $res=array();
  117.         $sdesc = '';
  118.         if ($element->docblock->sdesc)
  119.         {
  120.             $sdesc = $element->docblock->sdesc->Convert($this);
  121.         }
  122.         $params = array();
  123.         if (count($element->docblock->params))
  124.         foreach($element->docblock->params as $param => $val)
  125.         {
  126.             $a = $val->Convert($this);
  127.             $params[$param] = array("var" => $param,"datatype" => $val->converted_returnType,"data" => $a);
  128.         }
  129.         if (!$element->docblock->return->returnType) $element->docblock->return->returnType = 'void';
  130.         $res[] = "method";
  131.         $res[] = $element->getLineNumber(); // pos
  132.         $res[] = $element->getPath();
  133.         $res[] = $this->class; // class
  134.         $a = $element->docblock->getKeyword('access');
  135.         $access= $a->value; // access
  136.         if( $access == "" ) $access="public";
  137.         $res[] = $access; // access;
  138.         $res[] = $element->name; // var/method name
  139.         $res[] = $element->docblock->return->returnType; // return type
  140.         $res[] = $sdesc; // descriptopn
  141.         foreach( $params as $p ) {
  142.             $a="";
  143.             $a =$p["var"] ."|";
  144.             $a.=$p["datatype"] ."|";
  145.             $a.=$p["data"];
  146.             $res[] = $a; // parameter
  147.         }
  148.  
  149.         $this->csv_array[] = $res;
  150.     }
  151.     
  152.     function convertVar(&$element)
  153.     {
  154.         $res=array();
  155.         $sdesc = '';
  156.         if ($element->docblock->sdesc)
  157.         {
  158.             $sdesc = $element->docblock->sdesc->Convert($this);
  159.         }
  160.         $res[] = "membervar";
  161.         $res[] = $element->getLineNumber(); // pos
  162.         $res[] = $element->getPath();
  163.         $res[] = $this->class; // class
  164.         $a = $element->docblock->getKeyword('access');
  165.         $access= $a->value; // access
  166.         if( $access == "" ) $access="public";
  167.         $res[] = $access; // access;
  168.         $res[] = $element->docblock->var->returnType; // type
  169.         $res[] = $element->name; // var/method name
  170.         $res[] = $element->value; // init value
  171.         $res[] = $sdesc; // descriptopn
  172.  
  173.         $this->csv_array[] = $res;
  174.     }
  175.     
  176.     function convertClass(&$element)
  177.     {
  178.         $res=array();
  179.         $sdesc = '';
  180.         if ($element->docblock->sdesc)
  181.         {
  182.             $sdesc = $element->docblock->sdesc->Convert($this);
  183.         }
  184.         $res[] = "class";
  185.         $res[] = $element->getLineNumber(); // pos
  186.         $res[] = $element->getPath();
  187.         $res[] = $this->class; // class
  188.         $res[] = $sdesc; // descriptopn
  189.  
  190.         $this->csv_array[] = $res;
  191.     }
  192.     
  193.     function convertInclude(&$element)
  194.     {
  195.     }
  196.     
  197.     function convertFunction(&$element)
  198.     {
  199.     }
  200.     
  201.     function convertDefine(&$element)
  202.     {
  203.     }
  204.     
  205.     function convertPage(&$element)
  206.     {
  207.     }
  208.     
  209.     function getPageName(&$element)
  210.     {
  211.     }
  212.  
  213.     function getTutorialId($package,$subpackage,$tutorial,$id)
  214.     {
  215.     }
  216.     
  217.     function getCData($value)
  218.     {
  219.         return '';
  220.     }
  221.     
  222.     function convertPackagepage(&$element)
  223.     {
  224.     }
  225.     
  226.     function convertTutorial(&$element)
  227.     {
  228.     }
  229.     
  230.     function generateFormattedClassTrees($package)
  231.     {
  232.     }
  233.     
  234.     function getRootTree($tree,$package)
  235.     {
  236.         return '';
  237.     }
  238.     
  239.     /**
  240.      * calls {@link Cezpdf::ezOutput()} and writes documentation.pdf to targetDir
  241.      */
  242.     function Output($title = 'Generated Documentation')
  243.     {
  244.         $x="";
  245.         foreach( $this->csv_array as $line ) {
  246.             $x .= $this->getcsv( $line );
  247.         }
  248.         $this->writeFile("documentation.csv", $x, true);
  249.     }
  250.     
  251.     function mystrnatcasecmp($a,$b)
  252.     {
  253.     }
  254.     
  255.     function getClassLink($expr,$package, $file = false,$text = false)
  256.     {
  257.         return '';
  258.     }
  259.  
  260.     function getFunctionLink($expr,$package, $file = false,$text = false)
  261.     {
  262.         return '';
  263.     }
  264.  
  265.     function getDefineLink($expr,$package, $file = false,$text = false)
  266.     {
  267.         return '';
  268.     }
  269.  
  270.     function getGlobalLink($expr,$package, $file = false,$text = false)
  271.     {
  272.         return '';
  273.     }
  274.  
  275.     function getPageLink($expr,$package, $path = false,$text = false)
  276.     {
  277.         return '';
  278.     }
  279.  
  280.     function getMethodLink($expr,$class,$package, $file = false,$text = false)
  281.     {
  282.         return '';
  283.     }
  284.  
  285.     function getVarLink($expr,$class,$package, $file = false,$text = false)
  286.     {
  287.         return '';
  288.     }
  289.  
  290.     function setTemplateDir($dir)
  291.     {
  292.     }
  293.     
  294.     /** @return 1 always the same */
  295.     function getState()
  296.     {
  297.         return 1;
  298.     }
  299.     
  300.     function unmangle($notused,$source)
  301.     {
  302.     }
  303.  
  304.     function getcsv ($array, $deliminator=",") { 
  305.         // taken from www.php.net/fgetcsv
  306.         $line = ""; 
  307.         foreach($array as $val) { 
  308.             # remove any windows new lines, 
  309.             # as they interfere with the parsing at the other end 
  310.             $val = str_replace("\r\n", "\n", $val); 
  311.      
  312.             # if a deliminator char, a double quote char or a newline 
  313.             # are in the field, add quotes 
  314.             if(ereg("[$deliminator\"\n\r]", $val)) { 
  315.                 $val = '"'.str_replace('"', '""', $val).'"'; 
  316.             }
  317.             $line .= $val.$deliminator; 
  318.         }
  319.         # strip the last deliminator 
  320.         $line = substr($line, 0, (strlen($deliminator) * -1)); 
  321.         # add the newline 
  322.         $line .= "\n"; 
  323.         # we don't care if the file pointer is invalid, 
  324.         # let fputs take care of it 
  325.         return $line; 
  326.     }
  327.  
  328.     /**
  329.     * Create errors.html template file output
  330.     *
  331.     * This method takes all parsing errors and warnings and spits them out ordered by file and line number.
  332.     * @global ErrorTracker We'll be using it's output facility
  333.     */
  334.     function ConvertErrorLog()
  335.     {
  336.     # file currently contains NO path!
  337.         global $phpDocumentor_errors;
  338.         $files = array();
  339.         $warnings = $phpDocumentor_errors->returnWarnings();
  340.         $errors = $phpDocumentor_errors->returnErrors();
  341.         foreach($warnings as $warning)
  342.         {
  343.             $res=array();
  344.             $file = '##none';
  345.             $linenum = 'Warning';
  346.             if ($warning->file)
  347.             {
  348.                 $file = $warning->file;
  349.                 $linenum .= ' on line '.$warning->linenum;
  350.                 $res[] = "warning";
  351.                 $linenum=preg_replace("/.*[^0-9]/", "", $linenum);
  352.                 $res[] = $linenum; // pos
  353.                 $res[] = $file; // filename
  354.                 $res[] = $warning->data; // warning
  355.                 $this->csv_array[] = $res;
  356.             }
  357.         }
  358.         foreach($errors as $error)
  359.         {
  360.             $file = '##none';
  361.             $linenum = 'Error';
  362.             if ($error->file)
  363.             {
  364.                 $file = $error->file;
  365.                 $linenum .= ' on line '.$error->linenum;
  366.                 $res[] = "error";
  367.                 $linenum=preg_replace("/.*[^0-9]/", "", $linenum);
  368.                 $res[] = $linenum; // pos
  369.                 $res[] = $file; // filename
  370.                 $res[] = $error->data; // error
  371.                 $this->csv_array[] = $res;
  372.             }
  373.         }
  374.     }
  375.  
  376. }
  377. ?>
  378.