<script type="text/javascript" charset="utf-8">
  jQuery.noConflict();
  function join(id){
    form = jQuery('#<{$dirname}>_policy_oaipmh_mappingform');
    form.find(':hidden:eq(0)').val('join');
    form.find(':hidden:eq(1)').val(id);
    return true;
  }
  function add(id){
    form = jQuery('#<{$dirname}>_policy_oaipmh_mappingform');
    form.find(':hidden:eq(0)').val('add');
    form.find(':hidden:eq(1)').val(id);
    return true;
  }
  function del(id){
    form = jQuery('#<{$dirname}>_policy_oaipmh_mappingform');
    form.find(':hidden:eq(0)').val('delete');
    form.find(':hidden:eq(1)').val(id);
    form.submit();
    return true;
  }
  function update(){
    form = jQuery('#<{$dirname}>_policy_oaipmh_mappingform');
    form.find(':hidden:eq(0)').val('update');
    return true;
  }
  <{if $selectedprefix=='oai_dc'}>
  function autocreate(){
    form = jQuery('#<{$dirname}>_policy_oaipmh_mappingform');
    form.find(':hidden:eq(0)').val('autocreate');
    return true;
  }
  <{else}>
  function change(){
    form = jQuery('#<{$dirname}>_policy_oaipmh_mappingform');
    form.find(':hidden:eq(0)').val('change');
    form.submit();
    return true;
  }
  <{/if}>
  function init(){
    form = jQuery('#<{$dirname}>_policy_oaipmh_mappingform');
    form.find(':hidden:eq(0)').val('init');
    form.find('#<{$dirname}>_selectedprefix').val('');
    form.find('#<{$dirname}>_selecteditemtype').val('');
    form.submit();
    return true;
  }
</script>
<{include file="file:admin_header.html"}>
<{$errors}>
<form name="<{$dirname}>_policy_oaipmh_mappingform" id="<{$dirname}>_policy_oaipmh_mappingform" action="policy_oaipmh_mapping.php" method="post">
<input name="op" value="" type="hidden"/>
<input name="targetid" value="" type="hidden"/>
<{$token_ticket}>
<div style="text-align: center; margin-left: 8px; margin-top: 15px;">
<table>
  <tr>
  <td style="width: 20%; text-align: left;" class="even">
    <{$smarty.const._AM_XOONIPS_POLICY_OAIPMHQUOTA_PREFIX_TITLE}>
  </td>
  <td style="width: 80%; text-align: left;" class="even">
  <{if $selectedprefix eq '' || $selecteditemtype eq ''}>
    <select name="selectedprefix" size="1">
    <{foreach item=prefix from=$prefixList }>
    <option value="<{$prefix}>" <{if $selectedprefix==$prefix}>selected="selected"<{/if}>><{$prefix|xoops_escape}></option>
    <{/foreach}>
    </select>
  <{else}>
    <b><{$selectedprefix}></b>
    <input id="<{$dirname}>_selectedprefix" name="selectedprefix" value="<{$selectedprefix}>" type="hidden"/>
  <{/if}>
  </td>
  </tr>
  <tr>
  <td style="width: 20%; text-align: left;" class="even">
    <{$smarty.const._AM_XOONIPS_POLICY_OAIPMHQUOTA_ITEMTYPE_TITLE}>
  </td>
  <td style="width: 80%; text-align: left;" class="even">
  <{if $selectedprefix eq '' || $selecteditemtype eq ''}>
    <select name="selecteditemtype" size="1">
    <{foreach item=itemtype from=$itemtypeList }>
    <option value="<{$itemtype.item_type_id}>" <{if $selecteditemtype==$itemtype.item_type_id}>selected="selected"<{/if}>><{$itemtype.name|xoops_escape}></option>
    <{/foreach}>
    </select>
  <{else}>
    <b><{$selecteditemtypename}></b>
    <input id="<{$dirname}>_selecteditemtype" name="selecteditemtype" value="<{$selecteditemtype}>" type="hidden"/>
  <{/if}>
  </td>
  </tr>
  <{if $selectedprefix eq '' || $selecteditemtype eq ''}>
    <tr><td colspan="2"><input class="formButton" type="button" value="<{$smarty.const._AM_XOONIPS_LABEL_NEXT}>"  onclick="change()"/></td></tr>
  <{/if}>
</table>
</div>

<{if $selectedprefix ne '' && $selecteditemtype ne ''}>
<table width="100%" cellspacing="1" class="outer">
  <tbody>
  <tr>
   <th><{$smarty.const._AM_XOONIPS_POLICY_OAIPMHQUOTA_SCHEMA_TITLE}></th>
   <th><{$smarty.const._AM_XOONIPS_POLICY_OAIPMHQUOTA_FIELD_TITLE}></th>
  </tr>
  <{foreach item=schema from=$schemaList}>
  <tr>
    <td class="head" style="width: 20%; vertical-align: top;">
      <{$schema.name}><{if $schema.min_occurences==1}><span style="color:red;">*</span><{/if}>
    </td>    
    <td class="<{cycle values="odd,even" name="c0"}>" style="width: 80%; vertical-align: top;">
    <{if $schema.data}> 
    <{foreach item=data key=dk from=$schema.data }>
        <{foreach item=select key=sk from=$data.selects }>
      <{if $sk>0 || $dk>0}><br/><{/if}>
        <select name="select_<{$schema.schema_id}>_<{$dk}>[]" size="1">
          <option value=""></option>
          <{foreach item=valueset from=$schema.list }>
            <option value="<{$valueset.key}>" <{if $valueset.key==$select}>selected="selected"<{/if}>><{$valueset.value|xoops_escape}></option>
          <{/foreach}>
        </select>
      <{if $dk>0 || $sk>0}>
         <a href="#" onclick="del('<{$schema.schema_id}>_<{$dk}>_<{$sk}>')"><img src="../images/icon_delete.png" alt="<{$smarty.const._AM_XOONIPS_LABEL_DELETE}>" title="<{$smarty.const._AM_XOONIPS_LABEL_DELETE}>" /></a>
      <{/if}>
      <{/foreach}>
    <{if $schema.hasValueSet==false}>
      <br />   
      <input type="checkbox" name="checkbox_<{$schema.schema_id}>_<{$dk}>" value="1" <{if $data.checkbox==1}>checked="checked"<{/if}>/>
      <input type="text" size="80" value="<{$data.text|xoops_escape}>" name="text_<{$schema.schema_id}>_<{$dk}>"/><br/>
      <input type="submit" value="<{$smarty.const._AM_XOONIPS_LABEL_JOIN}>" onclick="join('<{$schema.schema_id}>_<{$dk}>')"/>      
      <{/if}>
    <{/foreach}>
  <{else}>
        <select name="select_<{$schema.schema_id}>_0[]" size="1">
        <option value=""></option>
        <{foreach item=valueset from=$schema.list }>
            <option value="<{$valueset.key}>"><{$valueset.value|xoops_escape}></option>
        <{/foreach}>
        </select>
      <{if $schema.hasValueSet==false}>
          <br />   
          <input type="checkbox" name="checkbox_<{$schema.schema_id}>_0" value="1" />
          <input type="text" size="80" value="" name="text_<{$schema.schema_id}>_0"/><br/>
          <input type="submit" value="<{$smarty.const._AM_XOONIPS_LABEL_JOIN}>" onclick="join('<{$schema.schema_id}>_0')"/>      
        <{/if}>
    <{/if}>
    <{if $schema.max_occurences==0}>
        <br/><input type="submit" value="<{$smarty.const._AM_XOONIPS_LABEL_ADD}>" onclick="add('<{$schema.schema_id}>')"/>
    <{/if}>
    </td>
  </tr>
  <{/foreach}>
  </tbody>
</table>
<{if $selectedprefix=='oai_dc'}>
  <p style="color:blue">&nbsp;&nbsp;&nbsp;<{$smarty.const._AM_XOONIPS_POLICY_OAIPMH_QUOTA_ATTENTION}></p>
  <p align="center">
  <input class="formButton" type="submit" value="<{$smarty.const._AM_XOONIPS_LABEL_AUTOCREATE}>" onclick="autocreate()"/>
<{else}>
  <p align="center">
<{/if}>
<input class="formButton" type="submit" value="<{$smarty.const._AM_XOONIPS_LABEL_UPDATE}>" onclick="update()"/>
<input class="formButton" type="submit" value="<{$smarty.const._AM_XOONIPS_LABEL_BACK}>" onclick="init()"/>
</p>
<{/if}>
</form>
<{include file="file:admin_footer.html"}>
