Skip to content

Commit

Permalink
bioCADDIE core UI v0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
RuilingLiu committed Mar 16, 2016
1 parent 483fc27 commit 1d8bf0e
Show file tree
Hide file tree
Showing 1,101 changed files with 252,573 additions and 4,706 deletions.
6 changes: 6 additions & 0 deletions 403.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php include $_SERVER['DOCUMENT_ROOT'].'/views/header.php'; ?>
<div class="container">
<h1>403. That’s an error.</h1>
<h3>Access Denied/Forbidden.</h3>
</div>
<?php include $_SERVER['DOCUMENT_ROOT'].'/views/footer.php';?>
9 changes: 9 additions & 0 deletions 404.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php include $_SERVER['DOCUMENT_ROOT'].'/views/header.php'; ?>

<div class="container">
<h1>404: Page not Found </h1>

<h3>Sorry, but the page you are looking for has not been found.</h3>
<h3>Try checking the URL for errors, then hit the refresh button on your browser.</h3>
</div>
<?php include $_SERVER['DOCUMENT_ROOT'].'/views/footer.php';?>
130 changes: 130 additions & 0 deletions about.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php

require_once dirname(__FILE__) .'/config/config.php';
require_once dirname(__FILE__) . '/trackactivity.php';

$errors = '';
$name = '';
$email = '';
$message = '';
$subject ='';

if(isset($_POST['submit']))
{
$subject = $_POST['SUBJECT'];
$name = $_POST["NAME"];
$message = $_POST["MESSAGE"];
$email = $_POST["EMAIL"];

if(empty($_SESSION['6_letters_code'] ) ||
strcasecmp($_SESSION['6_letters_code'], $_POST['6_letters_code']) != 0)
{
//Note: the captcha code is compared case insensitively.
//if you want case sensitive match, update the check above to
// strcmp()
$errors .= "\n The captcha code does not match!";
}

if(empty($errors))
{
//send the email
sendEmails();

echo '<script type="text/javascript">';
echo 'alert("You request has been received and we will contact you soon")';
echo '</script>';
}
}
function sendEmails(){
$subject = $_POST['SUBJECT'];

require_once dirname(__FILE__) . '/vendor/swiftmailer/swiftmailer/lib/swift_required.php';

$from = $_POST["EMAIL"];
$to = array("[email protected]","[email protected]","[email protected]");
$body = 'BioCADDIE contact request<br>
----------------------------------------<br>
NAME: '.$_POST["NAME"].'<br>
MESSAGE: '.$_POST["MESSAGE"].'<br>
EMAIL: '.$_POST["EMAIL"];

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername('[email protected]')
->setPassword('biocaddie4050@');

$mailer = Swift_Mailer::newInstance($transport);

$message = Swift_Message::newInstance('bioCaddie Contact us email:' . $subject)
->setFrom(array($from => 'bioCaddie'))
->setTo($to)
->setBody($body)
->setContentType("text/html");
$mailer->send($message);
}

?>

<?php include dirname(__FILE__).'/views/header.php'; ?>
<div class="container" style="background-color:#DCDCDC">

<h3 style="text-align:center"> OUR MISSION </h3>

<p style="text-align:center">Develop a prototype of a data discovery index.</p>
<div class="about_box" style="background-color:white">
<br>
<p class="about_style"> We at the bioCADDIE (biomedical and healthcare Data Discovery Index Ecosystem) are developing a prototype of a data discovery index (DDI) to help you search and find datasets you’re interested in. Our prototype aims to provide:</p>

<p class="about_style"> 1. A free, user-friendly means for you to locate data sets of interest.</p>
<p class="about_style"> 2. Standardized, searchable information (metadata) about the contents of a data set.</p>

<p class="about_style"> You can use the web interface and provide us feedback <a class="hyperlink" href="./feedback.php">here </a> about your search experience. This is a prototype in development and your valuable suggestions and comments will help us to make the system better.</p>

<p class="about_style"> For more information about bioCADDIE, click <a class="hyperlink" href="https://biocaddie.org/" target="_blank"> here </a></p>

<p class="about_style" > Contact us:</p>

<div id='contact_form_errorloc' class='err'></div>
<form method="POST" name="contact_form"
action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" class="about_style" data-toggle="validator">
<div class="about_style" >
<label for="name">Name *</label>
<input type="text" name="NAME" class="form-control" id="pwd" placeholder="Your name" value="<?php echo $name;?>" required>


<label for="email">E-mail address *</label>
<input type="email" name="EMAIL" class="form-control" id="email" placeholder="Your email" value="<?php echo $email;?>"required>
<div class="form-group">
<label for="">Subject *</label>
<input type="text" name="SUBJECT" class="form-control" id="subject" value="<?php echo $subject;?>" required >
</div>
<div class="form-group">
<label for="">Message * </label>
<textarea type="text" name="MESSAGE" class="form-control" id="message" rows="4" required><?php echo htmlspecialchars($message)?></textarea>
</div>
<?php if(!empty($errors)) {
echo "<p class='err' style='color:red'>" . nl2br($errors) . "</p>";
} ?>

<p>
<img src="html-contact-form-captcha/captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' ><br>
<label for='message'>Enter the code above here :</label><br>
<input id="6_letters_code" name="6_letters_code" type="text"><br>
<small>Can't read the image? click <a href='javascript: refreshCaptcha();' class="hyperlink">here</a> to refresh</small>
</p>
<input type="submit" value="Submit" name='submit'>
</div>
</form>
</div>
</div>


<?php include dirname(__FILE__) . '/views/footer.php'; ?>
<script language='JavaScript' type='text/javascript'>
function refreshCaptcha()
{
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
</script>
</body>
</html>
33 changes: 33 additions & 0 deletions advanced.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

require_once dirname(__FILE__) .'/config/config.php';
include dirname(__FILE__) . '/views/header.php';
require_once dirname(__FILE__) . '/search/SearchBuilder.php';

require_once dirname(__FILE__) . '/trackactivity.php';
?>




<div class="container">
<div class="row">
<h3>DataMed Advanced Search Builder</h3>
</div>

<div style="margin-top: 30px">
<form action='./search.php' method='get' autocomplete='off' id="search-form">
<?php include dirname(__FILE__) . '/views/advanced/builder.php'; ?>
</form>
</div>

</div>

<?php
/* Page Custom Scripts. */
$scripts = ["./js/page.scripts/advanced.js"];
?>


<?php include dirname(__FILE__) . '/views/footer.php'; ?>

112 changes: 112 additions & 0 deletions ajax/SearchSuggestionService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

require_once dirname(__FILE__) . '/../config/datasources.php';
require_once dirname(__FILE__) . '/../search/Repositories.php';
require_once dirname(__FILE__) . '/../search/ElasticSearch.php';

$query = filter_input(INPUT_GET, "query", FILTER_SANITIZE_STRING);
if (is_ajax() && isset($query)) {
$total_num = 0;
$repositoryObj = new Repositories();

$search_repository = new ElasticSearch();
$search_repository->search_fields = $repositoryObj->getSearchFields();
$search_repository->facets_fields = ['_index'];
$search_repository->facet_size = 20;
$search_repository->query = $query;
$search_repository->filter_fields = [];
$search_repository->es_index = getElasticSearchIndexes();
$search_repository->es_type = '';
$esResults= $search_repository->getSearchResult();
$repositories_counts = [];

foreach ($esResults['aggregations']['_index']['buckets'] as $bucket) {
$key = explode('_', $bucket['key'])[0];
$repositories_counts[$key] = $bucket['doc_count'];
}

foreach ($repositoryObj->getRepositories() as $repository) {

/*$search_repository = new ElasticSearch();
$search_repository->search_fields = $repository->search_fields;
$search_repository->facets_fields = $repository->facets_fields;
$search_repository->query = $query;
$search_repository->filter_fields = [];
$search_repository->es_index = $repository->index;
$search_repository->es_type = $repository->type;
$result = $search_repository->getSearchResult();
$repository->num = $result['hits']['total'];
*/
if(array_key_exists($repository->index,$repositories_counts)) {
$repository->num = $repositories_counts[$repository->index];
}
else {
$repository->num = 0;
}
// $total_num = $total_num + $repository->num;
}

$elasticSearchIndexes = '';
$mappings = getDatatypesMapping();
foreach ($mappings as $index) {
if (is_array($index)) {
foreach ($index as $item) {
$elasticSearchIndexes .= $item . ',';
}
} else {
$elasticSearchIndexes .= $index . ',';
}
}
$indexes = substr($elasticSearchIndexes, 0, -1);

/* $search_all_repository = new ElasticSearch();
$search_all_repository->search_fields = $repositoryObj->getSearchFields();
$search_all_repository->facets_fields = $repository->facets_fields;
$search_all_repository->query = $query;
$search_all_repository->filter_fields = [];
$search_all_repository->es_index = $indexes;
$search_all_repository->es_type = '';
$all_result = $search_all_repository->getSearchResult();
$total_num = $all_result['hits']['total'];
$all_items = $all_result['hits']['hits'];*/
$total_num = $esResults['hits']['total'];

$all_items = $esResults['hits']['hits'];
// For datasets href
$href = '"search.php?query=' . $query . '"';
$all_num = '(' . ($total_num) . ')';
$result_href = '';

// Caculate each datatypes item number
$datatypes_num = [];
foreach (getDatatypes() as $datatype) {

$dataindex = $mappings[$datatype];

$c = 0;
foreach ($repositoryObj->getRepositories() as $repository) {

if (is_array($dataindex)) {
foreach ($dataindex as $item) {
if ($repository->index == $item) {
$c = $c + $repository->num;
}
}
} else {
if ($repository->index == $dataindex) {
$c = $c + $repository->num;
}
}
}
$datatypes_num[$datatype] = $c;
}
$fianlResult = array('repository' => $repositoryObj->getRepositories(), 'datatypes' => $datatypes_num);
echo json_encode($fianlResult);
}

// Function to check if the request is an AJAX request
function is_ajax() {
return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}

24 changes: 24 additions & 0 deletions ajax/deletesearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

require_once '../dbcontroller.php';
require_once '../database/Search.php';

if (session_status() == PHP_SESSION_NONE) {
session_start();
}

$objDBController = new DBController();
$dbconn=$objDBController->getConn();
$search = new Search();


if(!empty($_POST['query'])) {

foreach($_POST['query'] as $check) {
$search->setSearchId($check);
if($search->deleteSearch($dbconn)){
echo "ok";
}
//echo $check;
}
}
26 changes: 26 additions & 0 deletions ajax/savesearch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require_once '../dbcontroller.php';
require_once '../database/Search.php';
require_once '../config/config.php';

$objDBController = new DBController();
$dbconn=$objDBController->getConn();
$search = new Search();

if(!empty($_POST['query'])) {

foreach($_POST['query'] as $check) {

$search->setDate(explode("|",$check)[2]);
$search->setSearchTerm(explode("|",$check)[0]);
$search->setSearchType(explode("|",$check)[1]);
$search->setUemail($_SESSION['email']);


if($search->saveSearch($dbconn)){
echo "ok";
}
}
}

26 changes: 26 additions & 0 deletions ajax/studyconsent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* Created by PhpStorm.
* User: rliu1
* Date: 3/8/16
* Time: 1:00 PM
*/
require_once '../dbcontroller.php';
require_once '../config/config.php';
require_once '../database/StudyConsent.php';
date_default_timezone_set('America/Chicago');

$objDBController = new DBController();
$dbconn=$objDBController->getConn();
$consent = new StudyConsent();

if(!empty($_POST['email'])) {
$consent->setEmail($_POST['email']);
$consent->setConsent(1);
$consent->setConsentTime(date("Y-m-d H:i:s"));
$consent->setUsername($_SESSION['email']);

if($consent->saveConsent($dbconn)){
echo "ok";
}
}
Loading

0 comments on commit 1d8bf0e

Please sign in to comment.