throw $e;
    }
}

function badge_disp($content) {
    if ($content instanceof Badge_Redirect) {
	header("Location: ".$content->url);
    } else {
	echo $content;
    }
    exit;
}

// execute op if required
if (@$params['op']) {
    badge_disp($badge->op($params['op'], $section, $params));
} else if (@$section) {
    badge_disp($badge->op('display', $section, $params));
}

// --- left sidebar (widget selection) html

function render_left_sidebar() {
    global $user;

    $page_url = PA::$url;
    $badge_list = "";
    
    foreach ($user->list_widgets() as $badge_info) {
	    list($badge_id, $title) = $badge_info;
	    $badge_list .= '<li><a href="'. $page_url .'/badge_create.php/'.htmlspecialchars($badge_id).'">'.htmlspecialchars($title ? $title : $badge_id)."</a></li>";