Commit 673e1d53 authored by Romain Loth's avatar Romain Loth

tidy up php before changes

factorize access to local static files and fix imagestar function, stash unused archeology of script variants for future decision to clean or integrate
parent 0fe18527
<?php
header('Content-Type: application/json');
include("DirectoryScanner.php");
$projectFolderPat = dirname(dirname(getcwd())) . "/";
$instance = new scanTree($projectFolderPat);
$instance->getDirectoryTree("data");
//pr(var_dump($instance->folders));
$output = array();
$output["folders"] = $instance->folders;
$output["gexf_idfolder"] = $instance->gexf_folder;
echo json_encode($output);
// ** Debug Functions: **
function br() {
echo "----------<br>";
}
function pr($msg) {
echo $msg . "<br>";
}
?>
<?php
echo 'toto';
?>
\ No newline at end of file
...@@ -11,9 +11,6 @@ $table = ""; ...@@ -11,9 +11,6 @@ $table = "";
$column = ""; $column = "";
$id=""; $id="";
// $twjs=end( explode("/",getcwd()) )."/"; // LOCALDB folder.
$twjs="LOCALDB/"; // LOCALDB folder.
// echo("count(elems): ".count($elems)."<br/>"); // echo("count(elems): ".count($elems)."<br/>");
// echo("elems[0]: ".$elems[0]."<br/>"); // echo("elems[0]: ".$elems[0]."<br/>");
// echo("is_array($elems): ".is_array($elems)."<br/>"); // echo("is_array($elems): ".is_array($elems)."<br/>");
...@@ -34,7 +31,6 @@ if($ndtype=="semantic"){ ...@@ -34,7 +31,6 @@ if($ndtype=="semantic"){
$factor=10; $factor=10;
} }
$restriction=''; $restriction='';
$factor=10;
$sql=""; $sql="";
////////// //////////
...@@ -113,11 +109,10 @@ foreach ($wos_ids as $id => $score) { ...@@ -113,11 +109,10 @@ foreach ($wos_ids as $id => $score) {
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data'; $sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$external_link="<a href=http://google.com/webhp?#q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=15px src="twlibs/img/google.png"></a>'; $external_link="<a href=http://google.com/webhp?#q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=15px src="'.$our_libs_root.'/img/google.png"></a>';
$output.="<li title='".$score."'>"; $output.="<li title='".$score."'>";
$output.=$external_link.imagestar($score,$factor,$twjs).' '; $output.=$external_link.imagestar($score,$factor,$our_libs_root).' ';
$output.='<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details.php?gexf='.urlencode($gexf).'&index='.$table.'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.$row['data']." </a> "; $output.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?gexf='.urlencode($gexf).'&index='.$table.'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.$row['data']." </a> ";
// echo '<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details.php?gexf='.urlencode($gexf).'&index='.$table.'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.$row['data']." </a> ";
} }
// get the authors /!\ hardcoded CortextDB table /!\ // get the authors /!\ hardcoded CortextDB table /!\
...@@ -196,7 +191,7 @@ $output .= "</ul>"; ##### ...@@ -196,7 +191,7 @@ $output .= "</ul>"; #####
// // $sql2='SELECT ISIpubdate.id,ISIC1_1.data from ISIpubdate,ISIC1_1 where ISIC1_1.data="'.$row['data'].'" AND ISIpubdate.id=ISIC1_1.id AND ISIpubdate.data="2013" limit 1'; // // $sql2='SELECT ISIpubdate.id,ISIC1_1.data from ISIpubdate,ISIC1_1 where ISIC1_1.data="'.$row['data'].'" AND ISIpubdate.id=ISIC1_1.id AND ISIpubdate.data="2013" limit 1';
// // //echo $sql2; // // //echo $sql2;
// // foreach ($corporadb->query($sql2) as $row2){ // // foreach ($corporadb->query($sql2) as $row2){
// // $nov_string.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($graphdb).'&gexf='.urlencode($gexf).'&query='.urlencode('["'.$res[$i].'"]').'&type='.urlencode($_GET["type"]).'&id='.$row2['id'].' \')">'.$res[$i]."</a>, "; // // $nov_string.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?db='.urlencode($graphdb).'&gexf='.urlencode($gexf).'&query='.urlencode('["'.$res[$i].'"]').'&type='.urlencode($_GET["type"]).'&id='.$row2['id'].' \')">'.$res[$i]."</a>, ";
// // } // // }
// // } // // }
// // } // // }
...@@ -215,7 +210,7 @@ $output .= "</ul>"; ##### ...@@ -215,7 +210,7 @@ $output .= "</ul>"; #####
// // $sql2='SELECT ISIpubdate.id,ISIC1_1.data from ISIpubdate,ISIC1_1 where ISIC1_1.data="'.$row['data'].'" AND ISIpubdate.id=ISIC1_1.id AND ISIpubdate.data="2013" limit 1'; // // $sql2='SELECT ISIpubdate.id,ISIC1_1.data from ISIpubdate,ISIC1_1 where ISIC1_1.data="'.$row['data'].'" AND ISIpubdate.id=ISIC1_1.id AND ISIpubdate.data="2013" limit 1';
// // //echo $sql2; // // //echo $sql2;
// // foreach ($corporadb->query($sql2) as $row2){ // // foreach ($corporadb->query($sql2) as $row2){
// // $res_string.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($graphdb).'&gexf='.urlencode($gexf).'&query='.urlencode('["'.$res[$i].'"]').'&type='.urlencode($_GET["type"]).'&id='.$row2['id'].' \')">'.$res[$i]."</a>, "; // // $res_string.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?db='.urlencode($graphdb).'&gexf='.urlencode($gexf).'&query='.urlencode('["'.$res[$i].'"]').'&type='.urlencode($_GET["type"]).'&id='.$row2['id'].' \')">'.$res[$i]."</a>, ";
// // } // // }
// // } // // }
// // } // // }
...@@ -285,22 +280,6 @@ $output .= "</ul>"; ##### ...@@ -285,22 +280,6 @@ $output .= "</ul>"; #####
} }
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="twlibs/img/star.gif" border="0" >';
}
} else {
$star_image.='<img src="twlibs/img/stargrey.gif" border="0">';
}
return $star_image;
}
if($max_item_displayed>$total_count) $max_item_displayed=$total_count; if($max_item_displayed>$total_count) $max_item_displayed=$total_count;
// echo $news.'<br/><h4><font color="#0000FF"> Full text of top '.$max_item_displayed.'/'.$related.' related publications:</font></h4>'.$output; // echo $news.'<br/><h4><font color="#0000FF"> Full text of top '.$max_item_displayed.'/'.$related.' related publications:</font></h4>'.$output;
echo '<br/><h4><font color="#0000FF"> Full text of top '.$max_item_displayed.'/'.$total_count.' related publications:</font></h4>'.$output; echo '<br/><h4><font color="#0000FF"> Full text of top '.$max_item_displayed.'/'.$total_count.' related publications:</font></h4>'.$output;
......
<?php <?php
include('tools.php');
include('parameters_details.php'); include('parameters_details.php');
$db = $gexf_db[$gexf]; $db = $gexf_db[$gexf];
...@@ -18,7 +19,7 @@ echo ' ...@@ -18,7 +19,7 @@ echo '
<link rel="stylesheet" href="js/jquery-ui.css" /> <link rel="stylesheet" href="js/jquery-ui.css" />
<script src="js/jquery-1.9.1.js"></script> <script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script> <script src="js/jquery-ui.js"></script>
<script> <script>
$(function() { $(function() {
$( "#tabs" ).tabs({ $( "#tabs" ).tabs({
...@@ -27,12 +28,12 @@ echo ' ...@@ -27,12 +28,12 @@ echo '
}); });
</script> </script>
</head> </head>
<body> <body>
<div id="tabs"> <div id="tabs">
<ul> <ul>
<li><a href="#tabs-1">Selected Document</a></li> <li><a href="#tabs-1">Selected Document</a></li>
<li><a href="full_doc_list.php?'.'gexf='.urlencode($gexf).'&query='.urlencode($_GET["query"]).'&index='.$_GET["index"].'&type='.urlencode($_GET["type"]).'">Full list</a></li>'; <li><a href="full_doc_list.php?'.'gexf='.urlencode($gexf).'&query='.urlencode($_GET["query"]).'&index='.$_GET["index"].'&type='.urlencode($_GET["type"]).'">Full list</a></li>';
echo '</ul>'; echo '</ul>';
echo '<div id="tabs-1">'; echo '<div id="tabs-1">';
...@@ -43,14 +44,14 @@ $id=$_GET["id"]; ...@@ -43,14 +44,14 @@ $id=$_GET["id"];
// //$elems = json_decode($query); // //$elems = json_decode($query);
// $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id; // $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
// foreach ($base->query($sql) as $row) { // foreach ($base->query($sql) as $row) {
// $country=$CC[strtoupper($row['data'])]; // $country=$CC[strtoupper($row['data'])];
// } // }
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data'; $sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$output.='<h2>'.$row['data'].'</h2>'; $output.='<h2>'.$row['data'].'</h2>';
$find.="<br/><a href=http://google.com/webhp?q=".urlencode('"'.$row['data'].'"')." target='blank'>[ Search on the web ] </a>"; $find.="<br/><a href=http://google.com/webhp?q=".urlencode('"'.$row['data'].'"')." target='blank'>[ Search on the web ] </a>";
} }
...@@ -76,7 +77,7 @@ $id=$_GET["id"]; ...@@ -76,7 +77,7 @@ $id=$_GET["id"];
// $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id; // $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
// foreach ($base->query($sql) as $row) { // foreach ($base->query($sql) as $row) {
// $country=$CC[strtoupper($row['data'])]; // $country=$CC[strtoupper($row['data'])];
// $output.=strtoupper($country).'<br/> '; // $output.=strtoupper($country).'<br/> ';
// } // }
...@@ -118,7 +119,7 @@ $id=$_GET["id"]; ...@@ -118,7 +119,7 @@ $id=$_GET["id"];
$abs.=". ".$row['data']; $abs.=". ".$row['data'];
} }
$abs=str_replace('ISSUES:' ,'<br/><br/><b>Issues:</b>',$abs); $abs=str_replace('ISSUES:' ,'<br/><br/><b>Issues:</b>',$abs);
$abs=str_replace('INTENDED IMPACT:' ,'<br/><br/><b>Intended impact:</b>',$abs); $abs=str_replace('INTENDED IMPACT:' ,'<br/><br/><b>Intended impact:</b>',$abs);
$abs=str_replace('IMPACT:' ,'<br/><br/><b>Impact:</b>',$abs); $abs=str_replace('IMPACT:' ,'<br/><br/><b>Impact:</b>',$abs);
$abs=str_replace('NOVELTY:' ,'<br/><br/><b>Novelty:</b>',$abs); $abs=str_replace('NOVELTY:' ,'<br/><br/><b>Novelty:</b>',$abs);
$abs=str_replace('BOLD INNOVATION:' ,'<br/><br/><b>Bold innovation:</b>',$abs); $abs=str_replace('BOLD INNOVATION:' ,'<br/><br/><b>Bold innovation:</b>',$abs);
...@@ -131,7 +132,7 @@ $id=$_GET["id"]; ...@@ -131,7 +132,7 @@ $id=$_GET["id"];
$abs=str_replace('_x000D_', ' ', $abs); $abs=str_replace('_x000D_', ' ', $abs);
$abs=str_replace('•', ' ', $abs); $abs=str_replace('•', ' ', $abs);
$abs=str_replace('’', '\'', $abs); $abs=str_replace('’', '\'', $abs);
foreach ($terms_of_query as $key => $value) { foreach ($terms_of_query as $key => $value) {
$abs=str_ireplace($value,'<font color="green"><b> '.$value.'</b></font>',$abs); $abs=str_ireplace($value,'<font color="green"><b> '.$value.'</b></font>',$abs);
} }
...@@ -140,7 +141,7 @@ $id=$_GET["id"]; ...@@ -140,7 +141,7 @@ $id=$_GET["id"];
} }
$output.='<br/><p align="justify"><b>Abstract : </b><i>'.$abs.' </i></p>'; $output.='<br/><p align="justify"><b>Abstract : </b><i>'.$abs.' </i></p>';
$output.="<br>"; $output.="<br>";
......
<?php <?php
include('tools.php');
include('parameters_details.php'); include('parameters_details.php');
$db = $gexf_db[$gexf]; $db = $gexf_db[$gexf];
...@@ -6,7 +7,6 @@ $base = new PDO("sqlite:../" .$db); ...@@ -6,7 +7,6 @@ $base = new PDO("sqlite:../" .$db);
$output = "<ul>"; // string sent to the javascript for display $output = "<ul>"; // string sent to the javascript for display
#http://localhost/branch_ademe/php/test.php?type=social&query=[%22marwah,%20m%22]
$type = $_GET["type"]; $type = $_GET["type"];
...@@ -14,7 +14,7 @@ $query = str_replace( '__and__', '&', $_GET["query"] ); ...@@ -14,7 +14,7 @@ $query = str_replace( '__and__', '&', $_GET["query"] );
$terms_of_query=json_decode($_GET["query"]); $terms_of_query=json_decode($_GET["query"]);
$elems = json_decode($query); $elems = json_decode($query);
// nombre d'item dans les tables // nombre d'item dans les tables
$sql='SELECT COUNT(*) FROM ISIABSTRACT'; $sql='SELECT COUNT(*) FROM ISIABSTRACT';
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$table_size=$row['COUNT(*)']; $table_size=$row['COUNT(*)'];
...@@ -23,7 +23,6 @@ foreach ($base->query($sql) as $row) { ...@@ -23,7 +23,6 @@ foreach ($base->query($sql) as $row) {
$table = ""; $table = "";
$column = ""; $column = "";
$id=""; $id="";
$twjs=end( explode("/",getcwd()) )."/"; // LOCALDB folder.
if($type=="social"){ if($type=="social"){
$table = "ISIAUTHOR"; $table = "ISIAUTHOR";
...@@ -63,9 +62,9 @@ $sum=0; ...@@ -63,9 +62,9 @@ $sum=0;
//The final query! //The final query!
// array of all relevant documents with score // array of all relevant documents with score
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
// on pondère le score par le nombre de termes mentionnés par l'article // on pondère le score par le nombre de termes mentionnés par l'article
//$num_rows = $result->numRows(); //$num_rows = $result->numRows();
$wos_ids[$row[$id]] = $row["count(*)"]; $wos_ids[$row[$id]] = $row["count(*)"];
$sum = $row["count(*)"] +$sum; $sum = $row["count(*)"] +$sum;
...@@ -76,7 +75,7 @@ foreach ($base->query($sql) as $row) { ...@@ -76,7 +75,7 @@ foreach ($base->query($sql) as $row) {
$number_doc=ceil(count($wos_ids)/3); $number_doc=ceil(count($wos_ids)/3);
$count=0; $count=0;
foreach ($wos_ids as $id => $score) { foreach ($wos_ids as $id => $score) {
if ($count<1000){ if ($count<1000){
// retrieve publication year // retrieve publication year
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id; $sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
...@@ -85,23 +84,16 @@ foreach ($wos_ids as $id => $score) { ...@@ -85,23 +84,16 @@ foreach ($wos_ids as $id => $score) {
} }
// to filter under some conditions // to filter under some conditions
$to_display=true; $to_display=true;
if ($to_display){ if ($to_display){
$count+=1; $count+=1;
$output.="<li title='".$score."'>"; $output.="<li title='".$score."'>";
$output.=imagestar($score,$factor,$twjs).' '; $output.=imagestar($score,$factor,$our_libs_root).' ';
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id." group by data"; $sql = 'SELECT data FROM ISITITLE WHERE id='.$id." group by data";
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$output.='<a href="default_doc_details.php?gexf='.urlencode($gexf).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> "; $output.='<a href="'.$our_php_root.'/default_doc_details.php?gexf='.urlencode($gexf).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="'.$our_libs_root.'/img/gs.png"></a>';
//this should be the command:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> ";
//the old one:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="twlibs/img/gs.png"></a>';
//$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>';
} }
// get the authors // get the authors
...@@ -110,9 +102,7 @@ foreach ($wos_ids as $id => $score) { ...@@ -110,9 +102,7 @@ foreach ($wos_ids as $id => $score) {
$output.=strtoupper($row['data']).', '; $output.=strtoupper($row['data']).', ';
} }
//<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>' $output.=$external_link."</li><br>";
$output.=$external_link."</li><br>";
} }
}else{ }else{
...@@ -126,21 +116,4 @@ $output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$ou ...@@ -126,21 +116,4 @@ $output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$ou
echo $output; echo $output;
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="twlibs/img/star.gif" border="0" >';
}
} else {
$star_image.='<img src="twlibs/img/stargrey.gif" border="0">';
}
return $star_image;
}
?> ?>
<?php <?php
// default path to ProjectExplorer root
// (where data directory and db.json file reside) // GLOBAL PARAMS
$mainpath=dirname(getcwd())."/../"; // -------------
$ntypes = 2; // 1 - relative urls
$our_php_root="twbackends/phpAPI"; // our php scripts relative URL
$our_libs_root="twbackends/phpAPI"; // for our few icons and jquery-ui
// POSS could be merged with our_php_root
// 2 - paths
$mainpath=dirname(dirname(getcwd()))."/"; // default fs path to ProjectExplorer root
// (where data dir and db.json file reside)
$project_menu_path = "db.json"; $project_menu_path = "db.json";
// 3 - others
$ntypes = 2; // max node types
// number of docs to display setting
$max_item_displayed = 7;
// for csv parsing
$csvsep = "\t";
$csvquote = '"';
// for csv caching (optional)
$memserver = 'localhost';
$memport = 11211;
// CONFIGURATION PARAMS
// --------------------
// reading db.json associations // reading db.json associations
// source graph file <=> (db, dbtype, cols) as relatedDocs php API // source graph file <=> (db, dbtype, cols) as relatedDocs php API
$project_menu_fh = fopen($mainpath.$project_menu_path, "r"); $project_menu_fh = fopen($mainpath.$project_menu_path, "r");
...@@ -69,6 +94,7 @@ foreach ($project_menu as $project_dir => $dir_items){ ...@@ -69,6 +94,7 @@ foreach ($project_menu as $project_dir => $dir_items){
$gexf= str_replace('"','',$_GET["gexf"]); $gexf= str_replace('"','',$_GET["gexf"]);
$ndtype = $_GET["type"]; $ndtype = $_GET["type"];
$ntid = null; $ntid = null;
$my_conf = null;
// legacy types => generic types // legacy types => generic types
if ($ndtype == 'semantic') { $ntid = 0; } if ($ndtype == 'semantic') { $ntid = 0; }
...@@ -84,27 +110,12 @@ else { ...@@ -84,27 +110,12 @@ else {
$graphdb = $my_conf['dir'].'/'.$my_conf['reldbfile']; $graphdb = $my_conf['dir'].'/'.$my_conf['reldbfile'];
} }
echodump("reldb", $graphdb); // echodump("params: reldb", $graphdb);
// echodump("params: node type id", $ntid);
// for csv parsing
$csvsep = "\t";
$csvquote = '"';
// for csv caching (optional)
$memserver = 'localhost';
$memport = 11211;
// number of docs to display setting
$max_item_displayed = 7;
// echodump("graphdb", $graphdb); // echodump("graphdb", $graphdb);
function echodump($title, $anyObj) {
echo "<br>".$title.": ";
echo (preg_replace_callback("/\n(\s*)/", function($capt){
return('<br>'.str_repeat('&nbsp;', strlen($capt[0])));
}, json_encode($anyObj, JSON_PRETTY_PRINT)));
echo "<br>";
}
?> ?>
<?php
function echodump($title, $anyObj) {
echo "<br>".$title.": ";
echo (preg_replace_callback("/\n(\s*)/", function($capt){
return('<br>'.str_repeat('&nbsp;', strlen($capt[0])));
}, json_encode($anyObj, JSON_PRETTY_PRINT)));
echo "<br>";
}
function errmsg($message, $context, $more = "") {
echo "<p class='micromessage'>The relatedDocs DB conf for $context is $message
(please read A-Introduction/servermenu_config.md).<br>$more</p>";
}
function imagestar($score,$factor,$static_libs) {
// produit le html des images de score
$star_image = '';
if ($score > 1) {
$star_image = '';
$yellow_star = '<img src="'.$static_libs.'/img/star.gif" border="0" >';
$grey_star = '<img src="'.$static_libs.'/img/stargrey.gif" border="0">';
$max = 5 * $score / $factor;
for ($s = 0; $s < 5 ; $s++) {
if ($s < $max) {
$star_image.=$yellow_star;
}
else {
$star_image.= $grey_star;
}
}
}
return $star_image;
}
?>
#### Unused functionalities
- `tfidf.php`: compute a tfidf value per term (as pointwise metric for ranking, not similarities) table in Cortext-like databases
- `listFiles.php` + `DirectoryScanner.php`: alternative strategy to navigate between source files (old tina before db.json)
- `favorites.php` : query a favorites table in Cortext-like databases
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
$db= $_GET["db"];//I receive the specific database as string! $db= $_GET["db"];//I receive the specific database as string!
$terms_of_query=json_decode($_GET["query"]); $terms_of_query=json_decode($_GET["query"]);
include('parameters_details.php'); include('parameters_details.php');
include('tools.php');
$base = new PDO("sqlite:" .$mainpath.$db); $base = new PDO("sqlite:" .$mainpath.$db);
$query=$_GET["query"]; $query=$_GET["query"];
$gexf=$_GET["gexf"]; $gexf=$_GET["gexf"];
...@@ -20,7 +21,7 @@ foreach ($base->query($sql) as $row){ ...@@ -20,7 +21,7 @@ foreach ($base->query($sql) as $row){
$favorite_keywords=array(); $favorite_keywords=array();
foreach ($wos_ids as $id => $score) { foreach ($wos_ids as $id => $score) {
if ($count<1000){ if ($count<1000){
// retrieve publication year // retrieve publication year
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id; $sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
...@@ -38,8 +39,8 @@ foreach ($wos_ids as $id => $score) { ...@@ -38,8 +39,8 @@ foreach ($wos_ids as $id => $score) {
}else{ }else{
$favorite_keywords[$row['data']]=1; $favorite_keywords[$row['data']]=1;
} }
} }
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id; $sql = 'SELECT data FROM ISITITLE WHERE id='.$id;
...@@ -47,12 +48,12 @@ foreach ($wos_ids as $id => $score) { ...@@ -47,12 +48,12 @@ foreach ($wos_ids as $id => $score) {
$output.='<a href="default_doc_details.php?db='.urlencode($db).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> "; $output.='<a href="default_doc_details.php?db='.urlencode($db).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> ";
//this should be the command: //this should be the command:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> "; //$output.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> ";
//the old one: //the old one:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> "; //$output.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="img/gs.png"></a>'; $external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="img/gs.png"></a>';
//$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>'; //$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>';
} }
// get the authors // get the authors
...@@ -62,7 +63,7 @@ foreach ($wos_ids as $id => $score) { ...@@ -62,7 +63,7 @@ foreach ($wos_ids as $id => $score) {
} }
if($project_folder!='nci'){ if($project_folder!='nci'){
$output.='('.$pubdate.') '; $output.='('.$pubdate.') ';
}else { }else {
...@@ -73,15 +74,15 @@ foreach ($wos_ids as $id => $score) { ...@@ -73,15 +74,15 @@ foreach ($wos_ids as $id => $score) {
$sql = 'SELECT data FROM ISIkeyword WHERE id='.$id; $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$country=$CC[strtoupper($row['data'])]; $country=$CC[strtoupper($row['data'])];
$output.=strtoupper($country).' '; $output.=strtoupper($country).' ';
} }
//<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>' //<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>'
$output.=$external_link."</li><br>"; $output.=$external_link."</li><br>";
}else{ }else{
continue; continue;
...@@ -106,22 +107,6 @@ foreach ($favorite_keywords as $key => $value) { ...@@ -106,22 +107,6 @@ foreach ($favorite_keywords as $key => $value) {
$output= '<h3>'.$num_favorite.' favorite items </h3>'.$tag_could.'<br/>'.$output; $output= '<h3>'.$num_favorite.' favorite items </h3>'.$tag_could.'<br/>'.$output;
echo $output; echo $output;
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="twlibs/img/star.gif" border="0" >';
}
} else {
$star_image.='<img src="twlibs/img/stargrey.gif" border="0">';
}
return $star_image;
}
?> ?>
### phpAPI old use-case specific variants
They are quasi-identical to info_div.php and full_doc_list.php, kept for future decision to remove or add as conditional behavior.
Apparent use-cases:
- `info_div2.php`: tweetoscope
- `full_doc_list2.php`: pasteur
- `default_doc_details2.php`: pasteur
- `full_doc_list_tidf.php`: ???
<?php <?php
include('tools.php');
include('parameters_details.php'); include('parameters_details.php');
$db = $gexf_db[$gexf]; $db = $gexf_db[$gexf];
...@@ -18,7 +19,7 @@ echo ' ...@@ -18,7 +19,7 @@ echo '
<link rel="stylesheet" href="js/jquery-ui.css" /> <link rel="stylesheet" href="js/jquery-ui.css" />
<script src="js/jquery-1.9.1.js"></script> <script src="js/jquery-1.9.1.js"></script>
<script src="js/jquery-ui.js"></script> <script src="js/jquery-ui.js"></script>
<script> <script>
$(function() { $(function() {
$( "#tabs" ).tabs({ $( "#tabs" ).tabs({
...@@ -27,12 +28,12 @@ echo ' ...@@ -27,12 +28,12 @@ echo '
}); });
</script> </script>
</head> </head>
<body> <body>
<div id="tabs"> <div id="tabs">
<ul> <ul>
<li><a href="#tabs-1">Selected Document</a></li> <li><a href="#tabs-1">Selected Document</a></li>
<li><a href="full_doc_list2.php?'.'gexf='.urlencode($gexf).'&query='.urlencode($_GET["query"]).'&type='.urlencode($_GET["type"]).'">Full list</a></li>'; <li><a href="full_doc_list2.php?'.'gexf='.urlencode($gexf).'&query='.urlencode($_GET["query"]).'&type='.urlencode($_GET["type"]).'">Full list</a></li>';
echo '</ul>'; echo '</ul>';
echo '<div id="tabs-1">'; echo '<div id="tabs-1">';
...@@ -43,7 +44,7 @@ $id=$_GET["id"]; ...@@ -43,7 +44,7 @@ $id=$_GET["id"];
// //$elems = json_decode($query); // //$elems = json_decode($query);
// $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id; // $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
// foreach ($base->query($sql) as $row) { // foreach ($base->query($sql) as $row) {
// $country=$CC[strtoupper($row['data'])]; // $country=$CC[strtoupper($row['data'])];
// } // }
...@@ -59,7 +60,7 @@ $id=$_GET["id"]; ...@@ -59,7 +60,7 @@ $id=$_GET["id"];
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$output.='<h2>'.$row['data'].'</h2>'; $output.='<h2>'.$row['data'].'</h2>';
$find.="<br/><a href=http://google.com/webhp?q=".urlencode('"'.$row['data'].'"')." target='blank'>[ Search on the web ] </a>"; $find.="<br/><a href=http://google.com/webhp?q=".urlencode('"'.$row['data'].'"')." target='blank'>[ Search on the web ] </a>";
} }
...@@ -77,13 +78,13 @@ $id=$_GET["id"]; ...@@ -77,13 +78,13 @@ $id=$_GET["id"];
$output.=' (2014) '; $output.=' (2014) ';
// // get the country // // get the country
// $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id; // $sql = 'SELECT data FROM ISIkeyword WHERE id='.$id;
// foreach ($base->query($sql) as $row) { // foreach ($base->query($sql) as $row) {
// $country=$CC[strtoupper($row['data'])]; // $country=$CC[strtoupper($row['data'])];
// $output.=strtoupper($country).'<br/> '; // $output.=strtoupper($country).'<br/> ';
// } // }
...@@ -125,7 +126,7 @@ $id=$_GET["id"]; ...@@ -125,7 +126,7 @@ $id=$_GET["id"];
$abs.=". ".$row['data']; $abs.=". ".$row['data'];
} }
$abs=str_replace('ISSUES:' ,'<br/><br/><b>Issues:</b>',$abs); $abs=str_replace('ISSUES:' ,'<br/><br/><b>Issues:</b>',$abs);
$abs=str_replace('INTENDED IMPACT:' ,'<br/><br/><b>Intended impact:</b>',$abs); $abs=str_replace('INTENDED IMPACT:' ,'<br/><br/><b>Intended impact:</b>',$abs);
$abs=str_replace('IMPACT:' ,'<br/><br/><b>Impact:</b>',$abs); $abs=str_replace('IMPACT:' ,'<br/><br/><b>Impact:</b>',$abs);
$abs=str_replace('NOVELTY:' ,'<br/><br/><b>Novelty:</b>',$abs); $abs=str_replace('NOVELTY:' ,'<br/><br/><b>Novelty:</b>',$abs);
$abs=str_replace('BOLD INNOVATION:' ,'<br/><br/><b>Bold innovation:</b>',$abs); $abs=str_replace('BOLD INNOVATION:' ,'<br/><br/><b>Bold innovation:</b>',$abs);
...@@ -138,7 +139,7 @@ $id=$_GET["id"]; ...@@ -138,7 +139,7 @@ $id=$_GET["id"];
$abs=str_replace('_x000D_', ' ', $abs); $abs=str_replace('_x000D_', ' ', $abs);
$abs=str_replace('•', ' ', $abs); $abs=str_replace('•', ' ', $abs);
$abs=str_replace('’', '\'', $abs); $abs=str_replace('’', '\'', $abs);
foreach ($terms_of_query as $key => $value) { foreach ($terms_of_query as $key => $value) {
$abs=str_ireplace($value,'<font color="green"><b> '.$value.'</b></font>',$abs); $abs=str_ireplace($value,'<font color="green"><b> '.$value.'</b></font>',$abs);
} }
...@@ -147,7 +148,7 @@ $id=$_GET["id"]; ...@@ -147,7 +148,7 @@ $id=$_GET["id"];
} }
$output.='<br/><p align="justify"><b>Abstract : </b><i>'.$abs.' </i></p>'; $output.='<br/><p align="justify"><b>Abstract : </b><i>'.$abs.' </i></p>';
$output.="<br>"; $output.="<br>";
......
<?php <?php
include('tools.php');
include('parameters_details.php'); include('parameters_details.php');
$db = $gexf_db[$gexf]; $db = $gexf_db[$gexf];
...@@ -14,7 +15,7 @@ $query = str_replace( '__and__', '&', $_GET["query"] ); ...@@ -14,7 +15,7 @@ $query = str_replace( '__and__', '&', $_GET["query"] );
$terms_of_query=json_decode($_GET["query"]); $terms_of_query=json_decode($_GET["query"]);
$elems = json_decode($query); $elems = json_decode($query);
// nombre d'item dans les tables // nombre d'item dans les tables
$sql='SELECT COUNT(*) FROM ISIABSTRACT'; $sql='SELECT COUNT(*) FROM ISIABSTRACT';
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$table_size=$row['COUNT(*)']; $table_size=$row['COUNT(*)'];
...@@ -23,7 +24,6 @@ foreach ($base->query($sql) as $row) { ...@@ -23,7 +24,6 @@ foreach ($base->query($sql) as $row) {
$table = ""; $table = "";
$column = ""; $column = "";
$id=""; $id="";
$twjs="pasteurapi/"; // submod path of TinaWebJS
if($type=="social"){ if($type=="social"){
$table = "ISIAUTHOR"; $table = "ISIAUTHOR";
...@@ -64,9 +64,9 @@ $sum=0; ...@@ -64,9 +64,9 @@ $sum=0;
//The final query! //The final query!
// array of all relevant documents with score // array of all relevant documents with score
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
// on pondère le score par le nombre de termes mentionnés par l'article // on pondère le score par le nombre de termes mentionnés par l'article
//$num_rows = $result->numRows(); //$num_rows = $result->numRows();
$wos_ids[$row[$id]] = $row["count(*)"]; $wos_ids[$row[$id]] = $row["count(*)"];
$sum = $row["count(*)"] +$sum; $sum = $row["count(*)"] +$sum;
...@@ -77,7 +77,7 @@ foreach ($base->query($sql) as $row) { ...@@ -77,7 +77,7 @@ foreach ($base->query($sql) as $row) {
$number_doc=ceil(count($wos_ids)/3); $number_doc=ceil(count($wos_ids)/3);
$count=0; $count=0;
foreach ($wos_ids as $id => $score) { foreach ($wos_ids as $id => $score) {
if ($count<1000){ if ($count<1000){
// retrieve publication year // retrieve publication year
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id; $sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
...@@ -86,23 +86,22 @@ foreach ($wos_ids as $id => $score) { ...@@ -86,23 +86,22 @@ foreach ($wos_ids as $id => $score) {
} }
// to filter under some conditions // to filter under some conditions
$to_display=true; $to_display=true;
if ($to_display){ if ($to_display){
$count+=1; $count+=1;
$output.="<li title='".$score."'>"; $output.="<li title='".$score."'>";
$output.=imagestar($score,$factor,$twjs).' '; $output.=imagestar($score,$factor,$our_libs_root).' ';
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id." group by data"; $sql = 'SELECT data FROM ISITITLE WHERE id='.$id." group by data";
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$output.='<a href="default_doc_details2.php?gexf='.urlencode($gexf).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> "; $output.='<a href="'.$our_php_root.'/default_doc_details2.php?gexf='.urlencode($gexf).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> ";
//this should be the command: //this should be the command:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> "; //$output.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> ";
//the old one: //the old one:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> "; //$output.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="twlibs/img/gs.png"></a>'; $external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="'.$our_libs_root.'/img/gs.png"></a>';
//$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>';
} }
// get the authors // get the authors
...@@ -113,7 +112,7 @@ foreach ($wos_ids as $id => $score) { ...@@ -113,7 +112,7 @@ foreach ($wos_ids as $id => $score) {
//<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>' //<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>'
$output.=$external_link."</li><br>"; $output.=$external_link."</li><br>";
} }
}else{ }else{
...@@ -127,21 +126,4 @@ $output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$ou ...@@ -127,21 +126,4 @@ $output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$ou
echo $output; echo $output;
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="twlibs/img/star.gif" border="0" >';
}
} else {
$star_image.='<img src="twlibs/img/stargrey.gif" border="0">';
}
return $star_image;
}
?> ?>
<?php <?php
include('tools.php');
include('parameters_details.php'); include('parameters_details.php');
$db= $_GET["db"];//I receive the specific database as string! $db= $_GET["db"];//I receive the specific database as string!
$query=$_GET["query"]; $query=$_GET["query"];
$gexf=$_GET["gexf"]; $gexf=$_GET["gexf"];
...@@ -21,7 +22,7 @@ $output = "<ul>"; // string sent to the javascript for display ...@@ -21,7 +22,7 @@ $output = "<ul>"; // string sent to the javascript for display
$type = $_GET["type"]; $type = $_GET["type"];
$query = str_replace( '__and__', '&', $_GET["query"] ); $query = str_replace( '__and__', '&', $_GET["query"] );
$elems = json_decode($query); $elems = json_decode($query);
// nombre d'item dans les tables // nombre d'item dans les tables
$sql='SELECT COUNT(*) FROM ISIABSTRACT'; $sql='SELECT COUNT(*) FROM ISIABSTRACT';
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$table_size=$row['COUNT(*)']; $table_size=$row['COUNT(*)'];
...@@ -31,7 +32,7 @@ foreach ($base->query($sql) as $row) { ...@@ -31,7 +32,7 @@ foreach ($base->query($sql) as $row) {
// Other restrictions // Other restrictions
// extracting the project folder and the year // extracting the project folder and the year
if (strpos($gexf,'2013')>0){ if (strpos($gexf,'2013')>0){
$year='2013'; $year='2013';
$year_filter=true; $year_filter=true;
}elseif (strpos($gexf,'2012')>0){ }elseif (strpos($gexf,'2012')>0){
$year='2012'; $year='2012';
...@@ -42,14 +43,13 @@ if (strpos($gexf,'2013')>0){ ...@@ -42,14 +43,13 @@ if (strpos($gexf,'2013')>0){
// identification d'une année pour echoing // identification d'une année pour echoing
if($project_folder=='nci'){ if($project_folder=='nci'){
$year_filter=true; $year_filter=true;
} }
$table = ""; $table = "";
$column = ""; $column = "";
$id=""; $id="";
$twjs="tinawebJS/"; // submod path of TinaWebJS
if($type=="social"){ if($type=="social"){
$table = "ISIAUTHOR"; $table = "ISIAUTHOR";
...@@ -95,7 +95,7 @@ $sum=0; ...@@ -95,7 +95,7 @@ $sum=0;
//echo $sql;//The final query! //echo $sql;//The final query!
// array of all relevant documents with score // array of all relevant documents with score
$count=0; $count=0;
foreach ($corporadb ->query($sql) as $row) { foreach ($corporadb ->query($sql) as $row) {
//if ($count<4*$max_item_displayed){ //if ($count<4*$max_item_displayed){
$wos_ids[$row[$id]] = $row['sum(tfidf)'];//$row["count(*)"]; $wos_ids[$row[$id]] = $row['sum(tfidf)'];//$row["count(*)"];
$sum = $row["count(*)"] +$sum; $sum = $row["count(*)"] +$sum;
...@@ -109,7 +109,7 @@ foreach ($corporadb ->query($sql) as $row) { ...@@ -109,7 +109,7 @@ foreach ($corporadb ->query($sql) as $row) {
$number_doc=ceil(count($wos_ids)/3); $number_doc=ceil(count($wos_ids)/3);
$count=0; $count=0;
foreach ($wos_ids as $id => $score) { foreach ($wos_ids as $id => $score) {
if ($count<1000){ if ($count<1000){
// retrieve publication year // retrieve publication year
$sql = 'SELECT data FROM ISIpubdate WHERE id='.$id; $sql = 'SELECT data FROM ISIpubdate WHERE id='.$id;
...@@ -118,37 +118,37 @@ foreach ($wos_ids as $id => $score) { ...@@ -118,37 +118,37 @@ foreach ($wos_ids as $id => $score) {
} }
// to filter under some conditions // to filter under some conditions
$to_display=true; $to_display=true;
if ($project_folder=='echoing'){ if ($project_folder=='echoing'){
if ($year_filter){ if ($year_filter){
if ($pubdate!=$year){ if ($pubdate!=$year){
$to_display=false; $to_display=false;
} }
} }
}elseif($project_folder=='nci'){ }elseif($project_folder=='nci'){
if ($year_filter){ if ($year_filter){
if ($pubdate!='2013'){ if ($pubdate!='2013'){
$to_display=false; $to_display=false;
} }
} }
} }
if ($to_display){ if ($to_display){
$count+=1; $count+=1;
$output.="<li title='".$score."'>"; $output.="<li title='".$score."'>";
$output.=imagestar($score,$factor,$twjs).' '; $output.=imagestar($score,$factor,$our_libs_root).' ';
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id; $sql = 'SELECT data FROM ISITITLE WHERE id='.$id;
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$output.='<a href="default_doc_details.php?db='.urlencode($db).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> "; $output.='<a href="'.$our_php_root.'/default_doc_details.php?db='.urlencode($db).'&type='.urlencode($_GET["type"]).'&query='.urlencode($query).'&id='.$id.'">'.$row['data']." </a> ";
//this should be the command: //this should be the command:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> "; //$output.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?db='.urlencode($datadb).'&id='.$id.' \')">'.$row['data']." </a> ";
//the old one: //the old one:
//$output.='<a href="JavaScript:newPopup(\''.$twjs.'php/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> "; //$output.='<a href="JavaScript:newPopup(\''.$our_php_root.'/default_doc_details.php?id='.$id.' \')">'.$row['data']." </a> ";
$external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="twlibs/img/gs.png"></a>'; $external_link="<a href=http://scholar.google.com/scholar?q=".urlencode('"'.$row['data'].'"')." target=blank>".' <img width=20px src="'.$our_libs_root.'/img/gs.png"></a>';
//$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>'; //$output.='<a href="JavaScript:newPopup(''php/doc_details.php?id='.$id.''')"> Link</a>';
} }
// get the authors // get the authors
...@@ -158,7 +158,7 @@ foreach ($wos_ids as $id => $score) { ...@@ -158,7 +158,7 @@ foreach ($wos_ids as $id => $score) {
} }
if($project_folder!='nci'){ if($project_folder!='nci'){
$output.='('.$pubdate.') '; $output.='('.$pubdate.') ';
}else { }else {
...@@ -169,7 +169,7 @@ foreach ($wos_ids as $id => $score) { ...@@ -169,7 +169,7 @@ foreach ($wos_ids as $id => $score) {
//<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>' //<a href="JavaScript:newPopup('http://www.quackit.com/html/html_help.cfm');">Open a popup window</a>'
$output.=$external_link."</li><br>"; $output.=$external_link."</li><br>";
} }
}else{ }else{
...@@ -183,21 +183,4 @@ $output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$ou ...@@ -183,21 +183,4 @@ $output= '<h3>'.$count.' items related to: '.implode(' OR ', $elems).'</h3>'.$ou
echo $output; echo $output;
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="twlibs/img/star.gif" border="0" >';
}
} else {
$star_image.='<img src="twlibs/img/stargrey.gif" border="0">';
}
return $star_image;
}
?> ?>
...@@ -13,7 +13,6 @@ $elems = json_decode($query); ...@@ -13,7 +13,6 @@ $elems = json_decode($query);
$table = ""; $table = "";
$column = ""; $column = "";
$id=""; $id="";
$twjs="API_CNRS/"; // submod path of TinaWebJS
if($type=="semantic"){ if($type=="semantic"){
...@@ -65,9 +64,9 @@ $sum=0; ...@@ -65,9 +64,9 @@ $sum=0;
//The final query! //The final query!
// array of all relevant documents with score // array of all relevant documents with score
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
// on pondère le score par le nombre de termes mentionnés par l'article // on pondère le score par le nombre de termes mentionnés par l'article
//$num_rows = $result->numRows(); //$num_rows = $result->numRows();
$wos_ids[$row[$id]] = $row["count(*)"]; $wos_ids[$row[$id]] = $row["count(*)"];
$sum = $row["count(*)"] +$sum; $sum = $row["count(*)"] +$sum;
...@@ -76,21 +75,21 @@ foreach ($base->query($sql) as $row) { ...@@ -76,21 +75,21 @@ foreach ($base->query($sql) as $row) {
// /// nombre de document associés $related // /// nombre de document associés $related
$total_count=0; $total_count=0;
$count_max=500; $count_max=500;
$number_doc=count($wos_ids); $number_doc=count($wos_ids);
$count=0; $count=0;
$all_terms_from_selected_projects=array();// list of terms for the top 6 project selected $all_terms_from_selected_projects=array();// list of terms for the top 6 project selected
// to filter under some conditions // to filter under some conditions
$to_display=true; $to_display=true;
$count=0; $count=0;
foreach ($wos_ids as $id => $score) { foreach ($wos_ids as $id => $score) {
if ($total_count<$count_max) { if ($total_count<$count_max) {
// retrieve publication year // retrieve publication year
if ($to_display){ if ($to_display){
$total_count+=1; $total_count+=1;
...@@ -99,27 +98,27 @@ foreach ($wos_ids as $id => $score) { ...@@ -99,27 +98,27 @@ foreach ($wos_ids as $id => $score) {
$sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data'; $sql = 'SELECT data FROM ISITITLE WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$external_link="<a href=http://google.com/webhp?#q=".urlencode('"'.utf8_decode($row['data']).'"')." target=blank>".' <img width=15px src="twlibs/img/google.png"></a>'; $external_link="<a href=http://google.com/webhp?#q=".urlencode('"'.utf8_decode($row['data']).'"')." target=blank>".' <img width=15px src="'.$our_libs_root.'/img/google.png"></a>';
$output.="<li title='".$score."'>"; $output.="<li title='".$score."'>";
$output.=$external_link.imagestar($score,$factor,$twjs).' '; $output.=$external_link.imagestar($score,$factor,$our_libs_root).' ';
$output.='<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details2.php?gexf='.urlencode($gexf).'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> "; $output.='<a href="JavaScript:newPopup(\''.$our_php_root.'default_doc_details2.php?gexf='.urlencode($gexf).'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> ";
// $output.='<a>'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> "; // $output.='<a>'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> ";
} }
$sql = 'SELECT data FROM ISIDOI WHERE id='.$id.' group by data'; $sql = 'SELECT data FROM ISIDOI WHERE id='.$id.' group by data';
foreach ($base->query($sql) as $row) { foreach ($base->query($sql) as $row) {
$output.=$external_link.imagestar($score,$factor,$twjs).' '; $output.=$external_link.imagestar($score,$factor,$our_libs_root).' ';
$output.='<a href="JavaScript:newPopup(\''.$twjs.'default_doc_details2.php?gexf='.urlencode($gexf).'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> "; $output.='<a href="JavaScript:newPopup(\''.$our_php_root.'default_doc_details2.php?gexf='.urlencode($gexf).'&query='.urlencode($query).'&type='.urlencode($_GET["type"]).'&id='.$id.' \')">'.htmlentities($row['data'], ENT_QUOTES, "UTF-8")." </a> ";
} // get the authors } // get the authors
$sql2 = 'SELECT data FROM ISIAUTHOR WHERE id='.$id. ' group by data'; $sql2 = 'SELECT data FROM ISIAUTHOR WHERE id='.$id. ' group by data';
foreach ($base->query($sql2) as $row2) { foreach ($base->query($sql2) as $row2) {
$output.=(str_replace("\r", "", $row2['data'])).', '; $output.=(str_replace("\r", "", $row2['data'])).', ';
} }
$output = rtrim($output, ", "); $output = rtrim($output, ", ");
$output.="</li><br>"; $output.="</li><br>";
} }
} }
...@@ -154,10 +153,10 @@ function getDB ($directory) { ...@@ -154,10 +153,10 @@ function getDB ($directory) {
$result = ""; $result = "";
$handler = opendir($directory); $handler = opendir($directory);
while ($file = readdir($handler)) { while ($file = readdir($handler)) {
if ($file != "." && $file != ".." if ($file != "." && $file != ".."
&& &&
((strpos($file,'.db~'))==false && (strpos($file,'.db'))==true ) ((strpos($file,'.db~'))==false && (strpos($file,'.db'))==true )
|| ||
((strpos($file,'.sqlite~'))==false && (strpos($file,'.sqlite'))==true) ((strpos($file,'.sqlite~'))==false && (strpos($file,'.sqlite'))==true)
) { ) {
//$results[] = $file; //$results[] = $file;
...@@ -170,19 +169,4 @@ function getDB ($directory) { ...@@ -170,19 +169,4 @@ function getDB ($directory) {
return $result; return $result;
} }
function imagestar($score,$factor,$twjs) {
// produit le html des images de score
$star_image = '';
if ($score > .5) {
$star_image = '';
for ($s = 0; $s < min(5,$score/$factor); $s++) {
$star_image.='<img src="twlibs/img/star.gif" border="0" >';
}
} else {
$star_image.='<img src="twlibs/img/stargrey.gif" border="0">';
}
return $star_image;
}
?> ?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment