コード例 #1
0
 /**
  * Performs the database update
  *
  * @param InputInterface $input cli input object
  *
  * @return void
  */
 protected function updateDb(InputInterface $input)
 {
     $joomlaApp = Bootstrapper::getApplication($input->getOption('path'));
     \JModelLegacy::addIncludePath($joomlaApp->getPath() . '/administrator/components/com_installer/models', 'InstallerModel');
     /* @var $model \InstallerModelDatabase */
     $model = \JModelLegacy::getInstance('Database', 'InstallerModel');
     $model->fix();
 }
コード例 #2
0
 /**
  * Install language
  *
  * @param InputInterface  $input  input cli object
  * @param OutputInterface $output output cli object
  *
  * @throws \RuntimeException
  *
  * @return void
  */
 protected function installLanguage(InputInterface $input, OutputInterface $output)
 {
     $joomlaApp = Bootstrapper::getApplication($input->getOption('path'));
     $joomlaApp->set('list_limit', 10000);
     $lang = $input->getArgument('language');
     // check if language already installed
     \JModelLegacy::addIncludePath($joomlaApp->getPath() . '/administrator/components/com_installer/models', 'InstallerModel');
     /* @var $model \InstallerModelManage */
     $model = \JModelLegacy::getInstance('Manage', 'InstallerModel');
     $items = $model->getItems();
     foreach ($items as $item) {
         if ($item->type !== 'language') {
             continue;
         }
         if (strtoupper($item->element) === strtoupper($lang)) {
             // check if language is installed on disk, if not installed remove from database and reinstall
             if (file_exists($joomlaApp->getPath() . '/language/' . $item->element)) {
                 $output->writeln('<info>Language ' . $item->element . ' already installed.');
                 return;
             } else {
                 // language in database but not on disk, lets cleanup database first so we can install
                 $db = \JFactory::getDbo();
                 $db->setQuery('DELETE FROM #__extensions WHERE type=' . $db->quote('language') . ' AND element=' . $db->quote($item->element));
                 $db->query();
                 $db->setQuery('DELETE FROM #__extensions WHERE type=' . $db->quote('package') . ' AND element=' . $db->quote('pkg_' . $item->element));
                 $db->query();
                 break;
             }
         }
     }
     \JModelLegacy::addIncludePath($joomlaApp->getPath() . '/administrator/components/com_installer/models', 'InstallerModel');
     /* @var $model \InstallerModelLanguages */
     $model = \JModelLegacy::getInstance('Languages', 'InstallerModel');
     $model->findLanguages();
     $items = $model->getItems();
     $table = \JTable::getInstance('update');
     foreach ($items as $item) {
         $table->load($item->update_id);
         $key = preg_replace('/^pkg_/i', '', $table->element);
         if (strtoupper($key) === strtoupper($lang)) {
             $output->writeln('<info>Installing language ' . $lang . '</info>');
             $model->install([$item->update_id]);
             return;
         }
     }
     throw new \RuntimeException('Language ' . $lang . ' not found!');
 }
コード例 #3
0
 /**
  * Performs the database update
  *
  * @param InputInterface $input cli input object
  *
  * @return void
  */
 protected function updateDb(InputInterface $input)
 {
     $joomlaApp = Bootstrapper::getApplication($input->getOption('path'));
     // Load the update component's model to run the cleanup methods
     \JModelLegacy::addIncludePath($joomlaApp->getPath() . '/administrator/components/com_joomlaupdate/models', 'JoomlaupdateModel');
     /** @var JoomlaupdateModelDefault $model */
     $model = \JModelLegacy::getInstance('default', 'JoomlaupdateModel');
     // Make sure we got the model
     if (!$model instanceof \JoomlaupdateModelDefault) {
         echo 'Could not load update component model, please check the logs for additional details.' . PHP_EOL;
         exit(1);
     }
     // Finalize the update
     if ($model->finaliseUpgrade() === false) {
         echo 'Failed to finalize the upgrade, please check the logs for additional details.' . PHP_EOL;
         exit(1);
     }
     // Cleanup after the update
     $model->cleanUp();
     \JModelLegacy::addIncludePath($joomlaApp->getPath() . '/administrator/components/com_installer/models', 'InstallerModel');
     /* @var $model \InstallerModelDatabase */
     $model = \JModelLegacy::getInstance('Database', 'InstallerModel');
     $model->fix();
 }
コード例 #4
0
 /**
  * List installed languages
  *
  * @param InputInterface  $input  input cli object
  * @param OutputInterface $output output cli object
  *
  * @throws \RuntimeException
  *
  * @return void
  */
 protected function listInstalledLanguages(InputInterface $input, OutputInterface $output)
 {
     $joomlaApp = Bootstrapper::getApplication($input->getOption('path'));
     $joomlaApp->set('list_limit', 10000);
     \JModelLegacy::addIncludePath($joomlaApp->getPath() . '/administrator/components/com_languages/models', 'LanguagesModel');
     /* @var $model \InstallerModelLanguages */
     $model = \JModelLegacy::getInstance('Installed', 'LanguagesModel');
     $items = $model->getData();
     foreach ($items as $item) {
         $output->writeln($item->language . ' (' . $item->name . ')');
     }
 }