public static function core_show_version() { $version = _PS_VERSION_; $configuration = PS_CLI_Configure::getConfigurationInstance(); if ($configuration->porcelain) { echo "{$version}\n"; } else { echo "PrestaShop version is {$version}\n"; } }
public static function upgrade_all_modules() { $configuration = PS_CLI_Configure::getConfigurationInstance(); $interface = PS_CLI_Interface::getInterface(); //types: // addonsMustHave // addonsNative // addonsBought ? // todo support for loggedOnAddons $loggedOnAddons = false; // Reload caches file_put_contents(_PS_ROOT_DIR_ . Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST, Tools::addonsRequest('native')); file_put_contents(_PS_ROOT_DIR_ . Module::CACHE_FILE_MUST_HAVE_MODULES_LIST, Tools::addonsRequest('must-have')); if ($loggedOnAddons) { file_put_contents(_PS_ROOT_DIR_ . Module::CACHE_FILE_CUSTOMER_MODULES_LIST, Tools::addonsRequest('customer')); } $xmlModuleLists = array(); $raw = Tools::file_get_contents(_PS_ROOT_DIR_ . Module::CACHE_FILE_DEFAULT_COUNTRY_MODULES_LIST); $xmlModuleLists[] = @simplexml_load_string($raw, null, LIBXML_NOCDATA); $raw = Tools::file_get_contents(_PS_ROOT_DIR_ . Module::CACHE_FILE_MUST_HAVE_MODULES_LIST); $xmlModuleLists[] = @simplexml_load_string($raw, null, LIBXML_NOCDATA); $moduleStore = array(); foreach ($xmlModuleLists as $xmlModuleList) { foreach ($xmlModuleList->module as $km) { $moduleStore[] = $km; } } $modulesOnDisk = Module::getModulesOnDisk(true); $upgradeErrors = array(); foreach ($modulesOnDisk as $module) { foreach ($moduleStore as $km) { if ($km->name != $module->name) { continue; } if (version_compare($module->version, $km->version, '<') == 0) { if ($configuration->debug) { $interface->display_line("{$module->name}: {$module->version} is equal to {$km->version}\n"); } continue; } $interface->display_line("Downloading {$module->name} archive\n"); $moduleArchive = self::_download_module_archive($km); if (!$moduleArchive) { $interface->display_line("Could not download {$module->name} update\n"); $upgradeErrors[] = "{$module->name} could not be downloaded\n"; continue; } $interface->display_line("Extracting {$module->name} archive\n"); if (!Tools::ZipExtract($moduleArchive, _PS_MODULE_DIR_)) { $interface->display_line("Could not extract {$module->name} archive\n"); $upgradeErrors[] = "{$module->name} could not be extracted\n"; continue; } // clean unlink($moduleArchive); } } $interface->display_line("Upgrading database"); self::upgrade_all_modules_database(); if (!empty($upgradeErrors)) { $interface->error('Some modules could not be upgraded'); } $interface->success('Done'); }
public static function add_configuration_value(Cli\Table &$table, $key, $friendlyName, $since = NULL) { $configuration = PS_CLI_Configure::getConfigurationInstance(); //if since is given and we know we're bellow, skip the value if ($since !== NULL) { if (version_compare($since, $configuration->psVersion, '>')) { return; } } $line = array($key, $friendlyName); $value = Configuration::get($key); array_push($line, $value); $table->addRow($line); }
public static function clear_smarty_cache() { $configuration = PS_CLI_Configure::getConfigurationInstance(); echo "Clearing cache...\n"; if ($configuration->verbose) { echo "Smarty cache "; } Tools::clearSmartyCache(); if ($configuration->verbose) { echo "[OK]\nXML cache "; } Tools::clearXMLCache(); if ($configuration->verbose) { echo "[OK]\nClearing media cache "; } Media::clearCache(); if ($configuration->verbose) { echo "[OK]\nRegenerating index "; } Tools::generateIndex(); if ($configuration->verbose) { echo "[OK]\n"; } echo "Done !\n"; return true; }
require_once PS_CLI_ROOT . '/PS_CLI/ps-cli_arguments.php'; require_once PS_CLI_ROOT . '/PS_CLI/ps-cli_configure.php'; require_once PS_CLI_ROOT . '/PS_CLI/ps-cli_interface.php'; require_once PS_CLI_ROOT . '/PS_CLI/ps-cli_plugins.php'; require_once PS_CLI_ROOT . '/PS_CLI/ps-cli_command.php'; require_once PS_CLI_ROOT . '/PS_CLI/ps-cli_hooks.php'; /* * Load 3d party librairies */ //php-cli-tools require_once PS_CLI_ROOT . '/lib/php-cli-tools/load-php-cli-tools.php'; //garden-cli argument parser require_once PS_CLI_ROOT . '/lib/garden-cli/Args.php'; require_once PS_CLI_ROOT . '/lib/garden-cli/Cli.php'; require_once PS_CLI_ROOT . '/lib/garden-cli/Table.php'; $conf = PS_CLI_Configure::getConfigurationInstance(); $conf->preload_configure(); $arguments = PS_CLI_Arguments::getArgumentsInstance(); $arguments->parse_arguments(); // run before_load_ps_core hooks PS_CLI_Hooks::callHooks('before_load_ps_core'); //load ps core if ($conf->loadPsCore) { PS_CLI_UTILS::ps_cli_load_ps_core(); } else { echo "[DEBUG]: PS core not loaded\n"; } $conf->postload_configure(); $interface = PS_CLI_INTERFACE::getInterface(); // todo: create a runner and export this code in it; we'll need to create an interface instance before //find what to run
protected function _upgradeCore() { $configuration = PS_CLI_Configure::getConfigurationInstance(); $upgrader = new Upgrader(); if (!is_object($upgrader)) { PS_CLI_Interface::error('Could not load autoupgrade module !'); } $upgrader->checkPSVersion(true, array('minor')); //$updates = $upgrader->checkPSVersion(true); $downloadPath = $configuration->boPath . DIRECTORY_SEPARATOR . 'autoupgrade' . DIRECTORY_SEPARATOR . 'download'; if ($configuration->debug) { PS_CLI_Interface::display_line("Downloading latest version to {$downloadPath}"); } if (!$upgrader->downloadLast($downloadPath)) { PS_CLI_Interface::error("Could not download latest version to {$downloadPath}"); } print_r($upgrader); die; }