.
*/
namespace Fisharebest\Webtrees\Module;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Controller\PageController;
use Fisharebest\Webtrees\Database;
use Fisharebest\Webtrees\Filter;
use Fisharebest\Webtrees\Functions\FunctionsEdit;
use Fisharebest\Webtrees\Functions\FunctionsPrint;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Menu;
use Fisharebest\Webtrees\Module;
use Fisharebest\Webtrees\Tree;
/**
* Class StoriesModule
*/
class StoriesModule extends AbstractModule implements ModuleTabInterface, ModuleConfigInterface, ModuleMenuInterface {
/** {@inheritdoc} */
public function getTitle() {
return /* I18N: Name of a module */ I18N::translate('Stories');
}
/** {@inheritdoc} */
public function getDescription() {
return /* I18N: Description of the “Stories” module */ I18N::translate('Add narrative stories to individuals in the family tree.');
}
/**
* This is a general purpose hook, allowing modules to respond to routes
* of the form module.php?mod=FOO&mod_action=BAR
*
* @param string $mod_action
*/
public function modAction($mod_action) {
switch ($mod_action) {
case 'admin_edit':
$this->edit();
break;
case 'admin_delete':
$this->delete();
$this->config();
break;
case 'admin_config':
$this->config();
break;
case 'show_list':
$this->showList();
break;
default:
http_response_code(404);
}
}
/** {@inheritdoc} */
public function getConfigLink() {
return 'module.php?mod=' . $this->getName() . '&mod_action=admin_config';
}
/** {@inheritdoc} */
public function defaultTabOrder() {
return 55;
}
/** {@inheritdoc} */
public function getTabContent() {
global $controller, $WT_TREE;
$block_ids =
Database::prepare(
"SELECT block_id" .
" FROM `##block`" .
" WHERE module_name=?" .
" AND xref=?" .
" AND gedcom_id=?"
)->execute(array(
$this->getName(),
$controller->record->getXref(),
$controller->record->getTree()->getTreeId(),
))->fetchOneColumn();
$html = '';
foreach ($block_ids as $block_id) {
// Only show this block for certain languages
$languages = $this->getBlockSetting($block_id, 'languages');
if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) {
$html .= '
';
}
}
/**
* The user can re-order menus. Until they do, they are shown in this order.
*
* @return int
*/
public function defaultMenuOrder() {
return 30;
}
/**
* What is the default access level for this module?
*
* Some modules are aimed at admins or managers, and are not generally shown to users.
*
* @return int
*/
public function defaultAccessLevel() {
return Auth::PRIV_HIDE;
}
/**
* A menu, to be added to the main application menu.
*
* @return Menu|null
*/
public function getMenu() {
if (Auth::isSearchEngine()) {
return null;
}
$menu = new Menu($this->getTitle(), 'module.php?mod=' . $this->getName() . '&mod_action=show_list', 'menu-story');
return $menu;
}
}