summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Http/Controllers/AdminSiteController.php44
-rw-r--r--app/Http/RequestHandlers/PhpInformation.php63
-rw-r--r--resources/views/admin/control-panel-tree-list.phtml105
-rw-r--r--resources/views/admin/control-panel.phtml119
-rw-r--r--resources/views/admin/trees-preferences.phtml2
-rw-r--r--routes/web.php3
6 files changed, 179 insertions, 157 deletions
diff --git a/app/Http/Controllers/AdminSiteController.php b/app/Http/Controllers/AdminSiteController.php
index 5ebbb56a7e..42b50d73a1 100644
--- a/app/Http/Controllers/AdminSiteController.php
+++ b/app/Http/Controllers/AdminSiteController.php
@@ -28,9 +28,11 @@ use Fisharebest\Webtrees\Module\ModuleThemeInterface;
use Fisharebest\Webtrees\Services\DatatablesService;
use Fisharebest\Webtrees\Services\MailService;
use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
use Fisharebest\Webtrees\Services\UserService;
use Fisharebest\Webtrees\Site;
use Fisharebest\Webtrees\Tree;
+use Fisharebest\Webtrees\User;
use Illuminate\Database\Capsule\Manager as DB;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\Expression;
@@ -64,6 +66,9 @@ class AdminSiteController extends AbstractBaseController
/** @var ModuleService */
private $module_service;
+ /** @var TreeService */
+ private $tree_service;
+
/** @var UserService */
private $user_service;
@@ -76,12 +81,13 @@ class AdminSiteController extends AbstractBaseController
* @param ModuleService $module_service
* @param UserService $user_service
*/
- public function __construct(DatatablesService $datatables_service, FilesystemInterface $filesystem, MailService $mail_service, ModuleService $module_service, UserService $user_service)
+ public function __construct(DatatablesService $datatables_service, FilesystemInterface $filesystem, MailService $mail_service, ModuleService $module_service, TreeService $tree_service, UserService $user_service)
{
$this->mail_service = $mail_service;
$this->datatables_service = $datatables_service;
$this->filesystem = $filesystem;
$this->module_service = $module_service;
+ $this->tree_service = $tree_service;
$this->user_service = $user_service;
}
@@ -106,7 +112,7 @@ class AdminSiteController extends AbstractBaseController
}
// Protect the media folders
- foreach (Tree::getAll() as $tree) {
+ foreach ($this->tree_service->all() as $tree) {
$media_directory = $tree->getPreference('MEDIA_DIRECTORY');
[$folder] = explode('/', $media_directory);
@@ -198,12 +204,15 @@ class AdminSiteController extends AbstractBaseController
$from = max($from, $earliest);
$to = min(max($from, $to), $latest);
- $user_options = ['' => ''];
- foreach ($this->user_service->all() as $tmp_user) {
- $user_options[$tmp_user->userName()] = $tmp_user->userName();
- }
+ $user_options = $this->user_service->all()->mapWithKeys(static function (User $user): array {
+ return [$user->userName() => $user->userName()];
+ });
+ $user_options = (new Collection(['' => '']))->merge($user_options);
- $tree_options = ['' => ''] + Tree::getNameList();
+ $tree_options = $this->tree_service->all()->mapWithKeys(static function (Tree $tree): array {
+ return [$tree->name() => $tree->title()];
+ });
+ $tree_options = (new Collection(['' => '']))->merge($tree_options);
$title = I18N::translate('Website logs');
@@ -527,25 +536,4 @@ class AdminSiteController extends AbstractBaseController
return redirect($url);
}
-
- /**
- * Show the server information page.
- *
- * @param ServerRequestInterface $request
- *
- * @return ResponseInterface
- */
- public function serverInformation(ServerRequestInterface $request): ResponseInterface
- {
- ob_start();
- phpinfo(INFO_ALL & ~INFO_CREDITS & ~INFO_LICENSE);
- $phpinfo = ob_get_clean();
- preg_match('%<body>(.*)</body>%s', $phpinfo, $matches);
- $phpinfo = $matches[1];
-
- return $this->viewResponse('admin/server-information', [
- 'title' => I18N::translate('Server information'),
- 'phpinfo' => $phpinfo,
- ]);
- }
}
diff --git a/app/Http/RequestHandlers/PhpInformation.php b/app/Http/RequestHandlers/PhpInformation.php
new file mode 100644
index 0000000000..60d40c2183
--- /dev/null
+++ b/app/Http/RequestHandlers/PhpInformation.php
@@ -0,0 +1,63 @@
+<?php
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2019 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+declare(strict_types=1);
+
+namespace Fisharebest\Webtrees\Http\RequestHandlers;
+
+use Fisharebest\Webtrees\Http\ViewResponseTrait;
+use Fisharebest\Webtrees\I18N;
+use Psr\Http\Message\ResponseInterface;
+use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Server\RequestHandlerInterface;
+
+use function ob_get_clean;
+use function ob_start;
+use function phpinfo;
+use function preg_match;
+
+use const INFO_ALL;
+use const INFO_CREDITS;
+use const INFO_LICENSE;
+
+/**
+ * Show PHP information.
+ */
+class PhpInformation implements RequestHandlerInterface
+{
+ use ViewResponseTrait;
+
+ /**
+ * @param ServerRequestInterface $request
+ *
+ * @return ResponseInterface
+ */
+ public function handle(ServerRequestInterface $request): ResponseInterface
+ {
+ $this->layout = 'layouts/administration';
+
+ ob_start();
+ phpinfo(INFO_ALL & ~INFO_CREDITS & ~INFO_LICENSE);
+ $phpinfo = ob_get_clean();
+ preg_match('%<body>(.*)</body>%s', $phpinfo, $matches);
+ $phpinfo = $matches[1];
+
+ return $this->viewResponse('admin/server-information', [
+ 'title' => I18N::translate('Server information'),
+ 'phpinfo' => $phpinfo,
+ ]);
+ }
+}
diff --git a/resources/views/admin/control-panel-tree-list.phtml b/resources/views/admin/control-panel-tree-list.phtml
deleted file mode 100644
index acc0bb4b73..0000000000
--- a/resources/views/admin/control-panel-tree-list.phtml
+++ /dev/null
@@ -1,105 +0,0 @@
-<?php
-
-use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
-use Fisharebest\Webtrees\I18N;
-use Fisharebest\Webtrees\Module\FamilyListModule;
-use Fisharebest\Webtrees\Module\IndividualListModule;
-use Fisharebest\Webtrees\Module\MediaListModule;
-use Fisharebest\Webtrees\Module\NoteListModule;
-use Fisharebest\Webtrees\Module\RepositoryListModule;
-use Fisharebest\Webtrees\Module\SourceListModule;
-
-?>
-
-<?php foreach ($all_trees as $tree) : ?>
- <tr class="<?= $changes[$tree->id()] ? 'danger' : '' ?>">
- <th scope="row">
- <a href="<?= e(route('tree-page', ['tree' => $tree->name()])) ?>">
- <?= e($tree->name()) ?>
- -
- <?= e($tree->title()) ?>
- </a>
- </th>
- <td>
- <a href="<?= e(route('manage-trees', ['tree' => $tree->name()])) ?>" title="<?= I18N::translate('Manage family trees') ?>">
- <?= view('icons/preferences') ?>
- </a>
- </td>
- <td style="text-align: right;">
- <?php if ($changes[$tree->id()]) : ?>
- <a href="<?= e(route('show-pending', ['ged' => $tree->name(), 'url' => route(ControlPanel::class)])) ?>">
- <?= I18N::number($changes[$tree->id()]) ?>
- <span class="sr-only"><?= I18N::translate('Pending changes') ?> <?= e($tree->title()) ?></span>
- </a>
- <?php else : ?>
- -
- <?php endif ?>
- </td>
- <td class="d-none d-sm-table-cell align-digits">
- <?php if ($individuals[$tree->id()] > 0) : ?>
- <?php if ($individual_list_module instanceof IndividualListModule) : ?>
- <a href="<?= e($individual_list_module->listUrl($tree)) ?>"><?= I18N::number($individuals[$tree->id()]) ?></a>
- <?php else : ?>
- <?= I18N::number($individuals[$tree->id()]) ?>
- <?php endif ?>
- <?php else : ?>
- -
- <?php endif ?>
- </td>
- <td class="d-none d-lg-table-cell align-digits">
- <?php if ($families[$tree->id()] > 0) : ?>
- <?php if ($family_list_module instanceof FamilyListModule) : ?>
- <a href="<?= e($family_list_module->listUrl($tree)) ?>"><?= I18N::number($families[$tree->id()]) ?></a>
- <?php else : ?>
- <?= I18N::number($families[$tree->id()]) ?>
- <?php endif ?>
- <?php else : ?>
- -
- <?php endif ?>
- </td>
- <td class="d-none d-sm-table-cell align-digits">
- <?php if ($sources[$tree->id()] > 0) : ?>
- <?php if ($source_list_module instanceof SourceListModule) : ?>
- <a href="<?= e($source_list_module->listUrl($tree)) ?>"><?= I18N::number($sources[$tree->id()]) ?></a>
- <?php else : ?>
- <?= I18N::number($sources[$tree->id()]) ?>
- <?php endif ?>
- <?php else : ?>
- -
- <?php endif ?>
- </td>
- <td class="d-none d-lg-table-cell align-digits">
- <?php if ($repositories[$tree->id()] > 0) : ?>
- <?php if ($repository_list_module instanceof RepositoryListModule) : ?>
- <a href="<?= e($repository_list_module->listUrl($tree)) ?>"><?= I18N::number($repositories[$tree->id()]) ?></a>
- <?php else : ?>
- <?= I18N::number($repositories[$tree->id()]) ?>
- <?php endif ?>
- <?php else : ?>
- -
- <?php endif ?>
- </td>
- <td class="d-none d-sm-table-cell align-digits">
- <?php if ($media[$tree->id()] > 0) : ?>
- <?php if ($media_list_module instanceof MediaListModule) : ?>
- <a href="<?= e($media_list_module->listUrl($tree)) ?>"><?= I18N::number($media[$tree->id()]) ?></a>
- <?php else : ?>
- <?= I18N::number($media[$tree->id()]) ?>
- <?php endif ?>
- <?php else : ?>
- -
- <?php endif ?>
- </td>
- <td class="d-none d-lg-table-cell align-digits">
- <?php if ($notes[$tree->id()] > 0) : ?>
- <?php if ($note_list_module instanceof NoteListModule) : ?>
- <a href="<?= e($note_list_module->listUrl($tree)) ?>"><?= I18N::number($notes[$tree->id()]) ?></a>
- <?php else : ?>
- <?= I18N::number($notes[$tree->id()]) ?>
- <?php endif ?>
- <?php else : ?>
- -
- <?php endif ?>
- </td>
- </tr>
-<?php endforeach ?>
diff --git a/resources/views/admin/control-panel.phtml b/resources/views/admin/control-panel.phtml
index 35a78e3f80..5652653ffc 100644
--- a/resources/views/admin/control-panel.phtml
+++ b/resources/views/admin/control-panel.phtml
@@ -1,9 +1,17 @@
<?php
+use Fisharebest\Webtrees\Http\RequestHandlers\ControlPanel;
use Fisharebest\Webtrees\Http\RequestHandlers\CreateTreePage;
+use Fisharebest\Webtrees\Http\RequestHandlers\PhpInformation;
use Fisharebest\Webtrees\I18N;
+use Fisharebest\Webtrees\Module\FamilyListModule;
+use Fisharebest\Webtrees\Module\IndividualListModule;
+use Fisharebest\Webtrees\Module\MediaListModule;
use Fisharebest\Webtrees\Module\ModuleConfigInterface;
use Fisharebest\Webtrees\Module\ModuleCustomInterface;
+use Fisharebest\Webtrees\Module\NoteListModule;
+use Fisharebest\Webtrees\Module\RepositoryListModule;
+use Fisharebest\Webtrees\Module\SourceListModule;
use Fisharebest\Webtrees\Webtrees;
use Illuminate\Support\Collection;
@@ -94,7 +102,7 @@ use Illuminate\Support\Collection;
</li>
<li>
<span class="fa-li"><?= view('icons/preferences') ?></span>
- <a href="<?= e(route('admin-site-information')) ?>">
+ <a href="<?= e(route(PhpInformation::class)) ?>">
<?= I18N::translate('Server information') ?>
</a>
</li>
@@ -145,9 +153,6 @@ use Illuminate\Support\Collection;
<thead>
<tr>
<th><?= I18N::translate('Family tree') ?></th>
- <th>
- <span class="sr-only"><?= I18N::translate('Manage family trees') ?></span>
- </th>
<th><?= I18N::translate('Pending changes') ?></th>
<th class="d-none d-sm-table-cell"><?= I18N::translate('Individuals') ?></th>
<th class="d-none d-lg-table-cell"><?= I18N::translate('Families') ?></th>
@@ -158,29 +163,99 @@ use Illuminate\Support\Collection;
</tr>
</thead>
<tbody>
- <?= view('admin/control-panel-tree-list', [
- 'all_trees' => $all_trees,
- 'changes' => $changes,
- 'families' => $families,
- 'individuals' => $individuals,
- 'media' => $media,
- 'notes' => $notes,
- 'repositories' => $repositories,
- 'sources' => $sources,
- 'family_list_module' => $family_list_module,
- 'individual_list_module' => $individual_list_module,
- 'media_list_module' => $media_list_module,
- 'note_list_module' => $note_list_module,
- 'repository_list_module' => $repository_list_module,
- 'source_list_module' => $source_list_module,
- ]) ?>
- </tbody>
+ <?php foreach ($all_trees as $tree) : ?>
+ <tr class="<?= $changes[$tree->id()] ? 'danger' : '' ?>">
+ <th scope="row">
+ <a href="<?= e(route('manage-trees', ['tree' => $tree->name()])) ?>">
+ <?= view('icons/preferences') ?>
+ <?= e($tree->name()) ?>
+ -
+ <?= e($tree->title()) ?>
+ </a>
+ </th>
+ <td style="text-align: right;">
+ <?php if ($changes[$tree->id()]) : ?>
+ <a href="<?= e(route('show-pending', ['ged' => $tree->name(), 'url' => route(ControlPanel::class)])) ?>">
+ <?= I18N::number($changes[$tree->id()]) ?>
+ <span class="sr-only"><?= I18N::translate('Pending changes') ?> <?= e($tree->title()) ?></span>
+ </a>
+ <?php else : ?>
+ -
+ <?php endif ?>
+ </td>
+ <td class="d-none d-sm-table-cell align-digits">
+ <?php if ($individuals[$tree->id()] > 0) : ?>
+ <?php if ($individual_list_module instanceof IndividualListModule) : ?>
+ <a href="<?= e($individual_list_module->listUrl($tree)) ?>"><?= I18N::number($individuals[$tree->id()]) ?></a>
+ <?php else : ?>
+ <?= I18N::number($individuals[$tree->id()]) ?>
+ <?php endif ?>
+ <?php else : ?>
+ -
+ <?php endif ?>
+ </td>
+ <td class="d-none d-lg-table-cell align-digits">
+ <?php if ($families[$tree->id()] > 0) : ?>
+ <?php if ($family_list_module instanceof FamilyListModule) : ?>
+ <a href="<?= e($family_list_module->listUrl($tree)) ?>"><?= I18N::number($families[$tree->id()]) ?></a>
+ <?php else : ?>
+ <?= I18N::number($families[$tree->id()]) ?>
+ <?php endif ?>
+ <?php else : ?>
+ -
+ <?php endif ?>
+ </td>
+ <td class="d-none d-sm-table-cell align-digits">
+ <?php if ($sources[$tree->id()] > 0) : ?>
+ <?php if ($source_list_module instanceof SourceListModule) : ?>
+ <a href="<?= e($source_list_module->listUrl($tree)) ?>"><?= I18N::number($sources[$tree->id()]) ?></a>
+ <?php else : ?>
+ <?= I18N::number($sources[$tree->id()]) ?>
+ <?php endif ?>
+ <?php else : ?>
+ -
+ <?php endif ?>
+ </td>
+ <td class="d-none d-lg-table-cell align-digits">
+ <?php if ($repositories[$tree->id()] > 0) : ?>
+ <?php if ($repository_list_module instanceof RepositoryListModule) : ?>
+ <a href="<?= e($repository_list_module->listUrl($tree)) ?>"><?= I18N::number($repositories[$tree->id()]) ?></a>
+ <?php else : ?>
+ <?= I18N::number($repositories[$tree->id()]) ?>
+ <?php endif ?>
+ <?php else : ?>
+ -
+ <?php endif ?>
+ </td>
+ <td class="d-none d-sm-table-cell align-digits">
+ <?php if ($media[$tree->id()] > 0) : ?>
+ <?php if ($media_list_module instanceof MediaListModule) : ?>
+ <a href="<?= e($media_list_module->listUrl($tree)) ?>"><?= I18N::number($media[$tree->id()]) ?></a>
+ <?php else : ?>
+ <?= I18N::number($media[$tree->id()]) ?>
+ <?php endif ?>
+ <?php else : ?>
+ -
+ <?php endif ?>
+ </td>
+ <td class="d-none d-lg-table-cell align-digits">
+ <?php if ($notes[$tree->id()] > 0) : ?>
+ <?php if ($note_list_module instanceof NoteListModule) : ?>
+ <a href="<?= e($note_list_module->listUrl($tree)) ?>"><?= I18N::number($notes[$tree->id()]) ?></a>
+ <?php else : ?>
+ <?= I18N::number($notes[$tree->id()]) ?>
+ <?php endif ?>
+ <?php else : ?>
+ -
+ <?php endif ?>
+ </td>
+ </tr>
+ <?php endforeach ?> </tbody>
<tfoot>
<tr>
<th scope="row">
<?= I18N::translate('Total') ?>
</th>
- <td></td>
<td class="align-digits">
<?= I18N::number(array_sum($changes)) ?>
</td>
diff --git a/resources/views/admin/trees-preferences.phtml b/resources/views/admin/trees-preferences.phtml
index 8182904cfc..5422fb9531 100644
--- a/resources/views/admin/trees-preferences.phtml
+++ b/resources/views/admin/trees-preferences.phtml
@@ -10,7 +10,7 @@ use Fisharebest\Webtrees\I18N;
<h1><?= $title ?></h1>
-<form method="post" action="<?= e(route('admin-trees-preferences-update')) ?>" class="form-horizontal">
+<form method="post" action="<?= e(route('admin-trees-preferences-update', ['tree' => $tree->name()])) ?>" class="form-horizontal">
<?= csrf_field() ?>
<h3><?= I18N::translate('General') ?></h3>
diff --git a/routes/web.php b/routes/web.php
index 2d771f2c05..de038bf035 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -36,6 +36,7 @@ use Fisharebest\Webtrees\Http\RequestHandlers\DeleteTreeAction;
use Fisharebest\Webtrees\Http\RequestHandlers\DeleteUser;
use Fisharebest\Webtrees\Http\RequestHandlers\HelpText;
use Fisharebest\Webtrees\Http\RequestHandlers\HomePage;
+use Fisharebest\Webtrees\Http\RequestHandlers\PhpInformation;
use Fisharebest\Webtrees\Http\RequestHandlers\RedirectFamilyPhp;
use Fisharebest\Webtrees\Http\RequestHandlers\RedirectGedRecordPhp;
use Fisharebest\Webtrees\Http\RequestHandlers\RedirectIndividualPhp;
@@ -142,12 +143,12 @@ $router->attach('', '/admin', static function (Map $router) {
$router->get('broadcast', '/broadcast', 'MessageController::broadcastPage');
$router->post('broadcast-action', '/broadcast', 'MessageController::broadcastAction');
+ $router->get(PhpInformation::class, '/information', PhpInformation::class);
$router->post('masquerade', '/masquerade/{user_id}', MasqueradeAsUser::class);
$router->get('admin-site-logs', '/logs', 'AdminSiteController::logs');
$router->get('admin-site-logs-data', '/logs-data', 'AdminSiteController::logsData');
$router->post('admin-site-logs-delete', '/logs-delete', 'AdminSiteController::logsDelete');
$router->get('admin-site-logs-export', '/logs-export', 'AdminSiteController::logsExport');
- $router->get('admin-site-information', '/information', 'AdminSiteController::serverInformation');
$router->get(CreateTreePage::class, '/trees/create', CreateTreePage::class);
$router->post(CreateTreeAction::class, '/trees/create', CreateTreeAction::class);
$router->get('tree-page-default-edit', '/trees/default-blocks', 'HomePageController::treePageDefaultEdit');