From 10a82801617ee17f29e6b17ba7b5e8acf2a3461a Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Sun, 31 Dec 2023 19:59:55 +0100 Subject: [PATCH 01/10] Github-Download --- lib/zip_url.php | 46 ++++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/zip_url.php b/lib/zip_url.php index 6ac2005..5f389b8 100644 --- a/lib/zip_url.php +++ b/lib/zip_url.php @@ -2,17 +2,14 @@ /** * zip_install Addon. * - * * @author Friends Of REDAXO * @author stefan-beyer * * @var rex_addon */ - class zip_url extends zip_install { - protected static function downloadFile($url, $destination) { try { @@ -26,7 +23,6 @@ protected static function downloadFile($url, $destination) if (empty($location)) { return false; } - # add host if needed if (strpos($location, '//') === false) { @@ -55,25 +51,39 @@ protected static function downloadFile($url, $destination) return false; } - public static function validateAndExtractUpload() { - $url = rex_post('file_url'); - if (!empty($url)) + $fileUrl = rex_post('file_url'); + + if (!empty($fileUrl)) { $tmp_file = rex_path::addon('zip_install', 'tmp/._tmp.zip'); - - if (!self::downloadFile($url, $tmp_file)) { - echo rex_view::error(rex_i18n::rawMsg('zip_install_url_file_not_loaded')); - } - - if (!file_exists($tmp_file)) { - echo rex_view::error(rex_i18n::rawMsg('zip_install_url_tmp_not_written')); - return; + $isGithubRepo = preg_match("/^https:\/\/github\.com\/[\w-]+\/[\w-]+$/", $fileUrl); + + if ($isGithubRepo) { + $mainBranchUrl = $fileUrl . '/archive/main.zip'; + $masterBranchUrl = $fileUrl . '/archive/master.zip'; + + // Versuche zuerst den 'main'-Branch + if (self::downloadFile($mainBranchUrl, $tmp_file) && file_exists($tmp_file)) { + self::installZip($tmp_file); + return; + } + + // Versuche dann den 'master'-Branch + if (self::downloadFile($masterBranchUrl, $tmp_file) && file_exists($tmp_file)) { + self::installZip($tmp_file); + return; + } + } else { + // Direkter Download der ZIP-Datei von der angegebenen URL + if (self::downloadFile($fileUrl, $tmp_file) && file_exists($tmp_file)) { + self::installZip($tmp_file); + return; + } } - - self::installZip($tmp_file); + + echo rex_view::error(rex_i18n::rawMsg('zip_install_url_file_not_loaded')); } } - } From 744435483472e7e3db868d59076a9fad43cc4bcb Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Sun, 31 Dec 2023 20:04:01 +0100 Subject: [PATCH 02/10] Update de_de.lang --- lang/de_de.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lang/de_de.lang b/lang/de_de.lang index 7383f50..dd5b631 100644 --- a/lang/de_de.lang +++ b/lang/de_de.lang @@ -1,7 +1,7 @@ # URL zip_install_url_title = Von URL installieren -zip_install_url = URL zu ZIP-Datei -zip_install_url_choose_info = AddOns und Plugins möglich. Sollte der Ordner bereits existieren, wird dieser überschrieben.
Bitte ggf. vor dem Upload ein Backup anlegen.

Hinweis: Der Ordner wird automatisch auf den Package-Name umbenannt, es muss nichts manuell gemacht werden. +zip_install_url = URL zu ZIP-Datei oder GitHub-Repo +zip_install_url_choose_info = AddOns und Plugins möglich. Sollte der Ordner bereits existieren, wird dieser überschrieben.
Bitte ggf. vor dem Upload ein Backup anlegen.

Hinweis: Der Ordner wird automatisch auf den Package-Name umbenannt, es muss nichts manuell gemacht werden. Bei Eingabe einer GitHub-Repo-Adresse wird automatisch das Main-Branch geladen. zip_install_url_file_not_loaded = Fehler beim Herunterladen der Datei. zip_install_url_no_zip = Die heruntergeladene Datei ist keine ZIP-Datei. zip_install_url_tmp_not_written = Fehler beim Herunterladen der Datei. Temporäre Datei nicht vorhanden. From a3897148f39bc4872ebb0761e8a3a7aa2da508c2 Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Sun, 31 Dec 2023 20:05:02 +0100 Subject: [PATCH 03/10] 1.3 --- package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.yml b/package.yml index 77124ef..26a5b66 100644 --- a/package.yml +++ b/package.yml @@ -1,5 +1,5 @@ package: zip_install -version: '1.2' +version: '1.3' author: Friends Of REDAXO supportpage: github.com/FriendsOfREDAXO/zip_install From 2f879266cd5527f23a728e1a74728d9194ef55f5 Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Sun, 31 Dec 2023 20:06:13 +0100 Subject: [PATCH 04/10] 1.4.0 --- package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.yml b/package.yml index 26a5b66..c5c371b 100644 --- a/package.yml +++ b/package.yml @@ -1,5 +1,5 @@ package: zip_install -version: '1.3' +version: '1.4.0' author: Friends Of REDAXO supportpage: github.com/FriendsOfREDAXO/zip_install From bb293263ec43f501cb3c0bbee991d059066dd46d Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Sun, 31 Dec 2023 20:19:26 +0100 Subject: [PATCH 05/10] vendor updates --- composer.lock | 26 ++++++++-------- .../lib/Doctrine/Deprecations/Deprecation.php | 3 +- vendor/doctrine/deprecations/phpcs.xml | 22 -------------- vendor/doctrine/deprecations/phpstan.neon | 9 ------ vendor/doctrine/deprecations/psalm.xml | 30 ------------------- vendor/symfony/process/Pipes/WindowsPipes.php | 2 +- 6 files changed, 16 insertions(+), 76 deletions(-) delete mode 100644 vendor/doctrine/deprecations/phpcs.xml delete mode 100644 vendor/doctrine/deprecations/phpstan.neon delete mode 100644 vendor/doctrine/deprecations/psalm.xml diff --git a/composer.lock b/composer.lock index ee8b4f0..0687cbb 100644 --- a/composer.lock +++ b/composer.lock @@ -146,16 +146,16 @@ }, { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://api.github.com/repos/doctrine/deprecations/zipball/4f2d4f2836e7ec4e7a8625e75c6aa916004db931", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -187,9 +187,9 @@ "homepage": "https://www.doctrine-project.org/", "support": { "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/v1.1.1" + "source": "https://github.com/doctrine/deprecations/tree/1.1.2" }, - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "symfony/filesystem", @@ -505,16 +505,16 @@ }, { "name": "symfony/process", - "version": "v5.4.28", + "version": "v5.4.34", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b" + "reference": "8fa22178dfc368911dbd513b431cd9b06f9afe7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b", - "reference": "45261e1fccad1b5447a8d7a8e67aa7b4a9798b7b", + "url": "https://api.github.com/repos/symfony/process/zipball/8fa22178dfc368911dbd513b431cd9b06f9afe7a", + "reference": "8fa22178dfc368911dbd513b431cd9b06f9afe7a", "shasum": "" }, "require": { @@ -547,7 +547,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.28" + "source": "https://github.com/symfony/process/tree/v5.4.34" }, "funding": [ { @@ -563,7 +563,7 @@ "type": "tidelift" } ], - "time": "2023-08-07T10:36:04+00:00" + "time": "2023-12-02T08:41:43+00:00" } ], "packages-dev": [], @@ -574,5 +574,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php b/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php index 07cb43b..bad5070 100644 --- a/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php +++ b/vendor/doctrine/deprecations/lib/Doctrine/Deprecations/Deprecation.php @@ -11,6 +11,7 @@ use function assert; use function debug_backtrace; use function sprintf; +use function str_replace; use function strpos; use function strrpos; use function substr; @@ -138,7 +139,7 @@ public static function triggerIfCalledFromOutside(string $package, string $link, // first check that the caller is not from a tests folder, in which case we always let deprecations pass if (isset($backtrace[1]['file'], $backtrace[0]['file']) && strpos($backtrace[1]['file'], DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) === false) { - $path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $package . DIRECTORY_SEPARATOR; + $path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $package) . DIRECTORY_SEPARATOR; if (strpos($backtrace[0]['file'], $path) === false) { return; diff --git a/vendor/doctrine/deprecations/phpcs.xml b/vendor/doctrine/deprecations/phpcs.xml deleted file mode 100644 index f115e43..0000000 --- a/vendor/doctrine/deprecations/phpcs.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - lib - tests - - - - - - diff --git a/vendor/doctrine/deprecations/phpstan.neon b/vendor/doctrine/deprecations/phpstan.neon deleted file mode 100644 index 4ee286b..0000000 --- a/vendor/doctrine/deprecations/phpstan.neon +++ /dev/null @@ -1,9 +0,0 @@ -parameters: - level: 6 - paths: - - lib - - tests - -includes: - - vendor/phpstan/phpstan-phpunit/extension.neon - - vendor/phpstan/phpstan-phpunit/rules.neon diff --git a/vendor/doctrine/deprecations/psalm.xml b/vendor/doctrine/deprecations/psalm.xml deleted file mode 100644 index ad76e32..0000000 --- a/vendor/doctrine/deprecations/psalm.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/vendor/symfony/process/Pipes/WindowsPipes.php b/vendor/symfony/process/Pipes/WindowsPipes.php index bca84f5..968dd02 100644 --- a/vendor/symfony/process/Pipes/WindowsPipes.php +++ b/vendor/symfony/process/Pipes/WindowsPipes.php @@ -149,7 +149,7 @@ public function readAndWrite(bool $blocking, bool $close = false): array if ($w) { @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6); } elseif ($this->fileHandles) { - usleep(Process::TIMEOUT_PRECISION * 1E6); + usleep((int) (Process::TIMEOUT_PRECISION * 1E6)); } } foreach ($this->fileHandles as $type => $fileHandle) { From 82cbfa8ab0a11236b59f659f73f333c29e2c2a1c Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Sun, 31 Dec 2023 20:25:52 +0100 Subject: [PATCH 06/10] GitHub repo info --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9b645c1..d3aae8e 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Das AddOn registriert zwei neue Subpages im Installer (neben "Eigene hochladen") * eine ZIP-Datei eines gültigen AddOns uploaden (wird geprüft). * eine URL zu einer ZIP-Datei eines gültigen AddOns angeben. + * eune URL zu einem GitHub-Repo z.B.: `https://github.com/FriendsOfREDAXO/quick_navigation` (aktueller Haupt-Branch wird geladen) Plugins lassen sich auch installieren. Diese werden automatisch in das richtige AddOn kopiert. (Benennung erfolgt ebenfalls automatisch) From f36a03b6050afb6dad00c6acf1d03c048b7bf4d3 Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Sun, 31 Dec 2023 20:26:25 +0100 Subject: [PATCH 07/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3aae8e..9fa8eb1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Das AddOn registriert zwei neue Subpages im Installer (neben "Eigene hochladen") * eine ZIP-Datei eines gültigen AddOns uploaden (wird geprüft). * eine URL zu einer ZIP-Datei eines gültigen AddOns angeben. - * eune URL zu einem GitHub-Repo z.B.: `https://github.com/FriendsOfREDAXO/quick_navigation` (aktueller Haupt-Branch wird geladen) + * eine URL zu einem GitHub-Repo z.B.: `https://github.com/FriendsOfREDAXO/quick_navigation` (aktueller Haupt-Branch wird geladen) Plugins lassen sich auch installieren. Diese werden automatisch in das richtige AddOn kopiert. (Benennung erfolgt ebenfalls automatisch) From 54de7285fa207fb6e1cb85616d0134385185691c Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Mon, 1 Jan 2024 17:22:06 +0100 Subject: [PATCH 08/10] Branch-Download added --- lib/zip_url.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/zip_url.php b/lib/zip_url.php index 5f389b8..f7bc0b1 100644 --- a/lib/zip_url.php +++ b/lib/zip_url.php @@ -1,4 +1,5 @@ isOk()) { + if (!$response->isOk()) { return false; } @@ -47,7 +48,8 @@ protected static function downloadFile($url, $destination) if ($response->writeBodyTo($destination)) { return true; } - } catch(rex_socket_exception $e) {} + } catch (rex_socket_exception $e) { + } return false; } @@ -55,10 +57,10 @@ public static function validateAndExtractUpload() { $fileUrl = rex_post('file_url'); - if (!empty($fileUrl)) - { + if (!empty($fileUrl)) { $tmp_file = rex_path::addon('zip_install', 'tmp/._tmp.zip'); $isGithubRepo = preg_match("/^https:\/\/github\.com\/[\w-]+\/[\w-]+$/", $fileUrl); + $isGithubBranch = preg_match("/^https:\/\/github\.com\/[\w-]+\/[\w-]+\/tree\/[\w-]+$/", $fileUrl); if ($isGithubRepo) { $mainBranchUrl = $fileUrl . '/archive/main.zip'; @@ -75,6 +77,13 @@ public static function validateAndExtractUpload() self::installZip($tmp_file); return; } + } elseif ($isGithubBranch) { + + // Entfernen Sie '/tree/' und ersetzen Sie es durch '/archive/' + '.zip' + if (self::downloadFile($branchUrl, $tmp_file) && file_exists($tmp_file)) { + self::installZip($tmp_file); + return; + } } else { // Direkter Download der ZIP-Datei von der angegebenen URL if (self::downloadFile($fileUrl, $tmp_file) && file_exists($tmp_file)) { From 90433c87b939f6ff1b84f5c959469c4dd5360f53 Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Mon, 1 Jan 2024 17:38:30 +0100 Subject: [PATCH 09/10] csfixes --- lib/zip_url.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/zip_url.php b/lib/zip_url.php index f7bc0b1..6f4c257 100644 --- a/lib/zip_url.php +++ b/lib/zip_url.php @@ -60,8 +60,7 @@ public static function validateAndExtractUpload() if (!empty($fileUrl)) { $tmp_file = rex_path::addon('zip_install', 'tmp/._tmp.zip'); $isGithubRepo = preg_match("/^https:\/\/github\.com\/[\w-]+\/[\w-]+$/", $fileUrl); - $isGithubBranch = preg_match("/^https:\/\/github\.com\/[\w-]+\/[\w-]+\/tree\/[\w-]+$/", $fileUrl); - + $isGithubBranch = preg_match("/^https:\/\/github\.com\/[\w-]+\/[\w-]+\/tree\/[\w\.-]+$/", $fileUrl); if ($isGithubRepo) { $mainBranchUrl = $fileUrl . '/archive/main.zip'; $masterBranchUrl = $fileUrl . '/archive/master.zip'; @@ -78,8 +77,8 @@ public static function validateAndExtractUpload() return; } } elseif ($isGithubBranch) { - // Entfernen Sie '/tree/' und ersetzen Sie es durch '/archive/' + '.zip' + $branchUrl = preg_replace("/\/tree\//", '/archive/', $fileUrl) . '.zip'; if (self::downloadFile($branchUrl, $tmp_file) && file_exists($tmp_file)) { self::installZip($tmp_file); return; From b13e51833cfb1c29bec2f169cbbc8fe0a856df5c Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Tue, 2 Jan 2024 00:22:43 +0100 Subject: [PATCH 10/10] =?UTF-8?q?Branch=20laden=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fa8eb1..6f3471c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ Das AddOn registriert zwei neue Subpages im Installer (neben "Eigene hochladen") * eine ZIP-Datei eines gültigen AddOns uploaden (wird geprüft). * eine URL zu einer ZIP-Datei eines gültigen AddOns angeben. - * eine URL zu einem GitHub-Repo z.B.: `https://github.com/FriendsOfREDAXO/quick_navigation` (aktueller Haupt-Branch wird geladen) + * eine URL zu einem GitHub-Repo z.B.: `https://github.com/FriendsOfREDAXO/quick_navigation` (aktueller Haupt-Branch wird geladen) + * ZIP einer GitHub-Branch laden z.B: `https://github.com/FriendsOfREDAXO/quick_navigation/tree/dev` Plugins lassen sich auch installieren. Diese werden automatisch in das richtige AddOn kopiert. (Benennung erfolgt ebenfalls automatisch)