예제 #1
0
 /**
  * Languages validator
  *
  * @param  array $languages
  * @return bool  true if selected language is valid
  */
 public function isLanguagesValid($languages)
 {
     $app = App::instance();
     if (is_array($languages)) {
         $available_langs = Setup::getLanguages();
         $isLangExists = false;
         foreach ($languages as $lang_code) {
             if (empty($available_langs[$lang_code])) {
                 $app->setNotification('N', $app->t('notice'), $app->t('language_will_be_ignored', array('lang_code' => $app->t($lang_code))), true, 'administration_settings');
             } else {
                 $isLangExists = true;
             }
         }
         if (!$isLangExists) {
             $app->setNotification('E', $app->t('error'), $app->t('empty_languages'), true, 'administration_settings');
         }
         return $isLangExists;
     } else {
         $app->setNotification('E', $app->t('error'), $app->t('empty_languages'), true, 'administration_settings');
         return false;
     }
 }
예제 #2
0
 /**
  * Setup console action
  *
  * @param  array $cart_settings     Cart settings
  * @param  array $database_settings Database settings
  * @param  array $server_settings   Server settings
  * @param  array $addons            List of addons to be installed
  * @return bool  Result of setup
  */
 public function actionConsole($cart_settings, $database_settings, $server_settings, $addons = array())
 {
     $app = App::instance();
     $setup_result = 1;
     // return code for cli
     $validator = new Validator();
     if ($validator->validateAll(array_merge($cart_settings, $server_settings, $database_settings, $addons))) {
         if ($app->connectToDB($database_settings['host'], $database_settings['name'], $database_settings['user'], $database_settings['password'], $database_settings['table_prefix'], $database_settings['database_backend'])) {
             define('CART_LANGUAGE', $cart_settings['main_language']);
             define('DESCR_SL', $cart_settings['main_language']);
             define('CART_SECONDARY_CURRENCY', 'NULL');
             // Need for cache_level
             set_time_limit(0);
             $sCart = new Setup($cart_settings, $server_settings, $database_settings, $this->isDemoInstall($cart_settings));
             $sAddons = new AddonsSetup();
             $sCart->setupScheme();
             $sCart->setupData();
             $sCart->setSimpleMode();
             if ($this->isDemoInstall($cart_settings)) {
                 $sCart->setupDemo();
             } else {
                 $sCart->clean();
             }
             $sCart->setupUsers();
             $sCart->setupCompanies();
             $sCart->setupLanguages($this->isDemoInstall($cart_settings));
             $sCart->setupThemes();
             $sAddons->setup($this->isDemoInstall($cart_settings), $addons);
             $license_number = !empty($cart_settings['license_number']) ? $cart_settings['license_number'] : '';
             $sCart->setupLicense($license_number);
             $sCart->writeConfig();
             $app->setNotification('N', '', $app->t('successfully_finished'), true);
             $setup_result = 0;
         }
     }
     return $setup_result;
 }