示例#1
0
文件: ExtShell.php 项目: dlpc/CakeWX
 /**
  * Call the appropriate command
  *
  * @return void
  */
 public function main()
 {
     $args = $this->args;
     $this->args = array_map('strtolower', $this->args);
     $method = $this->args[0];
     $type = $this->args[1];
     $ext = isset($args[2]) ? $args[2] : null;
     $force = isset($this->params['force']) ? $this->params['force'] : false;
     if ($type == 'theme') {
         $extensions = $this->_CroogoTheme->getThemes();
         $theme = Configure::read('Site.theme');
         $active = !empty($theme) ? $theme == 'default' : true;
     } elseif ($type == 'plugin') {
         $extensions = $this->_CroogoPlugin->getPlugins();
         if ($force) {
             $plugins = array_combine($p = App::objects('plugins'), $p);
             $extensions += $plugins;
         }
         $active = CakePlugin::loaded($ext);
     }
     if ($type == 'theme' && $method == 'deactivate') {
         $this->err(__d('croogo', 'Theme cannot be deactivated, instead activate another theme.'));
         return false;
     }
     if (!empty($ext) && !in_array($ext, $extensions) && !$active && !$force) {
         $this->err(__d('croogo', '%s "%s" not found.', ucfirst($type), $ext));
         return false;
     }
     switch ($method) {
         case 'list':
             $call = Inflector::pluralize($type);
             return $this->{$call}($ext);
         default:
             if (empty($ext)) {
                 $this->err(__d('croogo', '%s name must be provided.', ucfirst($type)));
                 return false;
             }
             return $this->{'_' . $method . ucfirst($type)}($ext);
     }
 }
示例#2
0
 /**
  * Call the appropriate command
  *
  * @return void
  */
 public function main()
 {
     $args = $this->args;
     $this->args = array_map('strtolower', $this->args);
     $activate = $this->args[0];
     $type = $this->args[1];
     $ext = isset($args[2]) ? $args[2] : null;
     if ($type == 'theme') {
         if ($activate == 'deactivate') {
             $this->_deactivateTheme();
             return true;
         }
         $extensions = $this->_CroogoTheme->getThemes();
     } elseif ($type == 'plugin') {
         $extensions = $this->_CroogoPlugin->getPlugins();
     }
     if (!in_array($ext, $extensions)) {
         $this->err(__('%s "%s" not found.', ucfirst($type), $ext));
         return false;
     }
     return $this->{'_' . $activate . ucfirst($type)}($ext);
 }