<?xml version="1.0" encoding="UTF-8"?>
<actions>

<meta>
  <description>spezielles Template für das System der Stabi Berlin</description>
</meta>


<action id="connect">
</action>

<action id="update-all">
  <page url="https://ausleihe.staatsbibliothek-berlin.de/opac/user.S?LANG=de&FUNC=medk&DUM1=&BENUTZER={uri-encode($username)}&PASSWORD={uri-encode($password)}" templateFile="update"/>
<!--  <error templateFile="loginError"/>-->
</action>


<action id="update-single">
  <page url="http://stabikat.de:8080/DB=1/CMD?ACT=SRCHA&IKT=54&SRT=YOP&TRM={uri-encode($book.id)}" templateFile="../pica/searchDetails"/>
  
  <page test="not($book.stabikatFound) and contains($book.id, '-')"   
        url="http://stabikat.de:8080/DB=1/CMD?ACT=SRCHA&IKT=54&SRT=YOP&TRM={uri-encode($book.shortId)}" 
        templateFile="../pica/searchDetails"/>
  
</action>


<action id="renew-list">
  <variable name="book-list">string-join(for $book in $renew-books return x"{uri-encode($book.extendId)}=YES", "&amp;")</variable> 

  <page url="https://ausleihe.staatsbibliothek-berlin.de/opac/verl.S" templateFile="simpleCheck">
    <post name="LANG" value="de"/>
    <post name="FUNC" value="verl"/>
    <post name="BENUTZER" value="{$username}"/>
    <post name="PASSWORD" value="{$password}"/>
    <post value="{$book-list}"/>
  </page>
  <page url="https://ausleihe.staatsbibliothek-berlin.de/opac/medk.S" templateFile="fastUpdate">
    <post name="LANG" value="de"/>
    <post name="BENUTZER" value="{$username}"/>
    <post name="PASSWORD" value="{$password}"/>
  </page>
</action>



<!-- compare pica template. 
Changes:
    x before all search options
     -->
<action id="search">
  <variable name="searchOptions">
  encode-for-uri( string-join(
    (if ($book.title != "")    then concat("xtit ", $book.title)    else (),
     if ($book.author != "")   then concat("xprs ", $book.author)   else (),
     if ($book.isbn != "")     then concat("xisb ", $book.isbn)     else (),
     if ($book.year != "")     then concat("xjah ", $book.year)     else (),
     if ($book.keywords != "") then concat("xslw ", $book.keywords) else ()), " UND "))
  </variable>


  <page url="http://stabikat.de/DB=1/SET=2/TTL=1/CMD?ACT=SRCHA&IKT=1016&SRT=RLV&TRM={$searchOptions}" templateFile="../pica/searchList"></page>
  
  <page test="$singleResult" url="http://stabikat.de/DB=1/SET=2/TTL=1/CMD?ACT=SRCHA&IKT=1016&SRT=RLV&TRM={$searchOptions}" templateFile="../pica/searchDetails"></page>

  <variable name="i">0</variable>
  <loop test="$nextPage != '' and $i < 10">
    <page url="{$nextPage}" templateFile="../pica/searchList"></page>
    <variable name="i">$i + 1</variable>
  </loop>
    
</action>

<action id="search-details">
  <page url="{$book.home-url}" templateFile="../pica/searchDetails"></page>
</action>

</actions>
