<mt:setvar name="page_title" value="<__trans phrase="Edit Category">">
<$mt:setvar name="position_actions_bottom" value="1"$>

<MTSetVarBlock name="system_msg">
<mt:if name="error">
  <mtapp:statusmsg
     id="generic-error"
     class="error"
     can_close="0">
    <mt:var name="error">
  </mtapp:statusmsg>
</mt:if>
<mt:if name="saved">
  <mtapp:statusmsg
     id="saved"
     class="success"
     rebuild="all"
     can_close="0">
    <__trans phrase="Your changes have been saved.">
  </mtapp:statusmsg>
</mt:if>
</MTSetVarBlock>

<mt:setvarblock name="related_content">
    <mtapp:widget
        id="useful-links"
        label="<__trans phrase="Useful links">">
        <ul>
            <li><a href="<mt:var name="script_url">?__mode=list&amp;_type=category&amp;blog_id=<$mt:var name="blog_id"$>"><__trans phrase="Manage Categories"></a></li>
            <mt:if name="can_create_post"><li><a href="<mt:var name="script_url">?__mode=list&_type=entry&amp;blog_id=<$mt:var name="blog_id" escape="url"$>&amp;filter=category_id&amp;filter_val=<$mt:var name="id" escape="url"$>"><__trans phrase="Manage entries in this category"></a></li></mt:if>
        </ul>
    </mtapp:widget>
    <$mtapp:PageActions$>
</mt:setvarblock>

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

<script type="text/javascript">
/* <![CDATA[ */
function validate(form) {    
    if ( !form.label.value.match(/\S/,'') ) {
        alert('<__trans phrase="You must specify a label for the category." escape="singlequotes">');
        form.label.focus();
        return false;
    }
    if ( !form.basename.value.match(/\S/,'') ) {
        alert('<__trans phrase="You must specify a basename for the category." escape="singlequotes">');
        form.basename.focus();
        return false;
    }

    if ( !(dirify(form.basename.value).match(/\S/,'')) ) {
        alert('<__trans phrase="Please enter a valid basename." escape="singlequotes">');
        form.basename.focus();
        return false;
    }

    return true;
}

function toggleFile() {
    var fld = getByID("basename");
    if (fld) {
        fld.disabled = false;
        fld.focus();
        var baseman = getByID("basename_manual");
        if (baseman) baseman.value = "1";
        var basewarn = getByID("basename-warning");
        if (basewarn) basewarn.style.display = "block";
    }
    var img = getByID("basename-lock");
    if (img)
        img.style.display = 'none';
    return false;
}

var tableSelect;
function init()
{
    // setup
    tableSelect = new TC.TableSelect( "<$mt:var name="asset_type"$>-listing-table" );
    tableSelect.rowSelect = true;
}
TC.attachLoadEvent( init );
/* ]]> */
</script>


<form method="post" action="<mt:var name="script_url">" onsubmit="return validate(this)">
  <input type="hidden" name="blog_id" value="<mt:var name="blog_id" escape="html">" />
  <input type="hidden" name="__mode" value="save" />
  <input type="hidden" name="_type" value="<mt:var name="object_type">" />
  <input type="hidden" name="id" value="<mt:var name="id" escape="html">" />
  <input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />
  <input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />
  <input type="hidden" name="category_parent" value="<mt:var name="parent" escape="html">" />

  <mtapp:settinggroup id="category-meta">

    <mtapp:setting
       id="label"
       label="<__trans phrase="Label">">
      <input type="text" name="label" id="label" class="text label" maxlength="100" value="<mt:var name="label" escape="html">" />
    </mtapp:setting>

    <mtapp:setting
       id="basename"
       label="<__trans phrase="_CATEGORY_BASENAME">"
       hint="<__trans phrase="This is the basename assigned to your category.">"
       help_page="categories"
       help_section="category_basename">
      <input type="text" name="basename" id="basename" class="mt-edit-field text basename" maxlength="250" value="<mt:var name="basename" escape="html">" />
      <p class="alert-warning-inline" id="basename-warning" style="display: none;">
        <img src="<mt:var name="static_uri">images/status_icons/warning.gif" alt="<__trans phrase="Warning">" width="9" height="9" />
        <__trans phrase="Warning: Changing this category's basename may break inbound links.">
      </p>
    </mtapp:setting>

    <mtapp:setting
       id="description"
       label="<__trans phrase="Description">">
      <textarea name="description" id="description" rows="" cols="" class="text low"><mt:var name="description" escape="html"></textarea>
    </mtapp:setting>

  </mtapp:settinggroup>

  <mtapp:settinggroup id="category-ping">

    <h2 class="title"><__trans phrase="Inbound TrackBacks"></h2>

    <mtapp:setting
       id="allow_pings"
       label="<__trans phrase="Accept Trackbacks">"
       hint="<__trans phrase="If enabled, TrackBacks will be accepted for this category from any source.">"
       help_page="categories"
       help_section="accept_category_pings">
      <input type="checkbox" name="allow_pings" id="allow_pings" value="1" onclick="toggleSubPrefs(this); return true"<mt:if name="allow_pings"> checked="checked"</mt:if> class="cb" /> 
    </mtapp:setting>

  <mt:if name="tb">
    <mt:if name="can_view_trackbacks">
      <mtapp:setting
         id="view_trackbacks"
         label="<__trans phrase="TrackBacks">">
      <div id="view_trackbacks"><strong><a href="<$mt:var name="script_url">?__mode=list&amp;_type=ping&amp;filter=category_id&amp;filter_val=<$mt:var name="id" escape="url"$>&amp;blog_id=<$mt:var name="blog_id" escape="url"$>"><__trans phrase="View TrackBacks"></a></strong></div>
      </mtapp:setting>
    </mt:if>
  </mt:if>

    <div id="allow_pings_prefs" style="display:<mt:if name="allow_pings">block<mt:else>none</mt:if>">

    <mt:if name="tb_url">
      <mtapp:setting
         id="trackback_url"
         label="<__trans phrase="TrackBack URL for this category">"
         hint="<__trans phrase="_USAGE_CATEGORY_PING_URL">">
        <input type="text" name="trackback_url" id="trackback_url" readonly="readonly" value="<mt:var name="tb_url" escape="html">" class="text readonly" />
      </mtapp:setting>

      <mtapp:setting
         id="tb_passphrase"
         label="<__trans phrase="Passphrase Protection">"
         hint="<__trans phrase="Optional">"
         help_page="categories"
         help_section="trackback_passphrase_protection">
        <input type="text" name="tb_passphrase" id="tb_passphrase" class="text" value="<mt:var name="tb_passphrase" escape="html">" />
      </mtapp:setting>
    </mt:if>
    </div>
  </mtapp:settinggroup>

  <mtapp:settinggroup id="category-ping">

    <h2 class="title"><__trans phrase="Outbound TrackBacks"></h2>

    <mtapp:setting
       id="ping_urls"
       label="<__trans phrase="Trackback URLs">"
       hint="<__trans phrase="Enter the URL(s) of the websites that you would like to send a TrackBack to each time you create an entry in this category. (Separate URLs with a carriage return.)">"
       help_page="categories"
       help_section="categories_urls_to_ping">
      <textarea name="ping_urls" id="ping_urls" cols="" rows="" class="text low"><mt:var name="ping_urls" escape="html"></textarea>
    </mtapp:setting>
  </mtapp:settinggroup>

  <mt:setvarblock name="action_buttons">
    <button
       type="submit"
       accesskey="s"
       title="<__trans phrase="Save changes to this category (s)">"
       class="save action button primary"
       ><__trans phrase="Save Changes"></button>
  </mt:setvarblock>

  <mt:include name="include/actions_bar.tmpl" bar_position="bottom" hide_pager="1" settings_bar="1">

</form>

<mt:setvarblock name="jq_js_include" append="1">
  jQuery.mtValidateRules['.label'] = function ($e) {
    if ( !$e.val().length ) return this.raise('Label is required.');
    return hasDupe(parent, id, $e.val()) ? this.raise('Duplicated label on this level.') : true;
  };

  jQuery.mtValidateRules['.basename'] = function ($e) {
    if ( !$e.val().length ) return this.raise('Basename is required.');
    if ( $e.val().match(/[^\w\-]/) ) return this.raise('Invalid Basename.');
    return hasDupe(parent, id, null, $e.val()) ? this.raise('Duplicated basename on this level.') : true;
  };
</mt:setvarblock>

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