Skip to content

Commit

Permalink
Batchsearch select ontologies.
Browse files Browse the repository at this point in the history
Added optional ontologies selection for the batch search function.
  • Loading branch information
e4ong1031 committed Aug 12, 2018
1 parent 5a045e1 commit f7a1832
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
21 changes: 19 additions & 2 deletions application/Controller/SearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,34 @@ public function batchsearch( $params = array() ) {
}
}

$batchontologies = $params['ontology'];
if ( $batchontologies != '' ) {
$batchontologies = explode( ',', $batchontologies );
} else {
$batchontologies = array();
}
//print_r($batchontologies);
//print_r($keywords);

$submit = false;
if ( array_key_exists( 'submit', $params ) ) {
$submit = true;
unset( $params['submit'] );
}

$ontologies = $this->model->getAllOntology();

if ( $submit && !empty($keywords) ) {
$jsons = array();
$ontologies = $this->model->getAllOntology();
foreach ( $keywords as $keyword ) {
$jsons[$keyword] = $this->model->searchKeyword( $keyword, '', 10000, true );
if ( empty( $batchontologies ) ) {
$jsons[$keyword] = $this->model->searchKeyword( $keyword, '', 10000, true );
} else {
$jsons[$keyword] = array();
foreach( $batchontologies as $batchontology ) {
$jsons[$keyword] = array_merge ( $jsons[$keyword], $this->model->searchKeyword( $keyword, $batchontology, 10000, true ) );
}
}
}
}

Expand Down
32 changes: 31 additions & 1 deletion application/View/Search/batchsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@

<?php require TEMPLATE . 'header.default.dwt.php'; ?>

<script src="<?php echo SITEURL; ?>public/js/inputpicker/jquery.inputpicker.js"></script>
<link href="<?php echo SITEURL; ?>public/css/inputpicker/jquery.inputpicker.css" rel="stylesheet" type="text/css"/>

<h3 class="head3_darkred">Ontobee Batch Search</h3>

<div>
Expand Down Expand Up @@ -74,10 +77,37 @@

</table>

<span style="margin-left:32px;"><strong>Please select ontologies (optional):</strong></span><br/>



<div style="margin-left:32px">
<input class="form-control" id="ontology" name="ontology" style="width:50%;height:32px;" value="<?php echo implode(",",$batchontologies);?>"/>
<script>
$('#ontology').inputpicker({
data:[
<?php
foreach ( $ontologies as $ontology ) {
echo
<<<END
{value:"{$ontology->ontology_abbrv}", fullname: "{$ontology->ontology_fullname}"},
END;
}
?>
],
fields:['value','fullname'],
fieldText : 'fullname',
multiple: true,
filterOpen: true,
autoOpen: true,
});
</script>
</div>

<p style="text-align:center;">
<input type="submit" name="submit" id="submit" value="Search" text-align="center" onClick="submitForm();"/>

<button type="button" name="reset" value="Reset" style="margin-left:40px;" text-align="center" onClick="document.getElementById('batchkeywords').value=''">Reset</button>
<button type="button" name="reset" value="Reset" style="margin-left:40px;" text-align="center" onClick="document.getElementById('batchkeywords').value='';document.getElementById('ontology').value=''">Reset</button>
</p>

</form>
Expand Down

0 comments on commit f7a1832

Please sign in to comment.