Commit bbe5717e authored by Romain Loth's avatar Romain Loth

directory views: fix organisms display

parent 848e6bcf
......@@ -236,6 +236,7 @@ for($i = 0; $i < $n_steps; $i++) {
) AS lab_relationship_to_inst_via_scholars ON src_orgid = orgs.orgid
WHERE orgs.orgid IN ( {$ids_str} )
AND orgs.name != '_NULL'
AND tgt_freq > 1
GROUP BY orgs.orgid
ORDER BY orgs.name, orgs.acro
LABSQLEXTENDED;
......@@ -261,13 +262,14 @@ LABSQLEXTENDED;
// keywords : POSS with an org <=> keywords map
// cf. doc/data_mining_exemples/correlated_kws.sql
// $info['keywords'] = $row['keywords'];
$info['keywords'] = null;
// most frequent parent orgs (max = 3)
$related_insts_ids = array_slice(explode(',', $row['related_insts'] ?? ""),0,3) ;
$info['related_insts'] = array_filter($related_insts_ids);
// most frequent parent orgs (max = 2)
$related_insts_ids = array_filter(array_slice(explode(',', $row['related_insts'] ?? ""),0,2)) ;
$info['related_insts'] = $related_insts_ids;
// also add them to orga_list
$additional_insts_ids[] = $related_insts_ids;
$additional_insts_ids = array_merge($additional_insts_ids,$related_insts_ids);
$info['admin'] = ucwords($row['contact_name'] ?? '');
if ($row['contact_email']) {
......@@ -292,43 +294,54 @@ LABSQLEXTENDED;
/// liste des organismes / affiliations institutionnelles ///
/////////////////////////////////////////////////////////////
// print_r("<br>0<br>") ;
// print_r($inst_counts) ;
// all direct institutions' orgids except ''
$inst_ids = array_filter(array_keys($inst_counts));
$insts_ids = array_filter(array_keys($inst_counts));
// any other institutions we want
// $insts_ids[] = $additional_insts_ids;
sort($inst_ids);
$insts_ids = array_merge($insts_ids, $additional_insts_ids);
sort($insts_ids);
$insts_ids = array_unique($insts_ids);
// all org with infos to retrieve
$organiz = array();
// all institutions with infos to retrieve
$institutions = array();
// debug
// $content .= var_dump($inst_ids) ;
$ids_str = implode(',', $insts_ids);
foreach ($inst_ids as $inst_id) {
$sql = "SELECT * FROM orgs WHERE orgid='" . $inst_id. "'";
$sql = "SELECT * FROM orgs WHERE orgid IN (" . $ids_str. ") ORDER BY label";
foreach ($base->query($sql) as $row) {
$info = array();
$info['unique_id'] = $inst_id;
$info['name'] = $row['name'];
foreach ($base->query($sql) as $row) {
if ($row['name'] == "_NULL") continue ;
$info['acronym'] = $row['acro'] ?? '';
$info['homepage'] = $row['url'] ?? '';
$info['inst_type'] = $row['inst_type'] ?? '';
$info['locname'] = $row['locname'] ?? ''; // ex: 'Barcelona, Spain'
// 'London, UK'
// 'UK'
$info = array();
$info['unique_id'] = $row['orgid'];
$info['name'] = $row['name'];
$info['acronym'] = $row['acro'] ?? '';
$info['homepage'] = $row['url'] ?? '';
$info['inst_type'] = $row['inst_type'] ?? '';
$info['locname'] = $row['locname'] ?? ''; // ex: 'Barcelona, Spain'
// 'London, UK'
// 'UK'
// TODO ADD keywords
// $info['keywords'] = $row['keywords'];
$info['keywords'] = null;
// cf. doc/data_mining_exemples/correlated_kws.sql
// TODO RESTORE keywords and contact
// $info['keywords'] = $row['keywords'];
// $info['admin'] = $row['admin'];
$organiz[$inst_id] = $info;
$info['admin'] = ucwords($row['contact_name'] ?? '');
if ($row['contact_email']) {
$safe_contact_email = safe_email($row['contact_email']);
$info['admin'] .= '<br><span class=code>'.$safe_contact_email.'</span>';
}
$institutions[$row['orgid']] = $info;
}
// debug
// $content .= var_dump($institutions) ;
///////////////////////////////////////////////////////////////
......
<?php
/*
* A place to factorize the injected JS
* TODO use more eg for charts
*/
// exemple snippet this one is to use in html context
$rm_ads_snippet = <<< ENDHTML
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
setTimeout( function() {
var ads = document.getElementsByClassName("highcharts-credits")
for (var ad of ads) {
ad.innerHTML = ""
}
}, 2000)
})
</script>
ENDHTML;
?>
......@@ -5,6 +5,7 @@ $content .='<br/>
<br/>
<br/>';
$has_acro = false;
foreach ($labs as $lab) {
if ($loop % 100){
......@@ -25,71 +26,50 @@ foreach ($labs as $lab) {
$content .= '<h2 >';
$www = org_info_to_search_link($lab);
$content .= '<a href="'.$www.'"><i class="icon-search"></i></a>&nbsp;';
$content .= $lab['name'];
if (strlen($lab['acronym'])){
$content.=' (<b>'.$lab['acronym'].'</b>)';
$has_acro = true;
$content.= $lab['acronym'];
}
// one of either acro or name should always be non null
else {
$content .= $lab['name'];
}
if ($lab['locname'] != null) {
$content.=' <span style="color:grey"><small> - ' . $lab['locname'] . '<small></span>';
$content.=' <span style="color:grey"><small> - ' . $lab['locname'] . '</small></span>';
}
if (array_key_exists('lab_code', $lab) && strlen($lab['lab_code'])) {
$content .= '&nbsp;&nbsp;<small>['.$lab['lab_code'].']</small>';
}
$content.="</h2>";
// var_dump($lab);
// if acro, full name is below title
if ($has_acro && $lab['name']) {
$content .= '<dl><dd>'.$lab['name'].'</dd></dl>';
}
$www = '';
if (array_key_exists('homepage', $lab) && strlen($lab['homepage'])) {
$www = homepage_to_alink($lab['homepage']);
$content .= '<dl><dd><i class="icon-home"></i>'.$www.'</dd></dl>';
}
$lab_code = '';
if (array_key_exists('lab_code', $lab) && strlen($lab['lab_code'])) {
$exact_search = 'https://search.iscpif.fr/?q='.urlencode('"'.$lab['lab_code'].'"');
$content .= '<dl><dd><i class="icon-flag"></i>' ;
$content .= '<a href="'.web_search($lab['lab_code'], true).'">';
$content .= $lab['lab_code'].'</a></dd></dl>';
}
$n_related_insts = count($lab['related_insts']);
if ($n_related_insts) {
$content .= '<br><h4 title="Frequently related institutions">Institutions:</h4>';
$content .= '<ul>';
// $content .= "<p>".$n_related_insts."</p>";
foreach ($lab['related_insts'] as $rel_inst_id) {
$content .= '<li class="parent-org"><a href="#org-'.$rel_inst_id.'">';
$rel_inst_info = $organiz[$rel_inst_id];
$has_acro = false ;
if (strlen($rel_inst_info['acronym'])) {
$content .= $rel_inst_info['acronym'];
$has_acro = true ;
} else {
$content .= $rel_inst_info['name'];
}
$content .= '</a>';
$content .= "</li>";
// $content .= '<dd class="parent-org">' . ['label'] . '</dd> ';
}
$content .= '</ul>';
}
$content .= '</div>';
$content .= '</div>';
// LABS MORE INFOS: admin (ie contact person),
// keywords (not used but POSS if orgs_kwid map)
$n_related_insts = count($lab['related_insts']);
$has_admin = array_key_exists('admin', $lab) && strlen($lab['admin']);
$has_kws = array_key_exists('keywords', $lab) && strlen($lab['keywords']);
if ($has_admin || $has_kws) {
if ($n_related_insts || $has_admin || $has_kws) {
$content .= '<div class="span3" align="justify">';
if ($has_kws) {
$content .= '<i class="icon-tags"></i> ' . $lab['keywords'] . '<br/><br/>';
......@@ -98,6 +78,36 @@ foreach ($labs as $lab) {
$content .= '<address><i class="icon-info-sign"></i> Administrative contact:<br>' . $lab['admin'] . '<br></address>';
}
if ($n_related_insts) {
$content .= '<h4 title="Frequently related institutions">Institutions:</h4>';
$content .= '<ul>';
// $content .= "<p>".$n_related_insts."</p>";
foreach ($lab['related_insts'] as $rel_inst_id) {
$content .= '<li class="parent-org"><a href="#org-'.$rel_inst_id.'">';
$rel_inst_info = $institutions[$rel_inst_id];
$has_acro = false ;
if (strlen($rel_inst_info['acronym'])) {
$content .= $rel_inst_info['acronym'];
$has_acro = true ;
} else {
$content .= $rel_inst_info['name'];
}
$content .= '</a>';
if (strlen($rel_inst_info['locname'])) {
$content .= "<span class='rel-inst-locname'> - ".$rel_inst_info['locname']."</span>";
}
// $content .= var_dump($rel_inst_info);
$content .= "</li>";
// $content .= '<dd class="parent-org">' . ['label'] . '</dd> ';
}
$content .= '</ul>';
}
$content .= '</div>';
}
$content .= '</div></div></div>';
......
......@@ -10,9 +10,9 @@ $content .='<br/>
$orga_count = 0;
// debug
$content .= var_dump($organiz) ;
// $content .= var_dump($institutions) ;
foreach ($organiz as $orga) {
foreach ($institutions as $orga) {
if ($loop % 100){
set_time_limit(20);
......@@ -58,25 +58,25 @@ foreach ($organiz as $orga) {
$content .= '<dl><dd><span class="glyphicon glyphicon-home"></span>'.$www.'</dd></dl>';
}
$content .= '</div>';
if ((trim($orga['fields']) != null)) {
$content .= '<div><p>';
//echo $orga['fields'].'<br/>';
$fields=trim(str_replace('Other','',clean_exp($orga['fields'])));
// if ((trim($orga['fields']) != null)) {
// $content .= '<div><p>';
// //echo $orga['fields'].'<br/>';
// $fields=trim(str_replace('Other','',clean_exp($orga['fields'])));
//
// if (strcmp(',', substr($fields,-1,1))==0){
// $fields=substr($fields,0,-1);
// }
// $fields=str_replace('%%%', ', ',$fields);
// $content .= '<i>Fields: </i> ' . str_replace(", , ", ", ", $fields). '.<br/><br/>';
//
// $content .= '</p></div>';
// }
$content .= '</div>';
if (strcmp(',', substr($fields,-1,1))==0){
$fields=substr($fields,0,-1);
}
$fields=str_replace('%%%', ', ',$fields);
$content .= '<i>Fields: </i> ' . str_replace(", , ", ", ", $fields). '.<br/><br/>';
$content .= '</p></div>';
}
$content .= '</div>';
if (($orga['keywords'] != null) || ($orga['admin'] != null)) {
$content .= '<div class="span3" align="justify">';
......
......@@ -8,14 +8,14 @@
// parameters : threshold to display orgs (labs / institutions) diagrams
$MIN_DISTINCT_LABS = 1 ;
$MIN_DISTINCT_LABS_SCHOLARS_SHARE = .25;
$MIN_DISTINCT_LABS_SCHOLARS_SHARE = .15;
$MIN_DISTINCT_INSTS = 1 ;
$MIN_DISTINCT_INSTS_SCHOLARS_SHARE = .20;
$MIN_DISTINCT_INSTS_SCHOLARS_SHARE = .05;
// always the same colors for "others" and "missing" categories
$COLOR_OTHERS="grey";
$COLOR_MISSING="darkgrey";
$COLOR_OTHERS="darkgrey";
$COLOR_MISSING="grey";
// all the other available color-scheme
$COLOR_SCHEME = '["#4572A7", "#AA4643", "#89A54E", "#80699B", "#3D96AE",
......@@ -39,8 +39,10 @@ $other_insts = 0;
$missing_country = 0;
$missing_title = 0;
$missing_position = 0;
$missing_labs = 0;
$missing_insts = 0;
$missing_labs = $lab_counts[''] || 0;
$missing_insts = $inst_counts[''] || 0;
// données des pays
......
<?php
include ("php_library/comex_library.php");
include ("php_library/js_elements.php");
include ("php_library/parametres.php");
include ("php_library/normalize.php");
......@@ -41,6 +42,8 @@ $meta = '<!DOCTYPE html>
</script>
';
$meta .= $rm_ads_snippet;
define('_is_utf8_split', 5000);
function is_utf8($string) {
......@@ -399,8 +402,6 @@ foreach ($base->query($sql) as $row) {
$idkey = $cat[1];
$counthash_ref = &$cat[2];
// £TODO_ORGS we'll need a missing_labs
$j = -1 ;
foreach ($info[$idkey] as $org_id) {
......@@ -414,7 +415,8 @@ foreach ($base->query($sql) as $row) {
$org_label = weedout_alt_nulls($org_label);
}
// all non-values are there as null
// all non-values are there as null => the key becomes ""
// (useful for missing labs)
$org_id_to_label[$org_id] = $org_label;
......@@ -538,7 +540,6 @@ Contributions and ideas are welcome to improve this directory.
echo $meta.' '.$stats.'</head>';
echo $header;
echo $content;
exit(0)
......
......@@ -215,8 +215,6 @@ HERE_QUERY;
$idkey = $cat[1];
$counthash_ref = &$cat[2];
// £TODO_ORGS we'll need a missing_labs
$j = -1 ;
foreach ($info[$idkey] as $org_id) {
......
......@@ -347,11 +347,15 @@ div.ccsection-footer {
/*in directory view*/
.labs-of-scholar {
font-family: Georgia, Cambria, serif;
font-style: italic;
}
.institutions-of-scholar {
font-family: Georgia, Cambria, serif;
font-weight: bold;
font-variant: small-caps;
font-style: italic;
}
.rel-inst-locname {
font-size: 75%;
}
......
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