Редакция 69 | Только различия | Учитывать пробелы | Содержимое файла | Авторство | Последнее изменение | Открыть журнал | RSS
Редакция 69 | Редакция 87 | ||
---|---|---|---|
1 | <?php
|
1 | <?php
|
2 | /**
|
2 | /**
|
3 | * <tasks:unixeol>
|
3 | * <tasks:unixeol>
|
4 | *
|
4 | *
|
5 | * PHP versions 4 and 5
|
5 | * PHP versions 4 and 5
|
6 | *
|
6 | *
|
7 | * LICENSE: This source file is subject to version 3.0 of the PHP license
|
7 | * LICENSE: This source file is subject to version 3.0 of the PHP license
|
8 | * that is available through the world-wide-web at the following URI:
|
8 | * that is available through the world-wide-web at the following URI:
|
9 | * http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
9 | * http://www.php.net/license/3_0.txt. If you did not receive a copy of
|
10 | * the PHP License and are unable to obtain it through the web, please
|
10 | * the PHP License and are unable to obtain it through the web, please
|
11 | * send a note to license@php.net so we can mail you a copy immediately.
|
11 | * send a note to license@php.net so we can mail you a copy immediately.
|
12 | *
|
12 | *
|
13 | * @category pear
|
13 | * @category pear
|
14 | * @package PEAR
|
14 | * @package PEAR
|
15 | * @author Greg Beaver <cellog@php.net>
|
15 | * @author Greg Beaver <cellog@php.net>
|
16 | * @copyright 1997-2008 The PHP Group
|
16 | * @copyright 1997-2008 The PHP Group
|
17 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
17 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
18 | * @version CVS: $Id: Unixeol.php,v 1.10 2008/05/13 21:28:20 cellog Exp $
|
18 | * @version CVS: $Id: Unixeol.php,v 1.10 2008/05/13 21:28:20 cellog Exp $
|
19 | * @link http://pear.php.net/package/PEAR
|
19 | * @link http://pear.php.net/package/PEAR
|
20 | * @since File available since Release 1.4.0a1
|
20 | * @since File available since Release 1.4.0a1
|
21 | */
|
21 | */
|
22 | /**
|
22 | /**
|
23 | * Base class
|
23 | * Base class
|
24 | */
|
24 | */
|
25 | require_once 'PEAR/Task/Common.php'; |
25 | require_once 'PEAR/Task/Common.php'; |
26 | /**
|
26 | /**
|
27 | * Implements the unix line endings file task.
|
27 | * Implements the unix line endings file task.
|
28 | * @category pear
|
28 | * @category pear
|
29 | * @package PEAR
|
29 | * @package PEAR
|
30 | * @author Greg Beaver <cellog@php.net>
|
30 | * @author Greg Beaver <cellog@php.net>
|
31 | * @copyright 1997-2008 The PHP Group
|
31 | * @copyright 1997-2008 The PHP Group
|
32 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
32 | * @license http://www.php.net/license/3_0.txt PHP License 3.0
|
33 | * @version Release: 1.7.2
|
33 | * @version Release: 1.7.2
|
34 | * @link http://pear.php.net/package/PEAR
|
34 | * @link http://pear.php.net/package/PEAR
|
35 | * @since Class available since Release 1.4.0a1
|
35 | * @since Class available since Release 1.4.0a1
|
36 | */
|
36 | */
|
37 | class PEAR_Task_Unixeol extends PEAR_Task_Common |
37 | class PEAR_Task_Unixeol extends PEAR_Task_Common |
38 | {
|
38 | {
|
39 | var $type = 'simple'; |
39 | var $type = 'simple'; |
40 | var $phase = PEAR_TASK_PACKAGE; |
40 | var $phase = PEAR_TASK_PACKAGE; |
41 | var $_replacements; |
41 | var $_replacements; |
42 | 42 | ||
43 | /**
|
43 | /**
|
44 | * Validate the raw xml at parsing-time.
|
44 | * Validate the raw xml at parsing-time.
|
45 | * @param PEAR_PackageFile_v2
|
45 | * @param PEAR_PackageFile_v2
|
46 | * @param array raw, parsed xml
|
46 | * @param array raw, parsed xml
|
47 | * @param PEAR_Config
|
47 | * @param PEAR_Config
|
48 | * @static
|
48 | * @static
|
49 | */
|
49 | */
|
50 | function validateXml($pkg, $xml, $config, $fileXml) |
50 | function validateXml($pkg, $xml, $config, $fileXml) |
51 | {
|
51 | {
|
52 | if ($xml != '') { |
52 | if ($xml != '') { |
53 | return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed'); |
53 | return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed'); |
54 | }
|
54 | }
|
55 | return true; |
55 | return true; |
56 | }
|
56 | }
|
57 | 57 | ||
58 | /**
|
58 | /**
|
59 | * Initialize a task instance with the parameters
|
59 | * Initialize a task instance with the parameters
|
60 | * @param array raw, parsed xml
|
60 | * @param array raw, parsed xml
|
61 | * @param unused
|
61 | * @param unused
|
62 | */
|
62 | */
|
63 | function init($xml, $attribs) |
63 | function init($xml, $attribs) |
64 | {
|
64 | {
|
65 | }
|
65 | }
|
66 | 66 | ||
67 | /**
|
67 | /**
|
68 | * Replace all line endings with line endings customized for the current OS
|
68 | * Replace all line endings with line endings customized for the current OS
|
69 | *
|
69 | *
|
70 | * See validateXml() source for the complete list of allowed fields
|
70 | * See validateXml() source for the complete list of allowed fields
|
71 | * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
|
71 | * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
|
72 | * @param string file contents
|
72 | * @param string file contents
|
73 | * @param string the eventual final file location (informational only)
|
73 | * @param string the eventual final file location (informational only)
|
74 | * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
|
74 | * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
|
75 | * (use $this->throwError), otherwise return the new contents
|
75 | * (use $this->throwError), otherwise return the new contents
|
76 | */
|
76 | */
|
77 | function startSession($pkg, $contents, $dest) |
77 | function startSession($pkg, $contents, $dest) |
78 | {
|
78 | {
|
79 | $this->logger->log(3, "replacing all line endings with \\n in $dest"); |
79 | $this->logger->log(3, "replacing all line endings with \\n in $dest"); |
80 | return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents); |
80 | return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents); |
81 | }
|
81 | }
|
82 | }
|
82 | }
|
83 | ?>
|
83 | ?>
|