Exemplo n.º 1
0
function listings_form($listingType, $listingSlug = false, $opts = false, $return = false)
{
    $API = new PerchAPI(1.0, 'listing');
    $defaults = array();
    $defaults['template'] = 'listings_form.html';
    $data = array();
    if (is_array($opts)) {
        $opts = array_merge($defaults, $opts);
    } else {
        $opts = $defaults;
    }
    $Template = $API->get('Template');
    $Template->set('listings/' . $opts['template'], 'listing');
    if ($listingSlug) {
        $Listings = new Listings($API);
        $Listing = $Listings->find_with_status($listingSlug, 'ALL');
        $data = $Listing->to_array();
    }
    $html = $Template->render($data);
    $html = $Template->apply_runtime_post_processing($html, $data);
    if ($return) {
        return $html;
    }
    echo $html;
}