@@ -136,6 +136,7 @@ private function struct($node, $reset=FALSE, $parent=array())
136136
137137 if (!empty ($ kind ) && !empty ($ name ) && !empty ($ line )) {
138138 $ structs [] = array (
139+ 'file ' => $ this ->mFile ,
139140 'kind ' => $ kind ,
140141 'name ' => $ name ,
141142 'line ' => $ line ,
@@ -154,8 +155,14 @@ private function struct($node, $reset=FALSE, $parent=array())
154155 private function render ($ structs , $ options )
155156 {
156157 $ str = '' ;
157- $ lines = file ($ this ->mFile );
158158 foreach ($ structs as $ struct ) {
159+ $ file = $ struct ['file ' ];
160+
161+ if (!isset ($ files [$ file ]))
162+ $ files [$ file ] = file ($ file );
163+
164+ $ lines = $ files [$ file ];
165+
159166 if (empty ($ struct ['name ' ]) || empty ($ struct ['line ' ]) || empty ($ struct ['kind ' ]))
160167 return ;
161168
@@ -165,7 +172,7 @@ private function render($structs, $options)
165172 $ str .= $ struct ['name ' ];
166173 }
167174
168- $ str .= "\t" . $ this -> mFile ;
175+ $ str .= "\t" . $ file ;
169176
170177 if ($ options ['excmd ' ] == 'number ' ) {
171178 $ str .= "\t" . $ struct ['line ' ];
@@ -225,9 +232,36 @@ private function render($structs, $options)
225232
226233 public function export ($ file , $ options )
227234 {
228- //@todo Check for existence
229- $ this ->mFile = $ file ;
230- $ structs = $ this ->struct ($ this ->mParser ->parse (file_get_contents ($ this ->mFile )), TRUE );
235+ $ structs = array ();
236+ if (is_dir ($ file ) && isset ($ options ['R ' ])) {
237+ $ iterator = new RecursiveIteratorIterator (
238+ new RecursiveDirectoryIterator (
239+ $ file ,
240+ FilesystemIterator::SKIP_DOTS |
241+ FilesystemIterator::FOLLOW_SYMLINKS
242+ )
243+ );
244+
245+ $ extensions = array ('.php ' , '.php3 ' , '.php4 ' , '.php5 ' , '.phps ' );
246+
247+ foreach ($ iterator as $ filename ) {
248+ if (!in_array (substr ($ filename , strrpos ($ filename , '. ' )), $ extensions )) {
249+ continue ;
250+ }
251+
252+ if (isset ($ options ['exclude ' ]) && false !== strpos ($ filename , $ options ['exclude ' ])) {
253+ continue ;
254+ }
255+
256+ //@todo Check for existence
257+ $ this ->mFile = (string ) $ filename ;
258+ $ structs += $ this ->struct ($ this ->mParser ->parse (file_get_contents ($ this ->mFile )), TRUE );
259+ }
260+ } else {
261+ //@todo Check for existence
262+ $ this ->mFile = $ file ;
263+ $ structs += $ this ->struct ($ this ->mParser ->parse (file_get_contents ($ this ->mFile )), TRUE );
264+ }
231265 return $ this ->render ($ structs , $ options );
232266 }
233267}
0 commit comments