All publications

<?php

$epca_code2 = "SAVMOFYZ";
$this_year = $_POST['this_year'];
settype($this_year, 'integer');
if (!$this_year) $this_year = date("Y");

echo "

Publications in the year “.$this_year.”

The data are taken from the on-line database of the Central Library of the Slovak Academy of Sciences.”;

// Roky pre vyber – this_year select box
echo “

Select publication year for the list: “;
for ($rok=date(“Y”);$rok>=”1980″;$rok–)
{
if ($this_year==$rok) $selected=”selected=’selected'”; else $selected=””;
echo “”.$rok.””;
}
echo “

“;

// odoslanie requestu na server
function SendReq($psReqUrl)
{
unset($next);
$max_repeat = 1;

for ($repeat=1;$repeat<=$max_repeat;$repeat++) {
unset($start);
$from = 1+$next;
$to = 501+$next;
$next=$next+501;
$psReqUrl2 = $psReqUrl."&from=".urlencode($from)."&to=".urlencode($to);

$ch = curl_init($psReqUrl2);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$out = curl_exec($ch);
if($out === false)
{
echo "

Publikačna činnosť – chyba: (“.curl_error($ch).”)

“;
}
curl_close($ch);
$ans = explode(“\n”,$out);
$max_line = count($ans)-1;

foreach ($ans as $line_num => $line) {
//z riadku 3 dostaneme pocet zaznamov celkom, vydelime a zaokruhlime aby sme mohli prechadzat dalsie zaznamy nad 501
if ($line_num==3) $max_repeat = ceil(trim($line)/501);
//ak nacita 0 ako pocet zaznamov, alebo nacita text namiesto cisla osetrime max_repeat
if (!$max_repeat OR $max_repeat==0 OR !is_numeric($max_repeat)) $max_repeat = 1;

//ak nahodou nacita zly max_repeat, nastavime pri hodnote nad 4 (viac ako 2000 zaznamov) na 1
if ($max_repeat>4) $max_repeat = 1;

if (strstr($line,”###”)) { $start=true; if (!$prvykrat) { $li=”

  • “; $prvykrat=1; } else $li=”
  • \n

  • “; }
    if (strstr($line,”Typ:”)) $type = str_replace(“Typ:”,” Typ: “,$line).”“;
    if (strstr($line,”Typ: “)) unset($type);

    if ($start AND !strstr($line,”Ohlasy:”) AND !strstr($line,”###”) AND ($line OR $line_num==$max_line) AND !strstr($line,”Typ:”))
    {
    if ($line_num==$max_line) { unset($li);unset($type); }
    $line = htmlspecialchars($line);
    $line = str_replace(“&#”,”&#”,$line);
    $line = str_replace(“<u>”,”“,$line);
    $line = str_replace(“</u>”,”
    “,$line);
    $vzor = $li.$line.$type;

    if ($start_cit)
    {
    $aaa++;
    $vys[$aaa] = str_replace(“[10]”,”[999]”,$vzor);
    $vys[$aaa] = str_replace(“[1]”,”[1.0]”,$vys[$aaa]);
    $vys[$aaa] = str_replace(“[2]”,”[2.0]”,$vys[$aaa]);
    }
    else
    {
    if ($vys[1])
    {
    asort($vys); $first_time=0;
    foreach ($vys as $key => $val)
    {
    $val = str_replace(“[999]”,”[10]”,$val);
    $val = str_replace(“[1.0]”,”[1]”,$val);
    $val = str_replace(“[2.0]”,”[2]”,$val);
    if ($first_time==”0″) $ohlasy_title=”Citácie:
    “;
    else unset($ohlasy_title);
    $first_time++;
    $vysledok .= “

    “.$ohlasy_title.$val.”

    “;
    }
    $vysledok .= $vzor; unset($key); unset($aaa); $vys = array();
    }
    else $vysledok .= $vzor;
    }
    }

    if (strstr($line,”Ohlasy:”))
    {
    $start_cit=true;
    unset($type);
    unset($li);
    }

    if (strstr($line,”###”)) unset($start_cit);
    }
    } //for end

    return $vysledok;
    }
    // end funkcie

    if ($type) $type_line = “@and @attr 1=2461 ‘$type'”;
    if (strstr($epca_code,”SAV”)) $or = “@or ‘”.$epca_code.”‘”;

    // $query=”@attr 98=2 $type_line @and @attr 1=2456 ‘”.$this_year.”‘ @attr 1=2462 $or ‘”.$epca_code2.”‘”;
    $query=”@attr 98=2 $type_line @and @attr 1=2456 ‘”.$this_year.”‘ @attr 1=2462 $or ‘”.$epca_code2.”‘”;

    $WSURL = “http://library.sk:8080/i2/i2.ws.cls”;
    $dbepca = “SavUnEpca”;
    $charset = “utf-8”;
    // $sort = “1=2466c i< 1=2461c i<"; //sort podla prveho mena 2466c a typu publ.
    $sort = "1=2461c i< 1=2466c i<"; //sort podla prveho mena 2466c a typu publ.
    $fmt = "TEXT_EPCA_ISO_SAV_OH_WS";
    $query = str_replace("\'","'",$query);

    $requrl=$WSURL."?".
    "method=search&".
    "db=".urlencode($dbepca)."&". //databaza v ktorej sa ma vyhladavat
    "query=".urlencode($query)."&". //otazka vo formate PQF
    "sort=".urlencode($sort)."&". //sort
    "charset=".urlencode($charset)."&". //znakova sada
    "fmt=".urlencode($fmt); //format vysledku

    if ($this_year AND $epca_code2) $publications = SendReq($requrl);

    if (!$publications) echo "

    Žiadne publikácie nevyhovujú tomuto kritériu.

    “;
    else echo “

      \n”.$publications.”

      \n

    \n”;
    ?>