small code style improvements

This commit is contained in:
msquare 2016-10-04 18:11:26 +02:00
parent 42144ed21c
commit 676f5e1627
2 changed files with 51 additions and 52 deletions

View File

@ -5,7 +5,8 @@ function admin_news() {
if (! isset($_GET["action"])) { if (! isset($_GET["action"])) {
redirect(page_link_to("news")); redirect(page_link_to("news"));
} else { }
$html = '<div class="col-md-12"><h1>' . _("Edit news entry") . '</h1>' . msg(); $html = '<div class="col-md-12"><h1>' . _("Edit news entry") . '</h1>' . msg();
if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) { if (isset($_REQUEST['id']) && preg_match("/^[0-9]{1,11}$/", $_REQUEST['id'])) {
$news_id = $_REQUEST['id']; $news_id = $_REQUEST['id'];
@ -14,7 +15,9 @@ function admin_news() {
} }
$news = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1"); $news = sql_select("SELECT * FROM `News` WHERE `ID`='" . sql_escape($news_id) . "' LIMIT 1");
if (count($news) > 0) { if (empty($news)) {
return error("No News found.", true);
}
switch ($_REQUEST["action"]) { switch ($_REQUEST["action"]) {
default: default:
redirect(page_link_to('news')); redirect(page_link_to('news'));
@ -59,10 +62,6 @@ function admin_news() {
redirect(page_link_to("news")); redirect(page_link_to("news"));
break; break;
} }
} else {
return error("No News found.", true);
}
}
return $html . '</div>'; return $html . '</div>';
} }
?> ?>

View File

@ -374,11 +374,11 @@ function render_table($columns, $rows, $data = true) {
foreach ($rows as $row) { foreach ($rows as $row) {
$html .= '<tr>'; $html .= '<tr>';
foreach ($columns as $key => $column) { foreach ($columns as $key => $column) {
$value = "&nbsp;";
if (isset($row[$key])) { if (isset($row[$key])) {
$html .= '<td class="column_' . $key . '">' . $row[$key] . '</td>'; $value = $row[$key];
} else {
$html .= '<td class="column_' . $key . '">&nbsp;</td>';
} }
$html .= '<td class="column_' . $key . '">' . $value . '</td>';
} }
$html .= '</tr>'; $html .= '</tr>';
} }