| <?php  | 
 | /******************************************************************************* | 
 |  * Copyright (c) 2006 Eclipse Foundation and others. | 
 |  * All rights reserved. This program and the accompanying materials | 
 |  * are made available under the terms of the Eclipse Public License v1.0 | 
 |  * which accompanies this distribution, and is available at | 
 |  * http://www.eclipse.org/legal/epl-v10.html | 
 |  * | 
 |  * Contributors: | 
 |  *    Wayne Beaton (Eclipse Foundation)- initial API and implementation | 
 |  *******************************************************************************/ | 
 |  | 
 | 	#***************************************************************************** | 
 | 	# | 
 | 	# add_resource.php | 
 | 	# | 
 | 	# Author: 		Wayne Beaton | 
 | 	# Date:			February 16, 2006 | 
 | 	# | 
 | 	# Description: | 
 | 	#    This file is used to list and delete resources. | 
 | 	#**************************************************************************** | 
 | 	include('scripts/common.php'); | 
 | 	include('scripts/sql.php'); | 
 | 	 | 
 | 	function get_selected($parameter, $value) { | 
 | 		return get_parameter($parameter) == $value ? 'selected' : ''; | 
 | 	} | 
 | 	 | 
 | 	$action = get_get_parameter('action', 'list'); | 
 | 	$id = get_get_parameter('id'); | 
 | 	 | 
 | 	$broker = new ResourceBroker(); | 
 | 		 | 
 | 	if ($action == 'delete') { | 
 | 		$broker->delete_resource($id); | 
 | 	} | 
 | 	 | 
 | 	include("scripts/header.php"); | 
 | 	display_messages($broker->messages); | 
 | ?> | 
 | 	<script language="javascript" type="text/javascript"> | 
 | 		function confirm_delete(id, title) { | 
 | 			answer = confirm("Are you sure you want to delete \"" + title + "\""); | 
 | 			if (answer) { | 
 | 				window.location.href = "list_resources.php?action=delete&id="+ id; | 
 | 			} | 
 | 		} | 
 | 	</script> | 
 | 	 | 
 | 	<div class="section"> | 
 | 	<h3>List Resources</h3> | 
 |  | 
 | 	<?php | 
 | 		$result = mysql_query('select id, title from resource order by title'); | 
 | 		if ($error = mysql_error()) { | 
 | 			echo "Error querying authors: $error<br/>"; | 
 | 			break; | 
 | 		} | 
 | 	?> | 
 | 	 | 
 | 	<ul> | 
 | 	<?php | 
 | 		while ($row = mysql_fetch_array($result)) { | 
 | 			$id = $row[0]; | 
 | 			$name = $row[1]; | 
 | 	?> | 
 | 	 | 
 | 	<li><?= $name ?> <a target="_blank" href="http://www.eclipse.org/resources/resource.php?id=<?= $id ?>">[open]</a> <a href="edit_resource.php?id=<?= $id ?>">[edit]</a> <a href="javascript:confirm_delete(<?= $id ?>, '<?= $name ?>');">[delete]</a></li> | 
 | 	 | 
 | 	<?php | 
 | 		} | 
 | 	?> | 
 | 	</ul> | 
 | 	</div> | 
 |  | 
 | <?php | 
 | 	include("scripts/footer.php"); | 
 | ?> |