Редакция 69 | Содержимое файла | Сравнить с предыдущей | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
69 | alex-w | 1 | <?php |
2 | /** |
||
3 | * <tasks:unixeol> |
||
4 | * |
||
5 | * PHP versions 4 and 5 |
||
6 | * |
||
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: |
||
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 |
||
11 | * send a note to license@php.net so we can mail you a copy immediately. |
||
12 | * |
||
13 | * @category pear |
||
14 | * @package PEAR |
||
15 | * @author Greg Beaver <cellog@php.net> |
||
16 | * @copyright 1997-2008 The PHP Group |
||
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 $ |
||
19 | * @link http://pear.php.net/package/PEAR |
||
20 | * @since File available since Release 1.4.0a1 |
||
21 | */ |
||
22 | /** |
||
23 | * Base class |
||
24 | */ |
||
25 | require_once 'PEAR/Task/Common.php'; |
||
26 | /** |
||
27 | * Implements the unix line endings file task. |
||
28 | * @category pear |
||
29 | * @package PEAR |
||
30 | * @author Greg Beaver <cellog@php.net> |
||
31 | * @copyright 1997-2008 The PHP Group |
||
32 | * @license http://www.php.net/license/3_0.txt PHP License 3.0 |
||
33 | * @version Release: 1.7.2 |
||
34 | * @link http://pear.php.net/package/PEAR |
||
35 | * @since Class available since Release 1.4.0a1 |
||
36 | */ |
||
37 | class PEAR_Task_Unixeol extends PEAR_Task_Common |
||
38 | { |
||
39 | var $type = 'simple'; |
||
40 | var $phase = PEAR_TASK_PACKAGE; |
||
41 | var $_replacements; |
||
42 | |||
43 | /** |
||
44 | * Validate the raw xml at parsing-time. |
||
45 | * @param PEAR_PackageFile_v2 |
||
46 | * @param array raw, parsed xml |
||
47 | * @param PEAR_Config |
||
48 | * @static |
||
49 | */ |
||
50 | function validateXml($pkg, $xml, $config, $fileXml) |
||
51 | { |
||
52 | if ($xml != '') { |
||
53 | return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed'); |
||
54 | } |
||
55 | return true; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Initialize a task instance with the parameters |
||
60 | * @param array raw, parsed xml |
||
61 | * @param unused |
||
62 | */ |
||
63 | function init($xml, $attribs) |
||
64 | { |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Replace all line endings with line endings customized for the current OS |
||
69 | * |
||
70 | * See validateXml() source for the complete list of allowed fields |
||
71 | * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 |
||
72 | * @param string file contents |
||
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 |
||
75 | * (use $this->throwError), otherwise return the new contents |
||
76 | */ |
||
77 | function startSession($pkg, $contents, $dest) |
||
78 | { |
||
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); |
||
81 | } |
||
82 | } |
||
83 | ?> |