<kupu:feature
    name="body"
    implementation="plone"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:kupu="http://kupu.oscom.org/namespaces/dist"
    xmlns:tal="http://xml.zope.org/namespaces/tal"
    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
    i18n:domain="kupu">
  <kupu:id>$Id: body.kupu 66130 2009-07-06 17:19:28Z duncan $</kupu:id>
  <kupu:part name="editorframe"><script type="text/javascript">var focuscount = 0;</script>
    <div>
    <iframe class="kupu-editor-iframe"
        frameborder="0"
        src="emptypage"
        tabindex=""
        onfocus="this.contentWindow.focus();"
        tal:define="base python:here.kupu_library_tool.getBaseUrl(here, True);
                    base kupu_base_override|base;"
        tal:attributes="src string:${base}/emptypage;
                        id string:kupu-editor-iframe-${fname};
                        name string:kupu-editor-iframe-${fname};tabindex tabindex/next|tabindex|nothing;"
        >
    </iframe>
     <input type="hidden" name="text_format:default" value="text/html"
        tal:define="fieldName fieldName|inputname|nothing;
                val python:fieldName and 'text/html' or 'html';
                fieldName python:test(fieldName, fieldName+'_', '') + 'text_format:default';"
        tal:attributes="name fieldName;value val;"
     />
<tal:test condition="fieldName|nothing">
    <textarea cols="80" rows="25"
        class="kupu-editor-textarea"
        name="description"
        tal:condition="fieldName|nothing"
        tal:define="global kupu_content python:here.convertContentForKupu(fieldName, inputvalue);"
        tal:content="kupu_content"
        tal:attributes="name inputname;
                        onfocus onfocus|nothing;
                        onblur onblur|nothing;
                        rows rows|default;
                        cols cols|default;">
    </textarea>
</tal:test>
    <textarea cols="80" rows="25"
        class="kupu-editor-textarea"
        name="description"
        id="kupu-editor-textarea"
        tal:define="pss modules/Products/PythonScripts/standard;
                text_format text_format | python: getattr(here,'text_format','html');
                is_stx python:text_format=='structured-text';
                is_ptx python:text_format=='plain';"

        tal:condition="not:fieldName|nothing"
        tal:content="python:(is_stx and pss.structured_text(inputvalue))
                                    or (is_ptx and pss.newline_to_br(inputvalue))
                                    or inputvalue"
        tal:attributes="name inputname;
                        onfocus onfocus|nothing;
                        onblur onblur|nothing;
                        rows rows|default;
                        cols cols|default;">
    </textarea>
    </div>
  </kupu:part>

  <kupu:part name="suppress-kupu">
    <tal:guard tal:define="ti context/getTypeInfo | nothing"
               tal:condition="python: ti and ti.listActionInfos('object/edit', check_condition=0)">
      <div class="kupuoverride"
	  tal:condition="python:exists('kupu_content') and allowed and len(allowed)!=1"
	  tal:define="floated widget/allow_file_upload | python:1;
		  klass python:test(exists('kupu_content') and len(kupu_content), ' kupusourceoverride', '');
		  gAC nocall:field/getAllowedContentTypes|nothing;
		  allowed python:gAC and gAC(context) or path('field/allowable_content_types|nothing');"
	  tal:attributes="style python:test(floated, 'float:left;;', '');class string:kupuoverride$klass"
	><span class="discreet"><a class="forcekupu" href="#"
	  i18n:translate="suppress-kupu" i18n:attributes="title title_suppress_kupu;"
	  tal:define="fs fieldset|nothing;fs python:test(fs,'&amp;fieldset=%s'%fs,'');
	  editaction python:context.getActionInfo('object/edit')['url'];"
	  tal:attributes="href string:${editaction}?kupu.suppress=${fieldName}${fs};"
	  title="reload current page without kupu">
	   Edit without visual editor
	</a></span>
      </div>
    </tal:guard>
  </kupu:part>

  <kupu:part name="force-kupu">
    <tal:archetypes tal:condition="fieldName|nothing">
      <div class="kupuoverride"
        tal:condition="python:path('widget/allow_format_edit|python:True') and not path('kupu_convert_message_generated|nothing')"
        tal:define="floated widget/allow_file_upload | python:1;"
        tal:attributes="style python:test(floated, 'float:left;;', '');"
        >
        <span class="discreet"><a class="forcekupu" href="#"
           i18n:translate="force-kupu" i18n:attributes="title title_force_kupu;"
           tal:condition="python:portal.kupu_library_tool.isKupuEnabled(REQUEST=context.REQUEST, context=context, fieldName=fieldName)"
           tal:define="fs fieldset|nothing;fs python:test(fs,'&amp;fieldset=%s'%fs,None);"
           tal:attributes="href string:${request/URL0}?kupu.convert=${fieldName}${fs};"
           title="reload current page using kupu to edit this field">
           Edit with visual editor
        </a></span>
      </div>
    </tal:archetypes>
  </kupu:part>
</kupu:feature>
