Beispiel #1
0
				<a href="#" id="new_package" class="btn btn-success btn-block">New Package</a>
			</div>
			<div class="col-sm-6">
				<a href="?show_archived=<?php 
echo !$show_archived ? 'true' : 'false';
?>
" class="btn btn-info btn-block"><?php 
echo !$show_archived ? 'Show' : 'Hide';
?>
 Archived Packages</a>
			</div>
		</div>
		<p></p>
		<div class="list-group" id="packages">
<?php 
foreach (JinglePackages::get_all(false) as $package) {
    if (!$show_archived && $package->get_archived() == true) {
        continue;
    }
    ?>
			<a href="#" class="list-group-item <?php 
    echo $package->get_archived() ? 'list-group-item-warning' : '';
    ?>
" data-package-id="<?php 
    echo $package->get_id();
    ?>
">
				<span class="badge"><?php 
    echo $package->count_jingles();
    ?>
 jingles</span>
     }
     $package = JinglePackages::get_by_id($jsonrpc->params['id']);
     if ($package == null) {
         $jsonrpc->error('invalid package');
     }
     $jingles = array();
     foreach ($package->get_jingles() as $jingle) {
         $jingles[] = array('id' => $jingle->get_id(), 'title' => $jingle->get_title());
     }
     $jsonrpc->output(array('package' => array('id' => $package->get_id(), 'name' => $package->get_name(), 'description' => $package->get_description()), 'jingles' => $jingles));
     break;
 case 'delete_from':
     if (!isset($jsonrpc->params['package_id']) || !isset($jsonrpc->params['jingle_id'])) {
         $jsonrpc->error('invalid jingle or package');
     }
     $package = JinglePackages::get_by_id($jsonrpc->params['package_id']);
     $jingle = Jingles::get_by_id($jsonrpc->params['jingle_id']);
     $result = $package->delete_jingle($jingle);
     if ($result == true) {
         $jsonrpc->output('ok');
     } else {
         $jsonrpc->output('error');
     }
     break;
 case 'search':
     if (!isset($jsonrpc->params['q'])) {
         $jsonrpc->error('invalid search query');
     }
     $results = Search::jingles($jsonrpc->params['q']);
     $jingles = array();
     foreach ($results['results'] as $result) {