نتیجه جستجو مدارک

[insert_php]
if (isset($_POST[“searchinput”])) {
$text =urlencode($_POST[“searchinput”]);
}
else{
$text =”;
}

if (isset($_POST[“doctype1”])) {
$doctype1 =$_POST[“doctype1″];;
}
else{
$doctype1 =”;
}

if (isset($_POST[“hasAttachment”])) {
$hasAttachment=$_POST[“hasAttachment”];
}
else{
$hasAttachment=”false”;
}

if($hasAttachment==”on”) $hasAttachment=”true”;
else $hasAttachment=”false”;

if (isset($_GET[‘pa’])) {
$_GET[‘pa’]=$_GET[‘pa’];
}
else{
$_GET[‘pa’]=0;
}

if($_GET[‘pa’]){
$cur_page=$_GET[‘pa’];
//$pages=(($_GET[‘pa’]-1)*50)+1;
$pages=(($_GET[‘pa’]-1)*50);

if (isset($_GET[“searchtext”])) {
$text =urlencode($_GET[“searchtext”]);
}
else{
$text =”;
}

if (isset($_GET[“doctype”])) {
$doctype1 =$_GET[“doctype”];
}
else{
$doctype1 =”;
}
if (isset($_GET[“hasAttachment”])) {
$hasAttachment=$_GET[“hasAttachment”];
}
else{
$hasAttachment=”false”;
}

}
else {$pages=0;$cur_page=1;}

if($_SERVER[‘QUERY_STRING’]!=”)
{
parse_str($_SERVER[‘QUERY_STRING’]);
$_SERVER[‘QUERY_STRING’]= preg_replace(‘#(first=)’.$first.’#’, ‘first=’.$pages, $_SERVER[‘QUERY_STRING’]);

$jsonurl=”http://lib.amfm.ir:8080/rest/search/biblio/recordsbydoctype?”.$_SERVER[‘QUERY_STRING’];
$cur_url=”?”.$_SERVER[‘QUERY_STRING’];
}
else
{
$cur_url=”?searchtext=”.$text.”&doctype=”.$doctype1.”&first=”.$pages.”&size=50″;
if($hasAttachment==”true”)
$cur_url.=”&hasAttachment=”.$hasAttachment;

$jsonurl=”http://lib.amfm.ir:8080/rest/search/biblio/recordsbydoctype?searchtext=”.$text.”&doctype=”.$doctype1.”&first=”.$pages.”&size=50″;

if($hasAttachment==”true”)
$jsonurl.=”&hasAttachment=”.$hasAttachment;
}

try {
$context = stream_context_create(
array(
‘http’ => array(
‘follow_location’ => true,
‘max_redirects’ => ۲۰
),
“ssl”=>array(
“verify_peer”=>false,
“verify_peer_name”=>false,
)
)
);

$resultjson = file_get_contents($jsonurl,false,$context);
$datajson = json_decode($resultjson,true);
$pages=ceil($datajson[‘totalResult’]/50);

if($pages>۱) {
echo “

“;
}

echo ‘

‘;
if($datajson[‘totalResult’])
echo “مجموع نتایج : “.$datajson[‘totalResult’];
else
echo ‘

موردی یافت نشد

‘;

echo “

“;
echo “
“;

$lastnums=0;
$lastnums=$datajson[‘totalResult’]-(($cur_page-1)*50);

if($datajson[‘totalResult’]){
if (is_array($datajson[‘biblioList’])) {
if($lastnums==1 || $datajson[‘totalResult’]==1){
if (isset($datajson[‘biblioList’][‘mainEntry’])) {
$datajson[‘biblioList’][‘mainEntry’] = $datajson[‘biblioList’][‘mainEntry’];
}
else{
$datajson[‘biblioList’][‘mainEntry’] = 0;
}
if (isset($datajson[‘biblioList’][‘publishDate’])) {
$datajson[‘biblioList’][‘publishDate’] = $datajson[‘biblioList’][‘publishDate’];
}
else{
$datajson[‘biblioList’][‘publishDate’] = 0;
}
if (isset($datajson[‘biblioList’][‘publisherName’])) {
$datajson[‘biblioList’][‘publisherName’] = $datajson[‘biblioList’][‘publisherName’];
}
else{
$datajson[‘biblioList’][‘publisherName’] = 0;
}

echo ‘

‘;
echo ‘

‘;
echo ‘

‘;
echo “

” ;
if(($datajson[‘biblioList’][‘materialType’]==”BF”)||($datajson[‘biblioList’][‘materialType’]==”BL”)) echo “ “;
elseif (($datajson[‘biblioList’][‘materialType’]==”AF”)||($datajson[‘biblioList’][‘materialType’]==”AL”)) echo “ “;
elseif (($datajson[‘biblioList’][‘materialType’]==”TF”)||($datajson[‘biblioList’][‘materialType’]==”TL”)) echo “ “;
elseif (($datajson[‘biblioList’][‘materialType’]==”PF”)||($datajson[‘biblioList’][‘materialType’]==”PL”)) echo “ “;
else echo “ “;
echo $datajson[‘biblioList’][‘title’].”

“;
if($datajson[‘biblioList’][‘mainEntry’]) echo $datajson[‘biblioList’][‘mainEntry’].” / “;
if($datajson[‘biblioList’][‘publishDate’]) echo $datajson[‘biblioList’][‘publishDate’].” / “;
if($datajson[‘biblioList’][‘publisherName’]) echo $datajson[‘biblioList’][‘publisherName’];
echo “

“;
echo ‘

‘;
echo “

“;
echo “

“;
} else {
foreach ($datajson[‘biblioList’] as $keyjson => $valuejson)
{
if (isset($valuejson[‘mainEntry’])) {
$valuejson[‘mainEntry’] = $valuejson[‘mainEntry’];
}
else{
$valuejson[‘mainEntry’] = 0;
}
if (isset($valuejson[‘publishDate’])) {
$valuejson[‘publishDate’] = $valuejson[‘publishDate’];
}
else{
$valuejson[‘publishDate’] = 0;
}
if (isset($valuejson[‘publisherName’])) {
$valuejson[‘publisherName’] = $valuejson[‘publisherName’];
}
else{
$valuejson[‘publisherName’] = 0;
}

echo ‘

‘;
echo ‘

‘;
echo ‘

“;
echo “

“;
}
}

}
}
if ($resultjson === false) {
echo “ziro”;
}
} catch (Exception $ex) {
echo “Exception”;
}

[/insert_php]