diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2019-01-22 18:51:23 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2019-01-22 18:51:23 +0000 |
| commit | 677aaceaa3f30bf689cca08894f5a34cdf4056b6 (patch) | |
| tree | 0b3077dc2b5f00c2ba425d57b54205e76fcfa3d8 | |
| parent | eca4a663f165bdb661e38d8684adc333ae7fdc22 (diff) | |
| download | webtrees-677aaceaa3f30bf689cca08894f5a34cdf4056b6.tar.gz webtrees-677aaceaa3f30bf689cca08894f5a34cdf4056b6.tar.bz2 webtrees-677aaceaa3f30bf689cca08894f5a34cdf4056b6.zip | |
Cleaning up
| -rw-r--r-- | app/Http/Controllers/ReportEngineController.php | 2 | ||||
| -rw-r--r-- | app/Module/ChartsBlockModule.php | 48 | ||||
| -rw-r--r-- | app/Module/DescendancyChartModule.php | 14 | ||||
| -rw-r--r-- | app/Module/ModuleConfigTrait.php | 5 | ||||
| -rw-r--r-- | app/Module/PedigreeChartModule.php | 8 | ||||
| -rw-r--r-- | resources/views/admin/module-components.phtml | 2 | ||||
| -rw-r--r-- | resources/views/admin/modules.phtml | 4 | ||||
| -rw-r--r-- | resources/views/edit-blocks-page.phtml | 4 | ||||
| -rw-r--r-- | resources/views/individual-page.phtml | 10 |
9 files changed, 52 insertions, 45 deletions
diff --git a/app/Http/Controllers/ReportEngineController.php b/app/Http/Controllers/ReportEngineController.php index 8770b6a633..41c294e27e 100644 --- a/app/Http/Controllers/ReportEngineController.php +++ b/app/Http/Controllers/ReportEngineController.php @@ -289,7 +289,7 @@ class ReportEngineController extends AbstractBaseController $reports = []; foreach (Module::activeReports($tree) as $report) { - $reports[$report->getName()] = $report->title(); + $reports[$report->name()] = $report->title(); } return $reports; diff --git a/app/Module/ChartsBlockModule.php b/app/Module/ChartsBlockModule.php index 4833c885cb..e7c511475e 100644 --- a/app/Module/ChartsBlockModule.php +++ b/app/Module/ChartsBlockModule.php @@ -18,9 +18,9 @@ declare(strict_types=1); namespace Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Auth; -use Fisharebest\Webtrees\Http\Controllers\PedigreeChartController; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Individual; +use Fisharebest\Webtrees\Module; use Fisharebest\Webtrees\Module\InteractiveTree\TreeView; use Fisharebest\Webtrees\Tree; use Symfony\Component\HttpFoundation\Request; @@ -84,53 +84,55 @@ class ChartsBlockModule extends AbstractModule implements ModuleInterface, Modul $title = $this->title(); if ($person) { - $content = ''; switch ($type) { + default: case 'pedigree': - $title = I18N::translate('Pedigree of %s', $person->getFullName()); - $chart_url = route('pedigree-chart', [ - 'xref' => $person->xref(), - 'ged' => $person->tree()->name(), + $module = Module::getModuleByClassName(PedigreeChartModule::class); + $title = $module->chartTitle($person); + $chart_url = $module->chartUrl($person, [ + 'ajax' => '1', 'generations' => 3, - 'layout' => PedigreeChartController::PORTRAIT, + 'layout' => PedigreeChartModule::PORTRAIT, ]); - $content = view('modules/charts/chart', [ + $content = view('modules/charts/chart', [ 'block_id' => $block_id, 'chart_url' => $chart_url, ]); break; + case 'descendants': - $title = I18N::translate('Descendants of %s', $person->getFullName()); - $chart_url = route('descendants-chart', [ - 'xref' => $person->xref(), - 'ged' => $person->tree()->name(), + $module = Module::getModuleByClassName(DescendancyChartModule::class); + $title = $module->chartTitle($person); + $chart_url = $module->chartUrl($person, [ + 'ajax' => '1', 'generations' => 2, - 'chart_style' => 0, + 'chart_style' => DescendancyChartModule::CHART_STYLE_LIST, ]); - $content = view('modules/charts/chart', [ + $content = view('modules/charts/chart', [ 'block_id' => $block_id, 'chart_url' => $chart_url, ]); break; + case 'hourglass': - $title = I18N::translate('Hourglass chart of %s', $person->getFullName()); - $chart_url = route('hourglass-chart', [ - 'xref' => $person->xref(), - 'ged' => $person->tree()->name(), + $module = Module::getModuleByClassName(HourglassChartModule::class); + $title = $module->chartTitle($person); + $chart_url = $module->chartUrl($person, [ + 'ajax' => '1', 'generations' => 2, - 'layout' => PedigreeChartController::PORTRAIT, ]); - $content = view('modules/charts/chart', [ + $content = view('modules/charts/chart', [ 'block_id' => $block_id, 'chart_url' => $chart_url, ]); break; + case 'treenav': + $module = Module::getModuleByClassName(InteractiveTreeModule::class); $title = I18N::translate('Interactive tree of %s', $person->getFullName()); - $mod = new InteractiveTreeModule(); $tv = new TreeView(); - $content .= '<script>$("head").append(\'<link rel="stylesheet" href="' . $mod->css() . '" type="text/css" />\');</script>'; - $content .= '<script src="' . $mod->js() . '"></script>'; + $content = '<script>$("head").append(\'<link rel="stylesheet" href="' . $module->css() . '" type="text/css" />\');</script>'; + $content .= '<script src="' . $module->js() . '"></script>'; [$html, $js] = $tv->drawViewport($person, 2); $content .= $html . '<script>' . $js . '</script>'; break; diff --git a/app/Module/DescendancyChartModule.php b/app/Module/DescendancyChartModule.php index 4d18a2f567..9fdaf31986 100644 --- a/app/Module/DescendancyChartModule.php +++ b/app/Module/DescendancyChartModule.php @@ -43,15 +43,15 @@ class DescendancyChartModule extends AbstractModule implements ModuleInterface, use ModuleChartTrait; // Chart styles - private const CHART_STYLE_LIST = 0; - private const CHART_STYLE_BOOKLET = 1; - private const CHART_STYLE_INDIVIDUALS = 2; - private const CHART_STYLE_FAMILIES = 3; + public const CHART_STYLE_LIST = 0; + public const CHART_STYLE_BOOKLET = 1; + public const CHART_STYLE_INDIVIDUALS = 2; + public const CHART_STYLE_FAMILIES = 3; // Defaults - private const DEFAULT_STYLE = self::CHART_STYLE_LIST; - private const DEFAULT_GENERATIONS = '3'; - private const DEFAULT_MAXIMUM_GENERATIONS = '9'; + public const DEFAULT_STYLE = self::CHART_STYLE_LIST; + public const DEFAULT_GENERATIONS = '3'; + public const DEFAULT_MAXIMUM_GENERATIONS = '9'; /** @var int[] */ protected $dabo_num = []; diff --git a/app/Module/ModuleConfigTrait.php b/app/Module/ModuleConfigTrait.php index 108aac42c7..fa04af13f1 100644 --- a/app/Module/ModuleConfigTrait.php +++ b/app/Module/ModuleConfigTrait.php @@ -23,6 +23,11 @@ namespace Fisharebest\Webtrees\Module; trait ModuleConfigTrait { /** + * @return string + */ + abstract public function name(): string; + + /** * The URL to a page where the user can modify the configuration of this module. * * @return string diff --git a/app/Module/PedigreeChartModule.php b/app/Module/PedigreeChartModule.php index 23eeb2bce9..f4b1c2b0d4 100644 --- a/app/Module/PedigreeChartModule.php +++ b/app/Module/PedigreeChartModule.php @@ -46,10 +46,10 @@ class PedigreeChartModule extends AbstractModule implements ModuleInterface, Mod * Chart orientation codes * Dont change them! the offset calculations rely on this order */ - protected const PORTRAIT = 0; - protected const LANDSCAPE = 1; - protected const OLDEST_AT_TOP = 2; - protected const OLDEST_AT_BOTTOM = 3; + public const PORTRAIT = 0; + public const LANDSCAPE = 1; + public const OLDEST_AT_TOP = 2; + public const OLDEST_AT_BOTTOM = 3; protected const DEFAULT_ORIENTATION = self::LANDSCAPE; diff --git a/resources/views/admin/module-components.phtml b/resources/views/admin/module-components.phtml index 1136c9f650..b11f2f748f 100644 --- a/resources/views/admin/module-components.phtml +++ b/resources/views/admin/module-components.phtml @@ -45,7 +45,7 @@ <?= e($tree->title()) ?> </td> <td> - <?= Bootstrap4::select(FunctionsEdit::optionsAccessLevels(), $module->accessLevel($tree, $component), ['name' => 'access-' . $module->getName() . '-' . $tree->id()]) ?> + <?= Bootstrap4::select(FunctionsEdit::optionsAccessLevels(), $module->accessLevel($tree, $component), ['name' => 'access-' . $module->name() . '-' . $tree->id()]) ?> </td> </tr> <?php endforeach ?> diff --git a/resources/views/admin/modules.phtml b/resources/views/admin/modules.phtml index e4daf64ffd..008809e135 100644 --- a/resources/views/admin/modules.phtml +++ b/resources/views/admin/modules.phtml @@ -97,11 +97,11 @@ <?php endif ?> </th> <td class="text-center" data-sort="<?= $module->isEnabled() ?>"> - <?= Bootstrap4::checkbox('', false, ['name' => 'status-' . $module->getName(), 'checked' => $module->isEnabled()]) ?> + <?= Bootstrap4::checkbox('', false, ['name' => 'status-' . $module->name(), 'checked' => $module->isEnabled()]) ?> </td> <td class="d-none d-sm-table-cell"> <?= $module->description() ?> - <?php if (!in_array($module->getName(), $core_module_names)) : ?> + <?php if (!in_array($module->name(), $core_module_names)) : ?> <br> <?= view('icons/warning') ?> <?= I18N::translate('Custom module') ?> diff --git a/resources/views/edit-blocks-page.phtml b/resources/views/edit-blocks-page.phtml index bdb06dfddd..615d224f93 100644 --- a/resources/views/edit-blocks-page.phtml +++ b/resources/views/edit-blocks-page.phtml @@ -167,7 +167,7 @@ <select multiple="multiple" id="main_select" name="main[]" size="10" onchange="show_description('main_select');"> <?php foreach ($main_blocks as $block_id => $block) : ?> <option value="<?= $block_id ?>"> - <?= $all_blocks[$block->getName()]->title() ?> + <?= $all_blocks[$block->name()]->title() ?> </option> <?php endforeach ?> </select> @@ -191,7 +191,7 @@ <select multiple="multiple" id="side_select" name="side[]" size="10" onchange="show_description('side_select');"> <?php foreach ($side_blocks as $block_id => $block) : ?> <option value="<?= $block_id ?>"> - <?= $all_blocks[$block->getName()]->title() ?> + <?= $all_blocks[$block->name()]->title() ?> </option> <?php endforeach ?> </select> diff --git a/resources/views/individual-page.phtml b/resources/views/individual-page.phtml index 1fbebc4b23..17c65f1218 100644 --- a/resources/views/individual-page.phtml +++ b/resources/views/individual-page.phtml @@ -97,7 +97,7 @@ <ul class="nav nav-tabs flex-wrap"> <?php foreach ($tabs as $tab) : ?> <li class="nav-item"> - <a class="nav-link<?= $tab->isGrayedOut($individual) ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" data-href="<?= e(route('individual-tab', ['xref' => $individual->xref(), 'ged' => $individual->tree()->name(), 'module' => $tab->getName()])) ?>" href="#<?= $tab->getName() ?>"> + <a class="nav-link<?= $tab->isGrayedOut($individual) ? ' text-muted' : '' ?>" data-toggle="tab" role="tab" data-href="<?= e(route('individual-tab', ['xref' => $individual->xref(), 'ged' => $individual->tree()->name(), 'module' => $tab->name()])) ?>" href="#<?= $tab->name() ?>"> <?= $tab->title() ?> </a> </li> @@ -105,7 +105,7 @@ </ul> <div class="tab-content"> <?php foreach ($tabs as $tab) : ?> - <div id="<?= $tab->getName() ?>" class="tab-pane fade wt-ajax-load" role="tabpanel"><?php if (!$tab->canLoadAjax()) : + <div id="<?= $tab->name() ?>" class="tab-pane fade wt-ajax-load" role="tabpanel"><?php if (!$tab->canLoadAjax()) : ?><?= $tab->getTabContent($individual) ?><?php endif ?></div> <?php endforeach ?> @@ -115,14 +115,14 @@ <div class="col-sm-4" id="sidebar" role="tablist"> <?php foreach ($sidebars as $sidebar) : ?> <div class="card"> - <div class="card-header" role="tab" id="sidebar-header-<?= $sidebar->getName() ?>"> + <div class="card-header" role="tab" id="sidebar-header-<?= $sidebar->name() ?>"> <div class="card-title mb-0"> - <a data-toggle="collapse" data-parent="#sidebar" href="#sidebar-content-<?= $sidebar->getName() ?>" aria-expanded="<?= $sidebar->getName() === 'family_nav' ? 'true' : 'false' ?>" aria-controls="sidebar-content-<?= $sidebar->getName() ?>"> + <a data-toggle="collapse" data-parent="#sidebar" href="#sidebar-content-<?= $sidebar->name() ?>" aria-expanded="<?= $sidebar->name() === 'family_nav' ? 'true' : 'false' ?>" aria-controls="sidebar-content-<?= $sidebar->name() ?>"> <?= $sidebar->title() ?> </a> </div> </div> - <div id="sidebar-content-<?= $sidebar->getName() ?>" class="collapse<?= $sidebar->getName() === 'family_nav' ? ' show' : '' ?>" role="tabpanel" aria-labelledby="sidebar-header-<?= $sidebar->getName() ?>"> + <div id="sidebar-content-<?= $sidebar->name() ?>" class="collapse<?= $sidebar->name() === 'family_nav' ? ' show' : '' ?>" role="tabpanel" aria-labelledby="sidebar-header-<?= $sidebar->name() ?>"> <div class="card-body"> <?= $sidebar->getSidebarContent($individual) ?></div> </div> |
