File: phpdoc.php

package info (click to toggle)
myphpmoney 1.3RC3-13
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,160 kB
  • ctags: 884
  • sloc: php: 18,081; pascal: 2,106; sh: 327; xml: 239; makefile: 137; sql: 130
file content (179 lines) | stat: -rw-r--r-- 6,102 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
/**
 * $Id: phpdoc.php,v 1.12 2003/04/02 12:16:54 courou Exp $
 *
 * 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__