getName().$block_id;
$class=$this->getName().'_block';
if ($ctype=='gedcom' && WT_USER_GEDCOM_ADMIN || $ctype=='user' && WT_USER_ID) {
$title='';
} else {
$title='';
}
$title.=$this->getTitle();
$content='';
// The standard anniversary rules cover most of the Yahrzeit rules, we just
// need to handle a few special cases.
// Fetch normal anniversaries...
$yahrzeits=array();
for ($jd=$startjd-1; $jd<=$endjd+$days; ++$jd) {
foreach (get_anniversary_events($jd, 'DEAT _YART') as $fact) {
// Exact hebrew dates only
$date = $fact->getDate();
if ($date->MinDate() instanceof WT_Date_Jewish && $date->MinJD()==$date->MaxJD()) {
$fact->jd = $jd;
$yahrzeits[]=$fact;
}
}
}
// ...then adjust dates
foreach ($yahrzeits as $yahrzeit) {
if ($yahrzeit->getTag() == 'DEAT') { // Just DEAT, not _YART
$today=new WT_Date_Jewish($yahrzeit->jd);
$hd=$yahrzeit->getDate()->MinDate();
$hd1=new WT_Date_Jewish($hd);
$hd1->y+=1;
$hd1->SetJDFromYMD();
// Special rules. See http://www.hebcal.com/help/anniv.html
// Everything else is taken care of by our standard anniversary rules.
if ($hd->d==30 && $hd->m==2 && $hd->y!=0 && $hd1->DaysInMonth()<30) { // 30 CSH
// Last day in CSH
$yahrzeit->jd = WT_Date_Jewish::YMDtoJD($today->y, 3, 1)-1;
} elseif ($hd->d==30 && $hd->m==3 && $hd->y!=0 && $hd1->DaysInMonth()<30) { // 30 KSL
// Last day in KSL
$yahrzeit->jd = WT_Date_Jewish::YMDtoJD($today->y, 4, 1)-1;
} elseif ($hd->d==30 && $hd->m==6 && $hd->y!=0 && $today->DaysInMonth()<30 && !$today->IsLeapYear()) { // 30 ADR
// Last day in SHV
$yahrzeit->jd = WT_Date_Jewish::YMDtoJD($today->y, 6, 1)-1;
}
}
}
switch ($infoStyle) {
case 'list':
foreach ($yahrzeits as $yahrzeit)
if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd+$days) {
$ind=$yahrzeit->getParent();
$content .= "getHtmlUrl()."\" class=\"list_item name2\">".$ind->getFullName()."".$ind->getSexImage();
$content .= "
";
$content .= $yahrzeit->getDate()->Display(true);
$content .= ', '.WT_I18N::translate('%s year anniversary', $yahrzeit->anniv);
$content .= "
";
}
break;
case 'table':
default:
$table_id = "ID".(int)(microtime()*1000000); // table requires a unique ID
$controller
->addExternalJavascript(WT_JQUERY_DATATABLES_URL)
->addInlineJavascript('
jQuery("#'.$table_id.'").dataTable({
"sDom": \'t\',
'.WT_I18N::datatablesI18N().',
"bAutoWidth":false,
"bPaginate": false,
"bLengthChange": false,
"bFilter": false,
"bInfo": true,
"bJQueryUI": true,
"aaSorting": [[5,"asc"]],
"aoColumns": [
/* 0-name */ { "iDataSort": 1 },
/* 1-NAME */ { "bVisible": false },
/* 2-date */ { "iDataSort": 3 },
/* 3-DATE */ { "bVisible": false },
/* 4-Aniv */ { "sClass": "center"},
/* 5-yart */ { "iDataSort": 6 },
/* 6-YART */ { "bVisible": false }
]
});
jQuery("#'.$table_id.'").css("visibility", "visible");
jQuery(".loading-image").css("display", "none");
');
$content='';
$content .= '
';
$content .= '';
$content .= '';
$content .= '| '.WT_Gedcom_Tag::getLabel('NAME').' | ';
$content .= ''.WT_Gedcom_Tag::getLabel('NAME').' | ';
$content .= ''.WT_Gedcom_Tag::getLabel('DEAT').' | ';
$content .= 'DEAT | ';
$content .= ' | ';
$content .= ''.WT_Gedcom_Tag::getLabel('_YART').' | ';
$content .= '_YART | ';
$content .= '
';
foreach ($yahrzeits as $yahrzeit) {
if ($yahrzeit->jd >= $startjd && $yahrzeit->jd < $startjd+$days) {
$content .= '';
$ind=$yahrzeit->getParent();
// Individual name(s)
$name=$ind->getFullName();
$url=$ind->getHtmlUrl();
$content .= '';
$content .= ''.$name.'';
$content .= $ind->getSexImage();
$addname=$ind->getAddName();
if ($addname) {
$content .= ' '.$addname.'';
}
$content .= ' | ';
$content .= ''.$ind->getSortName().' | ';
// death/yahrzeit event date
$content .= ''.$yahrzeit->getDate()->Display().' | ';
$content .= ''.$yahrzeit->getDate()->minJD().' | ';// sortable date
// Anniversary
$content .= ''.$yahrzeit->anniv.' | ';
// upcomming yahrzeit dates
switch ($calendar) {
case 'gregorian':
$today=new WT_Date_Gregorian($yahrzeit->jd);
break;
case 'jewish':
default:
$today=new WT_Date_Jewish($yahrzeit->jd);
break;
}
$td=new WT_Date($today->Format('%@ %A %O %E'));
$content .= ''.$td->Display().' | ';
$content .= ''.$td->minJD().' | ';// sortable date
$content .= '
';
}
}
$content .= '
';
break;
}
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 loadAjax() {
return true;
}
// Implement class WT_Module_Block
public function isUserBlock() {
return true;
}
// Implement class WT_Module_Block
public function isGedcomBlock() {
return true;
}
// Implement class WT_Module_Block
public function configureBlock($block_id) {
if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) {
set_block_setting($block_id, 'days', WT_Filter::postInteger('days', 1, 30, 7));
set_block_setting($block_id, 'infoStyle', WT_Filter::post('infoStyle', 'list|table', 'table'));
set_block_setting($block_id, 'calendar', WT_Filter::post('calendar', 'jewish|gregorian', 'jewish'));
set_block_setting($block_id, 'block', WT_Filter::postBool('block'));
exit;
}
require_once WT_ROOT.'includes/functions/functions_edit.php';
$days=get_block_setting($block_id, 'days', 7);
echo '| ';
echo WT_I18N::translate('Number of days to show');
echo ' | ';
echo '';
echo ' ', WT_I18N::plural('maximum %d day', 'maximum %d days', 30, 30) ,'';
echo ' |
';
$infoStyle=get_block_setting($block_id, 'infoStyle', 'table');
echo '| ';
echo WT_I18N::translate('Presentation style');
echo ' | ';
echo select_edit_control('infoStyle', array('list'=>WT_I18N::translate('list'), 'table'=>WT_I18N::translate('table')), null, $infoStyle, '');
echo ' |
';
$calendar=get_block_setting($block_id, 'calendar');
echo '| ';
echo WT_I18N::translate('Calendar');
echo ' | ';
echo select_edit_control('calendar', array(
'jewish' =>WT_Date_Jewish::calendarName(),
'gregorian'=>WT_Date_Gregorian::calendarName(),
), null, $calendar, '');
echo ' |
';
$block=get_block_setting($block_id, 'block', true);
echo '| ';
echo /* I18N: label for a yes/no option */ WT_I18N::translate('Add a scrollbar when block contents grow');
echo ' | ';
echo edit_field_yes_no('block', $block);
echo ' |
';
}
}