. */ /** * Class StoriesModule */ class StoriesModule extends Module 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.'); } /** {@inheritdoc} */ 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; $block_ids = Database::prepare( "SELECT block_id" . " FROM `##block`" . " WHERE module_name=?" . " AND xref=?" . " AND gedcom_id=?" )->execute(array( $this->getName(), $controller->record->getXref(), WT_GED_ID ))->fetchOneColumn(); $html = ''; foreach ($block_ids as $block_id) { // Only show this block for certain languages $languages = get_block_setting($block_id, 'languages'); if (!$languages || in_array(WT_LOCALE, explode(',', $languages))) { $html .= '
'; echo I18N::translate('Story title'); echo ' |
---|
'; echo I18N::translate('Story'); echo ' |
'; echo ''; echo ' |
', I18N::translate('Individual'), ' | '; echo '', I18N::translate('Show this block for which languages?'), ' | '; echo '
---|---|
'; echo ''; echo print_findindi_link('pid'); if ($xref) { $person = Individual::getInstance($xref); if ($person) { echo ' ', $person->format_list('span'); } } echo ' | '; $languages = explode(',', get_block_setting($block_id, 'languages')); echo ''; echo edit_language_checkboxes('lang', $languages); echo ' |
'; echo '
'; echo ''; } } else { header('Location: ' . WT_BASE_URL); } } /** * Respond to a request to delete a story. */ private function delete() { if (WT_USER_CAN_EDIT) { $block_id = Filter::getInteger('block_id'); Database::prepare( "DELETE FROM `##block_setting` WHERE block_id=?" )->execute(array($block_id)); Database::prepare( "DELETE FROM `##block` WHERE block_id=?" )->execute(array($block_id)); } else { header('Location: ' . WT_BASE_URL); exit; } } /** * The admin view - list, create, edit, delete stories. */ private function config() { $controller = new PageController; $controller ->restrictAccess(WT_USER_GEDCOM_ADMIN) ->setPageTitle($this->getTitle()) ->pageHeader() ->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL) ->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL) ->addInlineJavascript(' jQuery("#story_table").dataTable({ ' . I18N::datatablesI18N() . ', autoWidth: false, paging: true, pagingType: "full_numbers", lengthChange: true, filter: true, info: true, sorting: [[0,"asc"]], columns: [ /* 0-name */ null, /* 1-NAME */ null, /* 2-NAME */ { sortable:false }, /* 3-NAME */ { sortable:false } ] }); '); $stories = Database::prepare( "SELECT block_id, xref" . " FROM `##block` b" . " WHERE module_name=?" . " AND gedcom_id=?" . " ORDER BY xref" )->execute(array($this->getName(), WT_GED_ID))->fetchAll(); ?>block_id, 'title')); ?> | xref)): ?> getFullName(); ?> xref; ?> |
|
|
', I18N::translate('Story title'), ' | ', I18N::translate('Individual'), ' |
---|---|
' . $story_title . ' | ' . $indi->getFullName() . ' |
', $story_title, ' | ', $story->xref, ' |