1 : <?php
2 : /**
3 : * This is the default CLI driver for PEAR_PackageUpdate.
4 : *
5 : * PHP versions 4 and 5
6 : *
7 : * LICENSE: This source file is subject to version 3.01 of the PHP license
8 : * that is available through the world-wide-web at the following URI:
9 : * http://www.php.net/license/3_01.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_PackageUpdate
15 : * @author Laurent Laville <pear@laurent-laville.org>
16 : * @license http://www.php.net/license/3_01.txt PHP License 3.01
17 : * @version CVS: $Id: Cli.php,v 1.4 2007/11/25 16:23:47 farell Exp $
18 : * @link http://pear.php.net/package/PEAR_PackageUpdate
19 : * @since File available since Release 0.6.0
20 : */
21 :
22 :
23 : /**
24 : * This is the default CLI driver for PEAR_PackageUpdate.
25 : *
26 : * A package to make adding self updating functionality to other
27 : * packages easy.
28 : *
29 : * EXAMPLE:
30 : * <code>
31 : * <?php
32 : * require_once 'PEAR/PackageUpdate.php';
33 : * // check for updates of PEAR::Config package
34 : * $ppu =& PEAR_PackageUpdate::factory('Cli', 'Config', 'pear');
35 : * if ($ppu !== false) {
36 : * // Check for new stable and minor changes version
37 : * $ppu->setMinimumState(PEAR_PACKAGEUPDATE_STATE_STABLE);
38 : * $ppu->setMinimumReleaseType(PEAR_PACKAGEUPDATE_TYPE_MINOR);
39 : * if ($ppu->checkUpdate()) {
40 : * // Update your local copy
41 : * if ($ppu->update()) {
42 : * include_once 'Config.php';
43 : * }
44 : * }
45 : * }
46 : * ?>
47 : * </code>
48 : *
49 : * @category PEAR
50 : * @package PEAR_PackageUpdate
51 : * @author Laurent Laville <pear@laurent-laville.org>
52 : * @license http://www.php.net/license/3_01.txt PHP License 3.01
53 : * @version Release: 1.1.0a1
54 : * @link http://pear.php.net/package/PEAR_PackageUpdate
55 : * @since Class available since Release 0.6.0
56 : */
57 :
58 3 : class PEAR_PackageUpdate_Cli extends PEAR_PackageUpdate
59 : {
60 : /**
61 : * Cli driver class constructor
62 : *
63 : * @param string $packageName The package to update.
64 : * @param string $channel The channel the package resides on.
65 : * @param string $user_file (optional) file to read PEAR user-defined
66 : * options from
67 : * @param string $system_file (optional) file to read PEAR system-wide
68 : * defaults from
69 : * @param string $pref_file (optional) file to read PPU user-defined
70 : * options from
71 : *
72 : * @access public
73 : * @return void
74 : * @since 0.6.0
75 : */
76 : function PEAR_PackageUpdate_Cli($packageName, $channel,
77 : $user_file = '', $system_file = '', $pref_file = '')
78 : {
79 23 : parent::PEAR_PackageUpdate($packageName, $channel,
80 23 : $user_file, $system_file, $pref_file);
81 23 : }
82 :
83 : /**
84 : * Cli driver does not redirects or exits
85 : * to force the user to restart the application.
86 : *
87 : * @access public
88 : * @return void
89 : * @since 0.6.0
90 : */
91 : function forceRestart()
92 : {
93 1 : }
94 :
95 : /**
96 : * Cli driver does not present any frontend when an update is needed
97 : *
98 : * @access public
99 : * @return boolean Always true
100 : * @since 0.6.0
101 : */
102 : function presentUpdate()
103 : {
104 : // always update the package to latest version depending of options
105 : // see setMinimumState(), setMinimumReleaseType()
106 1 : return true;
107 : }
108 : }
|