<mt:setvarblock name="page_title"><mt:if name="blog_id"><__trans phrase="[_1] Themes" params="<mt:if name="is_blog"><__trans phrase="Blog"><mt:else><__trans phrase="Website"></mt:if>"><mt:else><__trans phrase="All Themes"></mt:if></mt:setvarblock>
<mt:unless name="blog_id">
    <$mt:setvar name="position_actions_top" value="1"$>
    <mt:setvar name="system-theme-settings" value="1">
</mt:unless>

<mt:setvarblock name="content_header">
<ul class="action-link-list">
  <li><a href="<__trans phrase="_THEME_DIRECTORY_URL">" class="icon-left icon-related" target="_blank"><__trans phrase="Find Themes"></a></li>
</ul>
</mt:setvarblock>

<mt:setvarblock name="system_msg">
<div id="msg-block">
<mt:if name="uninstalled_theme_name">
  <mtapp:statusmsg
     id="theme_uninstalled"
     class="success">
    <__trans phrase="Theme [_1] has been uninstalled." params="<mt:var name="uninstalled_theme_name">" escape="html">
  </mtapp:statusmsg>
</mt:if>
<mt:if name="applied">
  <mtapp:statusmsg
     id="theme_applied"
     class="success"
     rebuild="all"
     can_close="0">
<mt:if name="warning_on_apply">
    <__trans phrase="Theme [_1] has been applied (<a href="[_2]">[quant,_3,warning,warnings]</a>)." params="<mt:var name="current_theme_name" escape="html" escape="html">%%<mt:var name="script_url">?__mode=list&amp;_type=log&blog_id=<mt:var name="blog_id">%%<mt:var name="warning_on_apply">">
<mt:else>
    <__trans phrase="Theme [_1] has been applied." params="<mt:var name="current_theme_name" escape="html" escape="html">">
</mt:if>
  </mtapp:statusmsg>
</mt:if>
<mt:if name="refreshed">
  <mtapp:statusmsg
     id="theme_applied"
     class="success"
     rebuild="all"
     can_close="0">
     <__trans phrase="You have successfully refreshed your templates." escape="html">
  </mtapp:statusmsg>
</mt:if>
</div>
</mt:setvarblock>

<mt:setvartemplate name="theme_loop_tmpl">
<mt:loop name="$loop_for">
<div id="theme-<mt:var name="id">" class="theme<mt:if name="current"> current-theme</mt:if><mt:if name="errors"> disabled</mt:if>">
  <script type="text/javascript">
  /* <![CDATA[ */
    theme_ids.push('<mt:var name="id">');
  /* ]]> */
  </script>
  <div class="theme-status">
  <mt:unless name="current">
    <mt:if name="errors">
    <span class="alert-error icon-left icon-error"><__trans phrase="Failed"></span>
    </mt:if>
    <mt:if name="warnings">
    <span class="alert-warning icon-left icon-warning"><a href="#" class="theme-detail-link"><__trans phrase="[quant,_1,warning,warnings]" params="<mt:var name="warning_count">"></a></span>
    </mt:if>
  </mt:unless>
  <mt:if name="blog_id">
    <mt:unless name="errors">
      <mt:if name="current">
    <a href="<mt:var name="mt_url" />?__mode=dialog_refresh_templates&amp;blog_id=<mt:var name="blog_id">&amp;magic_token=<mt:var name="magic_token">&amp;return_args=<mt:var name="return_args" escape="url">" class="button apply-theme-link mt-open-dialog"><__trans phrase="Refresh Templates"></a>
    <a href="<mt:var name="mt_url" />?__mode=apply_theme&amp;blog_id=<mt:var name="blog_id">&amp;theme_id=<mt:var name="theme_id">&amp;magic_token=<mt:var name="magic_token">" class="button apply-theme-link"><__trans phrase="Reapply"></a>
      <mt:else>
    <a href="<mt:var name="mt_url" />?__mode=apply_theme&amp;blog_id=<mt:var name="blog_id">&amp;theme_id=<mt:var name="theme_id">&amp;magic_token=<mt:var name="magic_token">" class="button apply-theme-link"><__trans phrase="Apply"></a>
      </mt:if>
    </mt:unless>
  <mt:else>
    <mt:unless name="blog_id">
      <mt:if name="blog_count">
    <span class="icon-left icon-success"><__trans phrase="In Use"></span>
      </mt:if>
    </mt:unless>
    <mt:if name="is_administrator">
      <mt:if name="theme_type" eq="package">
        <mt:unless name="protected">
          <mt:unless name="blog_count">
    <a href="<mt:var name="mt_url" />?__mode=uninstall_theme&amp;theme_id=<mt:var name="theme_id">&amp;blog_id=<mt:var blog_id>&amp;magic_token=<mt:var name="magic_token">" class="button uninstall-theme-link"><__trans phrase="Uninstall"></a>
          </mt:unless>
        </mt:unless>
      </mt:if>
    </mt:if>
  </mt:if>
  </div>
  <div class="theme-thumbnail thumbnail picture small">
    <img src="<mt:var name="thumbnail_url">" width="<mt:var name="thumb_w">" height="<mt:var name="thumb_h">" />
  </div>
  <div class="theme-meta">
    <h3 class="theme-title">
      <a href="#" class="theme-detail-link toggle-link icon-left icon-spinner">
        <mt:var name="name" escape="html">
      <mt:if name="theme_version">
        <span class="theme-version"><mt:var name="theme_version" escape="html"></span>
      </mt:if>
      </a>
    </h3>
    <div class="theme-author">
    <mt:if name="author_link">
      <__trans phrase="Author: "><a href="<mt:var name="author_link" escape="html">"><mt:var name="author_name" escape="html" default="-"></a>
    <mt:else>
      <__trans phrase="Author: "><mt:var name="author_name" escape="html" default="-">
    </mt:if>
    </div>
  <mt:if name="description">
    <p class="description"><mt:var name="description" escape="html" nl2br="1"></p>
  </mt:if>
  <mt:unless name="current">
    <mt:if name="errors">
    <p class="error-text"><a href="#theme-<mt:var name="id">-errors" class="theme-detail-link"><__trans phrase="This theme cannot be applied to the website due to [_1] errors" params="<mt:var name="error_count">"></p>
    </mt:if>
  </mt:unless>
  </div>
  <div id="theme-<mt:var name="id">-details" class="theme-details">
    <ul class="theme-tabs-list">
    <mt:unless name="current">
      <mt:if name="errors">
      <li><a href="#theme-<mt:var name="id">-errors"><__trans phrase="Errors"></a></li>
      </mt:if>
      <mt:if name="warnings">
      <li><a href="#theme-<mt:var name="id">-warnings"><__trans phrase="Warnings"></a></li>
      </mt:if>
    </mt:unless>
    <mt:if name="info">
      <li><a href="#theme-<mt:var name="id">-info"><__trans phrase="Info"></a></li>
    </mt:if>
    </ul>
  <mt:unless name="current">
    <mt:if name="errors">
    <div id="theme-<mt:var name="id">-errors" class="theme-errors theme-info">
      <h4><__trans phrase="Theme Errors"></h4>
      <mtapp:statusmsg
         id="saved-added"
         class="error"
         can_close="0">
        <__trans phrase="This theme cannot be applied to the website due to [_1] errors" params="<mt:var name="error_count">">
      </mtapp:statusmsg>
      <ul>
      <mt:loop name="errors">
        <li><mt:var name="__value__" escape="html"></li>
      </mt:loop>
      </ul>
    </div>
    </mt:if>
    <mt:if name="warnings">
    <div id="theme-<mt:var name="id">-warnings" class="theme-warnings theme-info">
      <h4><__trans phrase="Theme Warnings"></h4>
      <mtapp:statusmsg
         id="saved-added"
         class="alert"
         can_close="0">
        <__trans phrase="Portions of this theme cannot be applied to the website. [_1] elements will be skipped." params="<mt:var name="warning_count">">
      </mtapp:statusmsg>
      <ul>
      <mt:loop name="warnings">
        <li><mt:var name="__value__"></li>
      </mt:loop>
      </ul>
    </div>
    </mt:if>
  </mt:unless>
  <mt:if name="info">
    <div id="theme-<mt:var name="id">-info" class="theme-info">
      <h4><__trans phrase="Theme Information"></h4>
      <ul>
      <mt:loop name="info">
        <li><mt:var name="__value__"></li>
      </mt:loop>
      </ul>
    </div>
  </mt:if>
  </div>
</div>
<mt:else>
<mtapp:statusmsg
   id="no-theme"
   class="info"
   can_close="0">
  <__trans phrase="No themes are installed.">
</mtapp:statusmsg>
</mt:loop>
</mt:setvartemplate>

<mt:setvarblock name="html_head" append="1">
<script type="text/javascript">
/* <![CDATA[ */
    var theme_ids = [];
/* ]]> */
</script>
</mt:setvarblock>

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

<mt:if name="blog_id">
<div id="current-theme-group" class="theme-group">
  <h2 class="theme-group-name"><__trans phrase="Current Theme"></h2>
  <div class="theme-list">
    <mt:setvar name="loop_for" value="current_theme_loop" /><mt:var name="theme_loop_tmpl">
  </div>
</div>
<div id="<$mt:var name="scope_type"$>-theme-group" class="theme-group">
  <h2 class="theme-group-name"><__trans phrase="Available Themes"></h2>
  <div class="theme-list">
    <mt:setvar name="loop_for" value="theme_loop" /><mt:var name="theme_loop_tmpl">
  </div>
</div>
<mt:else>
  <mt:if name="both_theme_loop">
<div id="both-theme-group" class="theme-group">
  <h2 class="theme-group-name"><__trans phrase="Themes for Both Blogs and Websites"></h2>
  <div class="theme-list">
    <mt:setvar name="loop_for" value="both_theme_loop" /><mt:var name="theme_loop_tmpl">
  </div>
</div>
  </mt:if>
  <mt:if name="blog_theme_loop">
<div id="blog-theme-group" class="theme-group">
  <h2 class="theme-group-name"><__trans phrase="Themes for Blogs"></h2>
  <div class="theme-list">
    <mt:setvar name="loop_for" value="blog_theme_loop" /><mt:var name="theme_loop_tmpl">
  </div>
</div>
  </mt:if>
  <mt:if name="website_theme_loop">
<div id="website-theme-group" class="theme-group">
  <h2 class="theme-group-name"><__trans phrase="Themes for Websites"></h2>
  <div class="theme-list">
    <mt:setvar name="loop_for" value="website_theme_loop" /><mt:var name="theme_loop_tmpl">
  </div>
</div>
  </mt:if>
</mt:if>

<mt:setvarblock name="jq_js_include" append="1">
    jQuery('a.theme-detail-link').click(function(event) {
        jQuery('.theme').not(jQuery(this).parents('.theme')).removeClass('theme-expanded active')
        jQuery(this).parents('.theme').toggleClass('theme-expanded active');
        event.preventDefault();
    });

    jQuery.each(theme_ids, function() {
        jQuery('#theme-'+this+'-details').tabs();
    });
</mt:setvarblock>

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