* Calendar - Add placeholder for birthdays {{day/birthdays}} for day table

This commit is contained in:
nathangray 2017-07-27 14:41:16 -06:00
parent 5fd6ccd409
commit ce9291d6e5

View File

@ -412,7 +412,7 @@ class calendar_merge extends Api\Storage\Merge
// Add in birthdays
if(strpos($repeat, 'day/birthdays') !== false)
{
$days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($_date);
$days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($day);
}
}
return $days[date('Ymd',$_date)][$plugin][0];
@ -518,7 +518,7 @@ class calendar_merge extends Api\Storage\Merge
// Add in birthdays
if(strpos($repeat, 'day/birthdays') !== false)
{
$days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($_date);
$days[date('Ymd', $_date)][date('l',strtotime($day))][0]['$$day/birthdays$$'] = $this->get_birthdays($day);
}
}
return $days[date('Ymd',$_date)][$plugin][0];
@ -612,16 +612,15 @@ class calendar_merge extends Api\Storage\Merge
/**
* Get replacement for birthdays placeholder
* @param int|DateTime $_date
* @param String $day Date in Ymd format
*/
protected function get_birthdays($_date)
protected function get_birthdays($day)
{
$day = date('Ymd', $_date);
$contacts = new Api\Contacts();
$birthdays = Array();
foreach($contacts->get_addressbooks() as $owner => $name)
{
$birthdays += $contacts->read_birthdays($owner, date('Y',$_date));
$birthdays += $contacts->read_birthdays($owner, substr($day, 0, 4));
}
return $birthdays[$day] ? implode(', ', array_column($birthdays[$day], 'name')) : '';
}
@ -727,8 +726,10 @@ class calendar_merge extends Api\Storage\Merge
}
echo '<tr><td>{{table/day_n}} ... {{endtable}}</td><td>1 <= n <= 31</td></tr>';
echo '</table></td></tr>';
echo '<tr><td>{{day/date}}</td><td colspan="3">'.lang('Date for the day of the week, available for the first entry inside each day of week or daily table inside the selected range.').'</td></tr>';
echo '<tr><td>{{day/name}}</td><td colspan="3">'.lang('Name of the week (ex: Monday), available for the first entry inside each day of week or daily table inside the selected range.').'</td></tr>';
echo '<tr><td colspan="2">Available for the first entry inside each day of week or daily table inside the selected range:</td></tr>';
echo '<tr><td>{{day/date}}</td><td colspan="3">'.lang('Date for the day of the week').'</td></tr>';
echo '<tr><td>{{day/name}}</td><td colspan="3">'.lang('Name of the week (ex: Monday)').'</td></tr>';
echo '<tr><td>{{day/birthdays}}</td><td colspan="3">'.lang('Birthdays').'</td></tr>';
echo '<tr><td colspan="4"><h3>'.lang('General fields:')."</h3></td></tr>";
foreach(array(