Example #1
0
<?php

/** @var rex_addon $this */
$addonkey = rex_request('addonkey', 'string');
$addons = [];
echo rex_api_function::getMessage();
try {
    $addons = rex_install_packages::getMyPackages();
} catch (rex_functional_exception $e) {
    echo rex_view::error($e->getMessage());
    $addonkey = '';
}
if ($addonkey && isset($addons[$addonkey])) {
    $addon = $addons[$addonkey];
    $file_id = rex_request('file', 'string');
    if ($file_id) {
        $new = $file_id == 'new';
        $file = $new ? ['version' => '', 'description' => '', 'status' => 1] : $addon['files'][$file_id];
        $newVersion = rex_addon::get($addonkey)->getVersion();
        $uploadCheckboxDisabled = '';
        $hiddenField = '';
        if ($new || !rex_addon::exists($addonkey)) {
            $uploadCheckboxDisabled = ' disabled="disabled"';
            $hiddenField = '<input type="hidden" name="upload[upload_file]" value="' . (int) $new . '" />';
        }
        $panel = '<fieldset>';
        $formElements = [];
        $n = [];
        $n['label'] = '<label for="rex-js-install-packages-upload-version">' . $this->i18n('version') . '</label>';
        $n['field'] = '<p class="form-control-static" id="rex-js-install-packages-upload-version">' . ($new ? $newVersion : $file['version']) . '</p>
                           <input type="hidden" name="upload[oldversion]" value="' . $file['version'] . '" />';