Exemple #1
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     $command = $arguments->getCommand();
     $status = null;
     //TODO: check modulename was given, print a message otherwise
     // maybe add an else die smth ?
     if ($opt = $arguments->getOpt('enable', false)) {
         if ($opt === "1") {
             $arguments->show_command_usage('modules');
             $interface->error();
         }
         $status = $this->enable_module($opt);
     } elseif ($opt = $arguments->getOpt('disable', false)) {
         if ($opt === "1") {
             $arguments->show_command_usage('modules');
             $interface->error();
         }
         $status = $this->disable_module($opt);
     } elseif ($opt = $arguments->getOpt('reset', false)) {
         if ($opt === "1") {
             $arguments->show_command_usage('modules');
             $interface->error();
         }
         $status = $this->reset_module($opt);
     } elseif ($opt = $arguments->getOpt('install', false)) {
         if ($opt === "1") {
             $arguments->show_command_usage('modules');
             $interface->error();
         }
         $status = $this->install_module($opt);
     } elseif ($opt = $arguments->getOpt('uninstall', false)) {
         if ($opt === "1") {
             $arguments->show_command_usage('modules');
             $interface->error();
         }
         $status = $this->uninstall_module($opt);
     } elseif ($opt = $arguments->getOpt('list', false)) {
         $status = $this->print_module_list();
     } elseif ($arguments->getOpt('show-status', false)) {
         $this->print_module_status();
         $status = true;
     } elseif ($arguments->getOpt('update', false)) {
         $key = $arguments->getOpt('key', NULL);
         $value = $arguments->getOpt('value', NULL);
         if (is_null($key)) {
             $interface->error('You must provide --key with --update');
         }
         if (is_null($value)) {
             $interface->error('You must provide --value with --update');
         }
         $this->_update_configuration($key, $value);
     } elseif ($opt = $arguments->getOpt('upgrade', false)) {
         $status = $this->upgrade_all_modules();
     } elseif ($opt = $arguments->getOpt('upgrade-db', false)) {
         $status = $this->upgrade_all_modules_database();
     } elseif ($moduleName = $arguments->getOpt('download', false)) {
         $status = $this->download_install_module($moduleName);
     } elseif ($opt = $arguments->getOpt('enable-overrides', false)) {
         $successMsg = 'modules overrides enabled';
         $errMsg = 'modules overrides could not be enabled';
         $notChanged = 'modules overrides were already enabled';
         $status = PS_CLI_Utils::update_global_value('PS_DISABLE_OVERRIDES', true, $successMsg, $errMsg, $notChanged);
     } elseif ($opt = $arguments->getOpt('disable-overrides', false)) {
         $successMsg = 'modules overrides disabled';
         $errMsg = 'modules overrides could not be disabled';
         $notChanged = 'modules overrides were already disabled';
         $status = PS_CLI_Utils::update_global_value('PS_DISABLE_OVERRIDES', false, $successMsg, $errMsg, $notChanged);
     } elseif ($opt = $arguments->getOpt('enable-non-native', false)) {
         $successMsg = 'non native modules enabled';
         $errMsg = 'non native modules could not be enabled';
         $notChanged = 'non native modules were already enabled';
         $status = PS_CLI_Utils::update_global_value('PS_DISABLE_NON_NATIVE_MODULE', false, $successMsg, $errMsg, $notChanged);
     } elseif ($opt = $arguments->getOpt('disable-non-native', false)) {
         $successMsg = 'non native modules disabled';
         $errMsg = 'non native modules could not be disabled';
         $notChanged = 'non native modules were already disabled';
         $status = PS_CLI_Utils::update_global_value('PS_DISABLE_NON_NATIVE_MODULE', true, $successMsg, $errMsg, $notChanged);
     } elseif ($opt = $arguments->getOpt('enable-check-update', false)) {
         $successMsg = 'modules auto updates check enabled';
         $errMsg = 'modules auto updates could not be enabled';
         $notChanged = 'modules auto updates checks were already enabled';
         $status = PS_CLI_Utils::update_global_value('PRESTASTORE_LIVE', true, $successMsg, $errMsg, $notChanged);
     } elseif ($opt = $arguments->getOpt('disable-check-update', false)) {
         $successMsg = 'modules auto updates check disabled';
         $errMsg = 'modules auto updates could not be disabled';
         $notChanged = 'modules auto updates checks were already disabled';
         $status = PS_CLI_Utils::update_global_value('PRESTASTORE_LIVE', false, $successMsg, $errMsg, $notChanged);
     } else {
         $arguments->show_command_usage($command);
         $interface->error();
     }
     $interface = PS_CLI_Interface::getInterface();
     if ($status === false) {
         $interface->set_ret_val(PS_CLI_Interface::RET_ERR);
     }
     $interface->success();
 }
Exemple #2
0
 public function run()
 {
     $arguments = PS_CLI_Arguments::getArgumentsInstance();
     $interface = PS_CLI_Interface::getInterface();
     if ($arguments->getOpt('show-status', false)) {
         $this->show_status();
         $interface->success();
     } elseif ($arguments->getOpt('enable-html-minifier', false)) {
         $successMsg = 'HTML code reduction successfully enabled';
         $errMsg = 'Could not enable HTML code reduction';
         $notChanged = 'HTML code reduction was already enabled';
         $status = PS_CLI_Utils::update_global_value('PS_HTML_THEME_COMPRESSION', true, $successMsg, $errMsg, $notChanged);
     } elseif ($arguments->getOpt('disable-html-minifier', false)) {
         $successMsg = 'HTML code reduction successfully disabled';
         $errMsg = 'Could not disable HTML code reduction';
         $notChanged = 'HTML code reduction was already disabled';
         $status = PS_CLI_Utils::update_global_value('PS_HTML_THEME_COMPRESSION', false, $successMsg, $errMsg, $notChanged);
     } elseif ($arguments->getOpt('enable-js-minifier', false)) {
         $successMsg = 'JavaScript code reduction successfully enabled';
         $errMsg = 'Could not enable JavaScript code reduction';
         $notChanged = 'JavaScript code reduction was already enabled';
         $status = PS_CLI_Utils::update_global_value('PS_JS_THEME_COMPRESSION', true, $successMsg, $errMsg, $notChanged);
     } elseif ($arguments->getOpt('disable-js-minifier', false)) {
         $successMsg = 'JavaScript code reduction successfully disabled';
         $errMsg = 'Could not disable JavaScript code reduction';
         $notChanged = 'JavaScript code reduction was already disabled';
         $status = PS_CLI_Utils::update_global_value('PS_JS_THEME_COMPRESSION', false, $successMsg, $errMsg, $notChanged);
     } elseif ($opt = $arguments->getOpt('disable-cache', false)) {
         $this->disable_cache();
     } elseif ($cache = $arguments->getOpt('enable-cache', false)) {
         if ($cache == "1") {
             $cache = 'default';
         }
         switch ($cache) {
             case 'fs':
                 $cacheType = 'CacheFS';
                 break;
             case 'memcache':
                 $cacheType = 'CacheMemcache';
                 break;
             case 'xcache':
                 $cacheType = 'CacheXcache';
                 break;
             case 'apc':
                 $cacheType = 'CacheApc';
                 break;
             case 'default':
                 $cacheType = 'default';
                 break;
             default:
                 $error = 'Cache type must be fs, memcache, xcache or apc';
                 $arguments->show_command_usage('cache', $error);
                 exit(1);
         }
         if ($depth = $arguments->getOpt('cache-depth', false)) {
             if ($depth <= 0) {
                 $error = 'cache-depth must be a positive integer';
                 exit(1);
             }
         } else {
             $depth = 1;
         }
         $status = $this->enable_cache($cache, $depth);
     } elseif ($opt = $arguments->getOpt('clear-cache', false)) {
         $status = $this->clear_smarty_cache();
     } else {
         $arguments->show_command_usage('ccc');
         $interface->error();
     }
     if ($status) {
         exit(0);
     } else {
         exit(1);
     }
 }