Example #1
0
function parseArticles($atts, $iscustom = 0, $thing = NULL)
{
    global $pretext, $is_article_list;
    $old_ial = $is_article_list;
    $is_article_list = $pretext['id'] && !$iscustom ? false : true;
    article_push();
    $r = $is_article_list ? doArticles($atts, $iscustom, $thing) : doArticle($atts, $thing);
    article_pop();
    $is_article_list = $old_ial;
    return $r;
}
Example #2
0
function parseArticles($atts, $iscustom = 0, $thing = null)
{
    global $pretext, $is_article_list;
    $old_ial = $is_article_list;
    $is_article_list = empty($pretext['id']) || $iscustom;
    article_push();
    $r = $is_article_list ? doArticles($atts, $iscustom, $thing) : doArticle($atts, $thing);
    article_pop();
    $is_article_list = $old_ial;
    return $r;
}
Example #3
0
function zem_event_list($atts, $thing = NULL)
{
    global $zem_thiseventcal, $pretext;
    extract(lAtts(array('wraptag' => '', 'class' => __FUNCTION__, 'break' => '', 'breakclass' => '', 'form' => 'zem_event_display', 'sort' => safe_pfx('zem_event_date') . '.event_date asc, ' . safe_pfx('zem_event_date') . '.event_time asc', 'date_from' => gps('date_from') ? gps('date_from') : 'today', 'date_to' => gps('date_to') ? gps('date_to') : '', 'date' => gps('date'), 'label' => '', 'labeltag' => '', 'limit' => '', 'category' => gps('c') ? gps('c') : @$pretext['c'], 'section' => '', 'all_categories' => gps('all_categories'), 'location' => gps('location'), 'all_locations' => gps('all_locations'), 'debug' => 0), $atts));
    if ($thing === NULL) {
        $thing = fetch_form($form);
    }
    $where = safe_pfx('zem_event_calendar') . '.id=' . safe_pfx('zem_event_date') . '.event_id and ' . safe_pfx('zem_event_calendar') . '.article_id = ' . safe_pfx('textpattern') . '.ID and ' . safe_pfx('textpattern') . '.Status >= 4 and ' . safe_pfx('textpattern') . '.Posted <= now()';
    if ($date) {
        @(list($y, $m, $d) = explode('-', $date));
        if ($y and $m and $d) {
            $date_from = $date_to = "{$y}-{$m}-{$d}";
        } elseif ($y and $m) {
            $date_from = "{$y}-{$m}-01";
            $date_to = strftime('%Y-%m-%d', strtotime('-1 day', strtotime('+1 month', strtotime($date_from))));
        } elseif ($y) {
            $date_from = "{$y}-01-01";
            $date_to = "{$y}-12-31";
        } elseif ($t = zem_strtotime($date)) {
            $date_from = strftime('%Y-%m-%d', $t);
            $date_to = strftime('%Y-%m-%d', $t);
        }
    }
    $w = zem_event_timeq($date_from, $date_to);
    if ($w) {
        $where .= ' and ' . join(' and ', $w);
    }
    if ($section) {
        $sections = do_list($section);
        $where .= " and textpattern.Section IN (" . join(',', quote_list($sections)) . ")";
    }
    if ($location and !$all_locations) {
        // location could be an array if it came from gps()
        if (is_array($location)) {
            $locs = $location;
        } else {
            $locs = do_list($location);
        }
        $where .= " and location IN (" . join(',', quote_list($locs)) . ")";
    }
    if ($q = gps('q')) {
        $where .= " and (name rlike '" . doSlash($q) . "' or description rlike '" . doSlash($q) . "')";
    }
    if ($category and !$all_categories) {
        // category could be an array if it came from gps()
        if (is_array($category)) {
            $cats = $category;
        } else {
            $cats = do_list($category);
        }
        $cats_id = safe_column('id', 'txp_category', "type='event' and name IN (" . join(',', quote_list($cats)) . ")");
        if (!$cats_id) {
            $cats_id = array(0);
        }
        $where = safe_pfx('zem_event_calendar') . ".id=" . safe_pfx('zem_event_category') . ".k1 and " . safe_pfx('zem_event_category') . ".k2 IN (" . join(',', quote_list($cats_id)) . ") and " . $where;
        $grand_total = safe_count('zem_event_calendar,zem_event_date,textpattern,zem_event_category', $where . ' group by ' . safe_pfx('zem_event_calendar') . '.id order by ' . $sort, $debug);
        $lim = zem_event_paginate($limit, $grand_total);
        $rs = safe_rows_start(safe_pfx('zem_event_calendar') . '.*, ' . safe_pfx('zem_event_date') . '.*, ' . safe_pfx('textpattern') . '.*, unix_timestamp(Posted) as uPosted', 'zem_event_calendar,zem_event_date,textpattern,zem_event_category', $where . ' group by ' . safe_pfx('zem_event_calendar') . '.id order by ' . $sort . $lim, $debug);
    } else {
        $grand_total = safe_count('zem_event_calendar,zem_event_date,textpattern', $where . ' order by ' . $sort, $debug);
        $lim = zem_event_paginate($limit, $grand_total);
        $rs = safe_rows_start('*, unix_timestamp(Posted) as uPosted', 'zem_event_calendar,zem_event_date,textpattern', $where . ' order by ' . $sort . $lim, $debug);
    }
    $out = array();
    while ($row = nextRow($rs)) {
        article_push();
        $zem_thiseventcal = $row;
        populateArticleData($row);
        $out[] = parse($thing);
        $zem_thiseventcal = NULL;
        article_pop();
    }
    return doTag($label, $labeltag, $class) . doWrap($out, $wraptag, $break, $class, $breakclass);
}