Beispiel #1
0
/**
 * 
 * Builds an archive listing of categories. Echoes out the resulting mark-up and content
 * @param string $template
 * @param bool $return if set to true returns the output rather than echoing it
 */
function perch_events_categories($opts = array(), $return = false)
{
    $default_opts = array('template' => 'category_link.html', 'skip-template' => false, 'cache' => true, 'include-empty' => false, 'filter' => false, 'past-events' => false);
    if (is_array($opts)) {
        $opts = array_merge($default_opts, $opts);
    } else {
        $opts = $default_opts;
    }
    if ($opts['skip-template']) {
        $return = true;
    }
    $cache = false;
    if ($opts['cache']) {
        $cache_key = 'perch_events_categories' . md5(serialize($opts));
        $cache = PerchEvents_Cache::get_static($cache_key, 10);
    }
    if ($cache) {
        if ($return) {
            return $cache;
        }
        echo $cache;
        return '';
    }
    $API = new PerchAPI(1.0, 'perch_events');
    $Events = new PerchEvents_Events($API);
    $Categories = new PerchEvents_Categories();
    $r = $Categories->get_custom($opts);
    if ($r != '' && $opts['cache']) {
        PerchEvents_Cache::save_static($cache_key, $r);
    }
    if ($return) {
        return $r;
    }
    echo $r;
    return false;
}