source: branches/version-2_13-dev/data/module/PEAR/Task/Unixeol.php @ 23125

Revision 23125, 2.2 KB checked in by kimoto, 11 years ago (diff)

#2275 PEAR更新
不要なrequire_onceの削除
レガシーなPEARモジュールは使わない
SearchReplace?.phpのパスが間違っているので修正

Line 
1<?php
2/**
3 * <tasks:unixeol>
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: Unixeol.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 */
19require_once 'PEAR/Task/Common.php';
20/**
21 * Implements the unix line endings 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 */
31class PEAR_Task_Unixeol extends PEAR_Task_Common
32{
33    var $type = 'simple';
34    var $phase = PEAR_TASK_PACKAGE;
35    var $_replacements;
36
37    /**
38     * Validate the raw xml at parsing-time.
39     * @param PEAR_PackageFile_v2
40     * @param array raw, parsed xml
41     * @param PEAR_Config
42     * @static
43     */
44    function validateXml($pkg, $xml, $config, $fileXml)
45    {
46        if ($xml != '') {
47            return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
48        }
49        return true;
50    }
51
52    /**
53     * Initialize a task instance with the parameters
54     * @param array raw, parsed xml
55     * @param unused
56     */
57    function init($xml, $attribs)
58    {
59    }
60
61    /**
62     * Replace all line endings with line endings customized for the current OS
63     *
64     * See validateXml() source for the complete list of allowed fields
65     * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
66     * @param string file contents
67     * @param string the eventual final file location (informational only)
68     * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
69     *         (use $this->throwError), otherwise return the new contents
70     */
71    function startSession($pkg, $contents, $dest)
72    {
73        $this->logger->log(3, "replacing all line endings with \\n in $dest");
74        return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents);
75    }
76}
77?>
Note: See TracBrowser for help on using the repository browser.