Skip to content

Commit

Permalink
Fix: 1334925 - Upcoming events block - not sorting by date
Browse files Browse the repository at this point in the history
  • Loading branch information
fisharebest committed Sep 20, 2014
1 parent a889090 commit 3e56ec0
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 46 deletions.
4 changes: 1 addition & 3 deletions includes/functions/functions_print_lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -1977,9 +1977,7 @@ function print_events_list($startjd, $endjd, $events='BIRT MARR DEAT', $only_liv
// Now we've filtered the list, we can sort by event, if required
switch ($sort_by) {
case 'anniv':
uasort($filtered_events, function($x, $y) {
return WT_Date::compare($y->getDate(), $x->getDate()); // most recent first
});
// Data is already sorted by anniversary date
break;
case 'alpha':
uasort($filtered_events, function($x, $y) {
Expand Down
36 changes: 18 additions & 18 deletions modules_v3/todays_events/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function getTitle() {
}

// Extend class WT_Module
public /* I18N: Description of the “On this day” module */ function getDescription() {
return WT_I18N::translate('A list of the anniversaries that occur today.');
public function getDescription() {
return /* I18N: Description of the “On this day” module */ WT_I18N::translate('A list of the anniversaries that occur today.');
}

// Implement class WT_Module_Block
Expand All @@ -38,11 +38,11 @@ public function getBlock($block_id, $template=true, $cfg=null) {

require_once WT_ROOT.'includes/functions/functions_print_lists.php';

$filter =get_block_setting($block_id, 'filter', true);
$onlyBDM =get_block_setting($block_id, 'onlyBDM', true);
$infoStyle =get_block_setting($block_id, 'infoStyle','table');
$sortStyle =get_block_setting($block_id, 'sortStyle','alpha');
$block =get_block_setting($block_id, 'block', true);
$filter = get_block_setting($block_id, 'filter', true);
$onlyBDM = get_block_setting($block_id, 'onlyBDM', true);
$infoStyle = get_block_setting($block_id, 'infoStyle', 'table');
$sortStyle = get_block_setting($block_id, 'sortStyle', 'alpha');
$block = get_block_setting($block_id, 'block', true);
if ($cfg) {
foreach (array('filter', 'onlyBDM', 'infoStyle', 'sortStyle', 'block') as $name) {
if (array_key_exists($name, $cfg)) {
Expand All @@ -51,16 +51,16 @@ public function getBlock($block_id, $template=true, $cfg=null) {
}
}

$todayjd=WT_CLIENT_JD;
$todayjd = WT_CLIENT_JD;

$id=$this->getName().$block_id;
$class=$this->getName().'_block';
if ($ctype=='gedcom' && WT_USER_GEDCOM_ADMIN || $ctype=='user' && WT_USER_ID) {
$title='<i class="icon-admin" title="'.WT_I18N::translate('Configure').'" onclick="modalDialog(\'block_edit.php?block_id='.$block_id.'\', \''.$this->getTitle().'\');"></i>';
$id = $this->getName().$block_id;
$class = $this->getName().'_block';
if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype=='user' && WT_USER_ID) {
$title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
} else {
$title='';
$title = '';
}
$title.=$this->getTitle();
$title .= $this->getTitle();

$content = '';
switch ($infoStyle) {
Expand All @@ -78,9 +78,9 @@ public function getBlock($block_id, $template=true, $cfg=null) {

if ($template) {
if ($block) {
require WT_THEME_DIR.'templates/block_small_temp.php';
require WT_THEME_DIR . 'templates/block_small_temp.php';
} else {
require WT_THEME_DIR.'templates/block_main_temp.php';
require WT_THEME_DIR . 'templates/block_main_temp.php';
}
} else {
return $content;
Expand Down Expand Up @@ -142,8 +142,8 @@ public function configureBlock($block_id) {
echo '</td><td class="optionbox">';
echo select_edit_control('sortStyle', array(
/* I18N: An option in a list-box */ 'alpha'=>WT_I18N::translate('sort by name'),
/* I18N: An option in a list-box */ 'anniv'=>WT_I18N::translate('sort by date'
)), null, $sortStyle, '');
/* I18N: An option in a list-box */ 'anniv'=>WT_I18N::translate('sort by date'),
), null, $sortStyle, '');
echo '</td></tr>';

$block=get_block_setting($block_id, 'block', true);
Expand Down
49 changes: 24 additions & 25 deletions modules_v3/upcoming_events/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public function getBlock($block_id, $template=true, $cfg=null) {

require_once WT_ROOT.'includes/functions/functions_print_lists.php';

$days =get_block_setting($block_id, 'days', 7);
$filter =get_block_setting($block_id, 'filter', true);
$onlyBDM =get_block_setting($block_id, 'onlyBDM', false);
$infoStyle=get_block_setting($block_id, 'infoStyle', 'table');
$sortStyle=get_block_setting($block_id, 'sortStyle', 'alpha');
$block =get_block_setting($block_id, 'block', true);
$days = get_block_setting($block_id, 'days', 7);
$filter = get_block_setting($block_id, 'filter', true);
$onlyBDM = get_block_setting($block_id, 'onlyBDM', false);
$infoStyle = get_block_setting($block_id, 'infoStyle', 'table');
$sortStyle = get_block_setting($block_id, 'sortStyle', 'alpha');
$block = get_block_setting($block_id, 'block', true);
if ($cfg) {
foreach (array('days', 'filter', 'onlyBDM', 'infoStyle', 'sortStyle', 'block') as $name) {
if (array_key_exists($name, $cfg)) {
Expand All @@ -52,38 +52,37 @@ public function getBlock($block_id, $template=true, $cfg=null) {
}
}

$startjd=WT_CLIENT_JD+1;
$endjd =WT_CLIENT_JD+$days;
$startjd = WT_CLIENT_JD + 1;
$endjd = WT_CLIENT_JD + $days;

// Output starts here
$id=$this->getName().$block_id;
$class=$this->getName().'_block';
if ($ctype=='gedcom' && WT_USER_GEDCOM_ADMIN || $ctype=='user' && WT_USER_ID) {
$title='<i class="icon-admin" title="'.WT_I18N::translate('Configure').'" onclick="modalDialog(\'block_edit.php?block_id='.$block_id.'\', \''.$this->getTitle().'\');"></i>';
$id = $this->getName().$block_id;
$class = $this->getName().'_block';
if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype=='user' && WT_USER_ID) {
$title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>';
} else {
$title='';
$title = '';
}
$title.=$this->getTitle();
$title .= $this->getTitle();

$content = '';
switch ($infoStyle) {
case "list":
case 'list':
// Output style 1: Old format, no visible tables, much smaller text. Better suited to right side of page.
$content.=print_events_list($startjd, $endjd, $onlyBDM?'BIRT MARR DEAT':'', $filter, $sortStyle);
$content .= print_events_list($startjd, $endjd, $onlyBDM ? 'BIRT MARR DEAT' : '', $filter, $sortStyle);
break;
case "table":
case 'table':
// Style 2: New format, tables, big text, etc. Not too good on right side of page
ob_start();
$content.=print_events_table($startjd, $endjd, $onlyBDM?'BIRT MARR DEAT':'', $filter, $sortStyle);
$content.=ob_get_clean();
$content .= print_events_table($startjd, $endjd, $onlyBDM ? 'BIRT MARR DEAT' : '', $filter, $sortStyle);
$content .= ob_get_clean();
break;
}

if ($template) {
if ($block) {
require WT_THEME_DIR.'templates/block_small_temp.php';
require WT_THEME_DIR . 'templates/block_small_temp.php';
} else {
require WT_THEME_DIR.'templates/block_main_temp.php';
require WT_THEME_DIR . 'templates/block_main_temp.php';
}
} else {
return $content;
Expand Down Expand Up @@ -127,14 +126,14 @@ public function configureBlock($block_id) {
echo ' <em>', WT_I18N::plural('maximum %d day', 'maximum %d days', 30, 30) ,'</em>';
echo '</td></tr>';

$filter=get_block_setting($block_id, 'filter', true);
$filter=get_block_setting($block_id, 'filter', true);
echo '<tr><td class="descriptionbox wrap width33">';
echo WT_I18N::translate('Show only events of living individuals?');
echo '</td><td class="optionbox">';
echo edit_field_yes_no('filter', $filter);
echo '</td></tr>';

$onlyBDM=get_block_setting($block_id, 'onlyBDM', false);
$onlyBDM=get_block_setting($block_id, 'onlyBDM', false);
echo '<tr><td class="descriptionbox wrap width33">';
echo WT_I18N::translate('Show only births, deaths, and marriages?');
echo '</td><td class="optionbox">';
Expand All @@ -154,7 +153,7 @@ public function configureBlock($block_id) {
echo '</td><td class="optionbox">';
echo select_edit_control('sortStyle', array(
/* I18N: An option in a list-box */ 'alpha'=>WT_I18N::translate('sort by name'),
/* I18N: An option in a list-box */ 'anniv'=>WT_I18N::translate('sort by date')
/* I18N: An option in a list-box */ 'anniv'=>WT_I18N::translate('sort by date'),
), null, $sortStyle, '');
echo '</td></tr>';

Expand Down

0 comments on commit 3e56ec0

Please sign in to comment.