예제 #1
0
파일: iq.php 프로젝트: 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;
 }
예제 #2
0
 /**
  * loop method
  *
  * @param mixed $function
  * @param mixed $what
  * @param mixed $id
  * @return void
  * @access protected
  */
 function _loop($function, $what, $id = null)
 {
     if ($function === '_upgrade') {
         $options = array('app', 'cake', 'plugin', 'vendor');
     } else {
         $options = array('cake', 'plugin', 'vendor');
     }
     $what = Inflector::singularize(Inflector::underscore($what));
     if ($what === '*') {
         $what = $options;
     } elseif (!in_array($what, $options)) {
         return false;
     }
     MiInstall::_settings();
     $return = array();
     $plugins = $vendors = array();
     foreach ((array) $what as $dir) {
         if ($dir === 'app') {
             $return['app'] = MiInstall::$function(APP, 'app');
             continue;
         }
         if ($dir === 'cake') {
             $dir = CAKE_CORE_INCLUDE_PATH . DS . 'cake';
             $return['cake'] = MiInstall::$function($dir, 'cake');
             continue;
         }
         if ($dir === 'plugin') {
             $plugins = MiInstall::plugins();
             foreach ($plugins as $dir => $name) {
                 if ($name[0] === '.' || $id && $name && $name !== $id) {
                     continue;
                 }
                 $return["{$name} (plugin)"] = MiInstall::$function($dir, 'plugin');
             }
             continue;
         }
         if ($dir === 'vendor') {
             $vendorDirs = App::path('vendors');
             foreach ($vendorDirs as $dir) {
                 $Folder = new Folder($dir);
                 $vendors = $Folder->read();
                 if (!empty($vendors)) {
                     $vendors = $vendors[0];
                 }
                 foreach ($vendors as $name) {
                     if ($name[0] === '.' || $id && $name && $name !== $id) {
                         continue;
                     }
                     $return["{$name} (vendor)"] = MiInstall::$function($dir . DS . $name, 'vendor');
                 }
             }
         }
     }
     return $return;
 }