This repository has been archived by the owner on Feb 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_directory.php
executable file
·351 lines (302 loc) · 11.1 KB
/
print_directory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
<?php
include ("comex_library.php");
include ("parametres.php");
include ("normalize.php");
//include("../common/library/fonctions_php.php");
$meta = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Complex Systems Scholars</title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- Le styles -->
<link href="css/bootstrap_iscpif.css" rel="stylesheet">
<link href="css/bootstrap_directory.css" rel="stylesheet">
<link type="text/css" href="css/brownian-motion/jquery-ui-1.8.16.custom.css">
<link href="http://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery/jquery-1.7.min.js"></script>
<script type="text/javascript" src="js/jquery-ui/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript" src="js/bootstrap/bootstrap-dropdown-fade.js"></script>
<script type="text/javascript" src="js/misc/underscore.min.js"></script>
<script type="text/javascript" src="js/jquery/jquery.highlight-3.js"></script>
<script type="text/javascript" src="js/misc/json2.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="Highcharts-2.2.0/js/highcharts.js"></script>
<script type="text/javascript" src="Highcharts-2.2.0/js/modules/exporting.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<link href="css/whoswho.css" rel="stylesheet" type="text/css">
<link rel="shortcut icon" href="images/favicon.ico">
<link rel="apple-touch-icon" href="images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push([\'_setAccount\', \'UA-30062222-1\']);
_gaq.push([\'_setDomainName\', \'communityexplorer.org\']);
_gaq.push([\'_trackPageview\']);
(function() {
var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
';
define('_is_utf8_split', 5000);
function is_utf8($string) {
// From http://w3.org/International/questions/qa-forms-utf-8.html
return preg_match('%^(?:
[\x09\x0A\x0D\x20-\x7E] # ASCII
| [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte
| \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs
| [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte
| \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates
| \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3
| [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15
| \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16
)*$%xs', $string);
}
$data = json_decode($_GET['query']);
function objectToArray($d) {
if (is_object($d)) {
// Gets the properties of the given object
// with get_object_vars function
$d = get_object_vars($d);
}
if (is_array($d)) {
/*
* Return array converted to object
* Using __FUNCTION__ (Magic constant)
* for recursive call
*/
return array_map(__FUNCTION__, $d);
}
else {
// Return array
return $d;
}
}
$data = objectToArray($data);
$categorya = $data["categorya"];
$categoryb = $data["categoryb"];
$countries = $data["countries"];
$keywords = $data["keywords"];
$laboratories = $data["laboratories"];
$organizations = $data["organizations"];
$tags = $data["tags"];
$query_details='<ul>';
$f = "";// requête
$labfilter='';
if ($tags) {
if (sizeof($tags) > 0) {
$f .= 'AND (';
}
$query_details.='<li><strong>Community tags: </strong>';
foreach ($tags as $kw) {
$words = explode(',', $kw);
$i = 0;
foreach ($words as $word) {
$word = sanitize_input(trim(strtolower($word)));
if ($word == "") continue;
if ($i > 0)
$f .= " OR ";
$f .= 'tags LIKE "%' . $word . '%" ';
$query_details.=$word.', ';
$i++;
}
}
$f .= ") ";
}
if ($keywords) {
if (sizeof($keywords) > 0) {
$f .= 'AND (';
}
$query_details.='<li><strong>Working on: </strong>';
foreach ($keywords as $kw) {
$words = explode(',', $kw);
$i = 0;
foreach ($words as $word) {
$word = sanitize_input(trim(strtolower($word)));
if ($word == "") continue;
$query_details.=$word.', ';
if ($i > 0)
$f .= " OR ";
$f .= 'keywords LIKE "%' . $word . '%" ';
$i++;
}
}
$f .= ") ";
}
if ($countries) {
if (sizeof($countries) > 0) {
$f .= 'AND (';
}
$query_details.='<li><strong>In the following country: </strong>';
$i = 0;
foreach ($countries as $country) {
//$country = sanitize_input(trim(strtolower($country)));
$country = sanitize_input(trim($country ));
if ($country == "") continue;
if ($i > 0)
$f .= " OR ";
$f .= 'country = "' . $country . '" ';
$query_details.=$country.', ';
$i++;
}
$f .= ") ";
}
if ($laboratories) {
if (sizeof($laboratories) > 0) {
$f .= 'AND (';
}
$query_details.='<li><strong>In the lab named : </strong>';
$i = 0;
foreach ($laboratories as $lab) {
$lab = sanitize_input(trim(strtolower($lab)));
if ($lab == "") continue;
if ($i > 0)
$f .= " OR ";
$f .= 'lab LIKE "%' . $lab . '%" ';
$query_details.=$lab.', ';
$i++;
}
$f .= ") ";
}
if ($organizations) {
if (sizeof($organizations) > 0) {
$f .= 'AND (';
}
$query_details.='<li><strong>In the organization named : </strong>';
$i = 0;
foreach ($organizations as $org) {
$org = sanitize_input(trim(strtolower($org)));
if ($org == "") continue;
$query_details.=$org.', ';
$f .= 'affiliation LIKE "%' . $org . '%" OR affiliation2 LIKE "%' . $org . '%" ';
//'affiliation LIKE "%' . $org . '% OR affiliation2 LIKE "%' . $org . '%"';
$i++;
}
$f .= ") ";
}
$query_details.='</ul>';
$base = new PDO("sqlite:" . $dbname);
$termsMatrix = array(); // liste des termes présents chez les scholars avec leurs cooc avec les autres termes
$scholarsMatrix = array(); // liste des scholars avec leurs cooc avec les autres termes
$scholarsIncluded = 0;
// liste des chercheurs
if (substr($f, 0,3)=='AND'){
$f=substr($f,3,-1);
}
if (substr($labfilter, 0,3)=='AND'){
$labfilter=substr($labfilter,3,-1);
}
$imsize = 150;
$content='';
if (strlen($f)>0){
$sql = "SELECT * FROM scholars where " . " " . $f.' ORDER BY last_name';
}else{
$sql = "SELECT * FROM scholars ORDER BY last_name";
}
//echo $sql.'<br/>';
// liste des chercheurs
$scholars = array();
//$query = "SELECT * FROM scholars";
foreach ($base->query($sql) as $row) {
$info = array();
$info['unique_id'] = $row['unique_id'];
$info['first_name'] = $row['first_name'];
$info['initials'] = $row['initials'];
$info['last_name'] = $row['last_name'];
$info['nb_keywords'] = $row['nb_keywords'];
$info['css_voter'] = $row['css_voter'];
$info['css_member'] = $row['css_member'];
$info['keywords_ids'] = explode(',', $row['keywords_ids']);
$info['keywords'] = $row['keywords'];
$info['status'] = $row['status'];
$info['country'] = $row['country'];
$info['homepage'] = $row['homepage'];
$info['lab'] = $row['lab'];
$info['affiliation'] = $row['affiliation'];
$info['lab2'] = $row['lab2'];
$info['affiliation2'] = $row['affiliation2'];
$info['homepage'] = $row['homepage'];
$info['title'] = $row['title'];
$info['position'] = $row['position'];
$info['photo_url'] = $row['photo_url'];
$info['interests'] = $row['interests'];
$info['address'] = $row['address'];
$info['city'] = $row['city'];
$info['postal_code'] = $row['postal_code'];
$info['phone'] = $row['phone'];
$info['mobile'] = $row['mobile'];
$info['fax'] = $row['fax'];
$info['affiliation_acronym'] = $row['affiliation_acronym'];
$scholars[$row['unique_id']] = $info;
}
/// stats
//$base = new PDO('sqlite:' . $dbname);
include ('stat-prep_from_array.php');///
include ("directory_content.php");
// liste des chercheurs
$content .= '</div>';
$content .= '</div>
<footer>
GENERATED BY <a href="http://iscpif.fr"><img src="css/branding/logo-iscpif_medium.png" alt="iscpif.fr" style="border: none; margin-bottom : -6px;" title="isc-pif" /></a>- <a href="http://sciencemapping.com" target="_BLANK">MOMA</a> - <a href="http://www.crea.polytechnique.fr/LeCREA/" target="_BLANK">CREA</a> - <a href="http://www.cnrs.fr/fr/recherche/index.htm" target="_BLANK">CNRS</a>
</footer>
</div>
</body>
</html>';
//////// Header
$header = '<div class="row" id="welcome">
<div class="span12" align="justify">
<img src="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';
if (strlen(trim($query_details))>3){
$header .= ': </p>'.$query_details;
}else{
$header .='.</p> ';
}
$header .='<p>Its aims are to foster interactions
between protagonists in the fields of Complex Systems science and Complexity
science, as well as to increase their visibility at the international scale.</p>
<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.
<li><i><b>This directory is browsable online</b> on the website of the complex systems society :</i> http://csbrowser.cssociety.org
</ul>
</p>
<p>
This directory is edited by the Complex Systems Registry. This initiative is supported by the <i>Complex Systems
Society</i> (<a href="http://cssociety.org">http://cssociety.org</a>).
</p>
<br/>
<p>Contributions and ideas are welcome to improve this directory.
<a href="http://css.csregistry.org/whoswho+feedback">Please feedback</a></p>
<br/>
<h2>Global statistics</h2>
<div id="country" style="width: 800px; height: 300px; margin: 0 auto"></div>
<div id="title" style="width: 800px; height: 300px; margin: 0 auto"></div>
<div id="position" style="width: 800px; height: 300px; margin: 0 auto"></div>
<br/>
<br/> <A NAME="scholars"> </A>
<h2>Scholars by alphabetical order</h2>
<br/>
<br/>
</div>
</div>';
echo $meta.' '.$stats.'</head>';
echo $header;
echo $content;
?>