1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2019 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\Module; 21 22use Fisharebest\Webtrees\Tree; 23use Psr\Http\Message\ServerRequestInterface; 24 25/** 26 * Interface ModuleBlockInterface - Classes and libraries for module system 27 */ 28interface ModuleBlockInterface extends ModuleInterface 29{ 30 // Places we can display blocks 31 public const CONTEXT_EMBED = 'embed'; 32 public const CONTEXT_TREE_PAGE = 'tree'; 33 public const CONTEXT_USER_PAGE = 'user'; 34 35 /** 36 * Generate the HTML content of this block. 37 * 38 * @param Tree $tree 39 * @param int $block_id 40 * @param string $context 41 * @param array $config 42 * 43 * @return string 44 */ 45 public function getBlock(Tree $tree, int $block_id, string $context, array $config = []): string; 46 47 /** 48 * Should this block load asynchronously using AJAX? 49 * 50 * Simple blocks are faster in-line, more complex ones can be loaded later. 51 * 52 * @return bool 53 */ 54 public function loadAjax(): bool; 55 56 /** 57 * Can this block be shown on the user’s home page? 58 * 59 * @return bool 60 */ 61 public function isUserBlock(): bool; 62 63 /** 64 * Can this block be shown on the tree’s home page? 65 * 66 * @return bool 67 */ 68 public function isTreeBlock(): bool; 69 70 /** 71 * An HTML form to edit block settings 72 * 73 * @param Tree $tree 74 * @param int $block_id 75 * 76 * @return string 77 */ 78 public function editBlockConfiguration(Tree $tree, int $block_id): string; 79 80 /** 81 * Update the configuration for a block. 82 * 83 * @param ServerRequestInterface $request 84 * @param int $block_id 85 * 86 * @return void 87 */ 88 public function saveBlockConfiguration(ServerRequestInterface $request, int $block_id): void; 89} 90