| 116 | | } |
|---|
| 117 | | |
|---|
| 118 | | function _pear_run_upgrade_all($config, $install_dir) |
|---|
| 119 | | { |
|---|
| 120 | | $registry = new PEAR_Registry($install_dir); |
|---|
| 121 | | $remote = new PEAR_Remote($config); |
|---|
| 122 | | $cmd = &PEAR_Command::factory('upgrade', $config); |
|---|
| 123 | | |
|---|
| 124 | | $pkgs = $registry->listPackages(); |
|---|
| 125 | | foreach ($pkgs as $pkg) |
|---|
| 126 | | { |
|---|
| 127 | | $remoteInfo = $remote->call('package.info', $pkg); |
|---|
| 128 | | $versions = array_keys($remoteInfo['releases']); |
|---|
| 129 | | $last = $versions[0]; |
|---|
| 130 | | $info = $registry->packageInfo($pkg); |
|---|
| 131 | | $current = $info['version']; |
|---|
| 132 | | if ($current < $last) |
|---|
| 133 | | { |
|---|
| 134 | | $ok = $cmd->run("upgrade", array(), $pkgs); |
|---|
| 135 | | if (PEAR::isError($ok)) |
|---|
| 136 | | { |
|---|
| 137 | | throw new Exception($ok->getMessage()); |
|---|
| 138 | | } |
|---|
| 139 | | } |
|---|
| 140 | | } |
|---|
| | 217 | |
|---|
| | 218 | function _get_plugin_name($arg) |
|---|
| | 219 | { |
|---|
| | 220 | $plugin_name = (false !== $pos = strrpos($arg, '/')) ? substr($arg, $pos + 1) : $arg; |
|---|
| | 221 | $plugin_name = (false !== $pos = strrpos($plugin_name, '-')) ? substr($plugin_name, 0, $pos) : $plugin_name; |
|---|
| | 222 | |
|---|
| | 223 | return $plugin_name; |
|---|
| | 224 | } |
|---|
| | 225 | |
|---|
| | 226 | function _install_web_content($plugin_name) |
|---|
| | 227 | { |
|---|
| | 228 | $web_dir = sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$plugin_name.DIRECTORY_SEPARATOR.'web'; |
|---|
| | 229 | if (is_dir($web_dir)) |
|---|
| | 230 | { |
|---|
| | 231 | pake_echo_action('plugin', 'installing web data for plugin'); |
|---|
| | 232 | pake_symlink($web_dir, sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$plugin_name, true); |
|---|
| | 233 | } |
|---|
| | 234 | } |
|---|
| | 235 | |
|---|
| | 236 | function _uninstall_web_content($plugin_name) |
|---|
| | 237 | { |
|---|
| | 238 | $web_dir = sfConfig::get('sf_plugins_dir').DIRECTORY_SEPARATOR.$plugin_name.DIRECTORY_SEPARATOR.'web'; |
|---|
| | 239 | $target_dir = sfConfig::get('sf_web_dir').DIRECTORY_SEPARATOR.$plugin_name; |
|---|
| | 240 | if (is_dir($web_dir) && is_dir($target_dir)) |
|---|
| | 241 | { |
|---|
| | 242 | pake_echo_action('plugin', 'uninstalling web data for plugin'); |
|---|
| | 243 | if (is_link($target_dir)) |
|---|
| | 244 | { |
|---|
| | 245 | pake_remove($target_dir, ''); |
|---|
| | 246 | } |
|---|
| | 247 | else |
|---|
| | 248 | { |
|---|
| | 249 | pake_remove(pakeFinder::type('any'), $target_dir); |
|---|
| | 250 | pake_remove($target_dir, ''); |
|---|
| | 251 | } |
|---|
| | 252 | } |
|---|
| | 253 | } |
|---|