Browse Source

Première version avec un templating php basique.

nicolas 8 years ago
parent
commit
335e02d9c2
5 changed files with 160 additions and 71 deletions
  1. 0 71
      index.html
  2. 15 0
      index.php
  3. 52 0
      lib/db.php
  4. 54 0
      templates/tpl-index.php
  5. 39 0
      templates/tpl-main.php

+ 0 - 71
index.html

@@ -1,71 +0,0 @@
-<!DOCTYPE html>
-<html lang="fr-fr">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>Exégètes - Presse à Citron</title>
-
-    <!-- Bootstrap -->
-    <!-- <link href="bootstrap3/css/bootstrap.min.css" rel="stylesheet"> -->
-    <link href="style.css" rel="stylesheet">
-
-    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
-    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
-    <!--[if lt IE 9]>
-      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
-      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
-    <![endif]-->
-  </head>
-  <body id="index">
-    <h1>Presse à Citron</h1>
-
-    <p class="bievenue">
-      Choisis un projet ou bien <a href="#ajouter">ajoute un nouveau projet</a> !
-    </p>
-
-    <div class="éditer" id="ajouter">
-	<form>
-	<div class="form-group">
-	    <label for="projetNom">Nom du projet:</label>
-	    <input type="text" class="form-control" id="projetNom" name="projetNom" placeholder="Projet de mémoire">
-	</div>
-	<div class="form-group">
-	    <label for="projetId">Identifiant:</label>
-	    <input type="text" class="form-control" id="projetId" name="projetId" placeholder="(automatiquement suggéré en fonction du nom)">
-	</div>
-	<div class="form-group">
-	    <label for="projetDossier">Dossier: <a href="ajout-dossier.html">(Nouveau dossier ?)</a></label>
-	    <select name="dossier" id="dossiers" multiple="" class="form-control input-lg select2 select2-offscreen" tabindex="-1">
-		<option value="intveld">In 't Veld</option>
-		<option value="abroretention">Abrogation de la rétention des données</option>
-		<option value="tes">Fichier TES</option>
-		<option value="orangefail">#OrangeFail</option>
-		<option value="prishield">Privacy Shield</option>
-	    </select>
-	</div>
-	<div class="actions"> 
-	    <button type="submit" class="bouton">Ajouter</button>
-	</div>
-	</form>
-    </div>
-
-    <nav class="dossiers">
-    <h2>Liste des dossiers</h2>
-      <a href="/intveld/">In 't Veld</a>
-      <a href="/abroretention/">Abrogation de la rétention des données</a>
-    </nav>
-    
-    <nav class="projets">
-      <span class="heading">Projets</span>
-      <a href="/replique-premierministre-csi.html">Réplique Premier Ministre CSI</a>
-      <a href="/abro-tele2.html">MA Abrogation Tele2</a>
-    </nav>
-
-
-    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
-    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
-    <!-- Include all compiled plugins (below), or include individual files as needed -->
-    <script src="bootstrap3/js/bootstrap.min.js"></script>
-  </body>
-</html>

+ 15 - 0
index.php

@@ -0,0 +1,15 @@
+<?php
+
+require_once 'lib/db.php';
+
+//ini_set('display_errors', 1);
+//ini_set('display_startup_errors', 1);
+//error_reporting(E_ALL);
+
+//phpinfo();
+//die();
+
+$db = new DB();
+$db->GetProjects();
+
+require_once('templates/tpl-index.php');

+ 52 - 0
lib/db.php

@@ -0,0 +1,52 @@
+<?php
+
+class DB extends SQLite3 {
+	
+	private $db = null;
+	
+	public function __construct () {
+		
+	}
+	
+	private function ensure_connection () {
+		if (!is_null($this->db))
+			return;
+		
+		$this->open('db.sqlite');
+		
+		if (!$this->ensure_tables()) {
+			echo "error";
+			return;
+		}
+	}
+	
+	private function ensure_tables () {
+		try {
+			$this->query('SELECT * FROM projects LIMIT 1');
+			return true;
+		} catch (Exception $e) {
+			try {
+				$this->query('
+					CREATE TABLE projects (
+						name varchar(128),
+						slugname varchar(128),
+						dossier varchar(128),
+						cloud_link varchar(1024),
+						wiki_link varchar(1024),
+						last_edit_date datetime
+					)
+				');
+			} catch (Exception $e) {
+				var_dump($e);
+			}
+			return false;
+		}
+	}
+	
+	public function GetProjects () {
+		$this->ensure_connection();
+		
+		return [];
+	}
+	
+}

+ 54 - 0
templates/tpl-index.php

@@ -0,0 +1,54 @@
+<?php
+
+function content () {
+?>
+
+<h1>Presse à Citron</h1>
+
+<p class="bievenue">
+	Choisis un projet ou bien <a href="#ajouter">ajoute un nouveau projet</a> !
+</p>
+
+<div class="éditer" id="ajouter">
+	<form>
+		<div class="form-group">
+			<label for="projetNom">Nom du projet:</label>
+			<input type="text" class="form-control" id="projetNom" name="projetNom" placeholder="Projet de mémoire">
+		</div>
+		<div class="form-group">
+			<label for="projetId">Identifiant:</label>
+			<input type="text" class="form-control" id="projetId" name="projetId" placeholder="(automatiquement suggéré en fonction du nom)">
+		</div>
+		<div class="form-group">
+			<label for="projetDossier">Dossier: <a href="ajout-dossier.html">(Nouveau dossier ?)</a></label>
+			<select name="dossier" id="dossiers" multiple="" class="form-control input-lg select2 select2-offscreen" tabindex="-1">
+				<option value="intveld">In 't Veld</option>
+				<option value="abroretention">Abrogation de la rétention des données</option>
+				<option value="tes">Fichier TES</option>
+				<option value="orangefail">#OrangeFail</option>
+				<option value="prishield">Privacy Shield</option>
+			</select>
+		</div>
+		<div class="actions"> 
+			<button type="submit" class="bouton">Ajouter</button>
+		</div>
+	</form>
+</div>
+
+<nav class="dossiers">
+	<h2>Liste des dossiers</h2>
+	<a href="/intveld/">In 't Veld</a>
+	<a href="/abroretention/">Abrogation de la rétention des données</a>
+</nav>
+
+<nav class="projets">
+	<span class="heading">Projets</span>
+	<a href="/replique-premierministre-csi.html">Réplique Premier Ministre CSI</a>
+	<a href="/abro-tele2.html">MA Abrogation Tele2</a>
+</nav>
+
+<?php
+}
+
+require_once('templates/tpl-main.php');
+main();

+ 39 - 0
templates/tpl-main.php

@@ -0,0 +1,39 @@
+<?php
+
+
+function main () {
+?>
+
+<!DOCTYPE html>
+<html lang="fr-fr">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>Exégètes - Presse à Citron</title>
+
+    <!-- Bootstrap -->
+    <!-- <link href="bootstrap3/css/bootstrap.min.css" rel="stylesheet"> -->
+    <link href="style.css" rel="stylesheet">
+
+    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
+    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
+    <!--[if lt IE 9]>
+      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
+      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
+    <![endif]-->
+  </head>
+  <body id="index">
+		
+		<?php content(); ?>
+		
+		 <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
+    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
+    <!-- Include all compiled plugins (below), or include individual files as needed -->
+    <script src="bootstrap3/js/bootstrap.min.js"></script>
+		
+	</body>
+</html>
+
+<?php
+} // end function main