Skip to content

Commit 663b664

Browse files
committed
Merge branch 'master' into demo/1.21
# Conflicts: # src/Templates/ModuleInfo.tmpl.php
2 parents f76a574 + 4c96a5a commit 663b664

13 files changed

+99
-12
lines changed

config/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version": "1.21.0"}
1+
{"version": "1.22.0-alpha.1"}

src/Classes/Controllers/IndexController.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,28 @@ public function invokeInstall()
392392
return $this->redirect('/');
393393
}
394394

395+
$force = $queryParams['force'] ?? '';
396+
$force = $force === 'true' ? true : false;
397+
398+
395399
try {
396-
$this->moduleInstaller->installWithDependencies($module);
400+
if ($force) {
401+
$this->moduleInstaller->install($module, true);
402+
} else {
403+
$this->moduleInstaller->installWithDependencies($module);
404+
}
397405
} catch (DependencyException $e) {
406+
$foreInstallUrl = "?action=install"
407+
. "&archiveName={$module->getArchiveName()}"
408+
. "&version={$module->getVersion()}"
409+
. "&ref=moduleInfo"
410+
. "&force=true";
411+
398412
Notification::pushFlashMessage([
399-
'text' => $e->getMessage(),
413+
'text' => $e->getMessage()
414+
. '<br><br>Click here to <a href="' . $foreInstallUrl . '">'
415+
. 'force install ' . $module->getArchiveName() . ':' . $module->getVersion()
416+
. ' without dependencies.</a>',
400417
'type' => 'error'
401418
]);
402419
} catch (RuntimeException $e) {

src/Classes/ModuleConverter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public static function convertToArray(Module $module): array
2525
'sourceDir' => $module->getSourceDir(),
2626
'sourceMmlcDir' => $module->getSourceMmlcDir(),
2727
'version' => $module->getVersion(),
28+
'date' => $module->getDate(),
2829
'shortDescription' => $module->getShortDescription(),
2930
'description' => $module->getDescription(),
3031
'developer' => $module->getDeveloper(),

src/Classes/ModuleFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public static function createFromArray(array $array): Module
7979
$module->setSourceDir($array['sourceDir'] ?? self::DIR_MODULE_SRC);
8080
$module->setSourceMmlcDir($array['sourceMmlcDir'] ?? self::DIR_MODULE_SRC_MMLC);
8181
$module->setVersion($array['version'] ?? 'auto');
82+
$module->setDate($array['date'] ?? 'unknown');
8283
$module->setShortDescription($array['shortDescription'] ?? '');
8384
$module->setDescription($array['description'] ?? '');
8485
$module->setDeveloper($array['developer'] ?? '');

src/Classes/ModuleInfo.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ class ModuleInfo
6666
*/
6767
protected $version;
6868

69+
/**
70+
* Beispiel: 2023-06-20 19:42:32
71+
*
72+
* @var string
73+
*/
74+
protected $date;
75+
6976
/**
7077
* Eine Kurzbeschreibung des Moduls in menschen lesbarer Form.
7178
*
@@ -247,6 +254,16 @@ public function setVersion(string $value): void
247254
$this->version = $value;
248255
}
249256

257+
public function getDate(): string
258+
{
259+
return $this->date;
260+
}
261+
262+
public function setDate(string $value): void
263+
{
264+
$this->date = $value;
265+
}
266+
250267
public function getShortDescription(): string
251268
{
252269
return $this->shortDescription;

src/Classes/ModuleSorter.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,31 @@ public static function sortByVersion(array $modules): array
8282
});
8383
return $modules;
8484
}
85+
86+
/**
87+
* @param Module[] $modules
88+
* @return Module[] Return a array of modules sorted by version.
89+
*/
90+
public static function sortByDate(array $modules): array
91+
{
92+
usort($modules, function (Module $moduleA, Module $moduleB): int {
93+
$dateA = $moduleA->getDate();
94+
if ($dateA === 'unknown') {
95+
$dateA = '0000-00-00 00:00:00';
96+
}
97+
98+
$dateB = $moduleB->getDate();
99+
if ($dateB === 'unknown') {
100+
$dateB = '0000-00-00 00:00:00';
101+
}
102+
103+
if ($dateA < $dateB) {
104+
return 1;
105+
} elseif ($dateA > $dateB) {
106+
return -1;
107+
}
108+
return 0;
109+
});
110+
return $modules;
111+
}
85112
}

src/Classes/ViewModels/ModuleViewModel.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ public function getVersion(): string
169169
return $this->module->getVersion();
170170
}
171171

172+
public function getDate(): string
173+
{
174+
return $this->module->getDate();
175+
}
176+
172177
public function isRemote(): bool
173178
{
174179
return $this->module->isRemote();

src/Templates/ModuleInfo.tmpl.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@
263263
<td><?= $moduleView->getVersion(); ?></td>
264264
</tr>
265265

266+
<tr>
267+
<td>Datum</td>
268+
<td><?= $moduleView->getDate(); ?></td>
269+
</tr>
270+
266271
<tr>
267272
<td>Kompatibel mit Modified</td>
268273
<td>

src/Templates/ModuleListing.tmpl.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
<?php
22
defined('LOADED_FROM_INDEX') && LOADED_FROM_INDEX ?? die('Access denied.');
33

4-
use RobinTheHood\ModifiedModuleLoaderClient\ModuleStatus;
54
use RobinTheHood\ModifiedModuleLoaderClient\Category;
6-
use RobinTheHood\ModifiedModuleLoaderClient\Notification;
5+
use RobinTheHood\ModifiedModuleLoaderClient\ModuleSorter;
76
use RobinTheHood\ModifiedModuleLoaderClient\ViewModels\NotificationViewModel;
87

98
$notificationView = new NotificationViewModel();
@@ -35,10 +34,24 @@
3534
<h2><?= Category::getCategoryName($category); ?></h2>
3635
<div class="category">
3736
<?php
37+
$modules = ModuleSorter::sortByDate($modules);
3838
foreach ($modules as $module) {
3939
if ($module->getVisibility() == 'hidden') {
4040
continue;
4141
}
42+
if (!$module->isCompatible()) {
43+
continue;
44+
}
45+
include 'ModuleListingModule.tmpl.php';
46+
}
47+
48+
foreach ($modules as $module) {
49+
if ($module->getVisibility() == 'hidden') {
50+
continue;
51+
}
52+
if ($module->isCompatible()) {
53+
continue;
54+
}
4255
include 'ModuleListingModule.tmpl.php';
4356
}
4457
?>

tests/acceptance.suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ actor: AcceptanceTester
88
modules:
99
enabled:
1010
- PhpBrowser:
11-
url: http://modified.localhost/ModifiedModuleLoaderClient/
11+
url: http://web/ModifiedModuleLoaderClient/
1212
- \Helper\Acceptance
1313
step_decorators: ~

tests/unit/DependencyManager/DependencyBuilderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testSatisfies1()
3030
$systemSet->set([
3131
"modified" => '2.0.4.2',
3232
"php" => '7.4.0',
33-
"mmlc" => '1.20.0-beta.1',
33+
"mmlc" => '1.21.0',
3434
"composer/autoload" => '1.3.0',
3535
"robinthehood/modified-std-module" => '0.9.0',
3636
"robinthehood/modified-orm" => '1.8.1',
@@ -44,7 +44,7 @@ public function testSatisfies1()
4444
[
4545
"modified" => '2.0.4.2',
4646
"php" => '7.4.0',
47-
"mmlc" => '1.20.0-beta.1',
47+
"mmlc" => '1.21.0',
4848
"composer/autoload" => '1.3.0',
4949
"robinthehood/modified-std-module" => '0.9.0',
5050
"robinthehood/modified-orm" => '1.8.1',
@@ -80,7 +80,7 @@ public function testSatisfies2()
8080
$systemSet->set([
8181
"modified" => '2.0.4.2',
8282
"php" => '7.4.0',
83-
"mmlc" => '1.20.0-beta.1',
83+
"mmlc" => '1.21.0',
8484
"composer/autoload" => '1.3.0',
8585
"robinthehood/modified-std-module" => '0.9.0',
8686
"robinthehood/modified-orm" => '1.8.1',
@@ -94,7 +94,7 @@ public function testSatisfies2()
9494
[
9595
"modified" => '2.0.4.2',
9696
"php" => '7.4.0',
97-
"mmlc" => '1.20.0-beta.1',
97+
"mmlc" => '1.21.0',
9898
"composer/autoload" => '1.3.0',
9999
"robinthehood/modified-std-module" => '0.9.0',
100100
"robinthehood/modified-orm" => '1.8.1',

tests/unit/ModuleLoaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ public function testCanLoadAllVersionsByContraint()
7979

8080
// tests for version >=1.0.0
8181
$modules = $this->loader->loadAllByArchiveNameAndConstraint('composer/autoload', '^1.2.0');
82-
$this->assertEquals(4, count($modules));
82+
$this->assertEquals(5, count($modules));
8383
$this->assertEquals('1.2.0', $modules[0]->getVersion());
8484
$this->assertEquals('1.2.1', $modules[1]->getVersion());
8585
$this->assertEquals('1.2.2', $modules[2]->getVersion());
8686
$this->assertEquals('1.3.0', $modules[3]->getVersion());
87+
$this->assertEquals('1.4.0', $modules[4]->getVersion());
8788
}
8889
}

tests/unit/RemoteModuleLoaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testCanLoadLatestVersionByArchiveName()
7474
$module = $this->loader->loadLatestVersionByArchiveName('composer/autoload');
7575

7676
$this->assertEquals('composer/autoload', $module->getArchiveName());
77-
$this->assertEquals('1.3.0', $module->getVersion());
77+
$this->assertEquals('1.4.0', $module->getVersion());
7878
}
7979

8080
public function testCanLoadByArchiveNameAndVersion()

0 commit comments

Comments
 (0)