Subversion Repositories Applications.gtt

Rev

Rev 94 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 94 Rev 187
Line 2... Line 2...
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
-
 
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
7
 * @category  pear
14
 * @package    PEAR
8
 * @package   PEAR
15
 * @author     Greg Beaver <cellog@php.net>
9
 * @author    Greg Beaver <cellog@php.net>
16
 * @copyright  1997-2006 The PHP Group
10
 * @copyright 1997-2009 The Authors
17
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
11
 * @license   http://opensource.org/licenses/bsd-license.php New BSD License
18
 * @version    CVS: $Id: Unixeol.php,v 1.8 2006/01/06 04:47:37 cellog Exp $
-
 
19
 * @link       http://pear.php.net/package/PEAR
12
 * @link      http://pear.php.net/package/PEAR
20
 * @since      File available since Release 1.4.0a1
13
 * @since     File available since Release 1.4.0a1
21
 */
14
 */
22
/**
15
/**
23
 * Base class
16
 * Base class
24
 */
17
 */
25
require_once 'PEAR/Task/Common.php';
18
require_once 'PEAR/Task/Common.php';
26
/**
19
/**
27
 * Implements the unix line endings file task.
20
 * Implements the unix line endings file task.
28
 * @category   pear
21
 * @category   pear
29
 * @package    PEAR
22
 * @package    PEAR
30
 * @author     Greg Beaver <cellog@php.net>
23
 * @author     Greg Beaver <cellog@php.net>
31
 * @copyright  1997-2006 The PHP Group
24
 * @copyright  1997-2009 The Authors
32
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
25
 * @license    http://opensource.org/licenses/bsd-license.php New BSD License
33
 * @version    Release: 1.5.1
26
 * @version    Release: 1.10.1
34
 * @link       http://pear.php.net/package/PEAR
27
 * @link       http://pear.php.net/package/PEAR
35
 * @since      Class available since Release 1.4.0a1
28
 * @since      Class available since Release 1.4.0a1
36
 */
29
 */
37
class PEAR_Task_Unixeol extends PEAR_Task_Common
30
class PEAR_Task_Unixeol extends PEAR_Task_Common
38
{
31
{
39
    var $type = 'simple';
32
    public $type = 'simple';
40
    var $phase = PEAR_TASK_PACKAGE;
33
    public $phase = PEAR_TASK_PACKAGE;
41
    var $_replacements;
34
    public $_replacements;
Line 42... Line 35...
42
 
35
 
43
    /**
36
    /**
-
 
37
     * Validate the raw xml at parsing-time.
44
     * Validate the raw xml at parsing-time.
38
     *
45
     * @param PEAR_PackageFile_v2
39
     * @param  PEAR_PackageFile_v2
46
     * @param array raw, parsed xml
40
     * @param  array raw, parsed xml
47
     * @param PEAR_Config
-
 
48
     * @static
41
     * @param  PEAR_Config
49
     */
42
     */
50
    function validateXml($pkg, $xml, &$config, $fileXml)
43
    public static function validateXml($pkg, $xml, $config, $fileXml)
51
    {
44
    {
52
        if ($xml != '') {
45
        if ($xml != '') {
53
            return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
46
            return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed');
-
 
47
        }
54
        }
48
 
55
        return true;
49
        return true;
Line 56... Line 50...
56
    }
50
    }
57
 
51
 
58
    /**
52
    /**
59
     * Initialize a task instance with the parameters
53
     * Initialize a task instance with the parameters
-
 
54
     * @param array raw, parsed xml
60
     * @param array raw, parsed xml
55
     * @param unused
61
     * @param unused
56
     * @param unused
62
     */
57
     */
63
    function init($xml, $attribs)
58
    public function init($xml, $attribs, $lastVersion = null)
Line 64... Line 59...
64
    {
59
    {
65
    }
60
    }
66
 
61
 
67
    /**
62
    /**
-
 
63
     * 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
64
     *
69
     *
65
     * See validateXml() source for the complete list of allowed fields
70
     * See validateXml() source for the complete list of allowed fields
66
     *
71
     * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2
67
     * @param  PEAR_PackageFile_v1|PEAR_PackageFile_v2
72
     * @param string file contents
68
     * @param  string file contents
73
     * @param string the eventual final file location (informational only)
69
     * @param  string the eventual final file location (informational only)
74
     * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
70
     * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail
75
     *         (use $this->throwError), otherwise return the new contents
71
     *                                 (use $this->throwError), otherwise return the new contents
76
     */
72
     */
-
 
73
    public function startSession($pkg, $contents, $dest)
77
    function startSession($pkg, $contents, $dest)
74
    {
78
    {
75
        $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");
76
 
80
        return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents);
-
 
81
    }
77
        return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents);