скрипт Events
Код: Выделить всё
if (file_exists('./modules/app_calendar/app_calendar.class.php')) {
include_once('./modules/app_calendar/app_calendar.class.php');
$calendar = new app_calendar();
$calendar->usual($out);
$events = $out['EVENTS_PASTPLAN'];
if ($events[0]['TITLE']) {
$say_phrase = 'Будущие события: ';
$total_tasks = count($events);
for($i=0;$i<$total_tasks;$i++) {
$datetime1 = date_create($events[$i]['DUE']);
$datetime2 = date_create(date('Y-m-d'));
$timeRASCHET = date_diff($datetime1, $datetime2);
$say_phrase .= ($i+1) . '. Через ' . myMorph($timeRASCHET->days, 'день', 'дня', 'дней') . ' ' . $events[$i]['TITLE'] . '. ';
}
}
}
if ($say_phrase) {
say($say_phrase, 2);
}
функция lib/my_funcs.php
Код: Выделить всё
<?php
// Склонение числительных
// string - само число
// ch1 - час, день, год, месяц
// ch2 - часа, дня, года, месяца
// ch3 - часов, дней, лет, месяцев
function myMorph($string, $ch1, $ch2, $ch3)
{
$ff=Array('0','1','2','3','4','5','6','7','8','9');
if(substr($string,-2, 1)==1 AND strlen($string)>1) $ry=array("0 $ch3","1 $ch3","2 $ch3","3 $ch3" ,"4 $ch3","5 $ch3","6 $ch3","7 $ch3","8 $ch3","9 $ch3");
else $ry=array("0 $ch3","1 $ch1","2 $ch2","3 $ch2","4 $ch2","5 $ch3","6 $ch3","7 $ch3","8 $ch3","9 $ch3");
$string1=substr($string,0,-1).str_replace($ff, $ry, substr($string,-1,1));
return $string1;
}