Inheritance: use trait rex_factory_trait
Exemplo n.º 1
0
 protected function doAction()
 {
     if (($msg = $this->extractArchiveTo(rex_path::addon($this->addonkey))) !== true) {
         return $msg;
     }
     rex_package_manager::synchronizeWithFileSystem();
     rex_install_packages::addedPackage($this->addonkey);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $function = rex_request('function', 'string');
     if (!in_array($function, ['install', 'uninstall', 'activate', 'deactivate', 'delete'])) {
         throw new rex_api_exception('Unknown package function "' . $function . '"!');
     }
     $packageId = rex_request('package', 'string');
     $package = rex_package::get($packageId);
     if ($function == 'uninstall' && !$package->isInstalled() || $function == 'activate' && $package->isAvailable() || $function == 'deactivate' && !$package->isAvailable() || $function == 'delete' && !rex_package::exists($packageId)) {
         throw new rex_api_exception('Illegal operation "' . $function . '" for package "' . $packageId . '"');
     }
     if ($package instanceof rex_null_package) {
         throw new rex_api_exception('Package "' . $packageId . '" doesn\'t exists!');
     }
     $reinstall = 'install' === $function && $package->isInstalled();
     $manager = rex_package_manager::factory($package);
     $success = $manager->{$function}();
     $message = $manager->getMessage();
     $result = new rex_api_result($success, $message);
     if ($success && !$reinstall) {
         $result->setRequiresReboot(true);
     }
     return $result;
 }
Exemplo n.º 3
0
 private static function installAddons($uninstallBefore = false, $installDump = true)
 {
     $addonErr = '';
     rex_package_manager::synchronizeWithFileSystem();
     if ($uninstallBefore) {
         foreach (array_reverse(rex_package::getSystemPackages()) as $package) {
             $manager = rex_package_manager::factory($package);
             $state = $manager->uninstall($installDump);
             if ($state !== true) {
                 $addonErr .= '<li>' . $package->getPackageId() . '<ul><li>' . $manager->getMessage() . '</li></ul></li>';
             }
         }
     }
     foreach (rex::getProperty('system_addons') as $packageRepresentation) {
         $state = true;
         $package = rex_package::get($packageRepresentation);
         $manager = rex_package_manager::factory($package);
         if ($state === true && !$package->isInstalled()) {
             $state = $manager->install($installDump);
         }
         if ($state !== true) {
             $addonErr .= '<li>' . $package->getPackageId() . '<ul><li>' . $manager->getMessage() . '</li></ul></li>';
         }
         if ($state === true && !$package->isAvailable()) {
             $state = $manager->activate();
             if ($state !== true) {
                 $addonErr .= '<li>' . $package->getPackageId() . '<ul><li>' . $manager->getMessage() . '</li></ul></li>';
             }
         }
     }
     if ($addonErr != '') {
         $addonErr = '<ul class="rex-ul1">
         <li>
         <h3 class="rex-hl3">' . rex_i18n::msg('setup_513', '<span class="rex-error">', '</span>') . '</h3>
         <ul>' . $addonErr . '</ul>
         </li>
         </ul>';
     }
     return $addonErr;
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function checkDependencies()
 {
     $check = $addonCheck = parent::checkDependencies();
     $dependencies = [];
     foreach ($this->package->getAvailablePlugins() as $plugin) {
         $manager = rex_plugin_manager::factory($plugin);
         if (!$manager->checkDependencies()) {
             $dependencies[] = $manager->getMessage();
             $check = false;
         }
     }
     if (!empty($dependencies)) {
         if (!$addonCheck) {
             $this->message .= '<br />';
         }
         $this->message .= implode('<br />', $dependencies);
     }
     return $check;
 }
Exemplo n.º 5
0
 /**
  * @param string      $temppath
  * @param string      $version
  * @param rex_addon[] $addons
  *
  * @throws rex_functional_exception
  */
 private function checkRequirements($temppath, $version, array $addons)
 {
     // ---- update "version", "requires" and "conflicts" properties
     $coreVersion = rex::getVersion();
     rex::setProperty('version', $version);
     $versions = new SplObjectStorage();
     $requirements = new SplObjectStorage();
     $conflicts = new SplObjectStorage();
     foreach ($addons as $addonkey => $config) {
         $addon = rex_addon::get($addonkey);
         $addonPath = $temppath . 'addons/' . $addonkey . '/';
         if (isset($config['requires'])) {
             $requirements[$addon] = $addon->getProperty('requires');
             $addon->setProperty('requires', $config['requires']);
         }
         if (isset($config['conflicts'])) {
             $conflicts[$addon] = $addon->getProperty('conflicts');
             $addon->setProperty('conflicts', $config['conflicts']);
         }
         $versions[$addon] = $addon->getVersion();
         $addon->setProperty('version', $config['version']);
         foreach ($addon->getAvailablePlugins() as $plugin) {
             if (is_dir($addonPath . 'plugins/' . $plugin->getName())) {
                 $config = rex_file::getConfig($addonPath . 'plugins/' . $plugin->getName() . '/' . rex_package::FILE_PACKAGE);
                 if (isset($config['requires'])) {
                     $requirements[$plugin] = $plugin->getProperty('requires');
                     $plugin->setProperty('requires', $config['requires']);
                 }
                 if (isset($config['conflicts'])) {
                     $conflicts[$plugin] = $plugin->getProperty('conflicts');
                     $plugin->setProperty('conflicts', $config['conflicts']);
                 }
                 if (isset($config['version'])) {
                     $versions[$plugin] = $plugin->getProperty('version');
                     $plugin->setProperty('requires', $config['version']);
                 }
             }
         }
     }
     // ---- check requirements
     $messages = [];
     foreach (rex_package::getAvailablePackages() as $package) {
         $manager = rex_package_manager::factory($package);
         if (!$manager->checkRequirements()) {
             $messages[] = $package->getPackageId() . ': ' . $manager->getMessage();
         } elseif (!$manager->checkConflicts()) {
             $messages[] = $package->getPackageId() . ': ' . $manager->getMessage();
         }
     }
     // ---- reset "version", "requires" and "conflicts" properties
     rex::setProperty('version', $coreVersion);
     foreach ($versions as $package) {
         $package->setProperty('version', $versions[$package]);
     }
     foreach ($requirements as $package) {
         $package->setProperty('requires', $requirements[$package]);
     }
     foreach ($conflicts as $package) {
         $package->setProperty('conflicts', $conflicts[$package]);
     }
     if (!empty($messages)) {
         throw new rex_functional_exception(implode('<br />', $messages));
     }
 }
Exemplo n.º 6
0
    if ($author) {
        $credits .= '<dt>' . rex_i18n::msg('credits_author') . '</dt><dd>' . htmlspecialchars($author) . '</dd>';
    }
    if ($supportPage) {
        $credits .= '<dt>' . rex_i18n::msg('credits_supportpage') . '</dt><dd><a href="http://' . $supportPage . '" onclick="window.open(this.href); return false;">' . $supportPage . '</a></dd>';
    }
    $credits .= '</dl>';
    $fragment = new rex_fragment();
    $fragment->setVar('title', rex_i18n::msg('credits'), false);
    $fragment->setVar('body', $credits, false);
    echo $fragment->parse('core/page/section.php');
    echo '<a class="btn btn-back" href="javascript:history.back();">' . rex_i18n::msg('package_back') . '</a>';
}
// ----------------- OUT
if ($subpage == '') {
    rex_package_manager::synchronizeWithFileSystem();
    $content .= '
            <table class="table table-hover">
            <thead>
                <tr>
                    <th class="rex-table-icon">&nbsp;</th>
                    <th>' . rex_i18n::msg('package_hname') . '</th>
                    <th>' . rex_i18n::msg('package_hversion') . '</th>
                    <th class="rex-table-slim">' . rex_i18n::msg('package_hhelp') . '</th>
                    <th class="rex-table-action">' . rex_i18n::msg('package_hinstall') . '</th>
                    <th class="rex-table-action">' . rex_i18n::msg('package_hactive') . '</th>
                    <th class="rex-table-action" colspan="2">' . rex_i18n::msg('package_hdelete') . '</th>
                </tr>
            </thead>
            <tbody>';
    $getLink = function (rex_package $package, $function, $icon = '', $confirm = false, $key = null) {
Exemplo n.º 7
0
 private function checkRequirements($config)
 {
     $temppath = rex_path::addon('.new.' . $this->addonkey);
     // ---- update "version", "requires" and "conflicts" properties
     $versions = new SplObjectStorage();
     $requirements = new SplObjectStorage();
     $conflicts = new SplObjectStorage();
     if (isset($config['requires'])) {
         $requirements[$this->addon] = $this->addon->getProperty('requires');
         $this->addon->setProperty('requires', $config['requires']);
     }
     if (isset($config['conflicts'])) {
         $conflicts[$this->addon] = $this->addon->getProperty('conflicts');
         $this->addon->setProperty('conflicts', $config['conflicts']);
     }
     $versions[$this->addon] = $this->addon->getVersion();
     $this->addon->setProperty('version', isset($config['version']) ? $config['version'] : $this->file['version']);
     $availablePlugins = $this->addon->getAvailablePlugins();
     foreach ($availablePlugins as $plugin) {
         if (is_dir($temppath . '/plugins/' . $plugin->getName())) {
             $config = rex_file::getConfig($temppath . '/plugins/' . $plugin->getName() . '/' . rex_package::FILE_PACKAGE);
             if (isset($config['requires'])) {
                 $requirements[$plugin] = $plugin->getProperty('requires');
                 $plugin->setProperty('requires', $config['requires']);
             }
             if (isset($config['conflicts'])) {
                 $conflicts[$plugin] = $plugin->getProperty('conflicts');
                 $plugin->setProperty('conflicts', $config['conflicts']);
             }
             if (isset($config['version'])) {
                 $versions[$plugin] = $plugin->getProperty('version');
                 $plugin->setProperty('requires', $config['version']);
             }
         }
     }
     // ---- check requirements
     $messages = [];
     $manager = rex_addon_manager::factory($this->addon);
     if (!$manager->checkRequirements()) {
         $messages[] = $manager->getMessage();
     }
     if (!$manager->checkConflicts()) {
         $messages[] = $manager->getMessage();
     }
     if (empty($messages)) {
         foreach ($availablePlugins as $plugin) {
             $manager = rex_plugin_manager::factory($plugin);
             if (!$manager->checkRequirements()) {
                 $messages[] = $plugin->getPackageId() . ': ' . $manager->getMessage();
             }
             if (!$manager->checkConflicts()) {
                 $messages[] = $plugin->getPackageId() . ': ' . $manager->getMessage();
             }
         }
         foreach (rex_package::getAvailablePackages() as $package) {
             if ($package->getAddon() === $this->addon) {
                 continue;
             }
             $manager = rex_package_manager::factory($package);
             if (!$manager->checkPackageRequirement($this->addon->getPackageId())) {
                 $messages[] = $package->getPackageId() . ': ' . $manager->getMessage();
             } elseif (!$manager->checkPackageConflict($this->addon->getPackageId())) {
                 $messages[] = $package->getPackageId() . ': ' . $manager->getMessage();
             } else {
                 foreach ($versions as $reqPlugin) {
                     if (!$manager->checkPackageRequirement($reqPlugin->getPackageId())) {
                         $messages[] = $package->getPackageId() . ': ' . $manager->getMessage();
                     }
                     if (!$manager->checkPackageConflict($reqPlugin->getPackageId())) {
                         $messages[] = $package->getPackageId() . ': ' . $manager->getMessage();
                     }
                 }
             }
         }
     }
     // ---- reset "version", "requires" and "conflicts" properties
     foreach ($versions as $package) {
         $package->setProperty('version', $versions[$package]);
     }
     foreach ($requirements as $package) {
         $package->setProperty('requires', $requirements[$package]);
     }
     foreach ($conflicts as $package) {
         $package->setProperty('conflicts', $conflicts[$package]);
     }
     return empty($messages) ? true : implode('<br />', $messages);
 }
Exemplo n.º 8
0
 /**
  * Constructor.
  *
  * @param rex_plugin $plugin Plugin
  */
 protected function __construct(rex_plugin $plugin)
 {
     parent::__construct($plugin, 'plugin_');
 }