Accéder au contenu.
Menu Sympa

devel - [Devel] r473 - in branches/generic: adl-specific adl-specific/templates includes

Objet : devel-adl

Archives de la liste

[Devel] r473 - in branches/generic: adl-specific adl-specific/templates includes


Chronologique Discussions 
  • From: svn AT agendadulibre.org
  • To: devel AT agendadulibre.org
  • Subject: [Devel] r473 - in branches/generic: adl-specific adl-specific/templates includes
  • Date: Fri, 23 Jul 2010 00:19:33 +0200 (CEST)
  • List-archive: <http://agendadulibre.org/pipermail/devel>
  • List-id: Developpement de l'Agenda du Libre <devel.agendadulibre.org>

Author: ploc
Date: Fri Jul 23 00:19:33 2010
New Revision: 473

Log:
adding template system

Added:
branches/generic/adl-specific/templates/
branches/generic/adl-specific/templates/footer.html
branches/generic/adl-specific/templates/header.html
Modified:
branches/generic/adl-specific/config.inc.php
branches/generic/adl-specific/special.inc.php
branches/generic/includes/funcs.inc.php

Modified: branches/generic/adl-specific/config.inc.php
==============================================================================
--- branches/generic/adl-specific/config.inc.php Thu Jul 22 23:12:42
2010 (r472)
+++ branches/generic/adl-specific/config.inc.php Fri Jul 23 00:19:33
2010 (r473)
@@ -6,6 +6,11 @@
$mailDomain = "agendadulibre.org"; /* domain used for sending
mails */
$rootUrl = "http://www.$mailDomain";; /* root url, without
trailing slash */

+/* template config */
+$headerTemplate = "$specificContent/templates/header.html";
+$footerTemplate = "$specificContent/templates/footer.html";
+
+/* main config */
$developerMail = "devel AT agendadulibre.org"; /* mail of developers */
$moderatorMail = "moderateurs AT agendadulibre.org"; /* mail of moderators */
$moderatorMail = "agenda AT survie.org";

Modified: branches/generic/adl-specific/special.inc.php
==============================================================================
--- branches/generic/adl-specific/special.inc.php Thu Jul 22 23:12:42
2010 (r472)
+++ branches/generic/adl-specific/special.inc.php Fri Jul 23 00:19:33
2010 (r473)
@@ -4,7 +4,7 @@
{
global $specificContent;

- echo <<<END
+ $other_countries_box = <<<END
<div id="important">
<p>
<a href="http://www.agendadulibre.org";><img style="vertical-align: middle;
margin-right: 1em; border: 0;" src="$specificContent/images/france.png"
title="Agenda du Libre France"/>France</a><br/>
@@ -14,6 +14,8 @@
</p>
</div>
END;
+
+ return $other_countries_box;
}

function calendar_custom_icon($year, $month, $day)

Added: branches/generic/adl-specific/templates/footer.html
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/generic/adl-specific/templates/footer.html Fri Jul 23 00:19:33
2010 (r473)
@@ -0,0 +1,15 @@
+</div>
+<div class="footer">
+<p><a href="submit.php">Proposer un évènement</a>
+ - <a href="rsslist.php">Flux RSS</a>
+ - <a href="icallist.php">Calendriers iCal</a>
+ - <a href="map.php">Carte</a>
+ - <a href="tags.php">Tags</a>
+ - <a href="infos.php">Informations</a>
+ - <a href="stats.php">Statistiques</a>
+ - <a href="mailto:%moderatorMail%";>Contact</a>
+ - <a href="moderation.php">Modération</a></p>
+</div>
+</body>
+</html>
+

Added: branches/generic/adl-specific/templates/header.html
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ branches/generic/adl-specific/templates/header.html Fri Jul 23 00:19:33
2010 (r473)
@@ -0,0 +1,67 @@
+<?xml version=\"1.0\" encoding=\"utf-8\"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
+<html xmlns="http://www.w3.org/1999/xhtml";>
+<head>
+ <title>%websiteName% - %title%</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <link rel="stylesheet" type="text/css" media="screen"
href="%specificContent%/css/calendar.css" />
+ <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
+
+%rss_feeds%
+%javascript%
+
+<!--TINY MCE-->
+ <script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
+ <script type="text/javascript">
+ tinyMCE.init({/**/
+ theme : "advanced",
+ mode : "exact",
+ language : "fr",
+ elements : "__event_description",
+ plugins : "inlinepopups",
+ theme_advanced_buttons1 :
"bold,italic,separator,bullist,numlist,separator,link,unlink,separator,undo,redo,separator,removeformat",
+ theme_advanced_buttons2 : "",
+ theme_advanced_buttons3 : "",
+ theme_advanced_toolbar_location : "top",
+ theme_advanced_resizing : true,
+ theme_advanced_resize_horizontal : false,
+ theme_advanced_statusbar_location : "bottom",
+ debug : false,
+ entity_encoding : "raw",
+ valid_elements : "" +
+"+a[rel|href|title]," +
+"-strong/-b," +
+"-em/-i," +
+"#p[]," +
+"-ol[]," +
+"-ul[]," +
+"-li[]," +
+ "br,"
+ });
+
+function toggleEditor() {
+ if (!tinyMCE.getInstanceById('__event_description'))
+ {
+ tinyMCE.execCommand('mceAddControl', false,
'__event_description');
+ document.getElementById('togglegeditor_text').innerHTML =
'Désactiver ';
+ }
+ else
+ {
+ tinyMCE.execCommand('mceRemoveControl',
false,'__event_description');
+ document.getElementById('togglegeditor_text').innerHTML =
'Activer ';
+ }
+}
+
+ </script>
+<!--/TINY MCE-->
+
+</head>
+
+%body%
+
+<div class="main">
+
+%other_countries_box%
+
+<h1><a href="index.php">%websiteName%</a></h1>
+<p id="subtitle"><em>%websiteSlogan%</em></p>

Modified: branches/generic/includes/funcs.inc.php
==============================================================================
--- branches/generic/includes/funcs.inc.php Thu Jul 22 23:12:42 2010
(r472)
+++ branches/generic/includes/funcs.inc.php Fri Jul 23 00:19:33 2010
(r473)
@@ -42,11 +42,12 @@

function rss_feed_header ($href, $title)
{
- echo "<link rel=\"alternate\" href=\"" . $href . "\" title=\"" . $title .
"\" type=\"application/rss+xml\" />";
+ return "<link rel=\"alternate\" href=\"" . $href . "\" title=\"" . $title
. "\" type=\"application/rss+xml\" />\n";
}

function put_header ($title, $jscriptcode = "", $onloadfunc = "")
{
+ global $headerTemplate;
global $specificContent;
global $websiteName;
global $websiteSlogan;
@@ -58,108 +59,77 @@
$region_list = $db->query ("select * from regions");

if ($region_list == FALSE)
- {
- error ("Erreur lors de la recherche des régions");
- put_footer();
- exit;
- }
+ {
+ error ("Erreur lors de la recherche des régions");
+ put_footer();
+ exit;
+ }

- echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
- ?>
+ $dynamicContent["websiteName"] = $websiteName;
+ $dynamicContent["title"] = $title;
+ $dynamicContent["specificContent"] = $specificContent;

-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd";>
-<html xmlns="http://www.w3.org/1999/xhtml";>
+ $rss_feeds = rss_feed_header("rss.php?region=all", $websiteName . ",
toutes les régions");
+ while ($row = mysql_fetch_object($region_list))
+ {
+ $rss_feeds .= rss_feed_header ("rss.php?region=" . $row->id,
$websiteName . ", " . $row->name);
+ }
+ $dynamicContent["rss_feeds"] = $rss_feeds;

-<head>
- <title><?php echo $websiteName;?> - <?php echo $title;?></title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <link rel="stylesheet" type="text/css" media="screen" href="<?php
echo $specificContent; ?>/css/calendar.css" />
- <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
-<?php
+ if ($jscriptcode) {
+ $javascript = $jscriptcode;
+ }
+ $dynamicContent["javascript"] = $javascript;

- rss_feed_header ("rss.php?region=all", $websiteName . ", toutes les
régions");
+ if ($onloadfunc)
+ $body = "<body onload=\"" . $onloadfunc . "\">";
+ else
+ $body = "<body>";
+ $dynamicContent["body"] = $body;

- while ($row = mysql_fetch_object($region_list))
- {
- rss_feed_header ("rss.php?region=" . $row->id, $websiteName . ", " .
$row->name);
- }
+ $dynamicContent["other_countries_box"] = other_countries_box();;

- if ($jscriptcode)
- echo $jscriptcode;
-?>
+ /* websiteName has already been initialized */

-<!--TINY MCE-->
- <script type="text/javascript" src="tiny_mce/tiny_mce.js"></script>
- <script type="text/javascript">
- tinyMCE.init({/**/
- theme : "advanced",
- mode : "exact",
- language : "fr",
- elements : "__event_description",
- plugins : "inlinepopups",
- theme_advanced_buttons1 :
"bold,italic,separator,bullist,numlist,separator,link,unlink,separator,undo,redo,separator,removeformat",
- theme_advanced_buttons2 : "",
- theme_advanced_buttons3 : "",
- theme_advanced_toolbar_location : "top",
- theme_advanced_resizing : true,
- theme_advanced_resize_horizontal : false,
- theme_advanced_statusbar_location : "bottom",
- debug : false,
- entity_encoding : "raw",
- valid_elements : "" +
-"+a[rel|href|title]," +
-"-strong/-b," +
-"-em/-i," +
-"#p[]," +
-"-ol[]," +
-"-ul[]," +
-"-li[]," +
- "br,"
- });
-
-function toggleEditor() {
- if (!tinyMCE.getInstanceById('__event_description'))
- {
- tinyMCE.execCommand('mceAddControl', false,
'__event_description');
- document.getElementById('togglegeditor_text').innerHTML =
'Désactiver ';
- }
- else
- {
- tinyMCE.execCommand('mceRemoveControl',
false,'__event_description');
- document.getElementById('togglegeditor_text').innerHTML =
'Activer ';
- }
-}
+ $dynamicContent["websiteSlogan"] = $websiteSlogan;

- </script>
-<!--/TINY MCE-->
-</head>
+ /* ---------- display ---------- */

-<?php
-if ($onloadfunc)
- echo "<body onload=\"" . $onloadfunc . "\">";
-else
- echo "<body>";
-?>
+ /* importing html template */
+ $htmlTemplate = file_get_contents($headerTemplate);

-<div class="main">
-<?php other_countries_box(); ?>
-<h1><a href="index.php"><?php echo $websiteName;?></a></h1>
-<p id="subtitle"><em><?php echo $websiteSlogan;?></em></p>
-<?php
- } //'
+ /* updating dynamic fields */
+ $htmlOutput = $htmlTemplate;
+ foreach ($dynamicContent as $key => $value) {
+ $htmlOutput = str_replace("%$key%", $value, $htmlOutput);
+ }
+
+ /* displaying dynamic html */
+ print $htmlOutput;
+
+} //'

function put_footer ()
{
-global $moderatorMail;
+ global $footerTemplate;
+ global $moderatorMail;
+
+ $dynamicContent["moderatorMail"] = scramble_email($moderatorMail);
+
+ /* ---------- display ---------- */
+
+ /* importing html template */
+ $htmlTemplate = file_get_contents($footerTemplate);
+
+ /* updating dynamic fields */
+ $htmlOutput = $htmlTemplate;
+ foreach ($dynamicContent as $key => $value) {
+ $htmlOutput = str_replace("%$key%", $value, $htmlOutput);
+ }
+
+ /* displaying dynamic html */
+ print $htmlOutput;

-?>
-</div>
-<div class="footer">
-<p><a href="submit.php">Proposer un évènement</a> - <a
href="rsslist.php">Flux RSS</a> - <a href="icallist.php">Calendriers iCal</a>
- <a href="map.php">Carte</a> - <a href="tags.php">Tags</a> - <a
href="infos.php">Informations</a> - <a href="stats.php">Statistiques</a> - <a
href="mailto:<?php echo scramble_email($moderatorMail); ?>">Contact</a> - <a
href="moderation.php">Modération</a></p>
-</div>
-</body>
-</html>
-<?php
} //'

function scramble_email ($email)




  • [Devel] r473 - in branches/generic: adl-specific adl-specific/templates includes, svn, 23/07/2010

Archives gérées par MHonArc 2.6.16.

Haut de le page