Файл: sources/admin/subcat.php
Строк: 111
<?php
if (!defined('VAPHP'))
{
die("Этот файл недоступен.");
}
class subcat extends base
{
function subcat()
{
global $CONF, $DB, $FORM, $LNG, $TMPL;
$TMPL['header'] = $LNG['a_subcat_header'];
if (isset($FORM['category']))
{
$category = intval($FORM['category']);
}
else {
$category = 0;
}
$cat_menu = "<select name="category" class="Input">n";
foreach ($CONF['categories'] as $idcat => $cat)
{
if ($category && $idcat==$category) $cat_menu .= "<option value="$idcat" selected>{$cat}</option>n";
$cat_menu .= "<option value="$idcat">{$cat}</option>n";
}
$cat_menu .= "</select>";
$TMPL['admin_content'] .= <<<EndHTML
<script language="javascript">
function check(form_name, field_name, value)
{
var check_boxes = document.forms[form_name].elements[field_name];
var num_check_boxes = check_boxes.length;
if (!num_check_boxes)
{
check_boxes.checked = value;
}
else {
for(var i = 0; i < num_check_boxes; i++)
{
check_boxes[i].checked = value;
}
}
}
</script>
<form action="index.php" method="get">
<input type="hidden" name="a" value="admin" />
<input type="hidden" name="b" value="subcat" />
{$cat_menu}
<input type="submit" class="ButtonNormal" value="{$LNG['a_subcat_view']}" />
</form><br>
<p align=right><a href="{$TMPL['site_url']}/index.php?a=admin&b=new_subcat" style="font-size:10pt; font-weight:bold">{$LNG['a_subcat_new']}</a></p>
<form action="{$TMPL['site_url']}/index.php?a=admin&b=delete_subcat" method="post" name="manage">
<table cellpadding="1" cellspacing="1" width="100%">
<tr align=center class="TableHeader">
<td></td>
<td>{$LNG['a_subcat_id']}</td>
<td>{$LNG['a_subcat_cat']}</td>
<td>{$LNG['a_subcat_name']}</td>
<td>{$LNG['a_subcat_sites']}</td>
<td colspan="2">{$LNG['a_cat_actions']}</td>
</tr>
EndHTML;
$alt = '';
$num = 0;
if($category)
{
$result = $DB->query("SELECT id, idcat, name FROM {$CONF['sql_prefix']}_subcat where idcat='{$category}' ORDER BY name ASC", __FILE__, __LINE__);
}
else
{
$result = $DB->query("SELECT id, idcat, name FROM {$CONF['sql_prefix']}_subcat ORDER BY name ASC", __FILE__, __LINE__);
}
while (list($id, $idcat, $name) = $DB->fetch_array($result))
{
list($num_sites) = $DB->fetch("SELECT COUNT(*) FROM {$CONF['sql_prefix']}_sites WHERE idsubcat='{$id}'", __FILE__, __LINE__);
list($catname) = $DB->fetch("SELECT name FROM {$CONF['sql_prefix']}_cat WHERE id='{$idcat}'", __FILE__, __LINE__);
$TMPL['admin_content'] .= <<<EndHTML
<tr class="lightbg{$alt}" align=center>
<td><input type="checkbox" name="id[]" value="{$id}" id="checkbox_{$num}" /></td>
<td>{$id}</td>
<td>{$catname}</td>
<td>{$name}</td>
<td>{$num_sites}</td>
<td><a href="{$TMPL['site_url']}/index.php?a=admin&b=edit_subcat&id={$id}">{$LNG['a_cat_edit']}</a></td>
<td><a href="{$TMPL['site_url']}/index.php?a=admin&b=delete_subcat&id={$id}">{$LNG['a_cat_delete']}</a></td>
</tr>
EndHTML;
if ($alt) { $alt = ''; }
else { $alt = 'alt'; }
$num++;
}
$TMPL['admin_content'] .= <<<EndHTML
</table><br>
<a href="javascript:void;" onclick="check('manage', 'id[]', true)">{$LNG['a_man_all']}</a> |
<a href="javascript:void;" onclick="check('manage', 'id[]', false)">{$LNG['a_man_none']}</a><br><br>
<input type="submit" class="ButtonNormal" value="{$LNG['a_man_del_sel']}" />
</form>
EndHTML;
}
}
?>