'startDate[year]','direction'=>SORT_ASC))); foreach($allValues as $pbd) { if (is_array($pbd['journal'])) { $myjournal = $pbd['journal'][0]; if (in_array($myjournal, $journals)) { continue; } else { $journals[] = $myjournal; } } } //Find journals that are empty foreach($allValues as $pdb) { if (empty($pdb['journal'][0])) { if (!in_array($pdb['journal'], $journals)) { $emptyjournals[$pdb['kid']] = $pdb; } } } //function to specify dates selected function filterdates($data,$postdatatime,$times) { $mylist = array('startDate', 'endDate', 'published', 'letterPublished', 'posted'); $kingdom = array(); foreach($data as $pbd) { foreach($mylist as $things) { if (isset($pbd[$things][$times]) && ($pbd[$things][$times] == $postdatatime)) { $kingdom[$pbd['kid']] = $pbd; } } } return $kingdom; } //function sorts the searches by kora's pdb. function cmp($a, $b) { return strcmp($a["pbd"], $b["pbd"]); } //create searchQuery if (!empty($_POST['submit'])) { $titlestr = array(); $searchQuery = array(); $myarray = array(); if (isset($_POST['title']) && !empty($_POST['title'])) { $usingtitle = true; $titlestr[] = $_POST['title'].' '; $tempclause1 = new KORA_Clause('title','LIKE','%'.$_POST['title'].'%'); $tempclause2 = new KORA_Clause('article_title','LIKE','%'.$_POST['title'].'%'); $tempclause3 = new KORA_Clause($tempclause1, 'OR', $tempclause2); $searchQuery[] = $tempclause3; } if (isset($_POST['keywords']) && !empty($_POST['keywords'])) { $keywords = parseSearchString($_POST['keywords']); if(sizeof($keywords)>0) { foreach ($keywords as $word) { if (empty($word)) { continue; } $searchQuery[] = new KORA_Clause('notes','LIKE','%'.$word.'%'); $searchQuery[] = new KORA_Clause('content','LIKE','%'.$word.'%'); $searchQuery[] = new KORA_Clause('title','LIKE','%'.$word.'%'); $searchQuery[] = new KORA_Clause('article_title','LIKE','%'.$word.'%'); $searchQuery[] = new KORA_Clause('authors','LIKE','%'.$word.'%'); $searchQuery[] = new KORA_Clause('editors','LIKE','%'.$word.'%'); $searchQuery[] = new KORA_Clause('book','LIKE','%'.$word.'%'); $searchQuery[] = new KORA_Clause('publisher','LIKE','%'.$word.'%'); $searchQuery[] = new KORA_Clause('reviewers','LIKE','%'.$word.'%'); } } } $searchq = array(); if (isset($_POST['year']) && !empty($_POST['year'])) { $usingtitle = false; $searchq['startDate'][] = "startDate LIKE '".$_POST['year']."-%'"; $searchq['endDate'][] = "endDate LIKE '".$_POST['year']."-%'"; $searchq['published'][] = "published LIKE '".$_POST['year']."-%'"; $searchq['letterPublished'][] = "letterPublished LIKE '".$_POST['year']."-%'"; $searchq['posted'][] = "posted LIKE '".$_POST['year']."-%'"; } if (isset($_POST['month']) && !empty($_POST['month'])) { $usingtitle = false; if ($_POST['month'] < 10) { $_POST['month'] = '0'.$_POST['month']; } $searchq['startDate'][] = "startDate LIKE '%-".$_POST['month']."-%'"; $searchq['endDate'][] = "endDate LIKE '%-".$_POST['month']."-%'"; $searchq['published'][] = "published LIKE '%-".$_POST['month']."-%'"; $searchq['letterPublished'][] = "letterPublished LIKE '%-".$_POST['month']."-%'"; $searchq['posted'][] = "posted LIKE '%-".$_POST['month']."-%'"; } if (isset($_POST['day']) && !empty($_POST['day'])) { $usingtitle = false; if ($_POST['day'] < 10) { $_POST['day'] = '0'.$_POST['day']; } $searchq['startDate'][] = "startDate LIKE '%-".$_POST['day']."'"; $searchq['endDate'][] = "endDate LIKE '%-".$_POST['day']."'"; $searchq['published'][] = "published LIKE '%-".$_POST['day']."'"; $searchq['letterPublished'][] = "letterPublished LIKE '%-".$_POST['day']."'"; $searchq['posted'][] = "posted LIKE '%-".$_POST['day']."'"; } if ($usingtitle == false) { if (isset($_POST['author_editor']) && !empty($_POST['author_editor'])) { if (isset($_POST['title']) && !empty($_POST['title'])) { $titlestr[] = $_POST['author_editor'].' '; $tempclause1 = new KORA_Clause('authors','LIKE','%'.$_POST['author_editor'].'%'); $tempclause2 = new KORA_Clause('editors','LIKE','%'.$_POST['author_editor'].'%'); $tempclause3 = new KORA_Clause($tempclause1, 'OR', $tempclause2); $searchQuery[] = $tempclause3; } else if (empty($searchq)) { $titlestr[] = $_POST['author_editor'].' '; $tempclause1 = new KORA_Clause('authors','LIKE','%'.$_POST['author_editor'].'%'); $tempclause2 = new KORA_Clause('editors','LIKE','%'.$_POST['author_editor'].'%'); $tempclause3 = new KORA_Clause($tempclause1, 'OR', $tempclause2); $searchQuery[] = $tempclause3; } } if (isset($_POST['journal']) && !empty($_POST['journal']) && $_POST['journal'] != '') { if (empty($searchq)) { $usingjournal = true; foreach ($_POST['journal'] as $journal) { $titlestr[] = $journal.' '; if (empty($journal)) { $booljournal = true; } if (!empty($journal)) { $searchQuery[] = new KORA_Clause('journal','=',$journal); } } } } } /*?>

Document Search

'; //print_r($searchQuery); //echo ''; $metadataValues = array(); foreach($searchQuery as $ico) { $temparray = KORA_Search($authTokenID,$projectID,$schemeID,$ico,$fields,array(array('field'=>'pbd','direction'=>SORT_ASC))); foreach($temparray as $pdb) { if(!in_array($pdb['kid'], $metadataValues)) { $metadataValues[$pdb['kid']] = $pdb; } } // if (!empty($newarray)) // { // $metadataValues = $newarray; // } } $onlydates = false; if (empty($metadataValues)) { if ($usingjournal == true) { $metadataValues = $emptyjournals; } else if (!empty($_POST['day']) || !empty($_POST['month']) || !empty($_POST['year'])) { $metadataValues = $allValues; $onlydates = true; } else { $metadataValues = $newarray; } } // else // { // $metadataValues = $newarray; // } //Show only the dates specified. if ($onlydates == true) { if (!empty($_POST['day'])) { $metadataValues = filterdates($metadataValues, $_POST['day'], 'day'); } if (!empty($_POST['month'])) { $metadataValues = filterdates($metadataValues, $_POST['month'], 'month'); } if (!empty($_POST['year'])) { $metadataValues = filterdates($metadataValues, $_POST['year'], 'year'); } // foreach($allValues as $pdb) // { // if(!in_array($pdb['kid'], $metadataValues)) // { // $metadataValues[$pdb['kid']] = $pdb; // } // } } else { $datesncluded = false; if (!empty($_POST['day'])) { $allValues = filterdates($allValues, $_POST['day'], 'day'); $datesncluded = true; } if (!empty($_POST['month'])) { $allValues = filterdates($allValues, $_POST['month'], 'month'); $datesncluded = true; } if (!empty($_POST['year'])) { $allValues = filterdates($allValues, $_POST['year'], 'year'); $datesncluded = true; } if ($datesncluded == true) { foreach($allValues as $pdb) { if(!in_array($pdb['kid'], $metadataValues)) { $metadataValues[$pdb['kid']] = $pdb; } } } } // if (isset($_POST['journal']) && !empty($_POST['journal']) && $_POST['journal'] != '') // { // foreach($emptyjournals as $pbd) // { // if (!in_array($pdb['kid'], $metadataValues)) // { // $metadataValues[$pbd['kid']] = $pbd; // } // } // } usort($metadataValues, "cmp"); foreach ($metadataValues as $pbd) { if (is_array($pbd['chronological'])) { if (in_array('Publications',$pbd['chronological'])) { $str = publicationshort($pbd); } elseif (in_array('Presentations',$pbd['chronological'])) { $str = presentationshort($pbd); } elseif (in_array('Comments',$pbd['chronological'])) { $str = commentshort($pbd); } } else { $str = ''; if (!empty($pbd['title'])) { if (!empty($pbd['authors'])) { $str .= implode(', ',$pbd['authors'])."'s "; } //print 'MYTITLE'.$pbd['title']; $str .= ''.$pbd['title'].''; if (!empty($pbd['edition'])) { $str .= ', '.$pbd['edition'].' ed.'; } if (!empty($pbd['publisher'])) { $str .= ', '.$pbd['publisher']; } if (!empty($pbd['city'])) { $str .= '. ('.$pbd['city']; $date = vali_date($pbd['published']); if (!empty($date)) { $str .= ': '.$date; } $str .= ')'; } } else if (!empty($pbd['article_title'])) { if (!empty($pbd['authors'])) { $str .= implode(', ',$pbd['authors'])."'s "; } $str .= '"'.$pbd['article_title'].'"'; if (!empty($pbd['notes'])) { $str .= ', '.$pbd['notes']; } $sdate = vali_date($pbd['startDate']); if (!empty($sdate)) { $str .= ' ('.$sdate.')'; } if (!empty($pbd['pages'])) { $str .= ': '.implode(', ',$pbd['pages']); } } } print '

'.$str.'

'; } print '

Clear Search Results'; } ?>