Esempio n. 1
0
 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, $change_view_allowed;
     if (ICAL_EVENTS_DEBUG) {
         echo '<br />Peak Memory So far :' . amr_memory_convert(memory_get_usage(true));
         echo '<br />Now Listing, and locale = ' . $locale . ' and list type = ' . $amr_listtype . '</h2>';
     }
     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;
     } 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 = '<div class="calendar_navigation">' . $navigation . '</div>';
     } 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 '<br />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 = '&nbsp;';
                 }
                 $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 .= '<!-- event calendar by anmari.com.  See it at icalevents.com -->';
     }
     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;
 }
Esempio n. 2
0
function amrical_mem_debug($text)
{
    if (isset($_GET['memdebug'])) {
        $mem = memory_get_usage(true);
        $peak = memory_get_peak_usage(true);
        echo '<br />memory: ' . amr_memory_convert($mem) . ' peak:' . amr_memory_convert($peak) . ' ' . $text;
        //echo '<br />memory: '.$mem.' peak:'.$peak.' '.$text;
    }
    if (isset($_GET['debugtime'])) {
        amr_track_run_time($text);
    }
}