<mt:if name="blog_id">
    <mt:var
        name="page_title"
        value="<__trans phrase="Refresh Templates">">
<mt:else>
    <mt:var
        name="page_title"
        value="<__trans phrase="Refresh Global Templates">">
</mt:if>

<mt:setvarblock name="html_head" append="1">
<script type="text/javascript" src="<mt:var name="static_uri">js/dialog.js"></script>
<script type="text/javascript">
/* <![CDATA[ */
function enable(id) {
    var el = getByID(id);
    if (el)
        el.disabled = false;
}
function disable(id) {
    var el = getByID(id);
    if (el)
        el.disabled = true;
}
var dialog;
var panels;
function dialog_closed(ok) {
    if (ok) {
        // fill out form and submit to create the association
        var frm = getByID("refresh_form");
        frm.submit();
    } else {
        parent.jQuery.fn.mtDialog.close();
    }
}
function init() {
    dialog = new Dialog.MultiPanel("refresh");
    panels = [];
    var panel;
    panel = new ListingPanel("refresh");
    panels[panels.length] = panel;
    panel = new ListingPanel("confirm");
    panels[panels.length] = panel;
    dialog.setPanels(panels);
    dialog.open({}, dialog_closed);
}
/* ]]> */
</script>
</mt:setvarblock>

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

<mt:if name="template_set_not_found">
    <mtapp:statusmsg
        id="template_set_not_found"
        can_close="0"
        class="error">
            <__trans phrase="Cannot find template set. Please apply [_1]theme[_2] to refresh your templates." params="<a href="javascript:void(0);" onclick="parent.jQuery.fn.mtDialog.close('<mt:var name="script_full_url">?__mode=list_theme&amp;blog_id=<mt:var name="blog_id">');">%%</a>">
    </mtapp:statusmsg>

<div class="actions-bar">
    <button
       type="submit"
       accesskey="x"
       class="cancel close action mt-close-dialog"
       title="<__trans phrase="Close">"
       ><__trans phrase="Close"></button>
</div>
<mt:else>
<form name="refresh_form" id="refresh_form" method="post" action="<mt:var name="script_url">" target="_top" onsubmit="return false">
    <input type="hidden" name="__mode" value="refresh_all_templates" />
    <input type="hidden" name="blog_id" value="<mt:var name="blog_id">" />
    <input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />
    <input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />

    <div id="refresh-panel" class="hidden panel">

    <mt:if name="blog_id">
        <mt:setvarblock name="refresh_label"><__trans phrase="Revert modifications of theme templates" params="<mt:var name="current_label" escape="html">"></mt:setvarblock>
        <mt:setvarblock name="new_label"><__trans phrase="Reset to theme defaults"></mt:setvarblock>
        <mt:setvarblock name="new_hint"><__trans phrase="Deletes all existing templates and install the selected theme's default."></mt:setvarblock>
    <mt:else>
        <mt:setvarblock name="refresh_label"><__trans phrase="Refresh global templates"></mt:setvarblock>
        <mt:setvarblock name="new_label"><__trans phrase="Reset to factory defaults"></mt:setvarblock>
        <mt:setvarblock name="new_hint"><__trans phrase="Deletes all existing templates and installs factory default template set."></mt:setvarblock>
    </mt:if>
    <mtapp:setting
        id="refresh_templates"
        label="$refresh_label"
        label_class="top-label"
        show_label="0"
        show_hint="1"
        hint="<__trans phrase="Updates current templates while retaining any user-created templates.">">
        <div class="field-header">
            <label for="refresh_type_refresh"><input type="radio" name="refresh_type" id="refresh_type_refresh" value="refresh" onclick="disable('template_set');toggleHidden('confirm-clean');toggleHidden('confirm-refresh');" checked="checked" /> <$mt:var name="refresh_label"$></label>
        </div>
    </mtapp:setting>
    <mtapp:setting
        id="clean_start"
        label="$new_label"
        show_label="0"
        show_hint="1"
        hint="$new_hint"
        label_class="top-label">

        <div class="field-header">
            <label for="refresh_type_clean"><input type="radio" name="refresh_type" id="refresh_type_clean" value="clean" onclick="enable('template_set');toggleHidden('confirm-refresh');toggleHidden('confirm-clean');" /> <$mt:var name="new_label"$></label>
        </div>
    </mtapp:setting>



        <div>
        <input type="checkbox" id="backup" name="backup" value="1" checked="checked" onclick="toggleHidden('backups-message-refresh');toggleHidden('backups-message-clean');" />
        <label for="backup"><__trans phrase="Make backups of existing templates first"></label>
        </div>

        <div class="actions-bar">
            <button
               type="submit"
               accesskey="s"
               class="action primary-button next"
               ><__trans phrase="Continue"></button>
            <button
               type="submit"
               accesskey="x"
               title="<__trans phrase="Cancel (x)">"
               class="close action mt-close-dialog"
               ><__trans phrase="Cancel"></button>
        </div>

    </div>

    <div id="confirm-panel" class="hidden panel">
        <div id="confirm-refresh">
            <mt:if name="blog_id">
                <p><__trans phrase="You have requested to <strong>refresh the current template set</strong>. This action will:"></p>
            <mt:else>
                <p><__trans phrase="You have requested to <strong>refresh the global templates</strong>. This action will:"></p>
            </mt:if>

            <ul>
                <li id="backups-message-refresh"><__trans phrase="make backups of your templates that can be accessed through your backup filter"></li>
                <li><__trans phrase="potentially install new templates"></li>
                <li><__trans phrase="overwrite some existing templates with new template code"></li>
            </ul>
        </div>

        <div id="confirm-clean" class="hidden">
            <mt:if name="blog_id">
                <p><__trans phrase="You have requested to <strong>apply a new template set</strong>. This action will:"></p>
            <mt:else>
                <p><__trans phrase="You have requested to <strong>reset to the default global templates</strong>. This action will:"></p>
            </mt:if>

            <ul>
                <li id="backups-message-clean"><__trans phrase="make backups of your templates that can be accessed through your backup filter"></li>
                <mt:if name="blog_id">
                    <li><__trans phrase="delete all of the templates in your blog"></li>
                    <li><__trans phrase="install new templates from the selected template set"></li>
                <mt:else>
                    <li><__trans phrase="delete all of your global templates"></li>
                    <li><__trans phrase="install new templates from the default global templates"></li>
                </mt:if>
            </ul>
        </div>

        <p><strong><__trans phrase="Are you sure you wish to continue?"></strong></p>

        <div class="actions-bar">
            <button
               type="button"
               accesskey="s"
               class="action primary-button close"
               ><__trans phrase="Confirm"></button>
            <button
               type="submit"
               accesskey="x"
               class="cancel close action mt-close-dialog"
               title="<__trans phrase="Cancel (x)">"
               ><__trans phrase="Cancel"></button>
            <!-- <button
                 onclick="toggleHidden('confirm-panel'); toggleHidden('refresh-panel'); return false"
                 type="submit"
                 accesskey="b"
                 title="<__trans phrase="Back (b)">"
                 ><__trans phrase="Back"></button> -->
        </div>

    </div>

</form>
</mt:if>

<script type="text/javascript">
/* <![CDATA[ */
jQuery(function() {
    init();
});
/* ]]> */
</script>

<mt:include name="dialog/footer.tmpl">
