-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
118 lines (115 loc) · 4.05 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
<?php
ini_set('display_errors', '1');
error_reporting(-1);
header( 'content-type: text/html; charset=utf-8' );
if ( !file_exists( $path = dirname(__FILE__)."/conf.php" ) ) {
echo '<h1>Problème de configuration, fichier conf.php introuvable.</h1>';
}
else {
$conf = include( $path );
}
include( dirname(dirname(__FILE__))."/Teinte/Web.php" );
include( dirname(dirname(__FILE__))."/Teinte/Base.php" );
$path = Teinte_Web::pathinfo(); // document demandé
$basehref = Teinte_Web::basehref(); //
$teinte = $basehref."../Teinte/";
// chercher le doc dans la base
$docid = current( explode( '/', $path ) );
if ( !file_exists( $conf['sqlite'] )) {
echo '<h1>Première installation ? Allez voir la page <a href="pull.php">pull.php</a> pour transformer vos fichiers XML.</h1>';
exit();
}
$base = new Teinte_Base( $conf['sqlite'] );
$query = $base->pdo->prepare("SELECT * FROM doc WHERE code = ?; ");
$query->execute( array( $docid ) );
$doc = $query->fetch();
$q = null;
if ( isset($_REQUEST['q']) ) $q=$_REQUEST['q'];
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title><?php
if( $doc ) echo $doc['title'].' — ';
echo $conf['title'];
?></title>
<link rel="stylesheet" type="text/css" href="<?= $teinte ?>tei2html.css" />
<link rel="stylesheet" type="text/css" href="<?= $basehref ?>../theme/obvil.css"/>
<link rel="stylesheet" type="text/css" href="<?= $basehref ?>gongora.css" />
</head>
<body id="top">
<div id="center">
<header id="header">
<h1><?php
if ( !$path && $base->search ) {
echo '<a href="'.$basehref.'">'.$conf['title'].'</a>';
}
else if ( !$path ) {
echo '<a href="https://obvil.sorbonne-universite.fr/projets/challe">OBVIL, '.$conf['title'].'</a>';
}
else {
echo '<a href="'.$basehref.'?'.$_COOKIE['lastsearch'].'">'.$conf['title'].'</a>';
}
?></h1>
<a class="logo" href="https://obvil.sorbonne-universite.fr/"><img class="logo" src="<?php echo $basehref; ?>../theme/img/logo-obvil.png" alt="OBVIL"></a>
</header>
<div id="contenu">
<aside id="aside">
<?php
if ( $doc ) {
// if (isset($doc['download'])) echo $doc['download'];
// auteur, titre, date
echo '
<header>
<a class="title" href="' . $basehref . $doc['code'] . '">'.$doc['title'].'</a>
</header>
<form action="#mark1">
<a title="Retour aux résultats" href="'.$basehref.'?'.$_COOKIE['lastsearch'].'"><img src="'.$basehref.'../theme/img/fleche-retour-corpus.png" alt="←"/></a>
<input name="q" value="'.str_replace( '"', '"', $base->p['q'] ).'"/><button type="submit">🔎</button>
</form>
';
// table des matières, quand il y en a une
if ( file_exists( $f="toc/".$doc['code']."_toc.html" ) ) readfile( $f );
}
// accueil ? formulaire de recherche général
else {
echo'
<form action="">
<input style="width: 100%;" name="q" class="text" placeholder="Rechercher de mots" value="'.str_replace( '"', '"', $base->p['q'] ).'"/>
<button type="reset" onclick="return Form.reset(this.form)">Effacer</button>
<button type="submit" style="float: right; ">Rechercher</button>
</form>
';
}
?>
</aside>
<div id="main">
<nav id="toolbar">
<?php
?>
</nav>
<div id="article" class="<?php echo $doc['class']; ?>">
<?php
if ( $doc ) {
$html = file_get_contents( "article/".$doc['code']."_art.html" );
if ( $q ) echo $base->hilite( $doc['id'], $q, $html );
else echo $html;
}
else if ( $base->search ) {
$base->biblio( array( "no", "date", "title", "occs" ), "SEARCH" );
}
// pas de livre demandé, montrer un rapport général
else {
$base->biblio( array( "date", "title" ) );
}
?>
<a id="gotop" href="#top">▲</a>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="<?= $teinte ?>Teinte.js">//</script>
<script type="text/javascript" src="<?= $teinte ?>Tree.js">//</script>
<script type="text/javascript" src="<?= $teinte ?>Sortable.js">//</script>
</body>
</html>