<html>
  <div tal:replace="structure context/manage_page_header"/>
    <body bgcolor="#ffffff" link="#000099" alink="#000099" vlink="#000099">
      <div tal:replace="structure context/manage_tabs"/>
	<style type="text/css">
	  td {
	     vertical-align: top;
	  }
	
	</style>

    <p>Templates are bind by 'portal_type'. Every Template Mixin enabled
         type registered in portal_types-tool is listed here.</p>
	
	<form action="manage_templates" method="POST"
	      tal:define="at context/archetype_tool;
	                  templates at/listTemplates;
			  vocab python:templates;
	                 ">
	
    <table class="main">
	<tr tal:repeat="fti python: at.listTemplateEnabledPortalTypes()">

	  <td><h3><img tal:attributes="src fti/content_icon" />
              <span tal:replace="string:${fti/product}" />:
              <span tal:replace="string:${fti/title_or_id}" /></h3>
          <p tal:condition="python:fti.id != fti.content_meta_type">
            Using meta_type <code tal:replace="string:${fti/content_meta_type}"/></p>
          <tal tal:define="overlaping python:fti.content_meta_type!=fti.getId() and [t for t in at.lookupTemplates(fti.content_meta_type) if t not in at.lookupTemplates(fti.getId())]">
            <tal:condition tal:condition="overlaping">
             <p>
             Templates bind to the from portal_type different meta_type:</p>
             <ul>
                <li tal:repeat="item overlaping" tal:content="item" />
             </ul>
             <p>Info: Archetypes 1.3.4 and later fixed a formerly broken <br />
                Template-Implemenation. Rebind this template if you need it.</p>
            </tal:condition>
          </tal>

      </td>
	  <td>
	    <select multiple="multiple"
	            tal:define="currentselection python:at.lookupTemplates(fti.getId());
	                        getValue nocall:vocab/getValue"
		        tal:attributes="name string:template_names_${fti/getId}:list;
		                        size python: len(vocab)">
	      <option selected=""
		          tal:repeat="item vocab"
		          tal:attributes="value item;
		                           selected python:item in currentselection and 'selected' or None;"
		          tal:content="python:'%s - (%s)' % (item, getValue(item))"/>
	    </select>

      </td>
	</tr>
    <tr>
       <td><input type="submit" name="submit" value="Update Bindings"/></td>
       <td>&nbsp;</td>
    </tr>
    <tr>
       <td>&nbsp;</td>
       <td>&nbsp;</td>
    </tr>
	<tr>
       <td>Add a new template</td>
	   <td>	
           <input type="text" name="newTemplate"/>
       </td>
	</tr>
    <tr>
       <td><input type="submit" name="addTemplate" value="Add Template"/></td>
       <td>&nbsp;</td>
    </tr>
    </table>






    </form>

      </body>
  </html>
