Ejemplo n.º 1
0
        }
    }
} catch (Exception $e) {
    print '<p><strong>Caught exception: ' . $e->getMessage() . '</strong></p>';
}
?>

	<h2>Demo two</h2>
	<p>Search for packages containing &#8220;osm&#8221; using the alias functions and search options: <code>$ckan->search($search_term, array('order_by' => 'title', 'offset' => 1, 'limit' => 2, 'openness' => 1, 'downloadable' => 1));</code> and then manually output the results.</p>

	<?php 
try {
    // Search for packages containing "osm" using the alias functions
    $search_term = 'osm';
    // search() is an alias for search_package()
    $data = $ckan->search($search_term, array('order_by' => 'title', 'offset' => 1, 'limit' => 2, 'openness' => 1, 'downloadable' => 1));
    // Display results
    if ($data) {
        printf('<h3>There %s %d result%s for &#8220;%s&#8221;:</h3>', $data->count === 1 ? 'is' : 'are', $data->count, $data->count === 1 ? '' : 's', $search_term);
        if ($data->count > 0) {
            print '<ol>';
            foreach ($data->results as $val) {
                // get_package($param) is an alias for
                // get_package_entity()
                $package = $ckan->get_package($val);
                printf('<li><a href="%s">%s</a>%s</li>', $package->ckan_url, $package->title, $package->notes ? ': ' . strip_tags(Markdown($package->notes), '<a>') : '');
            }
            print '</ol>';
        }
    }
} catch (Exception $e) {