-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
443 lines (398 loc) · 16.8 KB
/
index.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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
<!DOCTYPE html>
<?php
require_once("include/utils.php");
// Avant d'afficher quoi que ce soit de dynamique, on va aller récupérer les résultats en fonction des paramètres
$q = getParam("q");
$statut = getParam("statut");
$current_page = getParam("page");
isset($_GET['limit']) ? ($limit = $_GET['limit']) : $limit = $par_page;
isset($_GET['sort']) ? ($sort = $_GET['sort']) : $sort = 'dateSoutenance+desc';
$sortLabel = 'Par date de soutenance';
if($sort == 'dateSoutenance desc'){
$sortLabel = 'Par date de soutenance';
}
elseif($sort == 'titreTri asc'){
$sortLabel = 'Par titre';
}
elseif($sort == 'disciplineTri asc'){
$sortLabel = 'Par discipline';
}
if (!$current_page){
$current_page = 1;
}
$checkedFacetsObj = new stdClass();
$i = 0;
$checkedFacetsObj->etablissement->$i = $etab_star;
$checkedFacetsObj = initObjWithVars('discipline', $checkedFacetsObj);
$checkedFacetsObj = initObjWithVars('ecoleDoctorale', $checkedFacetsObj);
$checkedFacetsObj = initObjWithVars('langueThese', $checkedFacetsObj);
$checkedFacetsObj = initObjWithVars('directeurTheseNP', $checkedFacetsObj);
$checkedFacets = "";
foreach($checkedFacetsObj as $key => $value) {
foreach($checkedFacetsObj->$key as $v) {
$checkedFacets .= $key."=".urlencode($v).";";
}
}
$current_year = date("Y");
$dateSoutenance ="[1965-01-01T23:59:59Z TO ".$current_year."-12-31T23:59:59Z]";
$url = "http://www.theses.fr/?q=".urlencode($q)."&checkedfacets=".$checkedFacets."&maxnumber=".$limit."&sort=".$sort."&fq=dateSoutenance:".urlencode($dateSoutenance);
$stLabel = "";
if ($statut == "encours")
{
$stLabel = "En préparation";
$url = str_replace("www.theses.fr", "www.theses.fr/sujets", $url);
}
elseif ($statut == "fini")
{
$stLabel = "Soutenue";
$url .= "&status=status:soutenue";
}
elseif ($statut == "finidispo")
{
$stLabel = "Soutenue et accessible en ligne";
$url .= "&status=status:soutenue&access=accessible:oui";
}
$currentUrl = curPageURL();
$urljson = $url ."&start=".(($current_page - 1)*$par_page)."&format=json";
$json = getResponse($urljson, $proxy_server, $proxy_port);
$thesefr = json_decode($json);
if(is_object($thesefr)){
$numFound = $thesefr->response->numFound;
}
else {
$numFound = '';
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Mobile viewport optimization h5bp.com/ad -->
<meta name="HandheldFriendly" content="True">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title><?php echo $titre_page; ?></title>
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<!--
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,700,600,800' rel='stylesheet' type='text/css'>
<link href="css/custom.css" rel="stylesheet">
<link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<!-- HEADER -->
<div id="header-navbar" class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<a href="<?php echo $base_url; ?>" class="navbar-brand"><i class="fa fa-mortar-board "></i> <?php echo $titre_page; ?></a>
</div>
</div>
</div>
<!-- SEARCH FORM -->
<div id="search-navbar" class="navbar navbar-default navbar-static-top " role="navigation">
<div class="container">
<form accept-charset="UTF-8" action="<?php echo $base_url; ?>" class="search-query-form form-inline clearfix navbar-form" method="get">
<div class="input-group">
<label for="q" class="sr-only">Votre recherche...</label>
<input class="search_q q form-control" id="q" name='q' placeholder="Votre recherche..." type="text" autofocus="autofocus" <?php if ($q) print "value='$q'"; ?>/>
<span class="input-group-btn">
<button type="submit" class="btn btn-primary search-btn" id="search">
<span class="fa fa-search"></span>
</button>
</span>
</div>
</form>
</div>
</div>
<!-- CONTAINER -->
<div id="main-container" class="container">
<!-- SIDEBAR -->
<div class="row">
<div id="sidebar" class="col-md-3">
<div id="facets" class="facets sidenav">
<!-- FACETS -->
<div class="top-panel-heading panel-heading">
<button type="button" class="facets-toggle" data-toggle="collapse" data-target="#facet-panel-collapse">
<span class="sr-only">Déplier les facettes</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<h4>
Affiner les résultats
</h4>
</div>
<div id="facet-panel-collapse" class="panel-group collapse" style="height: 0px;">
<div class="panel panel-default facet_limit theses-status">
<div data-target="#facet-status" data-toggle="collapse" class="collapse-toggle panel-heading">
<h5 class="panel-title"><a href="#" data-no-turbolink="true">Statut</a></h5>
</div>
<div class="panel-collapse facet-content collapse in" id="facet-status" style="height: auto;">
<div class="panel-body facet-panel">
<ul class="facet-values list-unstyled">
<?php echo facetteStatut();?>
</ul>
</div>
</div>
</div>
<?php
echo getfacets($thesefr,'ecoleDoctorale', $checkedFacetsObj,$_GET);
echo getfacets($thesefr,'discipline', $checkedFacetsObj,$_GET);
echo getfacets($thesefr,'langueThese', $checkedFacetsObj,$_GET);
echo getfacets($thesefr,'directeurTheseNP', $checkedFacetsObj,$_GET);
?>
</div>
<!-- ADS THESES.FR -->
<div class="well" style='background:white'>
Consultez l'ensemble des thèses françaises depuis 1985, soutenues et en cours de préparation sur :<br/><br/>
<a href='http://www.theses.fr'><img class="thesefr-img" src='img/logo_thesesfr.gif'/></a>
</div>
</div>
</div>
<div id="content" class="col-md-8">
<h2 class="sr-only top-content-title">Search</h2>
<?php
if((isset($q) && !empty($q)) || (isset($checkedFacets) && ($checkedFacets != "etablissement=".urlencode($etab_star).";")) || (isset($statut) && !empty($statut))){
?>
<div id="appliedParams" class="clearfix constraints-container">
<div class="pull-right">
<a class="catalog_startOverLink btn btn-sm btn-text" href="<?php echo $base_url; ?>" id="startOverLink">Voir toutes les thèses</a>
</div>
<span class="constraints-label">Votre recherche :</span>
<?php
$current_search = currentSearch($q,$checkedFacetsObj, $currentUrl, $stLabel);
foreach($current_search as $key => $value) {
echo "$value";
}
?>
</div>
<?php
}
$nb_pages = ceil($numFound/$limit);
$currentUrlNoPage = preg_replace("/&page=\d*/", "", $currentUrl);
if (!preg_match("/\?/", $currentUrlNoPage)){
$currentUrlNoPage .= "?";
}
if(!empty($numFound) && $numFound != '0'){
if ($current_page == 1 && $current_page != $nb_pages ){
$current_results_first = "1";
$current_results_last = $limit;
}
elseif ($current_page == $nb_pages){
$current_results_first = (($current_page-1)*$limit)+1;
$current_results_last = $current_results_first + (($limit - 1) - (($nb_pages * $limit) - $numFound));
}
else {
$current_results_first = (($current_page-1)* $limit)+1;
$current_results_last = ($current_page* $limit);
}
if ($current_page == 1) { $prev = ""; }
else { $prev = "<a href='$currentUrlNoPage&page=".($current_page - 1)."'> « Précédent</a> |";}
if ($current_page == $nb_pages) { $next = "";}
else { $next = " | <a href='$currentUrlNoPage&page=".($current_page + 1)."'>Suivant »</a>";}
?>
<!-- SORTS -->
<div id="sortAndPerPage" class="clearfix">
<div class="page_links">
<?php print $prev; ?>
<span class="page_entries">
<strong><?php print $current_results_first; ?></strong> - <strong><?php print $current_results_last; ?></strong> sur <strong><?php print $numFound; ?></strong>
</span>
<?php print $next; ?>
</div>
<div class="search-widgets pull-right">
<div class="btn-group" id="sort-dropdown">
<button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button">
<a href="#"><?php print $sortLabel; ?></a> <span class="caret"></span>
</button>
<ul role="menu" class="dropdown-menu">
<?php
print '<li><a href="'.removeqsvar($currentUrl, 'sort').'&sort=dateSoutenance+desc">Par date de soutenance</a></li>';
print '<li><a href="'.removeqsvar($currentUrl, 'sort').'&sort=titreTri+asc">Par titre</a></li>';
print '<li><a href="'.removeqsvar($currentUrl, 'sort').'&sort=disciplineTri+asc">Par discipline</a></li>';
?>
</ul>
</div>
<!-- PER PAGE -->
<span class="sr-only">Nombre de résultats par page</span>
<div class="btn-group" id="per_page-dropdown">
<button data-toggle="dropdown" class="btn btn-default dropdown-toggle" type="button"><a href="#"><?php print $limit; ?> par page</a> <span class="caret"></span></button>
<ul role="menu" class="dropdown-menu">
<?php
print '<li><a href="'.removeqsvar($currentUrl, 'limit').'&limit=10">10<span class="sr-only"> par page</span></a></li>';
print '<li><a href="'.removeqsvar($currentUrl, 'limit').'&limit=20">20<span class="sr-only"> par page</span></a></li>';
print '<li><a href="'.removeqsvar($currentUrl, 'limit').'&limit=50">50<span class="sr-only"> par page</span></a></li>';
?>
</ul>
</div>
</div>
</div>
<?php }
elseif($numFound == '0') {
?>
<!-- NO RESULTS -->
<h2>Aucun résultat trouvé</h2>
<div class="noresults" id="documents">
<h3>Essayez de modifier votre recherche</h3>
<ul>
<li>Utilisez moins de mots-clés puis affinez les résultats à l'aide des liens disponibles sur la gauche de la page.</li>
</ul>
</div>
<?php
}
?>
<!-- RESULTS -->
<h2 class="sr-only">Résultats</h2>
<div id="documents">
<?php
if(is_object($thesefr)){
foreach ($thesefr->response->docs as $doc)
{
$urlRdf = 'http://www.theses.fr/'.$doc->num.'.rdf';
$rdf = getResponse($urlRdf, $proxy_server, $proxy_port);
$rdf = str_replace('rdf:', 'rdf_', $rdf);
$rdf = str_replace('dc:', 'dc_', $rdf);
$rdf = str_replace('dcterms:', 'dcterms_', $rdf);
$rdf = str_replace('skos:', 'skos_', $rdf);
$rdf = str_replace('isbd:', 'isbd_', $rdf);
$rdf = str_replace('marcrel:', 'marcrel_', $rdf);
$rdf = str_replace('foaf:', 'foaf_', $rdf);
$rdf = str_replace('bibo:', 'bibo_', $rdf);
$xml = simplexml_load_string($rdf); // load a SimpleXML object
$jsonrdf = json_decode(json_encode($xml)); // use json to get all values into an array
if ($doc->accessible == "oui"){$uri = 'http://www.theses.fr/'.$doc->num.'/document';}
else{$uri = 'http://www.theses.fr/'.$doc->num;}
print "<div class='document' id='$doc->num'>";
print '<div class="documentHeader row">'."\n";
if ($doc->status == "soutenue" ){
print "<div class='nnt' style='display:none'>".$doc->num."</div>";
}
print "<h4 class='index_title titre_". $doc->num ." col-sm-10 col-lg-10'><a target='_blank' href='".$uri."'>".$doc->titre."</a></h4>";
print "</div>";
print '<div class="documentDetail row">'."\n";
print '<div class="index-document-functions col-sm-10 col-lg-10">'."\n";
print '<dl class="document-metadata dl-horizontal dl-invert">';
print '<dt class="these-author_display">Auteur</dt>';
print '<dd class="these-author_display">'.$doc->auteur.'</dd>';
if(isset($jsonrdf->bibo_Thesis->dcterms_abstract)){
if(is_array($jsonrdf->bibo_Thesis->dcterms_abstract)){
print '<dt class="these-abstract_display">Résumé</dt>';
print '<dd class="these-abstract_display"><a data-toggle="collapse" data-parent="#accordion" href="#collapseAbstract'. $doc->num .'">Lire le résumé</a></dd>';
$first = true;
foreach ($jsonrdf->bibo_Thesis->dcterms_abstract as $abstract){
if ( $first ){
print ' <dd id="collapseAbstract'. $doc->num .'" class="panel-collapse collapse"><div class="abstract">'.$abstract.'</div></dd>';
$first = false;
}
}
}
else {
if (is_string($jsonrdf->bibo_Thesis->dcterms_abstract)){
print '<dt class="these-abstract_display">Résumé</dt>';
print '<dd class="these-abstract_display"><a data-toggle="collapse" data-parent="#accordion" href="#collapseAbstract'. $doc->num .'">Lire le résumé</a></dd>';
print ' <dd id="collapseAbstract'. $doc->num .'" class="panel-collapse collapse"><div class="abstract">'.$jsonrdf->bibo_Thesis->dcterms_abstract.'</div></dd>';
}
}
}
print '<dt class="these-subject">Disicipline</dt>';
print '<dd class="these-subject"><a href="'.$base_url.'?discipline[]='.urlencode($doc->discipline).'">'.$doc->discipline.'</a></dd>';
print '<dt class="these-author_display">Date</dt>';
if (isset($doc->dateSoutenance)){
print "<dd class='these-date_display'>Soutenue le ".date('d/m/Y', strtotime($doc->dateSoutenance))."</dd>";
}
if (isset($doc->sujDatePremiereInscription)){
print "<dd class='these-date_display'>En préparation depuis le ".date('d/m/Y', strtotime($doc->sujDatePremiereInscription))."</dd>";
}
if (isset($doc->sujDateSoutenancePrevue)){
print "<dd class='these-date_display'>Soutenance prévue le ".date('d/m/Y', strtotime($doc->sujDateSoutenancePrevue))."</dd>";
}
print '<dt class="these-director_display">Sous la direction de</dt>';
$i =0;
foreach ($doc->directeurTheseNP as $directeurTheseNP){
print '<dd class="these-director_display"><a href="'.$base_url.'?directeurTheseNP[]='.urlencode($directeurTheseNP).'">'.$doc->directeurThese[$i].'</a></dd>';
$i++;
}
print '<dt class="these-org">Organisme</dt>';
if(is_array($jsonrdf->bibo_Thesis->marcrel_dgg)){
foreach ($jsonrdf->bibo_Thesis->marcrel_dgg as $org){
print '<dd class="these-org">'.$org->foaf_Organization->foaf_name.'</dd>';
}
}
else {
print '<dd class="these-org">'.$jsonrdf->bibo_Thesis->marcrel_dgg->foaf_Organization->foaf_name.'</dd>';
}
if ($doc->status == "soutenue"){
print '<dt class="these-holdings_display">Disponibilité</dt>';
print '<dd class="index-document-functions acces_'.$doc->num.'">'."\n";
if ($doc->status == "soutenue"){
if ($doc->accessible == "oui"){
print '<div class="availability"><span class="label label-primary online">Web</span><a href="'.$uri.'" title="Disponible en ligne" target="_blank"> Accès libre en ligne</a></div>';
}
if ($doc->status == "soutenue"){
print '<div class="spinner"><i class="fa fa-spinner fa-spin fa-2x"></i></div>';
}
}
print '</dd>';
}
print '</dl>';
print '</div>';
print '<div class="col-sm-1 col-lg-1">'."\n";
if ($doc->status == "soutenue"){
print "<img src='img/soutenue.png' alt='Thèse soutenue' title='Thèse soutenue'/>";
if ($doc->accessible == "oui"){
}
}
elseif ($doc->status == "enCours"){
print "<img src='img/preparation.png' alt='Thèse en préparation' title='Thèse en préparation'/>";
}
print '</div>';
print '</div>';
print '</div>';
}
}
else {
?>
<!-- ERROR RETRIEVING THESES.FR -->
<div class="noresults" id="documents">
<h3>Le site <a href='theses.fr' target='_blank'>theses.fr</a> rencontre actuellement des difficultés</h3>
<ul>
<li>Merci de réessayer plus tard.</li>
</ul>
</div>
<?php
}
?>
</div>
<!-- PAGINATION -->
<?php
if(!empty($numFound) && $numFound != '0'){
?>
<div class="row record-padding">
<div class="col-md-9">
<?php
echo renderNavigation($cntAround = 2,$nb_pages,$current_page,$currentUrlNoPage) ;
?>
</div>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
</body>
</html>