Ejemplo n.º 1
0
function amr_list_event_subset($htm, $columns, $subset, $events)
{
    // now a flat array of ids
    $html = '';
    $alt = false;
    if (!is_array($events) or count($events) < 1) {
        return '';
    }
    if (!is_array($subset) or count($subset) < 1) {
        return '';
    }
    $no_cols = count($columns);
    //	foreach ($events as $i => $e) { /* for each event, loop through the properties and see if we should display */
    foreach ($subset as $i => $eventindex) {
        /* for each event, loop through the properties and see if we should display */
        $e = $events[$eventindex];
        amr_derive_component_further($e);
        amr_decide_display_timezone($e);
        // determine timezone that this event should be shown in
        if (!empty($e['Classes'])) {
            $classes = strtolower($e['Classes']);
        } else {
            $classes = '';
        }
        $eprop = '';
        /*  each event on a new list */
        $prevcol = 0;
        $colcount = 0;
        $col = 1;
        /* reset where we are with columns */
        $rowhtml = '';
        foreach ($columns as $col => $order) {
            // prepare the row
            $eprop = '';
            foreach ($order as $k => $kv) {
                /* ie for one column in event, check how to order the bits  */
                /* Now check if we should print the component or not, we may have an array of empty string */
                if (isset($e[$k])) {
                    $v = amr_check_flatten_array($e[$k]);
                    // *** huh? shoudl we do this here?
                } else {
                    $v = null;
                }
                $selector = $htm['li'];
                $selectorend = $htm['lic'];
                if (!empty($selector)) {
                    $selector .= ' class="' . strtolower($k) . '">';
                }
                if (!empty($v)) {
                    // some custom eg: TRUMBA fields may have empty or no  values
                    $eprop .= $selector . amr_format_value($v, $k, $e, $kv['Before'], $kv['After']) . $selectorend;
                }
            }
            if (empty($eprop)) {
                $eprop = '&nbsp;';
            }
            // a value for a dummytable cell if tere were no values in the column
            // annoying but only way to pass variables by reference is through an array, must return array to then.
            // so to allow filter of column and pass which column it is, thsi is how we do it
            $tmp = apply_filters('amr_events_column_html', array('colhtml' => $eprop, 'col' => $col));
            $eprop = $tmp['colhtml'];
            if (!empty($ul)) {
                // will phase the ul's  out eventually
                $eprop = $ul . ' class="amrcol' . $col . ' amrcol">' . $eprop . $htm['ulc'];
            }
            /* each column in a cell or list */
            $cellclasses = '';
            if (!empty($htm['cell'])) {
                // if we have a selector that surounds each property , then add classes.
                $cellclasses .= ' amrcol' . $col;
                if ($col == $no_cols) {
                    $cellclasses .= ' lastcol';
                    /* only want the cell to be lastcol, not the row */
                }
                $thiscolumn = $htm['cell'] . ' class="' . $cellclasses . '">' . $eprop . (empty($htm['cellc']) ? '' : $htm['cellc']);
            } else {
                $thiscolumn = $eprop;
            }
            $rowhtml .= $thiscolumn;
            // build up the row with each column
        }
        // end row
        // so now we have finished that group, start next
        // save the event or row,  for next group
        if (!empty($rowhtml)) {
            $tmp = apply_filters('amr_events_event_html', array('rowhtml' => $rowhtml, 'event' => $e));
            $rowhtml = $tmp['rowhtml'];
            $rowhtml = (!empty($htm['row']) ? $htm['row'] . ($alt ? ' class="odd alt' : ' class="') . $classes . ' event"> ' : '') . $rowhtml . $htm['rowc'];
            if ($alt) {
                $alt = false;
            } else {
                $alt = true;
            }
            $html .= $rowhtml;
            /* build  the group of events , adding on eprop */
            $rowhtml = '';
        }
    }
    //end of row or event
    return $html;
}
Ejemplo n.º 2
0
function amr_list_one_days_events($events, $columns)
{
    /* for the large calendar */
    global $amr_options, $amr_limits, $amr_listtype, $amrW, $amrtotalevents;
    if (empty($events)) {
        return;
    }
    $html = '';
    $no_cols = 1;
    /* --- setup the html tags ------need to have divs if want to allow html else must strip---------------------------------------- */
    $ev = AMR_NL . '<div class="event';
    $evc = '</div> ';
    /* -- body code ------------------------------------------*/
    $groupedhtml = '';
    // need to resort in case we have messed the timing up, keep the multi days to the top, hopefully in the order that they were in before.
    // done earlier // $events = amr_sort_by_two_cols ('dummytime','MultiDay', $events); //20140805
    foreach ($events as $i => $e) {
        /* for each event, loop through the properties and see if we should display */
        amr_derive_component_further($e);
        if (!empty($e['Classes'])) {
            $classes = strtolower($e['Classes']);
        } else {
            $classes = '';
        }
        $eventhtml = '';
        /*  each event on a new list */
        $colhtml = array();
        foreach ($columns as $col => $order) {
            $colhtml[$col] = '';
            foreach ($order as $field => $fieldconfig) {
                /* ie for one event, check how to order the bits */
                /* Now check if we should print the component or not, we may have an array of empty string - check our event has that value */
                if (isset($e[$field])) {
                    $v = amr_check_flatten_array($e[$field]);
                } else {
                    $v = null;
                }
                if (!empty($v)) {
                    //						$col = $fieldconfig['Column'];
                    $colhtml[$col] .= amr_format_value($v, $field, $e, $fieldconfig['Before'], $fieldconfig['After']);
                    /* amr any special formating here */
                }
            }
        }
        foreach ($colhtml as $col => $chtml) {
            $eventhtml .= empty($chtml) ? AMR_NL : AMR_NL . '<div class="details' . $col . '">' . $chtml . '</div>';
        }
        if (!($eventhtml === '')) {
            /* ------------------------------- if we have some event data to list  */
            $eventhtml = $ev . $classes . '">' . $eventhtml . $evc;
        }
        $html .= AMR_NL . $eventhtml;
    }
    //if (!empty($html)) $html = $html.$ulc;
    return $html;
}