';
$htm['cell'] ='';
$htm['cellc'] ='';
//
$htm['grow'] = ' '.AMR_NL;
$htm['ghcell'] = '';
$htm['ghcellc'] = '';
//
$htm['head'] = '';
$foot = '';
//
$htm['body'] = ''.AMR_NL;
//
$htm['box'] = ''.AMR_NL;
break;
case 'breaks' :
$htm['ul'] = '';
$htm['ulc'] = '';
$htm['li'] = '';
$htm['row'] = '';
$htm['rowc'] = '';
$htm['hcell'] =' ';
$htm['cell'] ='';
$htm['grow'] = ''.AMR_NL;
$htm['ghcell'] = $htm['hcell'];
$htm['ghcellc']= $htm['hcellc'];
$htm['head'] = ' ';
$htm['headc'] = ''.AMR_NL;
$htm['body'] = AMR_NL.''.AMR_NL;
$htm['box'] = AMR_NL.''.AMR_NL;
break;
case 'custom':
$where_am_i = 'in_events';
$htm['ul'] = '';
$htm['ulc'] = '';
$htm['li'] = '';
include ($custom_htmlstyle_file); // can check the $where_am_i
break;
default: /* the old way or tableoriginal*/
$htm['ul'] = '';
$htm['lic']= '';
$htm['row'] = ' ';
$htm['hcellc'] ='';
$htm['cellc'] ='';
$htm['ghcell'] = '';
$htm['ghcellc']= $htm['hcellc'];
$htm['head'] = AMR_NL.'';
$htm['body'] = AMR_NL.' ';
$htm['bodyc'] = AMR_NL.'';
$htm['box'] = AMR_NL.''.AMR_NL;
}
return ($htm);
}
}
if (!function_exists('amr_list_events') ) {
function amr_list_events($events, $tid, $class, $show_views=true) {
global $wp_locale,
$locale,
$amr_options,
$amr_limits,
$amr_listtype,
$amr_liststyle,
$amr_current_event,
$amrW,
$amrtotalevents,
$amr_globaltz,
$amr_groupings,
$amr_event_columns, //20151018
$change_view_allowed;
if (ICAL_EVENTS_DEBUG) {
echo '
Peak Memory So far :'.amr_memory_convert(memory_get_usage(true));
echo '
Now Listing, and locale = '.$locale.' and list type = '.$amr_listtype.'';
}
if (!defined('AMR_NL')) define('AMR_NL','PHP_EOL');
/* we want to maybe be able to replace the table html for alternate styling - may need to keep the li items though */
$amrconstrainedevents = count($events);
$html = '';
if (in_array ($amr_liststyle, array('smallcalendar','largecalendar','weekscalendar'))) {
/* is it a calendar box we want - handle separately */
$html = amr_events_as_calendar($amr_liststyle, $events, $tid, $class);
return($html);
}
$columns = $amr_event_columns; // 20151018 add so we can use easily//prepare_order_and_sequence ($amr_options['listtypes'][$amr_listtype]['compprop']);
if (!$columns) return; // no display requested
else $no_cols = count($columns);
/* --- setup the html tags ---------------------------------------------- */
$htm = amr_get_html_structure ($amr_liststyle, $no_cols);
/* -- show view options or not ------------------------------------------*/
if ((isset($amr_limits['show_views']))
and ($amr_limits['show_views']) and $change_view_allowed) {
$views = amrical_calendar_views();
}
else
$views = '';
/* -- show month year nav options or not ----------------NOT IN USE - need to lift code out for reuse --------------------------*/
$start = amr_newDateTime('now');
if (!empty($amr_limits['start']))
//$start = amr_newDateTime('now');
//else
$start = clone $amr_limits['start'];
$navigation = '';
if ((isset($amr_limits['show_month_nav']))
and ($amr_limits['show_month_nav']) ) {
if (isset ($amr_limits['months']))
$months = $amr_limits['months'];
else
$months = 1;
// $start = new Datetime('now',$amr_globaltz);
// $start = clone $amr_limits['start'];
$navigation = amr_calendar_navigation($start, $months, 0, $amr_liststyle); // include month year dropdown with links
$navigation = '';
}
else {
if ((isset($amr_limits['month_prev_next'])) and $amr_limits['month_prev_next']
and function_exists('amr_do_month_prev_next_shortcode')) {
$navigation .= amr_do_month_prev_next_shortcode();
}
if ((isset($amr_limits['month_year_dropdown'])) and $amr_limits['month_year_dropdown']
and function_exists('amr_month_year_navigation')) {
$navigation .= amr_month_year_navigation($start);
}
}
/* -- heading and footers code ------------------------------------------*/
if (isset($amr_limits['headings']))
$doheadings = $amr_limits['headings'];
else
$doheadings = true;
if (isset($amr_limits['pagination']))
$dopagination = $amr_limits['pagination'];
else
$dopagination = true;
$headhtml = '';
if ($doheadings) {
$docolheading=false;
if (ICAL_EVENTS_DEBUG) {echo '
Headings? '; var_dump($amr_options['listtypes'][$amr_listtype]['heading']);}
foreach ($amr_options['listtypes'][$amr_listtype]['heading'] as $i => $h) {
if (!empty($h))
$docolheading=true;
}
if ($docolheading) {
foreach ($columns as $i => $col) {
if (isset($amr_options['listtypes'][$amr_listtype]['heading'][$i]))
$colhead = __($amr_options['listtypes'][$amr_listtype]['heading'][$i],'amr-ical-events-list');
else
$colhead = ' ';
$headhtml .= amr_do_a_headercell_html($htm, $i, $colhead);
}
$html .= amr_do_column_header_html($htm, $i, $headhtml);
}
}
/* ***** with thechange in list types, we have to rethink how we do the footers .... for tables we say the footers up front, but for others not. */
$fhtml = '';
if ((isset($amr_options['ngiyabonga']) and ($amr_options['ngiyabonga'])))
$fhtml .= amr_ngiyabonga();
else
$fhtml .='';
if ((isset($amr_limits['show_look_more'])) and ($amr_limits['show_look_more'])) {
$fhtml .= amr_show_look_more();
}
if ((!empty($amr_limits)) and ($amrtotalevents > $amrconstrainedevents) ) {
if ($dopagination and function_exists('amr_semi_paginate'))
$fhtml .= amr_semi_paginate();
if (function_exists('amr_ical_edit'))
$fhtml .= amr_add_new_event_link();
}
$alt = false;
/* -- body code ------------------------------------------*/
/* ----------- check for groupings and compress these to requested groupings only */
$groupings = amr_get_groupings_requested ();
$groupedevents = amr_assign_events_to_groupings ($groupings, $events); // will just return if no grouping
$html .= amr_list_events_in_groupings ($htm, '', $columns, $groupedevents, $events);
if (!empty ($tid)) {
$tid = ' id="'.$tid.'" ';
}
$html = ((!empty($htm['box'])) ? ($htm['box'].$tid.' class="'.$class.'">') : '')
.$html
.$htm['boxc']
.$fhtml;
$html =
$views.AMR_NL
.$navigation.AMR_NL
.$html.AMR_NL;
return ($html);
}
}
if (!function_exists('amr_show_more_prev')) {
// coming later maybe, or will mods to look more be adequate?
// - show 'more' on page 2 onwards
// - on page 2 onwards, show see previous (like a back button?)
// - do not show more on last page - have to check DB for 'last event date' ? may slow things down
function amr_show_more_prev() {
}
}
if (!function_exists('amr_show_look_more')) { // does a google style next
function amr_show_look_more() {
global $amr_limits,
$amr_options,
$amr_formats,
$amr_globaltz,
$amr_last_date_time;
$next = new datetime('',$amr_globaltz);
if (!empty($amr_last_date_time)) {
$next = clone $amr_last_date_time; // get last used event date
}
else {
$amr_last_date_time = $amr_limits['end'] ;
$next = $amr_limits['end'] ;
}
date_time_set($next,0,0,0); // set to the beginning of the day
$prev = $amr_limits['start'] ;
$nexturl = add_query_arg ('events', $amr_limits['events']*2);
$prevurl = remove_query_arg ('events');
// if no events, then this makes no sense $explaint = sprintf (__('Displaying %s events.'),$amr_limits['events']) ;
$explaint = '';
// due to events limit, it may not show all events in a given day, so do not say displaying until date,
// rather just start the next display from that last date - may be a few events that overlap.
foreach ($amr_limits as $i=>$value) {
if (in_array ($i, array('days','hours','months','weeks'))) {
$nexturl = add_query_arg ($i, $value, $nexturl);
$prevurl = add_query_arg ($i, $value, $prevurl);
date_modify($prev, '-'.$value.' '.$i); // work back to the previous event
}
}
$nextd = $next->format("Ymd");
$prevd = $prev->format("Ymd");
$nexturl = (add_query_arg (array ('start'=>$nextd ), $nexturl));
$prevurl = (add_query_arg (array ('start'=>$prevd ), $prevurl));
// NB MUST increase the number of events otherwise one can get caught in a situation where if num of events less than events in a day, one can never get past that day.
if (empty($amr_options['lookmoremessage']))
$moret = __('Look for more', 'amr-ical-events-list');
else
/* translators: ignore, the text appears for translation eslewhere */
$moret = __($amr_options['lookmoremessage'],'amr-ical-events-list');
$morett = sprintf( __('Look for more from %s' ,'amr-ical-events-list'),$amr_last_date_time->format($amr_formats['Day']));
if (!empty($_REQUEST['start'])) {
if (empty($amr_options['lookprevmessage']))
$prevt = '';
else
/* translators: ignore, the text appears for translation eslewhere */
$prevt = __($amr_options['lookprevmessage'],'amr-ical-events-list');
if (empty($amr_options['resetmessage']))
$reset = ''; // allow it to be blanked out
else
/* translators: ignore, the text appears for translation eslewhere */
$reset = __($amr_options['resetmessage'],'amr-ical-events-list');
}
else { // if we on first page, do not show
$reset = '';
$prevt = '';
}
if (!empty ($reset) ) {
$reseturl = remove_query_arg(array('start','startoffset','events','days','months','hours','weeks'));
$reset =''.$reset.'';
}
if (!empty ($prevt) ) {
$prevt =''.$prevt.'';
}
return (
' '
.$prevt.' '
.$reset.' '
.''.$moret.''
.''
);
}
}
if (!function_exists('amr_parseModifiers')) {
function amr_parseModifiers($text) {
/* NAME="Contact Name";ID=28380;TYPE=SingleLine
*/
$modifers = array();
$p = explode (';',$text); /* if only a single will still return one array value */
foreach ($p as $i => $v) {
$eq = strpos($v,'=');
$pmodifier = substr ($v,0,$eq);
$pvalue = substr ($v,$eq+1);
$func = 'amr_parse'.$pmodifier;
if (function_exists ($func)) {
$modifers[$pmodifier] = (call_user_func($func, $pvalue));
}
else {
$modifers[$pmodifier] = $pvalue;
}
}
return ($modifers);
}
}
if (!function_exists('amr_format_repeatable_property')) {
function amr_format_repeatable_property ($content, $k, $event, $before='', $after='') {
// for properties that can have multiple values and for which we have received an array of those values, we need to do the format routine for each value
$c = '';
foreach ($content as $i => $v) {
if (!(empty($v))) {
$c .= amr_format_value ($v, $k, $event, $before,$after) .' ';
}
}
return ($c);
}
}
if (!function_exists('amr_format_value')) {
function amr_format_value ($content, $k, $event, $before='', $after='') { /* include the event so we can check for things like all day */
/* Format each Ical value for our presentation purposes
Note: Google does toss away the html when editing the text, but it is there if you add but don't edit.
what about all day?
*/
global $amr_formats; /* amr check that this get set to the chosen list type */
global $amr_options;
global $amr_listtype;
global $eventtaxonomies;
//echo '
'.$k;
if (empty($content)) return('');
if ($k == 'ORGANIZER') { // it is an array but a parsed one, not repeatable
$htmlcontent = amr_format_organiser ($content);
}
elseif ($k == 'ATTENDEE') { // it is an array but a parsed one, not repeatable
$htmlcontent = amr_format_attendees ($content);
}
elseif ($k == 'Attendee-counts') { // it is an array but we format the whole thing once
$htmlcontent = amr_format_attendee_counts ($content);
}
else if (is_object($content)) {
switch ($k){
case 'EventDate': {
$htmlcontent = (''
.amr_format_date ('c', $content).'">' //must be ISO 8601 date for microformats to work
.amr_format_date ($amr_formats['Day'], $content)
.''
);
break;
}
case 'EndDate': {
$days = amr_event_is_multiday($event);
if ( $days > 1)
$htmlcontent = ('' //must be ISO 8601 date
.amr_format_date ($amr_formats['Day'], $content)
.''
);
else $htmlcontent = '';
break;
}
case 'EndTime':
case 'StartTime':{
if (isset($event['allday']) and ($event['allday'] === 'allday'))
$htmlcontent = '';
else
$htmlcontent = amr_format_time ($amr_formats['Time'], $content);
break;
}
case 'DTSTART':
case 'DTEND':
case 'UNTIL': {
$htmlcontent = amr_format_date ($amr_formats['Day'], $content);
if (empty($event['allday']) or !($event['allday'] == 'allday'))
$htmlcontent .= ' '.amr_format_time ($amr_formats['Time'], $content);
break;
}
case 'X-WR-TIMEZONE': { /* amr need to add code to reformat the timezone as per admin entry. Also only show if timezone different ? */
$htmlcontent = amr_format_tz(timezone_name_get($content));
break;
}
case 'TZID': { /* amr need to add code to reformat the timezone as per admin entry. Also only show if timezone different ? */
$htmlcontent = amr_format_tz (timezone_name_get($content));
break;
}
case 'timezone': { /* amr need to add code to reformat the timezone as per admin entry. Also only show if timezone different ? */
$htmlcontent = amr_format_timezone ($content);
break;
}
default: /* should not be any */
$htmlcontent = amr_format_date ($amr_formats['DateTime'], $content);
}
}
elseif (is_array($content)) {
if ($k === 'DURATION') {
$htmlcontent = amr_format_duration ($content);
}
elseif (($k === 'RRULE') or ($k === 'EXRULE')) {
$htmlcontent = amr_format_rrule($content);
}
elseif (($k === 'RDATE') or ($k === 'EXDATE')) {
$htmlcontent = amr_prettyprint_r_ex_date ($content);
}
elseif ($k=== 'CATEGORIES') { // umm - what if ics category
$htmlcontent = amr_format_taxonomies ('category', $content);
}
elseif ($k=== 'post_tag' ) {
$htmlcontent = amr_format_taxonomies ('post_tag', $content);
}
elseif ($k == 'ATTACH') {
if (isset($content[0]['type'] )) {
// then we are at the top level of the array, so can ask to handled repetaed values
return ( amr_format_repeatable_property ($content, $k, $event, $before, $after));
}
else
$htmlcontent = amr_format_attach ($content, $event);
}
else { /* simple array don't think we need to list the items separately eg: multiple comments or descriptions - just line */
if (!empty( $eventtaxonomies) and in_array( $k, $eventtaxonomies)) {
$htmlcontent = amr_format_taxonomies ($k, $content);
}
else {
return( amr_format_repeatable_property ($content, $k, $event, $before, $after));
}
}
}
elseif (is_null($content) OR ($content === ''))
$htmlcontent = '';
else {
if (function_exists ('amr_format_'.$k)) {
$htmlcontent =(call_user_func('amr_format_'.$k, $content));
}
else
switch ($k){
case 'COMMENT':
case 'DESCRIPTION': {
//var_dump($content);
$htmlcontent = html_entity_decode(amr_click_and_trim(nl2br2(amr_amp($content))));
break;
}
case 'SUMMARY':
case 'icsurl':
case 'addtogoogle':
case 'addevent':
case 'subscribeevent':
case 'subscribeseries':
case 'map':
case 'refresh':
case 'attending_event': {
$htmlcontent = $content; /* avoid hyperlink as we may have added url already */
break;
}
case 'URL': /* assume valid URL, should not need to validate here, then format it as such */
$htmlcontent = amr_format_url($content);
break;
case 'LOCATION': {
$htmlcontent = (amr_click_and_trim(nl2br2(amr_amp($content))));
break;
}
case 'X-WR-TIMEZONE':{ /* not parsed as object - since it is cal attribute, not property attribue */
$htmlcontent = (amr_format_tz ($content));
break;
}
case 'allday': {
$htmlcontent =(amr_format_allday($content));
break;
}
default: /* Convert any newlines to html breaks */
if (!empty( $eventtaxonomies) and in_array( $k, $eventtaxonomies)) {
$htmlcontent = amr_format_taxonomies ($k, $content);
}
else {
$func = 'amr_format_'.str_replace('-','_',$k);
if (function_exists($func)) {
$htmlcontent = call_user_func ($func, $content);
}
else $htmlcontent = $content;
$htmlcontent = str_replace("\n", "
", $htmlcontent);
}
}
}
if (empty ($htmlcontent) )
return;
return ($before.$htmlcontent.$after);
}
}
if (!function_exists('amr_wp_format_date')) {
function amr_wp_format_date( $format, $datestamp, $gmttf) { /* want a integer timestamp or a date object */
/* Need to get rid the unnecessary date logic - should only be using date objects for now */
if (is_object($datestamp)) {
$offset = $datestamp->getOffset();
If (isset ($_REQUEST['tzdebug'])) {
echo '
Want to format '.$datestamp->format('Ymd His').' in '.$format.' like this '.$datestamp->format($format).' but localised';
// echo '
Add offset '.$offset/(60*60).' back to Unix timestamp to force correct localised date ';
}
$dateInt = $datestamp->format('U') + $offset; //to get the time in right timezone
}
else if (is_integer ($datestamp))
$dateInt = $datestamp;
else return(false);
if (stristr($format, '%') )
return (strftime( $format, $dateInt )); /* keep this for compatibility! will not localise though */
else {
//var_dump($dateInt);
$text = date_i18n($format, $dateInt, $gmttf); /* should be false, otherwise we get the utc/gmt time. */
If (false and isset ($_REQUEST['tzdebug']))
{
echo '
Localised with gmt=false: '.$text.'
';
$text2 = date_i18n($format, $dateInt, false);
echo 'Localised with gmt=true: '.$text2.'
';
$text3 = amr_date_i18n ('D, F j, Y g:i a', $datestamp);
echo 'Localised with amr date obj fn: '.$text3.'
';
}
return ($text); //
}
}
}
if (!function_exists('amr_show_in_events_timezone')) {
function amr_show_in_events_timezone( $amr_globaltz, $e) {
// if we are here, then we want to change global tz to this events tz, change for each event if the event has a tz
global $ical_timezone;
if (isset($_REQUEST['debugtz'])) {
echo '
applying tz filter';
var_dump($e);
}
if (!empty($e['timezone']) and is_object($e['timezone']))
$amr_globaltz = $e['timezone'];
else
$amr_globaltz = $ical_timezone; // must reset it else will just use last events timezone - bad for local floating events
return ($amr_globaltz);
}
}
if (!function_exists('amr_decide_display_timezone')) {
function amr_decide_display_timezone($e) { // if we want to display event timezones only, then set the global tz here for each event
global $amr_globaltz;
// timezone will only be altered if filter has been applied
$amr_globaltz = apply_filters('amr_show_in_events_timezone', $amr_globaltz, $e, 2);
}
}
if (!function_exists('amr_format_time')) {
function amr_format_time( $format, $datestamp) { /* want a integer timestamp or a date object */
global $amr_globaltz;
date_timezone_set ($datestamp, $amr_globaltz); /* Converting here, but then some derivations wrong eg: unsetting of end date */
// check for midnight, midday, noon etc
$time = $datestamp->format('His');
if (isset($_GET['tzdebug'])) echo '
Time='.$time;
$humanspeak = apply_filters('amr_human_time',$time);
if (!($time === $humanspeak )) return($humanspeak);
else
return (amr_format_date( $format, $datestamp)) ;
}
}
if (!function_exists('amr_format_date')) {
function amr_format_date( $format, $datestamp) { /* want a integer timestamp or a date object */
global $amr_options,
$amr_globaltz;
//if (is_string($datestamp)) $datestamp = date_create($datestamp, $amr_globaltz);
if (isset ($amr_options ['date_localise']))
$method = $amr_options ['date_localise'];
else
$method = 'wp'; // v4.0.9 was none
date_timezone_set ($datestamp, $amr_globaltz); /* Converting here, but then some derivations wrong eg: unsetting of end date */
if (isset($_GET['tzdebug'])) echo '
'.$datestamp->format('c');
if ($method === 'wp')
return amr_wp_format_date ( $format, $datestamp, false);
else if ($method === 'wpgmt')
return amr_wp_format_date ( $format, $datestamp, true);
else if ($method === 'amr')
return amr_date_i18n ( $format, $datestamp);
else {
if (stristr($format, '%') )
return (strftime( $format, $datestamp->format('U') )); /* keep this for compatibility! will not localise though */
else
return ($datestamp->format($format));
}
}
}
if (!function_exists('amr_format_duration')) {
function amr_format_duration ($arr) {
/* receive an array of hours, min, sec */
foreach ($arr as $i => $d) if ($d === 0) unset ($arr[$i]);
$i = count($arr);
if ($i > 1) $sep = ', ';
else $sep = '';
$d = '';
if (isset ($arr['years'] )) {
$d .= sprintf (_n ("%u year", "%u years", $arr['years'], 'amr-ical-events-list'), $arr['years']);
$d .= $sep;
$i = $i-1;
}
if (isset ($arr['months'] )) {
$d .= sprintf (_n ("%u month ", "%u months ", $arr['months'], 'amr-ical-events-list'), $arr['months']);
if ($i> 1) {$d .= $sep;}
$i = $i-1;
}
if (isset ($arr['weeks'] )) {
$d .= sprintf (_n ("%u week ", "%u weeks", $arr['weeks'], 'amr-ical-events-list'), $arr['weeks']);
if ($i> 1) {$d .= $sep;}
$i = $i-1;
}
if ((isset ($arr['days'] )) ) {
$d .= sprintf (_n ("%u day", "%u days", $arr['days'], 'amr-ical-events-list'), $arr['days']);
// If (ICAL_EVENTS_DEBUG) {echo ' and d = '.$d;}
if ($i> 1) {$d .= $sep;}
$i = $i-1;
}
if (isset ($arr['hours'] )) {
$d .= sprintf (_n ("%u hour", "%u hours", $arr['hours'], 'amr-ical-events-list'), $arr['hours']);
if ($i> 1) {$d .= $sep;}
$i = $i-1;
}
if (isset ($arr['minutes'] )) {
$d .= sprintf (_n ("%u minute", "%u minutes", $arr['minutes'], 'amr-ical-events-list'), $arr['minutes']);
if ($i> 1) {$d .= $sep;}
$i = $i-1;
}
if (isset ($arr['seconds'] )) {
$d .= sprintf (_n ("%u second", "%u seconds", $arr['seconds'], 'amr-ical-events-list'), $arr['seconds']);
}
return($d);
}
}
if (!function_exists('amr_format_tz')) { // this is the change timezone icon in the header
function amr_format_tz ($tzstring) {
global $amr_globaltz, $amr_options;
$url = esc_url_raw($_SERVER['REQUEST_URI']);
$tz = timezone_name_get($amr_globaltz);
if ($tz === $tzstring)
$tz2 = date_default_timezone_get();
else
$tz2 = $tzstring;
if ($tz2===$tz)
$tz2 = 'UTC';
$text1 = __('Change Timezone','amr-ical-events-list');
$text2 = sprintf( __('Timezone: %s, Click for %s','amr-ical-events-list'),$tz, $tz2);
if (isset ($amr_options['no_images']) and $amr_options['no_images'])
$t3 = $text1;
else
$t3 = '
';
return (''.$t3.' ');
}
}
if (!function_exists('amr_format_timezone')) { // this is the change timezone icon in the header
function amr_format_timezone ($tzobj) {
global $amr_options;
if (is_object($tzobj))
$tzstring = timezone_name_get($tzobj);
else
$tzstring = $tzobj;
return ($tzstring);
}
}
if (!function_exists('adebug')) { // we are loading late, so hope fully this should be fine - don't want top long a name
function adebug( $text, $whattodebug=true) {
if ((isset ($_REQUEST['debug']) ) and ($_REQUEST['debug'] == $whattodebug))
echo $text;
}
}
if (!function_exists('amr_format_binary')) { // amr maybe move to plus ?
function amr_format_binary ($name,$binary) {
// getting error - data not in recognised format in the binary, so skip for now till someone wants it
return null;
$im = imagecreatefromstring($binary);
$filename = ICAL_EVENTS_CACHE_LOCATION.'/ical-events-cache/'.$name.'.jpg';
// Save the image as 'simpletext.jpg'
imagejpeg($im, $filename);
$uploads = wp_upload_dir();
$url = $uploads[base_url].'/ical-events-cache/'.$name;
return($url);
}
}
if (!function_exists('amr_format_mailto')) { //201710
function amr_format_mailto ($mailto, $text='email', $title='email') {
return (''.$text.'');
}
}
if (!function_exists('amr_format_organiser')) {
function amr_format_organiser ($org) {/* receive array of hopefully CN and MAILTO, and possibly SENTBY */
If (ICAL_EVENTS_DEBUG) {echo '
Organiser array: '; var_dump($org);}
$text = '';
if (!(is_array($org))) {
$org = amr_parseOrganiser('ORGANIZER;'.$org); // may not have been parsed yet (eg in wp events)
//$org = amr_parse_property ('ORGANIZER;'.$org);
If (ICAL_EVENTS_DEBUG) var_dump($org);
}
if (!empty ($org['CN'])) {
if (!empty ($org['MAILTO']))
$text = amr_format_mailto ($org['MAILTO'], $org['CN'],
$title=__('Organiser', 'amr-ical-events-list'));
//''.$org['CN'].'';
else
$text = $org['CN'];
}
else {
if (!empty ($org['MAILTO']))
$text = amr_format_mailto ($org['MAILTO'], $org['MAILTO'],
$title=__('Organiser', 'amr-ical-events-list'));
//''.$org['MAILTO'].'';
}
if (!empty ($text)) $text .= ' ';
if (!empty ($org['SENT-BY'])) {
$text .= __('Sent by ','amr-ical-events-list').''.$org['SENT-BY'].'';
}
return($text);
}
}
/*
= "ROLE" "="
("CHAIR" ; Indicates chair of the
; calendar entity
/ "REQ-PARTICIPANT" ; Indicates a participant whose
; participation is required
/ "OPT-PARTICIPANT" ; Indicates a participant whose
; participation is optional
/ "NON-PARTICIPANT" ; Indicates a participant who
; is copied for information
; purposes only
/ x-name ; Experimental role
/ iana-token) ; Other IANA role
; Default is REQ-PARTICIPANT
"PARTSTAT" = ("NEEDS-ACTION" ; Event needs action
/ "ACCEPTED" ; Event accepted
/ "DECLINED" ; Event declined
/ "TENTATIVE" ; Event tentatively
; accepted
/ "DELEGATED" ; Event delegated
/ x-name ; Experimental status
/ iana-token) ; Other IANA-registered
; status
; These are the participation statuses for a "VEVENT".
; Default is NEEDS-ACTION.
RSVPPurpose: To specify whether there is an expectation of a favor of a
reply from the calendar user specified by the property value.
rsvpparam = "RSVP" "=" ("TRUE" / "FALSE")
; Default is FALSE
"CUTYPE" "="
("INDIVIDUAL" ; An individual
/ "GROUP" ; A group of individuals
/ "RESOURCE" ; A physical resource
/ "ROOM" ; A room resource
/ "UNKNOWN" ; Otherwise not known
/ x-name ; Experimental type
/ iana-token) ; Other IANA-registered
; type
; Default is INDIVIDUAL
SENT-BY
DELEGATED-FROM
DELEGATED-TO
MEMBER
DIR
ORGANIZER;DIR="ldap://example.com:6666/o=ABC%20Industries,
c=US???(cn=Jim%20Dolittle)":mailto:jimdo@example.com
*/
if (!function_exists('amr_format_attendee_counts ')) {
function amr_format_attendee_counts ($status) {
$text = array();
foreach ($status as $s => $n) {
if (!empty($n)) {
$text[] = amr_format_PARTSTAT ($s)
.' ('.$n.')';
}
}
return implode(' ',$text);
}
}
if (!function_exists('amr_derive_attendee_counts')) { // given array of attendees
function amr_derive_attendee_counts($attendees) {
$text = '';
$status = array(); //'ACCEPTED','TENTATIVE','DELEGATED','NEEDS-ACTION','DECLINED','COMPLETED','IN-PROCESS'
if (is_array($attendees)) {
// How should they be sorted ?
// CN alpha? or email alpha or by part stat? or role ?
//amr_sort_by_two_cols ('ROLE', 'CN', $attendees); // sort by participaton status, may include all
foreach ($attendees as $i => $attendee) {
if (empty($attendee['PARTSTAT'])) {
if (empty($status['NEEDS-ACTION'])) // the default
$status['NEEDS-ACTION'] = 1;
else
$status['NEEDS-ACTION']++; // RFC 5545 default
}
else {
// add count
if (empty($status[$attendee['PARTSTAT']]))
$status[$attendee['PARTSTAT']] = 1;
else
$status[$attendee['PARTSTAT']]++;
}
}
}
return $status;
}
}
if (!function_exists('amr_format_attendees') ) { // overwritten by addon
function amr_format_attendees ($attendees) {/* receive array of hopefully attendess[] CN and MAILTO, and possibly other */
// in plain ics only individuals and accepted attendees listed and by plain name only
// maybe show some stats ?
$text = '';
$status = array(); //'ACCEPTED','TENTATIVE','DELEGATED','NEEDS-ACTION','DECLINED','COMPLETED','IN-PROCESS'
if (is_array($attendees)) {
// How should they be sorted ?
// CN alpha? or email alpha or by part stat? or role ?
amr_sort_by_two_cols ('ROLE', 'CN', $attendees); // sort by role then name
foreach ($attendees as $i => $attendee) { // only shows accepted attendance
if ($attendee['PARTSTAT'] == 'ACCEPTED') {
$list[] = amr_format_attendee ($attendee);
}
}
if (!empty($list)) {
//$text .= '- '.implode ('
- ',$list).'
';
$text = implode (PHP_EOL.'
',$list);
}
}
return($text);
}
}
if (!function_exists('amr_format_PARTSTAT') ) { // called from format attendee
function amr_format_PARTSTAT ($participation_status) {
$text = '';
switch ($participation_status) {
case 'ACCEPTED': $text = ' √ '.$text ; break;
case 'DECLINED': $text = ' ✘ '. $text; break;
case 'TENTATIVE': $text = ' ? '. $text; break;
case 'DELEGATED': $text = ' → '. $text ; break;
case 'NEEDS-ACTION': $text = ' ! '. $text ; break;
}
return (''.$text.'');
}
}
if (!function_exists('amr_format_attendee') ) { // format a single attendee - maybe show role, status etc - overwritten by addon
function amr_format_attendee ($attendee) { // do not show emails for privacy reasons
// array could have
//CUTYPE=INDIVIDUAL
//ROLE=REQ-PARTICIPANT
//PARTSTAT=ACCEPTED or PARTSTAT=NEEDS-ACTION Participation status
// "ACCEPTED" ,"DECLINED","TENTATIVE", "DELEGATED
//X-NUM-GUESTS=0
//CN=Common name
//DELEGATED-FROM="mailto:bob@example.com
//SENT-BY=mailto:jan_doe@example.com
$text = '';
if (!empty ($attendee['CN'])) {
if (!empty ($attendee['LINK'])) // internal amr-events representation , not RFC5545 spec
$text = ''.$attendee['CN'].'';
else
$text = $attendee['CN'];
}
else { // we have no name, maybe just use the bit before the '@'
if (isset($attendee['text'])) { // maybe use this text
$text = $attendee['text'];
}
elseif (isset($attendee['MAILTO'])) { // maybe use this text
//$text = $attendee['MAILTO'];
$text = stristr($attendee['MAILTO'],'@', true);
}
else {
if (is_array($attendee)) {// now we desparate, dump the lot just in case but indicate we not happy
$text= '?? '.implode(', ', $attendee);
}
else
$text = '?? '.$attendee;
}
}
if (!empty($attendee['PARTSTAT'])) {
$text = amr_format_PARTSTAT ($attendee['PARTSTAT'], $attendee).' '.$text;
}
return ($text);
}
}
';
//
$htm['body'] = ''.AMR_NL;
//
$htm['box'] = ''.AMR_NL;
break;
case 'breaks' :
$htm['ul'] = '';
$htm['ulc'] = '';
$htm['li'] = '';
$htm['row'] = '';
$htm['rowc'] = '';
$htm['hcell'] ='
';
$htm['cell'] ='
';
$htm['grow'] = '
'.AMR_NL;
$htm['ghcell'] = $htm['hcell'];
$htm['ghcellc']= $htm['hcellc'];
$htm['head'] = '
';
$htm['headc'] = '
'.AMR_NL;
$htm['body'] = AMR_NL.''.AMR_NL;
$htm['box'] = AMR_NL.'
'.AMR_NL;
break;
case 'custom':
$where_am_i = 'in_events';
$htm['ul'] = '';
$htm['ulc'] = '';
$htm['li'] = '';
include ($custom_htmlstyle_file); // can check the $where_am_i
break;
default: /* the old way or tableoriginal*/
$htm['ul'] = '
- ';
$htm['lic']= '';
$htm['row'] = '
- '.implode ('
- ',$list).'