<mt:setvarblock name="page_title"><__trans phrase="Manage Categories"></mt:setvarblock>
<mt:setvarblock name="html_head" append="1">
<script type="text/javascript">
/* <![CDATA[ */
function submitMoveMode() {
    jQuery('#category-listing-form input[name=__mode]').val('save_cat');
    jQuery('#category-listing-form').submit();
}

function setCreateMode (id) {
    jQuery('#create-new-link').addClass('hidden');

    jQuery('#category-listing-form input[name=__mode]').val('save_cat');
    jQuery('#msg-block').hide();
    jQuery('#action-col-head').hide();
    jQuery('#delete-col-head').hide();
    jQuery('.cb').show();
    jQuery('.move-col').hide();
    jQuery('.move-row').hide();
    jQuery('.actions').hide();
    jQuery('.delete').hide();
    jQuery('#footer-list-actions').hide();

    jQuery('#create-'+id).toggleClass('table-row');
    jQuery('.create-row').hide();
    jQuery('#create-'+id).show();
    jQuery('input[name=^category-new-parent]').val('');

    jQuery('#category-listing-form input[name=move_cat_id]').val(0);

    jQuery('#category-new-parent-' + id).focus();

    return false;
}

function setMoveMode (id) {
    jQuery('#category-listing-form input[name=__mode]').val('save_cat');
    jQuery('#msg-block').hide();
    jQuery('#action-col-head').hide();
    jQuery('#delete-col-head').hide();
    jQuery('.cb').hide();
    jQuery('.move-col').show().children('input').show();
    jQuery('.move-row').show().children('#delete-0').hide();
    jQuery('.actions').hide();
    jQuery('#footer-list-actions').hide();
    jQuery('span.actions').show();
    jQuery('a.mt-delete-action').hide();
    jQuery('a.mt-cancel-action').show();

    jQuery('#category-'+id).addClass('selected');
    jQuery('#move-radio-'+id).hide();
    jQuery('#category-listing-form input[name=move_cat_id]').val(id);

    return false;
}
/* ]]> */
</script>
</mt:setvarblock>
<mt:setvarblock name="system_msg">
    <div id="msg-block">
        <mt:if name="saved">
            <mtapp:statusmsg
                id="saved"
                class="success"
                rebuild="all">
                <__trans phrase="Your category changes and additions have been made.">
            </mtapp:statusmsg>
        </mt:if>

        <mt:if name="saved_deleted">
            <mtapp:statusmsg
                id="saved-deleted"
                class="success"
                rebuild="all">
                <__trans phrase="You have successfully deleted the selected category.">
            </mtapp:statusmsg>
        </mt:if>
    </div>
</mt:setvarblock>
<mt:setvarblock name="action_buttons">
    <a href="javascript:void(0)"
       onclick="doRemoveItems(getByID('<$mt:var name="object_type"$>-listing-form'), '<__trans phrase="category" escape="js">', '<__trans phrase="categories" escape="js">'); return false;"
       accesskey="x"
       class="button mt-delete-action"
       title="<__trans phrase="Delete selected category (x)">"
       ><__trans phrase="Delete"></a>
    <a href="#"
       class="button mt-cancel-action"
       ><__trans phrase="Cancel"></a>
</mt:setvarblock>
<mt:setvarblock name="related_content">
    <$MTApp:PageActions from="list_cat"$>
</mt:setvarblock>
<mt:var name="position_actions_top" value="1">

<mt:setvarblock name="content_header">
    <p id="create-new-link"><a href="javascript:void(0)" onclick="return setCreateMode(0)" class="icon-left icon-create"><__trans phrase="Create top level category"></a></p>
</mt:setvarblock>

<mt:include name="include/header.tmpl">

<mtapp:listing
    hide_pager="1">
    <mt:if __first__>
        <input type="hidden" name="move_cat_id" value="" />

        <mt:setvarblock name="table_header">
            <tr>
                <th class="cb"><input type="checkbox" name="id-head" value="all" class="select" /></th>
                <th class="move-col">&nbsp;</th>
                <th class="category primary-col"><mt:var name="object_label_plural"></th>
                <th class="actions"><__trans phrase="Actions"></th>
                <th class="entry"><mt:var name="entry_label_plural"></th>
                <th class="trackback"><__trans phrase="TrackBacks"></th>
            </tr>
        </mt:setvarblock>

        <thead>
            <mt:var name="table_header">
        </thead>
        <tfoot>
            <mt:var name="table_header">
        </tfoot>
        <tbody>
            <tr class="create-row create-inline" id="create-0">
                <td class="move-col" colspan="2">&nbsp;</td>
                <td colspan="4">
                    <mt:setvarblock name="new_parent_label"><__trans phrase="New Parent [_1]" params="<mt:var name="object_label">"></mt:setvarblock>
                    <mtapp:setting
                        id="new-parent-category"
                        label="$new_parent_label"
                        label_class="inline field-no-header"
                        show_hint="0">
                        <input type="text" name="category-new-parent-0" id="category-new-parent-0" value="" maxlength="100" />
                        <span class="buttons">
                            <button
                                type="submit"
                                class="small-button"
                                title="<__trans phrase="Create Category">" 
                                ><__trans phrase="Create"></button> 
                            <button
                                class="small-button mt-cancel-action"
                                ><__trans phrase="Cancel"></button> 
                        </span> 
                    </mtapp:setting>
            </tr>

            <tr class="move-row" id="move-0">
                <td id="delete-0">&nbsp;</td>
                <td class="move-col" id="move-col-0"><input type="radio" name="move-radio" id="move-radio-0" value="0" onclick="submitMoveMode()" /></td>
                <td><__trans phrase="Top Level"></td>
                <td id="action-0" class="actions">&nbsp;</td>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
            </tr>
    </mt:if>
            <tr class="<mt:if name="__odd__">odd<mt:else>even</mt:if>" id="category-<mt:var name="category_id">">
                <td class="cb" id="delete-<mt:var name="category_id">" class="delete"><input type="checkbox" name="id" value="<mt:var name="category_id">" class="select" /></td>
                <td class="move-col" id="move-col-<mt:var name="category_id">"><input type="radio" name="move-radio" id="move-radio-<mt:var name="category_id">" value="<mt:var name="category_id">" onclick="submitMoveMode()" /></td>
                <td class="category">
<mt:if name="category_has_children">
    <mt:if name="category_is_expanded">
                    <a href="javascript:void(0)" onclick="return doCollapse(<mt:var name="category_id">)" title="<__trans phrase="Collapse">"><img alt="<__trans phrase="Collapse">" src="<mt:var name="static_uri">images/status_icons/collapse.gif" width="9" height="9" class="expcol" /></a>
    <mt:else>
                    <a href="javascript:void(0)" onclick="return doExpand(<mt:var name="category_id">)" title="<__trans phrase="Expand">"><img alt="<__trans phrase="Expand">" src="<mt:var name="static_uri">images/status_icons/expand.gif" width="9" height="9" class="expcol" /></a>
    </mt:if>
</mt:if>
                    <div style="margin-left: <mt:var name="category_pixel_depth">px;"><a href="<mt:var name="script_url">?__mode=view&amp;_type=<mt:var name="object_type" escape="url">&amp;blog_id=<mt:var name="blog_id" escape="url">&amp;id=<mt:var name="category_id" escape="url">"><mt:var name="category_label_full" escape="html"></a></div>
                </td>
                <td id="action-<mt:var name="category_id">" class="actions">
                    <a href="javascript:void(0)" onclick="return setCreateMode(<mt:var name="category_id">)" class="icon-left icon-create" title="<__trans phrase="Create Subcategory">"><__trans phrase="Create"></a>
                    <a href="javascript:void(0)" onclick="return setMoveMode(<mt:var name="category_id">);" class="icon-left icon-move" title="<__trans phrase="Move Category">"><__trans phrase="Move"></a>
                </td>
                <td class="entry">
                <mt:if name="category_entrycount">
                    <mt:if name="can_edit_entries">
                    <a href="<mt:var name="script_url">?__mode=list_<mt:var name="search_type" lower_case="1">&amp;_type=<mt:var name="search_type">&amp;blog_id=<mt:var name="blog_id">&amp;filter=category_id&amp;filter_val=<mt:var name="category_id">">
                    </mt:if>
                </mt:if>
                        <__trans phrase="[quant,_1,entry,entries]" params="<mt:var name="category_entrycount">%%<mt:var name="entry_label" lower_case="1">%%<mt:var name="entry_label_plural" lower_case="1">">
                <mt:if name="category_entrycount">
                    <mt:if name="can_edit_entries">
                    </a>
                    </mt:if>
                </mt:if>
                </td>

                <td class="trackback">
<mt:if name="has_tb">
    <mt:if name="category_tbcount">
        <mt:if name="can_edit_entries">
                    <a href="<mt:var name="script_url">?__mode=list_pings&amp;filter=<mt:var name="object_type" escape="url">_id&amp;blog_id=<mt:var name="blog_id" escape="url">&amp;filter_val=<mt:var name="category_id" escape="url">">
                        <__trans phrase="[quant,_1,TrackBack,TrackBacks]" params="<mt:var name="category_tbcount">">
                    </a>
        </mt:if>
    <mt:else>
                    <__trans phrase="[quant,_1,TrackBack,TrackBacks]" params="<mt:var name="category_tbcount">">
    </mt:if>
</mt:if>

                </td>
            </tr>

            <tr class="create-row create-inline" id="create-<mt:var name="category_id">">
                <td class="move-col" colspan="2">&nbsp;</td>
                <td colspan="4" style="padding-left: 15px;">
                    <div style="margin-left: <mt:var name="category_pixel_depth">px;">
                        <mt:setvarblock name="new_label"><__trans phrase="New [_1]" params="<mt:var name="object_label">"></mt:setvarblock>
                        <mtapp:setting
                            id="new-category"
                            label="$new_label"
                            label_class="inline field-no-header"
                            hint=""
                            show_hint="0">
                            <input type="text" name="category-new-parent-<mt:var name="category_id" escape="html">" id="category-new-parent-<mt:var name="category_id" escape="html">" value="" maxlength="100"/>
                            <span class="buttons"> 
                                <button
                                    type="submit"
                                    class="small-button"
                                    title="<__trans phrase="Create Subcategory">" 
                                    ><__trans phrase="Create"></button> 
                                <button
                                    class="small-button mt-cancel-action"
                                    ><__trans phrase="Cancel"></button> 
                            </span> 
                        </mtapp:setting>
                    </div>
                </td>
            </tr>
    <mt:if __last__>
        </tbody>
    </mt:if>
<mt:else>
    <mtapp:statusmsg id="zero-state" class="info zero-state">
        <__trans phrase="No categories could be found.">
    </mtapp:statusmsg>
    <form id="category-listing-form" method="post" action="<$mt:var name="script_url"$>">
        <input type="hidden" name="__mode" value="save_cat" />
        <input type="hidden" name="_type" value="category" />
        <input type="hidden" name="return_args" value="<$mt:var name="return_args" escape="html"$>" />
        <input type="hidden" name="blog_id" value="<$mt:var name="blog_id" escape="html"$>" />
        <input type="hidden" name="magic_token" value="<$mt:var name="magic_token"$>" />
        <table width="100%">
            <tr id="create-0" class="create-row create-inline">
                <td style="padding: 5px">
                    <mt:setvarblock name="new_label"><__trans phrase="New [_1]" params="<mt:var name="object_label">"></mt:setvarblock>
                    <mtapp:setting
                        id="new-category"
                        label="$new_label"
                        label_class="inline field-no-header"
                        hint=""
                        show_hint="0">
                        <input type="text" name="category-new-parent-0" id="category-new-parent-0" value="" maxlength="100" />
                        <span class="buttons"> 
                            <button
                                type="submit"
                                class="small-button"
                                title="<__trans phrase="Create Category">" 
                                ><__trans phrase="Create"></button> 
                            <button
                                class="small-button mt-cancel-action"
                                ><__trans phrase="Cancel"></button> 
                        </span> 
                    </mtapp:setting>
                </td>
            </tr>
        </table>
    </form>
</mtapp:listing>
<mt:setvarblock name="jq_js_include" append="1">
    jQuery.mtCheckbox();

    jQuery('a.mt-cancel-action').hide();
    jQuery('.mt-cancel-action').click(function() {
        jQuery('#create-new-link').removeClass('hidden');
        jQuery(this).parents('tr.create-row').hide();
        jQuery('.cb').show();
        jQuery('.actions').show();
        jQuery('.move-col').hide();
        jQuery('.move-row').hide();
        jQuery('#footer-list-actions').toggle();
        jQuery('a.mt-delete-action').show();
        jQuery('a.mt-cancel-action').hide();
        jQuery('tr.selected').removeClass('selected');
        jQuery('input:checked').parents('tr').addClass('selected');
        jQuery(this).parents('#new-category-field').find('input.text').val('');
        return false;
    });
</mt:setvarblock>
<mt:include name="include/footer.tmpl">
