ranks are converted. on the home stretch.

This commit is contained in:
Ryan Walberg 2012-11-17 03:48:06 +00:00
parent de147ad95a
commit e9530173d3
3 changed files with 151 additions and 112 deletions

View file

@ -81,11 +81,11 @@ else if ($action == "demote") {
exit;
}
else if ($action == "edit") {
$query = "SELECT title, rendered FROM {$OPT["table_prefix"]}ranks WHERE ranking = " . $_GET["ranking"];
$query = "SELECT title, rendered FROM {$OPT["table_prefix"]}ranks WHERE ranking = " . addslashes($_GET["ranking"]);
$rs = mysql_query($query) or die("Could not query: " . mysql_error());
if ($row = mysql_fetch_array($rs,MYSQL_ASSOC)) {
$title = htmlspecialchars($row["title"]);
$rendered = htmlspecialchars($row["rendered"]);
$title = $row["title"];
$rendered = $row["rendered"];
}
mysql_free_result($rs);
}
@ -123,113 +123,35 @@ else {
exit;
}
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Gift Registry - Manage Ranks</title>
<link href="styles.css" type="text/css" rel="stylesheet" />
</head>
<body>
<?php
if (isset($message)) {
echo "<span class=\"message\">" . $message . "</span>";
}
$query = "SELECT ranking, title, rendered, rankorder " .
"FROM {$OPT["table_prefix"]}ranks ";
$query .= " ORDER BY rankorder";
$ranks = mysql_query($query) or die("Could not query: " . mysql_error());
"FROM {$OPT["table_prefix"]}ranks " .
"ORDER BY rankorder";
$rs = mysql_query($query) or die("Could not query: " . mysql_error());
$ranks = array();
while ($row = mysql_fetch_array($rs, MYSQL_ASSOC)) {
$ranks[] = $row;
}
mysql_free_result($rs);
define('SMARTY_DIR',str_replace("\\","/",getcwd()).'/includes/Smarty-3.1.12/libs/');
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();
$smarty->assign('action', $action);
$smarty->assign('ranks', $ranks);
if (isset($message)) {
$smarty->assign('message', $message);
}
$smarty->assign('title', $title);
if (isset($title_error)) {
$smarty->assign('title_error', $title_error);
}
$smarty->assign('rendered', $rendered);
if (isset($rendered_error)) {
$smarty->assign('rendered_error', $rendered_error);
}
$smarty->assign('ranking', $_GET["ranking"]);
$smarty->assign('haserror', $haserror);
$smarty->assign('isadmin', $_SESSION["admin"]);
$smarty->assign('opt', $OPT);
$smarty->display('ranks.tpl');
?>
<p>
<table class="partbox" cellspacing="0" cellpadding="2">
<tr class="partboxtitle">
<td colspan="4" align="center">Ranks</td>
</tr>
<tr>
<th class="colheader">Title</th>
<th class="colheader">Rendered HTML</th>
<th class="colheader">Rank Order</th>
</tr>
<?php
$i = 0;
while ($row = mysql_fetch_array($ranks,MYSQL_ASSOC)) {
?>
<tr class="<?php echo (!($i++ % 2)) ? "evenrow" : "oddrow" ?>">
<td><?php echo htmlspecialchars($row["title"]); ?></td>
<td><?php echo $row["rendered"]; ?></td>
<td><?php echo $row["rankorder"]; ?></td>
<td align="right">
<a href="ranks.php?action=edit&ranking=<?php echo $row["ranking"]; ?>">Edit</a>
/
<a href="ranks.php?action=delete&ranking=<?php echo $row["ranking"]; ?>">Delete</a>
/
<a href="ranks.php?action=promote&ranking=<?php echo $row["ranking"]; ?>&rankorder=<?php echo $row["rankorder"]; ?>">Promote</a>
/
<a href="ranks.php?action=demote&ranking=<?php echo $row["ranking"]; ?>&rankorder=<?php echo $row["rankorder"]; ?>">Demote</a>
</td>
</tr>
<?php
}
mysql_free_result($ranks);
?>
</table>
</p>
<p>
<a href="ranks.php">Add a new rank</a> / <a href="index.php">Back to main</a>
</p>
<form name="rank" method="get" action="ranks.php">
<?php
if ($action == "edit" || (isset($haserror) && $action == "update")) {
?>
<input type="hidden" name="ranking" value="<?php echo $_GET["ranking"]; ?>">
<input type="hidden" name="action" value="update">
<?php
}
else if ($action == "" || (isset($haserror) && $action == "insert")) {
?>
<input type="hidden" name="action" value="insert">
<?php
}
?>
<div align="center">
<TABLE class="partbox">
<tr class="partboxtitle">
<td align="center" colspan="2"><?php echo ($action == "edit" ? "Edit Rank '" . $title . "'" : "Add New Rank"); ?></td>
</tr>
<TR valign="top">
<TD>Title</TD>
<TD>
<input name="title" type="text" value="<?php echo $title; ?>" maxlength="255" size="50"/>
<?php
if (isset($title_error)) {
?><br /><font color="red"><?php echo $title_error; ?></font><?php
}
?>
</TD>
</TR>
<TR valign="top">
<TD>HTML</TD>
<TD>
<textarea name="rendered" rows="4" cols="40"><?php echo $rendered; ?></textarea>
<?php
if (isset($rendered_error)) {
?><br /><font color="red"><?php echo $rendered_error; ?></font><?php
}
?>
</TD>
</TR>
</TABLE>
</div>
<P>
<div align="center">
<input type="submit" value="<?php if ($action == "" || $action == "insert") echo "Add"; else echo "Update"; ?>"/>
<input type="button" value="Cancel" onClick="document.location.href='ranks.php';">
</div>
</P>
</form>
<table border="1">
</table>
</body>
</html>

View file

@ -72,7 +72,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{/foreach}
</tbody>
</table>
<h5><a href="categories.php">Add a new category</a></h5>
<h5><a href="categories.php#catform">Add a new category</a></h5>
</div>
</div>
</div>

117
src/templates/ranks.tpl Normal file
View file

@ -0,0 +1,117 @@
{*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Gift Registry - Manage Ranks</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
</head>
<body>
{include file='navbar.tpl' isadmin=$isadmin}
<div class="container" style="padding-top: 60px;">
{if isset($message)}
<div class="row">
<div class="span12">
<div class="alert alert-block">{$message|escape:'htmlall'}</div>
</div>
</div>
{/if}
<div class="row">
<div class="span12">
<div class="well">
<h3>Ranks</h3>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>Title</th>
<th>Rendered HTML</th>
<th>Rank Order</th>
</tr>
</thead>
<tbody>
{foreach from=$ranks item=row}
<tr>
<td>{$row.title|escape:'htmlall'}</td>
<td>{$row.rendered}</td>
<td>{$row.rankorder}</td>
<td>
<a href="ranks.php?action=edit&ranking={$row.ranking}#rankform"><img src="images/write_obj.gif" border="0" alt="Edit Rank" title="Edit Rank" /></a>
/
<a href="ranks.php?action=delete&ranking={$row.ranking}"><img src="images/remove.gif" border="0" alt="Delete Rank" title="Delete Rank" /></a>
/
<a href="ranks.php?action=promote&ranking={$row.ranking}&rankorder={$row.rankorder}">Promote</a>
/
<a href="ranks.php?action=demote&ranking={$row.ranking}&rankorder={$row.rankorder}">Demote</a>
</td>
</tr>
{/foreach}
</tbody>
</table>
<h5><a href="ranks.php#rankform">Add a new rank</a></h5>
</div>
</div>
</div>
<a name="rankform">
<div class="row">
<div class="span12">
<form name="rank" method="get" action="ranks.php" class="well form-horizontal">
{if $action == "edit" || (isset($haserror) && $action == "update")}
<input type="hidden" name="ranking" value="{$ranking}">
<input type="hidden" name="action" value="update">
{elseif $action == "" || (isset($haserror) && $action == "insert")}
<input type="hidden" name="action" value="insert">
{/if}
<fieldset>
<legend>{if $action == "edit"}Edit Rank '{$title}'{else}Add Rank{/if}</legend>
<div class="control-group {if isset($title_error)}warning{/if}">
<label class="control-label" for="title">Title</label>
<div class="controls">
<input id="title" name="title" class="input-xlarge" type="text" value="{$title|escape:'htmlall'}" maxlength="255">
{if isset($title_error)}
<span class="help-inline">{$title_error|escape:'htmlall'}</span>
{/if}
</div>
</div>
<div class="control-group {if isset($rendered_error)}warning{/if}">
<label class="control-label" for="rendered">HTML</label>
<div class="controls">
<textarea id="rendered" name="rendered" class="input-xlarge" rows="4" cols="40">{$rendered|escape:'htmlall'}</textarea>
{if isset($rendered_error)}
<span class="help-inline">{$rendered_error|escape:'htmlall'}</span>
{/if}
</div>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-primary">{if $action == "" || $action == "insert"}Add{else}Update{/if}</button>
<button type="button" class="btn" onClick="document.location.href='ranks.php';">Cancel</button>
</div>
</fieldset>
</form>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>