Development

Changeset 2007

You must first sign up to be able to contribute.

Changeset 2007

Show
Ignore:
Timestamp:
09/08/06 11:44:12 (2 years ago)
Author:
fabien
Message:

added web content copy/link for plugins + removed plugin-upgrade-all

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/data/tasks/sfPakePlugins.php

    r1935 r2007  
    99pake_desc('uninstall a plugin'); 
    1010pake_task('plugin-uninstall', 'project_exists'); 
    11  
    12 pake_desc('upgrade all plugins'); 
    13 pake_task('plugin-upgrade-all', 'project_exists'); 
    1411 
    1512// symfony plugin-install pluginName 
     
    3229    throw new Exception($error); 
    3330  } 
     31 
     32  _install_web_content(_get_plugin_name($args[0])); 
    3433} 
    3534 
     
    5251    throw new Exception($error); 
    5352  } 
     53 
     54  $plugin_name = _get_plugin_name($args[0]); 
     55  _uninstall_web_content($plugin_name); 
     56  _install_web_content($plugin_name); 
    5457} 
    5558 
     
    6063    throw new Exception('You must provide the plugin name.'); 
    6164  } 
     65 
     66  _uninstall_web_content(_get_plugin_name($args[0])); 
    6267 
    6368  $config = _pear_init(); 
     
    7479} 
    7580 
    76 function run_plugin_upgrade_all($task, $args) 
    77 { 
    78   $config = _pear_init(); 
    79  
    80   // upgrade all plugins 
    81   pake_echo_action('plugin', 'upgrading all plugins'); 
    82   _pear_run_upgrade_all($config, sfConfig::get('sf_lib_dir').DIRECTORY_SEPARATOR.'plugins'); 
    83 } 
    84  
    8581function _pear_run_command($config, $command, $opts, $params) 
    8682{ 
     
    114110 
    115111  return $t; 
    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   } 
    141112} 
    142113 
     
    244215  return $config; 
    245216} 
     217 
     218function _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 
     226function _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 
     236function _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}