Location: PHPKode > projects > MyPhpMoney > myphpmoney_2.0/public_html/doc/phpdoc.php
<?php
/**
 * $Id: phpdoc.php 336 2003-04-02 12:18:39Z courou $
 *
 * Author     : courou&#64;users.sourceforge.net
 * Website    : http://allreponse.ath.cx
 *
 * Support    : http://sourceforge.net/projects/myphpmoney/
 * CVS        : http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/myphpmoney/
 *
 * Phpdoc utilitaire php pour generer de la doc
 *
 * $out  = XML | HTML (choix du format)
 * $high = oui | non (choix d'afficher le code source ou pas)
 */

if (!defined('__DOC__')) { define('__DOC__', 'YES');

/**
 * BEGIN CONFIG FILE NIV
 */
     require_once '../config/settings.inc.php';

/**
 * DEFINE VARIABLE GLOBALS
 */
      $_MPM['phpdoc_classes']       = array(); ## class
      $_MPM['phpdoc_functs']        = array(); ## functions
      $_MPM['phpdoc_vars']          = array(); ## vars

/**
 * SECURITY FOR NOT SCANN POSSIBILITY ALL THE FILE
 */
     if (isset($_GET['userfile']) && (!stristr($_GET['userfile'],$_MPM['dir_class'])) &&
        (!stristr($_GET['userfile'],$_PHPLIB['libdir'])) && (!stristr($_GET['userfile'],$_MPM['dir_function'])) &&
        (!stristr($_GET['userfile'],$_MPM['dir_graph'])) && (!stristr($_GET['userfile'],$_MPM['dir_style']))) {
     XHTML_Exit(__NIV__.'/'.$_MPM['http'][6]);
     }
     else if (isset($_POST['userfile'])) {
      XHTML_Exit(__NIV__.'/'.$_MPM['http'][6]);
     }
     else if (!isset($_GET['userfile'])) {
      XHTML_Exit(__NIV__.'/'.$_MPM['http'][6]);
     }

/**
 * GENERATE AND DISPLAY THE DOC
 */
     $fp = false;
     $high = 'non'; ## NO SHOW SOURCE BY DEFAULT
     if (!isset($_GET['userfile'])) $_GET['userfile'] = 'none';
     if (isset($_GET['userfile']) && $_GET['userfile'] != 'none') {
          $fp = fopen($_GET['userfile'],'r');
     }

if (!$fp) XHTML_Exit(__NIV__.'/'.$_MPM['http'][6]);
else if ($fp) {

  require_once $_MPM['dir_class'].''.$_MPM['class_phpdoc'];
  $PHPSCAN = new PHPscanner();
  $PHPSCAN->scanFile($fp);
  $objs = $PHPSCAN->objs;

  for ($i=0; $i<sizeof($objs); $i++) {
    switch ($objs[$i]->typ) {
        default: break;
        case __CLASST__: $_MPM['phpdoc_classes'][]   = $objs[$i];    break;
        case __FUNCT__:  $_MPM['phpdoc_functs'][]    = $objs[$i];    break;
        case __VART__:   $_MPM['phpdoc_vars'][]      = $objs[$i];    break;
    }
  }

/**
 * XML THE TEMPLATES -- BUILD HEADER PHPDOC
 */
        ## MODE XML
        if (isset($_GET['out']) && $_GET['out'] == 'XML') {

        header('content-type: text/xml');

          XHTML_SetFile('xml.tpl','',0);
          $_MPM['BeginMixed'] = array
          (
                 'TEMPLATES'            => $_MPM['dir_template'],
                 'HTTP_DOC_XSL'         => 'phpdoc.xsl',
                 'PHPDOC_XML_FILE'      => $_GET['userfile']
          );

        for ($b=0; $b<2; $b++) {
            XHTML_PhpDoc('xml.tpl',$b,($b == 0 ? $_MPM['phpdoc_classes'] : $_MPM['phpdoc_functs']),'toXML');
        }
        XHTML_SetFile('xml.tpl',$_MPM['BeginMixed'],4);

        ## MODE XHTML
        } else {

/**
 * BUILD THE HEADER
 */
     XHTML_header(1,0,0,0,0,0,0,1);

/**
 * HIGHLIGHT MODE
 */

 if (isset($_GET['high']) && $_GET['high'] == 'oui') {                ## HIGHLIGHT FILE
     echo '<span class="texte">';
     highlight_file($_GET['userfile']);
     echo '</span>';

 } else {                                                             ## NO HIGHLIGHT FILE

     $_MPM['BeginMixed'] = array
     (
               'PHPDOC_TOKEN_NOM'       => $_VAR['PHPDOC_TOKEN_NOM'],
               'PHPDOC_TOKEN_DESC'      => $_VAR['PHPDOC_TOKEN_DESC'],
               'PHPDOC_TOKEN_CLS'       => $_VAR['PHPDOC_TOKEN_CLS'],
               'PHPDOC_TOKEN_FNT'       => $_VAR['PHPDOC_TOKEN_FNT'],
               'PHPDOC_TOKEN_SRC'       => $_VAR['PHPDOC_TOKEN_SRC']
     );
     XHTML_SetFile('phpdoc.tpl','',0);

     $tpl->set_block('FILE_phpdoc.tpl', 'BOUCLE_PHPDOC_SECOND_CLASS', 'BLOCK_phpdoc.tpl_GO_1'); ## BLOCK INTERNE
     $tpl->set_block('FILE_phpdoc.tpl', 'BOUCLE_PHPDOC_FIRST_CLASS', 'BLOCK_phpdoc.tpl_GO_2');  ## BLOCK EXTERNE

for ($b=0; $b<2; $b++) {

  $tpl->set_var(array(
     'PHPDOC_TOKEN_CHOIX'  => $b == 0 ? $_VAR['PHPDOC_TOKEN_CLS'] : $_VAR['PHPDOC_TOKEN_FNT']
  ));
  $tpl->set_var('BLOCK_phpdoc.tpl_GO_1',''); ## EMPTY THE VALUES FOR SECOND BOUCLE
  $choice_class_function = ($b == 0 ? $_MPM['phpdoc_classes'] : $_MPM['phpdoc_functs']);

  if (sizeof($choice_class_function)>0) {

       for ($i=0; $i<sizeof($choice_class_function ); $i++) {

             $d = new cmtobj;
             $d->parse($choice_class_function[$i]->desc);

       $tpl->set_var(array(
                     'PHPDOC_USERFILE'       => $_GET['userfile'],
                     'PHPDOC_TXT'            => $d->txt,
                     'PHPDOC_ANCHOR'         => $choice_class_function[$i]->name
       ));
       $tpl->parse('BLOCK_phpdoc.tpl_GO_1','BOUCLE_PHPDOC_SECOND_CLASS',true); ## DISPLAY SECOND VALUE
       } ## end of for ($i = 0; $i<sizeof($_MPM['phpdoc_classes']); $i++)

       $tpl->parse('BLOCK_phpdoc.tpl_GO_2','BOUCLE_PHPDOC_FIRST_CLASS',true);  ## DISPLAY FIRST VALUE

   ## DISPLAY THE FUNCTION - CLASS (XML AND XHTML)
   XHTML_PhpDoc('phpdoc.tpl',$b,($b == 0 ? $_MPM['phpdoc_classes'] : $_MPM['phpdoc_functs']),'toHTML');

   } ## end of (sizeof($choice_class_function)>0)
} ## end of for (b=0; b >2; b++)

XHTML_SetFile('phpdoc.tpl',$_MPM['BeginMixed'],4);
} ## end of if (isset($_GET['high']). ...

/**
 * LINK SHOW SOURCE
 */
     $_MPM['BeginMixed'] = array
      (
          'HIGHLIGHT_HREF' => isset($_GET['high']) && $_GET['high'] == 'oui'
                                  ? htmlspecialchars(str_replace('&high=oui','',$_SERVER['REQUEST_URI']))
                                  : htmlspecialchars($_SERVER['REQUEST_URI'].'&high=oui'),
          'HIGHLIGHT_NAME' => isset($_GET['high']) && $_GET['high'] == 'oui'
                                  ? $_VAR['DOC_LANG_PHPDOC_6'] : $_VAR['DOC_LANG_PHPDOC_7']
     );
     XHTML_SetFile('show.tpl',$_MPM['BeginMixed'],2);

/**
 * BUILD THE FOOTER
 */
     XHTML_footer();
        } ## end of mode XHTML - XML...
    } ## end of if ($fp)
 } ## end of __DOC__
Return current item: MyPhpMoney