<div align="center">
<form enctype="multipart/form-data" action="" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="8000000">
<table class="block" width="100%">
<tr>
<th>Title /Description</th>
<th>Rank</th>
<th>Parent Id#</th>
<th>Visible</th>
<th>Img</th>
<th>Contents</th>
<th></th>
</tr>
<tr>
<td><a href="catalog_items.php"><b>/</b></a></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td style="text-align:right"><?php echo $html["count0"]?> files</td>
<td style="text-align:center">
<a href="?action=catalog_categs_clean_submit&id=0" onClick='javascript:if(!confirm("Are you sure?"))return false;'>[Remove contents]</a></td>
</tr>
<?php
function category_parse_($_categories,$_nbsp="",$category=array())
{
foreach($_categories as $_category)
{
if($_category['id']==@$category['id'])continue;
?>
<option value="<?php echo $_category['id']?>" <?php echo ($_category['id']==@$category['parent_id'])?"selected":"";?> ><?php echo $_nbsp.$_category['title']?></option>
<?php
if(count($_category['childs']))
category_parse_($_category['childs'],$_nbsp." ",$category);
}
}
//----------------------------------------------
function category_parse($_category_childs,$_nbsp="",$_categories)
{
$postget = $_POST?$_POST:$_GET;
foreach($_category_childs as $category)
{
?>
<?php if(@$postget["action"]=="catalog_categs_update" && $category['id'] == @$postget['id']){?>
<tr >
<td ><table><td><?php echo $_nbsp?></td><td><input type="text" name="title" value="<?php echo $category['title']?>">
<textarea name="description" ><?php echo $category['description']?></textarea></td></table></td>
<td align="center"><input type="text" name="rank" value="<?php echo $category['rank']?>" size="3"></td>
<td><select name="parent_id"><option value="0">/</option><?php category_parse_($_categories,"",$category)?></select></td>
<td align="center"><input type="checkbox" name="is_enabled" <?php echo ($category['is_enabled'])?"checked":""?> ></td>
<td><img src="../rwx/<?php echo $category['img']?>" alt=""><input type="file" name="img"></td>
<td style="text-align:right"><?php echo $category['total']?> files</td>
<td style="text-align:center">
<input type="hidden" name="id" value="<?php echo $category['id']?>">
<input name="submit" type="submit" class="button" value="Submit">
<input type="button" class="button" value="Cancel" onClick="location.href='?'"> </td>
</tr>
<?php }else{?>
<tr >
<td ><table><tr><td><?php echo $_nbsp ?></td><td><b><a href="catalog_items.php?categ_id=<?php echo $category['id']?>"><?php echo $category['title']?></a></b>
<br><?php echo $category['description']?>
</td></tr></table></td>
<td align="center"><?php echo $_nbsp.$category['rank']?></td>
<td ><?php echo ($category['parent_id'])?> </td>
<td align="center"><?php echo $category['is_enabled']?"+":"";?></td>
<td ><img src="../rwx/<?php echo @$category['img']?>" alt=""><?php if (@$category['img']) {?><input type="button" value="X" onclick='javascript:if (confirm("Are you sure?")) location.href="?action=category_thumb_delete&id=<?php echo $category['id']?>"'><?php } ?></td>
<td style="text-align:right"><?php echo $category['total']?> files</td>
<td style="text-align:center"><a href="?action=catalog_categs_update&id=<?php echo $category['id']?>">[Edit]</a>
<a href="?action=catalog_categs_delete_submit&id=<?php echo $category['id']?>" onClick='javascript:if(!confirm("Are you sure?"))return false;'>[Delete]</a> </td>
</tr>
<?php }//else
if(count($category['childs']))
category_parse($category['childs'],$_nbsp." ",$_categories);
}//foreach
}//function
?>
<?php category_parse($html['items'],"",$html['items'] ); ?>
<?php if(@$postget['action']=="catalog_categs_update" && !isset($postget['id']) ){?>
<tr><th colspan="7">Add new:</th></tr>
<tr >
<td><input type="text" name="title" value="" >
<textarea name="description" ></textarea></td>
<td><input type="text" name="rank" value="1" size="3"></td>
<td><select name="parent_id"><option value="0">/</option><?php category_parse_($html['items'])?></select></td>
<td><input type="checkbox" name="is_enabled" checked></td>
<td><input type="file" name="img"></td>
<td></td>
<td style="text-align:center"><input type="submit" value="Submit" class="button">
<input type="button" class="button" value="Cancel" onClick="location.href='?'"></td></tr>
<?php } else{ ?>
<tr >
<td colspan="6"></td><td style="text-align:center"><a href="?action=catalog_categs_update"><b>[Add new]</b></a></td>
</tr>
<?php } ?>
</table>
<INPUT type="hidden" name="action" value="catalog_categs_update_submit">
</form>
</div>