PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/php/PEAR/Task/Windowseol.php

https://bitbucket.org/adarshj/convenient_website
PHP | 77 lines | 24 code | 3 blank | 50 comment | 2 complexity | c321484c304ebb4de50cd204b6a61c6d MD5 | raw file
Possible License(s): Apache-2.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-2-Clause, GPL-2.0, LGPL-3.0
  1. <?php
  2. /**
  3. * <tasks:windowseol>
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * @category pear
  8. * @package PEAR
  9. * @author Greg Beaver <cellog@php.net>
  10. * @copyright 1997-2009 The Authors
  11. * @license http://opensource.org/licenses/bsd-license.php New BSD License
  12. * @version CVS: $Id: Windowseol.php 313023 2011-07-06 19:17:11Z dufuz $
  13. * @link http://pear.php.net/package/PEAR
  14. * @since File available since Release 1.4.0a1
  15. */
  16. /**
  17. * Base class
  18. */
  19. require_once 'PEAR/Task/Common.php';
  20. /**
  21. * Implements the windows line endsings file task.
  22. * @category pear
  23. * @package PEAR
  24. * @author Greg Beaver <cellog@php.net>
  25. * @copyright 1997-2009 The Authors
  26. * @license http://opensource.org/licenses/bsd-license.php New BSD License
  27. * @version Release: 1.9.4
  28. * @link http://pear.php.net/package/PEAR
  29. * @since Class available since Release 1.4.0a1
  30. */
  31. class PEAR_Task_Windowseol extends PEAR_Task_Common
  32. {
  33. var $type = 'simple';
  34. var $phase = PEAR_TASK_PACKAGE;
  35. var $_replacements;
  36. /**
  37. * Validate the raw xml at parsing-time.
  38. * @param PEAR_PackageFile_v2
  39. * @param array raw, parsed xml
  40. * @param PEAR_Config
  41. * @static
  42. */
  43. function validateXml($pkg, $xml, $config, $fileXml)
  44. {
  45. if ($xml != '') {
  46. return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
  47. }
  48. return true;
  49. }
  50. /**
  51. * Initialize a task instance with the parameters
  52. * @param array raw, parsed xml
  53. * @param unused
  54. */
  55. function init($xml, $attribs)
  56. {
  57. }
  58. /**
  59. * Replace all line endings with windows line endings
  60. *
  61. * See validateXml() source for the complete list of allowed fields
  62. * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
  63. * @param string file contents
  64. * @param string the eventual final file location (informational only)
  65. * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
  66. * (use $this->throwError), otherwise return the new contents
  67. */
  68. function startSession($pkg, $contents, $dest)
  69. {
  70. $this->logger->log(3, "replacing all line endings with \\r\\n in $dest");
  71. return preg_replace("/\r\n|\n\r|\r|\n/", "\r\n", $contents);
  72. }
  73. }
  74. ?>