<tal:block metal:use-macro="python:here.getFormsTool().getForm('site_admin_template').macros['page']">

<h1 metal:fill-slot="title">
  <span i18n:translate="" tal:omit-tag="">Local channels</span>
  <a tal:attributes="href string:${here/getSitePath}/localchannels_rdf"><img src="misc_/NaayaCore/xml.png" alt="Syndication (XML)" i18n:attributes="alt" /></a>
</h1>

<tal:block metal:fill-slot="section"
  tal:define="site here/getSite;
        site_url here/getSitePath;
        syndication_tool here/getSyndicationTool;
        ob_id python:request.get('id', '');
        ob_data python:syndication_tool.get_data_local_channel(ob_id)">
<p i18n:translate="">
  This page lists the local channels that this portal offers as feeds to other sites. 
  RDF and Atom feeds are automatically generated from each channel listed below as well as for each portal folder.
  Only the local channels listed below will appear when clicking the syndication icon 
  ( <img i18n:name="xml-icon" src="misc_/NaayaCore/xml.png" alt="Syndication (XML)" i18n:attributes="alt" /> ) available in some browsers 
  (e.g. Internet Explorer 7, Mozilla Firefox 2).
  Local channels are automatically generated in both <a href="http://en.wikipedia.org/wiki/Atom_%28standard%29" i18n:name="atom-standard">Atom</a> 
  and <a i18n:name="rdf-link" href="http://en.wikipedia.org/wiki/Resource_Description_Framework">RDF</a> formats.
  Read more about <a i18n:name="atom-link" href="http://www.intertwingly.net/wiki/pie/Rss20AndAtom10Compared" i18n:translate="">
  the differences between these formats on the Atom wiki</a>.
</p>
<h2 tal:condition="python:ob_data[0]!='add'">
  <a tal:attributes="href string:${site_url}/admin_localchannels_html" i18n:translate="">Add new channel</a>
</h2>
<fieldset>
  <legend>
    <tal:block tal:condition="python:ob_data[0]=='add'" i18n:translate="">Add new channel</tal:block>
    <tal:block tal:condition="python:ob_data[0]!='add'" i18n:translate="">Edit channel</tal:block>
  </legend>
  <form method="post" tal:attributes="action python:test(ob_data[0]=='add', '%s/admin_addlocalchannel' % site_url, '%s/admin_editlocalchannel' % site_url)">
  <div class="field">
    <label for="title" i18n:translate="">Title</label>
    <input type="text" name="title:utf8:ustring" size="50" tal:attributes="value python:ob_data[2]" />
  </div>
  <div class="field">
    <label for="description" i18n:translate="">Description</label>
    <textarea name="description" rows="5" cols="40" tal:content="python:ob_data[3]"></textarea>
  </div>  
  <div class="field">
    <label for="language" i18n:translate="">Language</label>
    <select name="language">
      <option value="auto" tal:attributes="selected python:ob_data[4]=='auto'">Auto-detect</option>
      <option tal:repeat="item here/gl_get_languages_map"
        tal:attributes="value python:item['id']; selected python:item['id']==ob_data[4]"
        tal:content="python:item['title']" />
    </select>
  </div>  
  <div class="field">
    <label for="type" i18n:translate="Type (translate as a noun)">Type</label>
    <select name="type">
      <option tal:repeat="item syndication_tool/get_channeltypes_list"
        tal:attributes="value item/id; selected python:item.id==ob_data[5]"
        tal:content="item/title" />
    </select>
  </div>
  <div class="field">
    <label for="objmetatype" i18n:translate="">Objects meta type(s) to include</label>
    <select name="objmetatype" size="5" multiple="true">
      <option tal:repeat="item here/get_meta_types"
          tal:attributes="value item; selected python:item in ob_data[6]"
          tal:content="item" />
    </select>
  </div>
  <div class="field">
    <label for="numberofitems" i18n:translate="">Maximum number of items to include</label>
    <input type="text" name="numberofitems" size="3" tal:attributes="value python:ob_data[7]" />
    <em i18n:translate="">(0 for all items)</em>
  </div>
  <div class="field" tal:condition="python:ob_data[0]=='add'">
    <label for="numberofitems" i18n:translate="">Create a portlet with the content of this channel</label>
    <input type="checkbox" name="portlet" checked="checked" />
  </div>
  <p>
    <input type="hidden" name="id" tal:attributes="value python:ob_data[1]" />
    <input type="submit" tal:attributes="value python:test(ob_data[0]=='add', 'Add', 'Save changes')" i18n:attributes="value" />
  </p>
  </form>
</fieldset>
<br />
<form method="post" tal:attributes="action string:${site_url}/admin_deletelocalchannel">
  <table class="datatable">
  <thead>
    <tr>
      <th class="scope-col" scope="col">&nbsp;</th>
      <th class="scope-col" scope="col" i18n:translate="">Title</th>
      <th class="scope-col" scope="col" i18n:translate="">Description</th>
      <th class="scope-col" scope="col" i18n:translate="">Language</th>
      <th class="scope-col" scope="col" i18n:translate="Type (translate as a noun)">Type</th>
      <th class="scope-col" scope="col" i18n:translate="">Actions</th>
    </tr>
  </thead>
  <tbody>
    <tr tal:repeat="channel syndication_tool/get_script_channels" tal:attributes="class python:test(path('repeat/channel/odd'), 'zebraodd', 'zebraeven')">
      <td valign="top"><input type="checkbox" name="ids" tal:attributes="value channel/id" /></td>
      <td valign="top" tal:content="channel/title_or_id" />
      <td valign="top" tal:content="channel/description" />
      <td valign="top" tal:define="lang channel/language"
        tal:content="python:test(lang=='auto', 'Auto-detect', here.gl_get_language_name(lang))" />
      <td valign="top" tal:content="python:syndication_tool.get_channeltype_title(channel.type)" />
      <td valign="top">
        [<a tal:attributes="href channel/absolute_url" i18n:translate="">Preview RDF</a>]
        [<a tal:attributes="href string:${channel/absolute_url}?feed=atom" i18n:translate="">Preview Atom</a>]
      </td>
    </tr>
    <tr tal:repeat="channel syndication_tool/get_local_channels" tal:attributes="class python:test(path('repeat/channel/odd'), 'zebraodd', 'zebraeven')">
      <td valign="top"><input type="checkbox" name="ids" tal:attributes="value channel/id" /></td>
      <td valign="top" tal:content="channel/title_or_id" />
      <td valign="top" tal:content="channel/description" />
      <td valign="top" tal:define="lang channel/language"
        tal:content="python:test(lang=='auto', 'Auto-detect', here.gl_get_language_name(lang))" />
      <td valign="top" tal:content="python:syndication_tool.get_channeltype_title(channel.type)" />
      <td valign="top">
        [<a tal:attributes="href channel/absolute_url" i18n:translate="">Preview RDF</a>]
        [<a tal:attributes="href string:${channel/absolute_url}?feed=atom" i18n:translate="">Preview Atom</a>]
        [<a tal:attributes="href string:${site_url}/admin_localchannels_html?id=${channel/id}" i18n:translate="">Edit channel</a>]
      </td>
    </tr>
  </tbody>
  </table>
  <input type="submit" value="Delete" i18n:attributes="value" />
</form>
<br />

</tal:block>

</tal:block>
