Permalink
Browse files

Versión 0.1.2 de PHP_Beautifier

  • Loading branch information...
clbustos committed Feb 4, 2005
0 parents commit a92c23c7e76dbf2c28ff1e37c01f7534b362d00c
Showing with 37,889 additions and 0 deletions.
  1. +1,342 −0 Beautifier.php
  2. +303 −0 Beautifier/Batch.php
  3. +63 −0 Beautifier/Batch/Output.php
  4. +59 −0 Beautifier/Batch/Output/Directory.php
  5. +43 −0 Beautifier/Batch/Output/DirectoryBz2.php
  6. +43 −0 Beautifier/Batch/Output/DirectoryGz.php
  7. +59 −0 Beautifier/Batch/Output/DirectoryTar.php
  8. +80 −0 Beautifier/Batch/Output/Files.php
  9. +39 −0 Beautifier/Batch/Output/FilesBz2.php
  10. +40 −0 Beautifier/Batch/Output/FilesGz.php
  11. +63 −0 Beautifier/Batch/Output/FilesTar.php
  12. +230 −0 Beautifier/Common.php
  13. +47 −0 Beautifier/Decorator.php
  14. +13 −0 Beautifier/Exception.php
  15. +245 −0 Beautifier/Filter.php
  16. +80 −0 Beautifier/Filter/ArrayNested.filter.php
  17. +368 −0 Beautifier/Filter/Default.filter.php
  18. +221 −0 Beautifier/Filter/IndentStyles.filter.php
  19. +144 −0 Beautifier/Filter/ListClassFunction.filter.php
  20. +125 −0 Beautifier/Filter/Pear.filter.php
  21. +48 −0 Beautifier/StreamWrapper.php
  22. +186 −0 Beautifier/StreamWrapper/Tarz.php
  23. +38 −0 Beautifier/Tokenizer.php
  24. +98 −0 Doc_PHP_Beautifier.ini
  25. BIN PhpDoc_data.lnk
  26. +9 −0 copia_cvs
  27. +6 −0 copia_cvs.bat
  28. +5 −0 correr_tests.bat
  29. +2 −0 crear_phps.sh
  30. +1 −0 demo.php
  31. +1 −0 doc.bat
  32. +666 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch.html
  33. +465 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output.html
  34. +199 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output_Directory.html
  35. +108 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output_DirectoryBz2.html
  36. +108 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output_DirectoryGz.html
  37. +197 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output_DirectoryTar.html
  38. +199 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output_Files.html
  39. +178 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output_FilesBz2.html
  40. +178 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output_FilesGz.html
  41. +365 −0 docs/PHP_Beautifier/Batch/PHP_Beautifier_Batch_Output_FilesTar.html
  42. +93 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_DirectoryBz2_php.html
  43. +93 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_DirectoryGz_php.html
  44. +93 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_DirectoryTar_php.html
  45. +64 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_Directory_php.html
  46. +93 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_FilesBz2_php.html
  47. +93 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_FilesGz_php.html
  48. +93 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_FilesTar_php.html
  49. +64 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_Files_php.html
  50. +63 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_Output_php.html
  51. +111 −0 docs/PHP_Beautifier/Batch/_usr_local_php5_lib_php_PHP_Beautifier_Batch_php.html
  52. +71 −0 docs/PHP_Beautifier/Batch/tutorial_Batch.cls.html
  53. +48 −0 docs/PHP_Beautifier/Exception_PHP_Beautifier_Filter.html
  54. +974 −0 docs/PHP_Beautifier/Filter/PHP_Beautifier_Filter.html
  55. +290 −0 docs/PHP_Beautifier/Filter/PHP_Beautifier_Filter_ArrayNested.html
  56. +1,436 −0 docs/PHP_Beautifier/Filter/PHP_Beautifier_Filter_Default.html
  57. +615 −0 docs/PHP_Beautifier/Filter/PHP_Beautifier_Filter_IndentStyles.html
  58. +505 −0 docs/PHP_Beautifier/Filter/PHP_Beautifier_Filter_ListClassFunction.html
  59. +408 −0 docs/PHP_Beautifier/Filter/PHP_Beautifier_Filter_Pear.html
  60. +64 −0 docs/PHP_Beautifier/Filter/_usr_local_php5_lib_php_PHP_Beautifier_Filter_ArrayNested_filter_php.html
  61. +63 −0 docs/PHP_Beautifier/Filter/_usr_local_php5_lib_php_PHP_Beautifier_Filter_Default_filter_php.html
  62. +64 −0 .../PHP_Beautifier/Filter/_usr_local_php5_lib_php_PHP_Beautifier_Filter_IndentStyles_filter_php.html
  63. +64 −0 ...Beautifier/Filter/_usr_local_php5_lib_php_PHP_Beautifier_Filter_ListClassFunction_filter_php.html
  64. +93 −0 docs/PHP_Beautifier/Filter/_usr_local_php5_lib_php_PHP_Beautifier_Filter_Pear_filter_php.html
  65. +65 −0 docs/PHP_Beautifier/Filter/_usr_local_php5_lib_php_PHP_Beautifier_Filter_php.html
  66. +130 −0 docs/PHP_Beautifier/Filter/tutorial_Filter.create.pkg.html
  67. +102 −0 docs/PHP_Beautifier/Filter/tutorial_Filter.pkg.html
  68. +104 −0 docs/PHP_Beautifier/Filter/tutorial_Filter2.pkg.html
  69. +2,490 −0 docs/PHP_Beautifier/PHP_Beautifier.html
  70. +353 −0 docs/PHP_Beautifier/PHP_Beautifier_Common.html
  71. +237 −0 docs/PHP_Beautifier/PHP_Beautifier_Decorator.html
  72. +208 −0 docs/PHP_Beautifier/PHP_Beautifier_Interface.html
  73. +466 −0 docs/PHP_Beautifier/StreamWrapper/PHP_Beautifier_StreamWrapper_Interface.html
  74. +781 −0 docs/PHP_Beautifier/StreamWrapper/PHP_Beautifier_StreamWrapper_Tarz.html
  75. +92 −0 docs/PHP_Beautifier/StreamWrapper/_usr_local_php5_lib_php_PHP_Beautifier_StreamWrapper_Tarz_php.html
  76. +91 −0 docs/PHP_Beautifier/StreamWrapper/_usr_local_php5_lib_php_PHP_Beautifier_StreamWrapper_php.html
  77. +137 −0 docs/PHP_Beautifier/Tokenizer/PHP_Beautifier_Tokeniker_Interface.html
  78. +63 −0 docs/PHP_Beautifier/Tokenizer/_usr_local_php5_lib_php_PHP_Beautifier_Tokenizer_php.html
  79. +76 −0 docs/PHP_Beautifier/_usr_local_php5_lib_php_PHP_Beautifier_Common_php.html
  80. +63 −0 docs/PHP_Beautifier/_usr_local_php5_lib_php_PHP_Beautifier_Decorator_php.html
  81. +65 −0 docs/PHP_Beautifier/_usr_local_php5_lib_php_PHP_Beautifier_Exception_php.html
  82. +178 −0 docs/PHP_Beautifier/_usr_local_php5_lib_php_PHP_Beautifier_php.html
  83. +102 −0 docs/PHP_Beautifier/tutorial_Filter.pkg.html
  84. +183 −0 docs/PHP_Beautifier/tutorial_PHP_Beautifier.callbacks.pkg.html
  85. +257 −0 docs/PHP_Beautifier/tutorial_PHP_Beautifier.howtouse.commandline.pkg.html
  86. +79 −0 docs/PHP_Beautifier/tutorial_PHP_Beautifier.howtouse.pkg.html
  87. +104 −0 docs/PHP_Beautifier/tutorial_PHP_Beautifier.howtouse.script.pkg.html
  88. +108 −0 docs/PHP_Beautifier/tutorial_PHP_Beautifier.pkg.html
  89. +76 −0 docs/classtrees_PHP_Beautifier.html
  90. +2,488 −0 docs/elementindex.html
  91. +2,485 −0 docs/elementindex_PHP_Beautifier.html
  92. +25 −0 docs/errors.html
  93. +24 −0 docs/index.html
  94. +176 −0 docs/li_PHP_Beautifier.html
  95. +33 −0 docs/media/banner.css
  96. BIN docs/media/images/AbstractClass.png
  97. BIN docs/media/images/AbstractClass_logo.png
  98. BIN docs/media/images/AbstractMethod.png
  99. BIN docs/media/images/AbstractPrivateClass.png
  100. BIN docs/media/images/AbstractPrivateClass_logo.png
  101. BIN docs/media/images/AbstractPrivateMethod.png
  102. BIN docs/media/images/Class.png
  103. BIN docs/media/images/Class_logo.png
  104. BIN docs/media/images/Constant.png
  105. BIN docs/media/images/Constructor.png
  106. BIN docs/media/images/Destructor.png
  107. BIN docs/media/images/Function.png
  108. BIN docs/media/images/Global.png
  109. BIN docs/media/images/I.png
  110. BIN docs/media/images/Index.png
  111. BIN docs/media/images/L.png
  112. BIN docs/media/images/Lminus.png
  113. BIN docs/media/images/Lplus.png
  114. BIN docs/media/images/Method.png
  115. BIN docs/media/images/Page.png
  116. BIN docs/media/images/Page_logo.png
  117. BIN docs/media/images/PrivateClass.png
  118. BIN docs/media/images/PrivateClass_logo.png
  119. BIN docs/media/images/PrivateMethod.png
  120. BIN docs/media/images/PrivateVariable.png
  121. BIN docs/media/images/T.png
  122. BIN docs/media/images/Tminus.png
  123. BIN docs/media/images/Tplus.png
  124. BIN docs/media/images/Variable.png
  125. BIN docs/media/images/blank.png
  126. BIN docs/media/images/class_folder.png
  127. BIN docs/media/images/empty.png
  128. BIN docs/media/images/file.png
  129. BIN docs/media/images/folder.png
  130. BIN docs/media/images/function_folder.png
  131. BIN docs/media/images/next_button.png
  132. BIN docs/media/images/next_button_disabled.png
  133. BIN docs/media/images/package.png
  134. BIN docs/media/images/package_folder.png
  135. BIN docs/media/images/previous_button.png
  136. BIN docs/media/images/previous_button_disabled.png
  137. BIN docs/media/images/private_class_logo.png
  138. BIN docs/media/images/tutorial.png
  139. BIN docs/media/images/tutorial_folder.png
  140. BIN docs/media/images/up_button.png
  141. +146 −0 docs/media/stylesheet.css
  142. +29 −0 docs/packages.html
  143. +33 −0 docs/todolist.html
  144. +1 −0 examples/README
  145. +8 −0 examples/example.js
  146. +6 −0 examples/example_array.php
  147. +47 −0 examples/example_comments.php
  148. +25 −0 examples/example_html.php
  149. +88 −0 examples/example_main.php
  150. +47 −0 examples/example_pear.php
  151. +2,634 −0 examples/log.txt
  152. +41 −0 examples/run_me.php
  153. +59 −0 licenses/apache.txt
  154. +32 −0 licenses/bsd.txt
  155. +23 −0 licenses/lgpl.txt
  156. +19 −0 licenses/php.txt
  157. +1,517 −0 log.txt
  158. +5 −0 pack_beaut
  159. +7 −0 pack_beaut.bat
  160. +108 −0 package.dtd
  161. +249 −0 package.xml
  162. +237 −0 scripts/php_beautifier
  163. +5 −0 scripts/php_beautifier.bat
  164. BIN site/PHP_Beautifier-0.0.6.1.tgz
  165. +1 −0 site/a.htaccess
  166. +79 −0 site/demo/index.php
  167. +1 −0 site/example.phps
  168. +21 −0 site/example_callbacks.php
  169. +46 −0 site/example_output.phps
  170. +115 −0 site/index.php
  171. +1,252 −0 site/phps/Beautifier.php
  172. +292 −0 site/phps/Beautifier/Batch.php
  173. +57 −0 site/phps/Beautifier/Batch/Output.php
  174. +59 −0 site/phps/Beautifier/Batch/Output/Directory.php
  175. +43 −0 site/phps/Beautifier/Batch/Output/DirectoryBz2.php
  176. +43 −0 site/phps/Beautifier/Batch/Output/DirectoryGz.php
  177. +59 −0 site/phps/Beautifier/Batch/Output/DirectoryTar.php
  178. +78 −0 site/phps/Beautifier/Batch/Output/Files.php
  179. +40 −0 site/phps/Beautifier/Batch/Output/FilesBz2.php
  180. +40 −0 site/phps/Beautifier/Batch/Output/FilesGz.php
  181. +60 −0 site/phps/Beautifier/Batch/Output/FilesTar.php
  182. +231 −0 site/phps/Beautifier/Common.php
  183. +45 −0 site/phps/Beautifier/Decorator.php
  184. +13 −0 site/phps/Beautifier/Exception.php
  185. +232 −0 site/phps/Beautifier/Filter.php
  186. +77 −0 site/phps/Beautifier/Filter/ArrayNested.filter.php
  187. +298 −0 site/phps/Beautifier/Filter/Default.filter.php
  188. +211 −0 site/phps/Beautifier/Filter/IndentStyles.filter.php
  189. +139 −0 site/phps/Beautifier/Filter/ListClassFunction.filter.php
  190. +122 −0 site/phps/Beautifier/Filter/Pear.filter.php
  191. +49 −0 site/phps/Beautifier/StreamWrapper.php
  192. +174 −0 site/phps/Beautifier/StreamWrapper/Tarz.php
  193. +39 −0 site/phps/Beautifier/Tokenizer.php
  194. +1 −0 site/phps/demo.php
  195. +22 −0 site/phps/examples/example_array.php
  196. +53 −0 site/phps/examples/example_comments.php
  197. +26 −0 site/phps/examples/example_html.php
  198. +111 −0 site/phps/examples/example_main.php
  199. +46 −0 site/phps/examples/example_pear.php
  200. +43 −0 site/phps/examples/run_me.php
  201. +77 −0 site/phps/site/demo/index.php
  202. +49 −0 site/phps/site/example_callbacks.php
  203. +113 −0 site/phps/site/index.php
  204. +5 −0 site/phps/site/view_source.php
  205. +34 −0 site/phps/test.php
  206. +193 −0 site/phps/test2.php
  207. +1,327 −0 site/phps/token.php
  208. BIN site/uml/PackageOverviewbatch.jpg
  209. BIN site/uml/PackageOverviewbeautifier.jpg
  210. BIN site/uml/PackageOverviewpear.jpg
  211. BIN site/uml/PackageOverviewstreamwrapper.jpg
  212. BIN site/uml/PackageOverwievphp.jpg
  213. BIN site/uml/PackagePHP_Beautifier.jpg
  214. +5 −0 site/view_source.php
  215. +4 −0 svn-commit.tmp
  216. +1 −0 test.bat
  217. +30 −0 test.php
  218. +351 −0 tests/Beautifier.phpt
  219. BIN tests/Beautifier.tar.bz2
  220. BIN tests/Beautifier.tar.gz
  221. +191 −0 tests/Beautifier_Bugs.phpt
  222. +61 −0 tests/Beautifier_Common.phpt
  223. +105 −0 tests/Beautifier_StreamWrapper.phpt
  224. +8 −0 tests/lista
  225. +136 −0 tests/log.txt
  226. +1 −0 tutorials/PHP_Beautifier/.htaccess
  227. +27 −0 tutorials/PHP_Beautifier/Batch/Batch.cls
  228. +99 −0 tutorials/PHP_Beautifier/Filter/Filter.create.pkg
  229. +63 −0 tutorials/PHP_Beautifier/Filter/Filter2.pkg
  230. +2 −0 tutorials/PHP_Beautifier/Filter/Filter2.pkg.ini
  231. +139 −0 tutorials/PHP_Beautifier/PHP_Beautifier.callbacks.pkg
  232. +304 −0 tutorials/PHP_Beautifier/PHP_Beautifier.howtouse.commandline.pkg
  233. +36 −0 tutorials/PHP_Beautifier/PHP_Beautifier.howtouse.pkg
  234. +4 −0 tutorials/PHP_Beautifier/PHP_Beautifier.howtouse.pkg.ini
  235. +70 −0 tutorials/PHP_Beautifier/PHP_Beautifier.howtouse.script.pkg
  236. +99 −0 tutorials/PHP_Beautifier/PHP_Beautifier.pkg
  237. +4 −0 tutorials/PHP_Beautifier/PHP_Beautifier.pkg.ini
  238. +4 −0 tutorials/doc2html.bat
  239. +4 −0 tutorials/html2doc.bat
  240. BIN uml/PHP_Beautifier.dia
  241. +699 −0 uml/PHP_Beautifier.xmi
  242. BIN uml/PHP_Beautifier.zargo
  243. BIN uml/PHP_Beautifier.zuml
  244. BIN uml/PHP_Beautifier.zuml.bak.0
  245. BIN uml/PHP_Beautifier.zuml.bak.1
  246. BIN uml/PHP_Beautifier.zuml.bak.2
  247. BIN uml/PHP_Beautifier.zuml.bak.3
  248. BIN uml/PHP_Beautifier.zuml.bak.4

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,303 @@
+<?php
+ /* vim: set expandtab tabstop=4 shiftwidth=4: */
+ // +----------------------------------------------------------------------+
+ // | PHP version 5 |
+ // +----------------------------------------------------------------------+
+ // | Copyright (c) 1997-2004 The PHP Group |
+ // +----------------------------------------------------------------------+
+ // | This source file is subject to version 3.0 of the PHP license, |
+ // | that is bundled with this package in the file LICENSE, and is |
+ // | available through the world-wide-web at the following url: |
+ // | http://www.php.net/license/3_0.txt. |
+ // | If you did not receive a copy of the PHP license and are unable to |
+ // | obtain it through the world-wide-web, please send a note to |
+ // | license@php.net so we can mail you a copy immediately. |
+ // +----------------------------------------------------------------------+
+ // | Authors: Claudio Bustos <cdx@users.sourceforge.net> |
+ // | Jens Bierkandt <schtorch@users.sourceforge.net> |
+ // +----------------------------------------------------------------------+
+ //
+ // $Id:
+
+ /**
+ * Definition of PHP_Beautifier_Batch
+ * @package PHP_Beautifier
+ * @subpackage Batch
+ * @author Claudio Bustos <cdx@users.sourceforge.net>
+ */
+ /**
+ * Require PHP_Beautifier_Decorator
+ */
+ require_once ('Decorator.php');
+ require_once ('Batch/Output.php');
+ // ArrayNested->off();
+ // ArrayNested->on();
+
+ /**
+ * Adds functionality to handle multiple files.
+ * - STDIN : As normal
+ * - STDOUT : Send all the scripts, prepended with the name of the original route
+ * - One in, one out: as normal
+ * - Multiple In, one out: determine the type of out.
+ * - Without '/' at the end, same as STDOUT.
+ * - With '/' at the end, copy the base structure and copy all the scripts
+ *
+ * If the file out end in .tgz, the output will be a tar archive. The same action
+ * will be obtained with {@link setCompress()} to true
+ * Use:
+ * <code>
+ * require "PHP/Beautifier.php";
+ * require "PHP/Beautifier/Batch.php";
+ * $oBeaut= new PHP_Beautifier();
+ * $oBatch= new PHP_Beautifier_Batch($oBeaut); // Decorator
+ * $oBatch->setInputFile(__FILE__);
+ * $oBatch->process();
+ * $oBatch->show();
+ * </code>
+ * @package PHP_Beautifier
+ * @subpackage Batch
+ * @author Claudio Bustos <cdx@users.sourceforge.net>
+ */
+ class PHP_Beautifier_Batch extends PHP_Beautifier_Decorator {
+ /**
+ * Compression method (for now, false, 'gz' and 'bz2')
+ * @var string
+ */
+ private $sCompress = false;
+ /**
+ * Array or STDIN of paths to parse
+ * @var array
+ */
+ private $mPreInputFiles = array();
+ /**
+ * Path to the output
+ */
+ private $sPreOutputFile = './';
+ /**
+ * @var PHP_Beautifier_Batch_Output
+ */
+ private $oBatchOutput;
+ /**
+ * @var array PHP_Beautifier_Batch_Input
+ */
+ private $aBatchInputs;
+ public $mInputFiles;
+ /**
+ * Output mode. Could be {@link PHP_Beautifier_Batch::FILES} or
+ * {@link PHP_Beautifier_Batch::DIRECTORY}
+ */
+ private $sOutputMode;
+ const FILES = 'Files';
+ const DIRECTORY = 'Directory';
+ /**
+ * Recursive search on dirs
+ * @var bool
+ */
+ public $bRecursive = false;
+ // public methods, overloaded from PHP_Beautifier
+
+ /**
+ * Set recursive search for files in dirs on
+ * @param bool
+ */
+ public function setRecursive($bRecursive = true)
+ {
+ $this->bRecursive = $bRecursive;
+ }
+ /**
+ * Set compression on/off
+ * @param mixed bool(false, true for gzip) or string ('gz' or 'gz2')
+ */
+ public function setCompress($mCompress = true)
+ {
+ if ($mCompress === true) {
+ $mCompress = 'gz';
+ } elseif (!$mCompress) {
+ $mCompress = false;
+ } elseif (!is_string($mCompress)) {
+ throw(new Exception('You have to define a mode for compress'));
+ }
+ $this->sCompress = $mCompress;
+ }
+ /**
+ * Set the input(s) files
+ * Could be STDIN or a name, with special chars (?,*)
+ * @param mixed STDIN or string(path)
+ * @return bool
+ */
+ public function setInputFile($mFiles)
+ {
+ if ($this->mPreInputFiles == STDIN and $mFiles != STDIN) {
+ throw(new Exception("Hey, you already defined STDIN,dude"));
+ } elseif ($mFiles == STDIN) {
+ $this->mPreInputFiles = STDIN;
+ } else {
+ // ArrayNested->off()
+ if (is_string($mFiles)) {
+ $mFiles = array($mFiles);
+ }
+ // ArrayNested->on()
+ $this->mPreInputFiles = array_merge($this->mPreInputFiles, $mFiles);
+ }
+ return true;
+ }
+ /**
+ * Set the output file
+ * Could be STDOUT or a path to a file or dir (with '/' at the end)
+ * @param mixed STDOUT or string (path)
+ * @return true
+ */
+ public function setOutputFile($sFile)
+ {
+ if (!is_string($sFile) and $sFile != STDOUT) {
+ throw(new Exception("Accept only string or STDOUT"));
+ }
+ $this->sPreOutputFile = $sFile;
+ return true;
+ }
+ private function setInputFilePost()
+ {
+ // ArrayNested->off()
+ if ($this->mPreInputFiles == STDIN) {
+ $mInputFiles = array(STDIN);
+ } else {
+ $mInputFiles = array();
+ foreach($this->mPreInputFiles as $sPath) {
+ $mInputFiles = array_merge($mInputFiles, PHP_Beautifier_Common::getFilesByGlob($sPath, $this->bRecursive));
+ }
+ }
+ // now, we create stream references for compressed files....
+ foreach($mInputFiles as $sFile) {
+ // First, tar files
+ if ($sFile!=STDIN and preg_match("/(.tgz|\.tar\.gz|\.tar\.bz2|\.tar)$/",$sFile,$aMatch)) {
+ if (strpos($aMatch[1], 'gz') !== FALSE) {
+ $sCompress = 'gz';
+ } elseif (strpos($aMatch[1], 'bz2') !== FALSE) {
+ $sCompress = 'bz2';
+ } elseif (strpos($aMatch[1],'tar')!==FALSE) {
+ $sCompress = false;
+ }
+ $oTar=new Archive_Tar($sFile,$sCompress);
+ foreach($oTar->listContent() as $aInput) {
+ if (empty($aInput['typeflag'])) {
+ $this->mInputFiles[]='tarz://'.$sFile.'#'.$aInput['filename'];
+ }
+ }
+ } else {
+ $this->mInputFiles[]=$sFile;
+ }
+ }
+ if(!$this->mInputFiles) {
+ throw(new Exception("Can't match any file"));
+ }
+ return true;
+ // ArrayNested->on()
+
+ }
+ private function setOutputFilePost()
+ {
+ if ($this->sPreOutputFile == STDOUT) {
+ $this->sOutputMode = PHP_Beautifier_Batch::FILES;
+ } else {
+ $sPath = str_replace(DIRECTORY_SEPARATOR, '/', $this->sPreOutputFile);
+ if (!$sPath) {
+ $sPath = "./";
+ }
+ // determine file or dir
+ if (substr($sPath, -1) != '/' and !is_dir($sPath)) {
+ $this->sOutputMode = PHP_Beautifier_Batch::FILES;
+ // Define compression mode
+ if (preg_match("/\.(gz|bz2)$/", $sPath, $aMatch)) {
+ $this->sCompress = $aMatch[1];
+ }
+ } else {
+ $this->sOutputMode = PHP_Beautifier_Batch::DIRECTORY;
+ }
+ }
+ return true;
+ }
+ /**
+ * Create the real references to files
+ * @return bool
+ * @throws Exception
+ */
+ public function process()
+ {
+ if (!$this->mPreInputFiles) {
+ throw(new Exception('Input file not defined'));
+ } else {
+ $this->setInputFilePost();
+ $this->setOutputFilePost();
+ }
+ return;
+ if (!$this->mInputFiles) {
+ throw(new Exception(implode(',', $this->mPreInputFiles) ." doesn't match any files"));
+ } else {
+ return true;
+ }
+ }
+ private function getBatchEngine()
+ {
+
+ $sCompress = ($this->sCompress)?ucfirst($this->sCompress):'';
+ $sClass = $this->sOutputMode.$sCompress;
+ $sClassEngine = 'PHP_Beautifier_Batch_Output_'.$sClass;
+ $sClassFile = PHP_Beautifier_Common::normalizeDir(dirname(__FILE__)) .'Batch/Output/'.$sClass.'.php';
+ if (!file_exists($sClassFile)) {
+ throw(new Exception("Doesn't exists file definition for $sClass ($sClassFile)"));
+ } else {
+ include_once ($sClassFile);
+ if (!class_exists($sClassEngine)) {
+ throw(new Exception("$sClassFile exists, but $sClassEngine isn't defined"));
+ } else {
+ return new $sClassEngine($this);
+ }
+ }
+ }
+ /**
+ * Save the beautified sources to file(s)
+ * @return bool
+ * @throws Exception
+ */
+ public function save($sFile=null)
+ {
+ $oBatchEngine = $this->getBatchEngine();
+ return $oBatchEngine->save();
+ }
+ /**
+ * Return a string with the content of the file(s)
+ * @return string
+ */
+ public function get()
+ {
+ $oBatchEngine = $this->getBatchEngine();
+ return $oBatchEngine->get();
+ }
+ public function show()
+ {
+ echo $this->get();
+ }
+ /**
+ * Allows subclass of {@link PHP_Beautifier_Batch_Engine} call methods of {@link $oBeaut}
+ * @param PHP_Beautifier_Batch_Engine
+ * @param string method to call
+ * @param array array of args
+ * @return mixed
+ */
+ public function callBeautifier(PHP_Beautifier_Batch_Output $oEngine, $sMethod, $aArgs = array())
+ {
+ return @call_user_func_array(array(
+ $this->oBeaut,
+ $sMethod
+ ) , $aArgs);
+ }
+ public function getInputFiles()
+ {
+ return $this->mInputFiles;
+ }
+ public function getOutputPath()
+ {
+ return $this->sPreOutputFile;
+ }
+ }
+?>
@@ -0,0 +1,63 @@
+<?php
+ /* vim: set expandtab tabstop=4 shiftwidth=4: */
+ // +----------------------------------------------------------------------+
+ // | PHP version 5 |
+ // +----------------------------------------------------------------------+
+ // | Copyright (c) 1997-2004 The PHP Group |
+ // +----------------------------------------------------------------------+
+ // | This source file is subject to version 3.0 of the PHP license, |
+ // | that is bundled with this package in the file LICENSE, and is |
+ // | available through the world-wide-web at the following url: |
+ // | http://www.php.net/license/3_0.txt. |
+ // | If you did not receive a copy of the PHP license and are unable to |
+ // | obtain it through the world-wide-web, please send a note to |
+ // | license@php.net so we can mail you a copy immediately. |
+ // +----------------------------------------------------------------------+
+ // | Authors: Claudio Bustos <cdx@users.sourceforge.net> |
+ // | Jens Bierkandt <schtorch@users.sourceforge.net> |
+ // +----------------------------------------------------------------------+
+ //
+ // $Id:
+ /**
+ * @package PHP_Beautifier
+ * @subpackage Batch
+ */
+ /**
+ * PHP_Beautifier_Batch_Output
+ * @package PHP_Beautifier
+ * @subpackage Batch
+ */
+ abstract class PHP_Beautifier_Batch_Output {
+ protected $oBatch;
+ public function __construct(PHP_Beautifier_Batch $oBatch)
+ {
+ $this->oBatch = $oBatch;
+ }
+ protected function beautifierSetInputFile($sFile)
+ {
+ return $this->oBatch->callBeautifier($this, 'setInputFile', array(
+ $sFile
+ ));
+ }
+ protected function beautifierProcess()
+ {
+ return $this->oBatch->callBeautifier($this, 'process');
+ }
+ protected function beautifierGet()
+ {
+ return $this->oBatch->callBeautifier($this, 'get');
+ }
+ protected function beautifierSave($sFile)
+ {
+ return $this->oBatch->callBeautifier($this, 'save', array(
+ $sFile
+ ));
+ }
+ public function get()
+ {
+ }
+ public function save()
+ {
+ }
+ }
+?>
Oops, something went wrong.

0 comments on commit a92c23c

Please sign in to comment.