Permalink
Browse files

Turn template into view

  • Loading branch information...
JustCarmen committed Oct 2, 2018
1 parent 9aae6bb commit 1530f82e193c442c62a2e5cb6b29252874f9d895
Showing with 47 additions and 94 deletions.
  1. +0 −67 app/Template/AdminTemplate.php
  2. +22 −27 module.php
  3. +25 −0 resources/views/admin.php

This file was deleted.

Oops, something went wrong.
@@ -15,32 +15,21 @@
*/
namespace JustCarmen\WebtreesAddOns\FancyBranches;
use Composer\Autoload\ClassLoader;
use Fisharebest\Webtrees\Filter;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Log;
use Fisharebest\Webtrees\Module\AbstractModule;
use Fisharebest\Webtrees\Module\ModuleConfigInterface;
use Fisharebest\Webtrees\Module\ModuleMenuInterface;
use Fisharebest\Webtrees\Tree;
use JustCarmen\WebtreesAddOns\FancyBranches\Template\AdminTemplate;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class FancyBranchesModule extends AbstractModule implements ModuleConfigInterface, ModuleMenuInterface {
const CUSTOM_VERSION = '2.0.0-dev';
const CUSTOM_WEBSITE = 'http://www.justcarmen.nl/fancy-modules/fancy-branches/';
/** @var string location of the fancy treeview module files */
public $directory;
public function __construct() {
parent::__construct('fancy_branches');
$this->directory = WT_MODULES_DIR . $this->getName();
// register the namespaces - is this neccessary since we don't have an extra class in this module?
$loader = new ClassLoader();
$loader->addPsr4('JustCarmen\\WebtreesAddOns\\FancyBranches\\', WT_MODULES_DIR . $this->getName() . '/app');
$loader->register();
}
/** {@inheritdoc} */
@@ -115,20 +104,26 @@ public function getMenu(Tree $tree) {
return null;
}
// Extend ModuleConfigInterface
public function modAction($mod_action) {
switch ($mod_action) {
case 'admin_config':
if (Filter::postBool('save') && Filter::checkCsrf()) {
$this->setPreference('FB', Filter::postInteger('NEW_FB'));
Log::addConfigurationLog($this->getTitle() . ' config updated');
}
$template = new AdminTemplate;
return $template->pageContent();
default:
http_response_code(404);
break;
/** {@inheritdoc} */
public function getAdminAction(): Response {
$this->layout = 'layouts/administration';
return $this->viewResponse('admin', [
'use_d_aboville' => $this->getPreference('FB'),
'title' => $this->getTitle()
]);
}
/** {@inheritdoc} */
public function postAdminAction(Request $request): RedirectResponse {
$use_d_aboville = (bool) $request->get('NEW_FB');
$this->setPreference('FB', $use_d_aboville);
$url = route('module', [
'module' => 'fancy_branches',
'action' => 'Admin'
]);
return new RedirectResponse($url);
}
/**
@@ -0,0 +1,25 @@
<?php use Fisharebest\Webtrees\Bootstrap4; ?>
<?php use Fisharebest\Webtrees\Functions\FunctionsEdit; ?>
<?php use Fisharebest\Webtrees\I18N; ?>

<?= view('components/breadcrumbs', ['links' => [route('admin-control-panel') => I18N::translate('Control panel'), route('admin-modules') => I18N::translate('Modules'), $title]]) ?>

<h1><?= $title ?></h1>

<form action="<?= e(route('module', ['module' => 'fancy_branches', 'action' => 'Admin'])) ?>" method="post">
<?= csrf_field() ?>
<div class="row form-group">
<label class="col-sm-4">
<?= I18N::translate('Use “d’Aboville” numbering system') ?>
</label>
<div class="col-sm-8">
<?= Bootstrap4::radioButtons('NEW_FB', FunctionsEdit::optionsNoYes(), $use_d_aboville, true) ?>
<p class="small text-muted"><?= I18N::translate('The “D’aboville” numbering system is a method to split descending generations into numbering sections. Each generation and each child gets a succeeding number seperated by a dot.') ?></p>
</div>
</div>
<button class="btn btn-primary" type="submit">
<i class="fa fa-check"></i>
<?= I18N::translate('save') ?>
</button>
</form>
<p>

0 comments on commit 1530f82

Please sign in to comment.