public function execute() { if (!rex::getUser()->isAdmin()) { throw new rex_api_exception('You do not have the permission!'); } $addonkey = rex_request('addonkey', 'string'); $upload = rex_request('upload', [['upload_file', 'bool'], ['oldversion', 'string'], ['redaxo', 'array[string]'], ['description', 'string'], ['status', 'int'], ['replace_assets', 'bool'], ['ignore_tests', 'bool']]); $file = []; $archive = null; $file['version'] = $upload['upload_file'] ? rex_addon::get($addonkey)->getVersion() : $upload['oldversion']; $file['redaxo_versions'] = $upload['redaxo']; $file['description'] = $upload['description']; $file['status'] = $upload['status']; try { if ($upload['upload_file']) { $archive = rex_path::addonCache('install', md5($addonkey . time()) . '.zip'); $exclude = []; if ($upload['replace_assets']) { $exclude[] = 'assets'; } if ($upload['ignore_tests']) { $exclude[] = 'tests'; } rex_install_archive::copyDirToArchive(rex_path::addon($addonkey), $archive, null, $exclude); if ($upload['replace_assets']) { rex_install_archive::copyDirToArchive(rex_url::addonAssets($addonkey), $archive, $addonkey . '/assets'); } $file['checksum'] = md5_file($archive); } rex_install_webservice::post(rex_install_packages::getPath('?package=' . $addonkey . '&file_id=' . rex_request('file', 'int', 0)), ['file' => $file], $archive); } catch (rex_functional_exception $e) { throw new rex_api_exception($e->getMessage()); } if ($archive) { rex_file::delete($archive); } unset($_REQUEST['addonkey']); unset($_REQUEST['file']); rex_install_packages::deleteCache(); return new rex_api_result(true, rex_i18n::msg('install_info_addon_uploaded', $addonkey)); }
/** * Bindet ggf extensions ein. * * @param rex_extension_point $ep */ function rex_metainfo_extensions_handler(rex_extension_point $ep) { $page = $ep->getSubject(); $mainpage = rex_be_controller::getCurrentPagePart(1); $mypage = 'metainfo'; // additional javascripts if ($mainpage == 'metainfo' || $page == 'content/metainfo' || $page == 'structure') { rex_view::addJsFile(rex_url::addonAssets($mypage, 'metainfo.js')); } // include extensions $curDir = __DIR__ . '/..'; if ($page == 'structure') { require_once $curDir . '/lib/handler/category_handler.php'; } elseif ($mainpage == 'mediapool') { require_once $curDir . '/lib/handler/media_handler.php'; } elseif ($mainpage == 'content') { require_once $curDir . '/extensions/extension_content_sidebar.php'; } elseif ($page == 'backup') { require_once $curDir . '/extensions/extension_cleanup.php'; } }
/** * {@inheritdoc} */ public function getAssetsUrl($file = '') { return rex_url::addonAssets($this->getName(), $file); }
$formElements[] = $n; $fragment = new rex_fragment(); $fragment->setVar('elements', $formElements, false); $panel .= $fragment->parse('core/form/form.php'); $formElements = []; $n = []; $n['reverse'] = true; $n['label'] = '<label for="rex-install-packages-upload-status">' . $this->i18n('online') . '</label>'; $n['field'] = '<input id="rex-install-packages-upload-status" type="checkbox" name="upload[status]" value="1" ' . (!$new && $file['status'] ? 'checked="checked" ' : '') . '/>'; $formElements[] = $n; $n = []; $n['reverse'] = true; $n['label'] = '<label for="rex-js-install-packages-upload-upload-file">' . $this->i18n('upload_file') . '</label>' . $hiddenField; $n['field'] = '<input id="rex-js-install-packages-upload-upload-file" type="checkbox" name="upload[upload_file]" value="1" ' . ($new ? 'checked="checked" ' : '') . $uploadCheckboxDisabled . '/>'; $formElements[] = $n; if (rex_addon::get($addonkey)->isInstalled() && is_dir(rex_url::addonAssets($addonkey))) { $n = []; $n['reverse'] = true; $n['label'] = '<label for="rex-js-install-packages-upload-replace-assets">' . $this->i18n('replace_assets') . '</label>'; $n['field'] = '<input id="rex-js-install-packages-upload-replace-assets" type="checkbox" name="upload[replace_assets]" value="1" ' . ($new ? '' : 'disabled="disabled" ') . '/>'; $formElements[] = $n; } if (is_dir(rex_path::addon($addonkey, 'tests'))) { $n = []; $n['reverse'] = true; $n['label'] = '<label for="rex-js-install-packages-upload-ignore-tests">' . $this->i18n('ignore_tests') . '</label>'; $n['field'] = '<input id="rex-js-install-packages-upload-ignore-tests" type="checkbox" name="upload[ignore_tests]" value="1" checked="checked"' . ($new ? '' : 'disabled="disabled" ') . '/>'; $formElements[] = $n; } $fragment = new rex_fragment(); $fragment->setVar('elements', $formElements, false);