commit 3f6d8dd1d92a8b03de384f131745f8846a92da0b
parent f6bcc3fd64dc3c8d7cbbb53f6428638b10c43ef0
Author: Georges Dupéron <jahvascriptmaniac+github@free.fr>
Date: Wed, 4 Aug 2010 08:33:17 +0200
CSS et page d'accueil (très incomplète).
Diffstat:
10 files changed, 71 insertions(+), 7 deletions(-)
diff --git a/__cms__/code/chemin/chemin.php b/__cms__/code/chemin/chemin.php
@@ -46,14 +46,16 @@ class Chemin {
// Invariant de sécurité : la chaîne renvoyée ne commence ni ne
// termine par '/'.
- public function get($slash_debut = false) {
+ public function get($slash_debut = true) {
return ($slash_debut ? '/' : '') . join($this->segments, '/');
}
public function get_url($fin = "") {
// Config::get("url_base") DOIT se terminer par '/', tel que spécifié
// dans config.php.
- return Config::get("url_base") . $this->get() . '/' . $fin;
+ $ch = $this->get(false) . "/";
+ if ($ch == '/') $ch = '';
+ return Config::get("url_base") . $ch . $fin;
}
public function get_fs_stockage() {
diff --git a/__cms__/code/cms/page.php b/__cms__/code/cms/page.php
@@ -13,6 +13,8 @@ class Page {
$this->set_page($a, $b);
} else if ($type == "sendfile") {
$this->set_sendfile($a, $b);
+ } else if ($type == "raw") {
+ $this->set_raw($a, $b);
} else if ($type == "redirect") {
$this->set_redirect($a, $b);
}
@@ -30,6 +32,12 @@ class Page {
$this->type = "sendfile";
}
+ public function set_raw($données, $mime) {
+ $this->raw_données = $données;
+ $this->raw_mime = $mime;
+ $this->type = "raw";
+ }
+
public function set_redirect($destination, $params = "") {
if (!is_string($destination)) $destination = $destination->get_url();
$this->redirect_destination = $destination . $params;
@@ -42,11 +50,15 @@ class Page {
echo Squelette::enrober($this);
} else if ($this->type == "sendfile") {
Stockage::get_prop_sendfile($this->sendfile_chemin, $this->sendfile_prop);
+ } else if ($this->type == "raw") {
+ header("Content-Type: " . $this->raw_mime);
+ echo $this->raw_données;
} else if ($this->type == "redirect") {
echo "TODO : Redirection vers <a href=\""
. $this->redirect_destination . "\">"
. $this->redirect_destination . "</a>";
}
+ // TODO : else erreur
}
}
diff --git a/__cms__/code/modules/galerie/galerie-photo.php b/__cms__/code/modules/galerie/galerie-photo.php
@@ -46,7 +46,7 @@ class GaleriePhoto {
$ret .= affichage_texte_enrichi(Stockage::get_prop($chemin, "message"));
}
return new Page($ret, Stockage::get_prop($chemin, "titre"));
- } else if ($vue == "miniature") {
+ } else if ($vue == "miniature" || $vue == "mini") {
$ret = '<img src="' . $chemin->get_url("?vue=image_mini") . '"></img>';
return new Page($ret, Stockage::get_prop($chemin, "titre"));
@@ -55,6 +55,7 @@ class GaleriePhoto {
} else if ($vue == "image_mini") {
return new Page($chemin, "image_mini", "sendfile");
}
+ return new Page('',''); // TODO : devrait renvoyer une page d'erreur !
}
}
diff --git a/__cms__/code/modules/include.php b/__cms__/code/modules/include.php
@@ -2,6 +2,7 @@
require_once(dirname(__FILE__) . "/modules.php");
+require_once(dirname(__FILE__) . "/site/include.php");
require_once(dirname(__FILE__) . "/admin/include.php");
require_once(dirname(__FILE__) . "/forum/include.php");
require_once(dirname(__FILE__) . "/galerie/include.php");
diff --git a/__cms__/code/modules/site/include.php b/__cms__/code/modules/site/include.php
@@ -0,0 +1,5 @@
+<?php
+
+require_once(dirname(__FILE__) . "/site-index.php");
+
+?>
+\ No newline at end of file
diff --git a/__cms__/code/modules/site/site-index.php b/__cms__/code/modules/site/site-index.php
@@ -0,0 +1,33 @@
+<?php
+
+class SiteIndex {
+ public static function action($chemin, $action, $paramètres) {
+ if (isset($paramètres["nom_site"])) {
+ Stockage::set_prop($chemin, "nom_site", $paramètres["nom_site"]);
+ }
+
+ if (isset($paramètres["vue"])) {
+ return self::vue($chemin, $paramètres["vue"]);
+ } else {
+ return self::vue($chemin);
+ }
+ }
+
+ public static function vue($chemin, $vue = "normal") {
+ if ($vue == "normal") {
+ $ret = '';
+ $ret .= "<h1>" . Stockage::get_prop($chemin, "nom_site") . "</h1>";
+ $ret .= "<ul>";
+ $ret .= "<li><a href=\"" . $chemin->enfant("galerie")->get_url() . "\">Galerie</a>";
+ $ret .= "</ul>";
+ return new Page($ret, Stockage::get_prop($chemin, "nom_site"));
+ } else if ($vue == "css") {
+ return new Page(get_css(), "text/css", "raw");
+ }
+ return new Page('',''); // TODO : devrait renvoyer une page d'erreur !
+ }
+}
+
+Modules::enregister_module("SiteIndex", "site-index", "vue", "titre");
+
+?>
+\ No newline at end of file
diff --git a/__cms__/code/site/css.php b/__cms__/code/site/css.php
@@ -1,4 +1,7 @@
-.galerie img {
+<?php
+
+function get_css() {
+ return ".galerie img {
border: thin solid black;
padding: 0.1em;
}
@@ -10,4 +13,5 @@
.galerie li {
float: left;
margin: 1em;
+}";
}
\ No newline at end of file
diff --git a/__cms__/code/site/include.php b/__cms__/code/site/include.php
@@ -1,5 +1,6 @@
<?php
+require_once(dirname(__FILE__) . "/css.php");
require_once(dirname(__FILE__) . "/squelette.php");
?>
\ No newline at end of file
diff --git a/__cms__/code/site/squelette.php b/__cms__/code/site/squelette.php
@@ -9,6 +9,9 @@ class Squelette {
}
public static function en_tete($page) {
+ // TODO : chemin css relatif.
+ $chemin_css = new Chemin('/');
+ $chemin_css = $chemin_css->get_url('?vue=css');
return
'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
@@ -16,7 +19,7 @@ class Squelette {
<title>' . $page->titre . '</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="fr" />
- <link href="../style.css" rel="stylesheet" type="text/css" /><!-- TODO : chemin incorrect -->
+ <link href="' . $chemin_css . '" rel="stylesheet" type="text/css" />
</head>
<body>';
// <meta name="keywords" lang="fr" content="motcle1,mocle2" />
diff --git a/__cms__/donnees/__prop__type b/__cms__/donnees/__prop__type
@@ -1 +1 @@
-galerie-index
-\ No newline at end of file
+site-index
+\ No newline at end of file