<!--#set global $topmenu="config"#-->
<!--#set global $statpath="../.."#-->
<!--#set global $helpsubject="Configure+RSS-0-7"#-->
<!--#include $webdir + "/inc_top.tmpl"#-->

<!--#set global $submenu="rss"#-->
<!--#include $webdir + "/inc_cmenu.tmpl"#-->

<h2><a href="../rss">$T('configRSS')</a></h2>

<!--#if $active_feed#-->

  <!--#set $feed = $active_feed#-->
  <div class="EntryBlock">
  <form action="upd_rss_feed" method="post">
    <fieldset class="EntryFieldSet">
      <legend <!--#if $rss[$feed]['enable'] then 'class="feedEnabled"' else 'class="feedDisabled"'#-->><input type="checkbox" onclick="this.form.action='toggle_rss_feed?session=$session';  this.form.submit(); return false;" name="enable" <!--#if $rss[$feed]['enable'] then "CHECKED" else "" #-->/>
      $T('feed') $feed</legend>

  <input type="text" size="105" name="uri" value="$rss[$feed]['uri']"/>
  <input type="button" onclick="if (confirm('$T('confirm').replace("'","`") ')) { this.form.action='del_rss_feed?session=$session&';  this.form.submit(); return false;}" value="$T('button-delFeed')"/>
  <input type="button" onclick="this.form.action='test_rss_feed?session=$session&'; this.form.submit(); return false;" value="$T('button-preFeed')"/>
  <input type="button" onclick="this.form.action='download_rss_feed?session=$session&'; this.form.submit(); return false;" value="$T('button-forceFeed')"/>
  <br/><br/>

  <!--#if $rss[$feed]['pick_cat']#-->
    <select name="cat">
      <optgroup label="$T('category')">
        <!--#for $ct in $cat_list#-->
          <option value="$ct" <!--#if $ct == $rss[$feed]['cat'] then "selected" else ""#-->>$Tspec($ct)</option>
        <!--#end for#-->
      </optgroup>
    </select>
  <!--#end if#-->
  <select name="pp">
    <optgroup label="$T('pp')">
      <option value="" <!--#if $rss[$feed]['pp'] == "" then 'selected' else ''#-->>$T('default')</option>
      <option value="0" <!--#if $rss[$feed]['pp'] == "0" then 'selected' else ''#-->>$T('pp-none')</option>
      <option value="1" <!--#if $rss[$feed]['pp'] == "1" then 'selected' else ''#-->>$T('pp-repair')</option>
      <option value="2" <!--#if $rss[$feed]['pp'] == "2" then 'selected' else ''#-->>$T('pp-unpack')</option>
      <option value="3" <!--#if $rss[$feed]['pp'] == "3" then 'selected' else ''#-->>$T('pp-delete')</option>
    </optgroup>
  </select>
  <!--#if $rss[$feed]['pick_script']#-->
    <select name="script">
      <optgroup label="$T('script')">
        <!--#for $sc in $script_list#-->
          <option value="$sc" <!--#if $sc == $rss[$feed]['script'] then "selected" else ""#-->>$Tspec($sc)</option>
        <!--#end for#-->
      </optgroup>
    </select>
  <!--#end if#-->
  <select name="priority">
    <optgroup label="$T('priority')">
      <option value="-100" <!--#if $rss[$feed]['priority'] == -100 then 'selected' else ''#-->>$T('default')</option>
      <option value="2" <!--#if $rss[$feed]['priority'] == 2 then 'selected' else ''#-->>$T('pr-force')</option>
      <option value="1" <!--#if $rss[$feed]['priority'] == 1 then 'selected' else ''#-->>$T('pr-high')</option>
      <option value="0" <!--#if $rss[$feed]['priority'] == 0 then 'selected' else ''#-->>$T('pr-normal')</option>
      <option value="-1" <!--#if $rss[$feed]['priority'] == -1 then 'selected' else ''#-->>$T('pr-low')</option>
      <option value="-2" <!--#if $rss[$feed]['priority'] == -2 then 'selected' else ''#-->>$T('pr-paused')</option>
    </optgroup>
  </select>

  <input type="hidden" name="feed" value="$feed"/>
  <input type="hidden" name="session" value="$session">
  <input type="submit" value="$T('button-save')"/>
  <br />

  </form>

  <br/><br/>

  <table>
    <tr>
      <th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
      <th>$T('rss-order')</th>
      <th>$T('rss-type')</th>
      <th>$T('rss-filter')</th>
      <!--#if $rss[$feed]['pick_cat']#--><th>$T('category')</th><!--#end if#-->
      <th>Mode</th>
      <!--#if $rss[$feed]['pick_script']#--><th>$T('script')</th><!--#end if#-->
      <th>$T('priority')</th>
      <th></th>
    </tr>

  <form action="upd_rss_filter" method="get">
  <tr class="odd">
  <td></td>
  <td></td>
  <td>
    <select name="filter_type">
      <option value="A" selected /> $T('rss-accept')</option>
      <option value="M" /> $T('rss-must')</option>
      <option value="R" /> $T('rss-reject')</option>
      <option value="C" /> $T('rss-mustcat')</option>
    </select>
  </td>
  <td><input type="text" size="60" name="filter_text" value=""></td>
  <!--#if $rss[$feed]['pick_cat']#-->
    <td>
      <select name="cat">
      <!--#for $ct in $cat_list#-->
        <option value="$ct" <!--#if $ct == "Default" then "selected" else ""#-->>$Tspec($ct)</option>
      <!--#end for#-->
      </select>
    </td>
  <!--#end if#-->
  <td>
    <select name="pp">
      <option value="" selected>$T('default')</option>
      <option value="0">$T('pp-none')</option>
      <option value="1">$T('pp-repair')</option>
      <option value="2">$T('pp-unpack')</option>
      <option value="3">$T('pp-delete')</option>
    </select>
  </td>
  <!--#if $rss[$feed]['pick_script']#-->
    <td>
      <select name="script">
      <!--#for $sc in $script_list#-->
        <option value="$sc" <!--#if $sc == "Default" then "selected" else ""#-->>$Tspec($sc)</option>
      <!--#end for#-->
      </select>
    </td>
  <td>
    <select name="priority">
      <option value="-100" selected>$T('default')</option>
      <option value="2">$T('pr-force')</option>
      <option value="1">$T('pr-high')</option>
      <option value="0">$T('pr-normal')</option>
      <option value="-1">$T('pr-low')</option>
      <option value="-2">$T('pr-paused')</option>
    </select>
  </td>
  <!--#end if#-->
  <input type="hidden" value="$rss[$feed]['filtercount']" name="index">
  <input type="hidden" value="$feed" name="feed">
  <input type="hidden" name="session" value="$session">
  <td><input type="submit" value="$T('button-save')"></td>
  </tr>
  </form>

  <!--#set $fnum = 0#-->
  <!--#for $filter in $rss[$feed].filters#-->
    <tr class="odd">
    <td>
      <form action="del_rss_filter" method="post">
      <input type="hidden" value="$fnum" name="index">
      <input type="hidden" value="$feed" name="feed">
      <input type="hidden" name="session" value="$session">
      <input type="submit" value="$T('rss-delFilter')"></form>
    </td>

  <form action="upd_rss_filter" method="get">
  <td>
    <input type="text" size="3" name="new_index" value=$fnum>
  </td>

  <td>
  <select name="filter_type">
    <option value="A" <!--#if $filter[3] == "A" then "selected" else ""#--> /> $T('rss-accept')</option>
    <option value="M" <!--#if $filter[3] == "M" then "selected" else ""#--> /> $T('rss-must')</option>
    <option value="R" <!--#if $filter[3] == "R" then "selected" else ""#--> /> $T('rss-reject')</option>
    <option value="C" <!--#if $filter[3] == "C" then "selected" else ""#--> /> $T('rss-mustcat')</option>
  </select>
  </td>

  <td><input type="text" size="60" name="filter_text" value="$filter[4]"/></td>
  <!--#if $rss[$feed]['pick_cat']#-->
    <td>
      <select name="cat">
      <!--#for $ct in $cat_list#-->
        <option value="$ct" <!--#if $ct == $filter[0] then "selected" else ""#-->>$Tspec($ct)</option>
      <!--#end for#-->
      </select>
    </td>
  <!--#end if#-->
  <td>
  <select name="pp">
    <option value="" <!--#if $filter[1] == "0" then 'selected' else ''#-->>$T('default')</option>
    <option value="0" <!--#if $filter[1] == "0" then 'selected' else ''#-->>$T('pp-none')</option>
    <option value="1" <!--#if $filter[1] == "1" then 'selected' else ''#-->>$T('pp-repair')</option>
    <option value="2" <!--#if $filter[1] == "2" then 'selected' else ''#-->>$T('pp-unpack')</option>
    <option value="3" <!--#if $filter[1] == "3" then 'selected' else ''#-->>$T('pp-delete')</option>
  </select>
  </td>
  <!--#if $rss[$feed]['pick_script']#-->
    <td>
      <select name="script">
      <!--#for $sc in $script_list#-->
        <option value="$sc" <!--#if $sc == $filter[2] then "selected" else ""#-->>$Tspec($sc)</option>
      <!--#end for#-->
      </select>
    </td>
  <!--#end if#-->
  <td>
    <select name="priority">
      <option value="-100" <!--#if $filter[5] == "-100" or $filter[4] == "" then 'selected' else ''#-->>$T('default')</option>
      <option value="2"    <!--#if $filter[5] == "2"    then "selected" else ""#-->>$T('pr-force')</option>
      <option value="1"    <!--#if $filter[5] == "1"    then "selected" else ""#-->>$T('pr-high')</option>
      <option value="0"    <!--#if $filter[5] == "0"    then "selected" else ""#-->>$T('pr-normal')</option>
      <option value="-1"   <!--#if $filter[5] == "-1"   then "selected" else ""#-->>$T('pr-low')</option>
      <option value="-2"   <!--#if $filter[5] == "-2"   then "selected" else ""#-->>$T('pr-paused')</option>
    </select>
  </td>
  <td>
  <input type="hidden" name="index" value="$fnum"/>
  <input type="hidden" name="feed" value="$feed"/>
  <input type="hidden" name="session" value="$session">
  <input type="submit" value="$T('button-save')"/>
  </td>
  </form>
  </tr>
  <!--#set $fnum = $fnum+1#-->
<!--#end for#-->

  </table>
  </div>
  </fieldset>

  <!--#if $error#-->
    <br/><br/><b>$error</b><br/><br/>
  <!--#end if#-->

  <h3>$T('rss-matched')</h3>
  <table id="catTable">
    <tr>
      <th>&nbsp;</th>
      <th>&nbsp;$T('rss-skip')&nbsp;</th>
      <th>&nbsp;$T('rss-filter')&nbsp;</th>
      <th>$T('sort-title')</th>
    </tr>
  <!--#set $odd = False#-->
  <!--#for $job in $matched#-->
    <!--#set $odd = not $odd#-->
    <tr class="<!--#if $odd then "odd" else "even"#-->">
    <td><form action="download" method="get">
      <input type="hidden" name="url" value="$job[0]"/>
      <input type="hidden" name="nzbname" value="$job[4]"/>
      <input type="hidden" value="$feed" name="feed"/>
      <input type="hidden" name="session" value="$session">
      <input type="submit" value="$T('link-download')">
    </form>
    </td>
    <td>$job[2]</td>
    <td>$job[3]</td>
    <td>$job[1]</td>
    </tr>
  <!--#end for#-->
  </table>

  <h3>$T('rss-notMatched')</h3>
  <table id="catTable">
    <tr>
      <th>&nbsp;</th>
      <th>&nbsp;$T('rss-skip')&nbsp;</th>
      <th>&nbsp;$T('rss-filter')&nbsp;</th>
      <th>$T('sort-title')</th>
    </tr>
  <!--#set $odd = False#-->
  <!--#for $job in $unmatched#-->
    <!--#set $odd = not $odd#-->
    <tr class="<!--#if $odd then "odd" else "even"#-->">
    <td><form action="download" method="get">
      <input type="hidden" name="url" value="$job[0]"/>
      <input type="hidden" name="nzbname" value="$job[4]"/>
      <input type="hidden" value="$feed" name="feed"/>
      <input type="hidden" name="session" value="$session">
      <input type="submit" value="$T('link-download')">
    </form>
    </td>
    <td>$job[2]</td>
    <td>$job[3]</td>
    <td>$job[1]</td>
    </tr>
  <!--#end for#-->
  </table>

  <h3>$T('rss-done')</h3>
  <!--#if $downloaded#-->
    <form action="clean_rss_jobs" method="get">
      <input type="hidden" value="$feed" name="feed"/>
      <input type="hidden" name="session" value="$session">
      <input type="submit" value="$T('button-clear')">
    </form><br/>
  <!--#end if#-->
  <table id="catTable">
    <tr>
      <th>$T('sort-title')</th>
    </tr>
  <!--#set $odd = False#-->
  <!--#for $job in $downloaded#-->
    <!--#set $odd = not $odd#-->
    <tr class="<!--#if $odd then "odd" else "even"#-->">
    <td>$job</td>
    </tr>
  <!--#end for#-->
  </table>

<!--#else#-->
  <div class="EntryBlock">
  <form action="add_rss_feed" method="post">
  <fieldset class="EntryFieldSet">
  <legend>$T('newFeedURI')</legend>
    <input type="text" size="10" name="feed" value="$feed"/>&nbsp;
    <input type="text" size="104" name="uri" value=""/><br/><br/>
    <input type="hidden" name="session" value="$session">
    <input type="submit" value="$T('button-add')"/>
  </fieldset>
  </form>
  </div>

  <p>$T('explain-RSS')</p>

  <div class="EntryBlock">
  <form action="save_rss_rate" method="post">
  <fieldset class="EntryFieldSet">
    <legend>$T('opt-rss_rate')</legend>
    <input type="text" name="rss_rate" value="$rss_rate">
    <input type="hidden" name="session" value="$session">
    <input type="submit" value="$T('button-save')"/>
    <br/>
    $T('explain-rss_rate')
  </fieldset>
  </form>
  </div>

  <div class="EntryBlock">
  <form action="rss_now" method="post">
  <fieldset class="EntryFieldSet">
    <legend>RSS</legend>
    <input type="hidden" name="session" value="$session">
    <input type="submit" value="$T('button-rssNow')"/>
    <br/>
    &nbsp;
  </fieldset>
  </form>
  </div>


  <table id="catTable">
    <tr>
      <th></th>
      <th>$T('enabled')</th>
      <th>$T('feed')</th>
      <th>URL</th>
    </tr>
  <!--#set $odd = False#-->
  <!--#for $feed in sorted($rss.keys(), cmp=lambda x,y: cmp(x.lower(), y.lower()))#-->
    <!--#set $odd = not $odd#-->
    <tr class="<!--#if $odd then "odd" else "even"#-->">
      <td><form action="del_rss_feed" method="get">
        <input type="hidden" name="session" value="$session">
        <input type="hidden" value="$feed" name="feed">
        <input type="button" onclick="if (confirm('$T('confirm').replace("'","`") ')) { this.form.action='del_rss_feed?session=$session&';  this.form.submit(); return false;}" value="$T('button-del')"/>
        </form>
      </td>
      <td><form action="upd_rss_feed" method="post">
        <input type="hidden" name="session" value="$session">
        <input type="hidden" value="$feed" name="feed">
        <input type="hidden" value="1" name="table">
        <input type="checkbox" onclick="this.form.action='toggle_rss_feed?session=$session';  this.form.submit(); return false;" name="enable" <!--#if $rss[$feed]['enable'] then "CHECKED" else "" #-->/>
        </form>
      </td>
      <td><a href="?feed=$rss[$feed]['link']">$feed</a></td>
      <td>$rss[$feed]['uri']</td>
    </tr>
  <!--#end for#-->
</table>

<!--#end if#-->


<!--#include $webdir + "/inc_bottom.tmpl"#-->
