From 17139224a1f1f2bbdcc1f1a98cb20f60a12bdfab Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Sun, 18 Nov 2012 17:14:48 +0000 Subject: update ping. Part 1: delete old version --- .gitattributes | 22 - buildscripts/phing/CREDITS | 45 - buildscripts/phing/LICENSE | 1042 ------ buildscripts/phing/README | 78 - buildscripts/phing/bin/pear-phing | 22 - buildscripts/phing/bin/pear-phing.bat | 44 - buildscripts/phing/bin/phing | 75 - buildscripts/phing/bin/phing.bat | 58 - buildscripts/phing/bin/phing.php | 54 - buildscripts/phing/classes/phing/BuildEvent.php | 205 -- .../phing/classes/phing/BuildException.php | 100 - buildscripts/phing/classes/phing/BuildListener.php | 91 - .../phing/classes/phing/IntrospectionHelper.php | 542 --- buildscripts/phing/classes/phing/Phing.php | 1161 ------- buildscripts/phing/classes/phing/Project.php | 966 ------ .../phing/classes/phing/ProjectComponent.php | 72 - .../phing/classes/phing/RuntimeConfigurable.php | 118 - buildscripts/phing/classes/phing/Target.php | 317 -- buildscripts/phing/classes/phing/Task.php | 266 -- buildscripts/phing/classes/phing/TaskAdapter.php | 84 - buildscripts/phing/classes/phing/TaskContainer.php | 42 - .../phing/classes/phing/UnknownElement.php | 211 -- .../classes/phing/filters/BaseFilterReader.php | 157 - .../phing/filters/BaseParamFilterReader.php | 69 - .../classes/phing/filters/ChainableReader.php | 42 - .../classes/phing/filters/ExpandProperties.php | 82 - .../phing/classes/phing/filters/HeadFilter.php | 161 - .../phing/classes/phing/filters/LineContains.php | 258 -- .../classes/phing/filters/LineContainsRegexp.php | 179 - .../phing/classes/phing/filters/PrefixLines.php | 142 - .../phing/classes/phing/filters/ReplaceRegexp.php | 129 - .../phing/classes/phing/filters/ReplaceTokens.php | 415 --- .../classes/phing/filters/StripLineBreaks.php | 148 - .../classes/phing/filters/StripLineComments.php | 205 -- .../classes/phing/filters/StripPhpComments.php | 190 -- .../phing/classes/phing/filters/TabToSpaces.php | 144 - .../phing/classes/phing/filters/TailFilter.php | 157 - .../phing/classes/phing/filters/TidyFilter.php | 162 - .../classes/phing/filters/TranslateGettext.php | 285 -- .../phing/classes/phing/filters/XsltFilter.php | 317 -- .../phing/filters/util/ChainReaderHelper.php | 184 - .../phing/filters/util/IniFileTokenReader.php | 96 - .../classes/phing/input/DefaultInputHandler.php | 82 - .../phing/classes/phing/input/InputHandler.php | 45 - .../phing/classes/phing/input/InputRequest.php | 107 - .../phing/input/MultipleChoiceInputRequest.php | 58 - .../phing/input/PropertyFileInputHandler.php | 129 - .../classes/phing/input/YesNoInputRequest.php | 47 - buildscripts/phing/classes/phing/lib/Capsule.php | 266 -- buildscripts/phing/classes/phing/lib/Zip.php | 3588 -------------------- .../classes/phing/listener/AnsiColorLogger.php | 231 -- .../phing/classes/phing/listener/BuildLogger.php | 42 - .../phing/classes/phing/listener/DefaultLogger.php | 233 -- .../classes/phing/listener/NoBannerLogger.php | 61 - .../phing/classes/phing/listener/PearLogger.php | 246 -- .../phing/classes/phing/listener/XmlLogger.php | 265 -- .../classes/phing/listener/defaults.properties | 43 - .../phing/classes/phing/mappers/FileNameMapper.php | 59 - .../phing/classes/phing/mappers/FlattenMapper.php | 55 - .../phing/classes/phing/mappers/GlobMapper.php | 113 - .../phing/classes/phing/mappers/IdentityMapper.php | 54 - .../phing/classes/phing/mappers/MergeMapper.php | 69 - .../phing/classes/phing/mappers/RegexpMapper.php | 97 - .../phing/classes/phing/parser/AbstractHandler.php | 98 - .../classes/phing/parser/AbstractSAXParser.php | 140 - .../phing/classes/phing/parser/DataTypeHandler.php | 144 - .../classes/phing/parser/ExpatParseException.php | 31 - .../phing/classes/phing/parser/ExpatParser.php | 140 - .../phing/classes/phing/parser/Location.php | 72 - .../classes/phing/parser/NestedElementHandler.php | 186 - .../classes/phing/parser/ProjectConfigurator.php | 246 -- .../phing/classes/phing/parser/ProjectHandler.php | 146 - .../phing/classes/phing/parser/RootHandler.php | 82 - .../phing/classes/phing/parser/TargetHandler.php | 149 - .../phing/classes/phing/parser/TaskHandler.php | 229 -- .../classes/phing/system/io/BufferedReader.php | 170 - .../classes/phing/system/io/BufferedWriter.php | 72 - .../classes/phing/system/io/ConsoleReader.php | 84 - .../phing/classes/phing/system/io/FileReader.php | 179 - .../phing/classes/phing/system/io/FileSystem.php | 657 ---- .../phing/classes/phing/system/io/FileWriter.php | 139 - .../phing/classes/phing/system/io/FilterReader.php | 72 - .../phing/classes/phing/system/io/IOException.php | 28 - .../phing/classes/phing/system/io/PhingFile.php | 866 ----- .../phing/classes/phing/system/io/Reader.php | 88 - .../phing/classes/phing/system/io/StringReader.php | 73 - .../phing/classes/phing/system/io/TokenReader.php | 51 - .../classes/phing/system/io/UnixFileSystem.php | 266 -- .../classes/phing/system/io/Win32FileSystem.php | 477 --- .../classes/phing/system/io/WinNTFileSystem.php | 35 - .../phing/classes/phing/system/io/Writer.php | 48 - .../phing/classes/phing/system/lang/Character.php | 49 - .../classes/phing/system/lang/EventObject.php | 52 - .../phing/system/lang/FileNotFoundException.php | 27 - .../phing/system/lang/NullPointerException.php | 27 - .../phing/system/lang/SecurityException.php | 27 - .../phing/classes/phing/system/util/Message.php | 9 - .../phing/classes/phing/system/util/Properties.php | 270 -- .../phing/classes/phing/system/util/Register.php | 115 - .../phing/classes/phing/system/util/Timer.php | 96 - .../phing/classes/phing/tasks/defaults.properties | 69 - .../phing/classes/phing/tasks/ext/CapsuleTask.php | 478 --- .../classes/phing/tasks/ext/CreoleSQLExecTask.php | 556 --- .../phing/classes/phing/tasks/ext/CreoleTask.php | 242 -- .../phing/classes/phing/tasks/ext/MailTask.php | 77 - .../classes/phing/tasks/ext/PackageAsPathTask.php | 65 - .../classes/phing/tasks/ext/PearPackageTask.php | 421 --- .../phing/classes/phing/tasks/ext/PhpLintTask.php | 82 - .../phing/classes/phing/tasks/ext/SmartyTask.php | 610 ---- .../phing/classes/phing/tasks/ext/TarTask.php | 380 --- .../phing/classes/phing/tasks/ext/XmlLintTask.php | 116 - .../phing/tasks/ext/ZendCodeAnalyzerTask.php | 163 - .../phing/classes/phing/tasks/ext/ZipTask.php | 176 - .../phing/tasks/ext/coverage/CoverageMerger.php | 127 - .../tasks/ext/coverage/CoverageMergerTask.php | 92 - .../tasks/ext/coverage/CoverageReportTask.php | 406 --- .../ext/coverage/CoverageReportTransformer.php | 121 - .../phing/tasks/ext/coverage/CoverageSetupTask.php | 163 - .../phing/tasks/ext/ioncube/IoncubeComment.php | 44 - .../phing/tasks/ext/ioncube/IoncubeEncoderTask.php | 336 -- .../phing/tasks/ext/ioncube/IoncubeLicenseTask.php | 144 - .../phing/tasks/ext/pearpackage/Fileset.php | 231 -- .../phing/tasks/ext/phpdoc/PHPDocumentorTask.php | 157 - .../classes/phing/tasks/ext/phpunit2/BatchTest.php | 171 - .../phing/tasks/ext/phpunit2/FormatterElement.php | 120 - .../tasks/ext/phpunit2/PHPUnit2ReportTask.php | 162 - .../tasks/ext/phpunit2/PHPUnit2ResultFormatter.php | 154 - .../phing/tasks/ext/phpunit2/PHPUnit2Task.php | 239 -- .../tasks/ext/phpunit2/PHPUnit2TestRunner.php | 107 - .../phing/tasks/ext/phpunit2/PHPUnit2Util.php | 114 - .../ext/phpunit2/PlainPHPUnit2ResultFormatter.php | 117 - .../phpunit2/SummaryPHPUnit2ResultFormatter.php | 58 - .../ext/phpunit2/XMLPHPUnit2ResultFormatter.php | 117 - .../simpletest/SimpleTestCountResultFormatter.php | 52 - .../ext/simpletest/SimpleTestFormatterElement.php | 126 - .../simpletest/SimpleTestPlainResultFormatter.php | 95 - .../ext/simpletest/SimpleTestResultFormatter.php | 162 - .../SimpleTestSummaryResultFormatter.php | 54 - .../phing/tasks/ext/simpletest/SimpleTestTask.php | 234 -- .../simpletest/SimpleTestXmlResultFormatter.php | 154 - .../classes/phing/tasks/ext/svn/SvnBaseTask.php | 180 - .../classes/phing/tasks/ext/svn/SvnExportTask.php | 68 - .../phing/tasks/ext/svn/SvnLastRevisionTask.php | 75 - .../phing/classes/phing/tasks/system/AdhocTask.php | 88 - .../phing/tasks/system/AdhocTaskdefTask.php | 90 - .../phing/tasks/system/AdhocTypedefTask.php | 71 - .../classes/phing/tasks/system/AppendTask.php | 240 -- .../classes/phing/tasks/system/AvailableTask.php | 132 - .../phing/classes/phing/tasks/system/ChmodTask.php | 177 - .../classes/phing/tasks/system/ConditionTask.php | 74 - .../phing/classes/phing/tasks/system/CopyTask.php | 401 --- .../classes/phing/tasks/system/CvsPassTask.php | 173 - .../phing/classes/phing/tasks/system/CvsTask.php | 540 --- .../classes/phing/tasks/system/DeleteTask.php | 277 -- .../phing/classes/phing/tasks/system/EchoTask.php | 107 - .../phing/classes/phing/tasks/system/ExecTask.php | 248 -- .../phing/classes/phing/tasks/system/ExitTask.php | 118 - .../classes/phing/tasks/system/ForeachTask.php | 138 - .../phing/classes/phing/tasks/system/IfTask.php | 224 -- .../classes/phing/tasks/system/IncludePathTask.php | 115 - .../phing/classes/phing/tasks/system/InputTask.php | 146 - .../classes/phing/tasks/system/MatchingTask.php | 361 -- .../phing/classes/phing/tasks/system/MkdirTask.php | 64 - .../phing/classes/phing/tasks/system/MoveTask.php | 197 -- .../classes/phing/tasks/system/PhingCallTask.php | 139 - .../phing/classes/phing/tasks/system/PhingTask.php | 596 ---- .../classes/phing/tasks/system/PhpEvalTask.php | 169 - .../phing/tasks/system/PropertyPromptTask.php | 201 -- .../classes/phing/tasks/system/PropertyTask.php | 438 --- .../classes/phing/tasks/system/ReflexiveTask.php | 155 - .../classes/phing/tasks/system/ResolvePathTask.php | 122 - .../classes/phing/tasks/system/SequentialTask.php | 57 - .../classes/phing/tasks/system/TaskdefTask.php | 127 - .../phing/classes/phing/tasks/system/TouchTask.php | 170 - .../classes/phing/tasks/system/TstampTask.php | 168 - .../classes/phing/tasks/system/TypedefTask.php | 125 - .../classes/phing/tasks/system/UpToDateTask.php | 217 -- .../phing/classes/phing/tasks/system/WarnTask.php | 35 - .../phing/classes/phing/tasks/system/XsltTask.php | 81 - .../phing/tasks/system/condition/AndCondition.php | 46 - .../phing/tasks/system/condition/Condition.php | 39 - .../phing/tasks/system/condition/ConditionBase.php | 195 -- .../tasks/system/condition/ContainsCondition.php | 76 - .../tasks/system/condition/EqualsCondition.php | 78 - .../tasks/system/condition/IsFalseCondition.php | 60 - .../tasks/system/condition/IsSetCondition.php | 53 - .../tasks/system/condition/IsTrueCondition.php | 59 - .../phing/tasks/system/condition/NotCondition.php | 48 - .../phing/tasks/system/condition/OrCondition.php | 46 - .../phing/tasks/system/condition/OsCondition.php | 63 - .../system/condition/ReferenceExistsCondition.php | 52 - .../phing/classes/phing/types/AbstractFileSet.php | 570 ---- .../phing/classes/phing/types/Commandline.php | 467 --- .../phing/classes/phing/types/DataType.php | 182 - .../phing/classes/phing/types/Description.php | 53 - buildscripts/phing/classes/phing/types/DirSet.php | 49 - .../phing/classes/phing/types/FileList.php | 223 -- buildscripts/phing/classes/phing/types/FileSet.php | 56 - .../phing/classes/phing/types/FilterChain.php | 164 - buildscripts/phing/classes/phing/types/Mapper.php | 207 -- .../phing/classes/phing/types/Parameter.php | 99 - .../phing/classes/phing/types/Parameterizable.php | 32 - buildscripts/phing/classes/phing/types/Path.php | 456 --- .../phing/classes/phing/types/PatternSet.php | 449 --- .../classes/phing/types/PhingFilterReader.php | 136 - .../phing/classes/phing/types/Reference.php | 56 - .../classes/phing/types/RegularExpression.php | 105 - .../phing/classes/phing/types/TokenReader.php | 66 - .../phing/classes/phing/types/TokenSource.php | 157 - .../phing/classes/phing/types/defaults.properties | 13 - .../classes/phing/types/selectors/AndSelector.php | 67 - .../phing/types/selectors/BaseExtendSelector.php | 62 - .../classes/phing/types/selectors/BaseSelector.php | 84 - .../types/selectors/BaseSelectorContainer.php | 270 -- .../types/selectors/ContainsRegexpSelector.php | 164 - .../phing/types/selectors/ContainsSelector.php | 151 - .../classes/phing/types/selectors/DateSelector.php | 214 -- .../phing/types/selectors/DependSelector.php | 151 - .../phing/types/selectors/DepthSelector.php | 158 - .../phing/types/selectors/ExtendFileSelector.php | 43 - .../phing/types/selectors/ExtendSelector.php | 127 - .../classes/phing/types/selectors/FileSelector.php | 47 - .../phing/types/selectors/FilenameSelector.php | 157 - .../phing/types/selectors/MajoritySelector.php | 92 - .../classes/phing/types/selectors/NoneSelector.php | 71 - .../classes/phing/types/selectors/NotSelector.php | 59 - .../classes/phing/types/selectors/OrSelector.php | 72 - .../phing/types/selectors/PresentSelector.php | 154 - .../phing/types/selectors/SelectSelector.php | 124 - .../phing/types/selectors/SelectorContainer.php | 141 - .../phing/types/selectors/SelectorScanner.php | 55 - .../phing/types/selectors/SelectorUtils.php | 440 --- .../classes/phing/types/selectors/SizeSelector.php | 228 -- .../classes/phing/types/selectors/TypeSelector.php | 113 - .../phing/classes/phing/util/DirectoryScanner.php | 710 ---- .../classes/phing/util/ExtendedFileStream.php | 133 - .../phing/classes/phing/util/FileUtils.php | 294 -- .../phing/classes/phing/util/LogWriter.php | 96 - .../phing/classes/phing/util/PathTokenizer.php | 245 -- .../phing/classes/phing/util/SourceFileScanner.php | 159 - .../phing/classes/phing/util/StringHelper.php | 209 -- .../phing/classes/phing/util/regexp/PregEngine.php | 105 - .../phing/classes/phing/util/regexp/Regexp.php | 168 - .../classes/phing/util/regexp/RegexpEngine.php | 74 - buildscripts/phing/etc/VERSION.TXT | 1 - buildscripts/phing/etc/coverage-frames.xsl | 669 ---- buildscripts/phing/etc/log.xsl | 216 -- buildscripts/phing/etc/phpunit2-frames.xsl | 677 ---- buildscripts/phing/etc/phpunit2-noframes.xsl | 436 --- buildscripts/phing/etc/str.replace.function.xsl | 105 - .../phing/pear/BuildPhingPEARPackageTask.php | 270 -- buildscripts/phing/pear/build.xml | 156 - buildscripts/phing/style/coverage-frames.xsl | 636 ---- buildscripts/phing/style/log.xsl | 216 -- buildscripts/phing/style/phpunit2-frames.xsl | 677 ---- buildscripts/phing/style/phpunit2-noframes.xsl | 436 --- buildscripts/phing/style/str.replace.function.xsl | 105 - 257 files changed, 49655 deletions(-) delete mode 100644 buildscripts/phing/CREDITS delete mode 100644 buildscripts/phing/LICENSE delete mode 100644 buildscripts/phing/README delete mode 100644 buildscripts/phing/bin/pear-phing delete mode 100644 buildscripts/phing/bin/pear-phing.bat delete mode 100644 buildscripts/phing/bin/phing delete mode 100644 buildscripts/phing/bin/phing.bat delete mode 100644 buildscripts/phing/bin/phing.php delete mode 100644 buildscripts/phing/classes/phing/BuildEvent.php delete mode 100644 buildscripts/phing/classes/phing/BuildException.php delete mode 100644 buildscripts/phing/classes/phing/BuildListener.php delete mode 100644 buildscripts/phing/classes/phing/IntrospectionHelper.php delete mode 100644 buildscripts/phing/classes/phing/Phing.php delete mode 100644 buildscripts/phing/classes/phing/Project.php delete mode 100644 buildscripts/phing/classes/phing/ProjectComponent.php delete mode 100644 buildscripts/phing/classes/phing/RuntimeConfigurable.php delete mode 100644 buildscripts/phing/classes/phing/Target.php delete mode 100644 buildscripts/phing/classes/phing/Task.php delete mode 100644 buildscripts/phing/classes/phing/TaskAdapter.php delete mode 100644 buildscripts/phing/classes/phing/TaskContainer.php delete mode 100644 buildscripts/phing/classes/phing/UnknownElement.php delete mode 100644 buildscripts/phing/classes/phing/filters/BaseFilterReader.php delete mode 100644 buildscripts/phing/classes/phing/filters/BaseParamFilterReader.php delete mode 100644 buildscripts/phing/classes/phing/filters/ChainableReader.php delete mode 100644 buildscripts/phing/classes/phing/filters/ExpandProperties.php delete mode 100644 buildscripts/phing/classes/phing/filters/HeadFilter.php delete mode 100644 buildscripts/phing/classes/phing/filters/LineContains.php delete mode 100644 buildscripts/phing/classes/phing/filters/LineContainsRegexp.php delete mode 100644 buildscripts/phing/classes/phing/filters/PrefixLines.php delete mode 100644 buildscripts/phing/classes/phing/filters/ReplaceRegexp.php delete mode 100644 buildscripts/phing/classes/phing/filters/ReplaceTokens.php delete mode 100644 buildscripts/phing/classes/phing/filters/StripLineBreaks.php delete mode 100644 buildscripts/phing/classes/phing/filters/StripLineComments.php delete mode 100644 buildscripts/phing/classes/phing/filters/StripPhpComments.php delete mode 100644 buildscripts/phing/classes/phing/filters/TabToSpaces.php delete mode 100644 buildscripts/phing/classes/phing/filters/TailFilter.php delete mode 100644 buildscripts/phing/classes/phing/filters/TidyFilter.php delete mode 100644 buildscripts/phing/classes/phing/filters/TranslateGettext.php delete mode 100644 buildscripts/phing/classes/phing/filters/XsltFilter.php delete mode 100644 buildscripts/phing/classes/phing/filters/util/ChainReaderHelper.php delete mode 100644 buildscripts/phing/classes/phing/filters/util/IniFileTokenReader.php delete mode 100644 buildscripts/phing/classes/phing/input/DefaultInputHandler.php delete mode 100644 buildscripts/phing/classes/phing/input/InputHandler.php delete mode 100644 buildscripts/phing/classes/phing/input/InputRequest.php delete mode 100644 buildscripts/phing/classes/phing/input/MultipleChoiceInputRequest.php delete mode 100644 buildscripts/phing/classes/phing/input/PropertyFileInputHandler.php delete mode 100644 buildscripts/phing/classes/phing/input/YesNoInputRequest.php delete mode 100644 buildscripts/phing/classes/phing/lib/Capsule.php delete mode 100644 buildscripts/phing/classes/phing/lib/Zip.php delete mode 100644 buildscripts/phing/classes/phing/listener/AnsiColorLogger.php delete mode 100644 buildscripts/phing/classes/phing/listener/BuildLogger.php delete mode 100644 buildscripts/phing/classes/phing/listener/DefaultLogger.php delete mode 100644 buildscripts/phing/classes/phing/listener/NoBannerLogger.php delete mode 100644 buildscripts/phing/classes/phing/listener/PearLogger.php delete mode 100644 buildscripts/phing/classes/phing/listener/XmlLogger.php delete mode 100644 buildscripts/phing/classes/phing/listener/defaults.properties delete mode 100644 buildscripts/phing/classes/phing/mappers/FileNameMapper.php delete mode 100644 buildscripts/phing/classes/phing/mappers/FlattenMapper.php delete mode 100644 buildscripts/phing/classes/phing/mappers/GlobMapper.php delete mode 100644 buildscripts/phing/classes/phing/mappers/IdentityMapper.php delete mode 100644 buildscripts/phing/classes/phing/mappers/MergeMapper.php delete mode 100644 buildscripts/phing/classes/phing/mappers/RegexpMapper.php delete mode 100644 buildscripts/phing/classes/phing/parser/AbstractHandler.php delete mode 100644 buildscripts/phing/classes/phing/parser/AbstractSAXParser.php delete mode 100644 buildscripts/phing/classes/phing/parser/DataTypeHandler.php delete mode 100644 buildscripts/phing/classes/phing/parser/ExpatParseException.php delete mode 100644 buildscripts/phing/classes/phing/parser/ExpatParser.php delete mode 100644 buildscripts/phing/classes/phing/parser/Location.php delete mode 100644 buildscripts/phing/classes/phing/parser/NestedElementHandler.php delete mode 100644 buildscripts/phing/classes/phing/parser/ProjectConfigurator.php delete mode 100644 buildscripts/phing/classes/phing/parser/ProjectHandler.php delete mode 100644 buildscripts/phing/classes/phing/parser/RootHandler.php delete mode 100644 buildscripts/phing/classes/phing/parser/TargetHandler.php delete mode 100644 buildscripts/phing/classes/phing/parser/TaskHandler.php delete mode 100644 buildscripts/phing/classes/phing/system/io/BufferedReader.php delete mode 100644 buildscripts/phing/classes/phing/system/io/BufferedWriter.php delete mode 100644 buildscripts/phing/classes/phing/system/io/ConsoleReader.php delete mode 100644 buildscripts/phing/classes/phing/system/io/FileReader.php delete mode 100644 buildscripts/phing/classes/phing/system/io/FileSystem.php delete mode 100644 buildscripts/phing/classes/phing/system/io/FileWriter.php delete mode 100644 buildscripts/phing/classes/phing/system/io/FilterReader.php delete mode 100644 buildscripts/phing/classes/phing/system/io/IOException.php delete mode 100644 buildscripts/phing/classes/phing/system/io/PhingFile.php delete mode 100644 buildscripts/phing/classes/phing/system/io/Reader.php delete mode 100644 buildscripts/phing/classes/phing/system/io/StringReader.php delete mode 100644 buildscripts/phing/classes/phing/system/io/TokenReader.php delete mode 100644 buildscripts/phing/classes/phing/system/io/UnixFileSystem.php delete mode 100644 buildscripts/phing/classes/phing/system/io/Win32FileSystem.php delete mode 100644 buildscripts/phing/classes/phing/system/io/WinNTFileSystem.php delete mode 100644 buildscripts/phing/classes/phing/system/io/Writer.php delete mode 100644 buildscripts/phing/classes/phing/system/lang/Character.php delete mode 100644 buildscripts/phing/classes/phing/system/lang/EventObject.php delete mode 100644 buildscripts/phing/classes/phing/system/lang/FileNotFoundException.php delete mode 100644 buildscripts/phing/classes/phing/system/lang/NullPointerException.php delete mode 100644 buildscripts/phing/classes/phing/system/lang/SecurityException.php delete mode 100644 buildscripts/phing/classes/phing/system/util/Message.php delete mode 100644 buildscripts/phing/classes/phing/system/util/Properties.php delete mode 100644 buildscripts/phing/classes/phing/system/util/Register.php delete mode 100644 buildscripts/phing/classes/phing/system/util/Timer.php delete mode 100644 buildscripts/phing/classes/phing/tasks/defaults.properties delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/CapsuleTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/CreoleSQLExecTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/CreoleTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/MailTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/PackageAsPathTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/PearPackageTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/PhpLintTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/SmartyTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/TarTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/XmlLintTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/ZendCodeAnalyzerTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/ZipTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/coverage/CoverageMerger.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/coverage/CoverageMergerTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/coverage/CoverageReportTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/coverage/CoverageReportTransformer.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/coverage/CoverageSetupTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/ioncube/IoncubeComment.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/ioncube/IoncubeEncoderTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/ioncube/IoncubeLicenseTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/pearpackage/Fileset.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpdoc/PHPDocumentorTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/BatchTest.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/FormatterElement.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/PHPUnit2ReportTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/PHPUnit2ResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/PHPUnit2Task.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/PHPUnit2TestRunner.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/PHPUnit2Util.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/PlainPHPUnit2ResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/SummaryPHPUnit2ResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/phpunit2/XMLPHPUnit2ResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestCountResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestFormatterElement.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestPlainResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestSummaryResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/simpletest/SimpleTestXmlResultFormatter.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/svn/SvnBaseTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/svn/SvnExportTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/ext/svn/SvnLastRevisionTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/AdhocTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/AdhocTaskdefTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/AdhocTypedefTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/AppendTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/AvailableTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/ChmodTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/ConditionTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/CopyTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/CvsPassTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/CvsTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/DeleteTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/EchoTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/ExecTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/ExitTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/ForeachTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/IfTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/IncludePathTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/InputTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/MatchingTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/MkdirTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/MoveTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/PhingCallTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/PhingTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/PhpEvalTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/PropertyPromptTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/PropertyTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/ReflexiveTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/ResolvePathTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/SequentialTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/TaskdefTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/TouchTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/TstampTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/TypedefTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/UpToDateTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/WarnTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/XsltTask.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/AndCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/Condition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/ConditionBase.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/ContainsCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/EqualsCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/IsFalseCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/IsSetCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/IsTrueCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/NotCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/OrCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/OsCondition.php delete mode 100644 buildscripts/phing/classes/phing/tasks/system/condition/ReferenceExistsCondition.php delete mode 100644 buildscripts/phing/classes/phing/types/AbstractFileSet.php delete mode 100644 buildscripts/phing/classes/phing/types/Commandline.php delete mode 100644 buildscripts/phing/classes/phing/types/DataType.php delete mode 100644 buildscripts/phing/classes/phing/types/Description.php delete mode 100644 buildscripts/phing/classes/phing/types/DirSet.php delete mode 100644 buildscripts/phing/classes/phing/types/FileList.php delete mode 100644 buildscripts/phing/classes/phing/types/FileSet.php delete mode 100644 buildscripts/phing/classes/phing/types/FilterChain.php delete mode 100644 buildscripts/phing/classes/phing/types/Mapper.php delete mode 100644 buildscripts/phing/classes/phing/types/Parameter.php delete mode 100644 buildscripts/phing/classes/phing/types/Parameterizable.php delete mode 100644 buildscripts/phing/classes/phing/types/Path.php delete mode 100644 buildscripts/phing/classes/phing/types/PatternSet.php delete mode 100644 buildscripts/phing/classes/phing/types/PhingFilterReader.php delete mode 100644 buildscripts/phing/classes/phing/types/Reference.php delete mode 100644 buildscripts/phing/classes/phing/types/RegularExpression.php delete mode 100644 buildscripts/phing/classes/phing/types/TokenReader.php delete mode 100644 buildscripts/phing/classes/phing/types/TokenSource.php delete mode 100644 buildscripts/phing/classes/phing/types/defaults.properties delete mode 100644 buildscripts/phing/classes/phing/types/selectors/AndSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/BaseExtendSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/BaseSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/BaseSelectorContainer.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/ContainsRegexpSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/ContainsSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/DateSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/DependSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/DepthSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/ExtendFileSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/ExtendSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/FileSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/FilenameSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/MajoritySelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/NoneSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/NotSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/OrSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/PresentSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/SelectSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/SelectorContainer.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/SelectorScanner.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/SelectorUtils.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/SizeSelector.php delete mode 100644 buildscripts/phing/classes/phing/types/selectors/TypeSelector.php delete mode 100644 buildscripts/phing/classes/phing/util/DirectoryScanner.php delete mode 100644 buildscripts/phing/classes/phing/util/ExtendedFileStream.php delete mode 100644 buildscripts/phing/classes/phing/util/FileUtils.php delete mode 100644 buildscripts/phing/classes/phing/util/LogWriter.php delete mode 100644 buildscripts/phing/classes/phing/util/PathTokenizer.php delete mode 100644 buildscripts/phing/classes/phing/util/SourceFileScanner.php delete mode 100644 buildscripts/phing/classes/phing/util/StringHelper.php delete mode 100644 buildscripts/phing/classes/phing/util/regexp/PregEngine.php delete mode 100644 buildscripts/phing/classes/phing/util/regexp/Regexp.php delete mode 100644 buildscripts/phing/classes/phing/util/regexp/RegexpEngine.php delete mode 100644 buildscripts/phing/etc/VERSION.TXT delete mode 100644 buildscripts/phing/etc/coverage-frames.xsl delete mode 100644 buildscripts/phing/etc/log.xsl delete mode 100644 buildscripts/phing/etc/phpunit2-frames.xsl delete mode 100644 buildscripts/phing/etc/phpunit2-noframes.xsl delete mode 100644 buildscripts/phing/etc/str.replace.function.xsl delete mode 100644 buildscripts/phing/pear/BuildPhingPEARPackageTask.php delete mode 100644 buildscripts/phing/pear/build.xml delete mode 100644 buildscripts/phing/style/coverage-frames.xsl delete mode 100644 buildscripts/phing/style/log.xsl delete mode 100644 buildscripts/phing/style/phpunit2-frames.xsl delete mode 100644 buildscripts/phing/style/phpunit2-noframes.xsl delete mode 100644 buildscripts/phing/style/str.replace.function.xsl diff --git a/.gitattributes b/.gitattributes index 3102dd50..9dabd3fe 100644 --- a/.gitattributes +++ b/.gitattributes @@ -850,28 +850,6 @@ buildscripts/jGrouseDoc/themes/sample/img/openLarge.gif -text buildscripts/jGrouseDoc/themes/simple/build.xml -text buildscripts/jGrouseDoc/themes/simple/css/theme.css -text buildscripts/jGrouseDoc/velocity-dep-1.5.jar -text -buildscripts/phing/CREDITS -text -buildscripts/phing/LICENSE -text -buildscripts/phing/README -text -buildscripts/phing/bin/pear-phing -text -buildscripts/phing/bin/pear-phing.bat -text -buildscripts/phing/bin/phing -text -buildscripts/phing/bin/phing.bat -text -buildscripts/phing/classes/phing/listener/defaults.properties -text -buildscripts/phing/classes/phing/tasks/defaults.properties -text -buildscripts/phing/classes/phing/types/defaults.properties -text -buildscripts/phing/etc/VERSION.TXT -text -buildscripts/phing/etc/coverage-frames.xsl -text -buildscripts/phing/etc/log.xsl -text -buildscripts/phing/etc/phpunit2-frames.xsl -text -buildscripts/phing/etc/phpunit2-noframes.xsl -text -buildscripts/phing/etc/str.replace.function.xsl -text -buildscripts/phing/pear/build.xml -text -buildscripts/phing/style/coverage-frames.xsl -text -buildscripts/phing/style/log.xsl -text -buildscripts/phing/style/phpunit2-frames.xsl -text -buildscripts/phing/style/phpunit2-noframes.xsl -text -buildscripts/phing/style/str.replace.function.xsl -text buildscripts/texbuilder/quickstart/quickstart.tex -text buildscripts/texbuilder/sqlmap/sqlmap.tex -text buildscripts/texbuilder/time-tracker/db.vsd -text diff --git a/buildscripts/phing/CREDITS b/buildscripts/phing/CREDITS deleted file mode 100644 index 0aff0706..00000000 --- a/buildscripts/phing/CREDITS +++ /dev/null @@ -1,45 +0,0 @@ - _________________________ - P H I N G - - New PHP5 PHING/2 Development - ---------------------------- - - Hans Lellelid - David Giffin - Michiel Rook - Sebastian Bergmann - - If you've done work on phing and you are not listed here, please feel free - to add yourself. - - Original PHING/1 Development - ----------------------------- - - Andreas Aderhold - Alex Black - Albert Lash - Charlie Killian - Manuel Holtgrewe - Andrzej Nowodworski - Jason Hines - Jesse Estevez - Andris Spruds - Ronald TAO - Yannick Lecaillez - Hans Lellelid - - Other libraries/contributions - ------------------------------ - - Apache ANT Project - License: Apache 1.1 - Phing is a port of the Apache ANT project. - http://ant.apache.org/ - - TAR Manager Class - License: LGPL - The Tar archive abstraction class - (c) Josh Barger - http://phpclasses.upperdesign.com/browse.html/package/529.html - - --$Id: CREDITS,v 1.6 2005/02/03 13:41:52 mrook Exp $ diff --git a/buildscripts/phing/LICENSE b/buildscripts/phing/LICENSE deleted file mode 100644 index 9139d608..00000000 --- a/buildscripts/phing/LICENSE +++ /dev/null @@ -1,1042 +0,0 @@ - _________________________ - - P H I N G - - - - - - Please, be sure to read the license header on any one of the phing core - - files. It explains the licensing scheme. - - - - Some files in phing are Perl Artistic, Apache, BSD, or just free. See - - "CREDITS" for a list. - - - - We've included a copy of the LGPL for convenience. - - - - - - LGPL LICENSE - - ------------ - - - - GNU LESSER GENERAL PUBLIC LICENSE - - Version 2.1, February 1999 - - - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Everyone is permitted to copy and distribute verbatim copies - - of this license document, but changing it is not allowed. - - - - [This is the first released version of the Lesser GPL. It also counts - - as the successor of the GNU Library Public License, version 2, hence - - the version number 2.1.] - - - - Preamble - - - - The licenses for most software are designed to take away your - - freedom to share and change it. By contrast, the GNU General Public - - Licenses are intended to guarantee your freedom to share and change - - free software--to make sure the software is free for all its users. - - - - This license, the Lesser General Public License, applies to some - - specially designated software packages--typically libraries--of the - - Free Software Foundation and other authors who decide to use it. You - - can use it too, but we suggest you first think carefully about whether - - this license or the ordinary General Public License is the better - - strategy to use in any particular case, based on the explanations below. - - - - When we speak of free software, we are referring to freedom of use, - - not price. Our General Public Licenses are designed to make sure that - - you have the freedom to distribute copies of free software (and charge - - for this service if you wish); that you receive source code or can get - - it if you want it; that you can change the software and use pieces of - - it in new free programs; and that you are informed that you can do - - these things. - - - - To protect your rights, we need to make restrictions that forbid - - distributors to deny you these rights or to ask you to surrender these - - rights. These restrictions translate to certain responsibilities for - - you if you distribute copies of the library or if you modify it. - - - - For example, if you distribute copies of the library, whether gratis - - or for a fee, you must give the recipients all the rights that we gave - - you. You must make sure that they, too, receive or can get the source - - code. If you link other code with the library, you must provide - - complete object files to the recipients, so that they can relink them - - with the library after making changes to the library and recompiling - - it. And you must show them these terms so they know their rights. - - - - We protect your rights with a two-step method: (1) we copyright the - - library, and (2) we offer you this license, which gives you legal - - permission to copy, distribute and/or modify the library. - - - - To protect each distributor, we want to make it very clear that - - there is no warranty for the free library. Also, if the library is - - modified by someone else and passed on, the recipients should know - - that what they have is not the original version, so that the original - - author's reputation will not be affected by problems that might be - - introduced by others. - - - - Finally, software patents pose a constant threat to the existence of - - any free program. We wish to make sure that a company cannot - - effectively restrict the users of a free program by obtaining a - - restrictive license from a patent holder. Therefore, we insist that - - any patent license obtained for a version of the library must be - - consistent with the full freedom of use specified in this license. - - - - Most GNU software, including some libraries, is covered by the - - ordinary GNU General Public License. This license, the GNU Lesser - - General Public License, applies to certain designated libraries, and - - is quite different from the ordinary General Public License. We use - - this license for certain libraries in order to permit linking those - - libraries into non-free programs. - - - - When a program is linked with a library, whether statically or using - - a shared library, the combination of the two is legally speaking a - - combined work, a derivative of the original library. The ordinary - - General Public License therefore permits such linking only if the - - entire combination fits its criteria of freedom. The Lesser General - - Public License permits more lax criteria for linking other code with - - the library. - - - - We call this license the "Lesser" General Public License because it - - does Less to protect the user's freedom than the ordinary General - - Public License. It also provides other free software developers Less - - of an advantage over competing non-free programs. These disadvantages - - are the reason we use the ordinary General Public License for many - - libraries. However, the Lesser license provides advantages in certain - - special circumstances. - - - - For example, on rare occasions, there may be a special need to - - encourage the widest possible use of a certain library, so that it - - becomes a de-facto standard. To achieve this, non-free programs must be - - allowed to use the library. A more frequent case is that a free - - library does the same job as widely used non-free libraries. In this - - case, there is little to gain by limiting the free library to free - - software only, so we use the Lesser General Public License. - - - - In other cases, permission to use a particular library in non-free - - programs enables a greater number of people to use a large body of - - free software. For example, permission to use the GNU C Library in - - non-free programs enables many more people to use the whole GNU - - operating system, as well as its variant, the GNU/Linux operating - - system. - - - - Although the Lesser General Public License is Less protective of the - - users' freedom, it does ensure that the user of a program that is - - linked with the Library has the freedom and the wherewithal to run - - that program using a modified version of the Library. - - - - The precise terms and conditions for copying, distribution and - - modification follow. Pay close attention to the difference between a - - "work based on the library" and a "work that uses the library". The - - former contains code derived from the library, whereas the latter must - - be combined with the library in order to run. - - - - GNU LESSER GENERAL PUBLIC LICENSE - - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - - - 0. This License Agreement applies to any software library or other - - program which contains a notice placed by the copyright holder or - - other authorized party saying it may be distributed under the terms of - - this Lesser General Public License (also called "this License"). - - Each licensee is addressed as "you". - - - - A "library" means a collection of software functions and/or data - - prepared so as to be conveniently linked with application programs - - (which use some of those functions and data) to form executables. - - - - The "Library", below, refers to any such software library or work - - which has been distributed under these terms. A "work based on the - - Library" means either the Library or any derivative work under - - copyright law: that is to say, a work containing the Library or a - - portion of it, either verbatim or with modifications and/or translated - - straightforwardly into another language. (Hereinafter, translation is - - included without limitation in the term "modification".) - - - - "Source code" for a work means the preferred form of the work for - - making modifications to it. For a library, complete source code means - - all the source code for all modules it contains, plus any associated - - interface definition files, plus the scripts used to control compilation - - and installation of the library. - - - - Activities other than copying, distribution and modification are not - - covered by this License; they are outside its scope. The act of - - running a program using the Library is not restricted, and output from - - such a program is covered only if its contents constitute a work based - - on the Library (independent of the use of the Library in a tool for - - writing it). Whether that is true depends on what the Library does - - and what the program that uses the Library does. - - - - 1. You may copy and distribute verbatim copies of the Library's - - complete source code as you receive it, in any medium, provided that - - you conspicuously and appropriately publish on each copy an - - appropriate copyright notice and disclaimer of warranty; keep intact - - all the notices that refer to this License and to the absence of any - - warranty; and distribute a copy of this License along with the - - Library. - - - - You may charge a fee for the physical act of transferring a copy, - - and you may at your option offer warranty protection in exchange for a - - fee. - - - - 2. You may modify your copy or copies of the Library or any portion - - of it, thus forming a work based on the Library, and copy and - - distribute such modifications or work under the terms of Section 1 - - above, provided that you also meet all of these conditions: - - - - a) The modified work must itself be a software library. - - - - b) You must cause the files modified to carry prominent notices - - stating that you changed the files and the date of any change. - - - - c) You must cause the whole of the work to be licensed at no - - charge to all third parties under the terms of this License. - - - - d) If a facility in the modified Library refers to a function or a - - table of data to be supplied by an application program that uses - - the facility, other than as an argument passed when the facility - - is invoked, then you must make a good faith effort to ensure that, - - in the event an application does not supply such function or - - table, the facility still operates, and performs whatever part of - - its purpose remains meaningful. - - - - (For example, a function in a library to compute square roots has - - a purpose that is entirely well-defined independent of the - - application. Therefore, Subsection 2d requires that any - - application-supplied function or table used by this function must - - be optional: if the application does not supply it, the square - - root function must still compute square roots.) - - - - These requirements apply to the modified work as a whole. If - - identifiable sections of that work are not derived from the Library, - - and can be reasonably considered independent and separate works in - - themselves, then this License, and its terms, do not apply to those - - sections when you distribute them as separate works. But when you - - distribute the same sections as part of a whole which is a work based - - on the Library, the distribution of the whole must be on the terms of - - this License, whose permissions for other licensees extend to the - - entire whole, and thus to each and every part regardless of who wrote - - it. - - - - Thus, it is not the intent of this section to claim rights or contest - - your rights to work written entirely by you; rather, the intent is to - - exercise the right to control the distribution of derivative or - - collective works based on the Library. - - - - In addition, mere aggregation of another work not based on the Library - - with the Library (or with a work based on the Library) on a volume of - - a storage or distribution medium does not bring the other work under - - the scope of this License. - - - - 3. You may opt to apply the terms of the ordinary GNU General Public - - License instead of this License to a given copy of the Library. To do - - this, you must alter all the notices that refer to this License, so - - that they refer to the ordinary GNU General Public License, version 2, - - instead of to this License. (If a newer version than version 2 of the - - ordinary GNU General Public License has appeared, then you can specify - - that version instead if you wish.) Do not make any other change in - - these notices. - - - - Once this change is made in a given copy, it is irreversible for - - that copy, so the ordinary GNU General Public License applies to all - - subsequent copies and derivative works made from that copy. - - - - This option is useful when you wish to copy part of the code of - - the Library into a program that is not a library. - - - - 4. You may copy and distribute the Library (or a portion or - - derivative of it, under Section 2) in object code or executable form - - under the terms of Sections 1 and 2 above provided that you accompany - - it with the complete corresponding machine-readable source code, which - - must be distributed under the terms of Sections 1 and 2 above on a - - medium customarily used for software interchange. - - - - If distribution of object code is made by offering access to copy - - from a designated place, then offering equivalent access to copy the - - source code from the same place satisfies the requirement to - - distribute the source code, even though third parties are not - - compelled to copy the source along with the object code. - - - - 5. A program that contains no derivative of any portion of the - - Library, but is designed to work with the Library by being compiled or - - linked with it, is called a "work that uses the Library". Such a - - work, in isolation, is not a derivative work of the Library, and - - therefore falls outside the scope of this License. - - - - However, linking a "work that uses the Library" with the Library - - creates an executable that is a derivative of the Library (because it - - contains portions of the Library), rather than a "work that uses the - - library". The executable is therefore covered by this License. - - Section 6 states terms for distribution of such executables. - - - - When a "work that uses the Library" uses material from a header file - - that is part of the Library, the object code for the work may be a - - derivative work of the Library even though the source code is not. - - Whether this is true is especially significant if the work can be - - linked without the Library, or if the work is itself a library. The - - threshold for this to be true is not precisely defined by law. - - - - If such an object file uses only numerical parameters, data - - structure layouts and accessors, and small macros and small inline - - functions (ten lines or less in length), then the use of the object - - file is unrestricted, regardless of whether it is legally a derivative - - work. (Executables containing this object code plus portions of the - - Library will still fall under Section 6.) - - - - Otherwise, if the work is a derivative of the Library, you may - - distribute the object code for the work under the terms of Section 6. - - Any executables containing that work also fall under Section 6, - - whether or not they are linked directly with the Library itself. - - - - 6. As an exception to the Sections above, you may also combine or - - link a "work that uses the Library" with the Library to produce a - - work containing portions of the Library, and distribute that work - - under terms of your choice, provided that the terms permit - - modification of the work for the customer's own use and reverse - - engineering for debugging such modifications. - - - - You must give prominent notice with each copy of the work that the - - Library is used in it and that the Library and its use are covered by - - this License. You must supply a copy of this License. If the work - - during execution displays copyright notices, you must include the - - copyright notice for the Library among them, as well as a reference - - directing the user to the copy of this License. Also, you must do one - - of these things: - - - - a) Accompany the work with the complete corresponding - - machine-readable source code for the Library including whatever - - changes were used in the work (which must be distributed under - - Sections 1 and 2 above); and, if the work is an executable linked - - with the Library, with the complete machine-readable "work that - - uses the Library", as object code and/or source code, so that the - - user can modify the Library and then relink to produce a modified - - executable containing the modified Library. (It is understood - - that the user who changes the contents of definitions files in the - - Library will not necessarily be able to recompile the application - - to use the modified definitions.) - - - - b) Use a suitable shared library mechanism for linking with the - - Library. A suitable mechanism is one that (1) uses at run time a - - copy of the library already present on the user's computer system, - - rather than copying library functions into the executable, and (2) - - will operate properly with a modified version of the library, if - - the user installs one, as long as the modified version is - - interface-compatible with the version that the work was made with. - - - - c) Accompany the work with a written offer, valid for at - - least three years, to give the same user the materials - - specified in Subsection 6a, above, for a charge no more - - than the cost of performing this distribution. - - - - d) If distribution of the work is made by offering access to copy - - from a designated place, offer equivalent access to copy the above - - specified materials from the same place. - - - - e) Verify that the user has already received a copy of these - - materials or that you have already sent this user a copy. - - - - For an executable, the required form of the "work that uses the - - Library" must include any data and utility programs needed for - - reproducing the executable from it. However, as a special exception, - - the materials to be distributed need not include anything that is - - normally distributed (in either source or binary form) with the major - - components (compiler, kernel, and so on) of the operating system on - - which the executable runs, unless that component itself accompanies - - the executable. - - - - It may happen that this requirement contradicts the license - - restrictions of other proprietary libraries that do not normally - - accompany the operating system. Such a contradiction means you cannot - - use both them and the Library together in an executable that you - - distribute. - - - - 7. You may place library facilities that are a work based on the - - Library side-by-side in a single library together with other library - - facilities not covered by this License, and distribute such a combined - - library, provided that the separate distribution of the work based on - - the Library and of the other library facilities is otherwise - - permitted, and provided that you do these two things: - - - - a) Accompany the combined library with a copy of the same work - - based on the Library, uncombined with any other library - - facilities. This must be distributed under the terms of the - - Sections above. - - - - b) Give prominent notice with the combined library of the fact - - that part of it is a work based on the Library, and explaining - - where to find the accompanying uncombined form of the same work. - - - - 8. You may not copy, modify, sublicense, link with, or distribute - - the Library except as expressly provided under this License. Any - - attempt otherwise to copy, modify, sublicense, link with, or - - distribute the Library is void, and will automatically terminate your - - rights under this License. However, parties who have received copies, - - or rights, from you under this License will not have their licenses - - terminated so long as such parties remain in full compliance. - - - - 9. You are not required to accept this License, since you have not - - signed it. However, nothing else grants you permission to modify or - - distribute the Library or its derivative works. These actions are - - prohibited by law if you do not accept this License. Therefore, by - - modifying or distributing the Library (or any work based on the - - Library), you indicate your acceptance of this License to do so, and - - all its terms and conditions for copying, distributing or modifying - - the Library or works based on it. - - - - 10. Each time you redistribute the Library (or any work based on the - - Library), the recipient automatically receives a license from the - - original licensor to copy, distribute, link with or modify the Library - - subject to these terms and conditions. You may not impose any further - - restrictions on the recipients' exercise of the rights granted herein. - - You are not responsible for enforcing compliance by third parties with - - this License. - - - - 11. If, as a consequence of a court judgment or allegation of patent - - infringement or for any other reason (not limited to patent issues), - - conditions are imposed on you (whether by court order, agreement or - - otherwise) that contradict the conditions of this License, they do not - - excuse you from the conditions of this License. If you cannot - - distribute so as to satisfy simultaneously your obligations under this - - License and any other pertinent obligations, then as a consequence you - - may not distribute the Library at all. For example, if a patent - - license would not permit royalty-free redistribution of the Library by - - all those who receive copies directly or indirectly through you, then - - the only way you could satisfy both it and this License would be to - - refrain entirely from distribution of the Library. - - - - If any portion of this section is held invalid or unenforceable under any - - particular circumstance, the balance of the section is intended to apply, - - and the section as a whole is intended to apply in other circumstances. - - - - It is not the purpose of this section to induce you to infringe any - - patents or other property right claims or to contest validity of any - - such claims; this section has the sole purpose of protecting the - - integrity of the free software distribution system which is - - implemented by public license practices. Many people have made - - generous contributions to the wide range of software distributed - - through that system in reliance on consistent application of that - - system; it is up to the author/donor to decide if he or she is willing - - to distribute software through any other system and a licensee cannot - - impose that choice. - - - - This section is intended to make thoroughly clear what is believed to - - be a consequence of the rest of this License. - - - - 12. If the distribution and/or use of the Library is restricted in - - certain countries either by patents or by copyrighted interfaces, the - - original copyright holder who places the Library under this License may - - add an explicit geographical distribution limitation excluding those - - countries, so that distribution is permitted only in or among countries - - not thus excluded. In such case, this License incorporates the - - limitation as if written in the body of this License. - - - - 13. The Free Software Foundation may publish revised and/or new - - versions of the Lesser General Public License from time to time. - - Such new versions will be similar in spirit to the present version, - - but may differ in detail to address new problems or concerns. - - - - Each version is given a distinguishing version number. If the Library - - specifies a version number of this License which applies to it and - - "any later version", you have the option of following the terms and - - conditions either of that version or of any later version published by - - the Free Software Foundation. If the Library does not specify a - - license version number, you may choose any version ever published by - - the Free Software Foundation. - - - - 14. If you wish to incorporate parts of the Library into other free - - programs whose distribution conditions are incompatible with these, - - write to the author to ask for permission. For software which is - - copyrighted by the Free Software Foundation, write to the Free - - Software Foundation; we sometimes make exceptions for this. Our - - decision will be guided by the two goals of preserving the free status - - of all derivatives of our free software and of promoting the sharing - - and reuse of software generally. - - - - NO WARRANTY - - - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO - - WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. - - EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR - - OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY - - KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE - - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - - PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE - - LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME - - THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN - - WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY - - AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU - - FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR - - CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE - - LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING - - RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A - - FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF - - SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH - - DAMAGES. - - - - END OF TERMS AND CONDITIONS - - - - How to Apply These Terms to Your New Libraries - - - - If you develop a new library, and you want it to be of the greatest - - possible use to the public, we recommend making it free software that - - everyone can redistribute and change. You can do so by permitting - - redistribution under these terms (or, alternatively, under the terms of the - - ordinary General Public License). - - - - To apply these terms, attach the following notices to the library. It is - - safest to attach them to the start of each source file to most effectively - - convey the exclusion of warranty; and each file should have at least the - - "copyright" line and a pointer to where the full notice is found. - - - - - - Copyright (C) - - - - This library is free software; you can redistribute it and/or - - modify it under the terms of the GNU Lesser General Public - - License as published by the Free Software Foundation; either - - version 2.1 of the License, or (at your option) any later version. - - - - This library is distributed in the hope that it will be useful, - - but WITHOUT ANY WARRANTY; without even the implied warranty of - - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - - Lesser General Public License for more details. - - - - You should have received a copy of the GNU Lesser General Public - - License along with this library; if not, write to the Free Software - - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - - - Also add information on how to contact you by electronic and paper mail. - - - - You should also get your employer (if you work as a programmer) or your - - school, if any, to sign a "copyright disclaimer" for the library, if - - necessary. Here is a sample; alter the names: - - - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - - - , 1 April 1990 - - Ty Coon, President of Vice - - - - That's all there is to it! - - - - --$Id: LICENSE,v 1.3 2003/11/06 18:18:06 hlellelid Exp $ - - - diff --git a/buildscripts/phing/README b/buildscripts/phing/README deleted file mode 100644 index c2b64302..00000000 --- a/buildscripts/phing/README +++ /dev/null @@ -1,78 +0,0 @@ - _________________________ - P H I N G - - - - What is it? - ----------- - - Phing is a PHP based build tool. In theory it is kind of like "make" - without makes drawbacks and with the full portability and performance - of PHP. (PH)pmake (I)s (N)ot (G)numake - - Why? - ---- - - Why another build tool when there is already make, gnumake, nmake, jam, ant, - and others? Because all those tools have limitations that the binarycloud - development team could not live with when developing software across - different platforms. Make-like tools are inherently shell-based: they - evaluate a set of dependencies, then execute commands not unlike what you - would issue on a shell. - - This means that you can easily extend these tools by using or writing any - program for the OS that you are working on; however, this also means that - you limit yourself to the OS, or at least the OS type, such as Unix, that - you are working on. - - Makefiles are inherently evil as well. Anybody who has worked on them for - any time has run into the dreaded tab problem. "Is my command not executing - because I have a space in front of my tab?!!". Tools like Jam took care of - this to a great degree, but still have yet another format to use and - remember. Of course there is the Java based build tool ant, that is very - good approach to what now Phing is. But still based on Java you have to have - at least a running JRE installation on your plattfrom. - Great for Java projects but we thought this is very consistent way to build - a PHP based project. Additionally ant does not support a autoconf tool that - writes out proper buildfiles based on some simple rules prior defined in a - XML Configuration file. - - Phing is different. Instead of a model where it is extended with shell-based - commands, Phing is extended using PHP classes. Instead of writing shell - commands, the configuration files are XML-based, calling a target tree where - various tasks get executed. Each task is run by an object that implements - a particular Task action. - - Of course, this removes some of the expressive power that is inherent in - being able to construct a shell command such as - % `find . -name foo -exec rm {}` - but it gives you the ability to be cross-platform - to work anywhere and - everywhere. And if you really need to execute a shell command, Phing has an - task that allows different commands to be executed based on the operating - system it is executing on. - - The Latest Version - ------------------ - - Details of the latest version can be found on the Phing homepage - . - - Documentation - ------------- - - Documentation is available in XHTML format in the docs/ directory. In particular, - open the docs/phing_guide/book/index.html in a frames-compatible browser to see the - phing user guide. - - For installing see INSTALL. files in the Phing root. - - Licensing - --------- - - This software is licensed under the terms you may find in the file - named "LICENSE" in this directory. - - Thanks for using PHING. - - - --$Id: README,v 1.4 2004/03/20 04:14:35 hlellelid Exp $ diff --git a/buildscripts/phing/bin/pear-phing b/buildscripts/phing/bin/pear-phing deleted file mode 100644 index bf568c17..00000000 --- a/buildscripts/phing/bin/pear-phing +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# ------------------------------------------------------------------------ -# The phing build script for Unix based systems -# $Id: pear-phing,v 1.3 2003/12/23 19:45:14 hlellelid Exp $ -# ------------------------------------------------------------------------ - -# Change this to reflect your environment if the default value doesn't work -PHP_COMMAND="@PHP-BIN@" -export PHP_COMMAND - -# ------------------------------------------------------------------------- -# Do not change anything below this line unless you know what you're doing. -# ------------------------------------------------------------------------- - -if (test -z "$PHP_COMMAND") ; then - echo "WARNING: PHP_COMMAND environment not set. (Assuming php on PATH)" - PHP_COMMAND=php - export PHP_COMMAND -fi - -$PHP_COMMAND -d html_errors=off -qC @PEAR-DIR@/phing.php -logger phing.listener.AnsiColorLogger $* diff --git a/buildscripts/phing/bin/pear-phing.bat b/buildscripts/phing/bin/pear-phing.bat deleted file mode 100644 index fba90772..00000000 --- a/buildscripts/phing/bin/pear-phing.bat +++ /dev/null @@ -1,44 +0,0 @@ -@ECHO OFF - -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: The phing build script for Windows based systems -:: $Id: pear-phing.bat,v 1.4 2005/12/22 13:12:33 hlellelid Exp $ -::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - -::---------------------------------------------------------------------------------- -:: Please set following to PHP's CLI -:: NOTE: In PHP 4.2.x the PHP-CLI used to be named php-cli.exe. -:: PHP 4.3.x names it php.exe but stores it in a subdir called /cli/php.exe -:: E.g. for PHP 4.2 C:\phpdev\php-4.2-Win32\php-cli.exe -:: for PHP 4.3 C:\phpdev\php-4.3-Win32\cli\php.exe - - SET phpCli=@PHP-BIN@ - -::--------------------------------------------------------------------------------- -::--------------------------------------------------------------------------------- -:: Do not modify below this line!! (Unless you know what your doing :) -::--------------------------------------------------------------------------------- -::--------------------------------------------------------------------------------- - -:: Check existence of php.exe -IF EXIST "%phpCli%" ( - SET doNothing= -) ELSE GOTO :NoPhpCli - -"%phpCli%" -d html_errors=off -qC "@PEAR-DIR@\phing.php" %* -GOTO :EOF - -:: -:: php.exe not found error -GOTO :PAUSE_END -:NoPhpCli -ECHO ** ERROR ***************************************************************** -ECHO * Sorry, can't find the php.exe file. -ECHO * You must edit this file to point to your php.exe (CLI version!) -ECHO * [Currently set to %phpCli%] -ECHO ************************************************************************** - -GOTO :PAUSE_END - -:PAUSE_END -PAUSE \ No newline at end of file diff --git a/buildscripts/phing/bin/phing b/buildscripts/phing/bin/phing deleted file mode 100644 index e24c6cfb..00000000 --- a/buildscripts/phing/bin/phing +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# Shell wrapper for Phing -# $Id: phing,v 1.2 2006/01/23 21:51:16 mrook Exp $ -# -# This script will do the following: -# - check for PHP_COMMAND env, if found, use it. -# - if not found assume php is on the path -# - check for PHING_HOME evn, if found use it -# - if not look for it -# - check for PHP_CLASSPATH, if found use it -# - if not found set it using PHING_HOME/classes - -if [ -z "$PHING_HOME" ] ; then - - # echo "WARNING: PHING_HOME environment not set. Attempting to guess." - - # try to find PHING - if [ -d /opt/phing ] ; then - PHING_HOME=/opt/phing - fi - - if [ -d "${HOME}/opt/phing" ] ; then - PHING_HOME="${HOME}/opt/phing" - fi - - if [ -d "/usr/local/phing" ] ; then - PHING_HOME="/usr/local/phing" - fi - - if [ -d "${HOME}/usr/phing" ] ; then - PHING_HOME="${HOME}/usr/phing" - fi - - ## resolve links - $0 may be a link to phing's home - PRG="$0" - progname=`basename "$0"` - saveddir=`pwd` - - # need this for relative symlinks - dirname_prg=`dirname "$PRG"` - cd "$dirname_prg" - - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi - done - - PHING_HOME=`dirname "$PRG"`/.. - - cd "$saveddir" - - # make it fully qualified - PHING_HOME=`cd "$PHING_HOME" && pwd` - - # make it available in PHP via getenv("PHING_HOME") - export PHING_HOME -fi - -if (test -z "$PHP_COMMAND") ; then - # echo "WARNING: PHP_COMMAND environment not set. (Assuming php on PATH)" - PHP_COMMAND=php - export PHP_COMMAND -fi - -if (test -z "$PHP_CLASSPATH") ; then - PHP_CLASSPATH=$PHING_HOME/classes - export PHP_CLASSPATH -fi - -$PHP_COMMAND -d html_errors=off -qC $PHING_HOME/bin/phing.php -logger phing.listener.AnsiColorLogger $@ diff --git a/buildscripts/phing/bin/phing.bat b/buildscripts/phing/bin/phing.bat deleted file mode 100644 index c57c30dd..00000000 --- a/buildscripts/phing/bin/phing.bat +++ /dev/null @@ -1,58 +0,0 @@ -@echo off - -rem ********************************************************************* -rem ** the phing build script for Windows based systems -rem ** $Id: phing.bat,v 1.5 2003/11/06 14:56:13 hlellelid Exp $ -rem ********************************************************************* - -rem This script will do the following: -rem - check for PHP_COMMAND env, if found, use it. -rem - if not found detect php, if found use it, otherwise err and terminate -rem - check for PHING_HOME evn, if found use it -rem - if not found error and leave -rem - check for PHP_CLASSPATH, if found use it -rem - if not found set it using PHING_HOME/classes - -if "%OS%"=="Windows_NT" @setlocal - -rem %~dp0 is expanded pathname of the current script under NT -set DEFAULT_PHING_HOME=%~dp0.. - -goto init -goto cleanup - -:init - -if "%PHING_HOME%" == "" set PHING_HOME=%DEFAULT_PHING_HOME% -set DEFAULT_PHING_HOME= - -if "%PHP_COMMAND%" == "" goto no_phpcommand -if "%PHP_CLASSPATH%" == "" goto set_classpath - -goto run -goto cleanup - -:run -%PHP_COMMAND% -d html_errors=off -qC %PHING_HOME%\bin\phing.php %1 %2 %3 %4 %5 %6 %7 %8 %9 -goto cleanup - -:no_phpcommand -REM echo ------------------------------------------------------------------------ -REM echo WARNING: Set environment var PHP_COMMAND to the location of your php.exe -REM echo executable (e.g. C:\PHP\php.exe). (Assuming php.exe on Path) -REM echo ------------------------------------------------------------------------ -set PHP_COMMAND=php.exe -goto init - -:err_home -echo ERROR: Environment var PHING_HOME not set. Please point this -echo variable to your local phing installation! -goto cleanup - -:set_classpath -set PHP_CLASSPATH="%PHING_HOME%\classes" -goto init - -:cleanup -if "%OS%"=="Windows_NT" @endlocal -REM pause diff --git a/buildscripts/phing/bin/phing.php b/buildscripts/phing/bin/phing.php deleted file mode 100644 index 7d0a774a..00000000 --- a/buildscripts/phing/bin/phing.php +++ /dev/null @@ -1,54 +0,0 @@ - \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/BuildEvent.php b/buildscripts/phing/classes/phing/BuildEvent.php deleted file mode 100644 index d4e1ea79..00000000 --- a/buildscripts/phing/classes/phing/BuildEvent.php +++ /dev/null @@ -1,205 +0,0 @@ -. - */ - -require_once 'phing/system/lang/EventObject.php'; - -/** - * Encapsulates a build specific event. - * - *

We have three sources of events all handled by this class: - * - *

    - *
  • Project level events
  • - *
  • Target level events
  • - *
  • Task level events
  • - *
- * - *

Events are all fired from the project class by creating an event object - * using this class and passing it to the listeners. - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.10 $ - * @package phing - */ -class BuildEvent extends EventObject { - - /** - * A reference to the project - * @var Project - */ - protected $project; - - /** - * A reference to the target - * @var Target - */ - protected $target; - - /** - * A reference to the task - * - * @var Task - */ - protected $task; - - /** - * The message of this event, if the event is a message - * @var string - * @access private - */ - protected $message = null; - - /** - * The priority of the message - * - * @var string - * @see $message - * @access private - */ - protected $priority = PROJECT_MSG_VERBOSE; - - /** - * The execption that caused the event, if any - * - * @var object - * @access private - */ - protected $exception = null; - - /** - * Construct a BuildEvent for a project, task or target source event - * - * @param object project the project that emitted the event. - * @access public - */ - function __construct($source) { - parent::__construct($source); - if ($source instanceof Project) { - $this->project = $source; - $this->target = null; - $this->task = null; - } elseif ($source instanceof Target) { - $this->project = $source->getProject(); - $this->target = $source; - $this->task = null; - } elseif ($source instanceof Task) { - $this->project = $source->getProject(); - $this->target = $source->getOwningTarget(); - $this->task = $source; - } else { - throw new Exception("Can not construct BuildEvent, unknown source given."); - } - } - - /** - * Sets the message with details and the message priority for this event. - * - * @param string The string message of the event - * @param integer The priority this message should have - */ - function setMessage($message, $priority) { - $this->message = (string) $message; - $this->priority = (int) $priority; - } - - /** - * Set the exception that was the cause of this event. - * - * @param Exception The exception that caused the event - */ - function setException($exception) { - $this->exception = $exception; - } - - /** - * Returns the project instance that fired this event. - * - * The reference to the project instance is set by the constructor if this - * event was fired from the project class. - * - * @return Project The project instance that fired this event - */ - function getProject() { - return $this->project; - } - - /** - * Returns the target instance that fired this event. - * - * The reference to the target instance is set by the constructor if this - * event was fired from the target class. - * - * @return object The target that fired this event - * @access public - */ - function getTarget() { - return $this->target; - } - - /** - * Returns the target instance that fired this event. - * - * The reference to the task instance is set by the constructor if this - * event was fired within a task. - * - * @return object The task that fired this event - * @access public - */ - function getTask() { - return $this->task; - } - - /** - * Returns the logging message. This field will only be set for - * "messageLogged" events. - * - * @return string The log message - * @access public - */ - function getMessage() { - return $this->message; - } - - /** - * Returns the priority of the logging message. This field will only - * be set for "messageLogged" events. - * - * @return integer The message priority - * @access public - */ - function getPriority() { - return $this->priority; - } - - /** - * Returns the exception that was thrown, if any. - * This field will only be set for "taskFinished", "targetFinished", and - * "buildFinished" events. - * - * @see BuildListener::taskFinished() - * @see BuildListener::targetFinished() - * @see BuildListener::buildFinished() - */ - function getException() { - return $this->exception; - } -} diff --git a/buildscripts/phing/classes/phing/BuildException.php b/buildscripts/phing/classes/phing/BuildException.php deleted file mode 100644 index 8c108130..00000000 --- a/buildscripts/phing/classes/phing/BuildException.php +++ /dev/null @@ -1,100 +0,0 @@ -. - */ - -/** - * BuildException is for when things go wrong in a build execution. - * - * @author Andreas Aderhold - * @version $Revision: 1.12 $ - * @package phing - */ -class BuildException extends Exception { - - /** location in the xml file */ - protected $location = null; - - /** The nested "cause" exception. */ - protected $cause; - - /** - * Construct a BuildException. - * Supported signatures: - * throw new BuildException($causeExc); - * throw new BuildException($msg); - * throw new Buildexception($causeExc, $loc); - * throw new BuildException($msg, $causeExc); - * throw new BuildException($msg, $loc); - * throw new BuildException($msg, $causeExc, $loc); - */ - function __construct($p1, $p2 = null, $p3 = null) { - - $cause = null; - $loc = null; - $msg = ""; - - if ($p3 !== null) { - $cause = $p2; - $loc = $p3; - $msg = $p1; - } elseif ($p2 !== null) { - if ($p2 instanceof Exception) { - $cause = $p2; - $msg = $p1; - } elseif ($p2 instanceof Location) { - $loc = $p2; - if ($p1 instanceof Exception) { - $cause = $p1; - } else { - $msg = $p1; - } - } - } elseif ($p1 instanceof Exception) { - $cause = $p1; - } else { - $msg = $p1; - } - - parent::__construct($msg); - - if ($cause !== null) { - $this->cause = $cause; - $this->message .= " [wrapped: " . $cause->getMessage() ."]"; - } - - if ($loc !== null) { - $this->setLocation($loc); - } - } - - function getCause() { - return $this->cause; - } - - function getLocation() { - return $this->location; - } - - function setLocation($loc) { - $this->location = $loc; - $this->message = $loc->toString() . ': ' . $this->message; - } - -} diff --git a/buildscripts/phing/classes/phing/BuildListener.php b/buildscripts/phing/classes/phing/BuildListener.php deleted file mode 100644 index 12a96c7b..00000000 --- a/buildscripts/phing/classes/phing/BuildListener.php +++ /dev/null @@ -1,91 +0,0 @@ -. - */ - -/** - * Interface for build listeners. - * - * Classes that implement a listener must extend this class and (faux)implement - * all methods that are decleard as dummies below. - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.6 $ - * @see BuildEvent - * @see Project::addBuildListener() - * @package phing - */ -interface BuildListener { - - /** - * Fired before any targets are started. - * - * @param BuildEvent The BuildEvent - */ - function buildStarted(BuildEvent $event); - - /** - * Fired after the last target has finished. - * - * @param BuildEvent The BuildEvent - * @see BuildEvent::getException() - */ - function buildFinished(BuildEvent $event); - - /** - * Fired when a target is started. - * - * @param BuildEvent The BuildEvent - * @see BuildEvent::getTarget() - */ - function targetStarted(BuildEvent $event); - - /** - * Fired when a target has finished. - * - * @param BuildEvent The BuildEvent - * @see BuildEvent#getException() - */ - function targetFinished(BuildEvent $event); - - /** - * Fired when a task is started. - * - * @param BuildEvent The BuildEvent - * @see BuildEvent::getTask() - */ - function taskStarted(BuildEvent $event); - - /** - * Fired when a task has finished. - * - * @param BuildEvent The BuildEvent - * @see BuildEvent::getException() - */ - function taskFinished(BuildEvent $event); - - /** - * Fired whenever a message is logged. - * - * @param BuildEvent The BuildEvent - * @see BuildEvent::getMessage() - */ - function messageLogged(BuildEvent $event); -} diff --git a/buildscripts/phing/classes/phing/IntrospectionHelper.php b/buildscripts/phing/classes/phing/IntrospectionHelper.php deleted file mode 100644 index b4300950..00000000 --- a/buildscripts/phing/classes/phing/IntrospectionHelper.php +++ /dev/null @@ -1,542 +0,0 @@ -. - */ - -include_once 'phing/types/Reference.php'; -include_once 'phing/types/Path.php'; -include_once 'phing/util/StringHelper.php'; - -/** - * Helper class that collects the methods that a task or nested element - * holds to set attributes, create nested elements or hold PCDATA - * elements. - * - *

    - *
  • SMART-UP INLINE DOCS
  • - *
  • POLISH-UP THIS CLASS
  • - *
- * - * @author Andreas Aderhold - * @author Hans Lellelid - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.19 $ - * @package phing - */ -class IntrospectionHelper { - - - - /** - * Holds the attribute setter methods. - * - * @var array string[] - */ - private $attributeSetters = array(); - - /** - * Holds methods to create nested elements. - * - * @var array string[] - */ - private $nestedCreators = array(); - - /** - * Holds methods to store configured nested elements. - * - * @var array string[] - */ - private $nestedStorers = array(); - - /** - * Map from attribute names to nested types. - */ - private $nestedTypes = array(); - - /** - * New idea in phing: any class can register certain - * keys -- e.g. "task.current_file" -- which can be used in - * task attributes, if supported. In the build XML these - * are referred to like this: - * - * In the type/task a listener method must be defined: - * function setListeningReplace($slot) {} - * @var array string[] - */ - private $slotListeners = array(); - - /** - * The method to add PCDATA stuff. - * - * @var string Method name of the addText (redundant?) method, if class supports it :) - */ - private $methodAddText = null; - - /** - * The Class that's been introspected. - * - * @var object - * @access private - */ - private $bean; - - /** - * The cache of IntrospectionHelper classes instantiated by getHelper(). - * @var array IntrospectionHelpers[] - */ - private static $helpers = array(); - - /** - * Factory method for helper objects. - * - * @param string $class The class to create a Helper for - */ - public static function getHelper($class) { - if (!isset(self::$helpers[$class])) { - self::$helpers[$class] = new IntrospectionHelper($class); - } - return self::$helpers[$class]; - } - - /** - * This function constructs a new introspection helper for a specific class. - * - * This method loads all methods for the specified class and categorizes them - * as setters, creators, slot listeners, etc. This way, the setAttribue() doesn't - * need to perform any introspection -- either the requested attribute setter/creator - * exists or it does not & a BuildException is thrown. - * - * @param string $bean The classname for this IH. - */ - function __construct($class) { - - $this->bean = new ReflectionClass($class); - - //$methods = get_class_methods($bean); - foreach($this->bean->getMethods() as $method) { - - if ($method->isPublic()) { - - // We're going to keep case-insensitive method names - // for as long as we're allowed :) It makes it much - // easier to map XML attributes to PHP class method names. - $name = strtolower($method->getName()); - - // There are a few "reserved" names that might look like attribute setters - // but should actually just be skipped. (Note: this means you can't ever - // have an attribute named "location" or "tasktype" or a nested element named "task".) - if ($name === "setlocation" || $name === "settasktype" || $name === "addtask") { - continue; - } - - if ($name === "addtext") { - - $this->methodAddText = $method; - - } elseif (strpos($name, "setlistening") === 0) { - - // Phing supports something unique called "RegisterSlots" - // These are dynamic values that use a basic slot system so that - // classes can register to listen to specific slots, and the value - // will always be grabbed from the slot (and never set in the project - // component). This is useful for things like tracking the current - // file being processed by a filter (e.g. AppendTask sets an append.current_file - // slot, which can be ready by the XSLTParam type.) - - if (count($method->getParameters()) !== 1) { - throw new BuildException($method->getDeclaringClass()->getName()."::".$method->getName()."() must take exactly one parameter."); - } - - $this->slotListeners[$name] = $method; - - } elseif (strpos($name, "set") === 0) { - - // A standard attribute setter. - - if (count($method->getParameters()) !== 1) { - throw new BuildException($method->getDeclaringClass()->getName()."::".$method->getName()."() must take exactly one parameter."); - } - - $this->attributeSetters[$name] = $method; - - } elseif (strpos($name, "create") === 0) { - - if (count($method->getParameters()) > 0) { - throw new BuildException($method->getDeclaringClass()->getName()."::".$method->getName()."() may not take any parameters."); - } - - // Because PHP doesn't support return types, we are going to do - // two things here to guess return type: - // 1) parse comments for an explicit value - // 2) if that fails, assume that the part of the method after "create" - // is the name of the return type (in many cases it is not) - - // This isn't super important -- i.e. we're not instantaiting classes - // based on this information. It's more just so that IntrospectionHelper - // can keep track of all the nested types -- and provide more helpful - // exception messages, etc. - - preg_match('/@return[\s]+([\w]+)/', $method->getDocComment(), $matches); - if (!empty($matches[1]) && class_exists($matches[1], false)) { - $this->nestedTypes[$name] = $matches[1]; - } else { - // assume that method createEquals() creates object of type "Equals" - // (that example would be false, of course) - $this->nestedTypes[$name] = $this->getPropertyName($name, "create"); - } - - $this->nestedCreators[$name] = $method; - - } elseif (strpos($name, "addconfigured") === 0) { - - // *must* use class hints if using addConfigured ... - - // 1 param only - $params = $method->getParameters(); - - if (count($params) < 1) { - throw new BuildException($method->getDeclaringClass()->getName()."::".$method->getName()."() must take at least one parameter."); - } - - if (count($params) > 1) { - $this->warn($method->getDeclaringClass()->getName()."::".$method->getName()."() takes more than one parameter. (IH only uses the first)"); - } - - $classname = null; - - if (($hint = $params[0]->getClass()) !== null) { - $classname = $hint->getName(); - } - - if ($classname === null) { - throw new BuildException($method->getDeclaringClass()->getName()."::".$method->getName()."() method MUST use a class hint to indicate the class type of parameter."); - } - - $this->nestedTypes[$name] = $classname; - - $this->nestedStorers[$name] = $method; - - } elseif (strpos($name, "add") === 0) { - - // *must* use class hints if using add ... - - // 1 param only - $params = $method->getParameters(); - if (count($params) < 1) { - throw new BuildException($method->getDeclaringClass()->getName()."::".$method->getName()."() must take at least one parameter."); - } - - if (count($params) > 1) { - $this->warn($method->getDeclaringClass()->getName()."::".$method->getName()."() takes more than one parameter. (IH only uses the first)"); - } - - $classname = null; - - if (($hint = $params[0]->getClass()) !== null) { - $classname = $hint->getName(); - } - - // we don't use the classname here, but we need to make sure it exists before - // we later try to instantiate a non-existant class - if ($classname === null) { - throw new BuildException($method->getDeclaringClass()->getName()."::".$method->getName()."() method MUST use a class hint to indicate the class type of parameter."); - } - - $this->nestedCreators[$name] = $method; - } - } // if $method->isPublic() - } // foreach - } - - - /** Sets the named attribute. */ - function setAttribute(Project $project, $element, $attributeName, &$value) { - - // we want to check whether the value we are setting looks like - // a slot-listener variable: %{task.current_file} - // - // slot-listener variables are not like properties, in that they cannot be mixed with - // other text values. The reason for this disparity is that properties are only - // set when first constructing objects from XML, whereas slot-listeners are always dynamic. - // - // This is made possible by PHP5 (objects automatically passed by reference) and PHP's loose - // typing. - - if (StringHelper::isSlotVar($value)) { - - $as = "setlistening" . strtolower($attributeName); - - if (!isset($this->slotListeners[$as])) { - $msg = $this->getElementName($project, $element) . " doesn't support a slot-listening '$attributeName' attribute."; - throw new BuildException($msg); - } - - $method = $this->slotListeners[$as]; - - $key = StringHelper::slotVar($value); - $value = Register::getSlot($key); // returns a RegisterSlot object which will hold current value of that register (accessible using getValue()) - - } else { - - // Traditional value options - - $as = "set".strtolower($attributeName); - - if (!isset($this->attributeSetters[$as])) { - $msg = $this->getElementName($project, $element) . " doesn't support the '$attributeName' attribute."; - throw new BuildException($msg); - } - - $method = $this->attributeSetters[$as]; - - if ($as == "setrefid") { - $value = new Reference($value); - } else { - - // decode any html entities in string - $value = html_entity_decode($value); - - // value is a string representation of a boolean type, - // convert it to primitive - if (StringHelper::isBoolean($value)) { - - $value = StringHelper::booleanValue($value); - } - - // does method expect a PhingFile object? if so, then - // pass a project-relative file. - $params = $method->getParameters(); - - $classname = null; - - if (($hint = $params[0]->getClass()) !== null) { - $classname = $hint->getName(); - } - - // there should only be one param; we'll just assume .... - if ($classname !== null) { - switch(strtolower($classname)) { - case "phingfile": - $value = $project->resolveFile($value); - break; - case "path": - $value = new Path($project, $value); - break; - case "reference": - $value = new Reference($value); - break; - // any other object params we want to support should go here ... - } - - } // if hint !== null - - } // if not setrefid - - } // if is slot-listener - - try { - $project->log(" -calling setter ".$method->getDeclaringClass()->getName()."::".$method->getName()."()", PROJECT_MSG_DEBUG); - $method->invoke($element, $value); - } catch(Exception $exc) { - throw new BuildException($exc); - } - - } - - /** Adds PCDATA areas.*/ - function addText(Project $project, $element, $text) { - if ($this->methodAddText === null) { - $msg = $this->getElementName($project, $element)." doesn't support nested text data."; - throw new BuildException($msg); - } - try { - $method = $this->methodAddText; - $method->invoke($element, $text); - } catch (Exception $exc) { - throw new BuildException($exc); - } - } - - /** - * Creates a named nested element. - * - * Valid creators can be in the form createFoo() or addFoo(Bar). - * @return object Returns the nested element. - * @throws BuildException - */ - function createElement(Project $project, $element, $elementName) { - - $addMethod = "add".strtolower($elementName); - $createMethod = "create".strtolower($elementName); - $nestedElement = null; - - if (isset($this->nestedCreators[$createMethod])) { - - $method = $this->nestedCreators[$createMethod]; - try { // try to invoke the creator method on object - $project->log(" -calling creator ".$method->getDeclaringClass()->getName()."::".$method->getName()."()", PROJECT_MSG_DEBUG); - $nestedElement = $method->invoke($element); - } catch (Exception $exc) { - throw new BuildException($exc); - } - - } elseif (isset($this->nestedCreators[$addMethod])) { - - $method = $this->nestedCreators[$addMethod]; - - // project components must use class hints to support the add methods - - try { // try to invoke the adder method on object - - $project->log(" -calling adder ".$method->getDeclaringClass()->getName()."::".$method->getName()."()", PROJECT_MSG_DEBUG); - // we've already assured that correct num of params - // exist and that method is using class hints - $params = $method->getParameters(); - - $classname = null; - - if (($hint = $params[0]->getClass()) !== null) { - $classname = $hint->getName(); - } - - // create a new instance of the object and add it via $addMethod - $nestedElement = new $classname(); - - $method->invoke($element, $nestedElement); - - } catch (Exception $exc) { - throw new BuildException($exc); - } - } else { - $msg = $this->getElementName($project, $element) . " doesn't support the '$elementName' creator/adder."; - throw new BuildException($msg); - } - - if ($nestedElement instanceof ProjectComponent) { - $nestedElement->setProject($project); - } - - return $nestedElement; - } - - /** - * Creates a named nested element. - * @return void - * @throws BuildException - */ - function storeElement($project, $element, $child, $elementName = null) { - - if ($elementName === null) { - return; - } - - $storer = "addconfigured".strtolower($elementName); - - if (isset($this->nestedStorers[$storer])) { - - $method = $this->nestedStorers[$storer]; - - try { - $project->log(" -calling storer ".$method->getDeclaringClass()->getName()."::".$method->getName()."()", PROJECT_MSG_DEBUG); - $method->invoke($element, $child); - } catch (Exception $exc) { - throw new BuildException($exc); - } - } - - } - - /** Does the introspected class support PCDATA? */ - function supportsCharacters() { - return ($this->methodAddText !== null); - } - - /** Return all attribues supported by the introspected class. */ - function getAttributes() { - $attribs = array(); - foreach (array_keys($this->attributeSetters) as $setter) { - $attribs[] =$this->getPropertyName($setter, "set"); - } - return $attribs; - } - - /** Return all nested elements supported by the introspected class. */ - function getNestedElements() { - return $this->nestedTypes; - } - - /** - * Get the the name for an element. - * When possible the full classnam (phing.tasks.system.PropertyTask) will - * be returned. If not available (loaded in taskdefs or typedefs) then the - * XML element name will be returned. - * - * @param Project $project - * @param object $element The Task or type element. - * @return string Fully qualified class name of element when possible. - */ - function getElementName(Project $project, $element) { - - $taskdefs = $project->getTaskDefinitions(); - $typedefs = $project->getDataTypeDefinitions(); - - // check if class of element is registered with project (tasks & types) - // most element types don't have a getTag() method - $elClass = get_class($element); - - if (!in_array('getTag', get_class_methods($elClass))) { - // loop through taskdefs and typesdefs and see if the class name - // matches (case-insensitive) any of the classes in there - foreach(array_merge($taskdefs, $typedefs) as $elName => $class) { - if (0 === strcasecmp($elClass, StringHelper::unqualify($class))) { - return $class; - } - } - return "$elClass (unknown)"; - } else { - // ->getTag() method does exist, so use it - $elName = $element->getTag(); - if (isset($taskdefs[$elName])) { - return $taskdefs[$elName]; - } elseif (isset($typedefs[$elName])) { - - return $typedefs[$elName]; - } else { - return "$elName (unknown)"; - } - } - } - - /** extract the name of a property from a method name - subtracting a given prefix. */ - function getPropertyName($methodName, $prefix) { - $start = strlen($prefix); - return strtolower(substr($methodName, $start)); - } - - /** - * Prints warning message to screen if -debug was used. - */ - function warn($msg) { - if (Phing::getMsgOutputLevel() === PROJECT_MSG_DEBUG) { - print("[IntrospectionHelper] " . $msg . "\n"); - } - } - -} diff --git a/buildscripts/phing/classes/phing/Phing.php b/buildscripts/phing/classes/phing/Phing.php deleted file mode 100644 index bb8d67f6..00000000 --- a/buildscripts/phing/classes/phing/Phing.php +++ /dev/null @@ -1,1161 +0,0 @@ -. - */ - -require_once 'phing/Project.php'; -require_once 'phing/ProjectComponent.php'; -require_once 'phing/Target.php'; -require_once 'phing/Task.php'; - -include_once 'phing/BuildException.php'; -include_once 'phing/BuildEvent.php'; - -include_once 'phing/parser/Location.php'; -include_once 'phing/parser/ExpatParser.php'; -include_once 'phing/parser/AbstractHandler.php'; -include_once 'phing/parser/ProjectConfigurator.php'; -include_once 'phing/parser/RootHandler.php'; -include_once 'phing/parser/ProjectHandler.php'; -include_once 'phing/parser/TaskHandler.php'; -include_once 'phing/parser/TargetHandler.php'; -include_once 'phing/parser/DataTypeHandler.php'; -include_once 'phing/parser/NestedElementHandler.php'; - -include_once 'phing/system/util/Properties.php'; -include_once 'phing/util/StringHelper.php'; -include_once 'phing/system/io/PhingFile.php'; -include_once 'phing/system/io/FileReader.php'; -include_once 'phing/system/util/Register.php'; - -/** - * Entry point into Phing. This class handles the full lifecycle of a build -- from - * parsing & handling commandline arguments to assembling the project to shutting down - * and cleaning up in the end. - * - * If you are invoking Phing from an external application, this is still - * the class to use. Your applicaiton can invoke the start() method, passing - * any commandline arguments or additional properties. - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.51 $ - * @package phing - */ -class Phing { - - /** The default build file name */ - const DEFAULT_BUILD_FILENAME = "build.xml"; - - /** Our current message output status. Follows PROJECT_MSG_XXX */ - private static $msgOutputLevel = PROJECT_MSG_INFO; - - /** PhingFile that we are using for configuration */ - private $buildFile = null; - - /** The build targets */ - private $targets = array(); - - /** - * Set of properties that are passed in from commandline or invoking code. - * @var Properties - */ - private static $definedProps; - - /** Names of classes to add as listeners to project */ - private $listeners = array(); - - private $loggerClassname = null; - - /** The class to handle input (can be only one). */ - private $inputHandlerClassname; - - /** Indicates if this phing should be run */ - private $readyToRun = false; - - /** Indicates we should only parse and display the project help information */ - private $projectHelp = false; - - /** Used by utility function getResourcePath() */ - private static $importPaths; - - /** System-wide static properties (moved from System) */ - private static $properties = array(); - - /** Static system timer. */ - private static $timer; - - /** The current Project */ - private static $currentProject; - - /** Whether to capture PHP errors to buffer. */ - private static $phpErrorCapture = false; - - /** Array of captured PHP errors */ - private static $capturedPhpErrors = array(); - - /** - * Prints the message of the Exception if it's not null. - */ - function printMessage(Exception $t) { - print($t->getMessage() . "\n"); - if (self::getMsgOutputLevel() === PROJECT_MSG_DEBUG) { - print($t->getTraceAsString()."\n"); - if ($t instanceof Exception) { - $c = $t->getCause(); - if ($c !== null) { - print("Wrapped exception trace:\n"); - print($c->getTraceAsString() . "\n"); - } - } - } // if output level is DEBUG - } - - /** - * Entry point allowing for more options from other front ends. - * - * This method encapsulates the complete build lifecycle. - * - * @param array &$args The commandline args passed to phing shell script. - * @param array $additionalUserProperties Any additional properties to be passed to Phing (alternative front-end might implement this). - * These additional properties will be available using the getDefinedProperty() method and will - * be added to the project's "user" properties. - * @return void - * @see execute() - * @see runBuild() - */ - public static function start(&$args, $additionalUserProperties = null) { - - try { - $m = new Phing(); - $m->execute($args); - } catch (Exception $exc) { - $m->printMessage($exc); - self::halt(-1); // Parameter error - } - - if ($additionalUserProperties !== null) { - $keys = $m->additionalUserProperties->keys(); - while(count($keys)) { - $key = array_shift($keys); - $property = $m->additionalUserProperties->getProperty($key); - $m->setDefinedProperty($key, $property); - } - } - - try { - $m->runBuild(); - } catch(Exception $exc) { - self::halt(1); // Errors occured - } - - // everything fine, shutdown - self::halt(0); // no errors, everything is cake - } - - /** - * Making output level a static property so that this property - * can be accessed by other parts of the system, enabling - * us to display more information -- e.g. backtraces -- for "debug" level. - * @return int - */ - public static function getMsgOutputLevel() { - return self::$msgOutputLevel; - } - - /** - * Command line entry point. This method kicks off the building - * of a project object and executes a build using either a given - * target or the default target. - * - * @param array $args Command line args. - * @return void - */ - public static function fire($args) { - self::start($args, null); - } - - /** - * Setup/initialize Phing environment from commandline args. - * @param array $args commandline args passed to phing shell. - * @return void - */ - public function execute($args) { - - self::$definedProps = new Properties(); - $this->searchForThis = null; - - // cycle through given args - for ($i = 0, $argcount = count($args); $i < $argcount; ++$i) { - // ++$i intentional here, as first param is script name - $arg = $args[$i]; - - if ($arg == "-help" || $arg == "-h") { - $this->printUsage(); - return; - } elseif ($arg == "-version" || $arg == "-v") { - $this->printVersion(); - return; - } elseif ($arg == "-quiet" || $arg == "-q") { - self::$msgOutputLevel = PROJECT_MSG_WARN; - } elseif ($arg == "-verbose") { - $this->printVersion(); - self::$msgOutputLevel = PROJECT_MSG_VERBOSE; - } elseif ($arg == "-debug") { - $this->printVersion(); - self::$msgOutputLevel = PROJECT_MSG_DEBUG; - } elseif ($arg == "-logfile") { - try { // try to set logfile - if (!isset($args[$i+1])) { - print("You must specify a log file when using the -logfile argument\n"); - return; - } else { - $logFile = new PhingFile($args[++$i]); - $this->loggerClassname = 'phing.listener.PearLogger'; - $this->setDefinedProperty('pear.log.name', $logFile->getAbsolutePath()); - } - } catch (IOException $ioe) { - print("Cannot write on the specified log file. Make sure the path exists and you have write permissions.\n"); - throw $ioe; - } - } elseif ($arg == "-buildfile" || $arg == "-file" || $arg == "-f") { - if (!isset($args[$i+1])) { - print("You must specify a buildfile when using the -buildfile argument\n"); - return; - } else { - $this->buildFile = new PhingFile($args[++$i]); - } - } elseif ($arg == "-listener") { - if (!isset($args[$i+1])) { - print("You must specify a listener class when using the -listener argument\n"); - return; - } else { - $this->listeners[] = $args[++$i]; - } - - } elseif (StringHelper::startsWith("-D", $arg)) { - $name = substr($arg, 2); - $value = null; - $posEq = strpos($name, "="); - if ($posEq !== false) { - $value = substr($name, $posEq+1); - $name = substr($name, 0, $posEq); - } elseif ($i < count($args)-1) { - $value = $args[++$i]; - } - self::$definedProps->setProperty($name, $value); - } elseif ($arg == "-logger") { - if (!isset($args[$i+1])) { - print("You must specify a classname when using the -logger argument\n"); - return; - } else { - $this->loggerClassname = $args[++$i]; - } - } elseif ($arg == "-inputhandler") { - if ($this->inputHandlerClassname !== null) { - throw new BuildException("Only one input handler class may be specified."); - } - if (!isset($args[$i+1])) { - print("You must specify a classname when using the -inputhandler argument\n"); - return; - } else { - $this->inputHandlerClassname = $args[++$i]; - } - } elseif ($arg == "-projecthelp" || $arg == "-targets" || $arg == "-list" || $arg == "-l") { - // set the flag to display the targets and quit - $this->projectHelp = true; - } elseif ($arg == "-find") { - // eat up next arg if present, default to build.xml - if ($i < count($args)-1) { - $this->searchForThis = $args[++$i]; - } else { - $this->searchForThis = self::DEFAULT_BUILD_FILENAME; - } - } elseif (substr($arg,0,1) == "-") { - // we don't have any more args - print("Unknown argument: $arg\n"); - $this->printUsage(); - return; - } else { - // if it's no other arg, it may be the target - array_push($this->targets, $arg); - } - } - - // if buildFile was not specified on the command line, - if ($this->buildFile === null) { - // but -find then search for it - if ($this->searchForThis !== null) { - $this->buildFile = $this->_findBuildFile(self::getProperty("user.dir"), $this->searchForThis); - } else { - $this->buildFile = new PhingFile(self::DEFAULT_BUILD_FILENAME); - } - } - // make sure buildfile exists - if (!$this->buildFile->exists()) { - throw new BuildException("Buildfile: " . $this->buildFile->__toString() . " does not exist!"); - } - - // make sure it's not a directory - if ($this->buildFile->isDirectory()) { - throw new BuildException("Buildfile: " . $this->buildFile->__toString() . " is a dir!"); - } - - $this->readyToRun = true; - } - - /** - * Helper to get the parent file for a given file. - * - * @param PhingFile $file - * @return PhingFile Parent file or null if none - */ - function _getParentFile(PhingFile $file) { - $filename = $file->getAbsolutePath(); - $file = new PhingFile($filename); - $filename = $file->getParent(); - - if ($filename !== null && self::$msgOutputLevel >= PROJECT_MSG_VERBOSE) { - print("Searching in $filename\n"); - } - - return ($filename === null) ? null : new PhingFile($filename); - } - - /** - * Search parent directories for the build file. - * - * Takes the given target as a suffix to append to each - * parent directory in search of a build file. Once the - * root of the file-system has been reached an exception - * is thrown. - * - * @param string $start Start file path. - * @param string $suffix Suffix filename to look for in parents. - * @return PhingFile A handle to the build file - * - * @throws BuildException Failed to locate a build file - */ - function _findBuildFile($start, $suffix) { - if (self::$msgOutputLevel >= PROJECT_MSG_INFO) { - print("Searching for $suffix ...\n"); - } - $startf = new PhingFile($start); - $parent = new PhingFile($startf->getAbsolutePath()); - $file = new PhingFile($parent, $suffix); - - // check if the target file exists in the current directory - while (!$file->exists()) { - // change to parent directory - $parent = $this->_getParentFile($parent); - - // if parent is null, then we are at the root of the fs, - // complain that we can't find the build file. - if ($parent === null) { - throw new BuildException("Could not locate a build file!"); - } - // refresh our file handle - $file = new PhingFile($parent, $suffix); - } - return $file; - } - - /** - * Executes the build. - * @return void - */ - function runBuild() { - - if (!$this->readyToRun) { - return; - } - - $project = new Project(); - - self::setCurrentProject($project); - set_error_handler(array('Phing', 'handlePhpError')); - - $error = null; - - $this->addBuildListeners($project); - $this->addInputHandler($project); - - // set this right away, so that it can be used in logging. - $project->setUserProperty("phing.file", $this->buildFile->getAbsolutePath()); - - try { - $project->fireBuildStarted(); - $project->init(); - } catch (Exception $exc) { - $project->fireBuildFinished($exc); - throw $exc; - } - - $project->setUserProperty("phing.version", $this->getPhingVersion()); - - $e = self::$definedProps->keys(); - while (count($e)) { - $arg = (string) array_shift($e); - $value = (string) self::$definedProps->getProperty($arg); - $project->setUserProperty($arg, $value); - } - unset($e); - - $project->setUserProperty("phing.file", $this->buildFile->getAbsolutePath()); - - // first use the Configurator to create the project object - // from the given build file. - - try { - ProjectConfigurator::configureProject($project, $this->buildFile); - } catch (Exception $exc) { - $project->fireBuildFinished($exc); - restore_error_handler(); - self::unsetCurrentProject(); - throw $exc; - } - - // make sure that we have a target to execute - if (count($this->targets) === 0) { - $this->targets[] = $project->getDefaultTarget(); - } - - // execute targets if help param was not given - if (!$this->projectHelp) { - - try { - $project->executeTargets($this->targets); - } catch (Exception $exc) { - $project->fireBuildFinished($exc); - restore_error_handler(); - self::unsetCurrentProject(); - throw $exc; - } - } - // if help is requested print it - if ($this->projectHelp) { - try { - $this->printDescription($project); - $this->printTargets($project); - } catch (Exception $exc) { - $project->fireBuildFinished($exc); - restore_error_handler(); - self::unsetCurrentProject(); - throw $exc; - } - } - - // finally { - if (!$this->projectHelp) { - $project->fireBuildFinished(null); - } - - restore_error_handler(); - self::unsetCurrentProject(); - } - - /** - * Bind any default build listeners to this project. - * Currently this means adding the logger. - * @param Project $project - * @return void - */ - private function addBuildListeners(Project $project) { - // Add the default listener - $project->addBuildListener($this->createLogger()); - } - - /** - * Creates the InputHandler and adds it to the project. - * - * @param Project $project the project instance. - * - * @throws BuildException if a specified InputHandler - * class could not be loaded. - */ - private function addInputHandler(Project $project) { - if ($this->inputHandlerClassname === null) { - $handler = new DefaultInputHandler(); - } else { - try { - $clz = Phing::import($this->inputHandlerClassname); - $handler = new $clz(); - if ($project !== null && method_exists($handler, 'setProject')) { - $handler->setProject($project); - } - } catch (Exception $e) { - $msg = "Unable to instantiate specified input handler " - . "class " . $this->inputHandlerClassname . " : " - . $e->getMessage(); - throw new BuildException($msg); - } - } - $project->setInputHandler($handler); - } - - /** - * Creates the default build logger for sending build events to the log. - * @return BuildListener The created Logger - */ - private function createLogger() { - if ($this->loggerClassname !== null) { - self::import($this->loggerClassname); - // get class name part - $classname = self::import($this->loggerClassname); - $logger = new $classname; - } else { - require_once 'phing/listener/DefaultLogger.php'; - $logger = new DefaultLogger(); - } - $logger->setMessageOutputLevel(self::$msgOutputLevel); - return $logger; - } - - /** - * Sets the current Project - * @param Project $p - */ - public static function setCurrentProject($p) { - self::$currentProject = $p; - } - - /** - * Unsets the current Project - */ - public static function unsetCurrentProject() { - self::$currentProject = null; - } - - /** - * Gets the current Project. - * @return Project Current Project or NULL if none is set yet/still. - */ - public static function getCurrentProject() { - return self::$currentProject; - } - - /** - * A static convenience method to send a log to the current (last-setup) Project. - * If there is no currently-configured Project, then this will do nothing. - * @param string $message - * @param int $priority PROJECT_MSG_INFO, etc. - */ - public static function log($message, $priority = PROJECT_MSG_INFO) { - $p = self::getCurrentProject(); - if ($p) { - $p->log($message, $priority); - } - } - - /** - * Error handler for PHP errors encountered during the build. - * This uses the logging for the currently configured project. - */ - public static function handlePhpError($level, $message, $file, $line) { - - // don't want to print supressed errors - if (error_reporting() > 0) { - - if (self::$phpErrorCapture) { - - self::$capturedPhpErrors[] = array('message' => $message, 'level' => $level, 'line' => $line, 'file' => $file); - - } else { - - $message = '[PHP Error] ' . $message; - $message .= ' [line ' . $line . ' of ' . $file . ']'; - - switch ($level) { - - case E_STRICT: - case E_NOTICE: - case E_USER_NOTICE: - self::log($message, PROJECT_MSG_VERBOSE); - break; - case E_WARNING: - case E_USER_WARNING: - self::log($message, PROJECT_MSG_WARN); - break; - case E_ERROR: - case E_USER_ERROR: - default: - self::log($message, PROJECT_MSG_ERR); - - } // switch - - } // if phpErrorCapture - - } // if not @ - - } - - /** - * Begins capturing PHP errors to a buffer. - * While errors are being captured, they are not logged. - */ - public static function startPhpErrorCapture() { - self::$phpErrorCapture = true; - self::$capturedPhpErrors = array(); - } - - /** - * Stops capturing PHP errors to a buffer. - * The errors will once again be logged after calling this method. - */ - public static function stopPhpErrorCapture() { - self::$phpErrorCapture = false; - } - - /** - * Clears the captured errors without affecting the starting/stopping of the capture. - */ - public static function clearCapturedPhpErrors() { - self::$capturedPhpErrors = array(); - } - - /** - * Gets any PHP errors that were captured to buffer. - * @return array array('message' => message, 'line' => line number, 'file' => file name, 'level' => error level) - */ - public static function getCapturedPhpErrors() { - return self::$capturedPhpErrors; - } - - /** Prints the usage of how to use this class */ - function printUsage() { - $lSep = self::getProperty("line.separator"); - $msg = ""; - $msg .= "phing [options] [target [target2 [target3] ...]]" . $lSep; - $msg .= "Options: " . $lSep; - $msg .= " -h -help print this message" . $lSep; - $msg .= " -l -list list available targets in this project" . $lSep; - $msg .= " -v -version print the version information and exit" . $lSep; - $msg .= " -q -quiet be extra quiet" . $lSep; - $msg .= " -verbose be extra verbose" . $lSep; - $msg .= " -debug print debugging information" . $lSep; - $msg .= " -logfile use given file for log" . $lSep; - $msg .= " -logger the class which is to perform logging" . $lSep; - $msg .= " -f -buildfile use given buildfile" . $lSep; - $msg .= " -D= use value for given property" . $lSep; - $msg .= " -find search for buildfile towards the root of the" . $lSep; - $msg .= " filesystem and use it" . $lSep; - //$msg .= " -recursive search for buildfile downwards and use it" . $lSep; - $msg .= $lSep; - $msg .= "Report bugs to ".$lSep; - print($msg); - } - - function printVersion() { - print(self::getPhingVersion()."\n"); - } - - function getPhingVersion() { - $versionPath = self::getResourcePath("phing/etc/VERSION.TXT"); - if ($versionPath === null) { - $versionPath = self::getResourcePath("etc/VERSION.TXT"); - } - try { // try to read file - $buffer = null; - $file = new PhingFile($versionPath); - $reader = new FileReader($file); - $reader->readInto($buffer); - $buffer = trim($buffer); - //$buffer = "PHING version 1.0, Released 2002-??-??"; - $phingVersion = $buffer; - } catch (IOException $iox) { - print("Can't read version information file\n"); - throw new BuildException("Build failed"); - } - return $phingVersion; - } - - /** Print the project description, if any */ - function printDescription(Project $project) { - if ($project->getDescription() !== null) { - print($project->getDescription()."\n"); - } - } - - /** Print out a list of all targets in the current buildfile */ - function printTargets($project) { - // find the target with the longest name - $maxLength = 0; - $targets = $project->getTargets(); - $targetNames = array_keys($targets); - $targetName = null; - $targetDescription = null; - $currentTarget = null; - - // split the targets in top-level and sub-targets depending - // on the presence of a description - - $subNames = array(); - $topNameDescMap = array(); - - foreach($targets as $currentTarget) { - $targetName = $currentTarget->getName(); - $targetDescription = $currentTarget->getDescription(); - - // subtargets are targets w/o descriptions - if ($targetDescription === null) { - $subNames[] = $targetName; - } else { - // topNames and topDescriptions are handled later - // here we store in hash map (for sorting purposes) - $topNameDescMap[$targetName] = $targetDescription; - if (strlen($targetName) > $maxLength) { - $maxLength = strlen($targetName); - } - } - } - - // Sort the arrays - sort($subNames); // sort array values, resetting keys (which are numeric) - ksort($topNameDescMap); // sort the keys (targetName) keeping key=>val associations - - $topNames = array_keys($topNameDescMap); - $topDescriptions = array_values($topNameDescMap); - - $defaultTarget = $project->getDefaultTarget(); - - if ($defaultTarget !== null && $defaultTarget !== "") { - $defaultName = array(); - $defaultDesc = array(); - $defaultName[] = $defaultTarget; - - $indexOfDefDesc = array_search($defaultTarget, $topNames, true); - if ($indexOfDefDesc !== false && $indexOfDefDesc >= 0) { - $defaultDesc = array(); - $defaultDesc[] = $topDescriptions[$indexOfDefDesc]; - } - - $this->_printTargets($defaultName, $defaultDesc, "Default target:", $maxLength); - - } - $this->_printTargets($topNames, $topDescriptions, "Main targets:", $maxLength); - $this->_printTargets($subNames, null, "Subtargets:", 0); - } - - /** - * Writes a formatted list of target names with an optional description. - * - * @param array $names The names to be printed. - * Must not be null. - * @param array $descriptions The associated target descriptions. - * May be null, in which case - * no descriptions are displayed. - * If non-null, this should have - * as many elements as names. - * @param string $heading The heading to display. - * Should not be null. - * @param int $maxlen The maximum length of the names of the targets. - * If descriptions are given, they are padded to this - * position so they line up (so long as the names really - * are shorter than this). - */ - private function _printTargets($names, $descriptions, $heading, $maxlen) { - $lSep = self::getProperty("line.separator"); - $spaces = ' '; - while (strlen($spaces) < $maxlen) { - $spaces .= $spaces; - } - $msg = ""; - $msg .= $heading . $lSep; - $msg .= str_repeat("-",79) . $lSep; - - $total = count($names); - for($i=0; $i < $total; $i++) { - $msg .= " "; - $msg .= $names[$i]; - if (!empty($descriptions)) { - $msg .= substr($spaces, 0, $maxlen - strlen($names[$i]) + 2); - $msg .= $descriptions[$i]; - } - $msg .= $lSep; - } - if ($total > 0) { - print $msg . $lSep; - } - } - - /** - * Import a dot-path notation class path. - * @param string $dotPath - * @param mixed $classpath String or object supporting __toString() - * @return string The unqualified classname (which can be instantiated). - * @throws BuildException - if cannot find the specified file - */ - public static function import($dotPath, $classpath = null) { - - // first check to see that the class specified hasn't already been included. - // (this also handles case where this method is called w/ a classname rather than dotpath) - $classname = StringHelper::unqualify($dotPath); - if (class_exists($classname, false)) { - return $classname; - } - - $dotClassname = basename($dotPath); - $dotClassnamePos = strlen($dotPath) - strlen($dotClassname); - $classFile = strtr($dotClassname, '.', DIRECTORY_SEPARATOR) . ".php"; - $path = substr_replace($dotPath, $classFile, $dotClassnamePos); - - Phing::__import($path, $classpath); - - return $classname; - } - - /** - * Import a PHP file - * @param string $path Path to the PHP file - * @param mixed $classpath String or object supporting __toString() - * @throws BuildException - if cannot find the specified file - */ - public static function __import($path, $classpath = null) { - - if ($classpath) { - - // Apparently casting to (string) no longer invokes __toString() automatically. - if (is_object($classpath)) { - $classpath = $classpath->__toString(); - } - - // classpaths are currently additive, but we also don't want to just - // indiscriminantly prepand/append stuff to the include_path. This means - // we need to parse current incldue_path, and prepend any - // specified classpath locations that are not already in the include_path. - // - // NOTE: the reason why we do it this way instead of just changing include_path - // and then changing it back, is that in many cases applications (e.g. Propel) will - // include/require class files from within method calls. This means that not all - // necessary files will be included in this import() call, and hence we can't - // change the include_path back without breaking those apps. While this method could - // be more expensive than switching & switching back (not sure, but maybe), it makes it - // possible to write far less expensive run-time applications (e.g. using Propel), which is - // really where speed matters more. - - $curr_parts = explode(PATH_SEPARATOR, ini_get('include_path')); - $add_parts = explode(PATH_SEPARATOR, $classpath); - $new_parts = array_diff($add_parts, $curr_parts); - if ($new_parts) { - if (self::getMsgOutputLevel() === PROJECT_MSG_DEBUG) { - print("Phing::import() prepending new include_path components: " . implode(PATH_SEPARATOR, $new_parts) . "\n"); - } - ini_set('include_path', implode(PATH_SEPARATOR, array_merge($new_parts, $curr_parts))); - } - } - - $ret = include_once($path); - - if ($ret === false) { - $e = new BuildException("Error importing $path"); - if (self::getMsgOutputLevel() === PROJECT_MSG_DEBUG) { - // We can't log this because listeners belong - // to projects. We'll just print it -- of course - // that isn't very compatible w/ other frontends (but - // there aren't any right now, so I'm not stressing) - print("Error importing $path\n"); - print($e->getTraceAsString()."\n"); - } - throw $e; - } - - return; - } - - /** - * Looks on include path for specified file. - * @return string File found (null if no file found). - */ - public static function getResourcePath($path) { - - if (self::$importPaths === null) { - $paths = ini_get("include_path"); - self::$importPaths = explode(PATH_SEPARATOR, ini_get("include_path")); - } - - $path = str_replace('\\', DIRECTORY_SEPARATOR, $path); - $path = str_replace('/', DIRECTORY_SEPARATOR, $path); - - foreach (self::$importPaths as $prefix) { - $foo_path = $prefix . DIRECTORY_SEPARATOR . $path; - if (file_exists($foo_path)) { - return $foo_path; - } - } - - // Check for the property phing.home - $home_dir = self::getProperty('phing.home'); - - if ($home_dir) - { - $home_path = $home_dir . DIRECTORY_SEPARATOR . $path; - - if (file_exists($home_path)) - { - return $home_path; - } - } - - // If we are using this via PEAR then check for the file in the data dir - // This is a bit of a hack, but works better than previous solution of assuming - // data_dir is on the include_path. - $data_dir = '@DATA-DIR@'; - if ($data_dir{0} != '@') { // if we're using PEAR then the @ DATA-DIR @ token will have been substituted. - $data_path = $data_dir . DIRECTORY_SEPARATOR . $path; - if (file_exists($data_path)) { - return $data_path; - } - } - - return null; - } - - // ------------------------------------------------------------------------------------------- - // System-wide methods (moved from System class, which had namespace conflicts w/ PEAR System) - // ------------------------------------------------------------------------------------------- - - /** - * Set System constants which can be retrieved by calling Phing::getProperty($propName). - * @return void - */ - private static function setSystemConstants() { - - /* - * PHP_OS returns on - * WindowsNT4.0sp6 => WINNT - * Windows2000 => WINNT - * Windows ME => WIN32 - * Windows 98SE => WIN32 - * FreeBSD 4.5p7 => FreeBSD - * Redhat Linux => Linux - * Mac OS X => Darwin - */ - self::setProperty('host.os', PHP_OS); - - // this is used by some tasks too - self::setProperty('os.name', PHP_OS); - - // it's still possible this won't be defined, - // e.g. if Phing is being included in another app w/o - // using the phing.php script. - if (!defined('PHP_CLASSPATH')) { - define('PHP_CLASSPATH', get_include_path()); - } - - self::setProperty('php.classpath', PHP_CLASSPATH); - - // try to determine the host filesystem and set system property - // used by Fileself::getFileSystem to instantiate the correct - // abstraction layer - - switch (strtoupper(PHP_OS)) { - case 'WINNT': - self::setProperty('host.fstype', 'WINNT'); - break; - case 'WIN32': - self::setProperty('host.fstype', 'WIN32'); - break; - default: - self::setProperty('host.fstype', 'UNIX'); - break; - } - - self::setProperty('php.version', PHP_VERSION); - self::setProperty('user.home', getenv('HOME')); - self::setProperty('application.startdir', getcwd()); - self::setProperty('line.separator', "\n"); - - // try to detect machine dependent information - $sysInfo = array(); - if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' && function_exists("posix_uname")) { - $sysInfo = posix_uname(); - } else { - $sysInfo['nodename'] = php_uname('n'); - $sysInfo['machine']= php_uname('m') ; - //this is a not so ideal substition, but maybe better than nothing - $sysInfo['domain'] = isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : "unknown"; - $sysInfo['release'] = php_uname('r'); - $sysInfo['version'] = php_uname('v'); - } - - - self::setProperty("host.name", isset($sysInfo['nodename']) ? $sysInfo['nodename'] : "unknown"); - self::setProperty("host.arch", isset($sysInfo['machine']) ? $sysInfo['machine'] : "unknown"); - self::setProperty("host.domain",isset($sysInfo['domain']) ? $sysInfo['domain'] : "unknown"); - self::setProperty("host.os.release", isset($sysInfo['release']) ? $sysInfo['release'] : "unknown"); - self::setProperty("host.os.version", isset($sysInfo['version']) ? $sysInfo['version'] : "unknown"); - unset($sysInfo); - } - - /** - * This gets a property that was set via command line or otherwise passed into Phing. - * "Defined" in this case means "externally defined". The reason this method exists is to - * provide a public means of accessing commandline properties for (e.g.) logger or listener - * scripts. E.g. to specify which logfile to use, PearLogger needs to be able to access - * the pear.log.name property. - * - * @param string $name - * @return string value of found property (or null, if none found). - */ - public static function getDefinedProperty($name) { - return self::$definedProps->getProperty($name); - } - - /** - * This sets a property that was set via command line or otherwise passed into Phing. - * - * @param string $name - * @return string value of found property (or null, if none found). - */ - public static function setDefinedProperty($name, $value) { - return self::$definedProps->setProperty($name, $value); - } - - /** - * Returns property value for a System property. - * System properties are "global" properties like line.separator, - * and user.dir. Many of these correspond to similar properties in Java - * or Ant. - * - * @param string $paramName - * @return string Value of found property (or null, if none found). - */ - public static function getProperty($propName) { - - // some properties are detemined on each access - // some are cached, see below - - // default is the cached value: - $val = isset(self::$properties[$propName]) ? self::$properties[$propName] : null; - - // special exceptions - switch($propName) { - case 'user.dir': - $val = getcwd(); - break; - } - - return $val; - } - - /** Retuns reference to all properties*/ - public static function &getProperties() { - return self::$properties; - } - - public static function setProperty($propName, $propValue) { - $propName = (string) $propName; - $oldValue = self::getProperty($propName); - self::$properties[$propName] = $propValue; - return $oldValue; - } - - public static function currentTimeMillis() { - list($usec, $sec) = explode(" ",microtime()); - return ((float)$usec + (float)$sec); - } - - /** - * Sets the include path based on PHP_CLASSPATH constant (set in phing.php). - * @return void - */ - private static function setIncludePaths() { - $success = false; - - if (defined('PHP_CLASSPATH')) { - $success = ini_set('include_path', PHP_CLASSPATH); - } else { - // don't do anything, just assume that include_path has been properly set. - $success = true; - } - - if ($success === false) { - print("SYSTEM FAILURE: Could not set PHP include path\n"); - self::halt(-1); - } - } - - /** - * Sets PHP INI values that Phing needs. - * @return void - */ - private static function setIni() { - error_reporting(E_ALL); - set_time_limit(0); - ini_set('magic_quotes_gpc', 'off'); - ini_set('short_open_tag', 'off'); - ini_set('default_charset', 'iso-8859-1'); - ini_set('register_globals', 'off'); - ini_set('allow_call_time_pass_reference', 'on'); - - // should return memory limit in MB - $mem_limit = (int) ini_get('memory_limit'); - if ($mem_limit < 32) { - ini_set('memory_limit', '32M'); // nore: this may need to be higher for many projects - } - } - - /** - * Returns reference to Timer object. - * @return Timer - */ - public static function getTimer() { - if (self::$timer === null) { - include_once 'phing/system/util/Timer.php'; - self::$timer= new Timer(); - } - return self::$timer; - } - - /** - * Start up Phing. - * Sets up the Phing environment -- does NOT initiate the build process. - * @return void - */ - public static function startup() { - - register_shutdown_function(array('Phing', 'shutdown')); - - // some init stuff - self::getTimer()->start(); - - self::setSystemConstants(); - self::setIncludePaths(); - self::setIni(); - } - - /** - * Halts the system. - * @see shutdown() - */ - public static function halt($code=0) { - self::shutdown($code); - } - - /** - * Stops timers & exits. - * @return void - */ - public static function shutdown($exitcode = 0) { - //print("[AUTOMATIC SYSTEM SHUTDOWN]\n"); - self::getTimer()->stop(); - exit($exitcode); // final point where everything stops - } - -} diff --git a/buildscripts/phing/classes/phing/Project.php b/buildscripts/phing/classes/phing/Project.php deleted file mode 100644 index 8123d91e..00000000 --- a/buildscripts/phing/classes/phing/Project.php +++ /dev/null @@ -1,966 +0,0 @@ -. - */ - -define('PROJECT_MSG_DEBUG', 4); -define('PROJECT_MSG_VERBOSE', 3); -define('PROJECT_MSG_INFO', 2); -define('PROJECT_MSG_WARN', 1); -define('PROJECT_MSG_ERR', 0); - -include_once 'phing/system/io/PhingFile.php'; -include_once 'phing/util/FileUtils.php'; -include_once 'phing/TaskAdapter.php'; -include_once 'phing/util/StringHelper.php'; -include_once 'phing/BuildEvent.php'; -include_once 'phing/input/DefaultInputHandler.php'; - -/** - * The Phing project class. Represents a completely configured Phing project. - * The class defines the project and all tasks/targets. It also contains - * methods to start a build as well as some properties and FileSystem - * abstraction. - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.29 $ - * @package phing - */ -class Project { - - /** contains the targets */ - private $targets = array(); - /** global filterset (future use) */ - private $globalFilterSet = array(); - /** all globals filters (future use) */ - private $globalFilters = array(); - - /** Project properties map (usually String to String). */ - private $properties = array(); - - /** - * Map of "user" properties (as created in the Ant task, for example). - * Note that these key/value pairs are also always put into the - * project properties, so only the project properties need to be queried. - * Mapping is String to String. - */ - private $userProperties = array(); - - /** - * Map of inherited "user" properties - that are those "user" - * properties that have been created by tasks and not been set - * from the command line or a GUI tool. - * Mapping is String to String. - */ - private $inheritedProperties = array(); - - /** task definitions for this project*/ - private $taskdefs = array(); - - /** type definitions for this project */ - private $typedefs = array(); - - /** holds ref names and a reference to the referred object*/ - private $references = array(); - - /** The InputHandler being used by this project. */ - private $inputHandler; - - /* -- properties that come in via xml attributes -- */ - - /** basedir (PhingFile object) */ - private $basedir; - - /** the default target name */ - private $defaultTarget = 'all'; - - /** project name (required) */ - private $name; - - /** project description */ - private $description; - - /** a FileUtils object */ - private $fileUtils; - - /** Build listeneers */ - private $listeners = array(); - - /** - * Constructor, sets any default vars. - */ - function __construct() { - $this->fileUtils = new FileUtils(); - $this->inputHandler = new DefaultInputHandler(); - } - - /** - * Sets the input handler - */ - public function setInputHandler(InputHandler $handler) { - $this->inputHandler = $handler; - } - - /** - * Retrieves the current input handler. - */ - public function getInputHandler() { - return $this->inputHandler; - } - - /** inits the project, called from main app */ - function init() { - // set builtin properties - $this->setSystemProperties(); - - // load default tasks - $taskdefs = Phing::getResourcePath("phing/tasks/defaults.properties"); - - try { // try to load taskdefs - $props = new Properties(); - $in = new PhingFile((string)$taskdefs); - - if ($in === null) { - throw new BuildException("Can't load default task list"); - } - $props->load($in); - - $enum = $props->propertyNames(); - foreach($enum as $key) { - $value = $props->getProperty($key); - $this->addTaskDefinition($key, $value); - } - } catch (IOException $ioe) { - throw new BuildException("Can't load default task list"); - } - - // load default tasks - $typedefs = Phing::getResourcePath("phing/types/defaults.properties"); - - try { // try to load typedefs - $props = new Properties(); - $in = new PhingFile((string)$typedefs); - if ($in === null) { - throw new BuildException("Can't load default datatype list"); - } - $props->load($in); - - $enum = $props->propertyNames(); - foreach($enum as $key) { - $value = $props->getProperty($key); - $this->addDataTypeDefinition($key, $value); - } - } catch(IOException $ioe) { - throw new BuildException("Can't load default datatype list"); - } - } - - /** returns the global filterset (future use) */ - function getGlobalFilterSet() { - return $this->globalFilterSet; - } - - // --------------------------------------------------------- - // Property methods - // --------------------------------------------------------- - - /** - * Sets a property. Any existing property of the same name - * is overwritten, unless it is a user property. - * @param string $name The name of property to set. - * Must not be null. - * @param string $value The new value of the property. - * Must not be null. - * @return void - */ - public function setProperty($name, $value) { - - // command line properties take precedence - if (isset($this->userProperties[$name])) { - $this->log("Override ignored for user property " . $name, PROJECT_MSG_VERBOSE); - return; - } - - if (isset($this->properties[$name])) { - $this->log("Overriding previous definition of property " . $name, PROJECT_MSG_VERBOSE); - } - - $this->log("Setting project property: " . $name . " -> " . $value, PROJECT_MSG_DEBUG); - $this->properties[$name] = $value; - } - - /** - * Sets a property if no value currently exists. If the property - * exists already, a message is logged and the method returns with - * no other effect. - * - * @param string $name The name of property to set. - * Must not be null. - * @param string $value The new value of the property. - * Must not be null. - * @since 2.0 - */ - public function setNewProperty($name, $value) { - if (isset($this->properties[$name])) { - $this->log("Override ignored for property " . $name, PROJECT_MSG_DEBUG); - return; - } - $this->log("Setting project property: " . $name . " -> " . $value, PROJECT_MSG_DEBUG); - $this->properties[$name] = $value; - } - - /** - * Sets a user property, which cannot be overwritten by - * set/unset property calls. Any previous value is overwritten. - * @param string $name The name of property to set. - * Must not be null. - * @param string $value The new value of the property. - * Must not be null. - * @see #setProperty() - */ - public function setUserProperty($name, $value) { - $this->log("Setting ro project property: " . $name . " -> " . $value, PROJECT_MSG_DEBUG); - $this->userProperties[$name] = $value; - $this->properties[$name] = $value; - } - - /** - * Sets a user property, which cannot be overwritten by set/unset - * property calls. Any previous value is overwritten. Also marks - * these properties as properties that have not come from the - * command line. - * - * @param string $name The name of property to set. - * Must not be null. - * @param string $value The new value of the property. - * Must not be null. - * @see #setProperty() - */ - public function setInheritedProperty($name, $value) { - $this->inheritedProperties[$name] = $value; - $this->setUserProperty($name, $value); - } - - /** - * Sets a property unless it is already defined as a user property - * (in which case the method returns silently). - * - * @param name The name of the property. - * Must not be null. - * @param value The property value. Must not be null. - */ - private function setPropertyInternal($name, $value) { - if (isset($this->userProperties[$name])) { - $this->log("Override ignored for user property " . $name, PROJECT_MSG_VERBOSE); - return; - } - $this->properties[$name] = $value; - } - - /** - * Returns the value of a property, if it is set. - * - * @param string $name The name of the property. - * May be null, in which case - * the return value is also null. - * @return string The property value, or null for no match - * or if a null name is provided. - */ - public function getProperty($name) { - if (!isset($this->properties[$name])) { - return null; - } - return $this->properties[$name]; - } - - /** - * Replaces ${} style constructions in the given value with the - * string value of the corresponding data types. - * - * @param value The string to be scanned for property references. - * May be null. - * - * @return the given string with embedded property names replaced - * by values, or null if the given string is - * null. - * - * @exception BuildException if the given value has an unclosed - * property name, e.g. ${xxx - */ - public function replaceProperties($value) { - return ProjectConfigurator::replaceProperties($this, $value, $this->properties); - } - - /** - * Returns the value of a user property, if it is set. - * - * @param string $name The name of the property. - * May be null, in which case - * the return value is also null. - * @return string The property value, or null for no match - * or if a null name is provided. - */ - public function getUserProperty($name) { - if (!isset($this->userProperties[$name])) { - return null; - } - return $this->userProperties[$name]; - } - - /** - * Returns a copy of the properties table. - * @return array A hashtable containing all properties - * (including user properties). - */ - public function getProperties() { - return $this->properties; - } - - /** - * Returns a copy of the user property hashtable - * @return a hashtable containing just the user properties - */ - public function getUserProperties() { - return $this->userProperties; - } - - /** - * Copies all user properties that have been set on the command - * line or a GUI tool from this instance to the Project instance - * given as the argument. - * - *

To copy all "user" properties, you will also have to call - * {@link #copyInheritedProperties copyInheritedProperties}.

- * - * @param Project $other the project to copy the properties to. Must not be null. - * @return void - * @since phing 2.0 - */ - public function copyUserProperties(Project $other) { - foreach($this->userProperties as $arg => $value) { - if (isset($this->inheritedProperties[$arg])) { - continue; - } - $other->setUserProperty($arg, $value); - } - } - - /** - * Copies all user properties that have not been set on the - * command line or a GUI tool from this instance to the Project - * instance given as the argument. - * - *

To copy all "user" properties, you will also have to call - * {@link #copyUserProperties copyUserProperties}.

- * - * @param other the project to copy the properties to. Must not be null. - * - * @since phing 2.0 - */ - public function copyInheritedProperties(Project $other) { - foreach($this->userProperties as $arg => $value) { - if ($other->getUserProperty($arg) !== null) { - continue; - } - $other->setInheritedProperty($arg, $value); - } - } - - // --------------------------------------------------------- - // END Properties methods - // --------------------------------------------------------- - - - function setDefaultTarget($targetName) { - $this->defaultTarget = (string) trim($targetName); - } - - function getDefaultTarget() { - return (string) $this->defaultTarget; - } - - /** - * Sets the name of the current project - * - * @param string name of project - * @return void - * @access public - * @author Andreas Aderhold, andi@binarycloud.com - */ - - function setName($name) { - $this->name = (string) trim($name); - $this->setProperty("phing.project.name", $this->name); - } - - /** - * Returns the name of this project - * - * @returns string projectname - * @access public - * @author Andreas Aderhold, andi@binarycloud.com - */ - function getName() { - return (string) $this->name; - } - - /** Set the projects description */ - function setDescription($description) { - $this->description = (string) trim($description); - } - - /** return the description, null otherwise */ - function getDescription() { - return $this->description; - } - - /** Set basedir object from xml*/ - function setBasedir($dir) { - if ($dir instanceof PhingFile) { - $dir = $dir->getAbsolutePath(); - } - - $dir = $this->fileUtils->normalize($dir); - - $dir = new PhingFile((string) $dir); - if (!$dir->exists()) { - throw new BuildException("Basedir ".$dir->getAbsolutePath()." does not exist"); - } - if (!$dir->isDirectory()) { - throw new BuildException("Basedir ".$dir->getAbsolutePath()." is not a directory"); - } - $this->basedir = $dir; - $this->setPropertyInternal("project.basedir", $this->basedir->getAbsolutePath()); - $this->log("Project base dir set to: " . $this->basedir->getPath(), PROJECT_MSG_VERBOSE); - - // [HL] added this so that ./ files resolve correctly. This may be a mistake ... or may be in wrong place. - chdir($dir->getAbsolutePath()); - } - - /** - * Returns the basedir of this project - * - * @returns PhingFile Basedir PhingFile object - * @access public - * @throws BuildException - * @author Andreas Aderhold, andi@binarycloud.com - */ - function getBasedir() { - if ($this->basedir === null) { - try { // try to set it - $this->setBasedir("."); - } catch (BuildException $exc) { - throw new BuildException("Can not set default basedir. ".$exc->getMessage()); - } - } - return $this->basedir; - } - - /** - * Sets system properties and the environment variables for this project. - * - * @return void - */ - function setSystemProperties() { - - // first get system properties - $systemP = array_merge( self::getProperties(), Phing::getProperties() ); - foreach($systemP as $name => $value) { - $this->setPropertyInternal($name, $value); - } - - // and now the env vars - foreach($_SERVER as $name => $value) { - // skip arrays - if (is_array($value)) { - continue; - } - $this->setPropertyInternal('env.' . $name, $value); - } - return true; - } - - - /** - * Adds a task definition. - * @param string $name Name of tag. - * @param string $class The class path to use. - * @param string $classpath The classpat to use. - */ - function addTaskDefinition($name, $class, $classpath = null) { - $name = $name; - $class = $class; - if ($class === "") { - $this->log("Task $name has no class defined.", PROJECT_MSG_ERR); - } elseif (!isset($this->taskdefs[$name])) { - Phing::import($class, $classpath); - $this->taskdefs[$name] = $class; - $this->log(" +Task definiton: $name ($class)", PROJECT_MSG_DEBUG); - } else { - $this->log("Task $name ($class) already registerd, skipping", PROJECT_MSG_VERBOSE); - } - } - - function &getTaskDefinitions() { - return $this->taskdefs; - } - - /** - * Adds a data type definition. - * @param string $name Name of tag. - * @param string $class The class path to use. - * @param string $classpath The classpat to use. - */ - function addDataTypeDefinition($typeName, $typeClass, $classpath = null) { - if (!isset($this->typedefs[$typeName])) { - Phing::import($typeClass, $classpath); - $this->typedefs[$typeName] = $typeClass; - $this->log(" +User datatype: $typeName ($typeClass)", PROJECT_MSG_DEBUG); - } else { - $this->log("Type $name ($class) already registerd, skipping", PROJECT_MSG_VERBOSE); - } - } - - function getDataTypeDefinitions() { - return $this->typedefs; - } - - /** add a new target to the project */ - function addTarget($targetName, &$target) { - if (isset($this->targets[$targetName])) { - throw new BuildException("Duplicate target: $targetName"); - } - $this->addOrReplaceTarget($targetName, $target); - } - - function addOrReplaceTarget($targetName, &$target) { - $this->log(" +Target: $targetName", PROJECT_MSG_DEBUG); - $target->setProject($this); - $this->targets[$targetName] = $target; - } - - function getTargets() { - return $this->targets; - } - - /** - * Create a new task instance and return reference to it. This method is - * sorta factory like. A _local_ instance is created and a reference returned to - * that instance. Usually PHP destroys local variables when the function call - * ends. But not if you return a reference to that variable. - * This is kinda error prone, because if no reference exists to the variable - * it is destroyed just like leaving the local scope with primitive vars. There's no - * central place where the instance is stored as in other OOP like languages. - * - * [HL] Well, ZE2 is here now, and this is still working. We'll leave this alone - * unless there's any good reason not to. - * - * @param string $taskType Task name - * @returns Task A task object - * @throws BuildException - * Exception - */ - function createTask($taskType) { - try { - $cls = ""; - $tasklwr = strtolower($taskType); - foreach ($this->taskdefs as $name => $class) { - if (strtolower($name) === $tasklwr) { - $cls = StringHelper::unqualify($class); - break; - } - } - - if ($cls === "") { - return null; - } - - if (!class_exists($cls)) { - throw new BuildException("Could not instantiate class $cls, even though a class was specified. (Make sure that the specified class file contains a class with the correct name.)"); - } - - $o = new $cls(); - - if ($o instanceof Task) { - $task = $o; - } else { - $this->log (" (Using TaskAdapter for: $taskType)", PROJECT_MSG_DEBUG); - // not a real task, try adapter - $taskA = new TaskAdapter(); - $taskA->setProxy($o); - $task = $taskA; - } - $task->setProject($this); - $task->setTaskType($taskType); - // set default value, can be changed by the user - $task->setTaskName($taskType); - $this->log (" +Task: " . $taskType, PROJECT_MSG_DEBUG); - } catch (Exception $t) { - throw new BuildException("Could not create task of type: " . $taskType, $t); - } - // everything fine return reference - return $task; - } - - /** - * Create a task instance and return reference to it - * See createTask() for explanation how this works - * - * @param string Type name - * @returns object A datatype object - * @throws BuildException - * Exception - */ - function createDataType($typeName) { - try { - $cls = ""; - $typelwr = strtolower($typeName); - foreach ($this->typedefs as $name => $class) { - if (strtolower($name) === $typelwr) { - $cls = StringHelper::unqualify($class); - break; - } - } - - if ($cls === "") { - return null; - } - - if (!class_exists($cls)) { - throw new BuildException("Could not instantiate class $cls, even though a class was specified. (Make sure that the specified class file contains a class with the correct name.)"); - } - - $type = new $cls(); - $this->log(" +Type: $typeName", PROJECT_MSG_DEBUG); - if (!($type instanceof DataType)) { - throw new Exception("$class is not an instance of phing.types.DataType"); - } - if ($type instanceof ProjectComponent) { - $type->setProject($this); - } - } catch (Exception $t) { - throw new BuildException("Could not create type: $typeName", $t); - } - // everything fine return reference - return $type; - } - - /** - * Executes a list of targets - * - * @param array List of target names to execute - * @returns void - * @throws BuildException - */ - function executeTargets($targetNames) { - foreach($targetNames as $tname) { - $this->executeTarget($tname); - } - } - - /** - * Executes a target - * - * @param string Name of Target to execute - * @returns void - * @throws BuildException - */ - function executeTarget($targetName) { - - // complain about executing void - if ($targetName === null) { - throw new BuildException("No target specified"); - } - - // invoke topological sort of the target tree and run all targets - // until targetName occurs. - $sortedTargets = $this->_topoSort($targetName, $this->targets); - - $curIndex = (int) 0; - $curTarget = null; - do { - try { - $curTarget = $sortedTargets[$curIndex++]; - $curTarget->performTasks(); - } catch (BuildException $exc) { - $this->log("Execution of target \"".$curTarget->getName()."\" failed for the following reason: ".$exc->getMessage(), PROJECT_MSG_ERR); - throw $exc; - } - } while ($curTarget->getName() !== $targetName); - } - - - function resolveFile($fileName, $rootDir = null) { - if ($rootDir === null) { - return $this->fileUtils->resolveFile($this->basedir, $fileName); - } else { - return $this->fileUtils->resolveFile($rootDir, $fileName); - } - } - - /** - * Topologically sort a set of Targets. - * @param $root is the (String) name of the root Target. The sort is - * created in such a way that the sequence of Targets until the root - * target is the minimum possible such sequence. - * @param $targets is a array representing a "name to Target" mapping - * @return An array of Strings with the names of the targets in - * sorted order. - */ - function _topoSort($root, &$targets) { - - $root = (string) $root; - $ret = array(); - $state = array(); - $visiting = array(); - - // We first run a DFS based sort using the root as the starting node. - // This creates the minimum sequence of Targets to the root node. - // We then do a sort on any remaining unVISITED targets. - // This is unnecessary for doing our build, but it catches - // circular dependencies or missing Targets on the entire - // dependency tree, not just on the Targets that depend on the - // build Target. - - $this->_tsort($root, $targets, $state, $visiting, $ret); - - $retHuman = ""; - for ($i=0, $_i=count($ret); $i < $_i; $i++) { - $retHuman .= $ret[$i]->toString()." "; - } - $this->log("Build sequence for target '$root' is: $retHuman", PROJECT_MSG_VERBOSE); - - $keys = array_keys($targets); - while($keys) { - $curTargetName = (string) array_shift($keys); - if (!isset($state[$curTargetName])) { - $st = null; - } else { - $st = (string) $state[$curTargetName]; - } - - if ($st === null) { - $this->_tsort($curTargetName, $targets, $state, $visiting, $ret); - } elseif ($st === "VISITING") { - throw new Exception("Unexpected node in visiting state: $curTargetName"); - } - } - - $retHuman = ""; - for ($i=0,$_i=count($ret); $i < $_i; $i++) { - $retHuman .= $ret[$i]->toString()." "; - } - $this->log("Complete build sequence is: $retHuman", PROJECT_MSG_VERBOSE); - - return $ret; - } - - // one step in a recursive DFS traversal of the target dependency tree. - // - The array "state" contains the state (VISITED or VISITING or null) - // of all the target names. - // - The stack "visiting" contains a stack of target names that are - // currently on the DFS stack. (NB: the target names in "visiting" are - // exactly the target names in "state" that are in the VISITING state.) - // 1. Set the current target to the VISITING state, and push it onto - // the "visiting" stack. - // 2. Throw a BuildException if any child of the current node is - // in the VISITING state (implies there is a cycle.) It uses the - // "visiting" Stack to construct the cycle. - // 3. If any children have not been VISITED, tsort() the child. - // 4. Add the current target to the Vector "ret" after the children - // have been visited. Move the current target to the VISITED state. - // "ret" now contains the sorted sequence of Targets upto the current - // Target. - - function _tsort($root, &$targets, &$state, &$visiting, &$ret) { - $state[$root] = "VISITING"; - $visiting[] = $root; - - if (!isset($targets[$root]) || !($targets[$root] instanceof Target)) { - $target = null; - } else { - $target = $targets[$root]; - } - - // make sure we exist - if ($target === null) { - $sb = "Target '$root' does not exist in this project."; - array_pop($visiting); - if (!empty($visiting)) { - $parent = (string) $visiting[count($visiting)-1]; - $sb .= "It is used from target '$parent'."; - } - throw new BuildException($sb); - } - - $deps = $target->getDependencies(); - - while($deps) { - $cur = (string) array_shift($deps); - if (!isset($state[$cur])) { - $m = null; - } else { - $m = (string) $state[$cur]; - } - if ($m === null) { - // not been visited - $this->_tsort($cur, $targets, $state, $visiting, $ret); - } elseif ($m == "VISITING") { - // currently visiting this node, so have a cycle - throw $this->_makeCircularException($cur, $visiting); - } - } - - $p = (string) array_pop($visiting); - if ($root !== $p) { - throw new Exception("Unexpected internal error: expected to pop $root but got $p"); - } - - $state[$root] = "VISITED"; - $ret[] = $target; - } - - function _makeCircularException($end, $stk) { - $sb = "Circular dependency: $end"; - do { - $sb .= " <- ".(string) array_pop($stk); - } while($c != $end); - return new BuildException($sb); - } - - /** - * Adds a reference to an object. This method is called when the parser - * detects a id="foo" attribute. It passes the id as $name and a reference - * to the object assigned to this id as $value - */ - function addReference($name, $object) { - if (isset($this->references[$name])) { - $this->log("Overriding previous definition of reference to $name", PROJECT_MSG_WARN); - } - $this->log("Adding reference: $name -> ".get_class($object), PROJECT_MSG_DEBUG); - $this->references[$name] = $object; - } - - /** - * Returns the references array. - * @return array - */ - function getReferences() { - return $this->references; - } - - /** - * Returns a specific reference. - * @param string $key The reference id/key. - * @return object or null if not defined - */ - function getReference($key) - { - if (isset($this->references[$key])) { - return $this->references[$key]; - } - return null; // just to be explicit - } - - /** - * Abstracting and simplifyling Logger calls for project messages - */ - function log($msg, $level = PROJECT_MSG_INFO) { - $this->logObject($this, $msg, $level); - } - - function logObject($obj, $msg, $level) { - $this->fireMessageLogged($obj, $msg, $level); - } - - function addBuildListener(BuildListener $listener) { - $this->listeners[] = $listener; - } - - function removeBuildListener(BuildListener $listener) { - $newarray = array(); - for ($i=0, $size=count($this->listeners); $i < $size; $i++) { - if ($this->listeners[$i] !== $listener) { - $newarray[] = $this->listeners[$i]; - } - } - $this->listeners = $newarray; - } - - function getBuildListeners() { - return $this->listeners; - } - - function fireBuildStarted() { - $event = new BuildEvent($this); - foreach($this->listeners as $listener) { - $listener->buildStarted($event); - } - } - - function fireBuildFinished($exception) { - $event = new BuildEvent($this); - $event->setException($exception); - foreach($this->listeners as $listener) { - $listener->buildFinished($event); - } - } - - function fireTargetStarted($target) { - $event = new BuildEvent($target); - foreach($this->listeners as $listener) { - $listener->targetStarted($event); - } - } - - function fireTargetFinished($target, $exception) { - $event = new BuildEvent($target); - $event->setException($exception); - foreach($this->listeners as $listener) { - $listener->targetFinished($event); - } - } - - function fireTaskStarted($task) { - $event = new BuildEvent($task); - foreach($this->listeners as $listener) { - $listener->taskStarted($event); - } - } - - function fireTaskFinished($task, $exception) { - $event = new BuildEvent($task); - $event->setException($exception); - foreach($this->listeners as $listener) { - $listener->taskFinished($event); - } - } - - function fireMessageLoggedEvent($event, $message, $priority) { - $event->setMessage($message, $priority); - foreach($this->listeners as $listener) { - $listener->messageLogged($event); - } - } - - function fireMessageLogged($object, $message, $priority) { - $this->fireMessageLoggedEvent(new BuildEvent($object), $message, $priority); - } -} diff --git a/buildscripts/phing/classes/phing/ProjectComponent.php b/buildscripts/phing/classes/phing/ProjectComponent.php deleted file mode 100644 index 97ef329f..00000000 --- a/buildscripts/phing/classes/phing/ProjectComponent.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -/** - * Abstract class providing properties and methods common to all - * the project components - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.5 $ - * @package phing - */ -abstract class ProjectComponent { - - /** - * Holds a reference to the project that a project component - * (a task, a target, etc.) belongs to - * - * @var object A reference to the current project instance - */ - protected $project = null; - - /** - * References the project to the current component. - * - * @param object The reference to the current project - * @access public - */ - function setProject($project) { - $this->project = $project; - } - - /** - * Returns a reference to current project - * - * @return object Reference to current porject object - * @access public - */ - function getProject() { - return $this->project; - } - - /** - * Logs a message with the given priority. - * - * @param string The message to be logged. - * @param integer The message's priority at this message should have - */ - public function log($msg, $level = PROJECT_MSG_INFO) { - if ($this->project !== null) { - $this->project->log($msg, $level); - } - } -} diff --git a/buildscripts/phing/classes/phing/RuntimeConfigurable.php b/buildscripts/phing/classes/phing/RuntimeConfigurable.php deleted file mode 100644 index a23437fa..00000000 --- a/buildscripts/phing/classes/phing/RuntimeConfigurable.php +++ /dev/null @@ -1,118 +0,0 @@ -. - */ - -/** - * Wrapper class that holds the attributes of a Task (or elements - * nested below that level) and takes care of configuring that element - * at runtime. - * - * SMART-UP INLINE DOCS - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.6 $ - * @package phing - */ -class RuntimeConfigurable { - - private $elementTag = null; - private $children = array(); - private $wrappedObject = null; - private $attributes = array(); - private $characters = ""; - - - /** @param proxy The element to wrap. */ - function __construct($proxy, $elementTag) { - $this->wrappedObject = $proxy; - $this->elementTag = $elementTag; - } - - function setProxy($proxy) { - $this->wrappedObject = $proxy; - } - - /** Set's the attributes for the wrapped element. */ - function setAttributes($attributes) { - $this->attributes = $attributes; - } - - /** Returns the AttributeList of the wrapped element. */ - function getAttributes() { - return $this->attributes; - } - - /** Adds child elements to the wrapped element. */ - function addChild(RuntimeConfigurable $child) { - $this->children[] = $child; - } - - /** Returns the child with index */ - function getChild($index) { - return $this->children[(int)$index]; - } - - /** Add characters from #PCDATA areas to the wrapped element. */ - function addText($data) { - $this->characters .= (string) $data; - } - - function getElementTag() { - return $this->elementTag; - } - - - /** Configure the wrapped element and all children. */ - function maybeConfigure(Project $project) { - $id = null; - - // DataType configured in ProjectConfigurator - // if ( is_a($this->wrappedObject, "DataType") ) - // return; - - if ($this->attributes || $this->characters) { - ProjectConfigurator::configure($this->wrappedObject, $this->attributes, $project); - - if (isset($this->attributes["id"])) { - $id = $this->attributes["id"]; - } - - $this->attributes = null; - - if ($this->characters) { - ProjectConfigurator::addText($project, $this->wrappedObject, (string) $this->characters); - $this->characters=""; - } - if ($id !== null) { - $project->addReference($id, $this->wrappedObject); - } - } - - if ( is_array($this->children) && !empty($this->children) ) { - // Configure all child of this object ... - foreach($this->children as $child) { - $child->maybeConfigure($project); - ProjectConfigurator::storeChild($project, $this->wrappedObject, $child->wrappedObject, strtolower($child->getElementTag())); - } - } - } -} - diff --git a/buildscripts/phing/classes/phing/Target.php b/buildscripts/phing/classes/phing/Target.php deleted file mode 100644 index 9aeb9440..00000000 --- a/buildscripts/phing/classes/phing/Target.php +++ /dev/null @@ -1,317 +0,0 @@ -. - */ - -include_once 'phing/TaskContainer.php'; - -/** - * The Target component. Carries all required target data. Implements the - * abstract class {@link TaskContainer} - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.10 $ $Date: 2005/10/04 19:13:44 $ - * @access public - * @see TaskContainer - * @package phing - */ - -class Target implements TaskContainer { - - /** name of target */ - private $name; - - /** dependencies */ - private $dependencies = array(); - - /** holds objects of children of this target */ - private $children = array(); - - /** the if cond. from xml */ - private $ifCondition = ""; - - /** the unless cond. from xml */ - private $unlessCondition = ""; - - /** description of this target */ - private $description; - - /** reference to project */ - private $project; - - /** - * References the project to the current component. - * - * @param Project The reference to the current project - */ - public function setProject(Project $project) { - $this->project = $project; - } - - /** - * Returns reference to current project - * - * @return Project Reference to current porject object - */ - public function getProject() { - return $this->project; - } - - /** - * Sets the target dependencies from xml - * - * @param string $depends Comma separated list of targetnames that depend on - * this target - * @throws BuildException - */ - public function setDepends($depends) { - // explode should be faster than strtok - $deps = explode(',', $depends); - for ($i=0, $size=count($deps); $i < $size; $i++) { - $trimmed = trim($deps[$i]); - if ($trimmed === "") { - throw new BuildException("Syntax Error: Depend attribute for target ".$this->getName()." is malformed."); - } - $this->addDependency($trimmed); - } - } - - /** - * Adds a singular dependent target name to the list - * - * @param string The dependency target to add - * @access public - */ - public function addDependency($dependency) { - $this->dependencies[] = (string) $dependency; - } - - /** - * Returns reference to indexed array of the dependencies this target has. - * - * @return array Referece to target dependencoes - */ - public function getDependencies() { - return $this->dependencies; - } - - /** - * Sets the name of the target - * - * @param string Name of this target - */ - public function setName($name) { - $this->name = (string) $name; - } - - /** - * Returns name of this target. - * - * @return string The name of the target - * @access public - */ - function getName() { - return (string) $this->name; - } - - /** - * Adds a task element to the list of this targets child elements - * - * @param object The task object to add - * @access public - */ - function addTask(Task $task) { - $this->children[] = $task; - } - - /** - * Adds a runtime configurable element to the list of this targets child - * elements. - * - * @param object The RuntimeConfigurabel object - * @access public - */ - function addDataType($rtc) { - $this->children[] = $rtc; - } - - /** - * Returns an array of all tasks this target has as childrens. - * - * The task objects are copied here. Don't use this method to modify - * task objects. - * - * @return array Task[] - */ - public function getTasks() { - $tasks = array(); - for ($i=0,$size=count($this->children); $i < $size; $i++) { - $tsk = $this->children[$i]; - if ($tsk instanceof Task) { - // note: we're copying objects here! - $tasks[] = clone $tsk; - } - } - return $tasks; - } - - /** - * Set the if-condition from the XML tag, if any. The property name given - * as parameter must be present so the if condition evaluates to true - * - * @param string The property name that has to be present - * @access public - */ - public function setIf($property) { - $this->ifCondition = ($property === null) ? "" : $property; - } - - /** - * Set the unless-condition from the XML tag, if any. The property name - * given as parameter must be present so the unless condition evaluates - * to true - * - * @param string The property name that has to be present - * @access public - */ - public function setUnless($property) { - $this->unlessCondition = ($property === null) ? "" : $property; - } - - /** - * Sets a textual description of this target. - * - * @param string The description text - */ - public function setDescription($description) { - if ($description !== null && strcmp($description, "") !== 0) { - $this->description = (string) $description; - } else { - $this->description = null; - } - } - - /** - * Returns the description of this target. - * - * @return string The description text of this target - */ - public function getDescription() { - return $this->description; - } - - /** - * Returns a string representation of this target. In our case it - * simply returns the target name field - * - * @return string The string representation of this target - */ - function toString() { - return (string) $this->name; - } - - /** - * The entry point for this class. Does some checking, then processes and - * performs the tasks for this target. - * - */ - public function main() { - if ($this->testIfCondition() && $this->testUnlessCondition()) { - foreach($this->children as $o) { - if ($o instanceof Task) { - // child is a task - $o->perform(); - } else { - // child is a RuntimeConfigurable - $o->maybeConfigure($this->project); - } - } - } elseif (!$this->testIfCondition()) { - $this->project->log("Skipped target '".$this->name."' because property '".$this->ifCondition."' not set.", PROJECT_MSG_VERBOSE); - } else { - $this->project->log("Skipped target '".$this->name."' because property '".$this->unlessCondition."' set.", PROJECT_MSG_VERBOSE); - } - } - - /** - * Performs the tasks by calling the main method of this target that - * actually executes the tasks. - * - * This method is for ZE2 and used for proper exception handling of - * task exceptions. - */ - public function performTasks() { - try {// try to execute this target - $this->project->fireTargetStarted($this); - $this->main(); - $this->project->fireTargetFinished($this, $null=null); - } catch (Exception $exc) { - // log here and rethrow - $this->project->fireTargetFinished($this, $exc); - throw $exc; - } - } - - /** - * Tests if the property set in ifConfiditon exists. - * - * @return boolean true if the property specified - * in $this->ifCondition exists; - * false otherwise - */ - private function testIfCondition() { - if ($this->ifCondition === "") { - return true; - } - - $properties = explode(",", $this->ifCondition); - - $result = true; - foreach ($properties as $property) { - $test = ProjectConfigurator::replaceProperties($this->getProject(), $property, $this->project->getProperties()); - $result = $result && ($this->project->getProperty($test) !== null); - } - - return $result; - } - - /** - * Tests if the property set in unlessCondition exists. - * - * @return boolean true if the property specified - * in $this->unlessCondition exists; - * false otherwise - */ - private function testUnlessCondition() { - if ($this->unlessCondition === "") { - return true; - } - - $properties = explode(",", $this->unlessCondition); - - $result = true; - foreach ($properties as $property) { - $test = ProjectConfigurator::replaceProperties($this->getProject(), $property, $this->project->getProperties()); - $result = $result && ($this->project->getProperty($test) === null); - } - return $result; - } - -} diff --git a/buildscripts/phing/classes/phing/Task.php b/buildscripts/phing/classes/phing/Task.php deleted file mode 100644 index 893a82e9..00000000 --- a/buildscripts/phing/classes/phing/Task.php +++ /dev/null @@ -1,266 +0,0 @@ -. - */ - -require_once 'phing/ProjectComponent.php'; -include_once 'phing/RuntimeConfigurable.php'; - -/** - * The base class for all Tasks. - * - * Use {@link Project#createTask} to register a new Task. - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.11 $ - * @see Project#createTask() - * @package phing - */ -abstract class Task extends ProjectComponent { - - /** owning Target object */ - protected $target; - - /** description of the task */ - protected $description; - - /** internal taskname (req) */ - protected $taskType; - - /** taskname for logger */ - protected $taskName; - - /** stored buildfile location */ - protected $location; - - /** wrapper of the task */ - protected $wrapper; - - /** - * Sets the owning target this task belongs to. - * - * @param object Reference to owning target - * @access public - */ - function setOwningTarget(Target $target) { - $this->target = $target; - } - - /** - * Returns the owning target of this task. - * - * @return object The target object that owns this task - * @access public - */ - function getOwningTarget() { - return $this->target; - } - - /** - * Returns the name of task, used only for log messages - * - * @return string Name of this task - * @access public - */ - function getTaskName() { - if ($this->taskName === null) { - // if no task name is set, then it's possible - // this task was created from within another task. We don't - // therefore know the XML tag name for this task, so we'll just - // use the class name stripped of "task" suffix. This is only - // for log messages, so we don't have to worry much about accuracy. - return preg_replace('/task$/i', '', get_class($this)); - } - return $this->taskName; - } - - /** - * Sets the name of this task for log messages - * - * @return string A string representing the name of this task for log - * @access public - */ - function setTaskName($name) { - $this->taskName = (string) $name; - } - - /** - * Returns the name of the task under which it was invoked, - * usually the XML tagname - * - * @return string The type of this task (XML Tag) - */ - function getTaskType() { - return $this->taskType; - } - - /** - * Sets the type of the task. Usually this is the name of the XML tag - * - * @param string The type of this task (XML Tag) - */ - function setTaskType($name) { - $this->taskType = (string) $name; - } - - /** - * Returns a name - * - */ - protected function getRegisterSlot($slotName) { - return Register::getSlot('task.' . $this->getTaskName() . '.' . $slotName); - } - - /** - * Provides a project level log event to the task. - * - * @param string The message to log - * @param integer The priority of the message - * @see BuildEvent - * @see BuildListener - */ - function log($msg, $level = PROJECT_MSG_INFO) { - $this->project->logObject($this, $msg, $level); - } - - /** - * Sets a textual description of the task - * - * @param string The text describing the task - */ - public function setDescription($desc) { - $this->description = $desc; - } - - /** - * Returns the textual description of the task - * - * @return string The text description of the task - */ - public function getDescription() { - return $this->description; - } - - /** - * Called by the parser to let the task initialize properly. - * Should throw a BuildException if something goes wrong with the build - * - * This is abstract here, but may not be overloaded by subclasses. - * - * @throws BuildException - */ - public function init() { - } - - /** - * Called by the project to let the task do it's work. This method may be - * called more than once, if the task is invoked more than once. For - * example, if target1 and target2 both depend on target3, then running - * phing target1 target2 will run all tasks in target3 twice. - * - * Should throw a BuildException if someting goes wrong with the build - * - * This is abstract here. Must be overloaded by real tasks. - * - * @access public - */ - abstract function main(); - - /** - * Returns the location within the buildfile this task occurs. Used - * by {@link BuildException} to give detailed error messages. - * - * @return Location The location object describing the position of this - * task within the buildfile. - */ - function getLocation() { - return $this->location; - } - - /** - * Sets the location within the buildfile this task occurs. Called by - * the parser to set location information. - * - * @return object The location object describing the position of this - * task within the buildfile. - * @access public - */ - function setLocation(Location $location) { - $this->location = $location; - } - - /** - * Returns the wrapper object for runtime configuration - * - * @return object The wrapper object used by this task - * @access public - */ - function getRuntimeConfigurableWrapper() { - if ($this->wrapper === null) { - $this->wrapper = new RuntimeConfigurable($this, $this->getTaskName()); - } - return $this->wrapper; - } - - /** - * Sets the wrapper object this task should use for runtime - * configurable elements. - * - * @param object The wrapper object this task should use - * @access public - */ - function setRuntimeConfigurableWrapper(RuntimeConfigurable $wrapper) { - $this->wrapper = $wrapper; - } - - /** - * Configure this task if it hasn't been done already. - * - * @access public - */ - function maybeConfigure() { - if ($this->wrapper !== null) { - $this->wrapper->maybeConfigure($this->project); - } - } - - /** - * Perfrom this task - * - * @access public - */ - function perform() { - - try { // try executing task - $this->project->fireTaskStarted($this); - $this->maybeConfigure(); - $this->main(); - $this->project->fireTaskFinished($this, $null=null); - } catch (Exception $exc) { - if ($exc instanceof BuildException) { - if ($exc->getLocation() === null) { - $exc->setLocation($this->getLocation()); - } - } - $this->project->fireTaskFinished($this, $exc); - throw $exc; - } - } -} diff --git a/buildscripts/phing/classes/phing/TaskAdapter.php b/buildscripts/phing/classes/phing/TaskAdapter.php deleted file mode 100644 index 8b84b768..00000000 --- a/buildscripts/phing/classes/phing/TaskAdapter.php +++ /dev/null @@ -1,84 +0,0 @@ -. - */ - -require_once 'phing/Task.php'; - -/** - * Use introspection to "adapt" an arbitrary ( not extending Task, but with - * similar patterns). - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.7 $ - * @package phing - */ -class TaskAdapter extends Task { - - /** target object */ - private $proxy; - - /** - * Main entry point. - * @return void - */ - function main() { - - if (method_exists($this->proxy, "setProject")) { - try { // try to set project - $this->proxy->setProject($this->project); - } catch (Exception $ex) { - $this->log("Error setting project in " . get_class($this->proxy) . PROJECT_MSG_ERR); - throw new BuildException($ex); - } - } else { - throw new Exception("Error setting project in class " . get_class($this->proxy)); - } - - if (method_exists($this->proxy, "main")) { - try { //try to call main - $this->proxy->main($this->project); - } catch (Exception $ex) { - $this->log("Error in " . get_class($this->proxy), PROJECT_MSG_ERR); - throw new BuildException($ex->getMessage()); - } - } else { - throw new BuildException("Your task-like class '" . get_class($this->proxy) ."' does not have a main() method"); - } - } - - /** - * Set the target object. - * @param object $o - * @return void - */ - function setProxy($o) { - $this->proxy = $o; - } - - /** - * Gets the target object. - * @return object - */ - function getProxy() { - return $this->proxy; - } - -} diff --git a/buildscripts/phing/classes/phing/TaskContainer.php b/buildscripts/phing/classes/phing/TaskContainer.php deleted file mode 100644 index 2e9eb67a..00000000 --- a/buildscripts/phing/classes/phing/TaskContainer.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - -/** - * Abstract interface for objects which can contain tasks (targets) - * Used to check if a class can contain tasks (via instanceof) - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.5 $ $Date: 2005/10/04 19:13:44 $ - * @access public - * @package phing - */ -interface TaskContainer { - - /** - * Adds a task to this task container. Must be implemented - * by derived class - * - * @param object The task to be added to the container - * @access public - */ - function addTask(Task $task); -} diff --git a/buildscripts/phing/classes/phing/UnknownElement.php b/buildscripts/phing/classes/phing/UnknownElement.php deleted file mode 100644 index 745130dc..00000000 --- a/buildscripts/phing/classes/phing/UnknownElement.php +++ /dev/null @@ -1,211 +0,0 @@ -. - */ - -require_once 'phing/Task.php'; - -/** - * Wrapper class that holds all information necessary to create a task - * that did not exist when Phing started. - * - * This has something to do with phing encountering an task XML element - * it is not aware of at start time. This is a situation where special steps - * need to be taken so that the element is then known. - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.9 $ - * @package phing - */ -class UnknownElement extends Task { - - private $elementName; - private $realThing; - private $children = array(); - - /** - * Constructs a UnknownElement object - * - * @param string The XML element name that is unknown - * @access public - */ - function __construct($elementName) { - $this->elementName = (string) $elementName; - } - - /** - * Return the XML element name that this UnnownElement - * handles. - * - * @return string The XML element name that is unknown - */ - public function getTag() { - return (string) $this->elementName; - } - - /** - * Tries to configure the unknown element - * - * @throws BuildException if the element can not be configured - */ - public function maybeConfigure() { - - $this->realThing = $this->makeObject($this, $this->wrapper); - $this->wrapper->setProxy($this->realThing); - if ($this->realThing instanceof Task) { - $this->realThing->setRuntimeConfigurableWrapper($this->wrapper); - } - - $this->handleChildren($this->realThing, $this->wrapper); - $this->wrapper->maybeConfigure($this->getProject()); - - } - - /** - * Called when the real task has been configured for the first time. - * - * @throws BuildException if the task can not be created - */ - public function main() { - - if ($this->realThing === null) { - // plain impossible to get here, maybeConfigure should - // have thrown an exception. - throw new BuildException("Should not be executing UnknownElement::main() -- task/type: {$this->elementName}"); - } - - if ($this->realThing instanceof Task) { - $this->realThing->main(); - } - - } - - /** - * Add a child element to the unknown element - * - * @param object The object representing the child element - */ - public function addChild(UnknownElement $child) { - $this->children[] = $child; - } - - /** - * Handle child elemets of the unknown element, if any. - * - * @param ProjectComponent The parent object the unkown element belongs to - * @param object The parent wrapper object - */ - function handleChildren(ProjectComponent $parent, $parentWrapper) { - - if ($parent instanceof TaskAdapter) { - $parent = $parent->getProxy(); - } - - $parentClass = get_class($parent); - $ih = IntrospectionHelper::getHelper($parentClass); - - for ($i=0, $childrenCount=count($this->children); $i < $childrenCount; $i++) { - - $childWrapper = $parentWrapper->getChild($i); - $child = $this->children[$i]; - $realChild = null; - if ($parent instanceof TaskContainer) { - $realChild = $this->makeTask($child, $childWrapper, false); - $parent->addTask($realChild); - } else { - $realChild = $ih->createElement($this->project, $parent, $child->getTag()); - } - - $childWrapper->setProxy($realChild); - if ($realChild instanceof Task) { - $realChild->setRuntimeConfigurableWrapper($childWrapper); - } - - $child->handleChildren($realChild, $childWrapper); - if ($realChild instanceof Task) { - $realChild->maybeConfigure(); - } - } - } - - /** - * Creates a named task or data type. If the real object is a task, - * it is configured up to the init() stage. - * - * @param UnknownElement $ue The unknown element to create the real object for. - * Must not be null. - * @param RuntimeConfigurable $w Ignored in this implementation. - * @return object The Task or DataType represented by the given unknown element. - */ - protected function makeObject(UnknownElement $ue, RuntimeConfigurable $w) { - $o = $this->makeTask($ue, $w, true); - if ($o === null) { - $o = $this->project->createDataType($ue->getTag()); - } - if ($o === null) { - throw new BuildException("Could not create task/type: '".$ue->getTag()."'. Make sure that this class has been declared using taskdef / typedef."); - } - return $o; - } - - /** - * Create a named task and configure it up to the init() stage. - * - * @param UnknownElement $ue The unknwon element to create a task from - * @param RuntimeConfigurable $w The wrapper object - * @param boolean $onTopLevel Whether to treat this task as if it is top-level. - * @return Task The freshly created task - */ - protected function makeTask(UnknownElement $ue, RuntimeConfigurable $w, $onTopLevel = false) { - - $task = $this->project->createTask($ue->getTag()); - - if ($task === null) { - if (!$onTopLevel) { - throw new BuildException("Could not create task of type: '".$this->elementName."'. Make sure that this class has been declared using taskdef."); - } - return null; - } - - // used to set the location within the xmlfile so that exceptions can - // give detailed messages - - $task->setLocation($this->getLocation()); - $attrs = $w->getAttributes(); - if (isset($attrs['id'])) { - $this->project->addReference($attrs['id'], $task); - } - - // UnknownElement always has an associated target - $task->setOwningTarget($this->target); - - $task->init(); - return $task; - } - - /** - * Get the name of the task to use in logging messages. - * - * @return string The task's name - */ - function getTaskName() { - return $this->realThing === null ? parent::getTaskName() : $this->realThing->getTaskName(); - } -} diff --git a/buildscripts/phing/classes/phing/filters/BaseFilterReader.php b/buildscripts/phing/classes/phing/filters/BaseFilterReader.php deleted file mode 100644 index c9f8c619..00000000 --- a/buildscripts/phing/classes/phing/filters/BaseFilterReader.php +++ /dev/null @@ -1,157 +0,0 @@ -. -*/ - -include_once 'phing/system/io/FilterReader.php'; -include_once 'phing/system/io/StringReader.php'; - - -/** - * Base class for core filter readers. - * - * @author Yannick Lecaillez - * @version $Revision: 1.8 $ $Date: 2004/05/20 02:24:10 $ - * @access public - * @see FilterReader - * @package phing.filters - */ -class BaseFilterReader extends FilterReader { - - /** Have the parameters passed been interpreted? */ - protected $initialized = false; - - /** The Phing project this filter is part of. */ - protected $project = null; - - /** - * Constructor used by Phing's introspection mechanism. - * The original filter reader is only used for chaining - * purposes, never for filtering purposes (and indeed - * it would be useless for filtering purposes, as it has - * no real data to filter). ChainedReaderHelper uses - * this placeholder instance to create a chain of real filters. - * - * @param Reader $in - */ - function __construct($in = null) { - if ($in === null) { - $dummy = ""; - $in = new StringReader($dummy); - } - parent::__construct($in); - } - - /** - * Returns the initialized status. - * - * @return boolean whether or not the filter is initialized - */ - function getInitialized() { - return $this->initialized; - } - - /** - * Sets the initialized status. - * - * @param boolean $initialized Whether or not the filter is initialized. - */ - function setInitialized($initialized) { - $this->initialized = (boolean) $initialized; - } - - /** - * Sets the project to work with. - * - * @param object $project The project this filter is part of. - * Should not be null. - */ - function setProject(Project $project) { - // type check, error must never occur, bad code of it does - $this->project = $project; - } - - /** - * Returns the project this filter is part of. - * - * @return object The project this filter is part of - */ - function getProject() { - return $this->project; - } - - /** - * Reads characters. - * - * @param off Offset at which to start storing characters. - * @param len Maximum number of characters to read. - * - * @return Characters read, or -1 if the end of the stream - * has been reached - * - * @throws IOException If an I/O error occurs - */ - function read($len = null) { - return $this->in->read($len); - } - - /** - * Reads a line of text ending with '\n' (or until the end of the stream). - * The returned String retains the '\n'. - * - * @return the line read, or null if the end of the - stream has already been reached - * - * @throws IOException if the underlying reader throws one during - * reading - */ - function readLine() { - $line = null; - - while ( ($ch = $this->in->read(1)) !== -1 ) { - $line .= $ch; - if ( $ch === "\n" ) - break; - } - - return $line; - } - - /** - * Returns whether the end of file has been reached with input stream. - * @return boolean - */ - function eof() { - return $this->in->eof(); - } - - /** - * Convenience method to support logging in filters. - * @param string $msg Message to log. - * @param int $level Priority level. - */ - function log($msg, $level = PROJECT_MSG_INFO) { - if ($this->project !== null) { - $this->project->log("[filter:".get_class($this)."] ".$msg, $level); - } - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/BaseParamFilterReader.php b/buildscripts/phing/classes/phing/filters/BaseParamFilterReader.php deleted file mode 100644 index 3d767b40..00000000 --- a/buildscripts/phing/classes/phing/filters/BaseParamFilterReader.php +++ /dev/null @@ -1,69 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseFilterReader.php'; -include_once 'phing/types/Parameterizable.php'; -include_once 'phing/types/Parameter.php'; - -/** - * Base class for core filter readers. - * - * @author Yannick Lecaillez - * @copyright © 2003 seasonfive. All rights reserved - * @version $Revision: 1.5 $ $Date: 2005/02/27 20:52:08 $ - * @access public - * @see FilterReader - * @package phing.filters - */ -class BaseParamFilterReader extends BaseFilterReader implements Parameterizable { - - /** The passed in parameter array. */ - protected $_parameters = array(); - - /* - * Sets the parameters used by this filter, and sets - * the filter to an uninitialized status. - * - * @param array Array of parameters to be used by this filter. - * Should not be null. - */ - function setParameters($parameters) { - // type check, error must never occur, bad code of it does - if ( !is_array($parameters) ) { - throw new Exception("Expected parameters array got something else"); - } - - $this->_parameters = $parameters; - $this->setInitialized(false); - } - - /* - * Returns the parameters to be used by this filter. - * - * @return the parameters to be used by this filter - */ - function &getParameters() { - return $this->_parameters; - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/ChainableReader.php b/buildscripts/phing/classes/phing/filters/ChainableReader.php deleted file mode 100644 index c7de07c4..00000000 --- a/buildscripts/phing/classes/phing/filters/ChainableReader.php +++ /dev/null @@ -1,42 +0,0 @@ -. -*/ - -/** - * Interface indicating that a reader may be chained to another one. - * - * @author Magesh Umasankar - */ -interface ChainableReader { - - /** - * Returns a reader with the same configuration as this one, - * but filtering input from the specified reader. - * - * @param Reader $rdr the reader which the returned reader should be filtering - * - * @return Reader A reader with the same configuration as this one, but - * filtering input from the specified reader - */ - public function chain(Reader $rdr); -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/ExpandProperties.php b/buildscripts/phing/classes/phing/filters/ExpandProperties.php deleted file mode 100644 index dfd98cc8..00000000 --- a/buildscripts/phing/classes/phing/filters/ExpandProperties.php +++ /dev/null @@ -1,82 +0,0 @@ -. -*/ - -require_once 'phing/filters/BaseFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * Expands Phing Properties, if any, in the data. - *

- * Example:
- *

- * Or: - *
.
-*/
-
-include_once 'phing/filters/BaseParamFilterReader.php';
-include_once 'phing/filters/ChainableReader.php';
-
-/**
- * Reads the first n lines of a stream.
- * (Default is first 10 lines.)
- * 

- * Example: - *

- * Or: - *

- *    
- * 
- * - * @author Yannick Lecaillez - * @author hans lellelid, hans@velum.net - * @version $Revision: 1.6 $ $Date: 2004/03/15 14:45:06 $ - * @access public - * @see FilterReader - * @package phing.filters - */ -class HeadFilter extends BaseParamFilterReader implements ChainableReader { - - /** - * Parameter name for the number of lines to be returned. - */ - const LINES_KEY = "lines"; - - /** - * Number of lines currently read in. - * @var integer - */ - private $_linesRead = 0; - - /** - * Number of lines to be returned in the filtered stream. - * @var integer - */ - private $_lines = 10; - - /** - * Returns first n lines of stream. - * @return the resulting stream, or -1 - * if the end of the resulting stream has been reached - * - * @exception IOException if the underlying stream throws an IOException - * during reading - */ - function read($len = null) { - - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - // note, if buffer contains fewer lines than - // $this->_lines this code will not work. - - if($this->_linesRead < $this->_lines) { - - $buffer = $this->in->read($len); - - if($buffer === -1) { - return -1; - } - - // now grab first X lines from buffer - - $lines = explode("\n", $buffer); - - $linesCount = count($lines); - - // must account for possibility that the num lines requested could - // involve more than one buffer read. - $len = ($linesCount > $this->_lines ? $this->_lines - $this->_linesRead : $linesCount); - $filtered_buffer = implode("\n", array_slice($lines, 0, $len) ); - $this->_linesRead += $len; - - return $filtered_buffer; - - } - - return -1; // EOF, since the file is "finished" as far as subsequent filters are concerned. - } - - /** - * Sets the number of lines to be returned in the filtered stream. - * - * @param integer $lines the number of lines to be returned in the filtered stream. - */ - function setLines($lines) { - $this->_lines = (int) $lines; - } - - /** - * Returns the number of lines to be returned in the filtered stream. - * - * @return integer The number of lines to be returned in the filtered stream. - */ - function getLines() { - return $this->_lines; - } - - /** - * Creates a new HeadFilter using the passed in - * Reader for instantiation. - * - * @param object A Reader object providing the underlying stream. - * Must not be null. - * - * @return object A new filter based on this configuration, but filtering - * the specified reader. - */ - function chain(Reader $reader) { - $newFilter = new HeadFilter($reader); - $newFilter->setLines($this->getLines()); - $newFilter->setInitialized(true); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /** - * Scans the parameters list for the "lines" parameter and uses - * it to set the number of lines to be returned in the filtered stream. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - for($i = 0, $_i=count($params) ; $i < $_i; $i++) { - if ( self::LINES_KEY == $params[$i]->getName() ) { - $this->_lines = (int) $params[$i]->getValue(); - break; - } - } - } - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/LineContains.php b/buildscripts/phing/classes/phing/filters/LineContains.php deleted file mode 100644 index 8f3136b7..00000000 --- a/buildscripts/phing/classes/phing/filters/LineContains.php +++ /dev/null @@ -1,258 +0,0 @@ -. - */ - -include_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/filters/BaseFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * Filter which includes only those lines that contain all the user-specified - * strings. - * - * Example: - * - *

- *   
- *   
- * 
- * - * Or: - * - *

- *    
- *    
- * 
- * - * This will include only those lines that contain foo and - * bar. - * - * @author Yannick Lecaillez - * @author Hans Lellelid - * @version $Revision: 1.11 $ - * @see PhingFilterReader - * @package phing.filters -*/ -class LineContains extends BaseParamFilterReader implements ChainableReader { - - /** - * The parameter name for the string to match on. - * @var string - */ - const CONTAINS_KEY = "contains"; - - /** - * Array of Contains objects. - * @var array - */ - private $_contains = array(); - - /** - * [Deprecated] - * @var string - */ - private $_line = null; - - /** - * Returns all lines in a buffer that contain specified strings. - * @return mixed buffer, -1 on EOF - */ - function read($len = null) { - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - $buffer = $this->in->read($len); - - if ($buffer === -1) { - return -1; - } - - $lines = explode("\n", $buffer); - $matched = array(); - $containsSize = count($this->_contains); - - foreach($lines as $line) { - for($i = 0 ; $i < $containsSize ; $i++) { - $containsStr = $this->_contains[$i]->getValue(); - if ( strstr($line, $containsStr) === false ) { - $line = null; - break; - } - } - if($line !== null) { - $matched[] = $line; - } - } - $filtered_buffer = implode("\n", $matched); - return $filtered_buffer; - } - - /** - * [Deprecated. For reference only, used to be read() method.] - * Returns the next character in the filtered stream, only including - * lines from the original stream which contain all of the specified words. - * - * @return the next character in the resulting stream, or -1 - * if the end of the resulting stream has been reached - * - * @exception IOException if the underlying stream throws an IOException - * during reading - */ - function readChar() { - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - $ch = -1; - - if ( $this->_line !== null ) { - $ch = substr($this->_line, 0, 1); - if ( strlen($this->_line) === 1 ) - $this->_line = null; - else - $this->_line = substr($this->_line, 1); - } else { - $this->_line = $this->readLine(); - if ( $this->_line === null ) { - $ch = -1; - } else { - $containsSize = count($this->_contains); - for($i = 0 ; $i < $containsSize ; $i++) { - $containsStr = $this->_contains[$i]->getValue(); - if ( strstr($this->_line, $containsStr) === false ) { - $this->_line = null; - break; - } - } - return $this->readChar(); - } - } - - return $ch; - } - - /** - * Adds a nested element. - * - * @return Contains The contains element added. - * Must not be null. - */ - function createContains() { - $num = array_push($this->_contains, new Contains()); - return $this->_contains[$num-1]; - } - - /** - * Sets the array of words which must be contained within a line read - * from the original stream in order for it to match this filter. - * - * @param array $contains An array of words which must be contained - * within a line in order for it to match in this filter. - * Must not be null. - */ - function setContains($contains) { - // type check, error must never occur, bad code of it does - if ( !is_array($contains) ) { - throw new Exception("Excpected array got something else"); - } - - $this->_contains = $contains; - } - - /** - * Returns the vector of words which must be contained within a line read - * from the original stream in order for it to match this filter. - * - * @return array The array of words which must be contained within a line read - * from the original stream in order for it to match this filter. The - * returned object is "live" - in other words, changes made to the - * returned object are mirrored in the filter. - */ - function getContains() { - return $this->_contains; - } - - /** - * Creates a new LineContains using the passed in - * Reader for instantiation. - * - * @param object A Reader object providing the underlying stream. - * Must not be null. - * - * @return object A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new LineContains($reader); - $newFilter->setContains($this->getContains()); - $newFilter->setInitialized(true); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /** - * Parses the parameters to add user-defined contains strings. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - foreach($params as $param) { - if ( self::CONTAINS_KEY == $param->getType() ) { - $cont = new Contains(); - $cont->setValue($param->getValue()); - array_push($this->_contains, $cont); - break; // because we only support a single contains - } - } - } - } -} - -/** - * Holds a contains element. - */ -class Contains { - - /** - * @var string - */ - private $_value; - - /** - * Set 'contains' value. - * @param string $contains - */ - function setValue($contains) { - $this->_value = (string) $contains; - } - - /** - * Returns 'contains' value. - * @return string - */ - function getValue() { - return $this->_value; - } -} -?> diff --git a/buildscripts/phing/classes/phing/filters/LineContainsRegexp.php b/buildscripts/phing/classes/phing/filters/LineContainsRegexp.php deleted file mode 100644 index dcbb532c..00000000 --- a/buildscripts/phing/classes/phing/filters/LineContainsRegexp.php +++ /dev/null @@ -1,179 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/types/RegularExpression.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * Filter which includes only those lines that contain the user-specified - * regular expression matching strings. - * - * Example: - *

- *   
- * 
- * - * Or: - * - *

- *    
- * 
- * - * This will fetch all those lines that contain the pattern foo - * - * @author Yannick Lecaillez - * @author Hans Lellelid - * @version $Revision: 1.8 $ - * @see FilterReader - * @package phing.filters - */ -class LineContainsRegexp extends BaseParamFilterReader implements ChainableReader { - - /** - * Parameter name for regular expression. - * @var string - */ - const REGEXP_KEY = "regexp"; - - /** - * Regular expressions that are applied against lines. - * @var array - */ - private $_regexps = array(); - - /** - * Returns all lines in a buffer that contain specified strings. - * @return mixed buffer, -1 on EOF - */ - function read($len = null) { - - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - $buffer = $this->in->read($len); - - if ($buffer === -1) { - return -1; - } - - $lines = explode("\n", $buffer); - $matched = array(); - - $regexpsSize = count($this->_regexps); - foreach($lines as $line) { - for($i = 0 ; $i<$regexpsSize ; $i++) { - $regexp = $this->_regexps[$i]; - $re = $regexp->getRegexp($this->getProject()); - $matches = $re->matches($line); - if ( !$matches ) { - $line = null; - break; - } - } - if($line !== null) { - $matched[] = $line; - } - } - $filtered_buffer = implode("\n", $matched); - return $filtered_buffer; - } - - /** - * Adds a regexp element. - * - * @return object regExp The regexp element added. - */ - function createRegexp() { - $num = array_push($this->_regexps, new RegularExpression()); - return $this->_regexps[$num-1]; - } - - /** - * Sets the vector of regular expressions which must be contained within - * a line read from the original stream in order for it to match this - * filter. - * - * @param regexps An array of regular expressions which must be contained - * within a line in order for it to match in this filter. Must not be - * null. - */ - function setRegexps($regexps) { - // type check, error must never occur, bad code of it does - if ( !is_array($regexps) ) { - throw new Exception("Excpected an 'array', got something else"); - } - $this->_regexps = $regexps; - } - - /** - * Returns the array of regular expressions which must be contained within - * a line read from the original stream in order for it to match this - * filter. - * - * @return array The array of regular expressions which must be contained within - * a line read from the original stream in order for it to match this - * filter. The returned object is "live" - in other words, changes made to - * the returned object are mirrored in the filter. - */ - function getRegexps() { - return $this->_regexps; - } - - /** - * Creates a new LineContainsRegExp using the passed in - * Reader for instantiation. - * - * @param object A Reader object providing the underlying stream. - * Must not be null. - * - * @return object A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new LineContainsRegExp($reader); - $newFilter->setRegexps($this->getRegexps()); - $newFilter->setInitialized(true); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /** - * Parses parameters to add user defined regular expressions. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - for($i = 0 ; $igetType() ) { - $pattern = $params[$i]->getValue(); - $regexp = new RegularExpression(); - $regexp->setPattern($pattern); - array_push($this->_regexps, $regexp); - } - } - } - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/PrefixLines.php b/buildscripts/phing/classes/phing/filters/PrefixLines.php deleted file mode 100644 index a5580f87..00000000 --- a/buildscripts/phing/classes/phing/filters/PrefixLines.php +++ /dev/null @@ -1,142 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * Attaches a prefix to every line. - * - * Example: - *
- * - * Or: - * - *

- *  
- * 
- * - * @author Yannick Lecaillez - * @author hans lellelid, hans@velum.net - * @version $Revision: 1.6 $ $Date: 2004/03/15 14:45:06 $ - * @access public - * @see FilterReader - * @package phing.filters -*/ -class PrefixLines extends BaseParamFilterReader implements ChainableReader { - - /** - * Parameter name for the prefix. - * @var string - */ - const PREFIX_KEY = "lines"; - - /** - * The prefix to be used. - * @var string - */ - private $_prefix = null; - - /** - * Adds a prefix to each line of input stream and returns resulting stream. - * - * @return mixed buffer, -1 on EOF - */ - function read($len = null) { - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - $buffer = $this->in->read($len); - - if ($buffer === -1) { - return -1; - } - - $lines = explode("\n", $buffer); - $filtered = array(); - - foreach($lines as $line) { - $line = $this->_prefix . $line; - $filtered[] = $line; - } - - $filtered_buffer = implode("\n", $filtered); - return $filtered_buffer; - } - - /** - * Sets the prefix to add at the start of each input line. - * - * @param string $prefix The prefix to add at the start of each input line. - * May be null, in which case no prefix - * is added. - */ - function setPrefix($prefix) { - $this->_prefix = (string) $prefix; - } - - /** - * Returns the prefix which will be added at the start of each input line. - * - * @return string The prefix which will be added at the start of each input line - */ - function getPrefix() { - return $this->_prefix; - } - - /** - * Creates a new PrefixLines filter using the passed in - * Reader for instantiation. - * - * @param object A Reader object providing the underlying stream. - * Must not be null. - * - * @return object A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new PrefixLines($reader); - $newFilter->setPrefix($this->getPrefix()); - $newFilter->setInitialized(true); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /** - * Initializes the prefix if it is available from the parameters. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - for($i = 0, $_i=count($params) ; $i < $_i ; $i++) { - if ( self::PREFIX_KEY == $params[$i]->getName() ) { - $this->_prefix = (string) $params[$i]->getValue(); - break; - } - } - } - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/ReplaceRegexp.php b/buildscripts/phing/classes/phing/filters/ReplaceRegexp.php deleted file mode 100644 index 3c5592e8..00000000 --- a/buildscripts/phing/classes/phing/filters/ReplaceRegexp.php +++ /dev/null @@ -1,129 +0,0 @@ -. -*/ - -require_once 'phing/filters/BaseFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; -include_once 'phing/types/RegularExpression.php'; - -/** - * Performs a regexp find/replace on stream. - *

- * Example:
- *

- * 
- *    
- *    
- * 
- * 
- * - * @author Hans Lellelid - * @version $Revision: 1.5 $ - * @package phing.filters - */ -class ReplaceRegexp extends BaseFilterReader implements ChainableReader { - - /** - * @var array RegularExpression[] - */ - private $regexps = array(); - - /** - * Creator method handles nested tags. - * @return RegularExpression - */ - function createRegexp() { - $num = array_push($this->regexps, new RegularExpression()); - return $this->regexps[$num-1]; - } - - /** - * Sets the current regexps. - * (Used when, e.g., cloning/chaining the method.) - * @param array RegularExpression[] - */ - function setRegexps($regexps) { - $this->regexps = $regexps; - } - - /** - * Gets the current regexps. - * (Used when, e.g., cloning/chaining the method.) - * @return array RegularExpression[] - */ - function getRegexps() { - return $this->regexps; - } - - /** - * Returns the filtered stream. - * The original stream is first read in fully, and the regex replace is performed. - * - * @param int $len Required $len for Reader compliance. - * - * @return mixed The filtered stream, or -1 if the end of the resulting stream has been reached. - * - * @exception IOException if the underlying stream throws an IOException - * during reading - */ - function read($len = null) { - - $buffer = $this->in->read($len); - - if($buffer === -1) { - return -1; - } - - // perform regex replace here ... - foreach($this->regexps as $exptype) { - $regexp = $exptype->getRegexp($this->project); - try { - $buffer = $regexp->replace($buffer); - $this->log("Performing regexp replace: /".$regexp->getPattern()."/".$regexp->getReplace()."/g".($regexp->getIgnoreCase() ? 'i' : ''), PROJECT_MSG_VERBOSE); - } catch (Exception $e) { - // perhaps mismatch in params (e.g. no replace or pattern specified) - $this->log("Error performing regexp replace: " . $e->getMessage(), PROJECT_MSG_WARN); - } - } - - return $buffer; - } - - /** - * Creates a new ReplaceRegExp filter using the passed in - * Reader for instantiation. - * - * @param Reader $reader A Reader object providing the underlying stream. - * Must not be null. - * - * @return ReplaceRegExp A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new ReplaceRegExp($reader); - $newFilter->setProject($this->getProject()); - $newFilter->setRegexps($this->getRegexps()); - return $newFilter; - } - -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/ReplaceTokens.php b/buildscripts/phing/classes/phing/filters/ReplaceTokens.php deleted file mode 100644 index 999f734f..00000000 --- a/buildscripts/phing/classes/phing/filters/ReplaceTokens.php +++ /dev/null @@ -1,415 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/types/TokenSource.php'; -include_once 'phing/filters/ChainableReader.php'; - -/* - * Replaces tokens in the original input with user-supplied values. - * - * Example: - * - *
;
- *   
- * 
- * - * Or: - * - *

- *   
- *   
- *   
- * 
- * - * @author Yannick Lecaillez - * @author hans lellelid, hans@velum.net - * @version $Revision: 1.14 $ $Date: 2005/06/16 15:09:10 $ - * @access public - * @see BaseParamFilterReader - * @package phing.filters - */ -class ReplaceTokens extends BaseParamFilterReader implements ChainableReader { - - /** - * Default "begin token" character. - * @var string - */ - const DEFAULT_BEGIN_TOKEN = "@"; - - /** - * Default "end token" character. - * @var string - */ - const DEFAULT_END_TOKEN = "@"; - - /** - * [Deprecated] Data that must be read from, if not null. - * @var string - */ - private $_queuedData = null; - - /** - * Array to hold the replacee-replacer pairs (String to String). - * @var array - */ - private $_tokens = array(); - - /** - * Array to hold the token sources that make tokens from - * different sources available - * @var array - */ - private $_tokensources = array(); - - /** - * Array holding all tokens given directly to the Filter and - * those passed via a TokenSource. - * @var array - */ - private $_alltokens = null; - - /** - * Character marking the beginning of a token. - * @var string - */ - private $_beginToken = "@"; // self::DEFAULT_BEGIN_TOKEN; - - /** - * Character marking the end of a token. - * @var string - */ - private $_endToken = "@"; //self::DEFAULT_END_TOKEN; - - /** - * Performs lookup on key and returns appropriate replacement string. - * @param array $matches Array of 1 el containing key to search for. - * @return string Text with which to replace key or value of key if none is found. - * @access private - */ - private function replaceTokenCallback($matches) { - - $key = $matches[1]; - - /* Get tokens from tokensource and merge them with the - * tokens given directly via build file. This should be - * done a bit more elegantly - */ - if ($this->_alltokens === null) { - $this->_alltokens = array(); - - $count = count($this->_tokensources); - for ($i = 0; $i < $count; $i++) { - $source = $this->_tokensources[$i]; - $this->_alltokens = array_merge($this->_alltokens, $source->getTokens()); - } - - - $this->_alltokens = array_merge($this->_tokens, $this->_alltokens); - } - - $tokens = $this->_alltokens; - - $replaceWith = null; - $count = count($tokens); - - for ($i = 0; $i < $count; $i++) { - if ($tokens[$i]->getKey() === $key) { - $replaceWith = $tokens[$i]->getValue(); - } - } - - if ($replaceWith === null) { - $replaceWith = $this->_beginToken . $key . $this->_endToken; - $this->log("No token defined for key \"".$this->_beginToken . $key . $this->_endToken."\""); - } else { - $this->log("Replaced \"".$this->_beginToken . $key . $this->_endToken ."\" with \"".$replaceWith."\""); - } - - return $replaceWith; - } - - /** - * Returns stream with tokens having been replaced with appropriate values. - * If a replacement value is not found for a token, the token is left in the stream. - * - * @return mixed filtered stream, -1 on EOF. - */ - function read($len = null) { - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - // read from next filter up the chain - $buffer = $this->in->read($len); - - if($buffer === -1) { - return -1; - } - - // filter buffer - $buffer = preg_replace_callback( - "/".preg_quote($this->_beginToken)."([\w\.\-:]+?)".preg_quote($this->_endToken)."/", - array($this, 'replaceTokenCallback'), $buffer); - - return $buffer; - } - - /** - * Sets the "begin token" character. - * - * @param string $beginToken the character used to denote the beginning of a token. - */ - function setBeginToken($beginToken) { - $this->_beginToken = (string) $beginToken; - } - - /** - * Returns the "begin token" character. - * - * @return string The character used to denote the beginning of a token. - */ - function getBeginToken() { - return $this->_beginToken; - } - - /** - * Sets the "end token" character. - * - * @param string $endToken the character used to denote the end of a token - */ - function setEndToken($endToken) { - $this->_endToken = (string) $endToken; - } - - /** - * Returns the "end token" character. - * - * @return the character used to denote the beginning of a token - */ - function getEndToken() { - return $this->_endToken; - } - - /** - * Adds a token element to the map of tokens to replace. - * - * @return object The token added to the map of replacements. - * Must not be null. - */ - function createToken() { - $num = array_push($this->_tokens, new Token()); - return $this->_tokens[$num-1]; - } - - /** - * Adds a token source to the sources of this filter. - * - * @return object A Reference to the source just added. - */ - function createTokensource() { - $num = array_push($this->_tokensources, new TokenSource()); - return $this->_tokensources[$num-1]; - } - - /** - * Sets the map of tokens to replace. - * ; used by ReplaceTokens::chain() - * - * @param array A map (String->String) of token keys to replacement - * values. Must not be null. - */ - function setTokens($tokens) { - // type check, error must never occur, bad code of it does - if ( !is_array($tokens) ) { - throw new Exception("Excpected 'array', got something else"); - } - - $this->_tokens = $tokens; - } - - /** - * Returns the map of tokens which will be replaced. - * ; used by ReplaceTokens::chain() - * - * @return array A map (String->String) of token keys to replacement values. - */ - function getTokens() { - return $this->_tokens; - } - - /** - * Sets the tokensources to use; used by ReplaceTokens::chain() - * - * @param array An array of token sources. - */ - function setTokensources($sources) { - // type check - if ( !is_array($sources)) { - throw new Exception("Exspected 'array', got something else"); - } - $this->_tokensources = $sources; - } - - /** - * Returns the token sources used by this filter; used by ReplaceTokens::chain() - * - * @return array - */ - function getTokensources() { - return $this->_tokensources; - } - - /** - * Creates a new ReplaceTokens using the passed in - * Reader for instantiation. - * - * @param object A Reader object providing the underlying stream. - * Must not be null. - * - * @return object A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new ReplaceTokens($reader); - $newFilter->setProject($this->getProject()); - $newFilter->setBeginToken($this->getBeginToken()); - $newFilter->setEndToken($this->getEndToken()); - $newFilter->setTokens($this->getTokens()); - $newFilter->setTokensources($this->getTokensources()); - $newFilter->setInitialized(true); - return $newFilter; - } - - /** - * Initializes tokens and loads the replacee-replacer hashtable. - * This method is only called when this filter is used through - * a tag in build file. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - for($i = 0 ; $igetType(); - if ( $type === "tokenchar" ) { - $name = $params[$i]->getName(); - if ( $name === "begintoken" ) { - $this->_beginToken = substr($params[$i]->getValue(), 0, 1); - } else if ( $name === "endtoken" ) { - $this->_endToken = substr($params[$i]->getValue(), 0, 1); - } - } else if ( $type === "token" ) { - $name = $params[$i]->getName(); - $value = $params[$i]->getValue(); - - $tok = new Token(); - $tok->setKey($name); - $tok->setValue($value); - - array_push($this->_tokens, $tok); - } else if ( $type === "tokensource" ) { - // Store data from nested tags in local array - $arr = array(); $subparams = $params[$i]->getParams(); - $count = count($subparams); - for ($i = 0; $i < $count; $i++) { - $arr[$subparams[$i]->getName()] = $subparams[$i]->getValue(); - } - - // Create TokenSource - $tokensource = new TokenSource(); - if (isset($arr["classname"])) - $tokensource->setClassname($arr["classname"]); - - // Copy other parameters 1:1 to freshly created TokenSource - foreach ($arr as $key => $value) { - if (strtolower($key) === "classname") - continue; - $param = $tokensource->createParam(); - $param->setName($key); - $param->setValue($value); - } - - $this->_tokensources[] = $tokensource; - } - } - } - } - } -} - -/** - * Holds a token. - */ -class Token { - - /** - * Token key. - * @var string - */ - private $_key; - - /** - * Token value. - * @var string - */ - private $_value; - - /** - * Sets the token key. - * - * @param string $key The key for this token. Must not be null. - */ - function setKey($key) { - $this->_key = (string) $key; - } - - /** - * Sets the token value. - * - * @param string $value The value for this token. Must not be null. - */ - function setValue($value) { - $this->_value = (string) $value; - } - - /** - * Returns the key for this token. - * - * @return string The key for this token. - */ - function getKey() { - return $this->_key; - } - - /** - * Returns the value for this token. - * - * @return string The value for this token. - */ - function getValue() { - return $this->_value; - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/StripLineBreaks.php b/buildscripts/phing/classes/phing/filters/StripLineBreaks.php deleted file mode 100644 index c5a06129..00000000 --- a/buildscripts/phing/classes/phing/filters/StripLineBreaks.php +++ /dev/null @@ -1,148 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * Filter to flatten the stream to a single line. - * - * Example: - * - *
- * - * Or: - * - *
- * - * @author Yannick Lecaillez - * @author hans lellelid, hans@velum.net - * @version $Revision: 1.8 $ $Date: 2004/03/15 14:45:06 $ - * @access public - * @see BaseParamFilterReader - * @package phing.filters - */ -class StripLineBreaks extends BaseParamFilterReader implements ChainableReader { - - /** - * Default line-breaking characters. - * @var string - */ - const DEFAULT_LINE_BREAKS = "\r\n"; - - /** - * Parameter name for the line-breaking characters parameter. - * @var string - */ - const LINES_BREAKS_KEY = "linebreaks"; - - /** - * The characters that are recognized as line breaks. - * @var string - */ - private $_lineBreaks = "\r\n"; // self::DEFAULT_LINE_BREAKS; - - /** - * Returns the filtered stream, only including - * characters not in the set of line-breaking characters. - * - * @return mixed the resulting stream, or -1 - * if the end of the resulting stream has been reached. - * - * @exception IOException if the underlying stream throws an IOException - * during reading - */ - function read($len = null) { - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - $buffer = $this->in->read($len); - if($buffer === -1) { - return -1; - } - - $buffer = preg_replace("/[".$this->_lineBreaks."]/", '', $buffer); - - return $buffer; - } - - /** - * Sets the line-breaking characters. - * - * @param string $lineBreaks A String containing all the characters to be - * considered as line-breaking. - */ - function setLineBreaks($lineBreaks) { - $this->_lineBreaks = (string) $lineBreaks; - } - - /** - * Gets the line-breaking characters. - * - * @return string A String containing all the characters that are considered as line-breaking. - */ - function getLineBreaks() { - return $this->_lineBreaks; - } - - /** - * Creates a new StripLineBreaks using the passed in - * Reader for instantiation. - * - * @param object A Reader object providing the underlying stream. - * Must not be null. - * - * @return object A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new StripLineBreaks($reader); - $newFilter->setLineBreaks($this->getLineBreaks()); - $newFilter->setInitialized(true); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /** - * Parses the parameters to set the line-breaking characters. - */ - private function _initialize() { - $userDefinedLineBreaks = null; - $params = $this->getParameters(); - if ( $params !== null ) { - for($i = 0 ; $igetName() ) { - $userDefinedLineBreaks = $params[$i]->getValue(); - break; - } - } - } - - if ( $userDefinedLineBreaks !== null ) { - $this->_lineBreaks = $userDefinedLineBreaks; - } - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/StripLineComments.php b/buildscripts/phing/classes/phing/filters/StripLineComments.php deleted file mode 100644 index 5d97979a..00000000 --- a/buildscripts/phing/classes/phing/filters/StripLineComments.php +++ /dev/null @@ -1,205 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/* - * This filter strips line comments. - * - * Example: - * - *

- *   
- *   
- *   
- *   
- *   
- * 
- * - * Or: - * - *

- *   
- *   
- *   
- *   
- *   
- * 
- * - * @author Yannick Lecaillez - * @author hans lellelid, hans@velum.net - * @version $Revision: 1.8 $ $Date: 2005/02/27 20:52:08 $ - * @access public - * @see BaseParamFilterReader - * @package phing.filters - */ -class StripLineComments extends BaseParamFilterReader implements ChainableReader { - - /** Parameter name for the comment prefix. */ - const COMMENTS_KEY = "comment"; - - /** Array that holds the comment prefixes. */ - private $_comments = array(); - - /** - * Returns stream only including - * lines from the original stream which don't start with any of the - * specified comment prefixes. - * - * @return mixed the resulting stream, or -1 - * if the end of the resulting stream has been reached. - * - * @throws IOException if the underlying stream throws an IOException - * during reading - */ - function read($len = null) { - - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - $buffer = $this->in->read($len); - - if ($buffer === -1) { - return -1; - } - - $lines = explode("\n", $buffer); - $filtered = array(); - - $commentsSize = count($this->_comments); - - foreach($lines as $line) { - for($i = 0; $i < $commentsSize; $i++) { - $comment = $this->_comments[$i]->getValue(); - if ( StringHelper::startsWith($comment, ltrim($line)) ) { - $line = null; - break; - } - } - if ($line !== null) { - $filtered[] = $line; - } - } - - $filtered_buffer = implode("\n", $filtered); - return $filtered_buffer; - } - - /* - * Adds a comment element to the list of prefixes. - * - * @return comment The comment element added to the - * list of comment prefixes to strip. - */ - function createComment() { - $num = array_push($this->_comments, new Comment()); - return $this->_comments[$num-1]; - } - - /* - * Sets the list of comment prefixes to strip. - * - * @param comments A list of strings, each of which is a prefix - * for a comment line. Must not be null. - */ - function setComments($lineBreaks) { - if (!is_array($lineBreaks)) { - throw new Exception("Excpected 'array', got something else"); - } - $this->_comments = $lineBreaks; - } - - /* - * Returns the list of comment prefixes to strip. - * - * @return array The list of comment prefixes to strip. - */ - function getComments() { - return $this->_comments; - } - - /* - * Creates a new StripLineComments using the passed in - * Reader for instantiation. - * - * @param reader A Reader object providing the underlying stream. - * Must not be null. - * - * @return a new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new StripLineComments($reader); - $newFilter->setComments($this->getComments()); - $newFilter->setInitialized(true); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /* - * Parses the parameters to set the comment prefixes. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - for($i = 0 ; $igetType() ) { - $comment = new Comment(); - $comment->setValue($params[$i]->getValue()); - array_push($this->_comments, $comment); - } - } - } - } -} - -/* - * The class that holds a comment representation. -*/ -class Comment { - - /** The prefix for a line comment. */ - private $_value; - - /* - * Sets the prefix for this type of line comment. - * - * @param string $value The prefix for a line comment of this type. - * Must not be null. - */ - function setValue($value) { - $this->_value = (string) $value; - } - - /* - * Returns the prefix for this type of line comment. - * - * @return string The prefix for this type of line comment. - */ - function getValue() { - return $this->_value; - } -} -?> diff --git a/buildscripts/phing/classes/phing/filters/StripPhpComments.php b/buildscripts/phing/classes/phing/filters/StripPhpComments.php deleted file mode 100644 index 9e21eed3..00000000 --- a/buildscripts/phing/classes/phing/filters/StripPhpComments.php +++ /dev/null @@ -1,190 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * This is a Php comment and string stripper reader that filters - * those lexical tokens out for purposes of simple Php parsing. - * (if you have more complex Php parsing needs, use a real lexer). - * Since this class heavily relies on the single char read function, - * you are reccomended to make it work on top of a buffered reader. - * - * @author Yannick Lecaillez - * @author hans lellelid, hans@velum.net - * @version $Revision: 1.6 $ $Date: 2004/07/16 01:36:35 $ - * @access public - * @see FilterReader - * @package phing.filters - * @todo -c use new PHP functions to perform this instead of regex. - */ -class StripPhpComments extends BaseFilterReader implements ChainableReader { - /** - * The read-ahead character, used for effectively pushing a single - * character back. -1 indicates that no character is in the buffer. - */ - private $_readAheadCh = -1; - - /** - * Whether or not the parser is currently in the middle of a string - * literal. - * @var boolean - */ - private $_inString = false; - - /** - * Returns the stream without Php comments. - * - * @return the resulting stream, or -1 - * if the end of the resulting stream has been reached - * - * @throws IOException if the underlying stream throws an IOException - * during reading - */ - function read($len = null) { - - $buffer = $this->in->read($len); - if($buffer === -1) { - return -1; - } - - // This regex replace /* */ and // style comments - $buffer = preg_replace('/\/\*[^*]*\*+([^\/*][^*]*\*+)*\/|\/\/[^\n]*|("(\\\\.|[^"\\\\])*"|\'(\\\\.|[^\'\\\\])*\'|.[^\/"\'\\\\]*)/s', "$2", $buffer); - - // The regex above is not identical to, but is based on the expression below: - // - // created by Jeffrey Friedl - // and later modified by Fred Curtis. - // s{ - // /\* ## Start of /* ... */ comment - // [^*]*\*+ ## Non-* followed by 1-or-more *'s - // ( - // [^/*][^*]*\*+ - // )* ## 0-or-more things which don't start with / - // ## but do end with '*' - // / ## End of /* ... */ comment - // - // | ## OR various things which aren't comments: - // - // ( - // " ## Start of " ... " string - // ( - // \\. ## Escaped char - // | ## OR - // [^"\\] ## Non "\ - // )* - // " ## End of " ... " string - // - // | ## OR - // - // ' ## Start of ' ... ' string - // ( - // \\. ## Escaped char - // | ## OR - // [^'\\] ## Non '\ - // )* - // ' ## End of ' ... ' string - // - // | ## OR - // - // . ## Anything other char - // [^/"'\\]* ## Chars which doesn't start a comment, string or escape - // ) - // }{$2}gxs; - - return $buffer; - } - - - /* - * Returns the next character in the filtered stream, not including - * Php comments. - * - * @return the next character in the resulting stream, or -1 - * if the end of the resulting stream has been reached - * - * @throws IOException if the underlying stream throws an IOException - * during reading - * @deprecated - */ - function readChar() { - $ch = -1; - - if ( $this->_readAheadCh !== -1 ) { - $ch = $this->_readAheadCh; - $this->_readAheadCh = -1; - } else { - $ch = $this->in->readChar(); - if ( $ch === "\"" ) { - $this->_inString = !$this->_inString; - } else { - if ( !$this->_inString ) { - if ( $ch === "/" ) { - $ch = $this->in->readChar(); - if ( $ch === "/" ) { - while ( $ch !== "\n" && $ch !== -1 ) { - $ch = $this->in->readChar(); - } - } else if ( $ch === "*" ) { - while ( $ch !== -1 ) { - $ch = $this->in->readChar(); - while ( $ch === "*" && $ch !== -1 ) { - $ch = $this->in->readChar(); - } - - if ( $ch === "/" ) { - $ch = $this->readChar(); - echo "$ch\n"; - break; - } - } - } else { - $this->_readAheadCh = $ch; - $ch = "/"; - } - } - } - } - } - - return $ch; - } - - /** - * Creates a new StripJavaComments using the passed in - * Reader for instantiation. - * - * @param reader A Reader object providing the underlying stream. - * Must not be null. - * - * @return a new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new StripPhpComments($reader); - $newFilter->setProject($this->getProject()); - return $newFilter; - } -} - -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/filters/TabToSpaces.php b/buildscripts/phing/classes/phing/filters/TabToSpaces.php deleted file mode 100644 index 7293d3b5..00000000 --- a/buildscripts/phing/classes/phing/filters/TabToSpaces.php +++ /dev/null @@ -1,144 +0,0 @@ -. -*/ - -require_once 'phing/filters/BaseParamFilterReader.php'; -require_once 'phing/filters/ChainableReader.php'; - -/** - * Converts tabs to spaces. - * - * Example: - * - *
- * - * Or: - * - *

- *   
- * 
- * - * @author Yannick Lecaillez - * @author Hans Lellelid - * @version $Revision: 1.9 $ - * @see BaseParamFilterReader - * @package phing.filters - */ -class TabToSpaces extends BaseParamFilterReader implements ChainableReader { - - /** - * The default tab length. - * @var int - */ - const DEFAULT_TAB_LENGTH = 8; - - /** - * Parameter name for the length of a tab. - * @var string - */ - const TAB_LENGTH_KEY = "tablength"; - - /** - * Tab length in this filter. - * @var int - */ - private $tabLength = 8; //self::DEFAULT_TAB_LENGTH; - - /** - * Returns stream after converting tabs to the specified number of spaces. - * - * @return the resulting stream, or -1 - * if the end of the resulting stream has been reached - * - * @exception IOException if the underlying stream throws an IOException - * during reading - */ - function read($len = null) { - - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - $buffer = $this->in->read($len); - - if($buffer === -1) { - return -1; - } - - $buffer = str_replace("\t", str_repeat(' ', $this->tabLength), $buffer); - - return $buffer; - } - - /** - * Sets the tab length. - * - * @param int $tabLength The number of spaces to be used when converting a tab. - */ - function setTablength($tabLength) { - $this->tabLength = (int) $tabLength; - } - - /** - * Returns the tab length. - * - * @return int The number of spaces used when converting a tab - */ - function getTablength() { - return $this->tabLength; - } - - /** - * Creates a new TabsToSpaces using the passed in - * Reader for instantiation. - * - * @param Reader $reader A Reader object providing the underlying stream. - * Must not be null. - * - * @return Reader A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new TabToSpaces($reader); - $newFilter->setTablength($this->getTablength()); - $newFilter->setInitialized(true); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /** - * Parses the parameters to set the tab length. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - for($i = 0 ; $igetName()) { - $this->tabLength = $params[$i]->getValue(); - break; - } - } - } - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/TailFilter.php b/buildscripts/phing/classes/phing/filters/TailFilter.php deleted file mode 100644 index a6af6e4b..00000000 --- a/buildscripts/phing/classes/phing/filters/TailFilter.php +++ /dev/null @@ -1,157 +0,0 @@ -. -*/ - -require_once 'phing/filters/BaseParamFilterReader.php'; - -/** - * Reads the last n lines of a stream. (Default is last10 lines.) - * - * Example: - * - *
- * - * Or: - * - *

- *   
- * 
- * - * @author Yannick Lecaillez - * @author hans lellelid, hans@velum.net - * @copyright © 2003 seasonfive. All rights reserved - * @version $Revision: 1.7 $ - * @see BaseParamFilterReader - * @package phing.filters - */ -class TailFilter extends BaseParamFilterReader implements ChainableReader { - - /** - * Parameter name for the number of lines to be returned. - * @var string - */ - const LINES_KEY = "lines"; - - - /** - * Number of lines to be returned in the filtered stream. - * @var integer - */ - private $_lines = 10; - - /** - * Array to hold lines. - * @var array - */ - private $_lineBuffer = array(); - - /** - * Returns the last n lines of a file. - * @param int $len Num chars to read. - * @return mixed The filtered buffer or -1 if EOF. - */ - function read($len = null) { - - while ( ($buffer = $this->in->read($len)) !== -1 ) { - // Remove the last "\n" from buffer for - // prevent explode to add an empty cell at - // the end of array - $buffer= trim($buffer, "\n"); - - $lines = explode("\n", $buffer); - - if ( count($lines) >= $this->_lines ) { - // Buffer have more (or same) number of lines than needed. - // Fill lineBuffer with the last "$this->_lines" lasts ones. - $off = count($lines)-$this->_lines; - $this->_lineBuffer = array_slice($lines, $off); - } else { - // Some new lines ... - // Prepare space for insert these new ones - $this->_lineBuffer = array_slice($this->_lineBuffer, count($lines)-1); - $this->_lineBuffer = array_merge($this->_lineBuffer, $lines); - } - } - - if ( empty($this->_lineBuffer) ) - $ret = -1; - else { - $ret = implode("\n", $this->_lineBuffer); - $this->_lineBuffer = array(); - } - - return $ret; - } - - /** - * Sets the number of lines to be returned in the filtered stream. - * - * @param integer $lines the number of lines to be returned in the filtered stream. - */ - function setLines($lines) { - $this->_lines = (int) $lines; - } - - /** - * Returns the number of lines to be returned in the filtered stream. - * - * @return integer The number of lines to be returned in the filtered stream. - */ - function getLines() { - return $this->_lines; - } - - /** - * Creates a new TailFilter using the passed in - * Reader for instantiation. - * - * @param object A Reader object providing the underlying stream. - * Must not be null. - * - * @return object A new filter based on this configuration, but filtering - * the specified reader. - */ - function chain(Reader $reader) { - $newFilter = new TailFilter($reader); - $newFilter->setLines($this->getLines()); - $newFilter->setInitialized(true); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /** - * Scans the parameters list for the "lines" parameter and uses - * it to set the number of lines to be returned in the filtered stream. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - for($i=0, $_i=count($params); $i < $_i; $i++) { - if ( self::LINES_KEY == $params[$i]->getName() ) { - $this->_lines = (int) $params[$i]->getValue(); - break; - } - } - } - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/TidyFilter.php b/buildscripts/phing/classes/phing/filters/TidyFilter.php deleted file mode 100644 index 10d75fc4..00000000 --- a/buildscripts/phing/classes/phing/filters/TidyFilter.php +++ /dev/null @@ -1,162 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * This filter uses the bundled-with-PHP Tidy extension to filter input. - * - *

- * Example:
- *

- * 
- *   
- *   
- * 
- * 
- * - * @author Hans Lellelid - * @version $Revision: 1.2 $ $Date: 2005/12/08 19:15:20 $ - * @package phing.filters - */ -class TidyFilter extends BaseParamFilterReader implements ChainableReader { - - /** @var string Encoding of resulting document. */ - private $encoding = 'utf8'; - - /** @var array Parameter[] */ - private $configParameters = array(); - - /** - * Set the encoding for resulting (X)HTML document. - * @param string $v - */ - public function setEncoding($v) { - $this->encoding = $v; - } - - /** - * Sets the config params. - * @param array Parameter[] - * @see chain() - */ - public function setConfigParameters($params) - { - $this->configParameters = $params; - } - - /** - * Adds a element (which is a Parameter). - * @return Parameter - */ - public function createConfig() { - $num = array_push($this->configParameters, new Parameter()); - return $this->configParameters[$num-1]; - } - - /** - * Converts the Parameter objects being used to store configuration into a simle assoc array. - * @return array - */ - private function getDistilledConfig() { - $config = array(); - foreach($this->configParameters as $p) { - $config[$p->getName()] = $p->getValue(); - } - return $config; - } - - /** - * Reads input and returns Tidy-filtered output. - * - * @return the resulting stream, or -1 if the end of the resulting stream has been reached - * - * @throws IOException if the underlying stream throws an IOException - * during reading - */ - function read($len = null) { - - if (!class_exists('Tidy')) { - throw new BuildException("You must enable the 'tidy' extension in your PHP configuration in order to use the Tidy filter."); - } - - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - $buffer = $this->in->read($len); - if($buffer === -1) { - return -1; - } - - $config = $this->getDistilledConfig(); - - $tidy = new Tidy(); - $tidy->parseString($buffer, $config, $this->encoding); - $tidy->cleanRepair(); - - return tidy_get_output($tidy); - - } - - - /** - * Creates a new TidyFilter using the passed in Reader for instantiation. - * - * @param reader A Reader object providing the underlying stream. - * Must not be null. - * - * @return a new filter based on this configuration, but filtering - * the specified reader - */ - public function chain(Reader $reader) { - $newFilter = new TidyFilter($reader); - $newFilter->setConfigParameters($this->configParameters); - $newFilter->setEncoding($this->encoding); - $newFilter->setProject($this->getProject()); - return $newFilter; - } - - /** - * Initializes any parameters (e.g. config options). - * This method is only called when this filter is used through a tag in build file. - */ - private function _initialize() { - $params = $this->getParameters(); - if ($params) { - foreach($params as $param) { - if ($param->getType() == "config") { - $this->configParameters[] = $param; - } else { - - if ($param->getName() == "encoding") { - $this->setEncoding($param->getValue()); - } - - } - - } - } - } - -} diff --git a/buildscripts/phing/classes/phing/filters/TranslateGettext.php b/buildscripts/phing/classes/phing/filters/TranslateGettext.php deleted file mode 100644 index f71823e3..00000000 --- a/buildscripts/phing/classes/phing/filters/TranslateGettext.php +++ /dev/null @@ -1,285 +0,0 @@ -. -*/ - -require_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * Replaces gettext("message id") and _("message id") with the translated string. - * - * Gettext is great for creating multi-lingual sites, but in some cases (e.g. for - * performance reasons) you may wish to replace the gettext calls with the translations - * of the strings; that's what this task is for. Note that this is similar to - * ReplaceTokens, but both the find and the replace aspect is more complicated -- hence - * this is a separate, stand-alone filter. - * - *

- * Example:
- *

- * 
- * 
- * - * @author Hans Lellelid - * @version $Revision: 1.11 $ $Date: 2005/12/08 15:59:56 $ - * @access public - * @see BaseFilterReader - * @package phing.filters - */ -class TranslateGettext extends BaseParamFilterReader implements ChainableReader { - - // constants for specifying keys to expect - // when this is called using - const DOMAIN_KEY = "domain"; - const DIR_KEY = "dir"; - const LOCALE_KEY = "locale"; - - /** The domain to use */ - private $domain = 'messages'; - - /** The dir containing LC_MESSAGES */ - private $dir; - - /** The locale to use */ - private $locale; - - /** The system locale before it was changed for this filter. */ - private $storedLocale; - - /** - * Set the text domain to use. - * The text domain must correspond to the name of the compiled .mo files. - * E.g. "messages" ==> $dir/LC_MESSAGES/messages.mo - * "mydomain" ==> $dir/LC_MESSAGES/mydomain.mo - * @param string $domain - */ - function setDomain($domain) { - $this->domain = $domain; - } - - /** - * Get the current domain. - * @return string - */ - function getDomain() { - return $this->domain; - } - - /** - * Sets the root locale directory. - * @param PhingFile $dir - */ - function setDir(PhingFile $dir) { - $this->dir = $dir; - } - - /** - * Gets the root locale directory. - * @return PhingFile - */ - function getDir() { - return $this->dir; - } - - /** - * Sets the locale to use for translation. - * Note that for gettext() to work, you have to make sure this locale - * is specific enough for your system (e.g. some systems may allow an 'en' locale, - * but others will require 'en_US', etc.). - * @param string $locale - */ - function setLocale($locale) { - $this->locale = $locale; - } - - /** - * Gets the locale to use for translation. - * @return string - */ - function getLocale() { - return $this->locale; - } - - /** - * Make sure that required attributes are set. - * @throws BuldException - if any required attribs aren't set. - */ - protected function checkAttributes() { - if (!$this->domain || !$this->locale || !$this->dir) { - throw new BuildException("You must specify values for domain, locale, and dir attributes."); - } - } - - /** - * Initialize the gettext/locale environment. - * This method will change some env vars and locale settings; the - * restoreEnvironment should put them all back :) - * - * @return void - * @throws BuildException - if locale cannot be set. - * @see restoreEnvironment() - */ - protected function initEnvironment() { - $this->storedLocale = getenv("LANG"); - - $this->log("Setting locale to " . $this->locale, PROJECT_MSG_DEBUG); - putenv("LANG=".$this->locale); - $ret = setlocale(LC_ALL, $this->locale); - if ($ret === false) { - $msg = "Could not set locale to " . $this->locale - . ". You may need to use fully qualified name" - . " (e.g. en_US instead of en)."; - throw new BuildException($msg); - } - - $this->log("Binding domain '".$this->domain."' to " . $this->dir, PROJECT_MSG_DEBUG); - bindtextdomain($this->domain, $this->dir->getAbsolutePath()); - textdomain($this->domain); - } - - /** - * Restores environment settings and locale. - * This does _not_ restore any gettext-specific settings - * (e.g. textdomain()). - * - * @return void - */ - protected function restoreEnvironment() { - putenv("LANG=".$this->storedLocale); - setlocale(LC_ALL, $this->storedLocale); - } - - /** - * Performs gettext translation of msgid and returns translated text. - * - * This function simply wraps gettext() call, but provides ability to log - * string replacements. (alternative would be using preg_replace with /e which - * would probably be faster, but no ability to debug/log.) - * - * @param array $matches Array of matches; we're interested in $matches[2]. - * @return string Translated text - */ - private function xlateStringCallback($matches) { - $charbefore = $matches[1]; - $msgid = $matches[2]; - $translated = gettext($msgid); - $this->log("Translating \"$msgid\" => \"$translated\"", PROJECT_MSG_DEBUG); - return $charbefore . '"' . $translated . '"'; - } - - /** - * Returns the filtered stream. - * The original stream is first read in fully, and then translation is performed. - * - * @return mixed the filtered stream, or -1 if the end of the resulting stream has been reached. - * - * @throws IOException - if the underlying stream throws an IOException during reading - * @throws BuildException - if the correct params are not supplied - */ - function read($len = null) { - - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - // Make sure correct params/attribs have been set - $this->checkAttributes(); - - $buffer = $this->in->read($len); - if($buffer === -1) { - return -1; - } - - // Setup the locale/gettext environment - $this->initEnvironment(); - - - // replace any occurrences of _("") or gettext("") with - // the translated value. - // - // ([^\w]|^)_\("((\\"|[^"])*)"\) - // --$1--- -----$2---- - // ---$3-- [match escaped quotes or any char that's not a quote] - // - // also match gettext() -- same as above - - $buffer = preg_replace_callback('/([^\w]|^)_\("((\\\"|[^"])*)"\)/', array($this, 'xlateStringCallback'), $buffer); - $buffer = preg_replace_callback('/([^\w]|^)gettext\("((\\\"|[^"])*)"\)/', array($this, 'xlateStringCallback'), $buffer); - - // Check to see if there are any _('') calls and flag an error - - // Check to see if there are any unmatched gettext() calls -- and flag an error - - $matches = array(); - if (preg_match('/([^\w]|^)(gettext\([^\)]+\))/', $buffer, $matches)) { - $this->log("Unable to perform translation on: " . $matches[2], PROJECT_MSG_WARN); - } - - $this->restoreEnvironment(); - - return $buffer; - } - - /** - * Creates a new TranslateGettext filter using the passed in - * Reader for instantiation. - * - * @param Reader $reader A Reader object providing the underlying stream. - * Must not be null. - * - * @return TranslateGettext A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new TranslateGettext($reader); - $newFilter->setProject($this->getProject()); - $newFilter->setDomain($this->getDomain()); - $newFilter->setLocale($this->getLocale()); - $newFilter->setDir($this->getDir()); - return $newFilter; - } - - /** - * Parses the parameters if this filter is being used in "generic" mode. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - foreach($params as $param) { - switch($param->getType()) { - case self::DOMAIN_KEY: - $this->setDomain($param->getValue()); - break; - case self::DIR_KEY: - $this->setDir($this->project->resolveFile($param->getValue())); - break; - - case self::LOCALE_KEY: - $this->setLocale($param->getValue()); - break; - } // switch - } - } // if params !== null - } -} - -?> diff --git a/buildscripts/phing/classes/phing/filters/XsltFilter.php b/buildscripts/phing/classes/phing/filters/XsltFilter.php deleted file mode 100644 index 0b8c4e6f..00000000 --- a/buildscripts/phing/classes/phing/filters/XsltFilter.php +++ /dev/null @@ -1,317 +0,0 @@ -. -*/ - -include_once 'phing/filters/BaseParamFilterReader.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * Applies XSL stylesheet to incoming text. - * - * Uses PHP XSLT support (libxslt). - * - * @author Hans Lellelid - * @author Yannick Lecaillez - * @author Andreas Aderhold - * @version $Revision: 1.16 $ - * @see FilterReader - * @package phing.filters - */ -class XsltFilter extends BaseParamFilterReader implements ChainableReader { - - /** - * Path to XSL stylesheet. - * @var string - */ - private $xslFile = null; - - /** - * Whether XML file has been transformed. - * @var boolean - */ - private $processed = false; - - /** - * XSLT Params. - * @var array - */ - private $xsltParams = array(); - - /** - * Whether to use loadHTML() to parse the input XML file. - */ - private $html = false; - - /** - * Create new XSLT Param object, to handle the nested element. - * @return XSLTParam - */ - function createParam() { - $num = array_push($this->xsltParams, new XSLTParam()); - return $this->xsltParams[$num-1]; - } - - /** - * Sets the XSLT params for this class. - * This is used to "clone" this class, in the chain() method. - * @param array $params - */ - function setParams($params) { - $this->xsltParams = $params; - } - - /** - * Returns the XSLT params set for this class. - * This is used to "clone" this class, in the chain() method. - * @return array - */ - function getParams() { - return $this->xsltParams; - } - - /** - * Set the XSLT stylesheet. - * @param mixed $file PhingFile object or path. - */ - function setStyle(PhingFile $file) { - $this->xslFile = $file; - } - - /** - * Whether to use HTML parser for the XML. - * This is supported in libxml2 -- Yay! - * @return boolean - */ - function getHtml() { - return $this->html; - } - - /** - * Whether to use HTML parser for XML. - * @param boolean $b - */ - function setHtml($b) { - $this->html = (boolean) $b; - } - - /** - * Get the path to XSLT stylesheet. - * @return mixed XSLT stylesheet path. - */ - function getStyle() { - return $this->xslFile; - } - - /** - * Reads stream, applies XSLT and returns resulting stream. - * @return string transformed buffer. - * @throws BuildException - if XSLT support missing, if error in xslt processing - */ - function read($len = null) { - - if (!class_exists('XSLTProcessor')) { - throw new BuildException("Could not find the XSLTProcessor class. Make sure PHP has been compiled/configured to support XSLT."); - } - - if ($this->processed === true) { - return -1; // EOF - } - - if ( !$this->getInitialized() ) { - $this->_initialize(); - $this->setInitialized(true); - } - - // Read XML - $_xml = null; - while ( ($data = $this->in->read($len)) !== -1 ) - $_xml .= $data; - - if ($_xml === null ) { // EOF? - return -1; - } - - if(empty($_xml)) { - $this->log("XML file is empty!", PROJECT_MSG_WARN); - return ''; // return empty string, don't attempt to apply XSLT - } - - // Read XSLT - $_xsl = null; - $xslFr = new FileReader($this->xslFile); - $xslFr->readInto($_xsl); - - $this->log("Tranforming XML " . $this->in->getResource() . " using style " . $this->xslFile->getPath(), PROJECT_MSG_VERBOSE); - - $out = ''; - try { - $out = $this->process($_xml, $_xsl); - $this->processed = true; - } catch (IOException $e) { - throw new BuildException($e); - } - - return $out; - } - - // {{{ method _ProcessXsltTransformation($xml, $xslt) throws BuildException - /** - * Try to process the XSLT transformation - * - * @param string XML to process. - * @param string XSLT sheet to use for the processing. - * - * @throws BuildException On XSLT errors - */ - protected function process($xml, $xsl) { - - $processor = new XSLTProcessor(); - - $xmlDom = new DOMDocument(); - $xslDom = new DOMDocument(); - - if ($this->html) { - $xmlDom->loadHTML($xml); - } else { - $xmlDom->loadXML($xml); - } - - $xslDom->loadxml($xsl); - - $processor->importStylesheet($xslDom); - - // ignoring param "type" attrib, because - // we're only supporting direct XSL params right now - foreach($this->xsltParams as $param) { - $this->log("Setting XSLT param: " . $param->getName() . "=>" . $param->getExpression(), PROJECT_MSG_DEBUG); - $processor->setParameter(null, $param->getName(), $param->getExpression()); - } - - $result = $processor->transformToXML($xmlDom); - - if ( !$result ) { - //$errno = xslt_errno($processor); - //$err = xslt_error($processor); - throw new BuildException("XSLT Error"); - } else { - return $result; - } - } - - /** - * Creates a new XsltFilter using the passed in - * Reader for instantiation. - * - * @param Reader A Reader object providing the underlying stream. - * Must not be null. - * - * @return Reader A new filter based on this configuration, but filtering - * the specified reader - */ - function chain(Reader $reader) { - $newFilter = new XsltFilter($reader); - $newFilter->setProject($this->getProject()); - $newFilter->setStyle($this->getStyle()); - $newFilter->setInitialized(true); - $newFilter->setParams($this->getParams()); - $newFilter->setHtml($this->getHtml()); - return $newFilter; - } - - /** - * Parses the parameters to get stylesheet path. - */ - private function _initialize() { - $params = $this->getParameters(); - if ( $params !== null ) { - for($i = 0, $_i=count($params) ; $i < $_i; $i++) { - if ( $params[$i]->getType() === null ) { - if ($params[$i]->getName() === "style") { - $this->setStyle($params[$i]->getValue()); - } - } elseif ($params[$i]->getType() == "param") { - $xp = new XSLTParam(); - $xp->setName($params[$i]->getName()); - $xp->setExpression($params[$i]->getValue()); - $this->xsltParams[] = $xp; - } - } - } - } - -} - - -/** - * Class that holds an XSLT parameter. - */ -class XSLTParam { - - private $name; - - private $expr; - - /** - * Sets param name. - * @param string $name - */ - public function setName($name) { - $this->name = $name; - } - - /** - * Get param name. - * @return string - */ - public function getName() { - return $this->name; - } - - /** - * Sets expression value. - * @param string $expr - */ - public function setExpression($expr) { - $this->expr = $expr; - } - - /** - * Sets expression to dynamic register slot. - * @param RegisterSlot $expr - */ - public function setListeningExpression(RegisterSlot $expr) { - $this->expr = $expr; - } - - /** - * Returns expression value -- performs lookup if expr is registerslot. - * @return string - */ - public function getExpression() { - if ($this->expr instanceof RegisterSlot) { - return $this->expr->getValue(); - } else { - return $this->expr; - } - } -} - -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/filters/util/ChainReaderHelper.php b/buildscripts/phing/classes/phing/filters/util/ChainReaderHelper.php deleted file mode 100644 index 80508a82..00000000 --- a/buildscripts/phing/classes/phing/filters/util/ChainReaderHelper.php +++ /dev/null @@ -1,184 +0,0 @@ -. -*/ - -include_once 'phing/Project.php'; -include_once 'phing/filters/BaseFilterReader.php'; -include_once 'phing/types/PhingFilterReader.php'; -include_once 'phing/types/FilterChain.php'; -include_once 'phing/types/Parameter.php'; -include_once 'phing/util/FileUtils.php'; -include_once 'phing/util/StringHelper.php'; -include_once 'phing/filters/ChainableReader.php'; - -/** - * Process a FilterReader chain. - * - * Here, the interesting method is 'getAssembledReader'. - * The purpose of this one is to create a simple Reader object which - * apply all filters on another primary Reader object. - * - * For example : In copyFile (phing.util.FileUtils) the primary Reader - * is a FileReader object (more accuratly, a BufferedReader) previously - * setted for the source file to copy. So, consider this filterchain : - * - * - * - * - * - * - * - * - * - * getAssembledReader will return a Reader object wich read on each - * of these filters. Something like this : ('->' = 'which read data from') : - * - * [TABTOSPACES] -> [LINECONTAINS] -> [STRIPPHPCOMMENTS] -> [FILEREADER] - * (primary reader) - * - * So, getAssembledReader will return the TABTOSPACES Reader object. Then - * each read done with this Reader object will follow this path. - * - * Hope this explanation is clear :) - * - * TODO: Implement the classPath feature. - * - * @author Yannick Lecaillez - * @version $Revision: 1.8 $ $Date: 2005/02/27 20:52:09 $ - * @access public - * @package phing.filters.util -*/ -class ChainReaderHelper { - - /** Primary reader to wich the reader chain is to be attached */ - private $primaryReader = null; - - /** The site of the buffer to be used. */ - private $bufferSize = 8192; - - /** Chain of filters */ - private $filterChains = array(); - - /** The Phing project */ - private $project; - - /* - * Sets the primary reader - */ - function setPrimaryReader(Reader $reader) { - $this->primaryReader = $reader; - } - - /* - * Set the project to work with - */ - function setProject(Project $project) { - $this->project = $project; - } - - /* - * Get the project - */ - function getProject() { - return $this->project; - } - - /* - * Sets the buffer size to be used. Defaults to 8192, - * if this method is not invoked. - */ - function setBufferSize($size) { - $this->bufferSize = $size; - } - - /* - * Sets the collection of filter reader sets - */ - function setFilterChains(&$fchain) { - $this->filterChains = &$fchain; - } - - /* - * Assemble the reader - */ - function getAssembledReader() { - - $instream = $this->primaryReader; - $filterReadersCount = count($this->filterChains); - $finalFilters = array(); - - // Collect all filter readers of all filter chains used ... - for($i = 0 ; $i<$filterReadersCount ; $i++) { - $filterchain = &$this->filterChains[$i]; - $filterReaders = $filterchain->getFilterReaders(); - $readerCount = count($filterReaders); - for($j = 0 ; $j<$readerCount ; $j++) { - $finalFilters[] = $filterReaders[$j]; - } - } - - // ... then chain the filter readers. - $filtersCount = count($finalFilters); - if ( $filtersCount > 0 ) { - for($i = 0 ; $i<$filtersCount ; $i++) { - $filter = $finalFilters[$i]; - - if ( $filter instanceof PhingFilterReader ) { - - // This filter reader is an external class. - $className = $filter->getClassName(); - $classpath = $filter->getClasspath(); - $project = $filter->getProject(); - - if ( $className !== null ) { - $cls = Phing::import($className, $classpath); - $impl = new $cls(); - } - - if ( !($impl instanceof FilterReader) ) { - throw new Exception($className." does not extend phing.system.io.FilterReader"); - } - - $impl->setReader($instream); // chain - $impl->setProject($this->getProject()); // what about $project above ? - - if ( $impl instanceof Parameterizable ) { - $impl->setParameters($filter->getParams()); - } - - $instream = $impl; // now that it's been chained - - } elseif (($filter instanceof ChainableReader) && ($filter instanceof Reader)) { - if ( $this->getProject() !== null && ($filter instanceof BaseFilterReader) ) { - $filter->setProject($this->getProject()); - } - $instream = $filter->chain($instream); - } else { - throw new Exception("Cannot chain invalid filter: " . get_class($filter)); - } - } - } - - return $instream; - } - -} - -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/filters/util/IniFileTokenReader.php b/buildscripts/phing/classes/phing/filters/util/IniFileTokenReader.php deleted file mode 100644 index 34bc5943..00000000 --- a/buildscripts/phing/classes/phing/filters/util/IniFileTokenReader.php +++ /dev/null @@ -1,96 +0,0 @@ -. -*/ - -include_once 'phing/types/TokenReader.php'; -include_once 'phing/system/io/IOException.php'; -include_once 'phing/filters/ReplaceTokens.php'; // For class Token - -/** - * Class that allows reading tokens from INI files. - * - * @author Manuel Holtgewe - * @version $Revision: 1.7 $ - * @package phing.filters.util - */ -class IniFileTokenReader extends TokenReader { - - /** - * Holds the path to the INI file that is to be read. - * @var object Reference to a PhingFile Object representing - * the path to the INI file. - */ - private $file = null; - - /** - * @var string Sets the section to load from the INI file. - * if omitted, all sections are loaded. - */ - private $section = null; - - /** - * Reads the next token from the INI file - * - * @throws IOException On error - */ - function readToken() { - if ($this->file === null) { - throw new BuildException("No File set for IniFileTokenReader"); - } - - static $tokens = null; - if ($tokens === null) { - $tokens = array(); - $arr = parse_ini_file($this->file->getAbsolutePath(), true); - if ($this->section === null) { - foreach ($arr as $sec_name => $values) { - foreach($arr[$sec_name] as $key => $value) { - $tok = new Token; - $tok->setKey($key); - $tok->setValue($value); - $tokens[] = $tok; - } - } - } else if (isset($arr[$this->section])) { - foreach ($arr[$this->section] as $key => $value) { - $tok = new Token; - $tok->setKey($key); - $tok->setValue($value); - $tokens[] = $tok; - } - } - } - - if (count($tokens) > 0) { - return array_pop($tokens); - } else - return null; - } - - function setFile(PhingFile $file) { - $this->file = $file; - } - - function setSection($str) { - $this->section = (string) $str; - } -} - -?> diff --git a/buildscripts/phing/classes/phing/input/DefaultInputHandler.php b/buildscripts/phing/classes/phing/input/DefaultInputHandler.php deleted file mode 100644 index 8ce76cdd..00000000 --- a/buildscripts/phing/classes/phing/input/DefaultInputHandler.php +++ /dev/null @@ -1,82 +0,0 @@ -. - */ - -require_once 'phing/input/InputHandler.php'; -include_once 'phing/system/io/ConsoleReader.php'; - -/** - * Prompts using print(); reads input from Console. - * - * @author Hans Lellelid (Phing) - * @author Stefan Bodewig (Ant) - * @version $Revision: 1.6 $ - * @package phing.input - */ -class DefaultInputHandler implements InputHandler { - - /** - * Prompts and requests input. May loop until a valid input has - * been entered. - * @throws BuildException - */ - public function handleInput(InputRequest $request) { - $prompt = $this->getPrompt($request); - $in = new ConsoleReader(); - do { - print $prompt; - try { - $input = $in->readLine(); - if ($input === "" && ($request->getDefaultValue() !== null) ) { - $input = $request->getDefaultValue(); - } - $request->setInput($input); - } catch (Exception $e) { - throw new BuildException("Failed to read input from Console.", $e); - } - } while (!$request->isInputValid()); - } - - /** - * Constructs user prompt from a request. - * - *

This implementation adds (choice1,choice2,choice3,...) to the - * prompt for MultipleChoiceInputRequests.

- * - * @param $request the request to construct the prompt for. - * Must not be null. - */ - protected function getPrompt(InputRequest $request) { - $prompt = $request->getPrompt(); - - // use is_a() to avoid needing the class to be loaded - if (is_a($request, 'YesNoInputRequest')) { // (yes/no) - $prompt .= '(' . implode('/', $request->getChoices()) .')'; - } elseif (is_a($request, 'MultipleChoiceInputRequest')) { // (a,b,c,d) - $prompt .= '(' . implode(',', $request->getChoices()) . ')'; - } - if ($request->getDefaultValue() !== null) { - $prompt .= ' ['.$request->getDefaultValue().']'; - } - $pchar = $request->getPromptChar(); - return $prompt . ($pchar ? $pchar . ' ' : ' '); - } -} diff --git a/buildscripts/phing/classes/phing/input/InputHandler.php b/buildscripts/phing/classes/phing/input/InputHandler.php deleted file mode 100644 index 68fad7b5..00000000 --- a/buildscripts/phing/classes/phing/input/InputHandler.php +++ /dev/null @@ -1,45 +0,0 @@ -. - */ - -/** - * Plugin to Phing to handle requests for user input. - * - * @author Stefan Bodewig - * @version $Revision: 1.3 $ - * @package phing.input - */ -interface InputHandler { - - /** - * Handle the request encapsulated in the argument. - * - *

Precondition: the request.getPrompt will return a non-null - * value.

- * - *

Postcondition: request.getInput will return a non-null - * value, request.isInputValid will return true.

- * @return void - * @throws BuildException - */ - public function handleInput(InputRequest $request); - -} diff --git a/buildscripts/phing/classes/phing/input/InputRequest.php b/buildscripts/phing/classes/phing/input/InputRequest.php deleted file mode 100644 index 7bfe8def..00000000 --- a/buildscripts/phing/classes/phing/input/InputRequest.php +++ /dev/null @@ -1,107 +0,0 @@ -. - */ - -/** - * Encapsulates an input request. - * - * @author Hans Lellelid (Phing) - * @author Stefan Bodewig (Ant) - * @version $Revision: 1.4 $ - * @package phing.input - */ -class InputRequest { - - protected $prompt; - protected $input; - protected $defaultValue; - protected $promptChar; - - /** - * @param string $prompt The prompt to show to the user. Must not be null. - */ - public function __construct($prompt) { - if ($prompt === null) { - throw new BuildException("prompt must not be null"); - } - $this->prompt = $prompt; - } - - /** - * Retrieves the prompt text. - */ - public function getPrompt() { - return $this->prompt; - } - - /** - * Sets the user provided input. - */ - public function setInput($input) { - $this->input = $input; - } - - /** - * Is the user input valid? - */ - public function isInputValid() { - return true; - } - - /** - * Retrieves the user input. - */ - public function getInput() { - return $this->input; - } - - /** - * Set the default value to use. - * @param mixed $v - */ - public function setDefaultValue($v) { - $this->defaultValue = $v; - } - - /** - * Return the default value to use. - * @return mixed - */ - public function getDefaultValue() { - return $this->defaultValue; - } - - /** - * Set the default value to use. - * @param string $c - */ - public function setPromptChar($c) { - $this->promptChar = $c; - } - - /** - * Return the default value to use. - * @return string - */ - public function getPromptChar() { - return $this->promptChar; - } -} diff --git a/buildscripts/phing/classes/phing/input/MultipleChoiceInputRequest.php b/buildscripts/phing/classes/phing/input/MultipleChoiceInputRequest.php deleted file mode 100644 index d4ea1212..00000000 --- a/buildscripts/phing/classes/phing/input/MultipleChoiceInputRequest.php +++ /dev/null @@ -1,58 +0,0 @@ -. - */ - -require_once 'phing/input/InputRequest.php'; - -/** - * Encapsulates an input request. - * - * @author Stefan Bodewig - * @version $Revision: 1.5 $ - * @package phing.input - */ -class MultipleChoiceInputRequest extends InputRequest { - - protected $choices = array(); - - /** - * @param string $prompt The prompt to show to the user. Must not be null. - * @param array $choices holds all input values that are allowed. - * Must not be null. - */ - public function __construct($prompt, $choices) { - parent::__construct($prompt); - $this->choices = $choices; - } - - /** - * @return The possible values. - */ - public function getChoices() { - return $this->choices; - } - - /** - * @return true if the input is one of the allowed values. - */ - public function isInputValid() { - return in_array($this->getInput(), $this->choices); // not strict (?) - } -} diff --git a/buildscripts/phing/classes/phing/input/PropertyFileInputHandler.php b/buildscripts/phing/classes/phing/input/PropertyFileInputHandler.php deleted file mode 100644 index e588cead..00000000 --- a/buildscripts/phing/classes/phing/input/PropertyFileInputHandler.php +++ /dev/null @@ -1,129 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2002 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "Ant" and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - */ - -package org.apache.tools.ant.input; - -import org.apache.tools.ant.BuildException; - -import java.io.FileInputStream; -import java.io.IOException; -import java.util.Properties; - -/** - * Reads input from a property file, the file name is read from the - * system property ant.input.properties, the prompt is the key for input. - * - * @author Stefan Bodewig - * @version $Revision: 1.1 $ - * @since Ant 1.5 - */ -public class PropertyFileInputHandler implements InputHandler { - private Properties props = null; - - /** - * Name of the system property we expect to hold the file name. - */ - public static final String FILE_NAME_KEY = "ant.input.properties"; - - /** - * Empty no-arg constructor. - */ - public PropertyFileInputHandler() { - } - - /** - * Picks up the input from a property, using the prompt as the - * name of the property. - * - * @exception BuildException if no property of that name can be found. - */ - public void handleInput(InputRequest request) throws BuildException { - readProps(); - - Object o = props.get(request.getPrompt()); - if (o == null) { - throw new BuildException("Unable to find input for \'" - + request.getPrompt()+"\'"); - } - request.setInput(o.toString()); - if (!request.isInputValid()) { - throw new BuildException("Found invalid input " + o - + " for \'" + request.getPrompt() + "\'"); - } - } - - /** - * Reads the properties file if it hasn't already been read. - */ - private synchronized void readProps() throws BuildException { - if (props == null) { - String propsFile = System.getProperty(FILE_NAME_KEY); - if (propsFile == null) { - throw new BuildException("System property " - + FILE_NAME_KEY - + " for PropertyFileInputHandler not" - + " set"); - } - - props = new Properties(); - - try { - props.load(new FileInputStream(propsFile)); - } catch (IOException e) { - throw new BuildException("Couldn't load " + propsFile, e); - } - } - } - -} diff --git a/buildscripts/phing/classes/phing/input/YesNoInputRequest.php b/buildscripts/phing/classes/phing/input/YesNoInputRequest.php deleted file mode 100644 index e34863d5..00000000 --- a/buildscripts/phing/classes/phing/input/YesNoInputRequest.php +++ /dev/null @@ -1,47 +0,0 @@ -. - */ - -require_once 'phing/input/MultipleChoiceInputRequest.php'; - -/** - * Encapsulates an input request that returns a boolean (yes/no). - * - * @author Hans Lellelid - * @version $Revision: 1.4 $ - * @package phing.input - */ -class YesNoInputRequest extends MultipleChoiceInputRequest { - - /** - * @return true if the input is one of the allowed values. - */ - public function isInputValid() { - return StringHelper::isBoolean($this->input); - } - - /** - * Converts input to boolean. - * @return boolean - */ - public function getInput() { - return StringHelper::booleanValue($this->input); - } -} diff --git a/buildscripts/phing/classes/phing/lib/Capsule.php b/buildscripts/phing/classes/phing/lib/Capsule.php deleted file mode 100644 index bab05486..00000000 --- a/buildscripts/phing/classes/phing/lib/Capsule.php +++ /dev/null @@ -1,266 +0,0 @@ - - * @version $Revision: 1.9 $ $Date: 2004/08/31 20:12:02 $ - */ -class Capsule { - - /** - * Look for templates here (if relative path provided). - * @var string - */ - protected $templatePath; - - /** - * Where should output files be written? - * (This is named inconsistently to be compatible w/ Texen.) - * @var string - */ - protected $outputDirectory; - - /** - * The variables that can be used by the templates. - * @var array Hash of variables. - */ - public $vars = array(); - - /** - * Has template been initialized. - */ - protected $initialized = false; - - /** - * Stores the pre-parse() include_path. - * @var string - */ - private $old_include_path; - - function __construct() { - } - - /** - * Clears one or several or all variables. - * @param mixed $which String name of var, or array of names. - * @return void - */ - function clear($which = null) { - if ($which === null) { - $this->vars = array(); - } elseif (is_array($which)) { - foreach($which as $var) { - unset($this->vars[$var]); - } - } else { - unset($this->vars[$which]); - } - } - - /** - * Set the basepath to use for template lookups. - * @param string $v - */ - function setTemplatePath($v) { - $this->templatePath = rtrim($v, DIRECTORY_SEPARATOR.'/'); - } - - /** - * Get the basepath to use for template lookups. - * @return string - */ - function getTemplatePath() { - return $this->templatePath; - } - - /** - * Set a basepath to use for output file creation. - * @param string $v - */ - function setOutputDirectory($v) { - $this->outputDirectory = rtrim($v, DIRECTORY_SEPARATOR.'/'); - } - - /** - * Get basepath to use for output file creation. - * @return string - */ - function getOutputDirectory() { - return $this->outputDirectory; - } - - /** - * Low overhead (no output buffering) method to simply dump template - * to buffer. - * - * @param string $__template - * @return void - * @throws Exception - if template cannot be found - */ - function display($__template) { - - // Prepend "private" variable names with $__ in this function - // to keep namespace conflict potential to a minimum. - - // Alias this class to $generator. - $generator = $this; - - if (isset($this->vars['this'])) { - throw new Exception("Assigning a variable named \$this to a context conflicts with class namespace."); - } - - // extract variables into local namespace - extract($this->vars); - - // prepend template path to include path, - // so that include "path/relative/to/templates"; can be used within templates - $__old_inc_path = ini_get('include_path'); - ini_set('include_path', $this->templatePath . PATH_SEPARATOR . $__old_inc_path); - - @ini_set('track_errors', true); - include $__template; - @ini_restore('track_errors'); - - // restore the include path - ini_set('include_path', $__old_inc_path); - - if (!empty($php_errormsg)) { - throw new Exception("Unable to parse template " . $__template . ": " . $php_errormsg); - } - } - - /** - * Fetches the results of a tempalte parse and either returns - * the string or writes results to a specified output file. - * - * @param string $template The template filename (relative to templatePath or absolute). - * @param string $outputFile If specified, contents of template will also be written to this file. - * @param boolean $append Should output be appended to source file? - * @return string The "parsed" template output. - * @throws Exception - if template not found. - */ - function parse($template, $outputFile = null, $append = false) { - - // main work done right here: - // hopefully this works recursively ... fingers crossed. - ob_start(); - - try { - $this->display($template); - } catch (Exception $e) { - ob_end_flush(); // flush the output on error (so we can see up to what point it parsed everything) - throw $e; - } - - $output = ob_get_contents(); - ob_end_clean(); - - if ($outputFile !== null) { - $outputFile = $this->resolvePath($outputFile, $this->outputDirectory); - - $flags = null; - if ($append) $flags = FILE_APPEND; - - if (!file_put_contents($outputFile, $output, $flags) && $output != "") { - throw new Exception("Unable to write output to " . $outputFile); - } - } - - return $output; - } - - /** - * This returns a "best guess" path for the given file. - * - * @param string $file File name or possibly absolute path. - * @param string $basepath The basepath that should be prepended if $file is not absolute. - * @return string "Best guess" path for this file. - */ - protected function resolvePath($file, $basepath) { - if ( !($file{0} == DIRECTORY_SEPARATOR || $file{0} == '/') - // also account for C:\ style path - && !($file{1} == ':' && ($file{2} == DIRECTORY_SEPARATOR || $file{2} == '/'))) { - if ($basepath != null) { - $file = $basepath . DIRECTORY_SEPARATOR . $file; - } - } - return $file; - } - - /** - * Gets value of specified var or NULL if var has not been put(). - * @param string $name Variable name to retrieve. - * @return mixed - */ - function get($name) { - if (!isset($this->vars[$name])) return null; - return $this->vars[$name]; - } - - /** - * Merges in passed hash to vars array. - * - * Given an array like: - * - * array( 'myvar' => 'Hello', - * 'myvar2' => 'Hello') - * - * Resulting template will have access to $myvar and $myvar2. - * - * @param array $vars - * @param boolean $recursiveMerge Should matching keys be recursively merged? - * @return void - */ - function putAll($vars, $recursiveMerge = false) { - if ($recursiveMerge) { - $this->vars = array_merge_recursive($this->vars, $vars); - } else { - $this->vars = array_merge($this->vars, $vars); - } - } - - /** - * Adds a variable to the context. - * - * Resulting template will have access to ${$name$} variable. - * - * @param string $name - * @param mixed $value - */ - function put($name, $value) { - $this->vars[$name] = $value; - } - - /** - * Put a variable into the context, assigning it by reference. - * This means that if the template modifies the variable, then it - * will also be modified in the context. - * - * @param $name - * @param &$value - */ - function putRef($name, &$value) { - $this->vars[$name] = &$value; - } - - /** - * Makes a copy of the value and puts it into the context. - * This is primarily to force copying (cloning) of objects, rather - * than the default behavior which is to assign them by reference. - * @param string $name - * @param mixed $value - */ - function putCopy($name, $value) { - if (is_object($value)) { - $value = clone $value; - } - $this->vars[$name] = $value; - } - -} \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/lib/Zip.php b/buildscripts/phing/classes/phing/lib/Zip.php deleted file mode 100644 index 70d31595..00000000 --- a/buildscripts/phing/classes/phing/lib/Zip.php +++ /dev/null @@ -1,3588 +0,0 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: Zip.php,v 1.3 2005/12/27 16:05:57 hlellelid Exp $ - - // ----- Constants - define( 'ARCHIVE_ZIP_READ_BLOCK_SIZE', 2048 ); - - // ----- File list separator - define( 'ARCHIVE_ZIP_SEPARATOR', ',' ); - - // ----- Optional static temporary directory - // By default temporary files are generated in the script current - // path. - // If defined : - // - MUST BE terminated by a '/'. - // - MUST be a valid, already created directory - // Samples : - // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', '/temp/' ); - // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', 'C:/Temp/' ); - define( 'ARCHIVE_ZIP_TEMPORARY_DIR', '' ); - - // ----- Error codes - define( 'ARCHIVE_ZIP_ERR_NO_ERROR', 0 ); - define( 'ARCHIVE_ZIP_ERR_WRITE_OPEN_FAIL', -1 ); - define( 'ARCHIVE_ZIP_ERR_READ_OPEN_FAIL', -2 ); - define( 'ARCHIVE_ZIP_ERR_INVALID_PARAMETER', -3 ); - define( 'ARCHIVE_ZIP_ERR_MISSING_FILE', -4 ); - define( 'ARCHIVE_ZIP_ERR_FILENAME_TOO_LONG', -5 ); - define( 'ARCHIVE_ZIP_ERR_INVALID_ZIP', -6 ); - define( 'ARCHIVE_ZIP_ERR_BAD_EXTRACTED_FILE', -7 ); - define( 'ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL', -8 ); - define( 'ARCHIVE_ZIP_ERR_BAD_EXTENSION', -9 ); - define( 'ARCHIVE_ZIP_ERR_BAD_FORMAT', -10 ); - define( 'ARCHIVE_ZIP_ERR_DELETE_FILE_FAIL', -11 ); - define( 'ARCHIVE_ZIP_ERR_RENAME_FILE_FAIL', -12 ); - define( 'ARCHIVE_ZIP_ERR_BAD_CHECKSUM', -13 ); - define( 'ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP', -14 ); - define( 'ARCHIVE_ZIP_ERR_MISSING_OPTION_VALUE', -15 ); - define( 'ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE', -16 ); - - // ----- Warning codes - define( 'ARCHIVE_ZIP_WARN_NO_WARNING', 0 ); - define( 'ARCHIVE_ZIP_WARN_FILE_EXIST', 1 ); - - // ----- Methods parameters - define( 'ARCHIVE_ZIP_PARAM_PATH', 'path' ); - define( 'ARCHIVE_ZIP_PARAM_ADD_PATH', 'add_path' ); - define( 'ARCHIVE_ZIP_PARAM_REMOVE_PATH', 'remove_path' ); - define( 'ARCHIVE_ZIP_PARAM_REMOVE_ALL_PATH', 'remove_all_path' ); - define( 'ARCHIVE_ZIP_PARAM_SET_CHMOD', 'set_chmod' ); - define( 'ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING', 'extract_as_string' ); - define( 'ARCHIVE_ZIP_PARAM_NO_COMPRESSION', 'no_compression' ); - define( 'ARCHIVE_ZIP_PARAM_BY_NAME', 'by_name' ); - define( 'ARCHIVE_ZIP_PARAM_BY_INDEX', 'by_index' ); - define( 'ARCHIVE_ZIP_PARAM_BY_EREG', 'by_ereg' ); - define( 'ARCHIVE_ZIP_PARAM_BY_PREG', 'by_preg' ); - - define( 'ARCHIVE_ZIP_PARAM_PRE_EXTRACT', 'callback_pre_extract' ); - define( 'ARCHIVE_ZIP_PARAM_POST_EXTRACT', 'callback_post_extract' ); - define( 'ARCHIVE_ZIP_PARAM_PRE_ADD', 'callback_pre_add' ); - define( 'ARCHIVE_ZIP_PARAM_POST_ADD', 'callback_post_add' ); - - - -/** -* Class for manipulating zip archive files -* -* A class which provided common methods to manipulate ZIP formatted -* archive files. -* It provides creation, extraction, deletion and add features. -* -* @author Vincent Blavet -* @version $Revision: 1.3 $ -* @package phing.lib -*/ -class Archive_Zip -{ - /** - * The filename of the zip archive. - * - * @var string Name of the Zip file - */ - var $_zipname=''; - - /** - * File descriptor of the opened Zip file. - * - * @var int Internal zip file descriptor - */ - var $_zip_fd=0; - - /** - * @var int last error code - */ - var $_error_code=1; - - /** - * @var string Last error description - */ - var $_error_string=''; - - // {{{ constructor - /** - * Archive_Zip Class constructor. This flavour of the constructor only - * declare a new Archive_Zip object, identifying it by the name of the - * zip file. - * - * @param string $p_zipname The name of the zip archive to create - * @access public - */ - function __construct($p_zipname) - { - if (!extension_loaded('zlib')) { - throw new Exception("The extension 'zlib' couldn't be found.\n". - "Please make sure your version of PHP was built ". - "with 'zlib' support."); - } - - // ----- Set the attributes - $this->_zipname = $p_zipname; - $this->_zip_fd = 0; - } - // }}} - - // {{{ create() - /** - * This method creates a Zip Archive with the filename set with - * the constructor. - * The files and directories indicated in $p_filelist - * are added in the archive. - * When a directory is in the list, the directory and its content is added - * in the archive. - * The methods takes a variable list of parameters in $p_params. - * The supported parameters for this method are : - * 'add_path' : Add a path to the archived files. - * 'remove_path' : Remove the specified 'root' path of the archived files. - * 'remove_all_path' : Remove all the path of the archived files. - * 'no_compression' : The archived files will not be compressed. - * - * @access public - * @param mixed $p_filelist The list of the files or folders to add. - * It can be a string with filenames separated - * by a comma, or an array of filenames. - * @param mixed $p_params An array of variable parameters and values. - * @return mixed An array of file description on success, - * an error code on error - */ - function create($p_filelist, $p_params=0) - { - $this->_errorReset(); - - // ----- Set default values - if ($p_params === 0) { - $p_params = array(); - } - if ($this->_check_parameters($p_params, - array('no_compression' => false, - 'add_path' => "", - 'remove_path' => "", - 'remove_all_path' => false)) != 1) { - return 0; - } - - // ----- Look if the $p_filelist is really an array - $p_result_list = array(); - if (is_array($p_filelist)) { - $v_result = $this->_create($p_filelist, $p_result_list, $p_params); - } - - // ----- Look if the $p_filelist is a string - else if (is_string($p_filelist)) { - // ----- Create a list with the elements from the string - $v_list = explode(ARCHIVE_ZIP_SEPARATOR, $p_filelist); - - $v_result = $this->_create($v_list, $p_result_list, $p_params); - } - - // ----- Invalid variable - else { - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, - 'Invalid variable type p_filelist'); - $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; - } - - if ($v_result != 1) { - return 0; - } - - return $p_result_list; - } - // }}} - - // {{{ add() - /** - * This method add files or directory in an existing Zip Archive. - * If the Zip Archive does not exist it is created. - * The files and directories to add are indicated in $p_filelist. - * When a directory is in the list, the directory and its content is added - * in the archive. - * The methods takes a variable list of parameters in $p_params. - * The supported parameters for this method are : - * 'add_path' : Add a path to the archived files. - * 'remove_path' : Remove the specified 'root' path of the archived files. - * 'remove_all_path' : Remove all the path of the archived files. - * 'no_compression' : The archived files will not be compressed. - * 'callback_pre_add' : A callback function that will be called before - * each entry archiving. - * 'callback_post_add' : A callback function that will be called after - * each entry archiving. - * - * @access public - * @param mixed $p_filelist The list of the files or folders to add. - * It can be a string with filenames separated - * by a comma, or an array of filenames. - * @param mixed $p_params An array of variable parameters and values. - * @return mixed An array of file description on success, - * 0 on an unrecoverable failure, an error code is logged. - */ - function add($p_filelist, $p_params=0) - { - $this->_errorReset(); - - // ----- Set default values - if ($p_params === 0) { - $p_params = array(); - } - if ($this->_check_parameters($p_params, - array ('no_compression' => false, - 'add_path' => '', - 'remove_path' => '', - 'remove_all_path' => false, - 'callback_pre_add' => '', - 'callback_post_add' => '')) != 1) { - return 0; - } - - // ----- Look if the $p_filelist is really an array - $p_result_list = array(); - if (is_array($p_filelist)) { - // ----- Call the create fct - $v_result = $this->_add($p_filelist, $p_result_list, $p_params); - } - - // ----- Look if the $p_filelist is a string - else if (is_string($p_filelist)) { - // ----- Create a list with the elements from the string - $v_list = explode(ARCHIVE_ZIP_SEPARATOR, $p_filelist); - - // ----- Call the create fct - $v_result = $this->_add($v_list, $p_result_list, $p_params); - } - - // ----- Invalid variable - else { - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, - "add() : Invalid variable type p_filelist"); - $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; - } - - if ($v_result != 1) { - return 0; - } - - // ----- Return the result list - return $p_result_list; - } - // }}} - - // {{{ listContent() - /** - * This method gives the names and properties of the files and directories - * which are present in the zip archive. - * The properties of each entries in the list are : - * filename : Name of the file. - * For create() or add() it's the filename given by the user. - * For an extract() it's the filename of the extracted file. - * stored_filename : Name of the file / directory stored in the archive. - * size : Size of the stored file. - * compressed_size : Size of the file's data compressed in the archive - * (without the zip headers overhead) - * mtime : Last known modification date of the file (UNIX timestamp) - * comment : Comment associated with the file - * folder : true | false (indicates if the entry is a folder) - * index : index of the file in the archive (-1 when not available) - * status : status of the action on the entry (depending of the action) : - * Values are : - * ok : OK ! - * filtered : the file/dir was not extracted (filtered by user) - * already_a_directory : the file can't be extracted because a - * directory with the same name already - * exists - * write_protected : the file can't be extracted because a file - * with the same name already exists and is - * write protected - * newer_exist : the file was not extracted because a newer - * file already exists - * path_creation_fail : the file is not extracted because the - * folder does not exists and can't be - * created - * write_error : the file was not extracted because there was a - * error while writing the file - * read_error : the file was not extracted because there was a - * error while reading the file - * invalid_header : the file was not extracted because of an - * archive format error (bad file header) - * Note that each time a method can continue operating when there - * is an error on a single file, the error is only logged in the file status. - * - * @access public - * @return mixed An array of file description on success, - * 0 on an unrecoverable failure, an error code is logged. - */ - function listContent() - { - $this->_errorReset(); - - // ----- Check archive - if (!$this->_checkFormat()) { - return(0); - } - - $v_list = array(); - if ($this->_list($v_list) != 1) { - unset($v_list); - return(0); - } - - return $v_list; - } - // }}} - - // {{{ extract() - /** - * This method extract the files and folders which are in the zip archive. - * It can extract all the archive or a part of the archive by using filter - * feature (extract by name, by index, by ereg, by preg). The extraction - * can occur in the current path or an other path. - * All the advanced features are activated by the use of variable - * parameters. - * The return value is an array of entry descriptions which gives - * information on extracted files (See listContent()). - * The method may return a success value (an array) even if some files - * are not correctly extracted (see the file status in listContent()). - * The supported variable parameters for this method are : - * 'add_path' : Path where the files and directories are to be extracted - * 'remove_path' : First part ('root' part) of the memorized path - * (if similar) to remove while extracting. - * 'remove_all_path' : Remove all the memorized path while extracting. - * 'extract_as_string' : - * 'set_chmod' : After the extraction of the file the indicated mode - * will be set. - * 'by_name' : It can be a string with file/dir names separated by ',', - * or an array of file/dir names to extract from the archive. - * 'by_index' : A string with range of indexes separated by ',', - * (sample "1,3-5,12"). - * 'by_ereg' : A regular expression (ereg) that must match the extracted - * filename. - * 'by_preg' : A regular expression (preg) that must match the extracted - * filename. - * 'callback_pre_extract' : A callback function that will be called before - * each entry extraction. - * 'callback_post_extract' : A callback function that will be called after - * each entry extraction. - * - * @access public - * @param mixed $p_params An array of variable parameters and values. - * @return mixed An array of file description on success, - * 0 on an unrecoverable failure, an error code is logged. - */ - function extract($p_params=0) - { - - $this->_errorReset(); - - // ----- Check archive - if (!$this->_checkFormat()) { - return(0); - } - - // ----- Set default values - if ($p_params === 0) { - $p_params = array(); - } - if ($this->_check_parameters($p_params, - array ('extract_as_string' => false, - 'add_path' => '', - 'remove_path' => '', - 'remove_all_path' => false, - 'callback_pre_extract' => '', - 'callback_post_extract' => '', - 'set_chmod' => 0, - 'by_name' => '', - 'by_index' => '', - 'by_ereg' => '', - 'by_preg' => '') ) != 1) { - return 0; - } - - // ----- Call the extracting fct - $v_list = array(); - if ($this->_extractByRule($v_list, $p_params) != 1) { - unset($v_list); - return(0); - } - - return $v_list; - } - // }}} - - - // {{{ delete() - /** - * This methods delete archive entries in the zip archive. - * Notice that at least one filtering rule (set by the variable parameter - * list) must be set. - * Also notice that if you delete a folder entry, only the folder entry - * is deleted, not all the files bellonging to this folder. - * The supported variable parameters for this method are : - * 'by_name' : It can be a string with file/dir names separated by ',', - * or an array of file/dir names to delete from the archive. - * 'by_index' : A string with range of indexes separated by ',', - * (sample "1,3-5,12"). - * 'by_ereg' : A regular expression (ereg) that must match the extracted - * filename. - * 'by_preg' : A regular expression (preg) that must match the extracted - * filename. - * - * @access public - * @param mixed $p_params An array of variable parameters and values. - * @return mixed An array of file description on success, - * 0 on an unrecoverable failure, an error code is logged. - */ - function delete($p_params) - { - $this->_errorReset(); - - // ----- Check archive - if (!$this->_checkFormat()) { - return(0); - } - - // ----- Set default values - if ($this->_check_parameters($p_params, - array ('by_name' => '', - 'by_index' => '', - 'by_ereg' => '', - 'by_preg' => '') ) != 1) { - return 0; - } - - // ----- Check that at least one rule is set - if ( ($p_params['by_name'] == '') - && ($p_params['by_index'] == '') - && ($p_params['by_ereg'] == '') - && ($p_params['by_preg'] == '')) { - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, - 'At least one filtering rule must' - .' be set as parameter'); - return 0; - } - - // ----- Call the delete fct - $v_list = array(); - if ($this->_deleteByRule($v_list, $p_params) != 1) { - unset($v_list); - return(0); - } - - return $v_list; - } - // }}} - - // {{{ properties() - /** - * This method gives the global properties of the archive. - * The properties are : - * nb : Number of files in the archive - * comment : Comment associated with the archive file - * status : not_exist, ok - * - * @access public - * @param mixed $p_params {Description} - * @return mixed An array with the global properties or 0 on error. - */ - function properties() - { - $this->_errorReset(); - - // ----- Check archive - if (!$this->_checkFormat()) { - return(0); - } - - // ----- Default properties - $v_prop = array(); - $v_prop['comment'] = ''; - $v_prop['nb'] = 0; - $v_prop['status'] = 'not_exist'; - - // ----- Look if file exists - if (@is_file($this->_zipname)) { - // ----- Open the zip file - if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) { - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, - 'Unable to open archive \''.$this->_zipname - .'\' in binary read mode'); - return 0; - } - - // ----- Read the central directory informations - $v_central_dir = array(); - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { - return 0; - } - - $this->_closeFd(); - - // ----- Set the user attributes - $v_prop['comment'] = $v_central_dir['comment']; - $v_prop['nb'] = $v_central_dir['entries']; - $v_prop['status'] = 'ok'; - } - - return $v_prop; - } - // }}} - - - // {{{ duplicate() - /** - * This method creates an archive by copying the content of an other one. - * If the archive already exist, it is replaced by the new one without - * any warning. - * - * @access public - * @param mixed $p_archive It can be a valid Archive_Zip object or - * the filename of a valid zip archive. - * @return integer 1 on success, 0 on failure. - */ - function duplicate($p_archive) - { - $this->_errorReset(); - - // ----- Look if the $p_archive is a Archive_Zip object - if ( (is_object($p_archive)) - && (strtolower(get_class($p_archive)) == 'archive_zip')) { - $v_result = $this->_duplicate($p_archive->_zipname); - } - - // ----- Look if the $p_archive is a string (so a filename) - else if (is_string($p_archive)) { - // ----- Check that $p_archive is a valid zip file - // TBC : Should also check the archive format - if (!is_file($p_archive)) { - $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, - "No file with filename '".$p_archive."'"); - $v_result = ARCHIVE_ZIP_ERR_MISSING_FILE; - } - else { - $v_result = $this->_duplicate($p_archive); - } - } - - // ----- Invalid variable - else { - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, - "Invalid variable type p_archive_to_add"); - $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; - } - - return $v_result; - } - // }}} - - // {{{ merge() - /** - * This method merge a valid zip archive at the end of the - * archive identified by the Archive_Zip object. - * If the archive ($this) does not exist, the merge becomes a duplicate. - * If the archive to add does not exist, the merge is a success. - * - * @access public - * @param mixed $p_archive_to_add It can be a valid Archive_Zip object or - * the filename of a valid zip archive. - * @return integer 1 on success, 0 on failure. - */ - function merge($p_archive_to_add) - { - $v_result = 1; - $this->_errorReset(); - - // ----- Check archive - if (!$this->_checkFormat()) { - return(0); - } - - // ----- Look if the $p_archive_to_add is a Archive_Zip object - if ( (is_object($p_archive_to_add)) - && (strtolower(get_class($p_archive_to_add)) == 'archive_zip')) { - $v_result = $this->_merge($p_archive_to_add); - } - - // ----- Look if the $p_archive_to_add is a string (so a filename) - else if (is_string($p_archive_to_add)) { - // ----- Create a temporary archive - $v_object_archive = new Archive_Zip($p_archive_to_add); - - // ----- Merge the archive - $v_result = $this->_merge($v_object_archive); - } - - // ----- Invalid variable - else { - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, - "Invalid variable type p_archive_to_add"); - $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; - } - - return $v_result; - } - // }}} - - // {{{ errorCode() - /** - * Method that gives the lastest error code. - * - * @access public - * @return integer The error code value. - */ - function errorCode() - { - return($this->_error_code); - } - // }}} - - // {{{ errorName() - /** - * This method gives the latest error code name. - * - * @access public - * @param boolean $p_with_code If true, gives the name and the int value. - * @return string The error name. - */ - function errorName($p_with_code=false) - { - $v_const_list = get_defined_constants(); - - // ----- Extract error constants from all const. - for (reset($v_const_list); - list($v_key, $v_value) = each($v_const_list);) { - if (substr($v_key, 0, strlen('ARCHIVE_ZIP_ERR_')) - =='ARCHIVE_ZIP_ERR_') { - $v_error_list[$v_key] = $v_value; - } - } - - // ----- Search the name form the code value - $v_key=array_search($this->_error_code, $v_error_list, true); - if ($v_key!=false) { - $v_value = $v_key; - } - else { - $v_value = 'NoName'; - } - - if ($p_with_code) { - return($v_value.' ('.$this->_error_code.')'); - } - else { - return($v_value); - } - } - // }}} - - // {{{ errorInfo() - /** - * This method returns the description associated with the latest error. - * - * @access public - * @param boolean $p_full If set to true gives the description with the - * error code, the name and the description. - * If set to false gives only the description - * and the error code. - * @return string The error description. - */ - function errorInfo($p_full=false) - { - if ($p_full) { - return($this->errorName(true)." : ".$this->_error_string); - } - else { - return($this->_error_string." [code ".$this->_error_code."]"); - } - } - // }}} - - -// ----------------------------------------------------------------------------- -// ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS ***** -// ***** ***** -// ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** -// ----------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _checkFormat() - // Description : - // This method check that the archive exists and is a valid zip archive. - // Several level of check exists. (futur) - // Parameters : - // $p_level : Level of check. Default 0. - // 0 : Check the first bytes (magic codes) (default value)) - // 1 : 0 + Check the central directory (futur) - // 2 : 1 + Check each file header (futur) - // Return Values : - // true on success, - // false on error, the error code is set. - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_checkFormat() - * - * { Description } - * - * @param integer $p_level - */ - function _checkFormat($p_level=0) - { - $v_result = true; - - // ----- Reset the error handler - $this->_errorReset(); - - // ----- Look if the file exits - if (!is_file($this->_zipname)) { - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, - "Missing archive file '".$this->_zipname."'"); - return(false); - } - - // ----- Check that the file is readeable - if (!is_readable($this->_zipname)) { - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, - "Unable to read archive '".$this->_zipname."'"); - return(false); - } - - // ----- Check the magic code - // TBC - - // ----- Check the central header - // TBC - - // ----- Check each file header - // TBC - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _create() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_create() - * - * { Description } - * - */ - function _create($p_list, &$p_result_list, &$p_params) - { - $v_result=1; - $v_list_detail = array(); - - $p_add_dir = $p_params['add_path']; - $p_remove_dir = $p_params['remove_path']; - $p_remove_all_dir = $p_params['remove_all_path']; - - // ----- Open the file in write mode - if (($v_result = $this->_openFd('wb')) != 1) - { - // ----- Return - return $v_result; - } - - // ----- Add the list of files - $v_result = $this->_addList($p_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params); - - // ----- Close - $this->_closeFd(); - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _add() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_add() - * - * { Description } - * - */ - function _add($p_list, &$p_result_list, &$p_params) - { - $v_result=1; - $v_list_detail = array(); - - $p_add_dir = $p_params['add_path']; - $p_remove_dir = $p_params['remove_path']; - $p_remove_all_dir = $p_params['remove_all_path']; - - // ----- Look if the archive exists or is empty and need to be created - if ((!is_file($this->_zipname)) || (filesize($this->_zipname) == 0)) { - $v_result = $this->_create($p_list, $p_result_list, $p_params); - return $v_result; - } - - // ----- Open the zip file - if (($v_result=$this->_openFd('rb')) != 1) { - return $v_result; - } - - // ----- Read the central directory informations - $v_central_dir = array(); - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) - { - $this->_closeFd(); - return $v_result; - } - - // ----- Go to beginning of File - @rewind($this->_zip_fd); - - // ----- Creates a temporay file - $v_zip_temp_name = ARCHIVE_ZIP_TEMPORARY_DIR.uniqid('archive_zip-').'.tmp'; - - // ----- Open the temporary file in write mode - if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) - { - $this->_closeFd(); - - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, - 'Unable to open temporary file \'' - .$v_zip_temp_name.'\' in binary write mode'); - return Archive_Zip::errorCode(); - } - - // ----- Copy the files from the archive to the temporary file - // TBC : Here I should better append the file and go back to erase the - // central dir - $v_size = $v_central_dir['offset']; - while ($v_size != 0) - { - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = fread($this->_zip_fd, $v_read_size); - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); - $v_size -= $v_read_size; - } - - // ----- Swap the file descriptor - // Here is a trick : I swap the temporary fd with the zip fd, in order to - // use the following methods on the temporary fil and not the real archive - $v_swap = $this->_zip_fd; - $this->_zip_fd = $v_zip_temp_fd; - $v_zip_temp_fd = $v_swap; - - // ----- Add the files - $v_header_list = array(); - if (($v_result = $this->_addFileList($p_list, $v_header_list, - $p_add_dir, $p_remove_dir, - $p_remove_all_dir, $p_params)) != 1) - { - fclose($v_zip_temp_fd); - $this->_closeFd(); - @unlink($v_zip_temp_name); - - // ----- Return - return $v_result; - } - - // ----- Store the offset of the central dir - $v_offset = @ftell($this->_zip_fd); - - // ----- Copy the block of file headers from the old archive - $v_size = $v_central_dir['size']; - while ($v_size != 0) - { - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = @fread($v_zip_temp_fd, $v_read_size); - @fwrite($this->_zip_fd, $v_buffer, $v_read_size); - $v_size -= $v_read_size; - } - - // ----- Create the Central Dir files header - for ($i=0, $v_count=0; $i_writeCentralFileHeader($v_header_list[$i]))!=1) { - fclose($v_zip_temp_fd); - $this->_closeFd(); - @unlink($v_zip_temp_name); - - // ----- Return - return $v_result; - } - $v_count++; - } - - // ----- Transform the header to a 'usable' info - $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); - } - - // ----- Zip file comment - $v_comment = ''; - - // ----- Calculate the size of the central header - $v_size = @ftell($this->_zip_fd)-$v_offset; - - // ----- Create the central dir footer - if (($v_result = $this->_writeCentralHeader($v_count - +$v_central_dir['entries'], - $v_size, $v_offset, - $v_comment)) != 1) { - // ----- Reset the file list - unset($v_header_list); - - // ----- Return - return $v_result; - } - - // ----- Swap back the file descriptor - $v_swap = $this->_zip_fd; - $this->_zip_fd = $v_zip_temp_fd; - $v_zip_temp_fd = $v_swap; - - // ----- Close - $this->_closeFd(); - - // ----- Close the temporary file - @fclose($v_zip_temp_fd); - - // ----- Delete the zip file - // TBC : I should test the result ... - @unlink($this->_zipname); - - // ----- Rename the temporary file - // TBC : I should test the result ... - //@rename($v_zip_temp_name, $this->_zipname); - $this->_tool_Rename($v_zip_temp_name, $this->_zipname); - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _openFd() - // Description : - // Parameters : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_openFd() - * - * { Description } - * - */ - function _openFd($p_mode) - { - $v_result=1; - - // ----- Look if already open - if ($this->_zip_fd != 0) - { - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, - 'Zip file \''.$this->_zipname.'\' already open'); - return Archive_Zip::errorCode(); - } - - // ----- Open the zip file - if (($this->_zip_fd = @fopen($this->_zipname, $p_mode)) == 0) - { - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, - 'Unable to open archive \''.$this->_zipname - .'\' in '.$p_mode.' mode'); - return Archive_Zip::errorCode(); - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _closeFd() - // Description : - // Parameters : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_closeFd() - * - * { Description } - * - */ - function _closeFd() - { - $v_result=1; - - if ($this->_zip_fd != 0) - @fclose($this->_zip_fd); - $this->_zip_fd = 0; - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _addList() - // Description : - // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is - // different from the real path of the file. This is usefull if you want to have PclTar - // running in any directory, and memorize relative path from an other directory. - // Parameters : - // $p_list : An array containing the file or directory names to add in the tar - // $p_result_list : list of added files with their properties (specially the status field) - // $p_add_dir : Path to add in the filename path archived - // $p_remove_dir : Path to remove in the filename path archived - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_addList() - * - * { Description } - * - */ - function _addList($p_list, &$p_result_list, - $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) - { - $v_result=1; - - // ----- Add the files - $v_header_list = array(); - if (($v_result = $this->_addFileList($p_list, $v_header_list, - $p_add_dir, $p_remove_dir, - $p_remove_all_dir, $p_params)) != 1) { - return $v_result; - } - - // ----- Store the offset of the central dir - $v_offset = @ftell($this->_zip_fd); - - // ----- Create the Central Dir files header - for ($i=0,$v_count=0; $i_writeCentralFileHeader($v_header_list[$i])) != 1) { - return $v_result; - } - $v_count++; - } - - // ----- Transform the header to a 'usable' info - $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); - } - - // ----- Zip file comment - $v_comment = ''; - - // ----- Calculate the size of the central header - $v_size = @ftell($this->_zip_fd)-$v_offset; - - // ----- Create the central dir footer - if (($v_result = $this->_writeCentralHeader($v_count, $v_size, $v_offset, - $v_comment)) != 1) - { - // ----- Reset the file list - unset($v_header_list); - - // ----- Return - return $v_result; - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _addFileList() - // Description : - // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is - // different from the real path of the file. This is usefull if you want to - // run the lib in any directory, and memorize relative path from an other directory. - // Parameters : - // $p_list : An array containing the file or directory names to add in the tar - // $p_result_list : list of added files with their properties (specially the status field) - // $p_add_dir : Path to add in the filename path archived - // $p_remove_dir : Path to remove in the filename path archived - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_addFileList() - * - * { Description } - * - */ - function _addFileList($p_list, &$p_result_list, - $p_add_dir, $p_remove_dir, $p_remove_all_dir, - &$p_params) - { - $v_result=1; - $v_header = array(); - - // ----- Recuperate the current number of elt in list - $v_nb = sizeof($p_result_list); - - // ----- Loop on the files - for ($j=0; ($j_tool_TranslateWinPath($p_list[$j], false); - - // ----- Skip empty file names - if ($p_filename == "") - { - continue; - } - - // ----- Check the filename - if (!file_exists($p_filename)) - { - $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, - "File '$p_filename' does not exists"); - return Archive_Zip::errorCode(); - } - - // ----- Look if it is a file or a dir with no all pathnre move - if ((is_file($p_filename)) || ((is_dir($p_filename)) && !$p_remove_all_dir)) { - // ----- Add the file - if (($v_result = $this->_addFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params)) != 1) - { - // ----- Return status - return $v_result; - } - - // ----- Store the file infos - $p_result_list[$v_nb++] = $v_header; - } - - // ----- Look for directory - if (is_dir($p_filename)) - { - - // ----- Look for path - if ($p_filename != ".") - $v_path = $p_filename."/"; - else - $v_path = ""; - - // ----- Read the directory for files and sub-directories - $p_hdir = opendir($p_filename); - $p_hitem = readdir($p_hdir); // '.' directory - $p_hitem = readdir($p_hdir); // '..' directory - while ($p_hitem = readdir($p_hdir)) - { - - // ----- Look for a file - if (is_file($v_path.$p_hitem)) - { - - // ----- Add the file - if (($v_result = $this->_addFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params)) != 1) - { - // ----- Return status - return $v_result; - } - - // ----- Store the file infos - $p_result_list[$v_nb++] = $v_header; - } - - // ----- Recursive call to _addFileList() - else - { - - // ----- Need an array as parameter - $p_temp_list[0] = $v_path.$p_hitem; - $v_result = $this->_addFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params); - - // ----- Update the number of elements of the list - $v_nb = sizeof($p_result_list); - } - } - - // ----- Free memory for the recursive loop - unset($p_temp_list); - unset($p_hdir); - unset($p_hitem); - } - } - - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _addFile() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_addFile() - * - * { Description } - * - */ - function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) - { - $v_result=1; - - if ($p_filename == "") - { - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); - - // ----- Return - return Archive_Zip::errorCode(); - } - - // ----- Calculate the stored filename - $v_stored_filename = $p_filename; - - // ----- Look for all path to remove - if ($p_remove_all_dir) { - $v_stored_filename = basename($p_filename); - } - // ----- Look for partial path remove - else if ($p_remove_dir != "") - { - if (substr($p_remove_dir, -1) != '/') - $p_remove_dir .= "/"; - - if ((substr($p_filename, 0, 2) == "./") || (substr($p_remove_dir, 0, 2) == "./")) - { - if ((substr($p_filename, 0, 2) == "./") && (substr($p_remove_dir, 0, 2) != "./")) - $p_remove_dir = "./".$p_remove_dir; - if ((substr($p_filename, 0, 2) != "./") && (substr($p_remove_dir, 0, 2) == "./")) - $p_remove_dir = substr($p_remove_dir, 2); - } - - $v_compare = $this->_tool_PathInclusion($p_remove_dir, $p_filename); - if ($v_compare > 0) -// if (substr($p_filename, 0, strlen($p_remove_dir)) == $p_remove_dir) - { - - if ($v_compare == 2) { - $v_stored_filename = ""; - } - else { - $v_stored_filename = substr($p_filename, strlen($p_remove_dir)); - } - } - } - // ----- Look for path to add - if ($p_add_dir != "") - { - if (substr($p_add_dir, -1) == "/") - $v_stored_filename = $p_add_dir.$v_stored_filename; - else - $v_stored_filename = $p_add_dir."/".$v_stored_filename; - } - - // ----- Filename (reduce the path of stored name) - $v_stored_filename = $this->_tool_PathReduction($v_stored_filename); - - - /* filename length moved after call-back in release 1.3 - // ----- Check the path length - if (strlen($v_stored_filename) > 0xFF) - { - // ----- Error log - $this->_errorLog(-5, "Stored file name is too long (max. 255) : '$v_stored_filename'"); - - // ----- Return - return Archive_Zip::errorCode(); - } - */ - - // ----- Set the file properties - clearstatcache(); - $p_header['version'] = 20; - $p_header['version_extracted'] = 10; - $p_header['flag'] = 0; - $p_header['compression'] = 0; - $p_header['mtime'] = filemtime($p_filename); - $p_header['crc'] = 0; - $p_header['compressed_size'] = 0; - $p_header['size'] = filesize($p_filename); - $p_header['filename_len'] = strlen($p_filename); - $p_header['extra_len'] = 0; - $p_header['comment_len'] = 0; - $p_header['disk'] = 0; - $p_header['internal'] = 0; - $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); - $p_header['offset'] = 0; - $p_header['filename'] = $p_filename; - $p_header['stored_filename'] = $v_stored_filename; - $p_header['extra'] = ''; - $p_header['comment'] = ''; - $p_header['status'] = 'ok'; - $p_header['index'] = -1; - - // ----- Look for pre-add callback - if ( (isset($p_params[ARCHIVE_ZIP_PARAM_PRE_ADD])) - && ($p_params[ARCHIVE_ZIP_PARAM_PRE_ADD] != '')) { - - // ----- Generate a local information - $v_local_header = array(); - $this->_convertHeader2FileInfo($p_header, $v_local_header); - - // ----- Call the callback - // Here I do not use call_user_func() because I need to send a reference to the - // header. - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_ADD].'(ARCHIVE_ZIP_PARAM_PRE_ADD, $v_local_header);'); - if ($v_result == 0) { - // ----- Change the file status - $p_header['status'] = "skipped"; - $v_result = 1; - } - - // ----- Update the informations - // Only some fields can be modified - if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { - $p_header['stored_filename'] = $this->_tool_PathReduction($v_local_header['stored_filename']); - } - } - - // ----- Look for empty stored filename - if ($p_header['stored_filename'] == "") { - $p_header['status'] = "filtered"; - } - - // ----- Check the path length - if (strlen($p_header['stored_filename']) > 0xFF) { - $p_header['status'] = 'filename_too_long'; - } - - // ----- Look if no error, or file not skipped - if ($p_header['status'] == 'ok') { - - // ----- Look for a file - if (is_file($p_filename)) - { - // ----- Open the source file - if (($v_file = @fopen($p_filename, "rb")) == 0) { - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); - return Archive_Zip::errorCode(); - } - - if ($p_params['no_compression']) { - // ----- Read the file content - $v_content_compressed = @fread($v_file, $p_header['size']); - - // ----- Calculate the CRC - $p_header['crc'] = crc32($v_content_compressed); - } - else { - // ----- Read the file content - $v_content = @fread($v_file, $p_header['size']); - - // ----- Calculate the CRC - $p_header['crc'] = crc32($v_content); - - // ----- Compress the file - $v_content_compressed = gzdeflate($v_content); - } - - // ----- Set header parameters - $p_header['compressed_size'] = strlen($v_content_compressed); - $p_header['compression'] = 8; - - // ----- Call the header generation - if (($v_result = $this->_writeFileHeader($p_header)) != 1) { - @fclose($v_file); - return $v_result; - } - - // ----- Write the compressed content - $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed); - @fwrite($this->_zip_fd, $v_binary_data, $p_header['compressed_size']); - - // ----- Close the file - @fclose($v_file); - } - - // ----- Look for a directory - else - { - // ----- Set the file properties - $p_header['filename'] .= '/'; - $p_header['filename_len']++; - $p_header['size'] = 0; - $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked - - // ----- Call the header generation - if (($v_result = $this->_writeFileHeader($p_header)) != 1) - { - return $v_result; - } - } - } - - // ----- Look for pre-add callback - if ( (isset($p_params[ARCHIVE_ZIP_PARAM_POST_ADD])) - && ($p_params[ARCHIVE_ZIP_PARAM_POST_ADD] != '')) { - - // ----- Generate a local information - $v_local_header = array(); - $this->_convertHeader2FileInfo($p_header, $v_local_header); - - // ----- Call the callback - // Here I do not use call_user_func() because I need to send a reference to the - // header. - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_ADD].'(ARCHIVE_ZIP_PARAM_POST_ADD, $v_local_header);'); - if ($v_result == 0) { - // ----- Ignored - $v_result = 1; - } - - // ----- Update the informations - // Nothing can be modified - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _writeFileHeader() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_writeFileHeader() - * - * { Description } - * - */ - function _writeFileHeader(&$p_header) - { - $v_result=1; - - // TBC - //for(reset($p_header); $key = key($p_header); next($p_header)) { - //} - - // ----- Store the offset position of the file - $p_header['offset'] = ftell($this->_zip_fd); - - // ----- Transform UNIX mtime to DOS format mdate/mtime - $v_date = getdate($p_header['mtime']); - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; - - // ----- Packed data - $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version'], $p_header['flag'], - $p_header['compression'], $v_mtime, $v_mdate, - $p_header['crc'], $p_header['compressed_size'], $p_header['size'], - strlen($p_header['stored_filename']), $p_header['extra_len']); - - // ----- Write the first 148 bytes of the header in the archive - fputs($this->_zip_fd, $v_binary_data, 30); - - // ----- Write the variable fields - if (strlen($p_header['stored_filename']) != 0) - { - fputs($this->_zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); - } - if ($p_header['extra_len'] != 0) - { - fputs($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _writeCentralFileHeader() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_writeCentralFileHeader() - * - * { Description } - * - */ - function _writeCentralFileHeader(&$p_header) - { - $v_result=1; - - // TBC - //for(reset($p_header); $key = key($p_header); next($p_header)) { - //} - - // ----- Transform UNIX mtime to DOS format mdate/mtime - $v_date = getdate($p_header['mtime']); - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; - - // ----- Packed data - $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'], - $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], - $p_header['compressed_size'], $p_header['size'], - strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], - $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']); - - // ----- Write the 42 bytes of the header in the zip file - fputs($this->_zip_fd, $v_binary_data, 46); - - // ----- Write the variable fields - if (strlen($p_header['stored_filename']) != 0) - { - fputs($this->_zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); - } - if ($p_header['extra_len'] != 0) - { - fputs($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); - } - if ($p_header['comment_len'] != 0) - { - fputs($this->_zip_fd, $p_header['comment'], $p_header['comment_len']); - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _writeCentralHeader() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_writeCentralHeader() - * - * { Description } - * - */ - function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) - { - $v_result=1; - - // ----- Packed data - $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment)); - - // ----- Write the 22 bytes of the header in the zip file - fputs($this->_zip_fd, $v_binary_data, 22); - - // ----- Write the variable fields - if (strlen($p_comment) != 0) - { - fputs($this->_zip_fd, $p_comment, strlen($p_comment)); - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _list() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_list() - * - * { Description } - * - */ - function _list(&$p_list) - { - $v_result=1; - - // ----- Open the zip file - if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) - { - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->_zipname.'\' in binary read mode'); - - // ----- Return - return Archive_Zip::errorCode(); - } - - // ----- Read the central directory informations - $v_central_dir = array(); - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) - { - return $v_result; - } - - // ----- Go to beginning of Central Dir - @rewind($this->_zip_fd); - if (@fseek($this->_zip_fd, $v_central_dir['offset'])) - { - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); - - // ----- Return - return Archive_Zip::errorCode(); - } - - // ----- Read each entry - for ($i=0; $i<$v_central_dir['entries']; $i++) - { - // ----- Read the file header - if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) - { - return $v_result; - } - $v_header['index'] = $i; - - // ----- Get the only interesting attributes - $this->_convertHeader2FileInfo($v_header, $p_list[$i]); - unset($v_header); - } - - // ----- Close the zip file - $this->_closeFd(); - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _convertHeader2FileInfo() - // Description : - // This function takes the file informations from the central directory - // entries and extract the interesting parameters that will be given back. - // The resulting file infos are set in the array $p_info - // $p_info['filename'] : Filename with full path. Given by user (add), - // extracted in the filesystem (extract). - // $p_info['stored_filename'] : Stored filename in the archive. - // $p_info['size'] = Size of the file. - // $p_info['compressed_size'] = Compressed size of the file. - // $p_info['mtime'] = Last modification date of the file. - // $p_info['comment'] = Comment associated with the file. - // $p_info['folder'] = true/false : indicates if the entry is a folder or not. - // $p_info['status'] = status of the action on the file. - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_convertHeader2FileInfo() - * - * { Description } - * - */ - function _convertHeader2FileInfo($p_header, &$p_info) - { - $v_result=1; - - // ----- Get the interesting attributes - $p_info['filename'] = $p_header['filename']; - $p_info['stored_filename'] = $p_header['stored_filename']; - $p_info['size'] = $p_header['size']; - $p_info['compressed_size'] = $p_header['compressed_size']; - $p_info['mtime'] = $p_header['mtime']; - $p_info['comment'] = $p_header['comment']; - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); - $p_info['index'] = $p_header['index']; - $p_info['status'] = $p_header['status']; - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _extractByRule() - // Description : - // Extract a file or directory depending of rules (by index, by name, ...) - // Parameters : - // $p_file_list : An array where will be placed the properties of each - // extracted file - // $p_path : Path to add while writing the extracted files - // $p_remove_path : Path to remove (from the file memorized path) while writing the - // extracted files. If the path does not match the file path, - // the file is extracted with its memorized path. - // $p_remove_path does not apply to 'list' mode. - // $p_path and $p_remove_path are commulative. - // Return Values : - // 1 on success,0 or less on error (see error code list) - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_extractByRule() - * - * { Description } - * - */ - function _extractByRule(&$p_file_list, &$p_params) - { - $v_result=1; - - $p_path = $p_params['add_path']; - $p_remove_path = $p_params['remove_path']; - $p_remove_all_path = $p_params['remove_all_path']; - - // ----- Check the path - if (($p_path == "") - || ((substr($p_path, 0, 1) != "/") - && (substr($p_path, 0, 3) != "../") && (substr($p_path,1,2)!=":/"))) - $p_path = "./".$p_path; - - // ----- Reduce the path last (and duplicated) '/' - if (($p_path != "./") && ($p_path != "/")) { - // ----- Look for the path end '/' - while (substr($p_path, -1) == "/") { - $p_path = substr($p_path, 0, strlen($p_path)-1); - } - } - - // ----- Look for path to remove format (should end by /) - if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) { - $p_remove_path .= '/'; - } - $p_remove_path_size = strlen($p_remove_path); - - // ----- Open the zip file - if (($v_result = $this->_openFd('rb')) != 1) - { - return $v_result; - } - - // ----- Read the central directory informations - $v_central_dir = array(); - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) - { - // ----- Close the zip file - $this->_closeFd(); - - return $v_result; - } - - // ----- Start at beginning of Central Dir - $v_pos_entry = $v_central_dir['offset']; - - // ----- Read each entry - $j_start = 0; - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { - // ----- Read next Central dir entry - @rewind($this->_zip_fd); - if (@fseek($this->_zip_fd, $v_pos_entry)) { - $this->_closeFd(); - - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, - 'Invalid archive size'); - - return Archive_Zip::errorCode(); - } - - // ----- Read the file header - $v_header = array(); - if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { - $this->_closeFd(); - - return $v_result; - } - - // ----- Store the index - $v_header['index'] = $i; - - // ----- Store the file position - $v_pos_entry = ftell($this->_zip_fd); - - // ----- Look for the specific extract rules - $v_extract = false; - - // ----- Look for extract by name rule - if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) - && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) { - - // ----- Look if the filename is in the list - for ($j=0; - ($j strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) - && (substr($v_header['stored_filename'], 0, strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { - $v_extract = true; - } - } - // ----- Look for a filename - elseif ($v_header['stored_filename'] == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { - $v_extract = true; - } - } - } - - // ----- Look for extract by ereg rule - else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])) - && ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != "")) { - - if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], $v_header['stored_filename'])) { - $v_extract = true; - } - } - - // ----- Look for extract by preg rule - else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])) - && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != "")) { - - if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], $v_header['stored_filename'])) { - $v_extract = true; - } - } - - // ----- Look for extract by index rule - else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) - && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) { - - // ----- Look if the index is in the list - for ($j=$j_start; ($j=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { - $v_extract = true; - } - if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { - $j_start = $j+1; - } - - if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { - break; - } - } - } - - // ----- Look for no rule, which means extract all the archive - else { - $v_extract = true; - } - - - // ----- Look for real extraction - if ($v_extract) - { - - // ----- Go to the file position - @rewind($this->_zip_fd); - if (@fseek($this->_zip_fd, $v_header['offset'])) - { - // ----- Close the zip file - $this->_closeFd(); - - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); - - // ----- Return - return Archive_Zip::errorCode(); - } - - // ----- Look for extraction as string - if ($p_params[ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING]) { - - // ----- Extracting the file - if (($v_result = $this->_extractFileAsString($v_header, $v_string)) != 1) - { - // ----- Close the zip file - $this->_closeFd(); - - return $v_result; - } - - // ----- Get the only interesting attributes - if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) - { - // ----- Close the zip file - $this->_closeFd(); - - return $v_result; - } - - // ----- Set the file content - $p_file_list[$v_nb_extracted]['content'] = $v_string; - - // ----- Next extracted file - $v_nb_extracted++; - } - else { - // ----- Extracting the file - if (($v_result = $this->_extractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_params)) != 1) - { - // ----- Close the zip file - $this->_closeFd(); - - return $v_result; - } - - // ----- Get the only interesting attributes - if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) - { - // ----- Close the zip file - $this->_closeFd(); - - return $v_result; - } - } - } - } - - // ----- Close the zip file - $this->_closeFd(); - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _extractFile() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_extractFile() - * - * { Description } - * - */ - function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params) - { - $v_result=1; - - // ----- Read the file header - if (($v_result = $this->_readFileHeader($v_header)) != 1) - { - // ----- Return - return $v_result; - } - - - // ----- Check that the file header is coherent with $p_entry info - // TBC - - // ----- Look for all path to remove - if ($p_remove_all_path == true) { - // ----- Get the basename of the path - $p_entry['filename'] = basename($p_entry['filename']); - } - - // ----- Look for path to remove - else if ($p_remove_path != "") - { - //if (strcmp($p_remove_path, $p_entry['filename'])==0) - if ($this->_tool_PathInclusion($p_remove_path, $p_entry['filename']) == 2) - { - - // ----- Change the file status - $p_entry['status'] = "filtered"; - - // ----- Return - return $v_result; - } - - $p_remove_path_size = strlen($p_remove_path); - if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) - { - - // ----- Remove the path - $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size); - - } - } - - // ----- Add the path - if ($p_path != '') - { - $p_entry['filename'] = $p_path."/".$p_entry['filename']; - } - - // ----- Look for pre-extract callback - if ( (isset($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT])) - && ($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT] != '')) { - - // ----- Generate a local information - $v_local_header = array(); - $this->_convertHeader2FileInfo($p_entry, $v_local_header); - - // ----- Call the callback - // Here I do not use call_user_func() because I need to send a reference to the - // header. - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT].'(ARCHIVE_ZIP_PARAM_PRE_EXTRACT, $v_local_header);'); - if ($v_result == 0) { - // ----- Change the file status - $p_entry['status'] = "skipped"; - $v_result = 1; - } - - // ----- Update the informations - // Only some fields can be modified - $p_entry['filename'] = $v_local_header['filename']; - } - - // ----- Trace - - // ----- Look if extraction should be done - if ($p_entry['status'] == 'ok') { - - // ----- Look for specific actions while the file exist - if (file_exists($p_entry['filename'])) - { - - // ----- Look if file is a directory - if (is_dir($p_entry['filename'])) - { - - // ----- Change the file status - $p_entry['status'] = "already_a_directory"; - - // ----- Return - //return $v_result; - } - // ----- Look if file is write protected - else if (!is_writeable($p_entry['filename'])) - { - - // ----- Change the file status - $p_entry['status'] = "write_protected"; - - // ----- Return - //return $v_result; - } - - // ----- Look if the extracted file is older - else if (filemtime($p_entry['filename']) > $p_entry['mtime']) - { - - // ----- Change the file status - $p_entry['status'] = "newer_exist"; - - // ----- Return - //return $v_result; - } - } - - // ----- Check the directory availability and create it if necessary - else { - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) - $v_dir_to_check = $p_entry['filename']; - else if (!strstr($p_entry['filename'], "/")) - $v_dir_to_check = ""; - else - $v_dir_to_check = dirname($p_entry['filename']); - - if (($v_result = $this->_dirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { - - // ----- Change the file status - $p_entry['status'] = "path_creation_fail"; - - // ----- Return - //return $v_result; - $v_result = 1; - } - } - } - - // ----- Look if extraction should be done - if ($p_entry['status'] == 'ok') { - - // ----- Do the extraction (if not a folder) - if (!(($p_entry['external']&0x00000010)==0x00000010)) - { - - // ----- Look for not compressed file - if ($p_entry['compressed_size'] == $p_entry['size']) - { - - // ----- Opening destination file - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) - { - - // ----- Change the file status - $p_entry['status'] = "write_error"; - - // ----- Return - return $v_result; - } - - - // ----- Read the file by ARCHIVE_ZIP_READ_BLOCK_SIZE octets blocks - $v_size = $p_entry['compressed_size']; - while ($v_size != 0) - { - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = fread($this->_zip_fd, $v_read_size); - $v_binary_data = pack('a'.$v_read_size, $v_buffer); - @fwrite($v_dest_file, $v_binary_data, $v_read_size); - $v_size -= $v_read_size; - } - - // ----- Closing the destination file - fclose($v_dest_file); - - // ----- Change the file mtime - touch($p_entry['filename'], $p_entry['mtime']); - } - else - { - // ----- Trace - - // ----- Opening destination file - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { - - // ----- Change the file status - $p_entry['status'] = "write_error"; - - return $v_result; - } - - - // ----- Read the compressed file in a buffer (one shot) - $v_buffer = @fread($this->_zip_fd, $p_entry['compressed_size']); - - // ----- Decompress the file - $v_file_content = gzinflate($v_buffer); - unset($v_buffer); - - // ----- Write the uncompressed data - @fwrite($v_dest_file, $v_file_content, $p_entry['size']); - unset($v_file_content); - - // ----- Closing the destination file - @fclose($v_dest_file); - - // ----- Change the file mtime - touch($p_entry['filename'], $p_entry['mtime']); - } - - // ----- Look for chmod option - if ( (isset($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD])) - && ($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD] != 0)) { - - // ----- Change the mode of the file - chmod($p_entry['filename'], $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]); - } - - } - } - - // ----- Look for post-extract callback - if ( (isset($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT])) - && ($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT] != '')) { - - // ----- Generate a local information - $v_local_header = array(); - $this->_convertHeader2FileInfo($p_entry, $v_local_header); - - // ----- Call the callback - // Here I do not use call_user_func() because I need to send a reference to the - // header. - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT].'(ARCHIVE_ZIP_PARAM_POST_EXTRACT, $v_local_header);'); - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _extractFileAsString() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_extractFileAsString() - * - * { Description } - * - */ - function _extractFileAsString(&$p_entry, &$p_string) - { - $v_result=1; - - // ----- Read the file header - $v_header = array(); - if (($v_result = $this->_readFileHeader($v_header)) != 1) - { - // ----- Return - return $v_result; - } - - - // ----- Check that the file header is coherent with $p_entry info - // TBC - - // ----- Trace - - // ----- Do the extraction (if not a folder) - if (!(($p_entry['external']&0x00000010)==0x00000010)) - { - // ----- Look for not compressed file - if ($p_entry['compressed_size'] == $p_entry['size']) - { - // ----- Trace - - // ----- Reading the file - $p_string = fread($this->_zip_fd, $p_entry['compressed_size']); - } - else - { - // ----- Trace - - // ----- Reading the file - $v_data = fread($this->_zip_fd, $p_entry['compressed_size']); - - // ----- Decompress the file - $p_string = gzinflate($v_data); - } - - // ----- Trace - } - else { - // TBC : error : can not extract a folder in a string - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _readFileHeader() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_readFileHeader() - * - * { Description } - * - */ - function _readFileHeader(&$p_header) - { - $v_result=1; - - // ----- Read the 4 bytes signature - $v_binary_data = @fread($this->_zip_fd, 4); - $v_data = unpack('Vid', $v_binary_data); - - // ----- Check signature - if ($v_data['id'] != 0x04034b50) - { - - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); - - // ----- Return - return Archive_Zip::errorCode(); - } - - // ----- Read the first 42 bytes of the header - $v_binary_data = fread($this->_zip_fd, 26); - - // ----- Look for invalid block size - if (strlen($v_binary_data) != 26) - { - $p_header['filename'] = ""; - $p_header['status'] = "invalid_header"; - - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); - - // ----- Return - return Archive_Zip::errorCode(); - } - - // ----- Extract the values - $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data); - - // ----- Get filename - $p_header['filename'] = fread($this->_zip_fd, $v_data['filename_len']); - - // ----- Get extra_fields - if ($v_data['extra_len'] != 0) { - $p_header['extra'] = fread($this->_zip_fd, $v_data['extra_len']); - } - else { - $p_header['extra'] = ''; - } - - // ----- Extract properties - $p_header['compression'] = $v_data['compression']; - $p_header['size'] = $v_data['size']; - $p_header['compressed_size'] = $v_data['compressed_size']; - $p_header['crc'] = $v_data['crc']; - $p_header['flag'] = $v_data['flag']; - - // ----- Recuperate date in UNIX format - $p_header['mdate'] = $v_data['mdate']; - $p_header['mtime'] = $v_data['mtime']; - if ($p_header['mdate'] && $p_header['mtime']) - { - // ----- Extract time - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; - $v_seconde = ($p_header['mtime'] & 0x001F)*2; - - // ----- Extract date - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; - $v_day = $p_header['mdate'] & 0x001F; - - // ----- Get UNIX date format - $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); - - } - else - { - $p_header['mtime'] = time(); - } - - // ----- Other informations - - // TBC - //for(reset($v_data); $key = key($v_data); next($v_data)) { - //} - - // ----- Set the stored filename - $p_header['stored_filename'] = $p_header['filename']; - - // ----- Set the status field - $p_header['status'] = "ok"; - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _readCentralFileHeader() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_readCentralFileHeader() - * - * { Description } - * - */ - function _readCentralFileHeader(&$p_header) - { - $v_result=1; - - // ----- Read the 4 bytes signature - $v_binary_data = @fread($this->_zip_fd, 4); - $v_data = unpack('Vid', $v_binary_data); - - // ----- Check signature - if ($v_data['id'] != 0x02014b50) - { - - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); - - // ----- Return - return Archive_Zip::errorCode(); - } - - // ----- Read the first 42 bytes of the header - $v_binary_data = fread($this->_zip_fd, 42); - - // ----- Look for invalid block size - if (strlen($v_binary_data) != 42) - { - $p_header['filename'] = ""; - $p_header['status'] = "invalid_header"; - - // ----- Error log - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); - - // ----- Return - return Archive_Zip::errorCode(); - } - - // ----- Extract the values - $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data); - - // ----- Get filename - if ($p_header['filename_len'] != 0) - $p_header['filename'] = fread($this->_zip_fd, $p_header['filename_len']); - else - $p_header['filename'] = ''; - - // ----- Get extra - if ($p_header['extra_len'] != 0) - $p_header['extra'] = fread($this->_zip_fd, $p_header['extra_len']); - else - $p_header['extra'] = ''; - - // ----- Get comment - if ($p_header['comment_len'] != 0) - $p_header['comment'] = fread($this->_zip_fd, $p_header['comment_len']); - else - $p_header['comment'] = ''; - - // ----- Extract properties - - // ----- Recuperate date in UNIX format - if ($p_header['mdate'] && $p_header['mtime']) - { - // ----- Extract time - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; - $v_seconde = ($p_header['mtime'] & 0x001F)*2; - - // ----- Extract date - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; - $v_day = $p_header['mdate'] & 0x001F; - - // ----- Get UNIX date format - $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); - - } - else - { - $p_header['mtime'] = time(); - } - - // ----- Set the stored filename - $p_header['stored_filename'] = $p_header['filename']; - - // ----- Set default status to ok - $p_header['status'] = 'ok'; - - // ----- Look if it is a directory - if (substr($p_header['filename'], -1) == '/') - { - $p_header['external'] = 0x41FF0010; - } - - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _readEndCentralDir() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_readEndCentralDir() - * - * { Description } - * - */ - function _readEndCentralDir(&$p_central_dir) - { - $v_result=1; - - // ----- Go to the end of the zip file - $v_size = filesize($this->_zipname); - @fseek($this->_zip_fd, $v_size); - if (@ftell($this->_zip_fd) != $v_size) { - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, - 'Unable to go to the end of the archive \'' - .$this->_zipname.'\''); - return Archive_Zip::errorCode(); - } - - // ----- First try : look if this is an archive with no commentaries - // (most of the time) - // in this case the end of central dir is at 22 bytes of the file end - $v_found = 0; - if ($v_size > 26) { - @fseek($this->_zip_fd, $v_size-22); - if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) { - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, - 'Unable to seek back to the middle of the archive \'' - .$this->_zipname.'\''); - return Archive_Zip::errorCode(); - } - - // ----- Read for bytes - $v_binary_data = @fread($this->_zip_fd, 4); - $v_data = unpack('Vid', $v_binary_data); - - // ----- Check signature - if ($v_data['id'] == 0x06054b50) { - $v_found = 1; - } - - $v_pos = ftell($this->_zip_fd); - } - - // ----- Go back to the maximum possible size of the Central Dir End Record - if (!$v_found) { - $v_maximum_size = 65557; // 0xFFFF + 22; - if ($v_maximum_size > $v_size) - $v_maximum_size = $v_size; - @fseek($this->_zip_fd, $v_size-$v_maximum_size); - if (@ftell($this->_zip_fd) != ($v_size-$v_maximum_size)) { - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, - 'Unable to seek back to the middle of the archive \'' - .$this->_zipname.'\''); - return Archive_Zip::errorCode(); - } - - // ----- Read byte per byte in order to find the signature - $v_pos = ftell($this->_zip_fd); - $v_bytes = 0x00000000; - while ($v_pos < $v_size) { - // ----- Read a byte - $v_byte = @fread($this->_zip_fd, 1); - - // ----- Add the byte - $v_bytes = ($v_bytes << 8) | Ord($v_byte); - - // ----- Compare the bytes - if ($v_bytes == 0x504b0506) { - $v_pos++; - break; - } - - $v_pos++; - } - - // ----- Look if not found end of central dir - if ($v_pos == $v_size) { - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, - "Unable to find End of Central Dir Record signature"); - return Archive_Zip::errorCode(); - } - } - - // ----- Read the first 18 bytes of the header - $v_binary_data = fread($this->_zip_fd, 18); - - // ----- Look for invalid block size - if (strlen($v_binary_data) != 18) { - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, - "Invalid End of Central Dir Record size : " - .strlen($v_binary_data)); - return Archive_Zip::errorCode(); - } - - // ----- Extract the values - $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data); - - // ----- Check the global size - if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, - "Fail to find the right signature"); - return Archive_Zip::errorCode(); - } - - // ----- Get comment - if ($v_data['comment_size'] != 0) - $p_central_dir['comment'] = fread($this->_zip_fd, $v_data['comment_size']); - else - $p_central_dir['comment'] = ''; - - $p_central_dir['entries'] = $v_data['entries']; - $p_central_dir['disk_entries'] = $v_data['disk_entries']; - $p_central_dir['offset'] = $v_data['offset']; - $p_central_dir['size'] = $v_data['size']; - $p_central_dir['disk'] = $v_data['disk']; - $p_central_dir['disk_start'] = $v_data['disk_start']; - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _deleteByRule() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_deleteByRule() - * - * { Description } - * - */ - function _deleteByRule(&$p_result_list, &$p_params) - { - $v_result=1; - $v_list_detail = array(); - - // ----- Open the zip file - if (($v_result=$this->_openFd('rb')) != 1) - { - // ----- Return - return $v_result; - } - - // ----- Read the central directory informations - $v_central_dir = array(); - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) - { - $this->_closeFd(); - return $v_result; - } - - // ----- Go to beginning of File - @rewind($this->_zip_fd); - - // ----- Scan all the files - // ----- Start at beginning of Central Dir - $v_pos_entry = $v_central_dir['offset']; - @rewind($this->_zip_fd); - if (@fseek($this->_zip_fd, $v_pos_entry)) { - // ----- Clean - $this->_closeFd(); - - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, - 'Invalid archive size'); - return Archive_Zip::errorCode(); - } - - // ----- Read each entry - $v_header_list = array(); - $j_start = 0; - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { - - // ----- Read the file header - $v_header_list[$v_nb_extracted] = array(); - $v_result - = $this->_readCentralFileHeader($v_header_list[$v_nb_extracted]); - if ($v_result != 1) { - // ----- Clean - $this->_closeFd(); - - return $v_result; - } - - // ----- Store the index - $v_header_list[$v_nb_extracted]['index'] = $i; - - // ----- Look for the specific extract rules - $v_found = false; - - // ----- Look for extract by name rule - if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) - && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) { - - // ----- Look if the filename is in the list - for ($j=0; - ($j strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) - && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { - $v_found = true; - } - elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ - && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { - $v_found = true; - } - } - // ----- Look for a filename - elseif ($v_header_list[$v_nb_extracted]['stored_filename'] - == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { - $v_found = true; - } - } - } - - // ----- Look for extract by ereg rule - else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])) - && ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != "")) { - - if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], - $v_header_list[$v_nb_extracted]['stored_filename'])) { - $v_found = true; - } - } - - // ----- Look for extract by preg rule - else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])) - && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != "")) { - - if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], - $v_header_list[$v_nb_extracted]['stored_filename'])) { - $v_found = true; - } - } - - // ----- Look for extract by index rule - else if ( (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) - && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) { - - // ----- Look if the index is in the list - for ($j=$j_start; - ($j=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) - && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { - $v_found = true; - } - if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { - $j_start = $j+1; - } - - if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { - break; - } - } - } - - // ----- Look for deletion - if ($v_found) { - unset($v_header_list[$v_nb_extracted]); - } - else { - $v_nb_extracted++; - } - } - - // ----- Look if something need to be deleted - if ($v_nb_extracted > 0) { - - // ----- Creates a temporay file - $v_zip_temp_name = ARCHIVE_ZIP_TEMPORARY_DIR.uniqid('archive_zip-') - .'.tmp'; - - // ----- Creates a temporary zip archive - $v_temp_zip = new Archive_Zip($v_zip_temp_name); - - // ----- Open the temporary zip file in write mode - if (($v_result = $v_temp_zip->_openFd('wb')) != 1) { - $this->_closeFd(); - - // ----- Return - return $v_result; - } - - // ----- Look which file need to be kept - for ($i=0; $i_zip_fd); - if (@fseek($this->_zip_fd, $v_header_list[$i]['offset'])) { - // ----- Clean - $this->_closeFd(); - $v_temp_zip->_closeFd(); - @unlink($v_zip_temp_name); - - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, - 'Invalid archive size'); - return Archive_Zip::errorCode(); - } - - // ----- Read the file header - if (($v_result = $this->_readFileHeader($v_header_list[$i])) != 1) { - // ----- Clean - $this->_closeFd(); - $v_temp_zip->_closeFd(); - @unlink($v_zip_temp_name); - - return $v_result; - } - - // ----- Write the file header - $v_result = $v_temp_zip->_writeFileHeader($v_header_list[$i]); - if ($v_result != 1) { - // ----- Clean - $this->_closeFd(); - $v_temp_zip->_closeFd(); - @unlink($v_zip_temp_name); - - return $v_result; - } - - // ----- Read/write the data block - $v_result = $this->_tool_CopyBlock($this->_zip_fd, - $v_temp_zip->_zip_fd, - $v_header_list[$i]['compressed_size']); - if ($v_result != 1) { - // ----- Clean - $this->_closeFd(); - $v_temp_zip->_closeFd(); - @unlink($v_zip_temp_name); - - return $v_result; - } - } - - // ----- Store the offset of the central dir - $v_offset = @ftell($v_temp_zip->_zip_fd); - - // ----- Re-Create the Central Dir files header - for ($i=0; $i_writeCentralFileHeader($v_header_list[$i]); - if ($v_result != 1) { - // ----- Clean - $v_temp_zip->_closeFd(); - $this->_closeFd(); - @unlink($v_zip_temp_name); - - return $v_result; - } - - // ----- Transform the header to a 'usable' info - $v_temp_zip->_convertHeader2FileInfo($v_header_list[$i], - $p_result_list[$i]); - } - - - // ----- Zip file comment - $v_comment = ''; - - // ----- Calculate the size of the central header - $v_size = @ftell($v_temp_zip->_zip_fd)-$v_offset; - - // ----- Create the central dir footer - $v_result = $v_temp_zip->_writeCentralHeader(sizeof($v_header_list), - $v_size, $v_offset, - $v_comment); - if ($v_result != 1) { - // ----- Clean - unset($v_header_list); - $v_temp_zip->_closeFd(); - $this->_closeFd(); - @unlink($v_zip_temp_name); - - return $v_result; - } - - // ----- Close - $v_temp_zip->_closeFd(); - $this->_closeFd(); - - // ----- Delete the zip file - // TBC : I should test the result ... - @unlink($this->_zipname); - - // ----- Rename the temporary file - // TBC : I should test the result ... - //@rename($v_zip_temp_name, $this->_zipname); - $this->_tool_Rename($v_zip_temp_name, $this->_zipname); - - // ----- Destroy the temporary archive - unset($v_temp_zip); - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _dirCheck() - // Description : - // Check if a directory exists, if not it creates it and all the parents directory - // which may be useful. - // Parameters : - // $p_dir : Directory path to check. - // Return Values : - // 1 : OK - // -1 : Unable to create directory - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_dirCheck() - * - * { Description } - * - * @param [type] $p_is_dir - */ - function _dirCheck($p_dir, $p_is_dir=false) - { - $v_result = 1; - - // ----- Remove the final '/' - if (($p_is_dir) && (substr($p_dir, -1)=='/')) { - $p_dir = substr($p_dir, 0, strlen($p_dir)-1); - } - - // ----- Check the directory availability - if ((is_dir($p_dir)) || ($p_dir == "")) { - return 1; - } - - // ----- Extract parent directory - $p_parent_dir = dirname($p_dir); - - // ----- Just a check - if ($p_parent_dir != $p_dir) { - // ----- Look for parent directory - if ($p_parent_dir != "") { - if (($v_result = $this->_dirCheck($p_parent_dir)) != 1) { - return $v_result; - } - } - } - - // ----- Create the directory - if (!@mkdir($p_dir, 0777)) { - $this->_errorLog(ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL, - "Unable to create directory '$p_dir'"); - return Archive_Zip::errorCode(); - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _merge() - // Description : - // If $p_archive_to_add does not exist, the function exit with a success result. - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_merge() - * - * { Description } - * - */ - function _merge(&$p_archive_to_add) - { - $v_result=1; - - // ----- Look if the archive_to_add exists - if (!is_file($p_archive_to_add->_zipname)) { - // ----- Nothing to merge, so merge is a success - return 1; - } - - // ----- Look if the archive exists - if (!is_file($this->_zipname)) { - // ----- Do a duplicate - $v_result = $this->_duplicate($p_archive_to_add->_zipname); - - return $v_result; - } - - // ----- Open the zip file - if (($v_result=$this->_openFd('rb')) != 1) { - return $v_result; - } - - // ----- Read the central directory informations - $v_central_dir = array(); - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { - $this->_closeFd(); - return $v_result; - } - - // ----- Go to beginning of File - @rewind($this->_zip_fd); - - // ----- Open the archive_to_add file - if (($v_result=$p_archive_to_add->_openFd('rb')) != 1) { - $this->_closeFd(); - return $v_result; - } - - // ----- Read the central directory informations - $v_central_dir_to_add = array(); - $v_result = $p_archive_to_add->_readEndCentralDir($v_central_dir_to_add); - if ($v_result != 1) { - $this->_closeFd(); - $p_archive_to_add->_closeFd(); - return $v_result; - } - - // ----- Go to beginning of File - @rewind($p_archive_to_add->_zip_fd); - - // ----- Creates a temporay file - $v_zip_temp_name = ARCHIVE_ZIP_TEMPORARY_DIR.uniqid('archive_zip-').'.tmp'; - - // ----- Open the temporary file in write mode - if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0) { - $this->_closeFd(); - $p_archive_to_add->_closeFd(); - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, - 'Unable to open temporary file \'' - .$v_zip_temp_name.'\' in binary write mode'); - return Archive_Zip::errorCode(); - } - - // ----- Copy the files from the archive to the temporary file - // TBC : Here I should better append the file and go back to erase the - // central dir - $v_size = $v_central_dir['offset']; - while ($v_size != 0) { - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = fread($this->_zip_fd, $v_read_size); - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); - $v_size -= $v_read_size; - } - - // ----- Copy the files from the archive_to_add into the temporary file - $v_size = $v_central_dir_to_add['offset']; - while ($v_size != 0) { - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = fread($p_archive_to_add->_zip_fd, $v_read_size); - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); - $v_size -= $v_read_size; - } - - // ----- Store the offset of the central dir - $v_offset = @ftell($v_zip_temp_fd); - - // ----- Copy the block of file headers from the old archive - $v_size = $v_central_dir['size']; - while ($v_size != 0) { - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = @fread($this->_zip_fd, $v_read_size); - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); - $v_size -= $v_read_size; - } - - // ----- Copy the block of file headers from the archive_to_add - $v_size = $v_central_dir_to_add['size']; - while ($v_size != 0) { - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = @fread($p_archive_to_add->_zip_fd, $v_read_size); - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); - $v_size -= $v_read_size; - } - - // ----- Zip file comment - // TBC : I should merge the two comments - $v_comment = ''; - - // ----- Calculate the size of the (new) central header - $v_size = @ftell($v_zip_temp_fd)-$v_offset; - - // ----- Swap the file descriptor - // Here is a trick : I swap the temporary fd with the zip fd, in order to use - // the following methods on the temporary fil and not the real archive fd - $v_swap = $this->_zip_fd; - $this->_zip_fd = $v_zip_temp_fd; - $v_zip_temp_fd = $v_swap; - - // ----- Create the central dir footer - if (($v_result = $this->_writeCentralHeader($v_central_dir['entries'] - +$v_central_dir_to_add['entries'], - $v_size, $v_offset, - $v_comment)) != 1) { - $this->_closeFd(); - $p_archive_to_add->_closeFd(); - @fclose($v_zip_temp_fd); - $this->_zip_fd = null; - - // ----- Reset the file list - unset($v_header_list); - - // ----- Return - return $v_result; - } - - // ----- Swap back the file descriptor - $v_swap = $this->_zip_fd; - $this->_zip_fd = $v_zip_temp_fd; - $v_zip_temp_fd = $v_swap; - - // ----- Close - $this->_closeFd(); - $p_archive_to_add->_closeFd(); - - // ----- Close the temporary file - @fclose($v_zip_temp_fd); - - // ----- Delete the zip file - // TBC : I should test the result ... - @unlink($this->_zipname); - - // ----- Rename the temporary file - // TBC : I should test the result ... - //@rename($v_zip_temp_name, $this->_zipname); - $this->_tool_Rename($v_zip_temp_name, $this->_zipname); - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _duplicate() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_duplicate() - * - * { Description } - * - */ - function _duplicate($p_archive_filename) - { - $v_result=1; - - // ----- Look if the $p_archive_filename exists - if (!is_file($p_archive_filename)) { - - // ----- Nothing to duplicate, so duplicate is a success. - $v_result = 1; - - // ----- Return - return $v_result; - } - - // ----- Open the zip file - if (($v_result=$this->_openFd('wb')) != 1) { - // ----- Return - return $v_result; - } - - // ----- Open the temporary file in write mode - if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) { - $this->_closeFd(); - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, - 'Unable to open archive file \'' - .$p_archive_filename.'\' in binary write mode'); - return Archive_Zip::errorCode(); - } - - // ----- Copy the files from the archive to the temporary file - // TBC : Here I should better append the file and go back to erase the - // central dir - $v_size = filesize($p_archive_filename); - while ($v_size != 0) { - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = fread($v_zip_temp_fd, $v_read_size); - @fwrite($this->_zip_fd, $v_buffer, $v_read_size); - $v_size -= $v_read_size; - } - - // ----- Close - $this->_closeFd(); - - // ----- Close the temporary file - @fclose($v_zip_temp_fd); - - return $v_result; - } - // --------------------------------------------------------------------------- - - /** - * Archive_Zip::_check_parameters() - * - * { Description } - * - * @param integer $p_error_code - * @param string $p_error_string - */ - function _check_parameters(&$p_params, $p_default) - { - - // ----- Check that param is an array - if (!is_array($p_params)) { - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, - 'Unsupported parameter, waiting for an array'); - return Archive_Zip::errorCode(); - } - - // ----- Check that all the params are valid - for (reset($p_params); list($v_key, $v_value) = each($p_params); ) { - if (!isset($p_default[$v_key])) { - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, - 'Unsupported parameter with key \''.$v_key.'\''); - - return Archive_Zip::errorCode(); - } - } - - // ----- Set the default values - for (reset($p_default); list($v_key, $v_value) = each($p_default); ) { - if (!isset($p_params[$v_key])) { - $p_params[$v_key] = $p_default[$v_key]; - } - } - - // ----- Check specific parameters - $v_callback_list = array ('callback_pre_add','callback_post_add', - 'callback_pre_extract','callback_post_extract'); - for ($i=0; $i_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, - "Callback '".$p_params[$v_key] - ."()' is not an existing function for " - ."parameter '".$v_key."'"); - return Archive_Zip::errorCode(); - } - } - } - - return(1); - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _errorLog() - // Description : - // Parameters : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_errorLog() - * - * { Description } - * - * @param integer $p_error_code - * @param string $p_error_string - */ - function _errorLog($p_error_code=0, $p_error_string='') - { - $this->_error_code = $p_error_code; - $this->_error_string = $p_error_string; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : _errorReset() - // Description : - // Parameters : - // --------------------------------------------------------------------------- - /** - * Archive_Zip::_errorReset() - * - * { Description } - * - */ - function _errorReset() - { - $this->_error_code = 1; - $this->_error_string = ''; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : $this->_tool_PathReduction() - // Description : - // Parameters : - // Return Values : - // --------------------------------------------------------------------------- - /** - * _tool_PathReduction() - * - * { Description } - * - */ - function _tool_PathReduction($p_dir) - { - $v_result = ""; - - // ----- Look for not empty path - if ($p_dir != "") - { - // ----- Explode path by directory names - $v_list = explode("/", $p_dir); - - // ----- Study directories from last to first - for ($i=sizeof($v_list)-1; $i>=0; $i--) - { - // ----- Look for current path - if ($v_list[$i] == ".") - { - // ----- Ignore this directory - // Should be the first $i=0, but no check is done - } - else if ($v_list[$i] == "..") - { - // ----- Ignore it and ignore the $i-1 - $i--; - } - else if (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0)) - { - // ----- Ignore only the double '//' in path, - // but not the first and last '/' - } - else - { - $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); - } - } - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : $this->_tool_PathInclusion() - // Description : - // This function indicates if the path $p_path is under the $p_dir tree. Or, - // said in an other way, if the file or sub-dir $p_path is inside the dir - // $p_dir. - // The function indicates also if the path is exactly the same as the dir. - // This function supports path with duplicated '/' like '//', but does not - // support '.' or '..' statements. - // Parameters : - // Return Values : - // 0 if $p_path is not inside directory $p_dir - // 1 if $p_path is inside directory $p_dir - // 2 if $p_path is exactly the same as $p_dir - // --------------------------------------------------------------------------- - /** - * _tool_PathInclusion() - * - * { Description } - * - */ - function _tool_PathInclusion($p_dir, $p_path) - { - $v_result = 1; - - // ----- Explode dir and path by directory separator - $v_list_dir = explode("/", $p_dir); - $v_list_dir_size = sizeof($v_list_dir); - $v_list_path = explode("/", $p_path); - $v_list_path_size = sizeof($v_list_path); - - // ----- Study directories paths - $i = 0; - $j = 0; - while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { - - // ----- Look for empty dir (path reduction) - if ($v_list_dir[$i] == '') { - $i++; - continue; - } - if ($v_list_path[$j] == '') { - $j++; - continue; - } - - // ----- Compare the items - if ( ($v_list_dir[$i] != $v_list_path[$j]) - && ($v_list_dir[$i] != '') - && ( $v_list_path[$j] != '')) { - $v_result = 0; - } - - // ----- Next items - $i++; - $j++; - } - - // ----- Look if everything seems to be the same - if ($v_result) { - // ----- Skip all the empty items - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++; - while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++; - - if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) { - // ----- There are exactly the same - $v_result = 2; - } - else if ($i < $v_list_dir_size) { - // ----- The path is shorter than the dir - $v_result = 0; - } - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : $this->_tool_CopyBlock() - // Description : - // Parameters : - // $p_mode : read/write compression mode - // 0 : src & dest normal - // 1 : src gzip, dest normal - // 2 : src normal, dest gzip - // 3 : src & dest gzip - // Return Values : - // --------------------------------------------------------------------------- - /** - * _tool_CopyBlock() - * - * { Description } - * - * @param integer $p_mode - */ - function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0) - { - $v_result = 1; - - if ($p_mode==0) - { - while ($p_size != 0) - { - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = @fread($p_src, $v_read_size); - @fwrite($p_dest, $v_buffer, $v_read_size); - $p_size -= $v_read_size; - } - } - else if ($p_mode==1) - { - while ($p_size != 0) - { - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = @gzread($p_src, $v_read_size); - @fwrite($p_dest, $v_buffer, $v_read_size); - $p_size -= $v_read_size; - } - } - else if ($p_mode==2) - { - while ($p_size != 0) - { - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = @fread($p_src, $v_read_size); - @gzwrite($p_dest, $v_buffer, $v_read_size); - $p_size -= $v_read_size; - } - } - else if ($p_mode==3) - { - while ($p_size != 0) - { - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE - ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); - $v_buffer = @gzread($p_src, $v_read_size); - @gzwrite($p_dest, $v_buffer, $v_read_size); - $p_size -= $v_read_size; - } - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : $this->_tool_Rename() - // Description : - // This function tries to do a simple rename() function. If it fails, it - // tries to copy the $p_src file in a new $p_dest file and then unlink the - // first one. - // Parameters : - // $p_src : Old filename - // $p_dest : New filename - // Return Values : - // 1 on success, 0 on failure. - // --------------------------------------------------------------------------- - /** - * _tool_Rename() - * - * { Description } - * - */ - function _tool_Rename($p_src, $p_dest) - { - $v_result = 1; - - // ----- Try to rename the files - if (!@rename($p_src, $p_dest)) { - - // ----- Try to copy & unlink the src - if (!@copy($p_src, $p_dest)) { - $v_result = 0; - } - else if (!@unlink($p_src)) { - $v_result = 0; - } - } - - // ----- Return - return $v_result; - } - // --------------------------------------------------------------------------- - - // --------------------------------------------------------------------------- - // Function : $this->_tool_TranslateWinPath() - // Description : - // Translate windows path by replacing '\' by '/' and optionally removing - // drive letter. - // Parameters : - // $p_path : path to translate. - // $p_remove_disk_letter : true | false - // Return Values : - // The path translated. - // --------------------------------------------------------------------------- - /** - * _tool_TranslateWinPath() - * - * { Description } - * - * @param [type] $p_remove_disk_letter - */ - function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true) - { - if (stristr(php_uname(), 'windows')) { - // ----- Look for potential disk letter - if ( ($p_remove_disk_letter) - && (($v_position = strpos($p_path, ':')) != false)) { - $p_path = substr($p_path, $v_position+1); - } - // ----- Change potential windows directory separator - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) { - $p_path = strtr($p_path, '\\', '/'); - } - } - return $p_path; - } - // --------------------------------------------------------------------------- - - } - // End of class - -?> diff --git a/buildscripts/phing/classes/phing/listener/AnsiColorLogger.php b/buildscripts/phing/classes/phing/listener/AnsiColorLogger.php deleted file mode 100644 index 00b0a7a9..00000000 --- a/buildscripts/phing/classes/phing/listener/AnsiColorLogger.php +++ /dev/null @@ -1,231 +0,0 @@ -. - */ - -require_once 'phing/listener/DefaultLogger.php'; -include_once 'phing/system/util/Properties.php'; - -/** - * Uses ANSI Color Code Sequences to colorize messages - * sent to the console. - * - * If used with the -logfile option, the output file - * will contain all the necessary escape codes to - * display the text in colorized mode when displayed - * in the console using applications like cat, more, - * etc. - * - * This is designed to work on terminals that support ANSI - * color codes. It works on XTerm, ETerm, Mindterm, etc. - * It also works on Win9x (with ANSI.SYS loaded.) - * - * NOTE: - * It doesn't work on WinNT's COMMAND.COM even with - * ANSI.SYS loaded. - * - * The default colors used for differentiating - * the message levels can be changed by editing the - * /org/apache/tools/ant/listener/defaults.properties - * file. - * This file contains 5 key/value pairs: - * AnsiColorLogger.ERROR_COLOR=2;31 - * AnsiColorLogger.WARNING_COLOR=2;35 - * AnsiColorLogger.INFO_COLOR=2;36 - * AnsiColorLogger.VERBOSE_COLOR=2;32 - * AnsiColorLogger.DEBUG_COLOR=2;34 - * - * Another option is to pass a system variable named - * ant.logger.defaults, with value set to the path of - * the file that contains user defined Ansi Color - * Codes, to the java command using -D option. - * - * To change these colors use the following chart: - * - * ANSI COLOR LOGGER CONFIGURATION - * - * Format for AnsiColorLogger.*= - * Attribute;Foreground;Background - * - * Attribute is one of the following: - * 0 -> Reset All Attributes (return to normal mode) - * 1 -> Bright (Usually turns on BOLD) - * 2 -> Dim - * 3 -> Underline - * 5 -> link - * 7 -> Reverse - * 8 -> Hidden - * - * Foreground is one of the following: - * 30 -> Black - * 31 -> Red - * 32 -> Green - * 33 -> Yellow - * 34 -> Blue - * 35 -> Magenta - * 36 -> Cyan - * 37 -> White - * - * Background is one of the following: - * 40 -> Black - * 41 -> Red - * 42 -> Green - * 43 -> Yellow - * 44 -> Blue - * 45 -> Magenta - * 46 -> Cyan - * 47 -> White - * - * @author Hans Lellelid (Phing) - * @author Magesh Umasankar (Ant) - * @package phing.listener - * @version $Revision: 1.13 $ - */ -final class AnsiColorLogger extends DefaultLogger { - - const ATTR_NORMAL = 0; - const ATTR_BRIGHT = 1; - const ATTR_DIM = 2; - const ATTR_UNDERLINE = 3; - const ATTR_BLINK = 5; - const ATTR_REVERSE = 7; - const ATTR_HIDDEN = 8; - - const FG_BLACK = 30; - const FG_RED = 31; - const FG_GREEN = 32; - const FG_YELLOW = 33; - const FG_BLUE = 34; - const FG_MAGENTA = 35; - const FG_CYAN = 36; - const FG_WHITE = 37; - - const BG_BLACK = 40; - const BG_RED = 41; - const BG_GREEN = 42; - const BG_YELLOW = 44; - const BG_BLUE = 44; - const BG_MAGENTA = 45; - const BG_CYAN = 46; - const BG_WHITE = 47; - - const PREFIX = "\x1b["; - const SUFFIX = "m"; - const SEPARATOR = ';'; - const END_COLOR = "\x1b[m"; // self::PREFIX . self::SUFFIX; - - private $errColor; - private $warnColor; - private $infoColor; - private $verboseColor; - private $debugColor; - - private $colorsSet = false; - - /** - * Construct new AnsiColorLogger - * Perform initializations that cannot be done in var declarations. - */ - public function __construct() { - parent::__construct(); - $this->errColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_RED . self::SUFFIX; - $this->warnColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_MAGENTA . self::SUFFIX; - $this->infoColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_CYAN . self::SUFFIX; - $this->verboseColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_GREEN . self::SUFFIX; - $this->debugColor = self::PREFIX . self::ATTR_DIM . self::SEPARATOR . self::FG_BLUE . self::SUFFIX; - } - - /** - * Set the colors to use from a property file specified by the - * special ant property ant.logger.defaults - */ - private final function setColors() { - - $userColorFile = Phing::getProperty("phing.logger.defaults"); - $systemColorFile = new PhingFile(Phing::getResourcePath("phing/listener/defaults.properties")); - - $in = null; - - try { - $prop = new Properties(); - - if ($userColorFile !== null) { - $prop->load($userColorFile); - } else { - $prop->load($systemColorFile); - } - - $err = $prop->getProperty("AnsiColorLogger.ERROR_COLOR"); - $warn = $prop->getProperty("AnsiColorLogger.WARNING_COLOR"); - $info = $prop->getProperty("AnsiColorLogger.INFO_COLOR"); - $verbose = $prop->getProperty("AnsiColorLogger.VERBOSE_COLOR"); - $debug = $prop->getProperty("AnsiColorLogger.DEBUG_COLOR"); - if ($err !== null) { - $errColor = self::PREFIX . $err . self::SUFFIX; - } - if ($warn !== null) { - $warnColor = self::PREFIX . $warn . self::SUFFIX; - } - if ($info !== null) { - $infoColor = self::PREFIX . $info . self::SUFFIX; - } - if ($verbose !== null) { - $verboseColor = self::PREFIX . $verbose . self::SUFFIX; - } - if ($debug !== null) { - $debugColor = self::PREFIX . $debug . self::SUFFIX; - } - } catch (IOException $ioe) { - //Ignore exception - we will use the defaults. - } - } - - /** - * @see DefaultLogger#printMessage - */ - protected final function printMessage($message, $priority) { - - if ($message !== null) { - - if (!$this->colorsSet) { - $this->setColors(); - $this->colorsSet = true; - } - - switch ($priority) { - case PROJECT_MSG_ERR: - $message = $this->errColor . $message . self::END_COLOR; - break; - case PROJECT_MSG_WARN: - $message = $this->warnColor . $message . self::END_COLOR; - break; - case PROJECT_MSG_INFO: - $message = $this->infoColor . $message . self::END_COLOR; - break; - case PROJECT_MSG_VERBOSE: - $message = $this->verboseColor . $message . self::END_COLOR; - break; - case PROJECT_MSG_DEBUG: - $message = $this->debugColor . $message . self::END_COLOR; - break; - } - print($message."\n"); - } - } -} diff --git a/buildscripts/phing/classes/phing/listener/BuildLogger.php b/buildscripts/phing/classes/phing/listener/BuildLogger.php deleted file mode 100644 index d1c5fcb6..00000000 --- a/buildscripts/phing/classes/phing/listener/BuildLogger.php +++ /dev/null @@ -1,42 +0,0 @@ -. - */ - - require_once 'phing/BuildListener.php'; - /** - * Interface used by Phing Ant to log the build output. - * - * @author Michiel Rook - * @version $Id: BuildLogger.php,v 1.3 2005/02/11 10:51:21 mrook Exp $ - * @package phing.listener - */ - interface BuildLogger extends BuildListener - { - /** - * Sets the highest level of message this logger should respond to. - * - * Only messages with a message level lower than or equal to the - * given level should be written to the log. - * - * @param int the logging level for the logger. - */ - function setMessageOutputLevel($level); - }; -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/listener/DefaultLogger.php b/buildscripts/phing/classes/phing/listener/DefaultLogger.php deleted file mode 100644 index c7387592..00000000 --- a/buildscripts/phing/classes/phing/listener/DefaultLogger.php +++ /dev/null @@ -1,233 +0,0 @@ -. - */ - -require_once 'phing/BuildListener.php'; -include_once 'phing/BuildEvent.php'; - -/** - * Writes a build event to the console. - * - * Currently, it only writes which targets are being executed, and - * any messages that get logged. - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.11 $ $Date: 2005/08/25 19:33:43 $ - * @see BuildEvent - * @package phing.listener - */ -class DefaultLogger implements BuildListener { - - /** - * Size of the left column in output. The default char width is 12. - * @var int - */ - const LEFT_COLUMN_SIZE = 12; - - /** - * The message output level that should be used. The default is - * PROJECT_MSG_VERBOSE. - * @var int - */ - protected $msgOutputLevel = PROJECT_MSG_ERR; - - /** - * Time that the build started - * @var int - */ - protected $startTime; - - /** - * Char that should be used to seperate lines. Default is the system - * property line.seperator. - * @var string - */ - protected $lSep; - - /** - * Construct a new default logger. - */ - public function __construct() { - $this->lSep = Phing::getProperty("line.separator"); - } - - /** - * Set the msgOutputLevel this logger is to respond to. - * - * Only messages with a message level lower than or equal to the given - * level are output to the log. - * - *

Constants for the message levels are in Project.php. The order of - * the levels, from least to most verbose, is: - * - *

    - *
  • PROJECT_MSG_ERR
  • - *
  • PROJECT_MSG_WARN
  • - *
  • PROJECT_MSG_INFO
  • - *
  • PROJECT_MSG_VERBOSE
  • - *
  • PROJECT_MSG_DEBUG
  • - *
- * - * The default message level for DefaultLogger is PROJECT_MSG_ERR. - * - * @param integer the logging level for the logger. - * @access public - */ - function setMessageOutputLevel($level) { - $this->msgOutputLevel = (int) $level; - } - - /** - * Sets the start-time when the build started. Used for calculating - * the build-time. - * - * @param object The BuildEvent - * @access public - */ - - function buildStarted(BuildEvent $event) { - $this->startTime = Phing::currentTimeMillis(); - if ($this->msgOutputLevel >= PROJECT_MSG_INFO) { - $this->printMessage("Buildfile: ".$event->getProject()->getProperty("phing.file"), PROJECT_MSG_INFO); - } - } - - /** - * Prints whether the build succeeded or failed, and any errors that - * occured during the build. Also outputs the total build-time. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getException() - */ - function buildFinished(BuildEvent $event) { - $error = $event->getException(); - if ($error === null) { - print($this->lSep . "BUILD FINISHED" . $this->lSep); - } else { - print($this->lSep . "BUILD FAILED" . $this->lSep); - if (PROJECT_MSG_VERBOSE <= $this->msgOutputLevel || !($error instanceof BuildException)) { - print($error->__toString().$this->lSep); - } else { - print($error->getMessage()); - } - } - print($this->lSep . "Total time: " .$this->_formatTime(Phing::currentTimeMillis() - $this->startTime) . $this->lSep); - } - - /** - * Prints the current target name - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getTarget() - */ - function targetStarted(BuildEvent $event) { - if (PROJECT_MSG_INFO <= $this->msgOutputLevel) { - print($this->lSep . $event->getProject()->getName() . ' > ' . $event->getTarget()->getName() . ':' . $this->lSep); - } - } - - /** - * Fired when a target has finished. We don't need specific action on this - * event. So the methods are empty. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getException() - */ - function targetFinished(BuildEvent $event) {} - - /** - * Fired when a task is started. We don't need specific action on this - * event. So the methods are empty. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getTask() - */ - function taskStarted(BuildEvent $event) {} - - /** - * Fired when a task has finished. We don't need specific action on this - * event. So the methods are empty. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getException() - */ - function taskFinished(BuildEvent $event) {} - - /** - * Print a message to the stdout. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getMessage() - */ - function messageLogged(BuildEvent $event) { - if ($event->getPriority() <= $this->msgOutputLevel) { - $msg = ""; - if ($event->getTask() !== null) { - $name = $event->getTask(); - $name = $name->getTaskName(); - $msg = str_pad("[$name] ", self::LEFT_COLUMN_SIZE, " ", STR_PAD_LEFT); - #for ($i=0; $i < ($this->LEFT_COLUMN_SIZE - strlen($msg)); ++$i) { - # print(" "); - #} - #print($msg); - } - $msg .= $event->getMessage(); - $this->printMessage($msg, $event->getPriority()); - } - } - - /** - * Formats a time micro integer to human readable format. - * - * @param integer The time stamp - * @access private - */ - function _formatTime($micros) { - $seconds = $micros; - $minutes = $seconds / 60; - if ($minutes > 1) { - return sprintf("%1.0f minute%s %0.2f second%s", - $minutes, ($minutes === 1 ? " " : "s "), - $seconds - floor($seconds/60) * 60, ($seconds%60 === 1 ? "" : "s")); - } else { - return sprintf("%0.4f second%s", $seconds, ($seconds%60 === 1 ? "" : "s")); - } - } - - /** - * Prints a message to console. - * - * @param string $message The message to print. - * Should not be null. - * @param int $priority The priority of the message. - * (Ignored in this implementation.) - * @return void - */ - protected function printMessage($message, $priority) { - print($message . $this->lSep); - } -} diff --git a/buildscripts/phing/classes/phing/listener/NoBannerLogger.php b/buildscripts/phing/classes/phing/listener/NoBannerLogger.php deleted file mode 100644 index e222e10c..00000000 --- a/buildscripts/phing/classes/phing/listener/NoBannerLogger.php +++ /dev/null @@ -1,61 +0,0 @@ -. - */ - -include_once 'phing/listener/DefaultLogger.php'; - -/** - * Extends DefaultLogger to strip out empty targets. This logger is most - * commonly used and also enforced by the default phing invokation scripts - * in bin/. - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.4 $ $Date: 2003/12/24 13:02:08 $ - * @package phing.listener - */ -class NoBannerLogger extends DefaultLogger { - - private $targetName = null; - - function targetStarted(BuildEvent $event) { - $target = $event->getTarget(); - $this->targetName = $target->getName(); - } - - function targetFinished(BuildEvent $event) { - $this->targetName = null; - } - - function messageLogged(BuildEvent $event) { - if ($event->getPriority() > $this->msgOutputLevel || - null === $event->getMessage() || - trim($event->getMessage() === "")) { - return; - } - - if ($this->targetName !== null) { - print($this->lSep . "Target: ".$this->targetName . $this->lSep); - $this->targetName = null; - } - - parent::messageLogged($event); - } -} diff --git a/buildscripts/phing/classes/phing/listener/PearLogger.php b/buildscripts/phing/classes/phing/listener/PearLogger.php deleted file mode 100644 index 2bea6655..00000000 --- a/buildscripts/phing/classes/phing/listener/PearLogger.php +++ /dev/null @@ -1,246 +0,0 @@ -. - */ - -require_once 'phing/BuildListener.php'; -include_once 'phing/BuildEvent.php'; -require_once 'Log.php'; - -/** - * Writes log messages to PEAR Log. - * - * By default it will log to file in current directory w/ name 'phing.log'. You can customize - * this behavior by setting properties: - * - pear.log.type - * - pear.log.name - * - pear.log.ident (note that this class changes ident to project name) - * - pear.log.conf (note that array values are currently unsupported in Phing property files) - * - * - * phing -f build.xml -logger phing.listener.PearLogger -Dpear.log.type=file -Dpear.log.name=/path/to/log.log - * - * - * @author Hans Lellelid - * @version $Revision: 1.3 $ $Date: 2004/03/15 14:45:06 $ - * @see BuildEvent - * @package phing.listener - */ -class PearLogger implements BuildListener { - - /** - * Size of the left column in output. The default char width is 12. - * @var int - */ - const LEFT_COLUMN_SIZE = 12; - - /** - * The message output level that should be used. The default is - * PROJECT_MSG_VERBOSE. - * @var int - */ - protected $msgOutputLevel = PROJECT_MSG_ERR; - - /** - * Time that the build started - * @var int - */ - protected $startTime; - - /** - * Maps Phing PROJECT_MSG_* constants to PEAR_LOG_* constants. - * @var array - */ - protected static $levelMap = array( PROJECT_MSG_DEBUG => PEAR_LOG_DEBUG, - PROJECT_MSG_INFO => PEAR_LOG_INFO, - PROJECT_MSG_VERBOSE => PEAR_LOG_NOTICE, - PROJECT_MSG_WARN => PEAR_LOG_WARNING, - PROJECT_MSG_ERR => PEAR_LOG_ERR - ); - /** - * Whether logging has been configured. - * @var boolean - */ - protected $logConfigured = false; - - /** - * Configure the logger. - */ - protected function configureLogging() { - - $type = Phing::getDefinedProperty('pear.log.type'); - $name = Phing::getDefinedProperty('pear.log.name'); - $ident = Phing::getDefinedProperty('pear.log.ident'); - $conf = Phing::getDefinedProperty('pear.log.conf'); - - if ($type === null) $type = 'file'; - if ($name === null) $name = 'phing.log'; - if ($ident === null) $ident = 'phing'; - if ($conf === null) $conf = array(); - - $this->logger = Log::singleton($type, $name, $ident, $conf, self::$levelMap[$this->msgOutputLevel]); - } - - /** - * Get the configured PEAR logger to use. - * This method just ensures that logging has been configured and returns the configured logger. - * @return Log - */ - protected function logger() { - if (!$this->logConfigured) { - $this->configureLogging(); - } - return $this->logger; - } - - /** - * Set the msgOutputLevel this logger is to respond to. - * - * Only messages with a message level lower than or equal to the given - * level are output to the log. - * - *

Constants for the message levels are in Project.php. The order of - * the levels, from least to most verbose, is: - * - *

    - *
  • PROJECT_MSG_ERR
  • - *
  • PROJECT_MSG_WARN
  • - *
  • PROJECT_MSG_INFO
  • - *
  • PROJECT_MSG_VERBOSE
  • - *
  • PROJECT_MSG_DEBUG
  • - *
- * - * The default message level for DefaultLogger is PROJECT_MSG_ERR. - * - * @param integer the logging level for the logger. - * @access public - */ - function setMessageOutputLevel($level) { - $this->msgOutputLevel = (int) $level; - } - - /** - * Sets the start-time when the build started. Used for calculating - * the build-time. - * - * @param object The BuildEvent - * @access public - */ - - function buildStarted(BuildEvent $event) { - $this->startTime = Phing::currentTimeMillis(); - $this->logger()->setIdent($event->getProject()->getName()); - $this->logger()->info("Starting build with buildfile: ". $event->getProject()->getProperty("phing.file")); - } - - /** - * Prints whether the build succeeded or failed, and any errors that - * occured during the build. Also outputs the total build-time. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getException() - */ - function buildFinished(BuildEvent $event) { - $error = $event->getException(); - if ($error === null) { - $msg = "Finished successful build."; - } else { - $msg = "Build failed. [reason: " . $error->getMessage() ."]"; - } - $this->logger()->log($msg . " Total time: " . $this->_formatTime(Phing::currentTimeMillis() - $this->startTime)); - } - - /** - * Prints the current target name - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getTarget() - */ - function targetStarted(BuildEvent $event) {} - - /** - * Fired when a target has finished. We don't need specific action on this - * event. So the methods are empty. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getException() - */ - function targetFinished(BuildEvent $event) {} - - /** - * Fired when a task is started. We don't need specific action on this - * event. So the methods are empty. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getTask() - */ - function taskStarted(BuildEvent $event) {} - - /** - * Fired when a task has finished. We don't need specific action on this - * event. So the methods are empty. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getException() - */ - function taskFinished(BuildEvent $event) {} - - /** - * Print a message to the stdout. - * - * @param object The BuildEvent - * @access public - * @see BuildEvent::getMessage() - */ - function messageLogged(BuildEvent $event) { - if ($event->getPriority() <= $this->msgOutputLevel) { - $msg = ""; - if ($event->getTask() !== null) { - $name = $event->getTask(); - $name = $name->getTaskName(); - $msg = str_pad("[$name] ", self::LEFT_COLUMN_SIZE, " ", STR_PAD_LEFT); - } - $msg .= $event->getMessage(); - $this->logger()->log($msg, self::$levelMap[$event->getPriority()]); - } - } - - /** - * Formats a time micro integer to human readable format. - * - * @param integer The time stamp - * @access private - */ - function _formatTime($micros) { - $seconds = $micros; - $minutes = $seconds / 60; - if ($minutes > 1) { - return sprintf("%1.0f minute%s %0.2f second%s", - $minutes, ($minutes === 1 ? " " : "s "), - $seconds - floor($seconds/60) * 60, ($seconds%60 === 1 ? "" : "s")); - } else { - return sprintf("%0.4f second%s", $seconds, ($seconds%60 === 1 ? "" : "s")); - } - } -} diff --git a/buildscripts/phing/classes/phing/listener/XmlLogger.php b/buildscripts/phing/classes/phing/listener/XmlLogger.php deleted file mode 100644 index 07ff031e..00000000 --- a/buildscripts/phing/classes/phing/listener/XmlLogger.php +++ /dev/null @@ -1,265 +0,0 @@ -. - */ - - require_once 'phing/listener/BuildLogger.php'; - require_once 'phing/listener/DefaultLogger.php'; - require_once 'phing/system/util/Timer.php'; - /** - * Generates a file in the current directory with - * an XML description of what happened during a build. - * The default filename is "log.xml", but this can be overridden - * with the property XmlLogger.file. - * - * @author Michiel Rook - * @version $Id: XmlLogger.php,v 1.3 2005/02/11 10:51:21 mrook Exp $ - * @package phing.listener - */ - class XmlLogger implements BuildLogger - { - /** XML element name for a build. */ - const BUILD_TAG = "build"; - /** XML element name for a target. */ - const TARGET_TAG = "target"; - /** XML element name for a task. */ - const TASK_TAG = "task"; - /** XML element name for a message. */ - const MESSAGE_TAG = "message"; - /** XML attribute name for a name. */ - const NAME_ATTR = "name"; - /** XML attribute name for a time. */ - const TIME_ATTR = "time"; - /** XML attribute name for a message priority. */ - const PRIORITY_ATTR = "priority"; - /** XML attribute name for a file location. */ - const LOCATION_ATTR = "location"; - /** XML attribute name for an error description. */ - const ERROR_ATTR = "error"; - /** XML element name for a stack trace. */ - const STACKTRACE_TAG = "stacktrace"; - - private $doc = NULL; - - private $buildStartTime = 0; - private $targetStartTime = 0; - private $taskStartTime = 0; - - private $buildElement = NULL; - - private $msgOutputLevel = PROJECT_MSG_DEBUG; - - /** - * Constructs a new BuildListener that logs build events to an XML file. - */ - function __construct() - { - $this->doc = new DOMDocument(); - $this->doc->formatOutput = true; - - $this->buildTimer = new Timer(); - $this->targetTimer = new Timer(); - $this->taskTimer = new Timer(); - } - - /** - * Fired when the build starts, this builds the top-level element for the - * document and remembers the time of the start of the build. - * - * @param BuildEvent Ignored. - */ - function buildStarted(BuildEvent $event) - { - $this->buildTimerStart = Phing::currentTimeMillis(); - $this->buildElement = $this->doc->createElement(XmlLogger::BUILD_TAG); - } - - /** - * Fired when the build finishes, this adds the time taken and any - * error stacktrace to the build element and writes the document to disk. - * - * @param BuildEvent An event with any relevant extra information. - * Will not be null. - */ - function buildFinished(BuildEvent $event) - { - $this->buildTimer->stop(); - - $elapsedTime = Phing::currentTimeMillis() - $this->buildTimerStart; - - $this->buildElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::_formatTime($elapsedTime)); - - if ($event->getException() != null) - { - $this->buildElement->setAttribute(XmlLogger::ERROR_ATTR, $event->getException()->toString()); - - $errText = $this->doc->createCDATASection($event->getException()->getTraceAsString()); - $stacktrace = $this->doc->createElement(XmlLogger::STACKTRACE_TAG); - $stacktrace->appendChild($errText); - $this->buildElement->appendChild($stacktrace); - } - - $outFilename = $event->getProject()->getProperty("XmlLogger.file"); - - if ($outFilename == "") - { - $outFilename = "log.xml"; - } - $writer = new FileWriter($outFilename); - - $writer->write("\n"); - $writer->write($this->doc->saveXML($this->buildElement)); - $writer->close(); - } - /** - * Fired when a target starts building, remembers the current time and the name of the target. - * - * @param BuildEvent An event with any relevant extra information. - * Will not be null. - */ - function targetStarted(BuildEvent $event) - { - $target = $event->getTarget(); - - $this->targetTimerStart = Phing::currentTimeMillis(); - - $this->targetElement = $this->doc->createElement(XmlLogger::TARGET_TAG); - $this->targetElement->setAttribute(XmlLogger::NAME_ATTR, $target->getName()); - } - - /** - * Fired when a target finishes building, this adds the time taken - * to the appropriate target element in the log. - * - * @param BuildEvent An event with any relevant extra information. - * Will not be null. - */ - function targetFinished(BuildEvent $event) - { - $target = $event->getTarget(); - - $elapsedTime = Phing::currentTimeMillis() - $this->targetTimerStart; - - $this->targetElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::_formatTime($elapsedTime)); - - $this->buildElement->appendChild($this->targetElement); - } - - /** - * Fired when a task starts building, remembers the current time and the name of the task. - * - * @param BuildEvent An event with any relevant extra information. - * Will not be null. - */ - function taskStarted(BuildEvent $event) - { - $task = $event->getTask(); - - $this->taskTimerStart = Phing::currentTimeMillis(); - - $this->taskElement = $this->doc->createElement(XmlLogger::TASK_TAG); - $this->taskElement->setAttribute(XmlLogger::NAME_ATTR, $task->getTaskName()); - $this->taskElement->setAttribute(XmlLogger::LOCATION_ATTR, $task->getLocation()->toString()); - } - /** - * Fired when a task finishes building, this adds the time taken - * to the appropriate task element in the log. - * - * @param BuildEvent An event with any relevant extra information. - * Will not be null. - */ - function taskFinished(BuildEvent $event) - { - $task = $event->getTask(); - - $elapsedTime = Phing::currentTimeMillis() - $this->taskTimerStart; - $this->taskElement->setAttribute(XmlLogger::TIME_ATTR, DefaultLogger::_formatTime($elapsedTime)); - - $this->targetElement->appendChild($this->taskElement); - } - - /** - * Fired when a message is logged, this adds a message element to the - * most appropriate parent element (task, target or build) and records - * the priority and text of the message. - * - * @param BuildEvent An event with any relevant extra information. - * Will not be null. - */ - function messageLogged(BuildEvent $event) - { - $priority = $event->getPriority(); - - if ($priority > $this->msgOutputLevel) - { - return; - } - - $messageElement = $this->doc->createElement(XmlLogger::MESSAGE_TAG); - - switch ($priority) - { - case PROJECT_MSG_ERR: - $name = "error"; - break; - - case PROJECT_MSG_WARN: - $name = "warn"; - break; - - case PROJECT_MSG_INFO: - $name = "info"; - break; - - default: - $name = "debug"; - break; - } - - $messageElement->setAttribute(XmlLogger::PRIORITY_ATTR, $name); - - $messageText = $this->doc->createCDATASection($event->getMessage()); - - $messageElement->appendChild($messageText); - - if ($event->getTask() != null) - { - $this->taskElement->appendChild($messageElement); - } - else - if ($event->getTarget() != null) - { - $this->targetElement->appendChild($messageElement); - } - else - if ($this->buildElement != null) - { - $this->buildElement->appendChild($messageElement); - } - } - - /** - * Set the logging level when using this as a Logger - */ - function setMessageOutputLevel($level) - { - $this->msgOutputLevel = $level; - } - }; -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/listener/defaults.properties b/buildscripts/phing/classes/phing/listener/defaults.properties deleted file mode 100644 index f60a3fd5..00000000 --- a/buildscripts/phing/classes/phing/listener/defaults.properties +++ /dev/null @@ -1,43 +0,0 @@ -#################################################### -# -# ANSI COLOR LOGGER CONFIGURATION -# -# Format for AnsiColorLogger.*= -# Attribute;Foreground;Background -# -# Attribute is one of the following: -# 0 -> Reset All Attributes (return to normal mode) -# 1 -> Bright (Usually turns on BOLD) -# 2 -> Dim -# 3 -> Underline -# 5 -> link -# 7 -> Reverse -# 8 -> Hidden -# -# Foreground is one of the following: -# 30 -> Black -# 31 -> Red -# 32 -> Green -# 33 -> Yellow -# 34 -> Blue -# 35 -> Magenta -# 36 -> Cyan -# 37 -> White -# -# Background is one of the following: -# 40 -> Black -# 41 -> Red -# 42 -> Green -# 43 -> Yellow -# 44 -> Blue -# 45 -> Magenta -# 46 -> Cyan -# 47 -> White -# -#################################################### - -AnsiColorLogger.ERROR_COLOR=2;31 -AnsiColorLogger.WARNING_COLOR=2;35 -AnsiColorLogger.INFO_COLOR=2;36 -AnsiColorLogger.VERBOSE_COLOR=2;32 -AnsiColorLogger.DEBUG_COLOR=2;34 diff --git a/buildscripts/phing/classes/phing/mappers/FileNameMapper.php b/buildscripts/phing/classes/phing/mappers/FileNameMapper.php deleted file mode 100644 index c8f1f8a9..00000000 --- a/buildscripts/phing/classes/phing/mappers/FileNameMapper.php +++ /dev/null @@ -1,59 +0,0 @@ -. - */ - -/** - * Interface for filename mapper classes. - * - * @author Andreas Aderhold, andi@binarycloud.com - * @author Hans Lellelid - * @version $Revision: 1.7 $ - * @package phing.mappers - */ -interface FileNameMapper { - - /** - * The mapper implementation. - * - * @param mixed $sourceFileName The data the mapper works on. - * @return array The data after the mapper has been applied; must be in array format (for some reason). - */ - public function main($sourceFileName); - - /** - * Accessor. Sets the to property. The actual implementation - * depends on the child class. - * - * @param string $to To what this mapper should convert the from string - * @return void - */ - public function setTo($to); - - /** - * Accessor. Sets the from property. What this mapper should - * recognize. The actual implementation is dependent upon the - * child class - * - * @param string $from On what this mapper should work - * @return void - */ - public function setFrom($from); - -} diff --git a/buildscripts/phing/classes/phing/mappers/FlattenMapper.php b/buildscripts/phing/classes/phing/mappers/FlattenMapper.php deleted file mode 100644 index fea5c1e4..00000000 --- a/buildscripts/phing/classes/phing/mappers/FlattenMapper.php +++ /dev/null @@ -1,55 +0,0 @@ -. - */ - -require_once 'phing/mappers/FileNameMapper.php'; - -/** - * Removes any directory information from the passed path. - * - * @author Andreas Aderhold - * @version $Revision: 1.9 $ - * @package phing.mappers - */ -class FlattenMapper implements FileNameMapper { - - /** - * The mapper implementation. Returns string with source filename - * but without leading directory information - * - * @param string $sourceFileName The data the mapper works on - * @return array The data after the mapper has been applied - */ - function main($sourceFileName) { - $f = new PhingFile($sourceFileName); - return array($f->getName()); - } - - /** - * Ignored here. - */ - function setTo($to) {} - - /** - * Ignored here. - */ - function setFrom($from) {} - -} diff --git a/buildscripts/phing/classes/phing/mappers/GlobMapper.php b/buildscripts/phing/classes/phing/mappers/GlobMapper.php deleted file mode 100644 index 3c178620..00000000 --- a/buildscripts/phing/classes/phing/mappers/GlobMapper.php +++ /dev/null @@ -1,113 +0,0 @@ -. - */ - -include_once 'phing/mappers/FileNameMapper.php'; - -/** - * description here - * - * @author Andreas Aderhold, andi@binarycloud.com - * @version $Revision: 1.10 $ - * @package phing.mappers - */ -class GlobMapper implements FileNameMapper { - - /** - * Part of "from" pattern before the *. - */ - private $fromPrefix = null; - - /** - * Part of "from" pattern after the *. - */ - private $fromPostfix = null; - - /** - * Length of the prefix ("from" pattern). - */ - private $prefixLength; - - /** - * Length of the postfix ("from" pattern). - */ - private $postfixLength; - - /** - * Part of "to" pattern before the *. - */ - private $toPrefix = null; - - /** - * Part of "to" pattern after the *. - */ - private $toPostfix = null; - - - function main($_sourceFileName) { - if (($this->fromPrefix === null) - || !StringHelper::startsWith($this->fromPrefix, $_sourceFileName) - || !StringHelper::endsWith($this->fromPostfix, $_sourceFileName)) { - return null; - } - $varpart = $this->_extractVariablePart($_sourceFileName); - $substitution = $this->toPrefix.$varpart.$this->toPostfix; - return array($substitution); - } - - - - function setFrom($from) { - $index = strrpos($from, '*'); - - if ($index === false) { - $this->fromPrefix = $from; - $this->fromPostfix = ""; - } else { - $this->fromPrefix = substr($from, 0, $index); - $this->fromPostfix = substr($from, $index+1); - } - $this->prefixLength = strlen($this->fromPrefix); - $this->postfixLength = strlen($this->fromPostfix); - } - - /** - * Sets the "to" pattern. Required. - */ - function setTo($to) { - $index = strrpos($to, '*'); - if ($index === false) { - $this->toPrefix = $to; - $this->toPostfix = ""; - } else { - $this->toPrefix = substr($to, 0, $index); - $this->toPostfix = substr($to, $index+1); - } - } - - private function _extractVariablePart($_name) { - // ergh, i really hate php's string functions .... all but natural - $start = ($this->prefixLength === 0) ? 0 : $this->prefixLength; - $end = ($this->postfixLength === 0) ? strlen($_name) : strlen($_name) - $this->postfixLength; - $len = $end-$start; - return substr($_name, $start, $len); - } - -} diff --git a/buildscripts/phing/classes/phing/mappers/IdentityMapper.php b/buildscripts/phing/classes/phing/mappers/IdentityMapper.php deleted file mode 100644 index daf80c25..00000000 --- a/buildscripts/phing/classes/phing/mappers/IdentityMapper.php +++ /dev/null @@ -1,54 +0,0 @@ -. - */ - -require_once 'phing/mappers/FileNameMapper.php'; - -/** - * This mapper does nothing ;) - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.7 $ - * @package phing.mappers - */ -class IdentityMapper implements FileNameMapper { - - /** - * The mapper implementation. Basically does nothing in this case. - * - * @param string $sourceFileName The data the mapper works on. - * @return array The data after the mapper has been applied - */ - function main($sourceFileName) { - return array($sourceFileName); - } - - /** - * Ignored here. - */ - function setTo($to) {} - - /** - * Ignored here. - */ - function setFrom($from) {} - -} diff --git a/buildscripts/phing/classes/phing/mappers/MergeMapper.php b/buildscripts/phing/classes/phing/mappers/MergeMapper.php deleted file mode 100644 index f10f41c0..00000000 --- a/buildscripts/phing/classes/phing/mappers/MergeMapper.php +++ /dev/null @@ -1,69 +0,0 @@ -. - */ - -include_once 'phing/mappers/FileNameMapper.php'; - -/** - * For merging files into a single file. In practice just returns whatever value - * was set for "to". - * - * @author Andreas Aderhold - * @version $Revision: 1.8 $ - * @package phing.mappers - */ -class MergeMapper implements FileNameMapper { - - /** the merge */ - private $mergedFile; - - /** - * The mapper implementation. Basically does nothing in this case. - * - * @param mixed The data the mapper works on - * @returns mixed The data after the mapper has been applied - * @access public - * @author Andreas Aderhold, andi@binarycloud.com - */ - function main($sourceFileName) { - if ($this->mergedFile === null) { - throw new BuildException("MergeMapper error, to attribute not set"); - } - return array($this->mergedFile); - } - - /** - * Accessor. Sets the to property - * - * @param string To what this mapper should convert the from string - * @returns boolean True - * @access public - * @author Andreas Aderhold, andi@binarycloud.com - */ - function setTo($to) { - $this->mergedFile = $to; - } - - /** - * Ignored. - */ - function setFrom($from) {} - -} diff --git a/buildscripts/phing/classes/phing/mappers/RegexpMapper.php b/buildscripts/phing/classes/phing/mappers/RegexpMapper.php deleted file mode 100644 index a3d51976..00000000 --- a/buildscripts/phing/classes/phing/mappers/RegexpMapper.php +++ /dev/null @@ -1,97 +0,0 @@ -. - */ - -require_once 'phing/mappers/FileNameMapper.php'; -include_once 'phing/util/StringHelper.php'; -include_once 'phing/util/regexp/Regexp.php'; - -/** - * Uses regular expressions to perform filename transformations. - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @version $Revision: 1.9 $ - * @package phing.mappers - */ -class RegexpMapper implements FileNameMapper { - - /** - * @var string - */ - private $to; - - /** - * The Regexp engine. - * @var Regexp - */ - private $reg; - - function __construct() { - // instantiage regexp matcher here - $this->reg = new Regexp(); - } - - /** - * Sets the "from" pattern. Required. - */ - function setFrom($from) { - $this->reg->SetPattern($from); - } - - /** - * Sets the "to" pattern. Required. - */ - function setTo($to) { - - // [HL] I'm changing the way this works for now to just use string - //$this->to = StringHelper::toCharArray($to); - - $this->to = $to; - } - - function main($sourceFileName) { - if ($this->reg === null || $this->to === null || !$this->reg->matches((string) $sourceFileName)) { - return null; - } - return array($this->replaceReferences($sourceFileName)); - } - - /** - * Replace all backreferences in the to pattern with the matched groups. - * groups of the source. - * @param string $source The source filename. - */ - private function replaceReferences($source) { - - // FIXME - // Can't we just use engine->replace() to handle this? the Preg engine - // will automatically convert \1 references to $1 - - // the expression has already been processed (when ->matches() was run in Main()) - // so no need to pass $source again to the engine. - $groups = (array) $this->reg->getGroups(); - - // replace \1 with value of $groups[1] and return the modified "to" string - return preg_replace('/\\\([\d]+)/e', "\$groups[$1]", $this->to); - } - -} - diff --git a/buildscripts/phing/classes/phing/parser/AbstractHandler.php b/buildscripts/phing/classes/phing/parser/AbstractHandler.php deleted file mode 100644 index 6f8d7705..00000000 --- a/buildscripts/phing/classes/phing/parser/AbstractHandler.php +++ /dev/null @@ -1,98 +0,0 @@ -. - */ - -include_once 'phing/parser/ExpatParseException.php'; - -/** - * This is an abstract class all SAX handler classes must extend - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.6 $ - * @package phing.parser - */ -abstract class AbstractHandler { - - public $parentHandler = null; - public $parser = null; - - /** - * Constructs a SAX handler parser. - * - * The constructor must be called by all derived classes. - * - * @param object the parser object - * @param object the parent handler of this handler - */ - protected function __construct($parser, $parentHandler) { - $this->parentHandler = $parentHandler; - $this->parser = $parser; - $this->parser->setHandler($this); - } - - /** - * Gets invoked when a XML open tag occurs - * - * Must be overloaded by the child class. Throws an ExpatParseException - * if there is no handler registered for an element. - * - * @param string the name of the XML element - * @param array the attributes of the XML element - */ - public function startElement($name, $attribs) { - throw new ExpatParseException("Unexpected element $name"); - } - - /** - * Gets invoked when element closes method. - * - */ - protected function finished() {} - - /** - * Gets invoked when a XML element ends. - * - * Can be overloaded by the child class. But should not. It hands - * over control to the parentHandler of this. - * - * @param string the name of the XML element - */ - public function endElement($name) { - $this->finished(); - $this->parser->setHandler($this->parentHandler); - } - - /** - * Invoked by occurance of #PCDATA. - * - * @param string the name of the XML element - * @exception ExpatParserException if there is no CDATA but method - * was called - * @access public - */ - public function characters($data) { - $s = trim($data); - if (strlen($s) > 0) { - throw new ExpatParseException("Unexpected text '$s'", $this->parser->getLocation()); - } - } -} diff --git a/buildscripts/phing/classes/phing/parser/AbstractSAXParser.php b/buildscripts/phing/classes/phing/parser/AbstractSAXParser.php deleted file mode 100644 index 60cf0c11..00000000 --- a/buildscripts/phing/classes/phing/parser/AbstractSAXParser.php +++ /dev/null @@ -1,140 +0,0 @@ -. - */ - -/** - * The abstract SAX parser class. - * - * This class represents a SAX parser. It is a abstract calss that must be - * implemented by the real parser that must extend this class - * - * @author Andreas Aderhold - * @author Hans Lellelid - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.13 $ - * @package phing.parser - */ -abstract class AbstractSAXParser { - - /** The AbstractHandler object. */ - protected $handler; - - /** - * Constructs a SAX parser - */ - function __construct() {} - - /** - * Sets options for PHP interal parser. Must be implemented by the parser - * class if it should be used. - */ - abstract function parserSetOption($opt, $val); - - /** - * Sets the current element handler object for this parser. Usually this - * is an object using extending "AbstractHandler". - * - * @param AbstractHandler $obj The handler object. - */ - function setHandler( $obj) { - $this->handler = $obj; - } - - /** - * Method that gets invoked when the parser runs over a XML start element. - * - * This method is called by PHP's internal parser funcitons and registered - * in the actual parser implementation. - * It gives control to the current active handler object by calling the - * startElement() method. - * - * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS - * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION. - * - * @param object the php's internal parser handle - * @param string the open tag name - * @param array the tag's attributes if any - */ - function startElement($parser, $name, $attribs) { - try { - $this->handler->startElement($name, $attribs); - } catch (Exception $e) { - print "[Exception in XML parsing]\n"; - print $e; - Phing::halt(-1); - } - } - - /** - * Method that gets invoked when the parser runs over a XML close element. - * - * This method is called by PHP's internal parser funcitons and registered - * in the actual parser implementation. - * - * It gives control to the current active handler object by calling the - * endElement() method. - * - * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS - * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION. - * - * @param object the php's internal parser handle - * @param string the closing tag name - */ - function endElement($parser, $name) { - try { - $this->handler->endElement($name); - } catch (Exception $e) { - print "[Exception in XML parsing]\n"; - print $e; - Phing::halt(-1); - } - } - - /** - * Method that gets invoked when the parser runs over CDATA. - * - * This method is called by PHP's internal parser functions and registered - * in the actual parser implementation. - * - * It gives control to the current active handler object by calling the - * characters() method. That processes the given CDATA. - * - * BECAUSE OF PROBLEMS WITH EXCEPTIONS BUBBLING UP THROUGH xml_parse() THIS - * METHOD WILL CALL Phing::halt(-1) ON EXCEPTION. - * - * @param resource $parser php's internal parser handle. - * @param string $data the CDATA - */ - function characters($parser, $data) { - try { - $this->handler->characters($data); - } catch (Exception $e) { - print "[Exception in XML parsing]\n"; - print $e; - Phing::halt(-1); - } - } - - /** - * Entrypoint for parser. This method needs to be implemented by the - * child classt that utilizes the concrete parser - */ - abstract function parse(); -} diff --git a/buildscripts/phing/classes/phing/parser/DataTypeHandler.php b/buildscripts/phing/classes/phing/parser/DataTypeHandler.php deleted file mode 100644 index 37d757c4..00000000 --- a/buildscripts/phing/classes/phing/parser/DataTypeHandler.php +++ /dev/null @@ -1,144 +0,0 @@ -. - */ - -include_once 'phing/RuntimeConfigurable.php'; - -/** - * Configures a Project (complete with Targets and Tasks) based on - * a XML build file. - *

- * Design/ZE2 migration note: - * If PHP would support nested classes. All the phing/parser/*Filter - * classes would be nested within this class - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.8 $ $Date: 2005/11/02 13:55:33 $ - * @access public - * @package phing.parser - */ - -class DataTypeHandler extends AbstractHandler { - - private $target; - private $element; - private $wrapper; - - /** - * Constructs a new DataTypeHandler and sets up everything. - * - * @param AbstractSAXParser $parser The XML parser (default: ExpatParser) - * @param AbstractHandler $parentHandler The parent handler that invoked this handler. - * @param ProjectConfigurator $configurator The ProjectConfigurator object - * @param Target $target The target object this datatype is contained in (null for top-level datatypes). - */ - function __construct(AbstractSAXParser $parser, AbstractHandler $parentHandler, ProjectConfigurator $configurator, $target = null) { // FIXME b2 typehinting - parent::__construct($parser, $parentHandler); - $this->target = $target; - $this->configurator = $configurator; - } - - /** - * Executes initialization actions required to setup the data structures - * related to the tag. - *

- * This includes: - *

    - *
  • creation of the datatype object
  • - *
  • calling the setters for attributes
  • - *
  • adding the type to the target object if any
  • - *
  • adding a reference to the task (if id attribute is given)
  • - *
- * - * @param string the tag that comes in - * @param array attributes the tag carries - * @throws ExpatParseException if attributes are incomplete or invalid - * @access public - */ - function init($propType, $attrs) { - // shorthands - $project = $this->configurator->project; - $configurator = $this->configurator; - - try {//try - $this->element = $project->createDataType($propType); - - if ($this->element === null) { - throw new BuildException("Unknown data type $propType"); - } - - if ($this->target !== null) { - $this->wrapper = new RuntimeConfigurable($this->element, $propType); - $this->wrapper->setAttributes($attrs); - $this->target->addDataType($this->wrapper); - } else { - $configurator->configure($this->element, $attrs, $project); - $configurator->configureId($this->element, $attrs); - } - - } catch (BuildException $exc) { - throw new ExpatParseException($exc, $this->parser->getLocation()); - } - } - - /** - * Handles character data. - * - * @param string the CDATA that comes in - * @access public - */ - function characters($data) { - $project = $this->configurator->project; - try {//try - $this->configurator->addText($project, $this->element, $data); - } catch (BuildException $exc) { - throw new ExpatParseException($exc->getMessage(), $this->parser->getLocation()); - } - } - - /** - * Checks for nested tags within the current one. Creates and calls - * handlers respectively. - * - * @param string the tag that comes in - * @param array attributes the tag carries - * @access public - */ - function startElement($name, $attrs) { - $nef = new NestedElementHandler($this->parser, $this, $this->configurator, $this->element, $this->wrapper, $this->target); - $nef->init($name, $attrs); - } - - /** - * Overrides endElement for data types. Tells the type - * handler that processing the element had been finished so - * handlers know they can perform actions that need to be - * based on the data contained within the element. - * - * @param string the name of the XML element - * @return void - */ - function endElement($name) { - $this->element->parsingComplete(); - parent::endElement($name); - } - -} diff --git a/buildscripts/phing/classes/phing/parser/ExpatParseException.php b/buildscripts/phing/classes/phing/parser/ExpatParseException.php deleted file mode 100644 index d5086c30..00000000 --- a/buildscripts/phing/classes/phing/parser/ExpatParseException.php +++ /dev/null @@ -1,31 +0,0 @@ -. - */ - -require_once 'phing/BuildException.php'; - -/** - * This class throws errors for Expat, the XML processor. - * - * @author Andreas Aderhold, andi@binarycloud.com - * @version $Revision: 1.5 $ $Date: 2003/11/19 05:48:28 $ - * @package phing.parser - */ -class ExpatParseException extends BuildException {} diff --git a/buildscripts/phing/classes/phing/parser/ExpatParser.php b/buildscripts/phing/classes/phing/parser/ExpatParser.php deleted file mode 100644 index 82046f8d..00000000 --- a/buildscripts/phing/classes/phing/parser/ExpatParser.php +++ /dev/null @@ -1,140 +0,0 @@ -. - */ - -require_once 'phing/parser/AbstractSAXParser.php'; -include_once 'phing/parser/ExpatParseException.php'; -include_once 'phing/system/io/IOException.php'; -include_once 'phing/system/io/FileReader.php'; - -/** - * This class is a wrapper for the PHP's internal expat parser. - * - * It takes an XML file represented by a abstract path name, and starts - * parsing the file and calling the different "trap" methods inherited from - * the AbstractParser class. - * - * Those methods then invoke the represenatative methods in the registered - * handler classes. - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.8 $ $Date: 2005/05/26 13:10:52 $ - * @access public - * @package phing.parser - */ - -class ExpatParser extends AbstractSAXParser { - - /** @var resource */ - private $parser; - - /** @var Reader */ - private $reader; - - private $file; - - private $buffer = 4096; - - private $error_string = ""; - - private $line = 0; - - /** @var Location Current cursor pos in XML file. */ - private $location; - - /** - * Constructs a new ExpatParser object. - * - * The constructor accepts a PhingFile object that represents the filename - * for the file to be parsed. It sets up php's internal expat parser - * and options. - * - * @param Reader $reader The Reader Object that is to be read from. - * @param string $filename Filename to read. - * @throws Exception if the given argument is not a PhingFile object - */ - function __construct(Reader $reader, $filename=null) { - - $this->reader = $reader; - if ($filename !== null) { - $this->file = new PhingFile($filename); - } - $this->parser = xml_parser_create(); - $this->buffer = 4096; - $this->location = new Location(); - xml_set_object($this->parser, $this); - xml_set_element_handler($this->parser, array($this,"startElement"),array($this,"endElement")); - xml_set_character_data_handler($this->parser, array($this, "characters")); - } - - /** - * Override PHP's parser default settings, created in the constructor. - * - * @param string the option to set - * @throws mixed the value to set - * @return boolean true if the option could be set, otherwise false - * @access public - */ - function parserSetOption($opt, $val) { - return xml_parser_set_option($this->parser, $opt, $val); - } - - /** - * Returns the location object of the current parsed element. It describes - * the location of the element within the XML file (line, char) - * - * @return object the location of the current parser - * @access public - */ - function getLocation() { - if ($this->file !== null) { - $path = $this->file->getAbsolutePath(); - } else { - $path = $this->reader->getResource(); - } - $this->location = new Location($path, xml_get_current_line_number($this->parser), xml_get_current_column_number($this->parser)); - return $this->location; - } - - /** - * Starts the parsing process. - * - * @param string the option to set - * @return int 1 if the parsing succeeded - * @throws ExpatParseException if something gone wrong during parsing - * @throws IOException if XML file can not be accessed - * @access public - */ - function parse() { - - while ( ($data = $this->reader->read()) !== -1 ) { - if (!xml_parse($this->parser, $data, $this->reader->eof())) { - $error = xml_error_string(xml_get_error_code($this->parser)); - $e = new ExpatParseException($error, $this->getLocation()); - xml_parser_free($this->parser); - throw $e; - } - } - xml_parser_free($this->parser); - - return 1; - } -} diff --git a/buildscripts/phing/classes/phing/parser/Location.php b/buildscripts/phing/classes/phing/parser/Location.php deleted file mode 100644 index fd79866c..00000000 --- a/buildscripts/phing/classes/phing/parser/Location.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -/** - * Stores the file name and line number of a XML file - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.6 $ $Date: 2003/12/24 13:02:09 $ - * @access public - * @package phing.parser - */ - -class Location { - - private $fileName; - private $lineNumber; - private $columnNumber; - - /** - * Constructs the location consisting of a file name and line number - * - * @param string the filename - * @param integer the line number - * @param integer the column number - * @access public - */ - function Location($fileName = null, $lineNumber = null, $columnNumber = null) { - $this->fileName = $fileName; - $this->lineNumber = $lineNumber; - $this->columnNumber = $columnNumber; - } - - /** - * Returns the file name, line number and a trailing space. - * - * An error message can be appended easily. For unknown locations, - * returns empty string. - * - * @return string the string representation of this Location object - * @access public - */ - function toString() { - $buf = ""; - if ($this->fileName !== null) { - $buf.=$this->fileName; - if ($this->lineNumber !== null) { - $buf.= ":".$this->lineNumber; - } - $buf.=":".$this->columnNumber; - } - return (string) $buf; - } -} diff --git a/buildscripts/phing/classes/phing/parser/NestedElementHandler.php b/buildscripts/phing/classes/phing/parser/NestedElementHandler.php deleted file mode 100644 index 8ecd0ed3..00000000 --- a/buildscripts/phing/classes/phing/parser/NestedElementHandler.php +++ /dev/null @@ -1,186 +0,0 @@ -. - */ - -include_once 'phing/IntrospectionHelper.php'; -include_once 'phing/TaskContainer.php'; - -/** - * The nested element handler class. - * - * This class handles the occurance of runtime registered tags like - * datatypes (fileset, patternset, etc) and it's possible nested tags. It - * introspects the implementation of the class and sets up the data structures. - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.10 $ $Date: 2005/10/04 19:13:44 $ - * @access public - * @package phing.parser - */ - -class NestedElementHandler extends AbstractHandler { - - /** - * Reference to the parent object that represents the parent tag - * of this nested element - * @var object - */ - private $parent; - - /** - * Reference to the child object that represents the child tag - * of this nested element - * @var object - */ - private $child; - - /** - * Reference to the parent wrapper object - * @var object - */ - private $parentWrapper; - - /** - * Reference to the child wrapper object - * @var object - */ - private $childWrapper; - - /** - * Reference to the related target object - * @var object the target instance - */ - private $target; - - /** - * Constructs a new NestedElement handler and sets up everything. - * - * @param object the ExpatParser object - * @param object the parent handler that invoked this handler - * @param object the ProjectConfigurator object - * @param object the parent object this element is contained in - * @param object the parent wrapper object - * @param object the target object this task is contained in - * @access public - */ - function __construct($parser, $parentHandler, $configurator, $parent, $parentWrapper, $target) { - parent::__construct($parser, $parentHandler); - $this->configurator = $configurator; - if ($parent instanceof TaskAdapter) { - $this->parent = $parent->getProxy(); - } else { - $this->parent = $parent; - } - $this->parentWrapper = $parentWrapper; - $this->target = $target; - } - - /** - * Executes initialization actions required to setup the data structures - * related to the tag. - *

- * This includes: - *

    - *
  • creation of the nested element
  • - *
  • calling the setters for attributes
  • - *
  • adding the element to the container object
  • - *
  • adding a reference to the element (if id attribute is given)
  • - *
- * - * @param string the tag that comes in - * @param array attributes the tag carries - * @throws ExpatParseException if the setup process fails - * @access public - */ - function init($propType, $attrs) { - $configurator = $this->configurator; - $project = $this->configurator->project; - - // introspect the parent class that is custom - $parentClass = get_class($this->parent); - $ih = IntrospectionHelper::getHelper($parentClass); - try { - if ($this->parent instanceof UnknownElement) { - $this->child = new UnknownElement(strtolower($propType)); - $this->parent->addChild($this->child); - } else { - $this->child = $ih->createElement($project, $this->parent, strtolower($propType)); - } - - $configurator->configureId($this->child, $attrs); - - if ($this->parentWrapper !== null) { - $this->childWrapper = new RuntimeConfigurable($this->child, $propType); - $this->childWrapper->setAttributes($attrs); - $this->parentWrapper->addChild($this->childWrapper); - } else { - $configurator->configure($this->child, $attrs, $project); - $ih->storeElement($project, $this->parent, $this->child, strtolower($propType)); - } - } catch (BuildException $exc) { - throw new ExpatParseException("Error initializing nested element <$propType>", $exc, $this->parser->getLocation()); - } - } - - /** - * Handles character data. - * - * @param string the CDATA that comes in - * @throws ExpatParseException if the CDATA could not be set-up properly - * @access public - */ - function characters($data) { - - $configurator = $this->configurator; - $project = $this->configurator->project; - - if ($this->parentWrapper === null) { - try { - $configurator->addText($project, $this->child, $data); - } catch (BuildException $exc) { - throw new ExpatParseException($exc->getMessage(), $this->parser->getLocation()); - } - } else { - $this->childWrapper->addText($data); - } - } - - /** - * Checks for nested tags within the current one. Creates and calls - * handlers respectively. - * - * @param string the tag that comes in - * @param array attributes the tag carries - * @access public - */ - function startElement($name, $attrs) { - //print(get_class($this) . " name = $name, attrs = " . implode(",",$attrs) . "\n"); - if ($this->child instanceof TaskContainer) { - // taskcontainer nested element can contain other tasks - no other - // nested elements possible - $tc = new TaskHandler($this->parser, $this, $this->configurator, $this->child, $this->childWrapper, $this->target); - $tc->init($name, $attrs); - } else { - $neh = new NestedElementHandler($this->parser, $this, $this->configurator, $this->child, $this->childWrapper, $this->target); - $neh->init($name, $attrs); - } - } -} diff --git a/buildscripts/phing/classes/phing/parser/ProjectConfigurator.php b/buildscripts/phing/classes/phing/parser/ProjectConfigurator.php deleted file mode 100644 index 6b69e955..00000000 --- a/buildscripts/phing/classes/phing/parser/ProjectConfigurator.php +++ /dev/null @@ -1,246 +0,0 @@ -. - */ - -include_once 'phing/system/io/BufferedReader.php'; -include_once 'phing/system/io/FileReader.php'; -include_once 'phing/BuildException.php'; -include_once 'phing/system/lang/FileNotFoundException.php'; -include_once 'phing/system/io/PhingFile.php'; - -/** - * The datatype handler class. - * - * This class handles the occurance of registered datatype tags like - * FileSet - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.17 $ $Date: 2006/01/06 14:57:18 $ - * @access public - * @package phing.parser - */ -class ProjectConfigurator { - - public $project; - public $locator; - - public $buildFile; - public $buildFileParent; - - /** - * Static call to ProjectConfigurator. Use this to configure a - * project. Do not use the new operator. - * - * @param object the Project instance this configurator should use - * @param object the buildfile object the parser should use - * @access public - */ - public static function configureProject(Project $project, PhingFile $buildFile) { - $pc = new ProjectConfigurator($project, $buildFile); - $pc->parse(); - } - - /** - * Constructs a new ProjectConfigurator object - * This constructor is private. Use a static call to - * configureProject to configure a project. - * - * @param object the Project instance this configurator should use - * @param object the buildfile object the parser should use - * @access private - */ - function __construct(Project $project, PhingFile $buildFile) { - $this->project = $project; - $this->buildFile = new PhingFile($buildFile->getAbsolutePath()); - $this->buildFileParent = new PhingFile($this->buildFile->getParent()); - } - - /** - * Creates the ExpatParser, sets root handler and kick off parsing - * process. - * - * @throws BuildException if there is any kind of execption during - * the parsing process - * @access private - */ - protected function parse() { - try { - $reader = new BufferedReader(new FileReader($this->buildFile)); - $reader->open(); - $parser = new ExpatParser($reader); - $parser->parserSetOption(XML_OPTION_CASE_FOLDING,0); - $parser->setHandler(new RootHandler($parser, $this)); - $this->project->log("parsing buildfile ".$this->buildFile->getName(), PROJECT_MSG_VERBOSE); - $parser->parse(); - $reader->close(); - } catch (Exception $exc) { - throw new BuildException("Error reading project file", $exc); - } - } - - /** - * Configures an element and resolves eventually given properties. - * - * @param object the element to configure - * @param array the element's attributes - * @param object the project this element belongs to - * @throws Exception if arguments are not valid - * @throws BuildException if attributes can not be configured - * @access public - */ - function configure($target, $attrs, Project $project) { - - if ($target instanceof TaskAdapter) { - $target = $target->getProxy(); - } - - // if the target is an UnknownElement, this means that the tag had not been registered - // when the enclosing element (task, target, etc.) was configured. It is possible, however, - // that the tag was registered (e.g. using ) after the original configuration. - // ... so, try to load it again: - if ($target instanceof UnknownElement) { - $tryTarget = $project->createTask($target->getTaskType()); - if ($tryTarget) { - $target = $tryTarget; - } - } - - $bean = get_class($target); - $ih = IntrospectionHelper::getHelper($bean); - - foreach ($attrs as $key => $value) { - if ($key == 'id') { - continue; - // throw new BuildException("Id must be set Extermnally"); - } - $value = self::replaceProperties($project, $value, $project->getProperties()); - try { // try to set the attribute - $ih->setAttribute($project, $target, strtolower($key), $value); - } catch (BuildException $be) { - // id attribute must be set externally - if ($key !== "id") { - throw $be; - } - } - } - } - - /** - * Configures the #CDATA of an element. - * - * @param object the project this element belongs to - * @param object the element to configure - * @param string the element's #CDATA - * @access public - */ - function addText($project, $target, $text = null) { - if ($text === null || strlen(trim($text)) === 0) { - return; - } - $ih = IntrospectionHelper::getHelper(get_class($target)); - $text = self::replaceProperties($project, $text, $project->getProperties()); - $ih->addText($project, $target, $text); - } - - /** - * Stores a configured child element into its parent object - * - * @param object the project this element belongs to - * @param object the parent element - * @param object the child element - * @param string the XML tagname - * @access public - */ - function storeChild($project, $parent, $child, $tag) { - $ih = IntrospectionHelper::getHelper(get_class($parent)); - $ih->storeElement($project, $parent, $child, $tag); - } - - // The following two properties are a sort of hack - // to enable a static function to serve as the callback - // for preg_replace_callback(). Clearly we cannot use object - // variables, since the replaceProperties() is called statically. - // This is IMO better than using global variables in the callback. - - private static $propReplaceProject; - private static $propReplaceProperties; - - /** - * Replace ${} style constructions in the given value with the - * string value of the corresponding data types. This method is - * static. - * - * @param object the project that should be used for property look-ups - * @param string the string to be scanned for property references - * @param array proeprty keys - * @return string the replaced string or null if the string - * itself was null - */ - public static function replaceProperties(Project $project, $value, $keys) { - - if ($value === null) { - return null; - } - - // These are a "hack" to support static callback for preg_replace_callback() - - // make sure these get initialized every time - self::$propReplaceProperties = $keys; - self::$propReplaceProject = $project; - - // Because we're not doing anything special (like multiple passes), - // regex is the simplest / fastest. PropertyTask, though, uses - // the old parsePropertyString() method, since it has more stringent - // requirements. - - $sb = preg_replace_callback('/\$\{([^}]+)\}/', array('ProjectConfigurator', 'replacePropertyCallback'), $value); - return $sb; - } - - /** - * Private [static] function for use by preg_replace_callback to replace a single param. - * This method makes use of a static variable to hold the - */ - private static function replacePropertyCallback($matches) - { - $propertyName = $matches[1]; - if (!isset(self::$propReplaceProperties[$propertyName])) { - self::$propReplaceProject->log('Property ${'.$propertyName.'} has not been set.', PROJECT_MSG_VERBOSE); - return $matches[0]; - } else { - self::$propReplaceProject->log('Property ${'.$propertyName.'} => ' . self::$propReplaceProperties[$propertyName], PROJECT_MSG_DEBUG); - } - return self::$propReplaceProperties[$propertyName]; - } - - /** - * Scan Attributes for the id attribute and maybe add a reference to - * project. - * - * @param object the element's object - * @param array the element's attributes - */ - function configureId(&$target, $attr) { - if (isset($attr['id']) && $attr['id'] !== null) { - $this->project->addReference($attr['id'], $target); - } - } -} diff --git a/buildscripts/phing/classes/phing/parser/ProjectHandler.php b/buildscripts/phing/classes/phing/parser/ProjectHandler.php deleted file mode 100644 index 54486ec9..00000000 --- a/buildscripts/phing/classes/phing/parser/ProjectHandler.php +++ /dev/null @@ -1,146 +0,0 @@ -. - */ - -require_once 'phing/parser/AbstractHandler.php'; -require_once 'phing/system/io/PhingFile.php'; - -/** - * Handler class for the XML element This class handles all elements - * under the element. - * - * @author Andreas Aderhold - * @copyright (c) 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.14 $ $Date: 2005/10/04 19:13:44 $ - * @access public - * @package phing.parser - */ -class ProjectHandler extends AbstractHandler { - - /** - * The phing project configurator object. - * @var ProjectConfigurator - */ - private $configurator; - - /** - * Constructs a new ProjectHandler - * - * @param object the ExpatParser object - * @param object the parent handler that invoked this handler - * @param object the ProjectConfigurator object - * @access public - */ - function __construct($parser, $parentHandler, $configurator) { - $this->configurator = $configurator; - parent::__construct($parser, $parentHandler); - } - - /** - * Executes initialization actions required to setup the project. Usually - * this method handles the attributes of a tag. - * - * @param string the tag that comes in - * @param array attributes the tag carries - * @param object the ProjectConfigurator object - * @throws ExpatParseException if attributes are incomplete or invalid - * @access public - */ - function init($tag, $attrs) { - $def = null; - $name = null; - $id = null; - $baseDir = null; - - // some shorthands - $project = $this->configurator->project; - $buildFileParent = $this->configurator->buildFileParent; - - foreach ($attrs as $key => $value) { - if ($key === "default") { - $def = $value; - } elseif ($key === "name") { - $name = $value; - } elseif ($key === "id") { - $id = $value; - } elseif ($key === "basedir") { - $baseDir = $value; - } else { - throw new ExpatParseException("Unexpected attribute '$key'"); - } - } - if ($def === null) { - throw new ExpatParseException("The default attribute of project is required"); - } - $project->setDefaultTarget($def); - - if ($name !== null) { - $project->setName($name); - $project->addReference($name, $project); - } - - if ($id !== null) { - $project->addReference($id, $project); - } - - if ($project->getProperty("project.basedir") !== null) { - $project->setBasedir($project->getProperty("project.basedir")); - } else { - if ($baseDir === null) { - $project->setBasedir($buildFileParent->getAbsolutePath()); - } else { - // check whether the user has specified an absolute path - $f = new PhingFile($baseDir); - if ($f->isAbsolute()) { - $project->setBasedir($baseDir); - } else { - $project->setBaseDir($project->resolveFile($baseDir, $buildFileParent)); - } - } - } - } - - /** - * Handles start elements within the tag by creating and - * calling the required handlers for the detected element. - * - * @param string the tag that comes in - * @param array attributes the tag carries - * @throws ExpatParseException if a unxepected element occurs - * @access public - */ - function startElement($name, $attrs) { - - $project = $this->configurator->project; - $types = $project->getDataTypeDefinitions(); - - if ($name == "target") { - $tf = new TargetHandler($this->parser, $this, $this->configurator); - $tf->init($name, $attrs); - } elseif (isset($types[$name])) { - $tyf = new DataTypeHandler($this->parser, $this, $this->configurator); - $tyf->init($name, $attrs); - } else { - $tf = new TaskHandler($this->parser, $this, $this->configurator); - $tf->init($name, $attrs); - } - } -} - diff --git a/buildscripts/phing/classes/phing/parser/RootHandler.php b/buildscripts/phing/classes/phing/parser/RootHandler.php deleted file mode 100644 index 28afb5d5..00000000 --- a/buildscripts/phing/classes/phing/parser/RootHandler.php +++ /dev/null @@ -1,82 +0,0 @@ -. - */ - -require_once 'phing/parser/AbstractHandler.php'; -include_once 'phing/parser/ExpatParseException.php'; -include_once 'phing/parser/ProjectHandler.php'; - -/** - * Root filter class for a phing buildfile. - * - * The root filter is called by the parser first. This is where the phing - * specific parsing starts. RootHandler decides what to do next. - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.7 $ - * @package phing.parser - */ -class RootHandler extends AbstractHandler { - - /** - * The phing project configurator object - */ - private $configurator; - - /** - * Constructs a new RootHandler - * - * The root filter is required so the parser knows what to do. It's - * called by the ExpatParser that is instatiated in ProjectConfigurator. - * - * It recieves the expat parse object ref and a reference to the - * configurator - * - * @param AbstractSAXParser $parser The ExpatParser object. - * @param ProjectConfigurator $configurator The ProjectConfigurator object. - */ - function __construct(AbstractSAXParser $parser, ProjectConfigurator $configurator) { - $this->configurator = $configurator; - parent::__construct($parser, $this); - } - - /** - * Kick off a custom action for a start element tag. - * - * The root element of our buildfile is the <project> element. The - * root filter handles this element if it occurs, creates ProjectHandler - * to handle any nested tags & attributes of the <project> tag, - * and calls init. - * - * @param string $tag The xml tagname - * @param array $attrs The attributes of the tag - * @throws ExpatParseException if the first element within our build file - * is not the >project< element - */ - function startElement($tag, $attrs) { - if ($tag === "project") { - $ph = new ProjectHandler($this->parser, $this, $this->configurator); - $ph->init($tag, $attrs); - } else { - throw new ExpatParseException("Unexpected tag <$tag> in top-level of build file.", $this->parser->getLocation()); - } - } -} diff --git a/buildscripts/phing/classes/phing/parser/TargetHandler.php b/buildscripts/phing/classes/phing/parser/TargetHandler.php deleted file mode 100644 index 7ca94b44..00000000 --- a/buildscripts/phing/classes/phing/parser/TargetHandler.php +++ /dev/null @@ -1,149 +0,0 @@ -. - */ - -require_once 'phing/parser/AbstractHandler.php'; - -/** - * The target handler class. - * - * This class handles the occurance of a tag and it's possible - * nested tags (datatypes and tasks). - * - * @author Andreas Aderhold - * @copyright 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.10 $ - * @package phing.parser - */ -class TargetHandler extends AbstractHandler { - - /** - * Reference to the target object that represents the currently parsed - * target. - * @var object the target instance - */ - private $target; - - /** - * The phing project configurator object - * @var ProjectConfigurator - */ - private $configurator; - - /** - * Constructs a new TargetHandler - * - * @param object the ExpatParser object - * @param object the parent handler that invoked this handler - * @param object the ProjectConfigurator object - */ - function __construct(AbstractSAXParser $parser, AbstractHandler $parentHandler, ProjectConfigurator $configurator) { - parent::__construct($parser, $parentHandler); - $this->configurator = $configurator; - } - - /** - * Executes initialization actions required to setup the data structures - * related to the tag. - *

- * This includes: - *

    - *
  • creation of the target object
  • - *
  • calling the setters for attributes
  • - *
  • adding the target to the project
  • - *
  • adding a reference to the target (if id attribute is given)
  • - *
- * - * @param string the tag that comes in - * @param array attributes the tag carries - * @throws ExpatParseException if attributes are incomplete or invalid - */ - function init($tag, $attrs) { - $name = null; - $depends = ""; - $ifCond = null; - $unlessCond = null; - $id = null; - $description = null; - - foreach($attrs as $key => $value) { - if ($key==="name") { - $name = (string) $value; - } else if ($key==="depends") { - $depends = (string) $value; - } else if ($key==="if") { - $ifCond = (string) $value; - } else if ($key==="unless") { - $unlessCond = (string) $value; - } else if ($key==="id") { - $id = (string) $value; - } else if ($key==="description") { - $description = (string)$value; - } else { - throw new ExpatParseException("Unexpected attribute '$key'", $this->parser->getLocation()); - } - } - - if ($name === null) { - throw new ExpatParseException("target element appears without a name attribute", $this->parser->getLocation()); - } - - // shorthand - $project = $this->configurator->project; - - $this->target = new Target(); - $this->target->setName($name); - $this->target->setIf($ifCond); - $this->target->setUnless($unlessCond); - $this->target->setDescription($description); - - $project->addTarget($name, $this->target); - - if ($id !== null && $id !== "") { - $project->addReference($id, $this->target); - } - // take care of dependencies - if (strlen($depends) > 0) { - $this->target->setDepends($depends); - } - - } - - /** - * Checks for nested tags within the current one. Creates and calls - * handlers respectively. - * - * @param string the tag that comes in - * @param array attributes the tag carries - */ - function startElement($name, $attrs) { - // shorthands - $project = $this->configurator->project; - $types = $project->getDataTypeDefinitions(); - - if (isset($types[$name])) { - $th = new DataTypeHandler($this->parser, $this, $this->configurator, $this->target); - $th->init($name, $attrs); - } else { - $tmp = new TaskHandler($this->parser, $this, $this->configurator, $this->target, null, $this->target); - $tmp->init($name, $attrs); - } - } -} diff --git a/buildscripts/phing/classes/phing/parser/TaskHandler.php b/buildscripts/phing/classes/phing/parser/TaskHandler.php deleted file mode 100644 index 976aebf2..00000000 --- a/buildscripts/phing/classes/phing/parser/TaskHandler.php +++ /dev/null @@ -1,229 +0,0 @@ -. - */ - -include_once 'phing/UnknownElement.php'; - -/** - * The task handler class. - * - * This class handles the occurance of a tag and it's possible - * nested tags (datatypes and tasks) that may be unknown off bat and are - * initialized on the fly. - * - * @author Andreas Aderhold - * @copyright © 2001,2002 THYRELL. All rights reserved - * @version $Revision: 1.10 $ - * @package phing.parser - */ -class TaskHandler extends AbstractHandler { - - /** - * Reference to the target object that contains the currently parsed - * task - * @var object the target instance - */ - private $target; - - /** - * Reference to the target object that represents the currently parsed - * target. This must not necessarily be a target, hence extra variable. - * @var object the target instance - */ - private $container; - - /** - * Reference to the task object that represents the currently parsed - * target. - * @var Task - */ - private $task; - - /** - * Wrapper for the parent element, if any. The wrapper for this - * element will be added to this wrapper as a child. - * @var RuntimeConfigurable - */ - private $parentWrapper; - - /** - * Wrapper for this element which takes care of actually configuring - * the element, if this element is contained within a target. - * Otherwise the configuration is performed with the configure method. - * @see ProjectHelper::configure(Object,AttributeList,Project) - */ - private $wrapper; - - /** - * The phing project configurator object - * @var ProjectConfigurator - */ - private $configurator; - - /** - * Constructs a new TaskHandler and sets up everything. - * - * @param AbstractSAXParser The ExpatParser object - * @param object $parentHandler The parent handler that invoked this handler - * @param ProjectConfigurator $configurator - * @param TaskContainer $container The container object this task is contained in (null for top-level tasks). - * @param RuntimeConfigurable $parentWrapper Wrapper for the parent element, if any. - * @param Target $target The target object this task is contained in (null for top-level tasks). - */ - function __construct(AbstractSAXParser $parser, $parentHandler, ProjectConfigurator $configurator, $container = null, $parentWrapper = null, $target = null) { - - parent::__construct($parser, $parentHandler); - - if (($container !== null) && !($container instanceof TaskContainer)) { - throw new Exception("Argument expected to be a TaskContainer, got something else"); - } - if (($parentWrapper !== null) && !($parentWrapper instanceof RuntimeConfigurable)) { - throw new Exception("Argument expected to be a RuntimeConfigurable, got something else."); - } - if (($target !== null) && !($target instanceof Target)) { - throw new Exception("Argument expected to be a Target, got something else"); - } - - $this->configurator = $configurator; - $this->container = $container; - $this->parentWrapper = $parentWrapper; - $this->target = $target; - } - - /** - * Executes initialization actions required to setup the data structures - * related to the tag. - *

- * This includes: - *

    - *
  • creation of the task object
  • - *
  • calling the setters for attributes
  • - *
  • adding the task to the container object
  • - *
  • adding a reference to the task (if id attribute is given)
  • - *
  • executing the task if the container is the <project> - * element
  • - *
- * - * @param string $tag The tag that comes in - * @param array $attrs Attributes the tag carries - * @throws ExpatParseException if attributes are incomplete or invalid - */ - function init($tag, $attrs) { - // shorthands - try { - $configurator = $this->configurator; - $project = $this->configurator->project; - - $this->task = $project->createTask($tag); - } catch (BuildException $be) { - // swallow here, will be thrown again in - // UnknownElement->maybeConfigure if the problem persists. - print("Swallowing exception: ".$be->getMessage() . "\n"); - } - - // the task is not known of bat, try to load it on thy fly - if ($this->task === null) { - $this->task = new UnknownElement($tag); - $this->task->setProject($project); - $this->task->setTaskType($tag); - $this->task->setTaskName($tag); - } - - // add file position information to the task (from parser) - // should be used in task exceptions to provide details - $this->task->setLocation($this->parser->getLocation()); - $configurator->configureId($task, $attrs); - - if ($this->container) { - $this->container->addTask($this->task); - } - - // Top level tasks don't have associated targets - // FIXME: if we do like Ant 1.6 and create an implicitTarget in the projectconfigurator object - // then we don't need to check for null here ... but there's a lot of stuff that will break if we - // do that at this point. - if ($this->target !== null) { - $this->task->setOwningTarget($this->target); - $this->task->init(); - $this->wrapper = $this->task->getRuntimeConfigurableWrapper(); - $this->wrapper->setAttributes($attrs); - if ($this->parentWrapper !== null) { // this may not make sense only within this if-block, but it - // seems to address current use cases adequately - $this->parentWrapper->addChild($this->wrapper); - } - } else { - $this->task->init(); - $configurator->configure($this->task, $attrs, $project); - } - } - - /** - * Executes the task at once if it's directly beneath the tag. - */ - protected function finished() { - if ($this->task !== null && $this->target === null) { - try { - $this->task->main(); - } catch (Exception $e) { - $this->task->log($e->getMessage(), PROJECT_MSG_ERR); - throw $e; - } - } - } - - /** - * Handles character data. - * - * @param string $data The CDATA that comes in - */ - function characters($data) { - if ($this->wrapper === null) { - $configurator = $this->configurator; - $project = $this->configurator->project; - try { // try - $configurator->addText($project, $this->task, $data); - } catch (BuildException $exc) { - throw new ExpatParseException($exc->getMessage(), $this->parser->getLocation()); - } - } else { - $this->wrapper->addText($data); - } - } - - /** - * Checks for nested tags within the current one. Creates and calls - * handlers respectively. - * - * @param string $name The tag that comes in - * @param array $attrs Attributes the tag carries - */ - function startElement($name, $attrs) { - $project = $this->configurator->project; - if ($this->task instanceof TaskContainer) { - //print("TaskHandler::startElement() (TaskContainer) name = $name, attrs = " . implode(",",$attrs) . "\n"); - $th = new TaskHandler($this->parser, $this, $this->configurator, $this->task, $this->wrapper, $this->target); - $th->init($name, $attrs); - } else { - //print("TaskHandler::startElement() name = $name, attrs = " . implode(",",$attrs) . "\n"); - $tmp = new NestedElementHandler($this->parser, $this, $this->configurator, $this->task, $this->wrapper, $this->target); - $tmp->init($name, $attrs); - } - } -} diff --git a/buildscripts/phing/classes/phing/system/io/BufferedReader.php b/buildscripts/phing/classes/phing/system/io/BufferedReader.php deleted file mode 100644 index 4946985c..00000000 --- a/buildscripts/phing/classes/phing/system/io/BufferedReader.php +++ /dev/null @@ -1,170 +0,0 @@ -. -*/ - -include_once 'phing/system/io/Reader.php'; - -/* - * Convenience class for reading files. - * - * @author Yannick Lecaillez - * @version $Revision: 1.6 $ $Date: 2005/12/27 19:12:13 $ - * @access public - * @see FilterReader - * @package phing.system.io -*/ -class BufferedReader extends Reader { - - private $bufferSize = 0; - private $buffer = null; - private $bufferPos = 0; - - /** - * The Reader we are buffering for. - */ - private $in; - - /** - * - * @param object $reader The reader (e.g. FileReader). - * @param integer $buffsize The size of the buffer we should use for reading files. - * A large buffer ensures that most files (all scripts?) are parsed in 1 buffer. - */ - function __construct(Reader $reader, $buffsize = 65536) { - $this->in = $reader; - $this->bufferSize = $buffsize; - } - - /** - * Reads and returns $_bufferSize chunk of data. - * @return mixed buffer or -1 if EOF. - */ - function read($len = null) { - // ignore $len param, not sure how to hanlde it, since - // this should only read bufferSize amount of data. - if ($len !== null) { - $this->currentPosition = ftell($this->fd); - } - - if ( ($data = $this->in->read($this->bufferSize)) !== -1 ) { - - // not all files end with a newline character, so we also need to check EOF - if (!$this->in->eof()) { - - $notValidPart = strrchr($data, "\n"); - $notValidPartSize = strlen($notValidPart); - - if ( $notValidPartSize > 1 ) { - // Block doesn't finish on a EOL - // Find the last EOL and forgot all following stuff - $dataSize = strlen($data); - $validSize = $dataSize - $notValidPartSize + 1; - - $data = substr($data, 0, $validSize); - - // Rewind to the begining of the forgotten stuff. - $this->in->skip(-$notValidPartSize+1); - } - - } // if !EOF - } - return $data; - } - - function skip($n) { - return $this->in->skip($n); - } - - function reset() { - return $this->in->reset(); - } - - function close() { - return $this->in->close(); - } - - function open() { - return $this->in->open(); - } - - /** - * Read a line from input stream. - */ - function readLine() { - $line = null; - while ( ($ch = $this->readChar()) !== -1 ) { - if ( $ch === "\n" ) { - break; - } - $line .= $ch; - } - - // Warning : Not considering an empty line as an EOF - if ( $line === null && $ch !== -1 ) - return ""; - - return $line; - } - - /** - * Reads a single char from the reader. - * @return string single char or -1 if EOF. - */ - function readChar() { - - if ( $this->buffer === null ) { - // Buffer is empty, fill it ... - $read = $this->in->read($this->bufferSize); - if ($read === -1) { - $ch = -1; - } else { - $this->buffer = $read; - return $this->readChar(); // recurse - } - } else { - // Get next buffered char ... - // handle case where buffer is read-in, but is empty. The next readChar() will return -1 EOF, - // so we just return empty string (char) at this point. (Probably could also return -1 ...?) - $ch = ($this->buffer !== "") ? $this->buffer{$this->bufferPos} : ''; - $this->bufferPos++; - if ( $this->bufferPos >= strlen($this->buffer) ) { - $this->buffer = null; - $this->bufferPos = 0; - } - } - - return $ch; - } - - /** - * Returns whether eof has been reached in stream. - * This is important, because filters may want to know if the end of the file (and not just buffer) - * has been reached. - * @return boolean - */ - function eof() { - return $this->in->eof(); - } - - function getResource() { - return $this->in->getResource(); - } -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/BufferedWriter.php b/buildscripts/phing/classes/phing/system/io/BufferedWriter.php deleted file mode 100644 index c982db28..00000000 --- a/buildscripts/phing/classes/phing/system/io/BufferedWriter.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -include_once 'phing/system/io/Writer.php'; - -/** - * Convenience class for writing files. - * - * @author Hans Lellelid - * @version $Revision: 1.10 $ - * @package phing.system.io - */ -class BufferedWriter extends Writer { - - /** - * The size of the buffer in kb. - */ - private $bufferSize = 0; - - /** - * The Writer we are buffering output to. - */ - private $out; - - function __construct(Writer $writer, $buffsize = 8192) { - $this->out = $writer; - $this->bufferSize = $buffsize; - } - - function write($buf, $off = null, $len = null) { - return $this->out->write($buf, $off, $len); - } - - function newLine() { - $this->write(Phing::getProperty('line.separator')); - } - - function getResource() { - return $this->out->getResource(); - } - - function reset() { - return $this->out->reset(); - } - - function close() { - return $this->out->close(); - } - - function open() { - return $this->out->open(); - } - -} diff --git a/buildscripts/phing/classes/phing/system/io/ConsoleReader.php b/buildscripts/phing/classes/phing/system/io/ConsoleReader.php deleted file mode 100644 index 33b37619..00000000 --- a/buildscripts/phing/classes/phing/system/io/ConsoleReader.php +++ /dev/null @@ -1,84 +0,0 @@ -. - */ - -include_once 'phing/system/io/Reader.php'; - -/** - * Convenience class for reading console input. - * - * @author Hans Lellelid - * @author Matthew Hershberger - * @version $Revision: 1.4 $ - * @package phing.system.io - */ -class ConsoleReader extends Reader { - - function readLine() { - - $out = fgets(STDIN); // note: default maxlen is 1kb - $out = rtrim($out); - - return $out; - } - - /** - * - * @param int $len Num chars to read. - * @return string chars read or -1 if eof. - */ - function read($len = null) { - - $out = fread(STDIN, $len); - - - return $out; - // FIXME - // read by chars doesn't work (yet?) with PHP stdin. Maybe - // this is just a language feature, maybe there's a way to get - // ability to read chars w/o ? - - } - - function close() { - // STDIN is always open - } - - function open() { - // STDIN is always open - } - - /** - * Whether eof has been reached with stream. - * @return boolean - */ - function eof() { - return feof(STDIN); - } - - /** - * Returns path to file we are reading. - * @return string - */ - function getResource() { - return "console"; - } -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/FileReader.php b/buildscripts/phing/classes/phing/system/io/FileReader.php deleted file mode 100644 index cbea2c7e..00000000 --- a/buildscripts/phing/classes/phing/system/io/FileReader.php +++ /dev/null @@ -1,179 +0,0 @@ -. - */ - -include_once 'phing/system/io/PhingFile.php'; -include_once 'phing/system/io/Reader.php'; - -/** - * Convenience class for reading files. The constructor of this - * @package phing.system.io - */ - -class FileReader extends Reader { - - protected $file; - protected $fd; - - protected $currentPosition = 0; - protected $mark = 0; - - function __construct($file, $exclusive = false) { - - if ($file instanceof PhingFile) { - $this->file = $file; - } elseif (is_string($file)) { - $this->file = new PhingFile($file); - } else { - throw new Exception("Illegal argument type to " . __METHOD__); - } - } - - function skip($n) { - $this->open(); - - $start = $this->currentPosition; - - $ret = @fseek($this->fd, $n, SEEK_CUR); - if ( $ret === -1 ) - return -1; - - $this->currentPosition = ftell($this->fd); - - if ( $start > $this->currentPosition ) - $skipped = $start - $this->currentPosition; - else - $skipped = $this->currentPosition - $start; - - return $skipped; - } - - /** - * Read data from file. - * @param int $len Num chars to read. - * @return string chars read or -1 if eof. - */ - function read($len = null) { - $this->open(); - if (feof($this->fd)) { - return -1; - } - - // Compute length to read - // possible that filesize($this->file) will be larger than - // available bytes to read, but that's fine -- better to err on high end - $length = ($len === null) ? filesize($this->file->getAbsolutePath()) : $len; - - // Read data - $out = fread($this->fd, $length + 1); // adding 1 seems to ensure that next call to read() will return EOF (-1) - $this->currentPosition = ftell($this->fd); - - return $out; - } - - function mark($n = null) { - $this->mark = $this->currentPosition; - } - - function reset() { - // goes back to last mark, by default this would be 0 (i.e. rewind file). - fseek($this->fd, SEEK_SET, $this->mark); - $this->mark = 0; - } - - function close() { - if ($this->fd === null) { - return true; - } - - if (false === @fclose($this->fd)) { - // FAILED. - $msg = "Cannot fclose " . $this->file->__toString() . " $php_errormsg"; - throw new IOException($msg); - } else { - $this->fd = null; - return true; - } - } - - function open() { - global $php_errormsg; - - if ($this->fd === null) { - $this->fd = @fopen($this->file->getAbsolutePath(), "rb"); - } - - if ($this->fd === false) { - // fopen FAILED. - // Add error from php to end of log message. $php_errormsg. - $msg = "Cannot fopen ".$this->file->getAbsolutePath().". $php_errormsg"; - throw new IOException($msg); - } - - if (false) { - // Locks don't seem to work on windows??? HELP!!!!!!!!! - // if (FALSE === @flock($fp, LOCK_EX)) { // FAILED. - $msg = "Cannot acquire flock on $file. $php_errormsg"; - throw new IOException($msg); - } - - return true; - } - - /** - * Whether eof has been reached with stream. - * @return boolean - */ - function eof() { - return feof($this->fd); - } - - /** - * Reads a entire file and stores the data in the variable - * passed by reference. - * - * @param string $file String. Path and/or name of file to read. - * @param object &$rBuffer Reference. Variable of where to put contents. - * - * @return TRUE on success. Err object on failure. - * @author Charlie Killian, charlie@tizac.com - */ - function readInto(&$rBuffer) { - - $this->open(); - - $fileSize = $this->file->length(); - if ($fileSize === false) { - $msg = "Cannot get filesize of " . $this->file->__toString() . " $php_errormsg"; - throw new IOException($msg); - } - $rBuffer = fread($this->fd, $fileSize); - $this->close(); - } - - /** - * Returns path to file we are reading. - * @return string - */ - function getResource() { - return $this->file->toString(); - } -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/FileSystem.php b/buildscripts/phing/classes/phing/system/io/FileSystem.php deleted file mode 100644 index 2802ddfb..00000000 --- a/buildscripts/phing/classes/phing/system/io/FileSystem.php +++ /dev/null @@ -1,657 +0,0 @@ -. - */ - -/** - * This is an abstract class for platform specific filesystem implementations - * you have to implement each method in the platform specific filesystem implementation - * classes Your local filesytem implementation must extend this class. - * You should also use this class as a template to write your local implementation - * Some native PHP filesystem specific methods are abstracted here as well. Anyway - * you _must_ always use this methods via a PhingFile object (that by nature uses the - * *FileSystem drivers to access the real filesystem via this class using natives. - * - * FIXME: - * - Error handling reduced to min fallthrough runtime excetions - * more precise errorhandling is done by the PhingFile class - * - * @author Charlie Killian - * @author Hans Lellelid - * @version $Revision: 1.11 $ - * @package phing.system.io - */ -abstract class FileSystem { - - /* properties for simple boolean attributes */ - const BA_EXISTS = 0x01; - const BA_REGULAR = 0x02; - const BA_DIRECTORY = 0x04; - const BA_HIDDEN = 0x08; - - /** Instance for getFileSystem() method. */ - private static $fs; - - /** - * Static method to return the FileSystem singelton representing - * this platform's local filesystem driver. - */ - function getFileSystem() { - if (self::$fs === null) { - switch(Phing::getProperty('host.fstype')) { - case 'UNIX': - include_once 'phing/system/io/UnixFileSystem.php'; - self::$fs = new UnixFileSystem(); - break; - case 'WIN32': - include_once 'phing/system/io/Win32FileSystem.php'; - self::$fs = new Win32FileSystem(); - break; - case 'WINNT': - include_once 'phing/system/io/WinNTFileSystem.php'; - self::$fs = new WinNTFileSystem(); - break; - default: - throw new Exception("Host uses unsupported filesystem, unable to proceed"); - } - } - return self::$fs; - } - - /* -- Normalization and construction -- */ - - /** - * Return the local filesystem's name-separator character. - */ - abstract function getSeparator(); - - /** - * Return the local filesystem's path-separator character. - */ - abstract function getPathSeparator(); - - /** - * Convert the given pathname string to normal form. If the string is - * already in normal form then it is simply returned. - */ - abstract function normalize($strPath); - - /** - * Compute the length of this pathname string's prefix. The pathname - * string must be in normal form. - */ - abstract function prefixLength($pathname); - - /** - * Resolve the child pathname string against the parent. - * Both strings must be in normal form, and the result - * will be a string in normal form. - */ - abstract function resolve($parent, $child); - - /** - * Resolve the given abstract pathname into absolute form. Invoked by the - * getAbsolutePath and getCanonicalPath methods in the PhingFile class. - */ - abstract function resolveFile(PhingFile $f); - - /** - * Return the parent pathname string to be used when the parent-directory - * argument in one of the two-argument PhingFile constructors is the empty - * pathname. - */ - abstract function getDefaultParent(); - - /** - * Post-process the given URI path string if necessary. This is used on - * win32, e.g., to transform "/c:/foo" into "c:/foo". The path string - * still has slash separators; code in the PhingFile class will translate them - * after this method returns. - */ - abstract function fromURIPath($path); - - /* -- Path operations -- */ - - /** - * Tell whether or not the given abstract pathname is absolute. - */ - abstract function isAbsolute(PhingFile $f); - - /** - * canonicalize filename by checking on disk - * @return mixed Canonical path or false if the file doesn't exist. - */ - function canonicalize($strPath) { - return @realpath($strPath); - } - - /* -- Attribute accessors -- */ - - /** - * Return the simple boolean attributes for the file or directory denoted - * by the given abstract pathname, or zero if it does not exist or some - * other I/O error occurs. - */ - function getBooleanAttributes($f) { - throw new Exception("SYSTEM ERROR method getBooleanAttributes() not implemented by fs driver"); - } - - /** - * Check whether the file or directory denoted by the given abstract - * pathname may be accessed by this process. If the second argument is - * false, then a check for read access is made; if the second - * argument is true, then a check for write (not read-write) - * access is made. Return false if access is denied or an I/O error - * occurs. - */ - function checkAccess(PhingFile $f, $write = false) { - // we clear stat cache, its expensive to look up from scratch, - // but we need to be sure - @clearstatcache(); - - - // Shouldn't this be $f->GetAbsolutePath() ? - // And why doesn't GetAbsolutePath() work? - - $strPath = (string) $f->getPath(); - - // FIXME - // if file object does denote a file that yet not existst - // path rights are checked - if (!@file_exists($strPath) && !is_dir($strPath)) { - $strPath = $f->getParent(); - if ($strPath === null || !is_dir($strPath)) { - $strPath = Phing::getProperty("user.dir"); - } - //$strPath = dirname($strPath); - } - - if (!$write) { - return (boolean) @is_readable($strPath); - } else { - return (boolean) @is_writable($strPath); - } - } - - /** - * Return the time at which the file or directory denoted by the given - * abstract pathname was last modified, or zero if it does not exist or - * some other I/O error occurs. - */ - function getLastModifiedTime(PhingFile $f) { - - if (!$f->exists()) { - return 0; - } - - @clearstatcache(); - $strPath = (string) $f->getPath(); - $mtime = @filemtime($strPath); - if (false === $mtime) { - // FAILED. Log and return err. - $msg = "FileSystem::Filemtime() FAILED. Cannot can not get modified time of $strPath. $php_errormsg"; - throw new Exception($msg); - } else { - return (int) $mtime; - } - } - - /** - * Return the length in bytes of the file denoted by the given abstract - * pathname, or zero if it does not exist, is a directory, or some other - * I/O error occurs. - */ - function getLength(PhingFile $f) { - $strPath = (string) $f->getAbsolutePath(); - $fs = filesize((string) $strPath); - if ($fs !== false) { - return $fs; - } else { - $msg = "FileSystem::Read() FAILED. Cannot get filesize of $strPath. $php_errormsg"; - throw new Exception($msg); - } - } - - /* -- File operations -- */ - - /** - * Create a new empty file with the given pathname. Return - * true if the file was created and false if a - * file or directory with the given pathname already exists. Throw an - * IOException if an I/O error occurs. - * - * @param string Path of the file to be created. - * - * @throws IOException - */ - function createNewFile($strPathname) { - if (@file_exists($strPathname)) - return false; - - // Create new file - $fp = @fopen($strPathname, "w"); - if ($fp === false) { - throw new IOException("The file \"$strPathname\" could not be created"); - } - @fclose($fp); - return true; - } - - /** - * Delete the file or directory denoted by the given abstract pathname, - * returning true if and only if the operation succeeds. - */ - function delete(PhingFile $f) { - if ($f->isDirectory()) { - return $this->rmdir($f->getPath()); - } else { - return $this->unlink($f->getPath()); - } - } - - /** - * Arrange for the file or directory denoted by the given abstract - * pathname to be deleted when Phing::shutdown is called, returning - * true if and only if the operation succeeds. - */ - function deleteOnExit($f) { - throw new Exception("deleteOnExit() not implemented by local fs driver"); - } - - /** - * List the elements of the directory denoted by the given abstract - * pathname. Return an array of strings naming the elements of the - * directory if successful; otherwise, return null. - */ - function listDir(PhingFile $f) { - $strPath = (string) $f->getAbsolutePath(); - $d = @dir($strPath); - if (!$d) { - return null; - } - $list = array(); - while($entry = $d->read()) { - if ($entry != "." && $entry != "..") { - array_push($list, $entry); - } - } - $d->close(); - unset($d); - return $list; - } - - /** - * Create a new directory denoted by the given abstract pathname, - * returning true if and only if the operation succeeds. - */ - function createDirectory(&$f) { - return @mkdir($f->getAbsolutePath(),0755); - } - - /** - * Rename the file or directory denoted by the first abstract pathname to - * the second abstract pathname, returning true if and only if - * the operation succeeds. - * - * @param PhingFile $f1 abstract source file - * @param PhingFile $f2 abstract destination file - * @return void - * @throws Exception if rename cannot be performed - */ - function rename(PhingFile $f1, PhingFile $f2) { - // get the canonical paths of the file to rename - $src = $f1->getAbsolutePath(); - $dest = $f2->getAbsolutePath(); - if (false === @rename($src, $dest)) { - $msg = "Rename FAILED. Cannot rename $src to $dest. $php_errormsg"; - throw new Exception($msg); - } - } - - /** - * Set the last-modified time of the file or directory denoted by the - * given abstract pathname returning true if and only if the - * operation succeeds. - * @return void - * @throws Exception - */ - function setLastModifiedTime(PhingFile $f, $time) { - $path = $f->getPath(); - $success = @touch($path, $time); - if (!$success) { - throw new Exception("Could not create directory due to: $php_errormsg"); - } - } - - /** - * Mark the file or directory denoted by the given abstract pathname as - * read-only, returning true if and only if the operation - * succeeds. - */ - function setReadOnly($f) { - throw new Exception("setReadonle() not implemented by local fs driver"); - } - - /* -- Filesystem interface -- */ - - /** - * List the available filesystem roots, return array of PhingFile objects - */ - function listRoots() { - throw new Exception("SYSTEM ERROR [listRoots() not implemented by local fs driver]"); - } - - /* -- Basic infrastructure -- */ - - /** - * Compare two abstract pathnames lexicographically. - */ - function compare($f1, $f2) { - throw new Exception("SYSTEM ERROR [compare() not implemented by local fs driver]"); - } - - /** - * Copy a file. - * - * @param PhingFile $src Source path and name file to copy. - * @param PhingFile $dest Destination path and name of new file. - * - * @return void - * @throws Exception if file cannot be copied. - */ - function copy(PhingFile $src, PhingFile $dest) { - global $php_errormsg; - $srcPath = $src->getAbsolutePath(); - $destPath = $dest->getAbsolutePath(); - - if (false === @copy($srcPath, $destPath)) { // Copy FAILED. Log and return err. - // Add error from php to end of log message. $php_errormsg. - $msg = "FileSystem::copy() FAILED. Cannot copy $srcPath to $destPath. $php_errormsg"; - throw new Exception($msg); - } - - try { - $dest->setMode($src->getMode()); - } catch(Exception $exc) { - // [MA] does chmod returns an error on systems that do not support it ? - // eat it up for now. - } - } - - /** - * Change the permissions on a file or directory. - * - * @param pathname String. Path and name of file or directory. - * @param mode Int. The mode (permissions) of the file or - * directory. If using octal add leading 0. eg. 0777. - * Mode is affected by the umask system setting. - * - * @return void - * @throws Exception if operation failed. - */ - function chmod($pathname, $mode) { - $str_mode = decoct($mode); // Show octal in messages. - if (false === @chmod($pathname, $mode)) {// FAILED. - $msg = "FileSystem::chmod() FAILED. Cannot chmod $pathname. Mode $str_mode. $php_errormsg"; - throw new Exception($msg); - } - } - - /** - * Locks a file and throws an Exception if this is not possible. - * @return void - * @throws Exception - */ - function lock(PhingFile $f) { - $filename = $f->getPath(); - $fp = @fopen($filename, "w"); - $result = @flock($fp, LOCK_EX); - @fclose($fp); - if (!$result) { - throw new Exception("Could not lock file '$filename'"); - } - } - - /** - * Unlocks a file and throws an IO Error if this is not possible. - * - * @throws Exception - * @return void - */ - function unlock(PhingFile $f) { - $filename = $f->getPath(); - $fp = @fopen($filename, "w"); - $result = @flock($fp, LOCK_UN); - fclose($fp); - if (!$result) { - throw new Exception("Could not unlock file '$filename'"); - } - } - - /** - * Delete a file. - * - * @param file String. Path and/or name of file to delete. - * - * @return void - * @throws Exception - if an error is encountered. - */ - function unlink($file) { - global $php_errormsg; - if (false === @unlink($file)) { - $msg = "FileSystem::unlink() FAILED. Cannot unlink '$file'. $php_errormsg"; - throw new Exception($msg); - } - } - - /** - * Symbolically link a file to another name. - * - * Currently symlink is not implemented on Windows. Don't use if the application is to be portable. - * - * @param string $target Path and/or name of file to link. - * @param string $link Path and/or name of link to be created. - * @return void - */ - function symlink($target, $link) { - - // If Windows OS then symlink() will report it is not supported in - // the build. Use this error instead of checking for Windows as the OS. - - if (false === @symlink($target, $link)) { - // Add error from php to end of log message. $php_errormsg. - $msg = "FileSystem::Symlink() FAILED. Cannot symlink '$target' to '$link'. $php_errormsg"; - throw new Exception($msg); - } - - } - - /** - * Set the modification and access time on a file to the present time. - * - * @param string $file Path and/or name of file to touch. - * @param int $time - * @return void - */ - function touch($file, $time = null) { - global $php_errormsg; - - if (null === $time) { - $error = @touch($file); - } else { - $error = @touch($file, $time); - } - - if (false === $error) { // FAILED. - // Add error from php to end of log message. $php_errormsg. - $msg = "FileSystem::touch() FAILED. Cannot touch '$file'. $php_errormsg"; - throw new Exception($msg); - } - } - - /** - * Delete an empty directory OR a directory and all of its contents. - * - * @param dir String. Path and/or name of directory to delete. - * @param children Boolean. False: don't delete directory contents. - * True: delete directory contents. - * - * @return void - */ - function rmdir($dir, $children = false) { - global $php_errormsg; - - // If children=FALSE only delete dir if empty. - if (false === $children) { - - if (false === @rmdir($dir)) { // FAILED. - // Add error from php to end of log message. $php_errormsg. - $msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $php_errormsg"; - throw new Exception($msg); - } - - } else { // delete contents and dir. - - $handle = @opendir($dir); - - if (false === $handle) { // Error. - - $msg = "FileSystem::rmdir() FAILED. Cannot opendir() $dir. $php_errormsg"; - throw new Exception($msg); - - } else { // Read from handle. - - // Don't error on readdir(). - while (false !== ($entry = @readdir($handle))) { - - if ($entry != '.' && $entry != '..') { - - // Only add / if it isn't already the last char. - // This ONLY serves the purpose of making the Logger - // output look nice:) - - if (strpos(strrev($dir), DIRECTORY_SEPARATOR) === 0) {// there is a / - $next_entry = $dir . $entry; - } else { // no / - $next_entry = $dir . DIRECTORY_SEPARATOR . $entry; - } - - // NOTE: As of php 4.1.1 is_dir doesn't return FALSE it - // returns 0. So use == not ===. - - // Don't error on is_dir() - if (false == @is_dir($next_entry)) { // Is file. - - try { - self::unlink($next_entry); // Delete. - } catch (Exception $e) { - $msg = "FileSystem::Rmdir() FAILED. Cannot FileSystem::Unlink() $next_entry. ". $e->getMessage(); - throw new Exception($msg); - } - - } else { // Is directory. - - try { - self::rmdir($next_entry, true); // Delete - } catch (Exception $e) { - $msg = "FileSystem::rmdir() FAILED. Cannot FileSystem::rmdir() $next_entry. ". $e->getMessage(); - throw new Exception($msg); - } - - } // end is_dir else - } // end .. if - } // end while - } // end handle if - - // Don't error on closedir() - @closedir($handle); - - if (false === @rmdir($dir)) { // FAILED. - // Add error from php to end of log message. $php_errormsg. - $msg = "FileSystem::rmdir() FAILED. Cannot rmdir $dir. $php_errormsg"; - throw new Exception($msg); - } - - } - - } - - /** - * Set the umask for file and directory creation. - * - * @param mode Int. Permissions ususally in ocatal. Use leading 0 for - * octal. Number between 0 and 0777. - * - * @return void - * @throws Exception if there is an error performing operation. - */ - function umask($mode) { - global $php_errormsg; - - // CONSIDERME: - // Throw a warning if mode is 0. PHP converts illegal octal numbers to - // 0 so 0 might not be what the user intended. - - $str_mode = decoct($mode); // Show octal in messages. - - if (false === @umask($mode)) { // FAILED. - // Add error from php to end of log message. $php_errormsg. - $msg = "FileSystem::Umask() FAILED. Value $mode. $php_errormsg"; - throw new Exception($msg); - } - } - - /** - * Compare the modified time of two files. - * - * @param file1 String. Path and name of file1. - * @param file2 String. Path and name of file2. - * - * @return Int. 1 if file1 is newer. - * -1 if file2 is newer. - * 0 if files have the same time. - * Err object on failure. - * - * @throws Exception - if cannot get modified time of either file. - */ - function compareMTimes($file1, $file2) { - - $mtime1 = filemtime($file1); - $mtime2 = filemtime($file2); - - if ($mtime1 === false) { // FAILED. Log and return err. - // Add error from php to end of log message. $php_errormsg. - $msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file1."; - throw new Exception($msg); - } elseif ($mtime2 === false) { // FAILED. Log and return err. - // Add error from php to end of log message. $php_errormsg. - $msg = "FileSystem::compareMTimes() FAILED. Cannot can not get modified time of $file2."; - throw new Exception($msg); - } else { // Worked. Log and return compare. - // Compare mtimes. - if ($mtime1 == $mtime2) { - return 0; - } else { - return ($mtime1 < $mtime2) ? -1 : 1; - } // end compare - } - } - -} diff --git a/buildscripts/phing/classes/phing/system/io/FileWriter.php b/buildscripts/phing/classes/phing/system/io/FileWriter.php deleted file mode 100644 index d6265777..00000000 --- a/buildscripts/phing/classes/phing/system/io/FileWriter.php +++ /dev/null @@ -1,139 +0,0 @@ -. - */ - -include_once 'phing/system/io/PhingFile.php'; -include_once 'phing/system/io/Writer.php'; - -/** - * Convenience class for reading files. The constructor of this - * - * @package phing.system.io - */ -class FileWriter extends Writer { - - protected $file; - protected $fd; - - /** Whether to append contents to file. */ - protected $append; - - /** Whether we should attempt to lock the file (currently disabled). */ - protected $exclusive; - - /** - * Construct a new FileWriter. - * @param mixed $file PhingFile or string pathname. - * @param boolean $append Append to existing file? - * @param boolean $exclusive Lock file? (currently disabled due to windows incompatibility) - */ - function __construct($file, $append = false, $exclusive = false) { - if ($file instanceof PhingFile) { - $this->file = $file; - } elseif (is_string($file)) { - $this->file = new PhingFile($file); - } else { - throw new Exception("Invalid argument type for \$file."); - } - $this->append = $append; - $this->exclusive = $exclusive; - } - - function close() { - if ($this->fd === null) { - return true; - } - - if (false === @fclose($this->fd)) { - // FAILED. - $msg = "Cannot fclose " . $this->file->__toString() . " $php_errormsg"; - throw new IOException($msg); - } else { - $this->fd = null; - return true; - } - } - - function open() { - if ($this->fd === null) { - if ($this->append) { $flags = "ab"; } else { $flags = "wb"; } - $this->fd = @fopen($this->file->getPath(), $flags); - } - - if ($this->fd === false) { - // fopen FAILED. - // Add error from php to end of log message. $php_errormsg. - $msg = "Cannot fopen ".$this->file->getPath()." $php_errormsg"; - throw new IOException($msg); - } - - if (false) { - // Locks don't seem to work on windows??? HELP!!!!!!!!! - // if (FALSE === @flock($fp, LOCK_EX)) { // FAILED. - $msg = "Cannot acquire flock on $file. $php_errormsg"; - throw new IOException($msg); - } - - return true; - } - - function reset() { - // FIXME -- what exactly should this do, if anything? - // reset to beginning of file (i.e. re-open)? - } - - function writeBuffer($buffer) { - - if (!$this->file->canWrite()) { - throw new IOException("No permission to write to file: " . $this->file->__toString()); - } - - $this->open(); - $result = @fwrite($this->fd, $buffer); - $this->close(); - - if ($result === false) { - throw new IOException("Error writing file: ". $this->file->toString()); - } else { - return true; - } - } - - function write($buf, $off = null, $len = null) { - if ( $off === null && $len === null ) - $to_write = $buf; - else - $to_write = substr($buf, $off, $len); - - $this->open(); - $result = @fwrite($this->fd, $to_write); - - if ( $result === false ) { - throw new IOException("Error writing file."); - } else { - return true; - } - } - - function getResource() { - return $this->file->toString(); - } -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/FilterReader.php b/buildscripts/phing/classes/phing/system/io/FilterReader.php deleted file mode 100644 index 8c683408..00000000 --- a/buildscripts/phing/classes/phing/system/io/FilterReader.php +++ /dev/null @@ -1,72 +0,0 @@ -. - */ - -include_once 'phing/system/io/Reader.php'; - -/** - * Convenience class for reading files. The constructor of this - * @package phing.system.io - * - * TODO: All filters should be ProjectComponents, too! - */ -class FilterReader extends Reader { - - protected $in; - - function __construct(Reader $in = null) { - $this->in = $in; - //parent::__construct(new FileReader($file, $exclusive)); - } - - public function setReader(Reader $in) { - $this->in = $in; - } - - public function skip($n) { - return $this->in->skip($n); - } - - /** - * Read data from source. - * FIXME: Clean up this function signature, as it a) params aren't being used - * and b) it doesn't make much sense. - */ - public function read($len = null) { - return $this->in->read($len); - } - - public function reset() { - return $this->in->reset(); - } - - public function close() { - return $this->in->close(); - } - - public function open() { - return $this->in->open(); - } - - function getResource() { - return $this->in->getResource(); - } -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/IOException.php b/buildscripts/phing/classes/phing/system/io/IOException.php deleted file mode 100644 index e2c73b27..00000000 --- a/buildscripts/phing/classes/phing/system/io/IOException.php +++ /dev/null @@ -1,28 +0,0 @@ -. - */ - -/** - * Extends Exception to take advantage of methods therein. - * - * @package phing.system.io - */ -class IOException extends Exception {} -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/system/io/PhingFile.php b/buildscripts/phing/classes/phing/system/io/PhingFile.php deleted file mode 100644 index cd881963..00000000 --- a/buildscripts/phing/classes/phing/system/io/PhingFile.php +++ /dev/null @@ -1,866 +0,0 @@ -. - */ - -include_once 'phing/system/io/FileSystem.php'; -include_once 'phing/system/lang/NullPointerException.php'; - -/** - * An abstract representation of file and directory pathnames. - * - * @version $Revision: 1.1 $ - * @package phing.system.io - */ -class PhingFile { - - /** separator string, static, obtained from FileSystem */ - public static $separator; - - /** path separator string, static, obtained from FileSystem (; or :)*/ - public static $pathSeparator; - - /** - * This abstract pathname's normalized pathname string. A normalized - * pathname string uses the default name-separator character and does not - * contain any duplicate or redundant separators. - */ - private $path = null; - - /** The length of this abstract pathname's prefix, or zero if it has no prefix. */ - private $prefixLength = 0; - - /** constructor */ - function __construct($arg1 = null, $arg2 = null) { - - if (self::$separator === null || self::$pathSeparator === null) { - $fs = FileSystem::getFileSystem(); - self::$separator = $fs->getSeparator(); - self::$pathSeparator = $fs->getPathSeparator(); - } - - /* simulate signature identified constructors */ - if ($arg1 instanceof PhingFile && is_string($arg2)) { - $this->_constructFileParentStringChild($arg1, $arg2); - } elseif (is_string($arg1) && ($arg2 === null)) { - $this->_constructPathname($arg1); - } elseif(is_string($arg1) && is_string($arg2)) { - $this->_constructStringParentStringChild($arg1, $arg2); - } else { - if ($arg1 === null) { - throw new NullPointerException("Argument1 to function must not be null"); - } - $this->path = (string) $arg1; - $this->prefixLength = (int) $arg2; - } - } - - /** Returns the length of this abstract pathname's prefix. */ - function getPrefixLength() { - return (int) $this->prefixLength; - } - - /* -- constructors not called by signature match, so we need some helpers --*/ - - function _constructPathname($pathname) { - // obtain ref to the filesystem layer - $fs = FileSystem::getFileSystem(); - - if ($pathname === null) { - throw new NullPointerException("Argument to function must not be null"); - } - - $this->path = (string) $fs->normalize($pathname); - $this->prefixLength = (int) $fs->prefixLength($this->path); - } - - function _constructStringParentStringChild($parent, $child = null) { - // obtain ref to the filesystem layer - $fs = FileSystem::getFileSystem(); - - if ($child === null) { - throw new NullPointerException("Argument to function must not be null"); - } - if ($parent !== null) { - if ($parent === "") { - $this->path = $fs->resolve($fs->getDefaultParent(), $fs->normalize($child)); - } else { - $this->path = $fs->resolve($fs->normalize($parent), $fs->normalize($child)); - } - } else { - $this->path = (string) $fs->normalize($child); - } - $this->prefixLength = (int) $fs->prefixLength($this->path); - } - - function _constructFileParentStringChild($parent, $child = null) { - // obtain ref to the filesystem layer - $fs = FileSystem::getFileSystem(); - - if ($child === null) { - throw new NullPointerException("Argument to function must not be null"); - } - - if ($parent !== null) { - if ($parent->path === "") { - $this->path = $fs->resolve($fs->getDefaultParent(), $fs->normalize($child)); - } else { - $this->path = $fs->resolve($parent->path, $fs->normalize($child)); - } - } else { - $this->path = $fs->normalize($child); - } - $this->prefixLength = $fs->prefixLength($this->path); - } - - /* -- Path-component accessors -- */ - - /** - * Returns the name of the file or directory denoted by this abstract - * pathname. This is just the last name in the pathname's name - * sequence. If the pathname's name sequence is empty, then the empty - * string is returned. - * - * @return The name of the file or directory denoted by this abstract - * pathname, or the empty string if this pathname's name sequence - * is empty - */ - function getName() { - // that's a lastIndexOf - $index = ((($res = strrpos($this->path, self::$separator)) === false) ? -1 : $res); - if ($index < $this->prefixLength) { - return substr($this->path, $this->prefixLength); - } - return substr($this->path, $index + 1); - } - - /** - * Returns the pathname string of this abstract pathname's parent, or - * null if this pathname does not name a parent directory. - * - * The parent of an abstract pathname consists of the pathname's prefix, - * if any, and each name in the pathname's name sequence except for the last. - * If the name sequence is empty then the pathname does not name a parent - * directory. - * - * @return The pathname string of the parent directory named by this - * abstract pathname, or null if this pathname does not name a parent - */ - function getParent() { - // that's a lastIndexOf - $index = ((($res = strrpos($this->path, self::$separator)) === false) ? -1 : $res); - if ($index < $this->prefixLength) { - if (($this->prefixLength > 0) && (strlen($this->path > $this->prefixLength))) { - return substr($this->path, 0, $this->prefixLength); - } - return null; - } - return substr($this->path, 0, $index); - } - - /** - * Returns the abstract pathname of this abstract pathname's parent, - * or null if this pathname does not name a parent directory. - * - * The parent of an abstract pathname consists of the pathname's prefix, - * if any, and each name in the pathname's name sequence except for the - * last. If the name sequence is empty then the pathname does not name - * a parent directory. - * - * @return The abstract pathname of the parent directory named by this - * abstract pathname, or null if this pathname - * does not name a parent - */ - function getParentFile() { - $p = $this->getParent(); - if ($p === null) { - return null; - } - return new PhingFile((string) $p, (int) $this->prefixLength); - } - - /** - * Converts this abstract pathname into a pathname string. The resulting - * string uses the default name-separator character to separate the names - * in the name sequence. - * - * @return The string form of this abstract pathname - */ - function getPath() { - return (string) $this->path; - } - - /** - * Tests whether this abstract pathname is absolute. The definition of - * absolute pathname is system dependent. On UNIX systems, a pathname is - * absolute if its prefix is "/". On Win32 systems, a pathname is absolute - * if its prefix is a drive specifier followed by "\\", or if its prefix - * is "\\". - * - * @return true if this abstract pathname is absolute, false otherwise - */ - function isAbsolute() { - return ($this->prefixLength !== 0); - } - - - /** - * Returns the absolute pathname string of this abstract pathname. - * - * If this abstract pathname is already absolute, then the pathname - * string is simply returned as if by the getPath method. - * If this abstract pathname is the empty abstract pathname then - * the pathname string of the current user directory, which is named by the - * system property user.dir, is returned. Otherwise this - * pathname is resolved in a system-dependent way. On UNIX systems, a - * relative pathname is made absolute by resolving it against the current - * user directory. On Win32 systems, a relative pathname is made absolute - * by resolving it against the current directory of the drive named by the - * pathname, if any; if not, it is resolved against the current user - * directory. - * - * @return The absolute pathname string denoting the same file or - * directory as this abstract pathname - * @see #isAbsolute() - */ - function getAbsolutePath() { - $fs = FileSystem::getFileSystem(); - return $fs->resolveFile($this); - } - - /** - * Returns the absolute form of this abstract pathname. Equivalent to - * getAbsolutePath. - * - * @return The absolute abstract pathname denoting the same file or - * directory as this abstract pathname - */ - function getAbsoluteFile() { - return new PhingFile((string) $this->getAbsolutePath()); - } - - - /** - * Returns the canonical pathname string of this abstract pathname. - * - * A canonical pathname is both absolute and unique. The precise - * definition of canonical form is system-dependent. This method first - * converts this pathname to absolute form if necessary, as if by invoking the - * getAbsolutePath() method, and then maps it to its unique form in a - * system-dependent way. This typically involves removing redundant names - * such as "." and .. from the pathname, resolving symbolic links - * (on UNIX platforms), and converting drive letters to a standard case - * (on Win32 platforms). - * - * Every pathname that denotes an existing file or directory has a - * unique canonical form. Every pathname that denotes a nonexistent file - * or directory also has a unique canonical form. The canonical form of - * the pathname of a nonexistent file or directory may be different from - * the canonical form of the same pathname after the file or directory is - * created. Similarly, the canonical form of the pathname of an existing - * file or directory may be different from the canonical form of the same - * pathname after the file or directory is deleted. - * - * @return The canonical pathname string denoting the same file or - * directory as this abstract pathname - */ - function getCanonicalPath() { - $fs = FileSystem::getFileSystem(); - return $fs->canonicalize($this->path); - } - - - /** - * Returns the canonical form of this abstract pathname. Equivalent to - * getCanonicalPath(. - * - * @return PhingFile The canonical pathname string denoting the same file or - * directory as this abstract pathname - */ - function getCanonicalFile() { - return new PhingFile($this->getCanonicalPath()); - } - - /** - * Converts this abstract pathname into a file: URL. The - * exact form of the URL is system-dependent. If it can be determined that - * the file denoted by this abstract pathname is a directory, then the - * resulting URL will end with a slash. - * - * Usage note: This method does not automatically escape - * characters that are illegal in URLs. It is recommended that new code - * convert an abstract pathname into a URL by first converting it into a - * URI, via the toURI() method, and then converting the URI - * into a URL via the URI::toURL() - * - * @return A URL object representing the equivalent file URL - * - * - */ - function toURL() { - /* - // URL class not implemented yet - return new URL("file", "", $this->_slashify($this->getAbsolutePath(), $this->isDirectory())); - */ - } - - /** - * Constructs a file: URI that represents this abstract pathname. - * Not implemented yet - */ - function toURI() { - /* - $f = $this->getAbsoluteFile(); - $sp = (string) $this->slashify($f->getPath(), $f->isDirectory()); - if (StringHelper::startsWith('//', $sp)) - $sp = '//' + sp; - return new URI('file', null, $sp, null); - */ - } - - function _slashify($path, $isDirectory) { - $p = (string) $path; - - if (self::$separator !== '/') { - $p = str_replace(self::$separator, '/', $p); - } - - if (!StringHelper::startsWith('/', $p)) { - $p = '/'.$p; - } - - if (!StringHelper::endsWith('/', $p) && $isDirectory) { - $p = $p.'/'; - } - - return $p; - } - - /* -- Attribute accessors -- */ - - /** - * Tests whether the application can read the file denoted by this - * abstract pathname. - * - * @return true if and only if the file specified by this - * abstract pathname exists and can be read by the - * application; false otherwise - */ - function canRead() { - $fs = FileSystem::getFileSystem(); - - if ($fs->checkAccess($this)) { - return (boolean) @is_readable($this->getAbsolutePath()); - } - return false; - } - - /** - * Tests whether the application can modify to the file denoted by this - * abstract pathname. - * - * @return true if and only if the file system actually - * contains a file denoted by this abstract pathname and - * the application is allowed to write to the file; - * false otherwise. - * - */ - function canWrite() { - $fs = FileSystem::getFileSystem(); - return $fs->checkAccess($this, true); - } - - /** - * Tests whether the file denoted by this abstract pathname exists. - * - * @return true if and only if the file denoted by this - * abstract pathname exists; false otherwise - * - */ - function exists() { - if ($this->isFile()) { - return @file_exists($this->path); - } else { - return @is_dir($this->path); - } - } - - /** - * Tests whether the file denoted by this abstract pathname is a - * directory. - * - * @return true if and only if the file denoted by this - * abstract pathname exists and is a directory; - * false otherwise - * - */ - function isDirectory() { - $fs = FileSystem::getFileSystem(); - if ($fs->checkAccess($this) !== true) { - throw new IOException("No read access to ".$this->path); - } - return @is_dir($this->path); - } - - /** - * Tests whether the file denoted by this abstract pathname is a normal - * file. A file is normal if it is not a directory and, in - * addition, satisfies other system-dependent criteria. Any non-directory - * file created by a Java application is guaranteed to be a normal file. - * - * @return true if and only if the file denoted by this - * abstract pathname exists and is a normal file; - * false otherwise - */ - function isFile() { - //$fs = FileSystem::getFileSystem(); - return @is_file($this->path); - } - - /** - * Tests whether the file named by this abstract pathname is a hidden - * file. The exact definition of hidden is system-dependent. On - * UNIX systems, a file is considered to be hidden if its name begins with - * a period character ('.'). On Win32 systems, a file is considered to be - * hidden if it has been marked as such in the filesystem. Currently there - * seems to be no way to dermine isHidden on Win file systems via PHP - * - * @return true if and only if the file denoted by this - * abstract pathname is hidden according to the conventions of the - * underlying platform - */ - function isHidden() { - $fs = FileSystem::getFileSystem(); - if ($fs->checkAccess($this) !== true) { - throw new IOException("No read access to ".$this->path); - } - return (($fs->getBooleanAttributes($this) & $fs->BA_HIDDEN) !== 0); - } - - /** - * Returns the time that the file denoted by this abstract pathname was - * last modified. - * - * @return A integer value representing the time the file was - * last modified, measured in milliseconds since the epoch - * (00:00:00 GMT, January 1, 1970), or 0 if the - * file does not exist or if an I/O error occurs - */ - function lastModified() { - $fs = FileSystem::getFileSystem(); - if ($fs->checkAccess($this) !== true) { - throw new IOException("No read access to " . $this->path); - } - return $fs->getLastModifiedTime($this); - } - - /** - * Returns the length of the file denoted by this abstract pathname. - * The return value is unspecified if this pathname denotes a directory. - * - * @return The length, in bytes, of the file denoted by this abstract - * pathname, or 0 if the file does not exist - */ - function length() { - $fs = FileSystem::getFileSystem(); - if ($fs->checkAccess($this) !== true) { - throw new IOException("No read access to ".$this->path."\n"); - } - return $fs->getLength($this); - } - - /** - * Convenience method for returning the contents of this file as a string. - * This method uses file_get_contents() to read file in an optimized way. - * @return string - * @throws Exception - if file cannot be read - */ - function contents() { - if (!$this->canRead() || !$this->isFile()) { - throw new IOException("Cannot read file contents!"); - } - return file_get_contents($this->getAbsolutePath()); - } - - /* -- File operations -- */ - - /** - * Atomically creates a new, empty file named by this abstract pathname if - * and only if a file with this name does not yet exist. The check for the - * existence of the file and the creation of the file if it does not exist - * are a single operation that is atomic with respect to all other - * filesystem activities that might affect the file. - * - * @return true if the named file does not exist and was - * successfully created; false if the named file - * already exists - * @throws IOException if file can't be created - */ - function createNewFile($parents=true, $mode=0777) { - $file = FileSystem::getFileSystem()->createNewFile($this->path); - return $file; - } - - /** - * Deletes the file or directory denoted by this abstract pathname. If - * this pathname denotes a directory, then the directory must be empty in - * order to be deleted. - * - * @return true if and only if the file or directory is - * successfully deleted; false otherwise - */ - function delete() { - $fs = FileSystem::getFileSystem(); - if ($fs->checkAccess($this, true) !== true) { - throw new IOException("No read access to " . $this->path."\n"); - } - return $fs->delete($this); - } - - /** - * Requests that the file or directory denoted by this abstract pathname - * be deleted when php terminates. Deletion will be attempted only for - * normal termination of php and if and if only Phing::shutdown() is - * called. - * - * Once deletion has been requested, it is not possible to cancel the - * request. This method should therefore be used with care. - * - */ - function deleteOnExit() { - $fs = FileSystem::getFileSystem(); - $fs->deleteOnExit($this); - } - - /** - * Returns an array of strings naming the files and directories in the - * directory denoted by this abstract pathname. - * - * If this abstract pathname does not denote a directory, then this - * method returns null Otherwise an array of strings is - * returned, one for each file or directory in the directory. Names - * denoting the directory itself and the directory's parent directory are - * not included in the result. Each string is a file name rather than a - * complete path. - * - * There is no guarantee that the name strings in the resulting array - * will appear in any specific order; they are not, in particular, - * guaranteed to appear in alphabetical order. - * - * @return An array of strings naming the files and directories in the - * directory denoted by this abstract pathname. The array will be - * empty if the directory is empty. Returns null if - * this abstract pathname does not denote a directory, or if an - * I/O error occurs. - * - */ - function listDir($filter = null) { - $fs = FileSystem::getFileSystem(); - return $fs->lister($this, $filter); - } - - function listFiles($filter = null) { - $ss = $this->listDir($filter); - if ($ss === null) { - return null; - } - $n = count($ss); - $fs = array(); - for ($i = 0; $i < $n; $i++) { - $fs[$i] = new PhingFile((string)$this->path, (string)$ss[$i]); - } - return $fs; - } - - /** - * Creates the directory named by this abstract pathname, including any - * necessary but nonexistent parent directories. Note that if this - * operation fails it may have succeeded in creating some of the necessary - * parent directories. - * - * @return true if and only if the directory was created, - * along with all necessary parent directories; false - * otherwise - * @throws IOException - */ - function mkdirs() { - if ($this->exists()) { - return false; - } - try { - if ($this->mkdir()) { - return true; - } - } catch (IOException $ioe) { - // IOException from mkdir() means that directory propbably didn't exist. - } - $parentFile = $this->getParentFile(); - return (($parentFile !== null) && ($parentFile->mkdirs() && $this->mkdir())); - } - - /** - * Creates the directory named by this abstract pathname. - * - * @return true if and only if the directory was created; false otherwise - * @throws IOException - */ - function mkdir() { - $fs = FileSystem::getFileSystem(); - - if ($fs->checkAccess(new PhingFile($this->path), true) !== true) { - throw new IOException("No write access to " . $this->getPath()); - } - return $fs->createDirectory($this); - } - - /** - * Renames the file denoted by this abstract pathname. - * - * @param destFile The new abstract pathname for the named file - * @return true if and only if the renaming succeeded; false otherwise - */ - function renameTo(PhingFile $destFile) { - $fs = FileSystem::getFileSystem(); - if ($fs->checkAccess($this) !== true) { - throw new IOException("No write access to ".$this->getPath()); - } - return $fs->rename($this, $destFile); - } - - /** - * Simple-copies file denoted by this abstract pathname into another - * PhingFile - * - * @param PhingFile $destFile The new abstract pathname for the named file - * @return true if and only if the renaming succeeded; false otherwise - */ - function copyTo(PhingFile $destFile) { - $fs = FileSystem::getFileSystem(); - - if ($fs->checkAccess($this) !== true) { - throw new IOException("No read access to ".$this->getPath()."\n"); - } - - if ($fs->checkAccess($destFile, true) !== true) { - throw new IOException("File::copyTo() No write access to ".$destFile->getPath()); - } - return $fs->copy($this, $destFile); - } - - /** - * Sets the last-modified time of the file or directory named by this - * abstract pathname. - * - * All platforms support file-modification times to the nearest second, - * but some provide more precision. The argument will be truncated to fit - * the supported precision. If the operation succeeds and no intervening - * operations on the file take place, then the next invocation of the - * lastModified method will return the (possibly truncated) time argument - * that was passed to this method. - * - * @param time The new last-modified time, measured in milliseconds since - * the epoch (00:00:00 GMT, January 1, 1970) - * @return true if and only if the operation succeeded; false otherwise - */ - function setLastModified($time) { - $time = (int) $time; - if ($time < 0) { - throw new Exception("IllegalArgumentException, Negative $time\n"); - } - - // FIXME check if accessible - $fs = FileSystem::getFileSystem(); - if ($fs->checkAccess($this, true) !== true) { - throw new IOException("File::setLastModified(). No write access to file\n"); - } - return $fs->setLastModifiedTime($this, $time); - } - - /** - * Marks the file or directory named by this abstract pathname so that - * only read operations are allowed. After invoking this method the file - * or directory is guaranteed not to change until it is either deleted or - * marked to allow write access. Whether or not a read-only file or - * directory may be deleted depends upon the underlying system. - * - * @return true if and only if the operation succeeded; false otherwise - */ - function setReadOnly() { - $fs = FileSystem::getFileSystem(); - if ($fs->checkAccess($this, true) !== true) { - // Error, no write access - throw new IOException("No write access to " . $this->getPath()); - } - return $fs->setReadOnly($this); - } - - /** - * Sets the mode of the file - * @param int $mode Ocatal mode. - */ - function setMode($mode) { - $fs = FileSystem::getFileSystem(); - return $fs->chmod($this->getPath(), $mode); - } - - /** - * Retrieve the mode of this file. - * @return int - */ - function getMode() { - return @fileperms($this->getPath()); - } - - /* -- Filesystem interface -- */ - - /** - * List the available filesystem roots. - * - * A particular platform may support zero or more hierarchically-organized - * file systems. Each file system has a root directory from which all - * other files in that file system can be reached. - * Windows platforms, for example, have a root directory for each active - * drive; UNIX platforms have a single root directory, namely "/". - * The set of available filesystem roots is affected by various system-level - * operations such the insertion or ejection of removable media and the - * disconnecting or unmounting of physical or virtual disk drives. - * - * This method returns an array of PhingFile objects that - * denote the root directories of the available filesystem roots. It is - * guaranteed that the canonical pathname of any file physically present on - * the local machine will begin with one of the roots returned by this - * method. - * - * The canonical pathname of a file that resides on some other machine - * and is accessed via a remote-filesystem protocol such as SMB or NFS may - * or may not begin with one of the roots returned by this method. If the - * pathname of a remote file is syntactically indistinguishable from the - * pathname of a local file then it will begin with one of the roots - * returned by this method. Thus, for example, PhingFile objects - * denoting the root directories of the mapped network drives of a Windows - * platform will be returned by this method, while PhingFile - * objects containing UNC pathnames will not be returned by this method. - * - * @return An array of PhingFile objects denoting the available - * filesystem roots, or null if the set of roots - * could not be determined. The array will be empty if there are - * no filesystem roots. - */ - function listRoots() { - $fs = FileSystem::getFileSystem(); - return (array) $fs->listRoots(); - } - - /* -- Tempfile management -- */ - - /** - * Returns the path to the temp directory. - */ - function getTempDir() { - return Phing::getProperty('php.tmpdir'); - } - - /** - * Static method that creates a unique filename whose name begins with - * $prefix and ends with $suffix in the directory $directory. $directory - * is a reference to a PhingFile Object. - * Then, the file is locked for exclusive reading/writing. - * - * @author manuel holtgrewe, grin@gmx.net - * @throws IOException - * @access public - */ - function createTempFile($prefix, $suffix, PhingFile $directory) { - - // quick but efficient hack to create a unique filename ;-) - $result = null; - do { - $result = new PhingFile($directory, $prefix . substr(md5(time()), 0, 8) . $suffix); - } while (file_exists($result->getPath())); - - $fs = FileSystem::getFileSystem(); - $fs->createNewFile($result->getPath()); - $fs->lock($result); - - return $result; - } - - /** - * If necessary, $File the lock on $File is removed and then the file is - * deleted - * - * @access public - */ - function removeTempFile() { - $fs = FileSystem::getFileSystem(); - // catch IO Exception - $fs->unlock($this); - $this->delete(); - } - - - /* -- Basic infrastructure -- */ - - /** - * Compares two abstract pathnames lexicographically. The ordering - * defined by this method depends upon the underlying system. On UNIX - * systems, alphabetic case is significant in comparing pathnames; on Win32 - * systems it is not. - * - * @param PhingFile $file Th file whose pathname sould be compared to the pathname of this file. - * - * @return int Zero if the argument is equal to this abstract pathname, a - * value less than zero if this abstract pathname is - * lexicographically less than the argument, or a value greater - * than zero if this abstract pathname is lexicographically - * greater than the argument - */ - function compareTo(PhingFile $file) { - $fs = FileSystem::getFileSystem(); - return $fs->compare($this, $file); - } - - /** - * Tests this abstract pathname for equality with the given object. - * Returns true if and only if the argument is not - * null and is an abstract pathname that denotes the same file - * or directory as this abstract pathname. Whether or not two abstract - * pathnames are equal depends upon the underlying system. On UNIX - * systems, alphabetic case is significant in comparing pathnames; on Win32 - * systems it is not. - * @return boolean - */ - function equals($obj) { - if (($obj !== null) && ($obj instanceof PhingFile)) { - return ($this->compareTo($obj) === 0); - } - return false; - } - - /** Backwards compatibility -- use PHP5's native __tostring method. */ - function toString() { - return $this->getPath(); - } - - /** PHP5's native method. */ - function __toString() { - return $this->getPath(); - } -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/Reader.php b/buildscripts/phing/classes/phing/system/io/Reader.php deleted file mode 100644 index 1e377378..00000000 --- a/buildscripts/phing/classes/phing/system/io/Reader.php +++ /dev/null @@ -1,88 +0,0 @@ -. -*/ - -/** - * Abstract class for reading character streams. - * @author Hans Lellelid - * @author Yannick Lecaillez - * @version $Revision: 1.5 $ - * @package phing.system.io - */ -abstract class Reader { - - /** - * Read data from source. - * If length is specified, then only that number of chars is read, - * otherwise stream is read until EOF. - * @param int $len - */ - abstract public function read($len = null); - - /** - * Close stream. - */ - abstract public function close(); - - /** - * Open stream for reading. - */ - abstract public function open(); - - /** - * Returns the filename, url, etc. that is being read from. - * This is critical for, e.g., ExpatParser's ability to know - * the filename that is throwing an ExpatParserException, etc. - * @return string - */ - abstract function getResource(); - - /** - * Move stream position relative to current pos. - * @param int $n - */ - public function skip($n) {} - - /** - * Reset the current position in stream to beginning or last mark (if supported). - */ - public function reset() {} - - /** - * If supported, places a "marker" (like a bookmark) at current stream position. - * A subsequent call to reset() will move stream position back - * to last marker (if supported). - */ - public function mark() {} - - /** - * Whether marking is supported. - * @return boolean - */ - public function markSupported() {} - - /** - * Is stream ready for reading. - * @return boolean - */ - public function ready() {} - -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/StringReader.php b/buildscripts/phing/classes/phing/system/io/StringReader.php deleted file mode 100644 index 689a2115..00000000 --- a/buildscripts/phing/classes/phing/system/io/StringReader.php +++ /dev/null @@ -1,73 +0,0 @@ -. - */ - -/** - * Dummy class for reading character streams. - * @package phing.system.io - */ -class StringReader extends Reader { - - private $_string; - private $mark = 0; - private $currPos = 0; - - function __construct($string) { - $this->_string = $string; - } - - function skip($n) {} - - function read($len = null) { - if ($len === null) { - return $this->_string; - } else { - if ($this->currPos >= strlen($this->_string)) { - return -1; - } - $out = substr($this->_string, $this->currPos, $len); - $this->currPos += $len; - return $out; - } - } - - function mark() { - $this->mark = $this->currPos; - } - - function reset() { - $this->currPos = $this->mark; - } - - function close() {} - - function open() {} - - function ready() {} - - function markSupported() { - return true; - } - - function getResource() { - return '(string) "'.$this->_string . '"'; - } -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/TokenReader.php b/buildscripts/phing/classes/phing/system/io/TokenReader.php deleted file mode 100644 index a57d994c..00000000 --- a/buildscripts/phing/classes/phing/system/io/TokenReader.php +++ /dev/null @@ -1,51 +0,0 @@ -. -*/ - -include_once 'phing/system/io/Reader.php'; -include_once 'phing/filters/ReplaceTokens.php'; // for class Token - -/** - * Abstract class for reading Tokens from a resource - * - * @author Manuel Holtgewe - * @version $Revision: 1.3 $ - * @access public - * @package phing.system.io - */ -class TokenReader extends Reader { - - /** - * Constructor - */ - function __construct() { - } - - /** - * Reads a token from the resource and returns it as a - * Token object. - * - * @access public - */ - function readToken() { - } -} - -?> diff --git a/buildscripts/phing/classes/phing/system/io/UnixFileSystem.php b/buildscripts/phing/classes/phing/system/io/UnixFileSystem.php deleted file mode 100644 index fb4e49b4..00000000 --- a/buildscripts/phing/classes/phing/system/io/UnixFileSystem.php +++ /dev/null @@ -1,266 +0,0 @@ -. - */ - -include_once 'phing/system/io/FileSystem.php'; - -/** - * UnixFileSystem class. This class encapsulates the basic file system functions - * for platforms using the unix (posix)-stylish filesystem. It wraps php native - * functions suppressing normal PHP error reporting and instead uses Exception - * to report and error. - * - * This class is part of a oop based filesystem abstraction and targeted to run - * on all supported php platforms. - * - * Note: For debugging turn track_errors on in the php.ini. The error messages - * and log messages from this class will then be clearer because $php_errormsg - * is passed as part of the message. - * - * FIXME: - * - Comments - * - Error handling reduced to min, error are handled by PhingFile mainly - * - * @author Andreas Aderhold, andi@binarycloud.com - * @version $Revision: 1.10 $ - * @package phing.system.io - */ -class UnixFileSystem extends FileSystem { - - /** - * returns OS dependant path separator char - */ - function getSeparator() { - return '/'; - } - - /** - * returns OS dependant directory separator char - */ - function getPathSeparator() { - return ':'; - } - - /** - * A normal Unix pathname contains no duplicate slashes and does not end - * with a slash. It may be the empty string. - * - * Check that the given pathname is normal. If not, invoke the real - * normalizer on the part of the pathname that requires normalization. - * This way we iterate through the whole pathname string only once. - */ - function normalize($strPathname) { - - if (empty($strPathname)) { - return; - } - - // Resolve home directories. We assume /home is where all home - // directories reside, b/c there is no other way to do this with - // PHP AFAIK. - if ($strPathname{0} === "~") { - if ($strPathname{1} === "/") { // like ~/foo => /home/user/foo - $strPathname = "/home/" . get_current_user() . substr($strPathname, 1); - } else { // like ~foo => /home/foo - $pos = strpos($strPathname, "/"); - $name = substr($strPathname, 1, $pos - 2); - $strPathname = "/home/" . $name . substr($strPathname, $pos); - } - } - - $n = strlen($strPathname); - $prevChar = 0; - for ($i=0; $i < $n; $i++) { - $c = $strPathname{$i}; - if (($prevChar === '/') && ($c === '/')) { - return self::normalizer($strPathname, $n, $i - 1); - } - $prevChar = $c; - } - if ($prevChar === '/') { - return self::normalizer($strPathname, $n, $n - 1); - } - return $strPathname; - } - - /** - * Normalize the given pathname, whose length is $len, starting at the given - * $offset; everything before this offset is already normal. - */ - protected function normalizer($pathname, $len, $offset) { - if ($len === 0) { - return $pathname; - } - $n = (int) $len; - while (($n > 0) && ($pathname{$n-1} === '/')) { - $n--; - } - if ($n === 0) { - return '/'; - } - $sb = ""; - - if ($offset > 0) { - $sb .= substr($pathname, 0, $offset); - } - $prevChar = 0; - for ($i = $offset; $i < $n; $i++) { - $c = $pathname{$i}; - if (($prevChar === '/') && ($c === '/')) { - continue; - } - $sb .= $c; - $prevChar = $c; - } - return $sb; - } - - /** - * Compute the length of the pathname string's prefix. The pathname - * string must be in normal form. - */ - function prefixLength($pathname) { - if (strlen($pathname === 0)) { - return 0; - } - return (($pathname{0} === '/') ? 1 : 0); - } - - /** - * Resolve the child pathname string against the parent. - * Both strings must be in normal form, and the result - * will be in normal form. - */ - function resolve($parent, $child) { - - if ($child === "") { - return $parent; - } - - if ($child{0} === '/') { - if ($parent === '/') { - return $child; - } - return $parent.$child; - } - - if ($parent === '/') { - return $parent.$child; - } - - return $parent.'/'.$child; - } - - function getDefaultParent() { - return '/'; - } - - function isAbsolute(PhingFile $f) { - return ($f->getPrefixLength() !== 0); - } - - /** - * the file resolver - */ - function resolveFile(PhingFile $f) { - // resolve if parent is a file oject only - if ($this->isAbsolute($f)) { - return $f->getPath(); - } else { - return $this->resolve(Phing::getProperty("user.dir"), $f->getPath()); - } - } - - /* -- most of the following is mapped to the php natives wrapped by FileSystem */ - - /* -- Attribute accessors -- */ - function getBooleanAttributes(&$f) { - //$rv = getBooleanAttributes0($f); - $name = $f->getName(); - $hidden = (strlen($name) > 0) && ($name{0} == '.'); - return ($hidden ? $this->BA_HIDDEN : 0); - } - - /** - * set file readonly on unix - */ - function setReadOnly($f) { - if ($f instanceof File) { - $strPath = (string) $f->getPath(); - $perms = (int) (@fileperms($strPath) & 0444); - return FileSystem::Chmod($strPath, $perms); - } else { - throw new Exception("IllegalArgutmentType: Argument is not File"); - } - } - - /** - * compares file paths lexicographically - */ - function compare($f1, $f2) { - if ( ($f1 instanceof PhingFile) && ($f2 instanceof PhingFile) ) { - $f1Path = $f1->getPath(); - $f2Path = $f2->getPath(); - return (boolean) strcmp((string) $f1Path, (string) $f2Path); - } else { - throw new Exception("IllegalArgutmentType: Argument is not PhingFile"); - } - } - - /* -- fs interface --*/ - - function listRoots() { - if (!$this->checkAccess('/', false)) { - die ("Can not access root"); - } - return array(new PhingFile("/")); - } - - /** - * returns the contents of a directory in an array - */ - function lister($f) { - $dir = @opendir($f->getAbsolutePath()); - if (!$dir) { - throw new Exception("Can't open directory " . $f->__toString()); - } - $vv = array(); - while (($file = @readdir($dir)) !== false) { - if ($file == "." || $file == "..") { - continue; - } - $vv[] = (string) $file; - } - @closedir($dir); - return $vv; - } - - function fromURIPath($p) { - if (StringHelper::endsWith("/", $p) && (strlen($p) > 1)) { - - // "/foo/" --> "/foo", but "/" --> "/" - $p = substr($p, 0, strlen($p) - 1); - - } - - return $p; - } - -} diff --git a/buildscripts/phing/classes/phing/system/io/Win32FileSystem.php b/buildscripts/phing/classes/phing/system/io/Win32FileSystem.php deleted file mode 100644 index c32c21ff..00000000 --- a/buildscripts/phing/classes/phing/system/io/Win32FileSystem.php +++ /dev/null @@ -1,477 +0,0 @@ -. - */ - -include_once 'phing/system/io/FileSystem.php'; - -/** - * @package phing.system.io - */ -class Win32FileSystem extends FileSystem { - - protected $slash; - protected $altSlash; - protected $semicolon; - - private static $driveDirCache = array(); - - function __construct() { - $this->slash = self::getSeparator(); - $this->semicolon = self::getPathSeparator(); - $this->altSlash = ($this->slash === '\\') ? '/' : '\\'; - } - - function isSlash($c) { - return ($c == '\\') || ($c == '/'); - } - - function isLetter($c) { - return ((ord($c) >= ord('a')) && (ord($c) <= ord('z'))) - || ((ord($c) >= ord('A')) && (ord($c) <= ord('Z'))); - } - - function slashify($p) { - if ((strlen($p) > 0) && ($p{0} != $this->slash)) { - return $this->slash.$p; - } - else { - return $p; - } - } - - /* -- Normalization and construction -- */ - - function getSeparator() { - // the ascii value of is the \ - return chr(92); - } - - function getPathSeparator() { - return ';'; - } - - /** - * A normal Win32 pathname contains no duplicate slashes, except possibly - * for a UNC prefix, and does not end with a slash. It may be the empty - * string. Normalized Win32 pathnames have the convenient property that - * the length of the prefix almost uniquely identifies the type of the path - * and whether it is absolute or relative: - * - * 0 relative to both drive and directory - * 1 drive-relative (begins with '\\') - * 2 absolute UNC (if first char is '\\'), else directory-relative (has form "z:foo") - * 3 absolute local pathname (begins with "z:\\") - */ - function normalizePrefix($strPath, $len, $sb) { - $src = 0; - while (($src < $len) && $this->isSlash($strPath{$src})) { - $src++; - } - $c = ""; - if (($len - $src >= 2) - && $this->isLetter($c = $strPath{$src}) - && $strPath{$src + 1} === ':') { - /* Remove leading slashes if followed by drive specifier. - * This hack is necessary to support file URLs containing drive - * specifiers (e.g., "file://c:/path"). As a side effect, - * "/c:/path" can be used as an alternative to "c:/path". */ - $sb .= $c; - $sb .= ':'; - $src += 2; - } - else { - $src = 0; - if (($len >= 2) - && $this->isSlash($strPath{0}) - && $this->isSlash($strPath{1})) { - /* UNC pathname: Retain first slash; leave src pointed at - * second slash so that further slashes will be collapsed - * into the second slash. The result will be a pathname - * beginning with "\\\\" followed (most likely) by a host - * name. */ - $src = 1; - $sb.=$this->slash; - } - } - return $src; - } - - /** Normalize the given pathname, whose length is len, starting at the given - offset; everything before this offset is already normal. */ - protected function normalizer($strPath, $len, $offset) { - if ($len == 0) { - return $strPath; - } - if ($offset < 3) { - $offset = 0; //Avoid fencepost cases with UNC pathnames - } - $src = 0; - $slash = $this->slash; - $sb = ""; - - if ($offset == 0) { - // Complete normalization, including prefix - $src = $this->normalizePrefix($strPath, $len, $sb); - } else { - // Partial normalization - $src = $offset; - $sb .= substr($strPath, 0, $offset); - } - - // Remove redundant slashes from the remainder of the path, forcing all - // slashes into the preferred slash - while ($src < $len) { - $c = $strPath{$src++}; - if ($this->isSlash($c)) { - while (($src < $len) && $this->isSlash($strPath{$src})) { - $src++; - } - if ($src === $len) { - /* Check for trailing separator */ - $sn = (int) strlen($sb); - if (($sn == 2) && ($sb{1} === ':')) { - // "z:\\" - $sb .= $slash; - break; - } - if ($sn === 0) { - // "\\" - $sb .= $slash; - break; - } - if (($sn === 1) && ($this->isSlash($sb{0}))) { - /* "\\\\" is not collapsed to "\\" because "\\\\" marks - the beginning of a UNC pathname. Even though it is - not, by itself, a valid UNC pathname, we leave it as - is in order to be consistent with the win32 APIs, - which treat this case as an invalid UNC pathname - rather than as an alias for the root directory of - the current drive. */ - $sb .= $slash; - break; - } - // Path does not denote a root directory, so do not append - // trailing slash - break; - } else { - $sb .= $slash; - } - } else { - $sb.=$c; - } - } - $rv = (string) $sb; - return $rv; - } - - /** - * Check that the given pathname is normal. If not, invoke the real - * normalizer on the part of the pathname that requires normalization. - * This way we iterate through the whole pathname string only once. - * @param string $strPath - * @return string - */ - function normalize($strPath) { - $n = strlen($strPath); - $slash = $this->slash; - $altSlash = $this->altSlash; - $prev = 0; - for ($i = 0; $i < $n; $i++) { - $c = $strPath{$i}; - if ($c === $altSlash) { - return $this->normalizer($strPath, $n, ($prev === $slash) ? $i - 1 : $i); - } - if (($c === $slash) && ($prev === $slash) && ($i > 1)) { - return $this->normalizer($strPath, $n, $i - 1); - } - if (($c === ':') && ($i > 1)) { - return $this->normalizer($strPath, $n, 0); - } - $prev = $c; - } - if ($prev === $slash) { - return $this->normalizer($strPath, $n, $n - 1); - } - return $strPath; - } - - function prefixLength($strPath) { - $path = (string) $strPath; - $slash = (string) $this->slash; - $n = (int) strlen($path); - if ($n === 0) { - return 0; - } - $c0 = $path{0}; - $c1 = ($n > 1) ? $path{1} : - 0; - if ($c0 === $slash) { - if ($c1 === $slash) { - return 2; // absolute UNC pathname "\\\\foo" - } - return 1; // drive-relative "\\foo" - } - - if ($this->isLetter($c0) && ($c1 === ':')) { - if (($n > 2) && ($path{2}) === $slash) { - return 3; // Absolute local pathname "z:\\foo" */ - } - return 2; // Directory-relative "z:foo" - } - return 0; // Completely relative - } - - function resolve($parent, $child) { - $parent = (string) $parent; - $child = (string) $child; - $slash = (string) $this->slash; - - $pn = (int) strlen($parent); - if ($pn === 0) { - return $child; - } - $cn = (int) strlen($child); - if ($cn === 0) { - return $parent; - } - - $c = $child; - if (($cn > 1) && ($c{0} === $slash)) { - if ($c{1} === $slash) { - // drop prefix when child is a UNC pathname - $c = substr($c, 2); - } - else { - //Drop prefix when child is drive-relative */ - $c = substr($c, 1); - } - } - - $p = $parent; - if ($p{$pn - 1} === $slash) { - $p = substr($p, 0, $pn - 1); - } - return $p.$this->slashify($c); - } - - function getDefaultParent() { - return (string) ("".$this->slash); - } - - function fromURIPath($strPath) { - $p = (string) $strPath; - if ((strlen($p) > 2) && ($p{2} === ':')) { - - // "/c:/foo" --> "c:/foo" - $p = substr($p,1); - - // "c:/foo/" --> "c:/foo", but "c:/" --> "c:/" - if ((strlen($p) > 3) && StringHelper::endsWith('/', $p)) { - $p = substr($p, 0, strlen($p) - 1); - } - } elseif ((strlen($p) > 1) && StringHelper::endsWith('/', $p)) { - // "/foo/" --> "/foo" - $p = substr($p, 0, strlen($p) - 1); - } - return (string) $p; - } - - - /* -- Path operations -- */ - - function isAbsolute(PhingFile $f) { - $pl = (int) $f->getPrefixLength(); - $p = (string) $f->getPath(); - return ((($pl === 2) && ($p{0} === $this->slash)) || ($pl === 3) || ($pl === 1 && $p{0} === $this->slash)); - } - - /** private */ - function _driveIndex($d) { - $d = (string) $d{0}; - if ((ord($d) >= ord('a')) && (ord($d) <= ord('z'))) { - return ord($d) - ord('a'); - } - if ((ord($d) >= ord('A')) && (ord($d) <= ord('Z'))) { - return ord($d) - ord('A'); - } - return -1; - } - - /** private */ - function _getDriveDirectory($drive) { - $drive = (string) $drive{0}; - $i = (int) $this->_driveIndex($drive); - if ($i < 0) { - return null; - } - - $s = (isset(self::$driveDirCache[$i]) ? self::$driveDirCache[$i] : null); - - if ($s !== null) { - return $s; - } - - $s = $this->_getDriveDirectory($i + 1); - self::$driveDirCache[$i] = $s; - return $s; - } - - function _getUserPath() { - //For both compatibility and security, we must look this up every time - return (string) $this->normalize(Phing::getProperty("user.dir")); - } - - function _getDrive($path) { - $path = (string) $path; - $pl = $this->prefixLength($path); - return ($pl === 3) ? substr($path, 0, 2) : null; - } - - function resolveFile(PhingFile $f) { - $path = $f->getPath(); - $pl = (int) $f->getPrefixLength(); - - if (($pl === 2) && ($path{0} === $this->slash)) { - return path; // UNC - } - - if ($pl === 3) { - return $path; // Absolute local - } - - if ($pl === 0) { - return (string) ($this->_getUserPath().$this->slashify($path)); //Completely relative - } - - if ($pl === 1) { // Drive-relative - $up = (string) $this->_getUserPath(); - $ud = (string) $this->_getDrive($up); - if ($ud !== null) { - return (string) $ud.$path; - } - return (string) $up.$path; //User dir is a UNC path - } - - if ($pl === 2) { // Directory-relative - $up = (string) $this->_getUserPath(); - $ud = (string) $this->_getDrive($up); - if (($ud !== null) && StringHelper::startsWith($ud, $path)) { - return (string) ($up . $this->slashify(substr($path,2))); - } - $drive = (string) $path{0}; - $dir = (string) $this->_getDriveDirectory($drive); - - $np = (string) ""; - if ($dir !== null) { - /* When resolving a directory-relative path that refers to a - drive other than the current drive, insist that the caller - have read permission on the result */ - $p = (string) $drive . (':'.$dir.$this->slashify(substr($path,2))); - - if (!$this->checkAccess($p, false)) { - // FIXME - // throw security error - die("Can't resolve path $p"); - } - return $p; - } - return (string) $drive.':'.$this->slashify(substr($path,2)); //fake it - } - - throw new Exception("Unresolvable path: " . $path); - } - - /* -- most of the following is mapped to the functions mapped th php natives in FileSystem */ - - /* -- Attribute accessors -- */ - - function setReadOnly($f) { - // dunno how to do this on win - throw new Exception("WIN32FileSystem doesn't support read-only yet."); - } - - /* -- Filesystem interface -- */ - - protected function _access($path) { - if (!$this->checkAccess($path, false)) { - throw new Exception("Can't resolve path $p"); - } - return true; - } - - function _nativeListRoots() { - // FIXME - } - - function listRoots() { - $ds = _nativeListRoots(); - $n = 0; - for ($i = 0; $i < 26; $i++) { - if ((($ds >> $i) & 1) !== 0) { - if (!$this->access((string)( chr(ord('A') + $i) . ':' . $this->slash))) { - $ds &= ~(1 << $i); - } else { - $n++; - } - } - } - $fs = array(); - $j = (int) 0; - $slash = (string) $this->slash; - for ($i = 0; $i < 26; $i++) { - if ((($ds >> $i) & 1) !== 0) { - $fs[$j++] = new PhingFile(chr(ord('A') + $i) . ':' . $this->slash); - } - } - return $fs; - } - - /* -- Basic infrastructure -- */ - - /** compares file paths lexicographically */ - function compare(PhingFile $f1, PhingFile $f2) { - $f1Path = $f1->getPath(); - $f2Path = $f2->getPath(); - return (boolean) strcasecmp((string) $f1Path, (string) $f2Path); - } - - - /** - * returns the contents of a directory in an array - */ - function lister($f) { - $dir = @opendir($f->getAbsolutePath()); - if (!$dir) { - throw new Exception("Can't open directory " . $f->__toString()); - } - $vv = array(); - while (($file = @readdir($dir)) !== false) { - if ($file == "." || $file == "..") { - continue; - } - $vv[] = (string) $file; - } - @closedir($dir); - return $vv; - } - -} - -?> diff --git a/buildscripts/phing/classes/phing/system/io/WinNTFileSystem.php b/buildscripts/phing/classes/phing/system/io/WinNTFileSystem.php deleted file mode 100644 index 86f76d80..00000000 --- a/buildscripts/phing/classes/phing/system/io/WinNTFileSystem.php +++ /dev/null @@ -1,35 +0,0 @@ -. - */ - -include_once 'phing/system/io/Win32FileSystem.php'; - -/** - * FileSystem for Windows NT/2000. - * @package phing.system.io - */ - -class WinNTFileSystem extends Win32FileSystem { - - /* -- class only for convenience and future use everything is inherinted --*/ - - -} -?> diff --git a/buildscripts/phing/classes/phing/system/io/Writer.php b/buildscripts/phing/classes/phing/system/io/Writer.php deleted file mode 100644 index 5e1a69b9..00000000 --- a/buildscripts/phing/classes/phing/system/io/Writer.php +++ /dev/null @@ -1,48 +0,0 @@ -. - */ - -/** - * Abstract class for writing character streams. - * @package phing.system.io - */ -abstract class Writer { - - abstract public function write($buf, $off = null, $len = null); - - abstract public function reset(); - - abstract public function close(); - - abstract public function open(); - - public function mark() {} - - public function ready() {} - - public function markSupported() {} - - /** - * Returns the filename, url, etc. that is being written to. - * @return string - */ - abstract function getResource(); -} -?> diff --git a/buildscripts/phing/classes/phing/system/lang/Character.php b/buildscripts/phing/classes/phing/system/lang/Character.php deleted file mode 100644 index bb7a5589..00000000 --- a/buildscripts/phing/classes/phing/system/lang/Character.php +++ /dev/null @@ -1,49 +0,0 @@ -. - */ - -/** - * @package phing.system.lang - */ -class Character { - - // this class might be extended with plenty of ordinal char constants - // and the like to support the multibyte aware datatype (char) in php - // in form of an object. - // anyway just a thought - - function isLetter($char) { - - if (strlen($char) !== 1) - $char = 0; - - $char = (int) ord($char); - - if ($char >= ord('A') && $char <= ord('Z')) - return true; - - if ($char >= ord('a') && $char <= ord('z')) - return true; - - return false; - } - -} -?> diff --git a/buildscripts/phing/classes/phing/system/lang/EventObject.php b/buildscripts/phing/classes/phing/system/lang/EventObject.php deleted file mode 100644 index 4a2211bc..00000000 --- a/buildscripts/phing/classes/phing/system/lang/EventObject.php +++ /dev/null @@ -1,52 +0,0 @@ -. - */ - -/** - * @package phing.system.lang - */ -class EventObject { - - /** The object on which the Event initially occurred. */ - protected $source; - - /** Constructs a prototypical Event. */ - function __construct($source) { - if ($source === null) { - throw new Exception("Null source"); - } - $this->source = $source; - } - - /** The object on which the Event initially occurred. */ - function getSource() { - return $this->source; - } - - /** Returns a String representation of this EventObject.*/ - function toString() { - if (method_exists($this->source, "toString")) { - return get_class($this)."[source=".$this->source->toString()."]"; - } else { - return get_class($this)."[source=".get_class($this->source)."]"; - } - } -} -?> diff --git a/buildscripts/phing/classes/phing/system/lang/FileNotFoundException.php b/buildscripts/phing/classes/phing/system/lang/FileNotFoundException.php deleted file mode 100644 index ff48c785..00000000 --- a/buildscripts/phing/classes/phing/system/lang/FileNotFoundException.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -/** - * @package phing.system.lang - */ -class FileNotFoundException extends Exception {} - -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/system/lang/NullPointerException.php b/buildscripts/phing/classes/phing/system/lang/NullPointerException.php deleted file mode 100644 index 38fa5c10..00000000 --- a/buildscripts/phing/classes/phing/system/lang/NullPointerException.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -/** - * @package phing.system.lang - */ -class NullPointerException extends Exception {} - -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/system/lang/SecurityException.php b/buildscripts/phing/classes/phing/system/lang/SecurityException.php deleted file mode 100644 index 21e8b1c3..00000000 --- a/buildscripts/phing/classes/phing/system/lang/SecurityException.php +++ /dev/null @@ -1,27 +0,0 @@ -. - */ - -/** - * @package phing.system.lang - */ -class SecurityException extends Exception {} - -?> \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/system/util/Message.php b/buildscripts/phing/classes/phing/system/util/Message.php deleted file mode 100644 index bf7bb56b..00000000 --- a/buildscripts/phing/classes/phing/system/util/Message.php +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/buildscripts/phing/classes/phing/system/util/Properties.php b/buildscripts/phing/classes/phing/system/util/Properties.php deleted file mode 100644 index deff2cdf..00000000 --- a/buildscripts/phing/classes/phing/system/util/Properties.php +++ /dev/null @@ -1,270 +0,0 @@ -. - */ - -include_once 'phing/system/io/PhingFile.php'; -include_once 'phing/system/io/FileWriter.php'; - -/** - * Convenience class for reading and writing property files. - * - * FIXME - * - Add support for arrays (separated by ',') - * - * @package phing.system.util - * @version $Revision: 1.13 $ - */ -class Properties { - - private $properties = array(); - - /** - * Load properties from a file. - * - * @param PhingFile $file - * @return void - * @throws IOException - if unable to read file. - */ - function load(PhingFile $file) { - if ($file->canRead()) { - $this->parse($file->getPath(), false); - } else { - throw new IOException("Can not read file ".$file->getPath()); - } - - } - - /** - * Replaces parse_ini_file() or better_parse_ini_file(). - * Saves a step since we don't have to parse and then check return value - * before throwing an error or setting class properties. - * - * @param string $filePath - * @param boolean $processSections Whether to honor [SectionName] sections in INI file. - * @return array Properties loaded from file (no prop replacements done yet). - */ - protected function parse($filePath) { - - // load() already made sure that file is readable - // but we'll double check that when reading the file into - // an array - - if (($lines = @file($filePath)) === false) { - throw new IOException("Unable to parse contents of $filePath"); - } - - $this->properties = array(); - $sec_name = ""; - - foreach($lines as $line) { - - $line = trim($line); - - if($line == "") - continue; - - if ($line{0} == '#' or $line{0} == ';') { - // it's a comment, so continue to next line - continue; - } else { - $pos = strpos($line, '='); - $property = trim(substr($line, 0, $pos)); - $value = trim(substr($line, $pos + 1)); - $this->properties[$property] = $this->inVal($value); - } - - } // for each line - } - - /** - * Process values when being read in from properties file. - * does things like convert "true" => true - * @param string $val Trimmed value. - * @return mixed The new property value (may be boolean, etc.) - */ - protected function inVal($val) { - if ($val === "true") { - $val = true; - } elseif ($val === "false") { - $val = false; - } - return $val; - } - - /** - * Process values when being written out to properties file. - * does things like convert true => "true" - * @param mixed $val The property value (may be boolean, etc.) - * @return string - */ - protected function outVal($val) { - if ($val === true) { - $val = "true"; - } elseif ($val === false) { - $val = "false"; - } - return $val; - } - - /** - * Create string representation that can be written to file and would be loadable using load() method. - * - * Essentially this function creates a string representation of properties that is ready to - * write back out to a properties file. This is used by store() method. - * - * @return string - */ - public function toString() { - $buf = ""; - foreach($this->properties as $key => $item) { - $buf .= $key . "=" . $this->outVal($item) . Phing::getProperty('line.separator'); - } - return $buf; - } - - /** - * Stores current properties to specified file. - * - * @param PhingFile $file File to create/overwrite with properties. - * @param string $header Header text that will be placed (within comments) at the top of properties file. - * @return void - * @throws IOException - on error writing properties file. - */ - function store(PhingFile $file, $header = null) { - // stores the properties in this object in the file denoted - // if file is not given and the properties were loaded from a - // file prior, this method stores them in the file used by load() - try { - $fw = new FileWriter($file); - $fw->open(); - if ($header !== null) { - $fw->write( "# " . $header . Phing::getProperty("line.separator") ); - } - $fw->write($this->toString()); - $fw->close(); - } catch (IOException $e) { - throw new IOException("Error writing property file: " . $e->getMessage()); - } - } - - /** - * Returns copy of internal properties hash. - * Mostly for performance reasons, property hashes are often - * preferable to passing around objects. - * - * @return array - */ - function getProperties() { - return $this->properties; - } - - /** - * Get value for specified property. - * This is the same as get() method. - * - * @param string $prop The property name (key). - * @return mixed - * @see get() - */ - function getProperty($prop) { - if (!isset($this->properties[$prop])) { - return null; - } - return $this->properties[$prop]; - } - - /** - * Get value for specified property. - * This function exists to provide a hashtable-like interface for - * properties. - * - * @param string $prop The property name (key). - * @return mixed - * @see getProperty() - */ - function get($prop) { - if (!isset($this->properties[$prop])) { - return null; - } - return $this->properties[$prop]; - } - - /** - * Set the value for a property. - * - * @param string $key - * @param mixed $value - * @return mixed Old property value or NULL if none was set. - */ - function setProperty($key, $value) { - $oldValue = @$this->properties[$key]; - $this->properties[$key] = $value; - return $oldValue; - } - - /** - * Set the value for a property. - * This function exists to provide hashtable-lie - * interface for properties. - * - * @param string $key - * @param mixed $value - */ - function put($key, $value) { - return $this->setProperty($key, $value); - } - - /** - * Same as keys() function, returns an array of property names. - * @return array - */ - function propertyNames() { - return $this->keys(); - } - - /** - * Whether loaded properties array contains specified property name. - * @return boolean - */ - function containsKey($key) { - return isset($this->properties[$key]); - } - - /** - * Returns properties keys. - * Use this for foreach() {} iterations, as this is - * faster than looping through property values. - * @return array - */ - function keys() { - return array_keys($this->properties); - } - - /** - * Whether properties list is empty. - * @return boolean - */ - function isEmpty() { - return empty($this->properties); - } - -} -?> diff --git a/buildscripts/phing/classes/phing/system/util/Register.php b/buildscripts/phing/classes/phing/system/util/Register.php deleted file mode 100644 index 5ef2b2fd..00000000 --- a/buildscripts/phing/classes/phing/system/util/Register.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * - * - * The task/type must provide a supporting setter for the attribute: - * - * - * function setListeningReplace(RegisterSlot $slot) { - * $this->replace = $slot; - * } - * - * // in main() - * if ($this->replace instanceof RegisterSlot) { - * $this->regexp->setReplace($this->replace->getValue()); - * } else { - * $this->regexp->setReplace($this->replace); - * } - * - * - * @author Hans Lellelid - * @version $Revision: 1.3 $ - * @package phing.system.util - */ -class Register { - - /** Slots that have been registered */ - private static $slots = array(); - - /** - * Returns RegisterSlot for specified key. - * - * If not slot exists a new one is created for key. - * - * @param string $key - * @return RegisterSlot - */ - public static function getSlot($key) { - if (!isset(self::$slots[$key])) { - self::$slots[$key] = new RegisterSlot($key); - } - return self::$slots[$key]; - } -} - - -/** - * Represents a slot in the register. - */ -class RegisterSlot { - - /** The name of this slot. */ - private $key; - - /** The value for this slot. */ - private $value; - - /** - * Constructs a new RegisterSlot, setting the key to passed param. - * @param string $key - */ - public function __construct($key) { - $this->key = (string) $key; - } - - /** - * Sets the key / name for this slot. - * @param string $k - */ - public function setKey($k) { - $this->key = (string) $k; - } - - /** - * Gets the key / name for this slot. - * @return string - */ - public function getKey() { - return $this->key; - } - - /** - * Sets the value for this slot. - * @param mixed - */ - public function setValue($v) { - $this->value = $v; - } - - /** - * Returns the value at this slot. - * @return mixed - */ - public function getValue() { - return $this->value; - } - -} -?> diff --git a/buildscripts/phing/classes/phing/system/util/Timer.php b/buildscripts/phing/classes/phing/system/util/Timer.php deleted file mode 100644 index a2a665b0..00000000 --- a/buildscripts/phing/classes/phing/system/util/Timer.php +++ /dev/null @@ -1,96 +0,0 @@ -. - */ - - -/** - * This class can be used to obtain the execution time of all of the scripts - * that are executed in the process of building a page. - * - * Example: - * To be done before any scripts execute: - * - * $Timer = new Timer; - * $Timer->Start_Timer(); - * - * To be done after all scripts have executed: - * - * $timer->Stop_Timer(); - * $timer->Get_Elapsed_Time(int number_of_places); - * - * @author Charles Killian - * @author Hans Lellelid - * @package phing.system.util - * @version $Revision: 1.5 $ $Date: 2003/12/24 13:02:09 $ - */ -class Timer { - - /** start time */ - protected $stime; - - /** end time */ - protected $etime; - - /** - * This function sets the class variable $stime to the current time in - * microseconds. - * @return void - */ - public function start() { - $this->stime = $this->getMicrotime(); - } - - /** - * This function sets the class variable $etime to the current time in - * microseconds. - * @return void - */ - function stop() { - $this->etime = $this->getMicrotime(); - } - - /** - * This function returns the elapsed time in seconds. - * - * Call start_time() at the beginning of script execution and end_time() at - * the end of script execution. Then, call elapsed_time() to obtain the - * difference between start_time() and end_time(). - * - * @param $places decimal place precision of elapsed time (default is 5) - * @return string Properly formatted time. - */ - function getElapsedTime($places=5) { - $etime = $this->etime - $this->stime; - $format = "%0.".$places."f"; - return (sprintf ($format, $etime)); - } - - /** - * This function returns the current time in microseconds. - * - * @author Everett Michaud, Zend.com - * @return current time in microseconds - * @access private - */ - function getMicrotime() { - list($usec, $sec) = explode(" ", microtime()); - return ((float)$usec + (float)$sec); - } -} diff --git a/buildscripts/phing/classes/phing/tasks/defaults.properties b/buildscripts/phing/classes/phing/tasks/defaults.properties deleted file mode 100644 index d0e62eff..00000000 --- a/buildscripts/phing/classes/phing/tasks/defaults.properties +++ /dev/null @@ -1,69 +0,0 @@ -; ------------------------------------- -; These taskdefs are loaded at startup. -; ------------------------------------- - -; Internal system tasks -; -adhoc=phing.tasks.system.AdhocTask -adhoc-task=phing.tasks.system.AdhocTaskdefTask -adhoc-type=phing.tasks.system.AdhocTypedefTask -append=phing.tasks.system.AppendTask -available=phing.tasks.system.AvailableTask -chmod=phing.tasks.system.ChmodTask -condition=phing.tasks.system.ConditionTask -copy=phing.tasks.system.CopyTask -cvs=phing.tasks.system.CvsTask -cvspass=phing.tasks.system.CvsPassTask -delete=phing.tasks.system.DeleteTask -echo=phing.tasks.system.EchoTask -exec=phing.tasks.system.ExecTask -fail=phing.tasks.system.ExitTask -foreach=phing.tasks.system.ForeachTask -includepath=phing.tasks.system.IncludePathTask -input=phing.tasks.system.InputTask -mkdir=phing.tasks.system.MkdirTask -move=phing.tasks.system.MoveTask -phing=phing.tasks.system.PhingTask -phingcall=phing.tasks.system.PhingCallTask -php=phing.tasks.system.PhpEvalTask -property=phing.tasks.system.PropertyTask -propertyprompt=phing.tasks.system.PropertyPromptTask -reflexive=phing.tasks.system.ReflexiveTask -resolvepath=phing.tasks.system.ResolvePathTask -taskdef=phing.tasks.system.TaskdefTask -touch=phing.tasks.system.TouchTask -tstamp=phing.tasks.system.TstampTask -typedef=phing.tasks.system.TypedefTask -uptodate=phing.tasks.system.UpToDateTask -xslt=phing.tasks.system.XsltTask -if=phing.tasks.system.IfTask -warn=phing.tasks.system.WarnTask - -; "Core" contributed tasks -; -- i.e. no taskdef needed. - -sql=phing.tasks.ext.CreoleSQLExecTask -package-as-path=phing.tasks.ext.PackageAsPathTask -smarty=phing.tasks.ext.SmartyTask -capsule=phing.tasks.ext.CapsuleTask -tar=phing.tasks.ext.TarTask -pearpkg=phing.tasks.ext.PearPackageTask -mail=phing.tasks.ext.MailTask -zip=phing.tasks.ext.ZipTask -phplint=phing.tasks.ext.PhpLintTask - -; "ext" tasks -phpdoc=phing.tasks.ext.phpdoc.PHPDocumentorTask -svnlastrevision=phing.tasks.ext.svn.SvnLastRevisionTask -svnexport=phing.tasks.ext.svn.SvnExportTask -phpunit2=phing.tasks.ext.phpunit2.PHPUnit2Task -phpunit2report=phing.tasks.ext.phpunit2.PHPUnit2ReportTask -coverage-setup=phing.tasks.ext.coverage.CoverageSetupTask -coverage-merger=phing.tasks.ext.coverage.CoverageMergerTask -coverage-report=phing.tasks.ext.coverage.CoverageReportTask -ioncubeencoder=phing.tasks.ext.ioncube.IoncubeEncoderTask -ioncubelicense=phing.tasks.ext.ioncube.IoncubeLicenseTask -simpletest=phing.tasks.ext.simpletest.SimpleTestTask -phplint=phing.tasks.ext.PhpLintTask -xmllint=phing.tasks.ext.XmlLintTask -analyze=phing.tasks.ext.ZendCodeAnalyzerTask \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/ext/CapsuleTask.php b/buildscripts/phing/classes/phing/tasks/ext/CapsuleTask.php deleted file mode 100644 index aa43a0e4..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/CapsuleTask.php +++ /dev/null @@ -1,478 +0,0 @@ -. - */ - -include_once 'phing/Task.php'; -include_once 'phing/BuildException.php'; -include_once 'phing/lib/Capsule.php'; -include_once 'phing/util/StringHelper.php'; - -/** - * A phing task for generating output by using Capsule. - * - * This is based on the interface to TexenTask from Apache's Velocity engine. - * - * @author Hans Lellelid - * @version $Revision: 1.17 $ - * @package phing.tasks.ext - */ -class CapsuleTask extends Task { - - /** - * Capsule "template" engine. - * @var Capsule - */ - protected $context; - - /** - * Any vars assigned via the build file. - * @var array AssignedVar[] - */ - protected $assignedVars = array(); - - /** - * This is the control template that governs the output. - * It may or may not invoke the services of worker - * templates. - * @var string - */ - protected $controlTemplate; - - /** - * This is where Velocity will look for templates - * using the file template loader. - * @var string - */ - protected $templatePath; - - /** - * This is where texen will place all the output - * that is a product of the generation process. - * @var string - */ - protected $outputDirectory; - - /** - * This is the file where the generated text - * will be placed. - * @var string - */ - protected $outputFile; - - /** - *

- * These are properties that are fed into the - * initial context from a properties file. This - * is simply a convenient way to set some values - * that you wish to make available in the context. - *

- *

- * These values are not critical, like the template path - * or output path, but allow a convenient way to - * set a value that may be specific to a particular - * generation task. - *

- *

- * For example, if you are generating scripts to allow - * user to automatically create a database, then - * you might want the $databaseName - * to be placed - * in the initial context so that it is available - * in a script that might look something like the - * following: - *

-     * #!bin/sh
-     * 
-     * echo y | mysqladmin create $databaseName
-     * 
- * The value of $databaseName isn't critical to - * output, and you obviously don't want to change - * the ant task to simply take a database name. - * So initial context values can be set with - * properties file. - * - * @var array - */ - protected $contextProperties; - - // ----------------------------------------------------------------------- - // The following getters & setters are used by phing to set properties - // specified in the XML for the capsule task. - // ----------------------------------------------------------------------- - - /** - * [REQUIRED] Set the control template for the - * generating process. - * @param string $controlTemplate - * @return void - */ - public function setControlTemplate ($controlTemplate) { - $this->controlTemplate = $controlTemplate; - } - - /** - * Get the control template for the - * generating process. - * @return string - */ - public function getControlTemplate() { - return $this->controlTemplate; - } - - /** - * [REQUIRED] Set the path where Velocity will look - * for templates using the file template - * loader. - * @return void - * @throws Exception - */ - public function setTemplatePath($templatePath) { - $resolvedPath = ""; - $tok = strtok($templatePath, ","); - while ( $tok ) { - // resolve relative path from basedir and leave - // absolute path untouched. - $fullPath = $this->project->resolveFile($tok); - $cpath = $fullPath->getCanonicalPath(); - if ($cpath === false) { - $this->log("Template directory does not exist: " . $fullPath->getAbsolutePath()); - } else { - $resolvedPath .= $cpath; - } - $tok = strtok(","); - if ( $tok ) { - $resolvedPath .= ","; - } - } - $this->templatePath = $resolvedPath; - } - - /** - * Get the path where Velocity will look - * for templates using the file template - * loader. - * @return string - */ - public function getTemplatePath() { - return $this->templatePath; - } - - /** - * [REQUIRED] Set the output directory. It will be - * created if it doesn't exist. - * @param PhingFile $outputDirectory - * @return void - * @throws Exception - */ - public function setOutputDirectory(PhingFile $outputDirectory) { - try { - if (!$outputDirectory->exists()) { - $this->log("Output directory does not exist, creating: " . $outputDirectory->getPath(),PROJECT_MSG_VERBOSE); - if (!$outputDirectory->mkdirs()) { - throw new IOException("Unable to create Ouptut directory: " . $outputDirectory->getAbsolutePath()); - } - } - $this->outputDirectory = $outputDirectory->getCanonicalPath(); - } catch (IOException $ioe) { - throw new BuildException($ioe); - } - } - - /** - * Get the output directory. - * @return string - */ - public function getOutputDirectory() { - return $this->outputDirectory; - } - - /** - * [REQUIRED] Set the output file for the - * generation process. - * @param string $outputFile (TODO: change this to File) - * @return void - */ - public function setOutputFile($outputFile) { - $this->outputFile = $outputFile; - } - - /** - * Get the output file for the - * generation process. - * @return string - */ - public function getOutputFile() { - return $this->outputFile; - } - - /** - * Set the context properties that will be - * fed into the initial context be the - * generating process starts. - * @param string $file - * @return void - */ - public function setContextProperties($file) { - $sources = explode(",", $file); - $this->contextProperties = new Properties(); - - // Always try to get the context properties resource - // from a file first. Templates may be taken from a JAR - // file but the context properties resource may be a - // resource in the filesystem. If this fails than attempt - // to get the context properties resource from the - // classpath. - for ($i=0, $sourcesLength=count($sources); $i < $sourcesLength; $i++) { - $source = new Properties(); - - try { - - // resolve relative path from basedir and leave - // absolute path untouched. - $fullPath = $this->project->resolveFile($sources[$i]); - $this->log("Using contextProperties file: " . $fullPath->toString()); - $source->load($fullPath); - - } catch (Exception $e) { - - throw new BuildException("Context properties file " . $sources[$i] . - " could not be found in the file system!"); - - } - - $keys = $source->keys(); - - foreach ($keys as $key) { - $name = $key; - $value = $this->project->replaceProperties($source->getProperty($name)); - $this->contextProperties->setProperty($name, $value); - } - } - } - - /** - * Get the context properties that will be - * fed into the initial context be the - * generating process starts. - * @return Properties - */ - public function getContextProperties() { - return $this->contextProperties; - } - - /** - * Creates an "AssignedVar" class. - */ - public function createAssign() { - $a = new AssignedVar(); - $this->assignedVars[] = $a; - return $a; - } - - // --------------------------------------------------------------- - // End of XML setters & getters - // --------------------------------------------------------------- - - /** - * Creates a Smarty object. - * - * @return Smarty initialized (cleared) Smarty context. - * @throws Exception the execute method will catch - * and rethrow as a BuildException - */ - public function initControlContext() { - $this->context->clear(); - foreach($this->assignedVars as $var) { - $this->context->put($var->getName(), $var->getValue()); - } - return $this->context; - } - - /** - * Execute the input script with Velocity - * - * @throws BuildException - * BuildExceptions are thrown when required attributes are missing. - * Exceptions thrown by Velocity are rethrown as BuildExceptions. - */ - public function main() { - - // Make sure the template path is set. - if (empty($this->templatePath)) { - throw new BuildException("The template path needs to be defined!"); - } - - // Make sure the control template is set. - if ($this->controlTemplate === null) { - throw new BuildException("The control template needs to be defined!"); - } - - // Make sure the output directory is set. - if ($this->outputDirectory === null) { - throw new BuildException("The output directory needs to be defined!"); - } - - // Make sure there is an output file. - if ($this->outputFile === null) { - throw new BuildException("The output file needs to be defined!"); - } - - // Setup Smarty runtime. - - // Smarty uses one object to store properties and to store - // the context for the template (unlike Velocity). We setup this object, calling it - // $this->context, and then initControlContext simply zeros out - // any assigned variables. - $this->context = new Capsule(); - - if ($this->templatePath !== null) { - $this->log("Using templatePath: " . $this->templatePath); - $this->context->setTemplatePath($this->templatePath); - } - - // Make sure the output directory exists, if it doesn't - // then create it. - $outputDir = new PhingFile($this->outputDirectory); - if (!$outputDir->exists()) { - $this->log("Output directory does not exist, creating: " . $outputDir->getAbsolutePath()); - $outputDir->mkdirs(); - } - - $this->context->setOutputDirectory($outputDir->getAbsolutePath()); - - $path = $this->outputDirectory . DIRECTORY_SEPARATOR . $this->outputFile; - $this->log("Generating to file " . $path); - - //$writer = new FileWriter($path); - - // The generator and the output path should - // be placed in the init context here and - // not in the generator class itself. - $c = $this->initControlContext(); - - // Set any variables that need to always - // be loaded - $this->populateInitialContext($c); - - // Feed all the options into the initial - // control context so they are available - // in the control/worker templates. - if ($this->contextProperties !== null) { - - foreach($this->contextProperties->keys() as $property) { - - $value = $this->contextProperties->getProperty($property); - - // Special exception (from Texen) - // for properties ending in file.contents: - // in that case we dump the contents of the file - // as the "value" for the Property. - if (preg_match('/file\.contents$/', $property)) { - // pull in contents of file specified - - $property = substr($property, 0, strpos($property, "file.contents") - 1); - - // reset value, and then - // read in teh contents of the file into that var - $value = ""; - $f = new PhingFile($project->resolveFile($value)->getCanonicalPath()); - if ($f->exists()) { - $fr = new FileReader($f); - $fr->readInto($value); - } - - } // if ends with file.contents - - if (StringHelper::isBoolean($value)) { - $value = StringHelper::booleanValue($value); - } - - $c->put($property, $value); - - } // foreach property - - } // if contextProperties !== null - - try { - $this->log("Parsing control template: " . $this->controlTemplate); - $c->parse($this->controlTemplate, $path); - } catch (Exception $ioe) { - throw new BuildException("Cannot write parsed template: ". $ioe->getMessage()); - } - - $this->cleanup(); - } - - /** - * Place useful objects into the initial context. - * - * - * @param Capsule $context The context to populate, as retrieved from - * {@link #initControlContext()}. - * @return void - * @throws Exception Error while populating context. The {@link - * #main()} method will catch and rethrow as a - * BuildException. - */ - protected function populateInitialContext(Capsule $context) { - $this->context->put("now", strftime("%c", time())); - $this->context->put("task", $this); - } - - /** - * A hook method called at the end of {@link #execute()} which can - * be overridden to perform any necessary cleanup activities (such - * as the release of database connections, etc.). By default, - * does nothing. - * @return void - * @throws Exception Problem cleaning up. - */ - protected function cleanup() { - } -} - - -/** - * An "inner" class for holding assigned var values. - * May be need to expand beyond name/value in the future. - */ -class AssignedVar { - - private $name; - private $value; - - function setName($v) { - $this->name = $v; - } - - function setValue($v) { - $this->value = $v; - } - - function getName() { - return $this->name; - } - - function getValue() { - return $this->value; - } - -} \ No newline at end of file diff --git a/buildscripts/phing/classes/phing/tasks/ext/CreoleSQLExecTask.php b/buildscripts/phing/classes/phing/tasks/ext/CreoleSQLExecTask.php deleted file mode 100644 index d35e44f4..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/CreoleSQLExecTask.php +++ /dev/null @@ -1,556 +0,0 @@ -. - */ - -require_once 'phing/tasks/ext/CreoleTask.php'; -include_once 'phing/system/io/StringReader.php'; - -/** - * Executes a series of SQL statements on a database using Creole. - * - *

Statements can - * either be read in from a text file using the src attribute or from - * between the enclosing SQL tags.

- * - *

Multiple statements can be provided, separated by semicolons (or the - * defined delimiter). Individual lines within the statements can be - * commented using either --, // or REM at the start of the line.

- * - *

The autocommit attribute specifies whether auto-commit should be - * turned on or off whilst executing the statements. If auto-commit is turned - * on each statement will be executed and committed. If it is turned off the - * statements will all be executed as one transaction.

- * - *

The onerror attribute specifies how to proceed when an error occurs - * during the execution of one of the statements. - * The possible values are: continue execution, only show the error; - * stop execution and commit transaction; - * and abort execution and transaction and fail task.

- * - * @author Hans Lellelid (Phing) - * @author Jeff Martin (Ant) - * @author Michael McCallum (Ant) - * @author Tim Stephenson (Ant) - * @package phing.tasks.ext - * @version $Revision: 1.21 $ - */ -class CreoleSQLExecTask extends CreoleTask { - - private $goodSql = 0; - private $totalSql = 0; - - const DELIM_ROW = "row"; - const DELIM_NORMAL = "normal"; - - /** - * Database connection - */ - private $conn = null; - - /** - * files to load - */ - private $filesets = array(); - - /** - * SQL statement - */ - private $statement = null; - - /** - * SQL input file - */ - private $srcFile = null; - - /** - * SQL input command - */ - private $sqlCommand = ""; - - /** - * SQL transactions to perform - */ - private $transactions = array(); - - /** - * SQL Statement delimiter - */ - private $delimiter = ";"; - - /** - * The delimiter type indicating whether the delimiter will - * only be recognized on a line by itself - */ - private $delimiterType = "normal"; // can't use constant just defined - - /** - * Print SQL results. - */ - private $print = false; - - /** - * Print header columns. - */ - private $showheaders = true; - - /** - * Results Output file. - */ - private $output = null; - - - /** - * Action to perform if an error is found - **/ - private $onError = "abort"; - - /** - * Encoding to use when reading SQL statements from a file - */ - private $encoding = null; - - /** - * Append to an existing file or overwrite it? - */ - private $append = false; - - /** - * Set the name of the SQL file to be run. - * Required unless statements are enclosed in the build file - */ - public function setSrc(PhingFile $srcFile) { - $this->srcFile = $srcFile; - } - - /** - * Set an inline SQL command to execute. - * NB: Properties are not expanded in this text. - */ - public function addText($sql) { - $this->sqlCommand .= $sql; - } - - /** - * Adds a set of files (nested fileset attribute). - */ - public function addFileset(FileSet $set) { - $this->filesets[] = $set; - } - - /** - * Add a SQL transaction to execute - */ - public function createTransaction() { - $t = new SQLExecTransaction($this); - $this->transactions[] = $t; - return $t; - } - - /** - * Set the file encoding to use on the SQL files read in - * - * @param encoding the encoding to use on the files - */ - public function setEncoding($encoding) { - $this->encoding = $encoding; - } - - /** - * Set the statement delimiter. - * - *

For example, set this to "go" and delimitertype to "ROW" for - * Sybase ASE or MS SQL Server.

- * - * @param delimiter - */ - public function setDelimiter($delimiter) - { - $this->delimiter = $delimiter; - } - - /** - * Set the Delimiter type for this sql task. The delimiter type takes two - * values - normal and row. Normal means that any occurence of the delimiter - * terminate the SQL command whereas with row, only a line containing just - * the delimiter is recognized as the end of the command. - * - * @param string $delimiterType - */ - public function setDelimiterType($delimiterType) - { - $this->delimiterType = $delimiterType; - } - - /** - * Set the print flag. - * - * @param boolean $print - */ - public function setPrint($print) - { - $this->print = (boolean) $print; - } - - /** - * Print headers for result sets from the - * statements; optional, default true. - * @param boolean $showheaders - */ - public function setShowheaders($showheaders) { - $this->showheaders = (boolean) $showheaders; - } - - /** - * Set the output file; - * optional, defaults to the console. - * @param PhingFile $output - */ - public function setOutput(PhingFile $output) { - $this->output = $output; - } - - /** - * whether output should be appended to or overwrite - * an existing file. Defaults to false. - * @param $append - */ - public function setAppend($append) { - $this->append = (boolean) $append; - } - - - /** - * Action to perform when statement fails: continue, stop, or abort - * optional; default "abort" - */ - public function setOnerror($action) { - $this->onError = $action; - } - - /** - * Load the sql file and then execute it - * @throws BuildException - */ - public function main() { - - $savedTransaction = array(); - for($i=0,$size=count($this->transactions); $i < $size; $i++) { - $savedTransaction[] = clone $this->transactions[$i]; - } - - $savedSqlCommand = $this->sqlCommand; - - $this->sqlCommand = trim($this->sqlCommand); - - try { - if ($this->srcFile === null && $this->sqlCommand === "" - && empty($this->filesets)) { - if (count($this->transactions) === 0) { - throw new BuildException("Source file or fileset, " - . "transactions or sql statement " - . "must be set!", $this->location); - } - } - - if ($this->srcFile !== null && !$this->srcFile->exists()) { - throw new BuildException("Source file does not exist!", $this->location); - } - - // deal with the filesets - for ($i = 0,$size=count($this->filesets); $i < $size; $i++) { - $fs = $this->filesets[$i]; - $ds = $fs->getDirectoryScanner($this->project); - $srcDir = $fs->getDir($this->project); - - $srcFiles = $ds->getIncludedFiles(); - - // Make a transaction for each file - for ($j=0, $size=count($srcFiles); $j < $size; $j++) { - $t = $this->createTransaction(); - $t->setSrc(new PhingFile($srcDir, $srcFiles[$j])); - } - } - - // Make a transaction group for the outer command - $t = $this->createTransaction(); - if ($this->srcFile) $t->setSrc($this->srcFile); - $t->addText($this->sqlCommand); - $this->conn = $this->getConnection(); - - try { - - $this->statement = $this->conn->createStatement(); - - $out = null; - - try { - - if ($this->output !== null) { - $this->log("Opening output file " . $this->output, PROJECT_MSG_VERBOSE); - $out = new BufferedWriter(new FileWriter($this->output->getAbsolutePath(), $this->append)); - } - - // Process all transactions - for ($i=0,$size=count($this->transactions); $i < $size; $i++) { - $this->transactions[$i]->runTransaction($out); - if (!$this->isAutocommit()) { - $this->log("Commiting transaction", PROJECT_MSG_VERBOSE); - $this->conn->commit(); - } - } - if ($out) $out->close(); - } catch (Exception $e) { - if ($out) $out->close(); - throw $e; - } - } catch (IOException $e) { - if (!$this->isAutocommit() && $this->conn !== null && $this->onError == "abort") { - try { - $this->conn->rollback(); - } catch (SQLException $ex) {} - } - throw new BuildException($e->getMessage(), $this->location); - } catch (SQLException $e){ - if (!$this->isAutocommit() && $this->conn !== null && $this->onError == "abort") { - try { - $this->conn->rollback(); - } catch (SQLException $ex) {} - } - throw new BuildException($e->getMessage(), $this->location); - } - - $this->log($this->goodSql . " of " . $this->totalSql . - " SQL statements executed successfully"); - } catch (Exception $e) { - $this->transactions = $savedTransaction; - $this->sqlCommand = $savedSqlCommand; - throw $e; - } - // finally { - $this->transactions = $savedTransaction; - $this->sqlCommand = $savedSqlCommand; - - } - - - /** - * read in lines and execute them - * @throws SQLException, IOException - */ - public function runStatements(Reader $reader, $out = null) { - $sql = ""; - $line = ""; - $in = new BufferedReader($reader); - try { - while (($line = $in->readLine()) !== null) { - $line = trim($line); - $line = ProjectConfigurator::replaceProperties($this->project, $line, - $this->project->getProperties()); - - if (StringHelper::startsWith("//", $line) || - StringHelper::startsWith("--", $line) || - StringHelper::startsWith("#", $line)) { - continue; - } - - if (strlen($line) > 4 - && strtoupper(substr($line,0, 4)) == "REM ") { - continue; - } - - $sql .= " " . $line; - $sql = trim($sql); - - // SQL defines "--" as a comment to EOL - // and in Oracle it may contain a hint - // so we cannot just remove it, instead we must end it - if (strpos($line, "--") !== false) { - $sql .= "\n"; - } - - if ($this->delimiterType == self::DELIM_NORMAL - && StringHelper::endsWith($this->delimiter, $sql) - || $this->delimiterType == self::DELIM_ROW - && $line == $this->delimiter) { - $this->log("SQL: " . $sql, PROJECT_MSG_VERBOSE); - $this->execSQL(StringHelper::substring($sql, 0, strlen($sql) - strlen($this->delimiter)) - 1, $out); - $sql = ""; - } - } - - // Catch any statements not followed by ; - if ($sql !== "") { - $this->execSQL($sql, $out); - } - } catch (SQLException $e) { - throw new BuildException("Error running statements", $e); - } - } - - - /** - * Exec the sql statement. - * @throws SQLException - */ - protected function execSQL($sql, $out = null) { - // Check and ignore empty statements - if (trim($sql) == "") { - return; - } - - try { - $this->totalSql++; - if (!$this->statement->execute($sql)) { - $this->log($this->statement->getUpdateCount() . " rows affected", PROJECT_MSG_VERBOSE); - } else { - if ($this->print) { - $this->printResults($out); - } - } - - $this->goodSql++; - - } catch (SQLException $e) { - $this->log("Failed to execute: " . $sql, PROJECT_MSG_ERR); - if ($this->onError != "continue") { - throw new BuildException("Failed to execute SQL", $e); - } - $this->log($e->getMessage(), PROJECT_MSG_ERR); - } - } - - /** - * print any results in the statement. - * @throw SQLException - */ - protected function printResults($out = null) { - $lSep = Phing::getProperty('line.separator'); - $rs = null; - do { - $rs = $this->statement->getResultSet(); - - if ($rs !== null) { - - $this->log("Processing new result set.", PROJECT_MSG_VERBOSE); - - $line = ""; - - $colsprinted = false; - - while ($rs->next()) { - $fields = $rs->getRow(); - - if (!$colsprinted && $this->showheaders) { - $first = true; - foreach($fields as $fieldName => $ignore) { - if ($first) $first = false; else $line .= ","; - $line .= $fieldName; - } - if ($out !== null) { - $out->write($line); - $out->newLine(); - } else { - print($line.$lSep); - } - $line = ""; - $colsprinted = true; - } // if show headers - - $first = true; - foreach($fields as $columnValue) { - - if ($columnValue != null) { - $columnValue = trim($columnValue); - } - - if ($first) { - $first = false; - } else { - $line .= ","; - } - $line .= $columnValue; - } - - if ($out !== null) { - $out->write($line); - $out->newLine(); - } else { - print($line . $lSep); - } - $line = ""; - - } // while rs->next() - } - } while ($this->statement->getMoreResults()); - print($lSep); - if ($out !== null) $out->newLine(); - } -} - - -/** - * "Inner" class that contains the definition of a new transaction element. - * Transactions allow several files or blocks of statements - * to be executed using the same JDBC connection and commit - * operation in between. - */ -class SQLExecTransaction { - - private $tSrcFile = null; - private $tSqlCommand = ""; - private $parent; - - function __construct($parent) - { - // Parent is required so that we can log things ... - $this->parent = $parent; - } - - public function setSrc(PhingFile $src) - { - $this->tSrcFile = $src; - } - - public function addText($sql) - { - $this->tSqlCommand .= $sql; - } - - /** - * @throws IOException, SQLException - */ - public function runTransaction($out = null) - { - if (!empty($this->tSqlCommand)) { - $this->parent->log("Executing commands", PROJECT_MSG_INFO); - $this->parent->runStatements(new StringReader($this->tSqlCommand), $out); - } - - if ($this->tSrcFile !== null) { - $this->parent->log("Executing file: " . $this->tSrcFile->getAbsolutePath(), - PROJECT_MSG_INFO); - $reader = new FileReader($this->tSrcFile); - $this->parent->runStatements($reader, $out); - $reader->close(); - } - } -} - - diff --git a/buildscripts/phing/classes/phing/tasks/ext/CreoleTask.php b/buildscripts/phing/classes/phing/tasks/ext/CreoleTask.php deleted file mode 100644 index a1b439e5..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/CreoleTask.php +++ /dev/null @@ -1,242 +0,0 @@ -. - */ - -require_once 'phing/Task.php'; -include_once 'phing/types/Reference.php'; - -/** - * Handles Creole configuration needed by SQL type tasks. - * - * @author Hans Lellelid (Phing) - * @author Nick Chalko (Ant) - * @author Jeff Martin (Ant) - * @author Michael McCallum (Ant) - * @author Tim Stephenson (Ant) - * @version $Revision: 1.13 $ - * @package phing.tasks.system - */ -abstract class CreoleTask extends Task { - - /** - * Used for caching loaders / driver. This is to avoid - * getting an OutOfMemoryError when calling this task - * multiple times in a row. - * - * NOT IMPLEMENTED YET - */ - private static $loaderMap = array(); - - private $caching = true; - - /** - * Autocommit flag. Default value is false - */ - private $autocommit = false; - - /** - * [optional] Classpath to Creole driver to use. - * @param string - */ - private $driver; - - /** - * DB url. - */ - private $url; - - /** - * User name. - */ - private $userId; - - /** - * Password - */ - private $password; - - /** - * RDBMS Product needed for this SQL. - **/ - private $rdbms; - - /** - * Initialize CreoleTask. - * This method includes any necessary Creole libraries and triggers - * appropriate error if they cannot be found. This is not done in header - * because we may want this class to be loaded w/o triggering an error. - */ - function init() { - include_once 'creole/Creole.php'; - if (!class_exists('Creole')) { - throw new Exception("Creole task depends on Creole classes being on include_path. (i.e. include of 'creole/Creole.php' failed.)"); - } - } - - /** - * Caching loaders / driver. This is to avoid - * getting an OutOfMemoryError when calling this task - * multiple times in a row; default: true - * @param $enable - */ - public function setCaching($enable) { - $this->caching = $enable; - } - - /** - * Sets the database connection URL; required. - * @param url The url to set - */ - public function setUrl($url) { - $this->url = $url; - } - - /** - * Set the Creole driver to be used. - * - * @param string $driver driver class name - */ - public function setDriver($driver) - { - $this->driver = $driver; - } - - /** - * Sets the password; required. - * @param password The password to set - */ - public function setPassword($password) { - $this->password = $password; - } - - /** - * Auto commit flag for database connection; - * optional, default false. - * @param autocommit The autocommit to set - */ - public function setAutocommit($autocommit) { - $this->autocommit = $autocommit; - } - - /** - * Sets the version string, execute task only if - * rdbms version match; optional. - * @param version The version to set - */ - public function setVersion($version) { - $this->version = $version; - } - - protected function getLoaderMap() { - return self::$loaderMap; - } - - - /** - * Creates a new Connection as using the driver, url, userid and password specified. - * The calling method is responsible for closing the connection. - * @return Connection the newly created connection. - * @throws BuildException if the UserId/Password/Url is not set or there is no suitable driver or the driver fails to load. - */ - protected function getConnection() { - - if ($this->url === null) { - throw new BuildException("Url attribute must be set!", $this->location); - } - - try { - - $this->log("Connecting to " . $this->getUrl(), PROJECT_MSG_VERBOSE); - $info = new Properties(); - - $dsn = Creole::parseDSN($this->url); - - if (!isset($dsn["username"]) && $this->userId === null) { - throw new BuildException("Username must be in URL or userid attribute must be set.", $this->location); - } - - if ($this->userId) { - $dsn["username"] = $this->getUserId(); - } - - if ($this->password) { - $dsn["password"] = $this->getPassword(); - } - - if ($this->driver) { - Creole::registerDriver($dsn['phptype'], $this->driver); - } - - $conn = Creole::getConnection($dsn); - $conn->setAutoCommit($this->autocommit); - return $conn; - - } catch (SQLException $e) { - throw new BuildException($e->getMessage(), $this->location); - } - - } - - public function isCaching($value) { - $this->caching = $value; - } - - /** - * Gets the autocommit. - * @return Returns a boolean - */ - public function isAutocommit() { - return $this->autocommit; - } - - /** - * Gets the url. - * @return Returns a String - */ - public function getUrl() { - return $this->url; - } - - /** - * Gets the userId. - * @return Returns a String - */ - public function getUserId() { - return $this->userId; - } - - /** - * Set the user name for the connection; required. - * @param userId The userId to set - */ - public function setUserid($userId) { - $this->userId = $userId; - } - - /** - * Gets the password. - * @return Returns a String - */ - public function getPassword() { - return $this->password; - } - -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/MailTask.php b/buildscripts/phing/classes/phing/tasks/ext/MailTask.php deleted file mode 100644 index 16d29fb8..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/MailTask.php +++ /dev/null @@ -1,77 +0,0 @@ -. - */ - -include_once 'phing/Task.php'; - -/** - * Send a message by mail() - * - * The build process is a success... - * - * @author Francois Harvey at SecuriWeb (http://www.securiweb.net) - * @version $Revision: 1.1 $ - * @package phing.tasks.ext - */ -class MailTask extends Task { - - protected $recipient; - - protected $subject; - - protected $msg; - - function main() { - $this->log('Sending mail to ' . $this->recipient ); - mail($this->recipient, $this->subject, $this->msg); - } - - /** setter for message */ - function setMsg($msg) { - $this->setMessage($msg); - } - - /** alias setter */ - function setMessage($msg) { - $this->msg = (string) $msg; - } - - /** setter for subject **/ - function setSubject($subject) { - $this->subject = (string) $subject; - } - - /** setter for recipient **/ - function setRecipient($recipient) { - $this->recipient = (string) $recipient; - } - - /** alias for recipient **/ - function setTo($recipient) { - $this->recipient = (string) $recipient; - } - - /** Supporting the Message syntax. */ - function addText($msg) - { - $this->msg = (string) $msg; - } -} - diff --git a/buildscripts/phing/classes/phing/tasks/ext/PackageAsPathTask.php b/buildscripts/phing/classes/phing/tasks/ext/PackageAsPathTask.php deleted file mode 100644 index b8664aac..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/PackageAsPathTask.php +++ /dev/null @@ -1,65 +0,0 @@ -. - */ - -require_once 'phing/Task.php'; - -/** - * Convert dot-notation packages to relative paths. - * - * @author Hans Lellelid - * @version $Revision: 1.5 $ - * @package phing.tasks.ext - */ -class PackageAsPathTask extends Task { - - /** The package to convert. */ - protected $pckg; - - /** The value to store the conversion in. */ - protected $name; - - /** - * Executes the package to patch converstion and stores it - * in the user property value. - */ - public function main() - { - $this->project->setUserProperty($this->name, strtr($this->pckg, '.', '/')); - } - - /** - * @param string $pckg the package to convert - */ - public function setPackage($pckg) - { - $this->pckg = $pckg; - } - - /** - * @param string $name the Ant variable to store the path in - */ - public function setName($name) - { - $this->name = $name; - } - -} diff --git a/buildscripts/phing/classes/phing/tasks/ext/PearPackageTask.php b/buildscripts/phing/classes/phing/tasks/ext/PearPackageTask.php deleted file mode 100644 index 4f8ee3ab..00000000 --- a/buildscripts/phing/classes/phing/tasks/ext/PearPackageTask.php +++ /dev/null @@ -1,421 +0,0 @@ -. - */ - -require_once 'phing/tasks/system/MatchingTask.php'; -include_once 'phing/types/FileSet.php'; - -/** - * A task to create PEAR package.xml file. - * - * This class uses the PEAR_PackageFileMaintainer class to perform the work. - * - * This class is designed to be very flexible -- i.e. account for changes to the package.xml w/o - * requiring changes to this class. We've accomplished this by having generic