<?php
require_once '_admin_setting.php';
require_once NSO_INC_PATH . 'Pager.php';

$cat = $_GET['cat'];
$cat = empty($cat) ? $nsoDefaultPostCatId : $cat;
$categoryName = getCategoryName($cat);

$categories = getCategoriesByParent($cat);

addHeaderJavascript('javascripts/post_list.js');
require_once '_top.php';
require_once '_header.php';
require_once '_menuPane.php';
?>
<div id="godContentContainer">
    <div class="content_part">
        <div class="title">
            <h2><?php echo $categoryName?> - 分类设置</h2>
        </div>
        <div id="topToolbar" class="toolbar">
            <div class="tool_button">
                <div class="button"><a href="category.php?cat=<?php echo $cat?>&parent=<?php echo $cat?>">增加</a><span class="deco_left"></span><span class="deco_right"></span></div>
            </div>
        </div>
        <div class="infobar">
            <div class="message_box">正在处理...</div>
        </div>
        <div class="content">
            <div class="table_content">
                <table>
                    <tbody>
                    <?php if ($categories) : foreach ($categories as $c) : $updateUrl = "category.php?cat={$cat}&parent={$cat}&id={$c['id']}";?>
                        <tr id="post-<?php echo $c['id']?>">
                            <td class="drag_icon"></td>
                            <td class="title"><a href="<?php echo $updateUrl?>"><?php echo $c['name']?></a></td>
                            <td class="action">
                            	<?php if ($cat == 3):?>
                            	<a href="category.php?cat=<?php echo $cat?>&parent=<?php echo $c['id']?>" >增加品牌</a>
                                <?php endif;?>
                                <a href="<?php echo $updateUrl?>" class="edit">编辑</a>
                                <a href="category_edit_action.php?cat=<?php echo $cat?>&id=<?php echo $c['id']?>&action=delete" class="delete">删除</a>
                            </td>
                        </tr>
                        <?php
                        $subcategories = getCategoriesByParent($c['id']);
                        if ($subcategories) : foreach ($subcategories as $sc) : $updateUrl = "category.php?cat={$cat}&parent={$c['id']}&id={$sc['id']}";
                        ?>
                        <tr id="post-<?php echo $sc['id']?>">
                            <td class="drag_icon"></td>
                            <td class="title">&nbsp;&nbsp; - &nbsp;<a href="<?php echo $updateUrl?>"><?php echo $sc['name']?></a></td>
                            <td class="action">
                                <a href="<?php echo $updateUrl?>" class="edit">编辑</a>
                                <a href="category_edit_action.php?action=delete&id=<?php echo $sc['id']?>" class="delete">删除</a>
                            </td>
                        </tr>
                        <?php endforeach; endif;?>
					<?php endforeach; endif;?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?php include_once '_bottom.php';?>