diff --git a/README.md b/README.md
index 9b645c1..6f3471c 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +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)
+ * 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)
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/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.
diff --git a/lib/zip_url.php b/lib/zip_url.php
index 6ac2005..6f4c257 100644
--- a/lib/zip_url.php
+++ b/lib/zip_url.php
@@ -1,18 +1,16 @@
isOk()) {
+ if (!$response->isOk()) {
return false;
}
@@ -51,29 +48,50 @@ protected static function downloadFile($url, $destination)
if ($response->writeBodyTo($destination)) {
return true;
}
- } catch(rex_socket_exception $e) {}
+ } catch (rex_socket_exception $e) {
+ }
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);
+ $isGithubBranch = preg_match("/^https:\/\/github\.com\/[\w-]+\/[\w-]+\/tree\/[\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;
+ }
+ } 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;
+ }
+ } 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'));
}
}
-
}
diff --git a/package.yml b/package.yml
index 77124ef..c5c371b 100644
--- a/package.yml
+++ b/package.yml
@@ -1,5 +1,5 @@
package: zip_install
-version: '1.2'
+version: '1.4.0'
author: Friends Of REDAXO
supportpage: github.com/FriendsOfREDAXO/zip_install
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) {