Esempio n. 1
0
File: iq.php Progetto: razzman/mi
 /**
  * choosePackage method
  *
  * @return void
  * @access protected
  */
 protected function _choosePackage($action = 'to install', $installed = false)
 {
     if ($installed) {
         $plugins = MiInstall::plugins();
         foreach ($plugins as $plugin) {
             $this->out($plugin);
         }
         $choice = $this->in('Type the name of what you want ' . $action);
         if (!$choice) {
             $this->out('no choice made');
             $this->_stop();
         }
         return $choice;
     }
     $page = 0;
     $options = MiInstall::details($this->params);
     $options = array_chunk($options, 5, true);
     $choice = false;
     while (!$choice && $page < count($options)) {
         $this->out('id                  Description');
         $this->hr();
         foreach ($options[$page] as $id => $description) {
             $id = str_pad($id, 20);
             $this->out($id . $description);
         }
         $choice = $this->in("Type the name of what you want {$action}, or enter for more options");
         $page++;
     }
     if (!$choice || !MiInstall::details($choice)) {
         $this->out('no choice made');
         $this->_stop();
     }
     return $choice;
 }
Esempio n. 2
0
 /**
  * upgradeGit method
  *
  * @param mixed $path
  * @param mixed $type null
  * @param mixed $name null
  * @return void
  * @access private
  */
 protected function _upgradeGit($path, $type = null, $name = null)
 {
     if (DS === '\\') {
         set_time_limit(60);
     }
     $stash = false;
     $out = array();
     MiInstall::_exec('cd ' . escapeshellarg($path) . ' && git status', $out);
     if (preg_match('@# (Changed but not updated|Changes to be committed):@', implode($out))) {
         MiInstall::_exec('cd ' . escapeshellarg($path) . ' && git stash save "automatic stash"');
         $stash = true;
     }
     if (isset(MiInstall::$settings[$type][$name]['upgrade'])) {
         $cmd = MiInstall::$settings[$type][$name]['upgrade'];
     } else {
         $cmd = MiInstall::$settings[$type]['upgrade'];
     }
     $out = array();
     MiInstall::_exec('cd ' . escapeshellarg($path) . ' && git branch', $out);
     if ($cmd === 'git pull' && strpos(implode($out), '* (no branch)') !== false) {
         $cmd = 'git checkout master && git pull origin master';
     }
     $result = 'unknown';
     if (MiInstall::_exec('cd ' . escapeshellarg($path) . ' && ' . $cmd, $out)) {
         $result = 'success';
         MiInstall::_initGitRemote($path);
         MiInstall::_exec('cd ' . escapeshellarg($path) . ' && ' . $cmd, $out);
     } else {
         $result = 'fail';
     }
     if ($stash) {
         MiInstall::_exec('cd ' . escapeshellarg($path) . ' && git stash pop');
     }
     if ($type === 'git') {
         if ($result === 'fail' && !$out) {
             $return = array(0, array('Assumed (no return message from issuing git pull)'));
         }
     }
     $return['cmd'] = $cmd;
     return MiInstall::$_return[$path] = $return;
 }