Location: PHPKode > projects > Phpman > phpman-2.0a_RC2/admin/languages.php
<?php
/**
* Manage languages
* @package phpman
* @copyright (c) 2004 Samuel Suter
* @author Samuel Suter <hide@address.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
* @version 1.0
**/
?>
<h1><?=$lang->languages?></h1>
<?php
if($_REQUEST["add"]) {
	editLang();
} elseif($_REQUEST["edit"]) {
	editLang($_REQUEST["edit"]);
} elseif($_REQUEST["delete"]) {
	$table = new mlsDBtable("#__languages","isocode",$database);
	$table->delete($_REQUEST["data"]["language_ID"]);
	listLang();
} elseif($_REQUEST["save"]) {
	saveLang($_REQUEST["data"]);
	listLang();
} else {
	listLang();
}

function saveLang($data) {
	global $database,$lang;
	$table = new mlsDBtable("#__languages","language_ID",$database);
	$table->bind($data);
	$table->store();
};

function editLang($id = 0) {
	global $database,$lang;
	$table = new mlsDBtable("#__languages","language_ID",$database);
	$data = $table->load($id);
	?>
	<form method="POST" action="index.php" name="adminForm">
	<input type="hidden" name="data[language_ID]" value="<?=$data["language_ID"] ?>">
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="admintable">
		<tr>
			<td class="form"><?=$lang->isocode?>:</td>
			<td class="form"><input class="inputbox" size="40" type="text" name="data[isocode]" value="<?=$data["isocode"] ?>"></td>
		</tr>
		<tr>
			<td class="form"><?=$lang->language?>:</td>
			<td class="form"><input class="inputbox" size="40" type="text" name="data[language]" value="<?=$data["language"] ?>"></td>
		</tr>
		<tr>
			<td></td>
			<td>
			<input type="submit" name="save" value="<?=$lang->save?>">
			<input type="submit" name="delete" value="<?=$lang->delete?>">
			</td>
		</tr>
		</table>
		<input type="hidden" name="page" value="<?=$_REQUEST["page"]?>">
		<input type="hidden" name="lang" value="<?=$_REQUEST["lang"]?>">
		</form>
	<?php
}
function listLang() {
	global $database,$lang;
	$table = new mlsDBtable("#__languages","isocode",$database);
	$table->select('','isocode','ASC');
	$rows = $table->_db->loadRowsAssoc();
	?>
	[ <a href="?page=<?=$_REQUEST["page"]?>&lang=<?=$_REQUEST["lang"]?>&add=yes"><?=$lang->add?></a> ]<br>
	<table cellpadding="4" cellspacing="0" border="0" width="100%" class="admintable">
		<tr>
			<th><?=$lang->language_ID?></th>
			<th><?=$lang->isocode?></th>
			<th><?=$lang->language?></th>
			<th>&nbsp;</th>
		</tr>
		<?php
		$k = 0;
		foreach($rows as $row) {
			?>
			<tr class="row<?=$k?>">
				<td><?=$row["language_ID"]?></td>
				<td><?=$row["isocode"]?></td>
				<td><?=$row["language"]?></td>
				<td><a href="?page=<?=$_REQUEST["page"]?>&lang=<?=$_REQUEST["lang"]?>&edit=<?=$row["language_ID"]?>"><?=$lang->edit?></a></td>
			</tr>
			<?php
			$k = 1 - $k;
		}
		?>
	</table>
	<?php
	
};
?>
Return current item: Phpman