summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNigel Osborne <kiwi3685@me.com>2011-02-20 21:14:22 +0000
committerNigel Osborne <kiwi3685@me.com>2011-02-20 21:14:22 +0000
commitde11ff8e7bf6bac35ef9d3fecca5a94252463606 (patch)
treed86893b4deee20d41fa6d2d3c30e6c3bc0edca63
parent20998d40415310611227f40100d9cb930a347c8f (diff)
downloadwebtrees-de11ff8e7bf6bac35ef9d3fecca5a94252463606.tar.gz
webtrees-de11ff8e7bf6bac35ef9d3fecca5a94252463606.tar.bz2
webtrees-de11ff8e7bf6bac35ef9d3fecca5a94252463606.zip
Bug #722090 Sort Errors in recent changes module
-rw-r--r--includes/functions/functions_print_lists.php337
-rw-r--r--modules/recent_changes/help_text.php6
-rw-r--r--modules/recent_changes/module.php248
3 files changed, 347 insertions, 244 deletions
diff --git a/includes/functions/functions_print_lists.php b/includes/functions/functions_print_lists.php
index f14dc66f6a..4283d97a89 100644
--- a/includes/functions/functions_print_lists.php
+++ b/includes/functions/functions_print_lists.php
@@ -1322,148 +1322,211 @@ function format_surname_list($surnames, $style, $totals, $type) {
/**
+ * print a list of recent changes
+ *
+ * @param array $change_ids contain records that were extracted from the database.
+ * @param string $sort determines what to sort
+ * @param bool $show_parents
+ */
+function print_changes_list($change_ids, $sort, $show_parents=false) {
+ global $SHOW_MARRIED_NAMES, $TEXT_DIRECTION, $WT_IMAGES;
+ define('NMAX', 1000);
+ $n = 0;
+ foreach ($change_ids as $change_id) {
+ if ($n >= NMAX)
+ break;
+ $record = WT_GedcomRecord::getInstance($change_id);
+ if (!$record || !$record->canDisplayDetails()) {
+ continue;
+ }
+ // setup sorting parameters
+ $arr[$n]['record'] = $record;
+ $arr[$n]['jd'] = ($sort == 'name') ? 1 : $n;
+ $arr[$n]['anniv'] = strtotime(str_replace('-', '', $record->LastChangeTimestamp(false)));
+ $arr[$n++]['fact'] = $record->getSortName(); // in case two changes have same timestamp
+ }
+
+ switch ($sort) {
+ case 'name':
+ uasort($arr, 'event_sort_name');
+ break;
+ case 'date_asc':
+ uasort($arr, 'event_sort');
+ $arr = array_reverse($arr);
+ break;
+ case 'date_desc':
+ uasort($arr, 'event_sort');
+ }
+ $return = '';
+ foreach ($arr as $value) {
+ $return .= "<a href='" . $value['record']->getHtmlUrl() . "' class='list_item name2' dir='" . $TEXT_DIRECTION . "'>" . PrintReady($value['record']->getFullName()) . "</a>";
+ $return .= "<div class='indent'>";
+ if ($value['record']->getType() == 'INDI') {
+ if ($value['record']->getAddName()) {
+ $return .= "<a href='" . $value['record']->getHtmlUrl() . "' class='list_item'>" . PrintReady($value['record']->getAddName()) . "</a>";
+ }
+ if ($SHOW_MARRIED_NAMES) {
+ foreach ($value['record']->getAllNames() as $name) {
+ if ($name['type'] == '_MARNM') {
+ $return .= "<div><a title='" . translate_fact('_MARNM') . "' href='" . $value['record']->getHtmlUrl() . "' class='list_item'>" . PrintReady($name['full']) . "</a></div>";
+ }
+ }
+ }
+ if ($show_parents) {
+ $return .= $value['record']->getPrimaryParentsNames('details1');
+ }
+ }
+ $return .= "<div style='margin-bottom:5px'>";
+ //-- Last change date/time & user
+ $return .= WT_I18N::translate("Changed on %s by %s", $value['record']->LastChangeTimestamp(empty($SEARCH_SPIDER)), $value['record']->LastChangeUser());
+ $return .= "</div>"; // class='indent'
+ $return .= "</div>";
+ }
+ $return .= WT_I18N::translate('Showing 1 to %d of %d entries', $n,$n);
+ if ($n >= NMAX) {
+ $return .= "<div class='warning'>" . WT_I18N::translate('Total changes exceed limit (%d)', NMAX) . "</div>";
+ }
+ return $return;
+}
+
+/**
* print a sortable table of recent changes
- * also called by mediaviewer to list records linked to a media
*
- * @param array $datalist contain records that were extracted from the database.
+ * @param array $change_ids contain records that were extracted from the database.
+ * @param string $sort determines what to sort
+ * @param bool $show_parents
*/
-function print_changes_table($change_ids) {
- global $SHOW_MARRIED_NAMES, $TEXT_DIRECTION, $WT_IMAGES;
- if (!$change_ids) return;
-// require_once WT_ROOT.'js/sorttable.js.htm';
- $table_id = "ID".floor(microtime()*1000000); // sorttable requires a unique ID
- echo WT_JS_START.'var table_id = "'.$table_id.'"'.WT_JS_END;
- ?>
- <script type="text/javascript" src="js/jquery/jquery.dataTables.min.js"></script>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- jQuery('#'+table_id).dataTable( {
- "bAutoWidth":false,
- "bPaginate": false,
- "bLengthChange": false,
- "bFilter": false,
- "bInfo": false,
- "bJQueryUI": false,
- "aoColumns": [
- /* 0-Type*/ null,
- /* 1-Record */ { "aaSorting": [ [0,'asc'], [1,'asc'] ] },
- /* 2-GIVN */ { "bVisible": false },
- /* 3-Change */ null,
- /* 4-User */ null
- ]
- });
- });
- </script>
- <?php
- //-- table header
- echo
- '<table id="', $table_id, '" class="list_table center width100">',
- '<thead><tr>',
- '<th class="list_label">&nbsp;</th>',
- '<th style="cursor:pointer;" class="list_label">', WT_I18N::translate('Record'), '</th>',
- '<th style="display:none;">GIVN</th>',
- '<th style="cursor:pointer;" class="list_label">', translate_fact('CHAN'), '</th>',
- '<th style="cursor:pointer;" class="list_label">', translate_fact('_WT_USER'), '</th>',
- '</tr></thead>';
- //-- table body
- echo '<tbody>';
- $n = 0;
- $NMAX = 1000;
- $indi = false;
- foreach ($change_ids as $change_id) {
- if ($n>=$NMAX) break;
- $record=WT_GedcomRecord::getInstance($change_id);
- if (!$record || !$record->canDisplayDetails()) {
- continue;
- }
- //-- Counter
- echo
- '<tr>',
- '<td class="list_value_wrap rela list_item">';
- switch ($record->getType()) {
- case "INDI":
- echo $record->getSexImage('small', '', '', false);
- $indi=true;
- break;
- case "FAM":
- echo '<img src="', $WT_IMAGES['cfamily'], '" title="" alt="" height="12" />';
- $indi = false;
- break;
- case "OBJE":
- echo '<img src="', $record->getMediaIcon(), '" title="" alt="" height="12" />';
- $indi = false;
- break;
- case "NOTE":
- echo '<img src="', $WT_IMAGES['note'], '" title="" alt="" height="12" />';
- $indi = false;
- break;
- case "SOUR":
- echo '<img src="', $WT_IMAGES['source'], '" title="" alt="" height="12" />';
- $indi = false;
- break;
- case "REPO":
- echo '<img src="', $WT_IMAGES['repository'], '" title="" alt="" height="12" />';
- $indi = false;
- break;
- default:
- $indi = false;
- break;
- }
- echo '</td>';
- ++$n;
- //-- Record name(s)
- $name = $record->getFullName();
- echo
- '<td class="list_value_wrap" align="', get_align($name), '">',
- '<a href="', $record->getHtmlUrl(), '" class="list_item name2" dir="', $TEXT_DIRECTION, '">', PrintReady($name), '</a>';
- $addname=$record->getAddName();
- if ($addname) {
- echo '<br /><a href="', $record->getHtmlUrl(), '" class="list_item">', PrintReady($addname), '</a>';
- }
- if ($indi) {
- if ($SHOW_MARRIED_NAMES) {
- foreach ($record->getAllNames() as $name) {
- if ($name['type']=='_MARNM') {
- echo '<br /><a title="', translate_fact('_MARNM'), '" href="', $record->getHtmlUrl(), '" class="list_item">', PrintReady($name['full']), '</a>';
- }
- }
- }
- echo $record->getPrimaryParentsNames("parents_$table_id details1", "none");
- }
- echo '</td>';
- //-- GIVN
- echo '<td>';
- $exp = explode(",", str_replace('<', ',', $name).",");
- echo $exp[1];
- echo '</td>';
- //-- Last change date/time
- echo '<td class="list_value_wrap rela">', $record->LastChangeTimestamp(empty($SEARCH_SPIDER)), '</td>';
- //-- Last change user
- echo '<td class="list_value_wrap rela">', $record->LastChangeUser(empty($SEARCH_SPIDER)), '</td>';
- echo '</tr>';
- }
- echo '</tbody>';
- //-- table footer
- echo
- '<tfoot><tr class="sortbottom">',
- '<td class="list_label" colspan="2">';
- if ($n>1 && $indi) {
- echo '<a href="javascript:;" onclick="sortByOtherCol(this, 1)"><img src="images/topdown.gif" alt="" border="0" /> ', translate_fact('GIVN'), '</a><br />';
- }
- if ($indi) {
- echo "<input id=\"cb_parents_$table_id\" type=\"checkbox\" onclick=\"toggleByClassName('DIV', 'parents_$table_id');\" /><label for=\"cb_parents_$table_id\">", WT_I18N::translate('Show parents'), "</label><br />";
- }
- echo WT_I18N::translate('Total changes'), ': ', $n;
- if ($n>=$NMAX) echo '<br /><span class="warning">', WT_I18N::translate('Recent changes'), ' &gt; ', $NMAX, '</span>';
- echo
- '</td>',
- '<td style="display:none">GIVN</td>',
- '<td></td>',
- '<td></td>',
- '</tr></tfoot>',
- '</table>';
+function print_changes_table($change_ids, $sort, $show_parents=false) {
+ global $SHOW_MARRIED_NAMES, $TEXT_DIRECTION, $WT_IMAGES;
+ define('NMAX', 1000);
+ $return = '';
+ $n = 0;
+ $table_id = "ID" . floor(microtime() * 1000000); // sorttable requires a unique ID
+ switch ($sort) {
+ case 'name': //name
+ $aaSorting = "[5,'asc'], [4,'desc']";
+ break;
+ case 'date_asc': //date ascending
+ $aaSorting = "[4,'asc'], [5,'asc']";
+ break;
+ case 'date_desc': //date descending
+ $aaSorting = "[4,'desc'], [5,'asc']";
+ }
+ echo WT_JS_START . 'var table_id = "' . $table_id . '"' . WT_JS_END;
+?>
+ <script type="text/javascript" src="js/jquery/jquery.dataTables.min.js"></script>
+ <script type="text/javascript">
+ jQuery(document).ready(function(){
+ jQuery('#'+table_id).dataTable( {
+ "bAutoWidth":false,
+ "bPaginate": false,
+ "bLengthChange": false,
+ "bFilter": false,
+ "bInfo": false,
+ "bJQueryUI": false,
+ "aaSorting": [<?php echo $aaSorting; ?>],
+ "aoColumns": [
+ /* 0-Sex */ { "bSortable" : false },
+ /* 1-Record */ { "iDataSort" : 5 },
+ /* 2-Change */ { "iDataSort" : 4 },
+ /* 3=By */ null,
+ /* 4-DATE */ { "bVisible" : false },
+ /* 5-SORTNAME */{ "bVisible" : false }
+ ]
+ });
+ });
+ </script>
+<?php
+ //-- table header
+ $return .= "<table id='" . $table_id . "' class='list_table center width100'>";
+ $return .= "<thead><tr>";
+ $return .= "<th class='list_label'></th>";
+ $return .= "<th style='cursor:pointer;' class='list_label'>" . WT_I18N::translate('Record') . "</th>";
+ $return .= "<th style='cursor:pointer;' class='list_label'>" . translate_fact('CHAN') . "</th>";
+ $return .= "<th style='cursor:pointer;' class='list_label'>" . translate_fact('_WT_USER') . "</th>";
+ $return .= "<th style='display:none;'>DATE</th>"; //hidden by datatables code
+ $return .= "<th style='display:none;'>SORTNAME</th>"; //hidden by datatables code
+ $return .= "</tr></thead><tbody>";
+ //-- table body
+
+ foreach ($change_ids as $change_id) {
+ if ($n >= NMAX)
+ break;
+ $record = WT_GedcomRecord::getInstance($change_id);
+ if (!$record || !$record->canDisplayDetails()) {
+ continue;
+ }
+ $return .= "<tr><td class='list_value_wrap rela list_item'>";
+ $indi = false;
+ switch ($record->getType()) {
+ case "INDI":
+ $return .= $record->getSexImage('small', '', '', false);
+ $indi = true;
+ break;
+ case "FAM":
+ $return .= '<img src="' . $WT_IMAGES['cfamily'] . '" title="" alt="" height="12" />';
+ break;
+ case "OBJE":
+ $return .= '<img src="' . $record->getMediaIcon() . '" title="" alt="" height="12" />';
+ break;
+ case "NOTE":
+ $return .= '<img src="' . $WT_IMAGES['note'] . '" title="" alt="" height="12" />';
+ break;
+ case "SOUR":
+ $return .= '<img src="' . $WT_IMAGES['source'] . '" title="" alt="" height="12" />';
+ break;
+ case "REPO":
+ $return .= '<img src="' . $WT_IMAGES['repository'] . '" title="" alt="" height="12" />';
+ break;
+ default:
+ break;
+ }
+ $return .= "</td>";
+ ++$n;
+ //-- Record name(s)
+ $name = $record->getFullName();
+ $return .= "<td class='list_value_wrap' align='" . get_align($name) . "'>";
+ $return .= "<a href='" . $record->getHtmlUrl() . "' class='list_item name2' dir='" . $TEXT_DIRECTION . "'>" . PrintReady($name) . "</a>";
+ if ($indi) {
+ $return .= "<div class='indent'>";
+ $addname = $record->getAddName();
+ if ($addname) {
+ $return .= "<a href='" . $record->getHtmlUrl() . "' class='list_item'>" . PrintReady($addname) . "</a>";
+ }
+ if ($SHOW_MARRIED_NAMES) {
+ foreach ($record->getAllNames() as $name) {
+ if ($name['type'] == '_MARNM') {
+ $return .= "<div><a title='" . translate_fact('_MARNM') . "' href='" . $record->getHtmlUrl() . "' class='list_item'>" . PrintReady($name['full']) . "</a></div>";
+ }
+ }
+ }
+ if ($show_parents) {
+ $return .= $record->getPrimaryParentsNames("parents_$table_id details1");
+ }
+ $return .= "</div>"; //class='indent'
+ }
+ $return .= "</td>";
+ //-- Last change date/time
+ $return .= "<td class='list_value_wrap'>" . $record->LastChangeTimestamp(empty($SEARCH_SPIDER)) . "</td>";
+ //-- Last change user
+ $return .= "<td class='list_value_wrap'>" . $record->LastChangeUser() . "</td>";
+ //-- change date (sortable) hidden by datatables code
+ $return .= "<td style='display:none;'>" . strtotime(str_replace('-', '', $record->LastChangeTimestamp(false))) . "</td>";
+ //-- names (sortable) hidden by datatables code
+ $return .= "<td>" . $record->getSortName() . "</td></tr>";
+ }
+
+ //-- table footer
+ $return .= "</tbody>";
+ $return .= "</table>";
+ $return .= WT_I18N::translate('Showing 1 to %d of %d entries', $n, $n);
+ if ($n >= NMAX) {
+ $return .= "<div class='warning'>" . WT_I18N::translate('Total changes exceed limit (%d)', NMAX) . "</div>";
+ }
+ return $return;
}
+
/**
* print a sortable table of events
* and generates hCalendar records
diff --git a/modules/recent_changes/help_text.php b/modules/recent_changes/help_text.php
index 0904064675..99a3538625 100644
--- a/modules/recent_changes/help_text.php
+++ b/modules/recent_changes/help_text.php
@@ -38,6 +38,12 @@ case 'recent_changes':
$text.=WT_I18N::translate('Number of days to show: This is the number of days that <b>webtrees</b> should use when searching for events');
$text.=' (<i>'.WT_I18N::plural('maximum %d day', 'maximum %d days', 30, 30).'</i>).';
$text.='</li><li>';
+ $text.=WT_I18N::translate('Presentation Style: Display as a list or in a table.');
+ $text.='</li><li>';
+ $text.=WT_I18N::translate('Display Parents: Select whether to display the person\'s parents.');
+ $text.='</li><li>';
+ $text.=WT_I18N::translate('Sort Style: Only used when viewing a list; for table view, click on the table headings to sort.');
+ $text.='</li><li>';
$text.=WT_I18N::translate('Should this block be hidden when it is empty?: Provides the option to hide the block if there are no changes to display.');
$text.='</li></ul>';
break;
diff --git a/modules/recent_changes/module.php b/modules/recent_changes/module.php
index 60f74e553a..7e92c18a8c 100644
--- a/modules/recent_changes/module.php
+++ b/modules/recent_changes/module.php
@@ -1,4 +1,5 @@
<?php
+
// Classes and libraries for module system
//
// webtrees: Web based Family History software
@@ -24,129 +25,162 @@
// @version $Id$
if (!defined('WT_WEBTREES')) {
- header('HTTP/1.0 403 Forbidden');
- exit;
+ header('HTTP/1.0 403 Forbidden');
+ exit;
}
class recent_changes_WT_Module extends WT_Module implements WT_Module_Block {
- // Extend class WT_Module
- public function getTitle() {
- return WT_I18N::translate('Recent changes');
- }
- // Extend class WT_Module
- public function getDescription() {
- return WT_I18N::translate('This block lists the changes that have been made to all family trees within a specified number of days.');
- }
+ // Extend class WT_Module
+ public function getTitle() {
+ return WT_I18N::translate('Recent changes');
+ }
+
+ // Extend class WT_Module
+ public function getDescription() {
+ return WT_I18N::translate('This block lists the changes that have been made to all family trees within a specified number of days.');
+ }
+
+ // Implement class WT_Module_Block
+ public function getBlock($block_id, $template=true, $cfg=null) {
+ global $ctype, $WT_IMAGES;
+
+ $days = get_block_setting($block_id, 'days', 7);
+ $infoStyle = get_block_setting($block_id, 'infoStyle', 'table');
+ $show_parents = get_block_setting($block_id, 'show_parents', false);
+ $sortStyle = get_block_setting($block_id, 'sortStyle', 'datea');
+ $hide_empty = get_block_setting($block_id, 'hide_empty', false);
+ $block = get_block_setting($block_id, 'block', true);
+ if ($cfg) {
+ foreach (array('days', 'infoStyle', 'show_parents', 'sortStyle', 'hide_empty', 'block') as $name) {
+ if (array_key_exists($name, $cfg)) {
+ $$name = $cfg[$name];
+ }
+ }
+ }
+
+ $found_facts = get_recent_changes(WT_CLIENT_JD - $days);
- // Implement class WT_Module_Block
- public function getBlock($block_id, $template=true, $cfg=null) {
- global $ctype, $WT_IMAGES;
+ if (empty($found_facts) && $hide_empty) {
+ return;
+ }
+ // Print block header
+ $id = $this->getName() . $block_id;
+ $title = '';
+ if ($ctype == "gedcom" && WT_USER_GEDCOM_ADMIN || $ctype == 'user') {
+ if ($ctype == "gedcom") {
+ $name = WT_GEDCOM;
+ } else {
+ $name = WT_USER_NAME;
+ }
+ $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('index_edit.php?action=configure&amp;ctype={$ctype}&amp;block_id={$block_id}', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
+ $title .= "<img class=\"adminicon\" src=\"" . $WT_IMAGES["admin"] . "\" width=\"15\" height=\"15\" border=\"0\" alt=\"" . WT_I18N::translate('Configure') . "\" /></a>";
+ }
+ $title.= WT_I18N::translate('Last %s days changes', $days) . help_link('recent_changes', $this->getName());
+ $content = "";
+ // Print block content
+ if (count($found_facts) == 0) {
+ $content .= WT_I18N::translate('There have been no changes within the last %s days.', $days);
+ } else {
+ ob_start();
+ switch ($infoStyle) {
+ case 'list':
+ $content .= print_changes_list($found_facts, $sortStyle, $show_parents);
+ break;
+ case 'table':
+ // sortable table
+ $content .= print_changes_table($found_facts, $sortStyle, $show_parents);
+ break;
+ }
+ $content .= ob_get_clean();
+ }
- $days=get_block_setting($block_id, 'days', 7);
- $hide_empty=get_block_setting($block_id, 'hide_empty', false);
- $block=get_block_setting($block_id, 'block', true);
- if ($cfg) {
- foreach (array('days', 'hide_empty', 'block') as $name) {
- if (array_key_exists($name, $cfg)) {
- $$name=$cfg[$name];
- }
- }
- }
+ if ($template) {
+ if ($block) {
+ require WT_THEME_DIR . 'templates/block_small_temp.php';
+ } else {
+ require WT_THEME_DIR . 'templates/block_main_temp.php';
+ }
+ } else {
+ return $content;
+ }
+ }
- $found_facts=get_recent_changes(WT_CLIENT_JD-$days);
+ // Implement class WT_Module_Block
+ public function loadAjax() {
+ return true;
+ }
- if (empty($found_facts) && $hide_empty) {
- return;
- }
- // Print block header
- $id=$this->getName().$block_id;
- $title='';
- if ($ctype=="gedcom" && WT_USER_GEDCOM_ADMIN || $ctype=='user') {
- if ($ctype=="gedcom") {
- $name = WT_GEDCOM;
- } else {
- $name = WT_USER_NAME;
- }
- $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('index_edit.php?action=configure&amp;ctype={$ctype}&amp;block_id={$block_id}', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">";
- $title .= "<img class=\"adminicon\" src=\"".$WT_IMAGES["admin"]."\" width=\"15\" height=\"15\" border=\"0\" alt=\"".WT_I18N::translate('Configure')."\" /></a>";
- }
- $title.= WT_I18N::translate('Recent changes').help_link('recent_changes', $this->getName());
+ // Implement class WT_Module_Block
+ public function isUserBlock() {
+ return true;
+ }
- $content = "";
- // Print block content
- if (count($found_facts)==0) {
- $content .= WT_I18N::translate('There have been no changes within the last %s days.', $days);
- } else {
- $content .= WT_I18N::translate('Changes made within the last %s days', $days);
- // sortable table
- require_once WT_ROOT.'includes/functions/functions_print_lists.php';
- ob_start();
- print_changes_table($found_facts);
- $content .= ob_get_clean();
- }
+ // Implement class WT_Module_Block
+ public function isGedcomBlock() {
+ return true;
+ }
- if ($template) {
- if ($block) {
- require WT_THEME_DIR.'templates/block_small_temp.php';
- } else {
- require WT_THEME_DIR.'templates/block_main_temp.php';
- }
- } else {
- return $content;
- }
- }
+ // Implement class WT_Module_Block
+ public function configureBlock($block_id) {
+ if (safe_POST_bool('save')) {
+ set_block_setting($block_id, 'days', safe_POST_integer('days', 1, 30, 7));
+ set_block_setting($block_id, 'infoStyle', safe_POST('infoStyle', array('list', 'table'), 'table'));
+ set_block_setting($block_id, 'show_parents', safe_POST_bool('show_parents'));
+ set_block_setting($block_id, 'sortStyle', safe_POST('sortStyle', array('name', 'date_asc', 'date_desc'), 'date_asc'));
+ set_block_setting($block_id, 'hide_empty', safe_POST_bool('hide_empty'));
+ set_block_setting($block_id, 'block', safe_POST_bool('block'));
+ echo WT_JS_START, 'window.opener.location.href=window.opener.location.href;window.close();', WT_JS_END;
+ exit;
+ }
- // Implement class WT_Module_Block
- public function loadAjax() {
- return true;
- }
+ require_once WT_ROOT . 'includes/functions/functions_edit.php';
- // Implement class WT_Module_Block
- public function isUserBlock() {
- return true;
- }
+ $days = get_block_setting($block_id, 'days', 7);
+ echo '<tr><td class="descriptionbox wrap width33">';
+ echo WT_I18N::translate('Number of days to show');
+ echo '</td><td class="optionbox">';
+ echo '<input type="text" name="days" size="2" value="', $days, '" />';
+ echo ' <i>', WT_I18N::plural('maximum %d day', 'maximum %d days', 30, 30), '</i>';
+ echo '</td></tr>';
- // Implement class WT_Module_Block
- public function isGedcomBlock() {
- return true;
- }
+ $infoStyle = get_block_setting($block_id, 'infoStyle', 'table');
+ echo '<tr><td class="descriptionbox wrap width33">';
+ echo WT_I18N::translate('Presentation style'); //, help_link('style');
+ echo '</td><td class="optionbox">';
+ echo select_edit_control('infoStyle', array('list' => WT_I18N::translate('List'), 'table' => WT_I18N::translate('Table')), null, $infoStyle, '');
+ echo '</td></tr>';
- // Implement class WT_Module_Block
- public function configureBlock($block_id) {
- if (safe_POST_bool('save')) {
- set_block_setting($block_id, 'days', safe_POST_integer('days', 1, 30, 7));
- set_block_setting($block_id, 'hide_empty', safe_POST_bool('hide_empty'));
- set_block_setting($block_id, 'block', safe_POST_bool('block'));
- echo WT_JS_START, 'window.opener.location.href=window.opener.location.href;window.close();', WT_JS_END;
- exit;
- }
+ $sortStyle = get_block_setting($block_id, 'sortStyle', 'date');
+ echo '<tr><td class="descriptionbox wrap width33">';
+ echo WT_I18N::translate('Sort Style'); //, help_link('sort_style');
+ echo '</td><td class="optionbox">';
+ echo select_edit_control('sortStyle', array('name' => WT_I18N::translate('Alphabetically'), 'date_asc' => WT_I18N::translate('By Date (ascending)'), 'date_desc' => WT_I18N::translate('By Date (descending)')), null, $sortStyle, '');
+ echo '</td></tr>';
- require_once WT_ROOT.'includes/functions/functions_edit.php';
+ $show_parents = get_block_setting($block_id, 'show_parents', true);
+ echo '<tr><td class="descriptionbox wrap width33">';
+ echo WT_I18N::translate('Show Parents?');
+ echo '</td><td class="optionbox">';
+ echo edit_field_yes_no('show_parents', $show_parents);
+ echo '</td></tr>';
- $days=get_block_setting($block_id, 'days', 7);
- echo '<tr><td class="descriptionbox wrap width33">';
- echo WT_I18N::translate('Number of days to show');
- echo '</td><td class="optionbox">';
- echo '<input type="text" name="days" size="2" value="', $days, '" />';
- echo ' <i>', WT_I18N::plural('maximum %d day', 'maximum %d days', 30, 30) ,'</i>';
- echo '</td></tr>';
+ $block = get_block_setting($block_id, 'block', true);
+ echo '<tr><td class="descriptionbox wrap width33">';
+ echo /* I18N: label for a yes/no option */ WT_I18N::translate('Add a scrollbar when block contents grow');
+ echo '</td><td class="optionbox">';
+ echo edit_field_yes_no('block', $block);
+ echo '</td></tr>';
- $hide_empty=get_block_setting($block_id, 'hide_empty', true);
- echo '<tr><td class="descriptionbox wrap width33">';
- echo WT_I18N::translate('Should this block be hidden when it is empty?');
- echo '</td><td class="optionbox">';
- echo edit_field_yes_no('hide_empty', $hide_empty);
- echo '</td></tr>';
- echo '<tr><td colspan="2" class="optionbox wrap">';
- echo '<span class="error">', WT_I18N::translate('If you hide an empty block, you will not be able to change its configuration until it becomes visible by no longer being empty.'), '</span>';
- echo '</td></tr>';
+ $hide_empty = get_block_setting($block_id, 'hide_empty', true);
+ echo '<tr><td class="descriptionbox wrap width33">';
+ echo WT_I18N::translate('Should this block be hidden when it is empty?');
+ echo '</td><td class="optionbox">';
+ echo edit_field_yes_no('hide_empty', $hide_empty);
+ echo '</td></tr>';
+ echo '<tr><td colspan="2" class="optionbox wrap">';
+ echo '<span class="error">', WT_I18N::translate('If you hide an empty block, you will not be able to change its configuration until it becomes visible by no longer being empty.'), '</span>';
+ echo '</td></tr>';
+ }
- $block=get_block_setting($block_id, 'block', true);
- echo '<tr><td class="descriptionbox wrap width33">';
- echo /* I18N: label for a yes/no option */ WT_I18N::translate('Add a scrollbar when block contents grow');
- echo '</td><td class="optionbox">';
- echo edit_field_yes_no('block', $block);
- echo '</td></tr>';
- }
}