$divs = array(); database_connect(IL_DATABASE_PATH, 'library'); $query = join(",", $display_files); $result = $dbHandle->query("SELECT id,file,title FROM library WHERE id IN (" . $query . ")"); $dbHandle = null; $result = $result->fetchAll(PDO::FETCH_ASSOC); //SORT QUERY RESULTS $tempresult = array(); foreach ($result as $row) { $key = array_search($row['id'], $export_files); $tempresult[$key] = $row; } ksort($tempresult); $result = $tempresult; foreach ($result as $item) { $divs[] = '<div id="list-item-' . $item['id'] . '" data-id="' . $item['id'] . '" data-file="' . $item['file'] . '" class="items listleft">' . lib_htmlspecialchars($item['title']) . '</div>'; } $result = null; $hr = '<div class="separator"></div>'; print join($hr, $divs); if ($offset < count($export_files) - 20) { print '<button id="nav-next" data-id="' . $export_files[$offset + 20] . '"><i class="fa fa-caret-down"></i></button>'; } ?> </div> <div class="alternating_row middle-panel" style="float:left;width:6px;height:100%;overflow:hidden;border-right:1px solid rgba(0,0,0,0.2);border-left:1px solid rgba(0,0,0,0.2);cursor:pointer"> <i class="fa fa-caret-left" style="position:relative;left:1px;top:48%"></i> </div> <div style="width:auto;height:100%;overflow:hidden" id="items-right" data-file="<?php echo $_GET['file'];
empty($_POST['custom1']) ? $custom1 = '' : ($custom1 = trim($_POST['custom1'])); empty($_POST['custom2']) ? $custom2 = '' : ($custom2 = trim($_POST['custom2'])); empty($_POST['custom3']) ? $custom3 = '' : ($custom3 = trim($_POST['custom3'])); empty($_POST['custom4']) ? $custom4 = '' : ($custom4 = trim($_POST['custom4'])); empty($_POST['bibtex']) ? $bibtex = '' : ($bibtex = trim($_POST['bibtex'])); empty($_POST['bibtex_type']) ? $bibtex_type = '' : ($bibtex_type = trim($_POST['bibtex_type'])); if (!empty($title)) { $database_update = $stmt->execute(); } if ($database_update == false) { $error = "Error! The database has not been updated."; } $stmt = null; $dbHandle = null; if (empty($error)) { die('title:' . lib_htmlspecialchars($title)); } } elseif (isset($_POST['form_sent'])) { $error = 'Error! Title is mandatory.'; } if (!empty($error)) { die($error); } ########## read reference data ########## database_connect(IL_DATABASE_PATH, 'library'); $file_query = $dbHandle->quote($_GET['file']); $record = $dbHandle->query("SELECT * FROM library WHERE id={$file_query} LIMIT 1"); $paper = $record->fetch(PDO::FETCH_ASSOC); $paper_urls = array(); if (!empty($paper['url'])) { $paper_urls = explode('|', $paper['url']);
function show_search_results($result, $select, $display, $shelf_files, $desktop_projects, $tempdbHandle) { $project = ''; if (!empty($_GET['project'])) { $project = $_GET['project']; } $i = 0; if ($display == 'icons') { print '<table cellspacing=0 id="icon-container" style="border:0;width:100%"> <tr><td class="alternating_row" style="width:100%;border-bottom:1px #c5c6c8 solid;border-top:1px #c5c6c8 solid;padding-bottom:11px">'; } while (list($key, $paper) = each($result)) { $pmid_url = ''; $pmcid_url = ''; $nasaads_url = ''; $arxiv_url = ''; $jstor_url = ''; $other_urls = ''; $urls = ''; $other_urls = ''; $uids = array(); $pmid = ''; $pmid_related_url = ''; $pmid_citedby_pmc = ''; $nasaid = ''; $nasa_related_url = ''; $nasa_citedby_pmc = ''; $ieeeid = ''; if (!empty($paper['uid'])) { $uids = explode("|", $paper['uid']); while (list($key, $uid) = each($uids)) { if (preg_match('/PMID:/', $uid)) { $pmid = preg_replace('/PMID:/', '', $uid); } if (preg_match('/NASAADS:/', $uid)) { $nasaid = preg_replace('/NASAADS:/', '', $uid); } if (preg_match('/IEEE:/', $uid)) { $ieeeid = preg_replace('/IEEE:/', '', $uid); } } } if (!empty($paper['url'])) { $urls = explode("|", $paper['url']); while (list($key, $url) = each($urls)) { if (preg_match('/pubmed\\.org/', $url)) { $pmid_url = $url; } elseif (preg_match('/pubmedcentral\\.nih\\.gov/', $url) || preg_match('/\\/pmc\\//', $url)) { $pmcid_url = $url; } elseif (preg_match('/adsabs\\.harvard\\.edu/', $url)) { $nasaads_url = $url; } elseif (preg_match('/arxiv\\.org/', $url)) { $arxiv_url = $url; } elseif (preg_match('/jstor\\.org/', $url)) { $jstor_url = $url; } else { $other_urls[] = $url; } } } if (!empty($pmid)) { $pmid_related_url = 'http://www.ncbi.nlm.nih.gov/sites/entrez?db=pubmed&cmd=link&linkname=pubmed_pubmed&uid=' . $pmid; $pmid_citedby_pmc = 'http://www.ncbi.nlm.nih.gov/pubmed?db=pubmed&cmd=link&linkname=pubmed_pubmed_citedin&uid=' . $pmid; } if (!empty($nasaid)) { $nasa_related_url = 'http://adsabs.harvard.edu/cgi-bin/nph-abs_connect?return_req=no_params&text=' . urlencode($paper['abstract']) . '&title=' . urlencode($paper['title']); $nasa_citedby_pmc = 'http://adsabs.harvard.edu/cgi-bin/nph-data_query?bibcode=' . $nasaid . '&link_type=CITATIONS'; } if (!empty($ieeeid)) { $ieee_url = 'http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=' . $ieeeid; } if (!empty($paper['authors'])) { $array = array(); $new_authors = array(); $array = explode(';', $paper['authors']); $array = array_filter($array); if (!empty($array)) { foreach ($array as $author) { $array2 = explode(',', $author); $last = trim($array2[0]); $last = substr($array2[0], 3, -1); $first = trim($array2[1]); $first = substr($array2[1], 3, -1); $new_authors[] = '<a href="display.php?select=' . $select . '&browse[' . urlencode($last . ', ' . $first) . ']=authors" class="navigation">' . htmlspecialchars($last . ', ' . $first) . '</a>'; } $paper['authors'] = join('; ', $new_authors); } } $paper['journal'] = htmlspecialchars($paper['journal']); $paper['title'] = lib_htmlspecialchars($paper['title']); $paper['abstract'] = lib_htmlspecialchars($paper['abstract']); $paper['year'] = htmlspecialchars($paper['year']); #######new date######### $date = ''; if (!empty($paper['year'])) { $date_array = array(); $date_array = explode('-', $paper['year']); if (count($date_array) == 1) { $date = $paper['year']; } else { if (empty($date_array[0])) { $date_array[0] = '1969'; } if (empty($date_array[1])) { $date_array[1] = '01'; } if (empty($date_array[2])) { $date_array[2] = '01'; } $date = date('Y M j', mktime(0, 0, 0, $date_array[1], $date_array[2], $date_array[0])); } } $result2 = $tempdbHandle->query("SELECT notesID,notes FROM temp_notes WHERE fileID=" . intval($paper['id']) . " LIMIT 1"); $fetched = $result2->fetch(PDO::FETCH_ASSOC); $result2 = null; $paper['notesID'] = $fetched['notesID']; $paper['notes'] = $fetched['notes']; $i = $i + 1; if ($display == 'icons') { if (!extension_loaded('gd')) { die('<p> Error! Icon view requires GD extension and Ghostscript.</p>'); } $first_author = ' '; $auth_arr = explode(';', $paper['authors']); $auth_arr2 = explode(',', strip_tags($auth_arr[0])); if (!empty($auth_arr2[0])) { $first_author = $auth_arr2[0]; } $etal = ''; if (count($auth_arr) > 1) { $etal = ', et al.'; } print '<div class="thumb-items" id="display-item-' . $paper['id'] . '" data-file="' . $paper['file'] . '"><div>'; print '<div class="thumb-titles"><div style="overflow:hidden;white-space:nowrap"><b>' . $paper['title'] . '</b><br>' . $first_author . $etal; if (!empty($paper['year'])) { print ' (' . substr($paper['year'], 0, 4) . ')'; } print '</div></div>'; if (date('Y-m-d') == $paper['addition_date']) { print '<div class="new-item ui-state-error-text">New!</div>'; } if (is_readable('library/' . $paper['file'])) { if (isset($_SESSION['pdfviewer']) && $_SESSION['pdfviewer'] == 'external') { print '<a href="' . htmlspecialchars('downloadpdf.php?file=' . urlencode($paper['file']) . '#pagemode=none&scrollbar=1&navpanes=0&toolbar=1&statusbar=0&page=1&view=FitH,0') . '" target="_blank" style="display:block">'; } if (!isset($_SESSION['pdfviewer']) || isset($_SESSION['pdfviewer']) && $_SESSION['pdfviewer'] == 'internal') { print '<a href="' . htmlspecialchars('viewpdf.php?file=' . urlencode($paper['file']) . '&title=' . urlencode($paper['title'])) . '" target="_blank" style="width:360px;height:240px;display:block">'; } print '<img src="icon.php?file=' . $paper['file'] . '" style="width:360px;height:240px;border:0" alt="Loading PDF..."></a>'; } else { print '<div style="margin-top:90px;margin-left:150px;font-size:18px;color:#b5b6b8">No PDF</div>'; } print '</div>'; print PHP_EOL . '<table class="item-sticker" style="margin:6px 0;width:100%"><tr><td class="noprint ui-corner-all" style="padding:5px 8px;border:1px solid #c5c6c8">'; print '<i class="fa fa-plus-circle expander view-icon" style="margin-right:0.5em"></i>'; print '<span><i class="star ' . ($paper['rating'] >= 1 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i>'; print ' <i class="star ' . ($paper['rating'] >= 2 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i>'; print ' <i class="star ' . ($paper['rating'] == 3 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i></span> '; print '<b style="margin:0 0.5em">·</b>'; if (isset($shelf_files) && in_array($paper['id'], $shelf_files)) { print ' <span class="update_shelf clicked"><i class="update_shelf fa fa-check-square ui-state-error-text"></i> Shelf </span>'; } else { print ' <span class="update_shelf"><i class="update_shelf fa fa-square-o"></i> Shelf </span>'; } if (isset($_SESSION['session_clipboard']) && in_array($paper['id'], $_SESSION['session_clipboard'])) { print ' <span class="update_clipboard clicked"><i class="update_clipboard fa fa-check-square ui-state-error-text"></i> Clipboard </span>'; } else { print ' <span class="update_clipboard"><i class="update_clipboard fa fa-square-o"></i> Clipboard </span>'; } foreach ($desktop_projects as $desktop_project) { $project_rowid = $tempdbHandle->query("SELECT ROWID FROM temp_projects WHERE projectID=" . intval($desktop_project['projectID']) . " AND fileID=" . intval($paper['id']) . " LIMIT 1"); $project_rowid = $project_rowid->fetchColumn(); if (!empty($project_rowid)) { print ' <span data-projid="' . $desktop_project['projectID'] . '" class="update_project clicked" style="white-space:nowrap;padding-right:0.5em"><i class="update_project fa fa-check-square ui-state-error-text"></i> ' . htmlspecialchars($desktop_project['project']) . '</span>'; } if (empty($project_rowid)) { print ' <span data-projid="' . $desktop_project['projectID'] . '" class="update_project" style="white-space:nowrap;padding-right:0.5em"><i class="update_project fa fa-square-o"></i> ' . htmlspecialchars($desktop_project['project']) . '</span>'; } $project_rowid = null; } print PHP_EOL . '</td></tr></table></div>'; } else { print PHP_EOL . '<div id="display-item-' . $paper['id'] . '" class="items" data-file="' . $paper['file'] . '" style="padding:0 0 10px 0">'; include 'coins.php'; print '<div class="ui-widget-header" style="overflow:hidden;border-left:0;border-right:0;padding:2px 6px">'; if (is_file('library/' . $paper['file']) && isset($_SESSION['auth'])) { if (isset($_SESSION['pdfviewer']) && $_SESSION['pdfviewer'] == 'external') { print '<div class="noprint titles-pdf" style="float:left;text-shadow:1px 1px 1px white"> <a class="ui-state-error-text" href="' . htmlspecialchars('downloadpdf.php?file=' . urlencode($paper['file']) . '#pagemode=none&scrollbar=1&navpanes=0&toolbar=1&statusbar=0&page=1&view=FitH,0') . '" target="_blank" style="display:block"> PDF</a></div>'; } if (!isset($_SESSION['pdfviewer']) || isset($_SESSION['pdfviewer']) && $_SESSION['pdfviewer'] == 'internal') { print '<div class="noprint titles-pdf" style="float:left;text-shadow:1px 1px 1px white"> <a class="ui-state-error-text" href="' . htmlspecialchars('viewpdf.php?file=' . urlencode($paper['file']) . '&title=' . urlencode($paper['title'])) . '" target="_blank" style="display:block"> PDF</a></div>'; } } else { print PHP_EOL . '<div class="ui-state-error-text noprint titles-pdf" style="float:left;color:#c5c6c8;cursor:auto">PDF</div>'; } print PHP_EOL . '<div class="titles brief">' . $paper['title'] . '</div>'; print '</div>'; print '<div style="clear:both"></div>'; print '<table class="noprint"><tr><td style="width:24px;padding-top:8px;padding-left:12px">'; if ($display != 'abstract') { print PHP_EOL . '<i class="expander fa fa-plus-circle view-' . $display . '"></i>'; } print '</td><td style="padding-top:8px">'; if (isset($shelf_files) && in_array($paper['id'], $shelf_files)) { print '<span class="update_shelf clicked"><i class="update_shelf fa fa-check-square ui-state-error-text"></i> Shelf </span>'; } else { print '<span class="update_shelf"><i class="update_shelf fa fa-square-o"></i> Shelf </span>'; } if (isset($_SESSION['session_clipboard']) && in_array($paper['id'], $_SESSION['session_clipboard'])) { print ' <span class="update_clipboard clicked"><i class="update_clipboard fa fa-check-square ui-state-error-text"></i> Clipboard </span>'; } else { print ' <span class="update_clipboard"><i class="update_clipboard fa fa-square-o"></i> Clipboard </span>'; } foreach ($desktop_projects as $desktop_project) { $project_rowid = $tempdbHandle->query("SELECT ROWID FROM temp_projects WHERE projectID=" . intval($desktop_project['projectID']) . " AND fileID=" . intval($paper['id']) . " LIMIT 1"); $project_rowid = $project_rowid->fetchColumn(); if (!empty($project_rowid)) { print ' <span data-projid="' . $desktop_project['projectID'] . '" class="update_project clicked" style="white-space:nowrap;padding-right:0.5em"><i class="update_project fa fa-check-square ui-state-error-text"></i> ' . htmlspecialchars($desktop_project['project']) . '</span>'; } if (empty($project_rowid)) { print ' <span data-projid="' . $desktop_project['projectID'] . '" class="update_project" style="white-space:nowrap;padding-right:0.5em"><i class="update_project fa fa-square-o"></i> ' . htmlspecialchars($desktop_project['project']) . '</span>'; } $project_rowid = null; } print PHP_EOL . '</td></tr></table>'; print PHP_EOL . '<div class="display-summary" style="margin:0 30px;'; print $display == 'brief' ? 'display:none">' : '">'; if (!empty($paper['authors'])) { print PHP_EOL . '<div class="authors"><i class="author_expander fa fa-plus-circle"></i> ' . $paper['authors'] . '</div>'; } print !empty($paper['journal']) ? $paper['journal'] : $paper['secondary_title']; print !empty($date) ? ' (' . htmlspecialchars($date) . ')' : ''; if (!empty($paper['volume'])) { print ' <b>' . htmlspecialchars($paper['volume']) . '</b>'; } if (!empty($paper['pages'])) { print ': ' . htmlspecialchars($paper['pages']); } if (date('Y-m-d') == $paper['addition_date']) { $today = ' <span class="ui-state-error-text"><b>New!</b></span>'; } else { $today = ''; } $result2 = $tempdbHandle->query("SELECT categoryID,category FROM temp_categories WHERE fileID=" . intval($paper['id']) . " ORDER BY category COLLATE NOCASE ASC"); while ($categories = $result2->fetch(PDO::FETCH_ASSOC)) { $category_array[] = '<a href="' . htmlspecialchars('display.php?browse[' . urlencode($categories['categoryID']) . ']=category&select=' . $select . '&project=' . $project) . '" class="navigation">' . htmlspecialchars($categories['category']) . '</a>'; } if (empty($category_array[0])) { $category_array[0] = '<a href="' . htmlspecialchars('display.php?browse[0]=category&select=' . $select) . '" class="navigation">!unassigned</a>'; } print '<br><span><i class="star ' . ($paper['rating'] >= 1 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i>'; print ' <i class="star ' . ($paper['rating'] >= 2 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i>'; print ' <i class="star ' . ($paper['rating'] == 3 ? 'ui-state-error-text' : 'ui-priority-secondary') . ' fa fa-star"></i></span> '; print '<b style="margin:0 0.5em">·</b>'; if (!empty($paper['bibtex'])) { print htmlspecialchars($paper['bibtex']); } else { $bibtex_author = strip_tags($paper['authors']); $bibtex_author = substr($bibtex_author, 0, strpos($bibtex_author, ',')); if (empty($bibtex_author)) { $bibtex_author = 'unknown'; } $bibtex_year = '0000'; $bibtex_year_array = explode('-', $paper['year']); if (!empty($bibtex_year_array[0])) { $bibtex_year = $bibtex_year_array[0]; } $bibtex_key = utf8_deaccent($bibtex_author) . '-' . $bibtex_year . '-ID' . $paper['id']; print htmlspecialchars($bibtex_key); } print '<b style="margin:0 0.5em">·</b>'; print 'Category: '; $category_string = join(", ", $category_array); $category_array = null; print $category_string; print '<b style="margin:0 0.5em">·</b> Added: <a href="display.php?select=' . $select . '&browse[' . $paper['addition_date'] . ']=addition_date" class="navigation">' . date('M jS, Y', strtotime($paper['addition_date'])) . '</a>' . $today; print '<div class="noprint display-abstract"'; print $display != 'abstract' ? ' style="display:none"' : ''; print '>'; if (!empty($pmid_url)) { print '<a href="' . htmlspecialchars($pmid_url) . '" target="_blank">PubMed</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($pmid_related_url)) { print '<a href="' . htmlspecialchars($pmid_related_url) . '" target="_blank">Related Articles</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($pmid_citedby_pmc)) { print '<a href="' . htmlspecialchars($pmid_citedby_pmc) . '" target="_blank">Cited by</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($pmcid_url)) { print '<a href="' . htmlspecialchars($pmcid_url) . '" target="_blank">PubMed Central</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($nasaads_url)) { print '<a href="' . htmlspecialchars($nasaads_url) . '" target="_blank">NASA ADS</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($nasa_related_url)) { print '<a href="' . htmlspecialchars($nasa_related_url) . '" target="_blank">Related Articles</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($nasa_citedby_pmc)) { print '<a href="' . htmlspecialchars($nasa_citedby_pmc) . '" target="_blank">Cited by</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($arxiv_url)) { print '<a href="' . htmlspecialchars($arxiv_url) . '" target="_blank">arXiv</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($jstor_url)) { print '<a href="' . htmlspecialchars($jstor_url) . '" target="_blank">JSTOR</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($ieee_url)) { print '<a href="' . htmlspecialchars($ieee_url) . '" target="_blank">IEEE</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($paper['doi'])) { print '<a href="' . htmlspecialchars('http://dx.doi.org/' . urlencode($paper['doi'])) . '" target="_blank">Publisher Website</a> <b style="margin:0 0.5em">·</b> '; } if (!empty($other_urls)) { foreach ($other_urls as $another_url) { print '<a href="' . htmlspecialchars($another_url) . '" target="_blank" class="anotherurl" title="' . htmlspecialchars(parse_url($another_url, PHP_URL_HOST)) . '">Link</a> <b style="margin:0 0.5em">·</b> '; } } print '<a href="stable.php?id=' . $paper['id'] . '" target="_blank">Stable Link</a>'; print '</div>'; print '<div class="abstract display-abstract" style="'; print $display != 'abstract' ? 'display:none' : ''; print '">' . $paper['abstract'] . '</div>'; print '<div class="display-abstract" style="'; print $display != 'abstract' ? 'display:none' : ''; print '">'; if (!empty($paper['notes'])) { print '<div class="item-sticker ui-widget-content ui-corner-all" style="margin:6px;width:340px;float:left"> <div class="ui-widget-header items ui-corner-top" style="border:0"><b class="ui-dialog-titlebar">Notes</b></div><div class="separator" style="margin:0"></div> <div class="alternating_row ui-corner-bottom" style="padding:4px 7px;max-height:200px;overflow:auto">' . $paper['notes'] . ' </div></div>'; } if (is_file(graphical_abstract($paper['file']))) { print '<div class="item-sticker ui-widget-content ui-corner-all" style="margin:6px;width:340px;float:left"> <div class="ui-widget-header items ui-corner-top" style="border:0"><b class="ui-dialog-titlebar">Graphical Abstract</b></div><div class="separator" style="margin:0"></div> <div class="alternating_row ui-corner-bottom" style="padding:4px 7px;max-height:200px;overflow:auto"> <img src="' . htmlspecialchars('attachment.php?mode=inline&attachment=' . basename(graphical_abstract($paper['file']))) . '"> </div></div>'; } print '</div></div></div>'; } } if ($display == 'icons') { print '</td></tr></table>'; } }
$_GET['select'] = 'library'; } $select = $_GET['select']; } else { $select = 'library'; } if (isset($_GET['file'])) { $query = $dbHandle->quote($_GET['file']); if (!isset($paper)) { $result = $dbHandle->query("SELECT * FROM library WHERE id={$query} LIMIT 1"); $paper = $result->fetch(PDO::FETCH_ASSOC); } if (!empty($paper['id'])) { $paper['journal'] = htmlspecialchars($paper['journal']); $paper['title'] = lib_htmlspecialchars($paper['title']); $paper['abstract'] = lib_htmlspecialchars($paper['abstract']); $paper['year'] = htmlspecialchars($paper['year']); #######new date######### $date = ''; if (!empty($paper['year'])) { $date_array = array(); $date_array = explode('-', $paper['year']); if (count($date_array) == 1) { $date = $paper['year']; } else { if (empty($date_array[0])) { $date_array[0] = '1969'; } if (empty($date_array[1])) { $date_array[1] = '01'; }