Commit 02be7d68 authored by Romain Loth's avatar Romain Loth

fix php html structure and some layout

parent 7930c4cd
<?php
echo "
$meta .= "
<script type='text/javascript'>
var _gaq = _gaq || [];
......
......@@ -4,7 +4,7 @@
* Common utility functions
*/
function clean_exp($string){
function clean_exp($string) {
// enlève les comma trainantes
if (strcmp(substr(trim($string),-1),',')==0){
return substr(trim($string),0,-1);
......@@ -13,8 +13,8 @@ function clean_exp($string){
}
}
function esc_html($string){
return htmlspecialchars($string,ENT_HTML5, 'UTF-8') ;
function esc_html($string) {
return htmlspecialchars($string,ENT_HTML5|ENT_QUOTES, 'UTF-8') ;
}
// -----------------------------8<------------------
......
......@@ -3,16 +3,9 @@
// sort un $content
echo '
<body>';
include ("analytics.php");
echo '
<div class="container">
<!-- Directory listing -->
<div class="hero-unit">
';
$content.= ' <!-- Directory listing --> ';
$imsize = 150;
......@@ -29,7 +22,6 @@ $loop = 0;
// NB this array was prepared in print_directory or print_scholar_directory
foreach ($scholars as $scholar) {
$scholar['position'] = weedout_alt_nulls($scholar['position']) ;
......@@ -41,12 +33,37 @@ foreach ($scholars as $scholar) {
set_time_limit(20);
}
$loop+=1;
$content.= '<div class="row">
<div class="span12">
<div class="row">
<div class="span9" align="justify">';
$content .= '<div>';
// Entry structure:
// ----------------
// <div class="row">
// <div class="span3" align="justify">
// <!-- picture -->
// </div>
// <div class="span9" align="justify">
// <div class="container inner">
// <div class="row">
// <div class="span6" align="justify">
// <!-- name and affiliations -->
// </div>
// <div class="span3" align="justify">
// <!-- keywords -->
// </div>
// </div>
// <div class="row">
// <div class="span12" align="justify">
// <!-- interests text -->
// </div>
// </div>
// </div>
// </div>
// </div>
$content .= "\n";
$content.= '<div class="row">';
// picture <=> left column
$content.= ' <div class="span3" align="justify">';
// remote pictures url 'http://some.org/path/blabla.png'
// or local '/data/shared_user_img/blabla.png'
if ($scholar['pic_src'] != null) {
......@@ -54,39 +71,52 @@ foreach ($scholars as $scholar) {
if ($_SERVER['REQUEST_SCHEME'] == 'https') {
$pic_src = preg_replace('/^http:/i', 'https:', $pic_src) ;
}
$content .= '<img style="margin: 7px 10px 10px 0px" src="'. $pic_src . '" width="' . $imsize . 'px" align="left">';
$content .= '<img class="pic-of-scholar" src="'. $pic_src . '" width="' . $imsize . 'px" align="left">';
}
else {
if (count($scholars) < 2000) {
$im_id = floor(rand(0, 11));
$content .= '<img style="margin: 7px 10px 10px 0px" src="static/img/' . $im_id . '.png" width="' . $imsize . 'px" align="left">';
$content .= '<img class="pic-of-scholar" src="static/img/' . $im_id . '.png" width="' . $imsize . 'px" align="left">';
}
}
$content.= ' </div><!-- close pic -->';
// right part :
// ---8---|--4- innerrow1
// ------12---- innerrow2
$content .= ' <div class="span9" align="justify">';
// innercontainer
$content .= ' <div class="container inner">';
// innerrow1
$content .= ' <div class="row">';
// name and affiliations
$content .= ' <div class="span6" align="justify">';
$content .= '<h2 >' . $scholar['title'] . ' ' . $scholar['first_name'] . ' ' . $scholar['mid_initial'] . ' ' . $scholar['last_name'] .
' <small> - ' . $scholar['country'] . '</small></h2>';
if (($scholar['position'] != null)||count($scholar['labs'])||count($scholar['institutions'])) {
if (($scholar['position'] != null)
|| $scholar['homepage'] != null
|| count($scholar['labs'])
|| count($scholar['institutions'])) {
$content .= '<dl>';
}
if ($scholar['position'] != null) {
$content .= '<dt>' . $scholar['position'] . '</dt>';
}
$lab = '';
// new way: list of org.label values
// list of org.label values
if (count($scholar['labs'])) {
$labs_html = implode(
'<br>',
array_map(
"clean_exp",
array_map("esc_html",
array_map(
array_map(
"weedout_alt_nulls",
$scholar['labs']
)
)
)
);
......@@ -98,14 +128,15 @@ foreach ($scholars as $scholar) {
# because we already have $lab_counts (per id)
}
// new way: list of org.label values
// list of org.label values
if (count($scholar['institutions'])) {
$institutions_html = implode(
'<br>',
array_map(
"clean_exp",
array_map("esc_html",
$scholar['institutions']
array_map(
"weedout_alt_nulls",
$scholar['institutions']
)
)
);
......@@ -118,46 +149,59 @@ foreach ($scholars as $scholar) {
}
// POSS: url of lab as link, if filled in DB
if ($scholar['homepage'] != null) {
$www = homepage_to_alink($scholar['homepage']);
$content .= '<dd class="url-of-scholar"><i class="icon-home"></i>'.$www.'</dd>';
}
if (($scholar['position'] != null)
||count($scholar['labs'])
||count($scholar['institutions'])
|| $scholar['homepage'] != null
|| count($scholar['labs'])
|| count($scholar['institutions'])
) {
$content .= '</dl>';
}
$content .= ' </div>'; // close span6
$content .= '</div>';
if ($scholar['keywords'] != null) {
$content .= '<div class="span3" align="left">';
if ($scholar['interests'] != null) {
$content .= ' <div class="keywords-of-scholar">
<i class="icon-tags"></i> ' . clean_exp($scholar['keywords']). '
</div>';
$htmlsafe_interests = str_replace('%%%', '<br/>',
htmlspecialchars($scholar['interests'],
ENT_HTML5, 'UTF-8')
);
$content .= '<div>';
$content .= '<h4>Research</h4>';
$content .= '<p>' . $htmlsafe_interests . '</p>';
$content .= '</div>';
$content .= "\n";
$content .= '</div>'; // close span3
$content .= "\n";
}
$content .= '</div>';
$content .= '</div>'; // close innerrow1
$content .= "\n";
if ($scholar['keywords'] != null) {
$content .= '<div class="span3" align="left">';
if ($scholar['keywords'] != null){
$content .= '<i class="icon-tags"></i> ' . clean_exp($scholar['keywords']). '.<br/><br/>';
}
if ($scholar['interests'] != null) {
// second row is undivided
$content .= "\n";
$content .= '<div class="row">
<div class="span9" align=justify>';
$content .= "\n";
$content .= '<div class="interests-of-scholar">';
$content .= '<dl><dt>Research</dt></dl>';
$content .= '<p>' . $scholar['interests'] . '</p>';
$content .= '</div>';
$content .= "\n";
$content .= '</div></div>'; // closing full span and innerrow2
$content .= "\n";
}
$content .= '</div>';
$content .= '</div>';
$content .= '</div>';
$content .= "\n";
$content .= '</div>'; // closing inner container
$content .= "\n";
$content .= '</div>'; // closing outer span12
$content .= "\n";
$content .= '</div>'; // closing outer row
$content .= "\n";
$content .= '
<center><img src="static/img/bar.png"></center>';
......@@ -222,21 +266,23 @@ for($i = 0; $i < $n_steps; $i++) {
AS related_insts
FROM orgs
LEFT JOIN (
SELECT sch_org.orgid AS src_orgid,
sch_org2.orgid AS tgt_orgid,
count(*) AS tgt_freq
FROM sch_org
LEFT JOIN sch_org AS sch_org2
ON sch_org.uid = sch_org2.uid
JOIN orgs AS orgs2
ON sch_org2.orgid = orgs2.orgid
WHERE orgs2.class = 'inst'
AND sch_org.orgid != sch_org2.orgid
GROUP BY sch_org.orgid, sch_org2.orgid
) AS lab_relationship_to_inst_via_scholars ON src_orgid = orgs.orgid
SELECT * FROM (
SELECT sch_org.orgid AS src_orgid,
sch_org2.orgid AS tgt_orgid,
count(sch_org.uid) AS tgt_freq
FROM sch_org
LEFT JOIN sch_org AS sch_org2
ON sch_org.uid = sch_org2.uid
JOIN orgs AS orgs2
ON sch_org2.orgid = orgs2.orgid
WHERE orgs2.class = 'inst'
AND sch_org.orgid != sch_org2.orgid
GROUP BY sch_org.orgid, sch_org2.orgid
) AS lab_relationship_to_inst_via_scholars
WHERE tgt_freq > 1
) lab_relationship_filtered 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;
......
......@@ -80,12 +80,12 @@ foreach ($labs as $lab) {
if ($n_related_insts) {
$content .= '<h4 title="Frequently related institutions">Institutions:</h4>';
$content .= '<ul>';
$content .= '<dl style="margin-top:5px;">';
// $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.'">';
$content .= '<dd class="parent-org"><a href="#org-'.$rel_inst_id.'">';
$rel_inst_info = $institutions[$rel_inst_id];
$has_acro = false ;
......@@ -100,12 +100,12 @@ foreach ($labs as $lab) {
$content .= "<span class='rel-inst-locname'> - ".$rel_inst_info['locname']."</span>";
}
// $content .= var_dump($rel_inst_info);
$content .= "</li>";
$content .= "</dd>";
// $content .= '<dd class="parent-org">' . ['label'] . '</dd> ';
}
$content .= '</ul>';
$content .= '</dl>';
}
$content .= '</div>';
......
......@@ -75,6 +75,7 @@ function split_join_keywords_for_html($str_value) {
$mod_arr = [];
foreach ($arr as $kw) {
$kw = esc_html($kw);
if (strlen(str_replace(' ', '', $kw))) {
$mod_kw = str_replace(' ', '&nbsp;', $kw) ;
array_push($mod_arr, $mod_kw);
......
......@@ -53,8 +53,8 @@ foreach ($institutions as $orga) {
$content.="</h2>";
$www = '';
if (array_key_exists('homepage', $lab) && strlen($lab['homepage'])) {
$www = homepage_to_alink($lab['homepage']);
if (array_key_exists('homepage', $orga) && strlen($orga['homepage'])) {
$www = homepage_to_alink($orga['homepage']);
$content .= '<dl><dd><span class="glyphicon glyphicon-home"></span>'.$www.'</dd></dl>';
}
......
......@@ -40,8 +40,8 @@ $missing_country = 0;
$missing_title = 0;
$missing_position = 0;
$missing_labs = $lab_counts[''] || 0;
$missing_insts = $inst_counts[''] || 0;
$missing_labs = array_key_exists('', $lab_counts) ? $lab_counts[''] : 0;
$missing_insts = array_key_exists('', $inst_counts) ? $inst_counts[''] : 0;
......
......@@ -143,6 +143,7 @@ if ($tags) {
$i++;
}
$f .= ") ";
$query_details .= "</li>";
}
if ($keywords) {
......@@ -172,6 +173,8 @@ if ($keywords) {
$i++;
}
$f .= ") ";
$query_details .= "</li>";
}
......@@ -195,6 +198,7 @@ if ($countries) {
$i++;
}
$f .= ") ";
$query_details .= "</li>";
}
if ($laboratories) {
......@@ -215,6 +219,7 @@ if ($laboratories) {
$i++;
}
$f .= ") ";
$query_details .= "</li>";
}
if ($organizations) {
......@@ -237,6 +242,7 @@ if ($organizations) {
$i++;
}
$f .= ") ";
$query_details .= "</li>";
}
$query_details.='</ul>';
......@@ -351,10 +357,10 @@ foreach ($base->query($sql) as $row) {
$info = array();
$info['unique_id'] = $row['luid'];
$info['doors_uid'] = $row['doors_uid'];
$info['first_name'] = $row['first_name'];
$info['first_name'] = esc_html($row['first_name']);
$info['mid_initial'] = (strlen($row['middle_name']) ? substr($row['middle_name'],0,1)."." : "");
$info['last_name'] = $row['last_name'];
$info['initials'] = $row['initials'];
$info['last_name'] = esc_html($row['last_name']);
$info['initials'] = esc_html($row['initials']);
// retrieved from secondary table and GROUP_CONCATenated
// $info['keywords_ids'] = explode(',', $row['keywords_ids']);
......@@ -365,21 +371,25 @@ foreach ($base->query($sql) as $row) {
// $info['status'] = $row['status'];
$info['record_status'] = $row['record_status']; // TODO use this one
$info['country'] = $row['country'];
$info['country'] = esc_html($row['country']);
$info['homepage'] = $row['home_url'];
// recreated arrays
$info['labs'] = explode('%%%', $row['labs_list'] ?? "") ;
$info['institutions'] = explode('%%%', $row['insts_list'] ?? "") ;
$info['labs'] = array_map("esc_html",
explode('%%%', $row['labs_list'] ?? "")
) ;
$info['institutions'] = array_map("esc_html",
explode('%%%', $row['insts_list'] ?? "")
) ;
$info['labs_ids'] = explode(',', $row['labs_ids'] ?? "") ;
$info['insts_ids'] = explode(',', $row['insts_ids'] ?? "") ;
$info['title'] = $row['hon_title'];
$info['position'] = $row['position'];
$info['title'] = esc_html($row['hon_title']);
$info['position'] = esc_html($row['position']);
$info['pic_src'] = $row['pic_fname'] ? '/data/shared_user_img/'.$row['pic_fname'] : $row['pic_url'] ;
$info['interests'] = $row['interests_text'];
$info['interests'] = str_replace('%%%', '<br/>',
esc_html($row['interests_text'])
);
// $info['address'] = $row['address'];
// $info['city'] = $row['city'];
......@@ -432,6 +442,7 @@ foreach ($base->query($sql) as $row) {
// both our stats have been filled
// var_dump($lab_counts) ;
// var_dump($inst_counts) ;
// var_dump($org_id_to_label) ;
// creates js for stats visualisations and counts (we re-use the orgs counts)
include ("php_library/stat-prep_from_array.php");
......@@ -445,8 +456,7 @@ include ("php_library/directory_content.php");
$content .= '</div>';
$content .= '</div>
<footer style="color:white">
$content .= '<footer style="color:white">
<!-- This directory is maintained by the <a href="http://cssociety.org" target="blank">Complex Systems Society</a>
and the <a href="http://iscpif.fr" target="blank">Complex Systems Institute of Paris Ile-de-France</a>.<br/>-->
<center>
......@@ -484,15 +494,16 @@ $content .= '</div>
</html>';
//////// Header
$header = '<div class="row" id="welcome">
$header = '
<div class="row" id="welcome">
<div class="span12" align="justify">
<img src="static/img/RegistryBanner.png" align="center">
<br/><br/>
<h1>Complex Systems Scholars</h1>
<br/>
<br/>
<p>
This directory presents the profiles of <a href="#scholars">'. count($scholars).' scholars</a>, <a href="#labs">'. count($labs).' labs</a> and <a href="#orga">'.$orga_count.' organizations</a> in the field of Complex Systems';
<img src="static/img/RegistryBanner.png" align="center">
<br/><br/>
<h1>Complex Systems Scholars</h1>
<br/>
<br/>
<p>
This directory presents the profiles of <a href="#scholars">'. count($scholars).' scholars</a>, <a href="#labs">'. count($labs).' labs</a> and <a href="#orga">'.$orga_count.' organizations</a> in the field of Complex Systems';
......@@ -508,13 +519,12 @@ science, as well as to increase their visibility at the international scale.<
<ul>
<li><b><i>This directory is open</i></b>. Anybody can have her profile included
provided it is related to Complex Systems science and Complexity science. Personal data are given on a
voluntary basis and people are responsible for the validity and integrity of their data.
voluntary basis and people are responsible for the validity and integrity of their data.</li>
<li>This directory is edited by the ISCPIF. This initiative is supported by the <i>Complex Systems
Society</i> (<a href="http://cssociety.org">http://cssociety.org</a>).
Contributions and ideas are welcome to improve this directory.
<a href="mailto:sysop AT iscpif.fr">Please feedback</a></p>
<a href="mailto:sysop AT iscpif.fr">Please feedback</a></li>
</ul>
</p>
<br/>
<br/>
......@@ -538,7 +548,12 @@ Contributions and ideas are welcome to improve this directory.
</div>';
echo $meta.' '.$stats.'</head>';
echo '<body>
<div class="container full-directory">
<div class="hero-unit">';
echo $header;
echo '';
echo $content;
exit(0)
......
......@@ -166,10 +166,10 @@ HERE_QUERY;
$info = array();
$info['unique_id'] = $row['luid'];
$info['doors_uid'] = $row['doors_uid'];
$info['first_name'] = $row['first_name'];
$info['first_name'] = esc_html($row['first_name']);
$info['mid_initial'] = (strlen($row['middle_name']) ? substr($row['middle_name'],0,1)."." : "");
$info['last_name'] = $row['last_name'];
$info['initials'] = $row['initials'];
$info['last_name'] = esc_html($row['last_name']);
$info['initials'] = esc_html($row['initials']);
// retrieved from secondary table and GROUP_CONCATenated
$info['keywords_ids'] = explode(',', $row['keywords_ids']);
......@@ -179,21 +179,25 @@ HERE_QUERY;
// $info['status'] = $row['status'];
$info['record_status'] = $row['record_status']; // TODO use this one
$info['country'] = $row['country'];
$info['country'] = esc_html($row['country']);
$info['homepage'] = $row['home_url'];
// recreated arrays
$info['labs'] = explode('%%%', $row['labs_list'] ?? "") ;
$info['institutions'] = explode('%%%', $row['insts_list'] ?? "") ;
$info['labs'] = array_map("esc_html",
explode('%%%', $row['labs_list'] ?? "")
) ;
$info['institutions'] = array_map("esc_html",
explode('%%%', $row['insts_list'] ?? "")
) ;
$info['labs_ids'] = explode(',', $row['labs_ids'] ?? "") ;
$info['insts_ids'] = explode(',', $row['insts_ids'] ?? "") ;
$info['title'] = $row['hon_title'];
$info['position'] = $row['position'];
$info['title'] = esc_html($row['hon_title']);
$info['position'] = esc_html($row['position']);
$info['pic_src'] = $row['pic_fname'] ? '/data/shared_user_img/'.$row['pic_fname'] : $row['pic_url'] ;
$info['interests'] = $row['interests_text'];
$info['interests'] = str_replace('%%%', '<br/>',
esc_html($row['interests_text'])
);
// $info['address'] = $row['address'];
// $info['city'] = $row['city'];
// $info['postal_code'] = $row['postal_code'];
......@@ -353,8 +357,13 @@ echo '<h2>Sorry, '.$target_name.' did not mention any keywords ... we cannot pr
If you are '.$target_name.', you can <a href="/services/user/profile" target="_BLANK">modify your profile</a> and see your
network in few minutes.';
}else{
echo $header;
echo $content;
echo '<body>
<div class="container full-directory">
<div class="hero-unit">';
echo $header;
echo '';
echo $content;
}
exit(0);
......
......@@ -346,16 +346,38 @@ div.ccsection-footer {
}
/*in directory view*/
.full-directory {
margin: 0 25;
}
.container.inner {
width: 100%;
}
.scholars-list {
}
.interests-of-scholar p {
font-size: 1.2em !important;
line-height: 1.3em !important;
margin-top: -.5em;
}
.keywords-of-scholar {
}
.url-of-scholar {
margin-top: .5em;
}
.pic-of-scholar {
/*margin: 7px 25px 15px 0px;*/
}
.labs-of-scholar {
font-style: italic;
}
.institutions-of-scholar {
font-variant: small-caps;
font-style: italic;
/*font-variant: small-caps;*/
font-family: sans;
}
.rel-inst-locname {
font-size: 75%;
font-size: 90%;
}
......
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