<!--#set global $pane="RSS"#-->
<!--#set global $help_uri="Configure+RSS-0-7"#-->
<!--#include $webdir + "/_inc_header.tmpl"#-->



<div class="tabs">
  <ul>
    <li><a href="#tabs-rss">$T('tableFeeds')</a></li>
    <!--#if $active_feed#-->
    <li><a href="#tabs-settings">$active_feed $T('feedSettings')</a></li>
    <li><a href="#tabs-filters">$T('filters').capitalize()</a></li>
    <li><a href="#tabs-downloaded">$T('rss-done') (<!--#echo len($downloaded)#-->)</a></li>
    <!--#end if#-->
  </ul>



  <div id="tabs-rss">

  <!--#set $feeds = sorted($rss.keys(), cmp=lambda x,y: cmp(x.lower(), y.lower()))#-->
  <!--#if $feeds#-->

  <table class="rssTable">
    <tr>
      <th>$T('enabled').capitalize()</th>
      <th>$T('feed')</th>
      <th>URL</th>
      <th>$T('Plush-rss-delete')</th>
    </tr>
  <!--#set $odd = False#-->
  <!--#for $feed_item in $feeds#-->
    <!--#set $odd = not $odd#-->
    <tr class="<!--#if $odd then "odd" else "even"#-->">
      <td><form action="upd_rss_feed" method="post">
        <input type="hidden" name="session" value="$session">
        <input type="hidden" value="$feed_item" name="feed">
        <input type="hidden" value="1" name="table">
        <input type="checkbox" class="toggleFeedCheckbox" name="enable" <!--#if $rss[$feed_item]['enable'] then "CHECKED" else "" #-->/>
        </form>
      </td>
      <td><strong><a class="juiButton" href="?feed=$rss[$feed_item]['link']#tabs-settings" <!--#if $active_feed == $feed_item#-->id="activeFeedLink"<!--#end if#-->>$feed_item</a></strong></td>
      <td>$rss[$feed_item]['uri']</td>
      <td>
      <form style="display:inline" action="del_rss_feed" method="get">
        <input type="hidden" name="session" value="$session">
        <input type="hidden" value="$feed_item" name="feed">
      <input type="button" class="juiButton" onclick="if (confirm('$T('confirm').replace("'","`") ')) { this.form.action='del_rss_feed?session=$session&';  this.form.submit(); return false;}" value="$T('Plush-rss-delete')"/>
        </form>
    </td>
    </tr>
  <!--#end for#-->
  <tfoot><tr><th colspan="4">
  <form style="display: inline" action="rss_now" method="post">
  <input type="hidden" name="session" value="$session">
  <input class="juiButton" type="submit" value="$T('button-rssNow')"/>
  </form>
    <input type="submit" class="juiButton" value="$T('addFeed')" onclick="jQuery('#pane-rss-details').toggle(); jQuery('#pane-add-feed').toggle();"/>
  </th></tr></tfoot>
  </table>
<!--#else#-->
<!--#end if#-->

  <br/>
  <div id="pane-add-feed" <!--#if $feeds#-->style="display:none"<!--#end if#-->>
    <form action="add_rss_feed" method="post">
      <table class="rssTable">
        <tr><th colspan="2">$T('addFeed')</th></tr>
    <tr><td>$T('name')</td><td><input type="text" size="10" name="feed" value="$feed"/></td></tr>
      <tr><td>$T('newFeedURI')</td><td><input type="text" size="80" name="uri"/></td></tr>
      <tr><th colspan="2"><input type="submit" class="juiButton" value="$T('addFeed')"/></th></tr>
    </table>
    <input type="hidden" name="session" value="$session">
    </form>
    <br/><hr/>&nbsp;
  </div>

  <div id="pane-rss-details">
<p>
$T('explain-RSS')
</p>
  <form action="save_rss_rate" method="post">
    <strong>$T('opt-rss_rate'):</strong><br/>
    <small>$T('explain-rss_rate')</small><br/>
    <input type="text" name="rss_rate" value="$rss_rate" size=8 />
    <input type="hidden" name="session" value="$session"/>
    <input type="submit" class="juiButton" value="$T('button-save')"/>
  </form>
</div>

  </div>

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

  <div id="tabs-settings">

  <!--#set $feed = $active_feed#-->
  <form action="upd_rss_feed" method="post">

  <table class="rssTable">

  <tr><th colspan="2">$T('feedSettings')</th></tr>

  <tr><td class="rssLeftColumn">$T('enabled').capitalize()</td><td><input type="checkbox" class="toggleFeedCheckbox" name="enable" <!--#if $rss[$feed]['enable'] then "CHECKED" else "" #-->/></td></tr>

  <tr><td class="rssLeftColumn" style="vertical-align: top">$T('feed')</td><td><textarea rows="3" cols="80" name="uri">$rss[$feed]['uri']</textarea></td></tr>

  <!--#if $rss[$feed]['pick_cat']#-->
  <tr><td class="rssLeftColumn">$T('category')</td><td>
    <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>
  </td></tr>
  <!--#end if#-->

  <tr><td class="rssLeftColumn">$T('pp')</td><td>
    <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>
  </td></tr>

  <!--#if $rss[$feed]['pick_script']#-->
  <tr><td class="rssLeftColumn">$T('script')</td><td>
    <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>
  </td></tr>
  <!--#end if#-->

  <tr><td class="rssLeftColumn">$T('priority')</td><td>
    <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>
  </td></tr>

  <tr><th colspan="2"><input type="submit" class="juiButton" value="$T('button-save') Settings"/>
<input type="button" class="juiButton" onclick="if (confirm('$T('confirm').replace("'","`") ')) { this.form.action='del_rss_feed?session=$session&';  this.form.submit(); return false;}" value="$T('button-delFeed')"/>
  </th></tr>

  </table>

  <input type="hidden" name="feed" value="$feed"/>
  <input type="hidden" name="session" value="$session">

  </form>

  </div>



  <div id="tabs-filters">

  <table class="rssTable">
    <tr>
      <th>$T('Plush-rss-delete')</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>$T('priority')</th>
      <th>$T('mode')</th>
      <!--#if $rss[$feed]['pick_script']#--><th>$T('script')</th><!--#end if#-->
      <th>$T('Plush-rss-actions')</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="30" 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="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>
  <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>
  <!--#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" class="juiButton" value="$T('button-add')"></td>
  </tr>
  </form>

  <!--#set $fnum = 0#-->
  <!--#set $odd = True#-->
  <!--#for $filter in $rss[$feed].filters#-->
    <!--#set $odd = not $odd#-->
    <tr class="<!--#if $odd then "odd" else "even"#-->">
    <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" class="juiButton" value="$T('Plush-rss-delete')"></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="30" 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="priority">
      <option value="-100" <!--#if $filter[5] == "-100" 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>
  <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>
  <input type="hidden" name="index" value="$fnum"/>
  <input type="hidden" name="feed" value="$feed"/>
  <input type="hidden" name="session" value="$session">
  <input type="submit" class="juiButton" value="$T('button-save')"/>
  </td>
  </form>
  </tr>
  <!--#set $fnum = $fnum+1#-->
<!--#end for#-->

  <tr><th colspan="100%">
    <form action="none" method="post">
    <input type="button" class="juiButton" onclick="this.form.action='test_rss_feed?session=$session&'; this.form.submit(); return false;" value="$T('button-preFeed')"/>
    <input type="button" class="juiButton" onclick="this.form.action='download_rss_feed?session=$session&'; this.form.submit(); return false;" value="$T('button-forceFeed')"/>
    <input type="hidden" name="feed" value="$feed"/>
    <input type="hidden" name="session" value="$session">
    </form>
  </th>
  </tr>
  </table>

  <p>
  $T('Plush-explain-rssActions')
  </p>


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


  <h1>$T('rss-matched') (<!--#echo len($matched)#-->)</h1>

  <!--#if $matched#-->
    <table class="rssTable">
      <tr>
        <th>$T('link-download')</th>
        <th>$T('rss-skip')</th>
        <th>$T('rss-filter')</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" class="juiButton" value="$T('link-download')">
      </form>
      </td>
      <td>$job[2]</td>
      <td>$job[3]</td>
      <td>$job[1]</td>
      </tr>
    <!--#end for#-->
    </table>
  <!--#else#-->
    $T('none')
  <!--#end if#-->

  <br/><br/><br/>

  <h1>$T('rss-notMatched') (<!--#echo len($unmatched)#-->)</h1>

  <!--#if $unmatched#-->
    <table class="rssTable">
      <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" class="juiButton" value="$T('link-download')">
      </form>
      </td>
      <td>$job[2]</td>
      <td>$job[3]</td>
      <td>$job[1]</td>
      </tr>
    <!--#end for#-->
    </table>
  <!--#else#-->
    $T('none')
  <!--#end if#-->
</div>

  <div id="tabs-downloaded">
    <!--#if $downloaded#-->
      <table class="rssTable">
        <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#-->
    <tr><th>
    <form style="display: inline" action="none" method="post">
      <input type="button" class="juiButton" onclick="this.form.action='clean_rss_jobs?session=$session&'; this.form.submit(); return false;" value="$T('button-clear')"/>
      <input type="hidden" name="feed" value="$feed"/>
      <input type="hidden" name="session" value="$session">
    </form>
    </th></tr>
      </table>
    <!--#else#-->
      $T('none')
    <!--#end if#-->
  </div>

</div>

</div>
<!-- end feed tab -->
<!--#end if#-->

</div>

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