diff options
Diffstat (limited to 'modules_v3/gedcom_news/module.php')
| -rw-r--r-- | modules_v3/gedcom_news/module.php | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/modules_v3/gedcom_news/module.php b/modules_v3/gedcom_news/module.php index 313f4a6389..b8e34859cb 100644 --- a/modules_v3/gedcom_news/module.php +++ b/modules_v3/gedcom_news/module.php @@ -1,6 +1,6 @@ <?php // webtrees: Web based Family History software -// Copyright (C) 2014 webtrees development team. +// Copyright (C) 2015 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -20,13 +20,16 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA use WT\Auth; +use WT\Theme; // Create tables, if not already present try { WT_DB::updateSchema(WT_ROOT . WT_MODULES_DIR . 'gedcom_news/db_schema/', 'NB_SCHEMA_VERSION', 3); } catch (PDOException $ex) { // The schema update scripts should never fail. If they do, there is no clean recovery. - die($ex); + WT_FlashMessages::addMessage($ex->getMessage(), 'danger'); + header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php'); + throw $ex; } /** @@ -58,10 +61,10 @@ class gedcom_news_WT_Module extends WT_Module implements WT_Module_Block { if (isset($_REQUEST['gedcom_news_archive'])) { $limit = 'nolimit'; - $flag = 0; + $flag = '0'; } else { $flag = get_block_setting($block_id, 'flag', 0); - if ($flag == 0) { + if ($flag === '0') { $limit = 'nolimit'; } else { $limit = get_block_setting($block_id, 'limit', 'nolimit'); @@ -100,7 +103,7 @@ class gedcom_news_WT_Module extends WT_Module implements WT_Module_Block { $c++; } if ($limit == 'date') { - if ((int)((WT_TIMESTAMP - $news->updated) / 86400) > $flag) { + if ((int) ((WT_TIMESTAMP - $news->updated) / 86400) > $flag) { break; } } @@ -113,7 +116,7 @@ class gedcom_news_WT_Module extends WT_Module implements WT_Module_Block { $content .= $news->body; // Print Admin options for this News item if (WT_USER_GEDCOM_ADMIN) { - $content .= '<hr>' . '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', news_window_specs); return false;">' . WT_I18N::translate('Edit') . '</a> | ' . '<a href="index.php?action=deletenews&news_id=' . $news->news_id . '&ctype=' . $ctype .'" onclick="return confirm(\'' . WT_I18N::translate('Are you sure you want to delete this news article?') . "');\">" . WT_I18N::translate('Delete') . '</a><br>'; + $content .= '<hr>' . '<a href="#" onclick="window.open(\'editnews.php?news_id=\'+' . $news->news_id . ', \'_blank\', news_window_specs); return false;">' . WT_I18N::translate('Edit') . '</a> | ' . '<a href="index.php?action=deletenews&news_id=' . $news->news_id . '&ctype=' . $ctype . '" onclick="return confirm(\'' . WT_I18N::translate('Are you sure you want to delete this news article?') . "');\">" . WT_I18N::translate('Delete') . '</a><br>'; } $content .= '</div>'; } @@ -126,12 +129,12 @@ class gedcom_news_WT_Module extends WT_Module implements WT_Module_Block { if ($printedAddLink) { $content .= ' | '; } - $content .= '<a href="index.php?gedcom_news_archive=yes&ctype=' . $ctype .'">' . WT_I18N::translate('View archive') . "</a>"; + $content .= '<a href="index.php?gedcom_news_archive=yes&ctype=' . $ctype . '">' . WT_I18N::translate('View archive') . "</a>"; $content .= help_link('gedcom_news_archive') . '<br>'; } if ($template) { - require WT_THEME_DIR . 'templates/block_main_temp.php'; + return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } @@ -157,25 +160,23 @@ class gedcom_news_WT_Module extends WT_Module implements WT_Module_Block { if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) { set_block_setting($block_id, 'limit', WT_Filter::post('limit')); set_block_setting($block_id, 'flag', WT_Filter::post('flag')); - exit; } require_once WT_ROOT . 'includes/functions/functions_edit.php'; - // Limit Type $limit = get_block_setting($block_id, 'limit', 'nolimit'); + $flag = get_block_setting($block_id, 'flag', 0); + echo '<tr><td class="descriptionbox wrap width33">', WT_I18N::translate('Limit display by:'), help_link('gedcom_news_limit'), - '</td><td class="optionbox"><select name="limit"><option value="nolimit"', - ($limit == 'nolimit' ? ' selected="selected"' : '') . ">", + '</td><td class="optionbox"><select name="limit"><option value="nolimit" ', + ($limit == 'nolimit' ? 'selected' : '') . ">", WT_I18N::translate('No limit') . "</option>", - '<option value="date"' . ($limit == 'date' ? ' selected="selected"' : '') . ">" . WT_I18N::translate('Age of item') . "</option>", - '<option value="count"' . ($limit == 'count' ? ' selected="selected"' : '') . ">" . WT_I18N::translate('Number of items') . "</option>", + '<option value="date" ' . ($limit == 'date' ? 'selected' : '') . ">" . WT_I18N::translate('Age of item') . "</option>", + '<option value="count" ' . ($limit == 'count' ? 'selected' : '') . ">" . WT_I18N::translate('Number of items') . "</option>", '</select></td></tr>'; - // Flag to look for - $flag = get_block_setting($block_id, 'flag', 0); echo '<tr><td class="descriptionbox wrap width33">'; echo WT_I18N::translate('Limit:'), help_link('gedcom_news_flag'); echo '</td><td class="optionbox"><input type="text" name="flag" size="4" maxlength="4" value="' . $flag . '"></td></tr>'; |
