|
From: mdw c. <myd...@li...> - 2001-09-04 21:31:15
|
MyDynaWeb CVS committal
Author : sukria
Project : mydynaweb
Module : htdocs
Dir : mydynaweb/htdocs/include
Modified Files:
gui.inc.php mydynaweb.libs.php templates.inc.php
Log Message:
*** MAJOR KERNEL MODIFICATIONS ***
The behavior of the templates engine has been enhanced.
Before, we needed to open and read template file each time
we wanted to send HTML output.
Now, with the new function, we are able to read a template file
once, and then access it through memory (thanks to the use of hash tables).
This makes pages to be sent really faster.
Precisely, I've added three functions in the library called
'templates.inc.php' :
* hashtable read_template (string $template_path)
=================================================
this function is to be called whenever you want to
put the content of a template file in a hash.
This the only place where the file is opened !
It returns a hashtable with the content of the file, splitted
according to the blocks defined in the templates.
For example a file like this :
<!-- BLOCK:FOO -->
my text here ~TEXT~
would make a hash like this :
$hash["FOO"] = "my text here ~TEXT~";
* string get_hash_template (string $hash_entry, hashtable $tokens)
==================================================================
returns the content of the string located in a particular
template hash entry with substituing its content with the tokens given.
In fact this function do the same as the old 'get_template' function but
it uses hash instead of opening the template file.
This saves IO time ;)
* void print_template_hash (...)
================================
Do the same as print_template but uses a hashtable instead of opening the file.
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/include/gui.inc.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -3 -r1.26 -r1.27
--- gui.inc.php 2001/08/26 18:52:52 1.26
+++ gui.inc.php 2001/09/04 21:30:44 1.27
@@ -7,11 +7,8 @@
//
///////////////////////////////////////////////////////
-///////////////////////////////////////////////////////
-//
-// The Top Bar
-//
-///////////////////////////////////////////////////////
+
+///////////////////////// functions /////////////////////////
function top_bar_query($DBH,$query,$field_top_bar)
{
@@ -138,17 +135,14 @@
-function get_piece_of_news($title, $text, $image, $image_alt, $link, $nbhit, $num_news, $num_cmt, $num_byte, $DBH)
+function get_piece_of_news($title, $text, $image, $image_alt, $link,
+ $nbhit, $num_news, $num_cmt, $num_byte, $DBH)
{
-
- if (! file_exists(THEMES_PATH)) {
- $ERR = new beeper();
- $ERR->send_file_error(THEMES_PATH, "check that your tempaltes directory is defined in mydynaweb.init.php");
- return(0);
- }
+ // set the hash templates
- $news_template = THEMES_PATH . "/news.html";
+$NEWS_HASH_TEMPLATE = read_template(THEMES_PATH . "/news.html");
+
$VALUES['PAGE_BOX_LINES'] = PAGE_BOX_LINES;
$VALUES['PAGE_TEXTE_BACK'] = PAGE_TEXTE_BACK;
$VALUES['PAGE_TITRE_BACK'] = PAGE_TITRE_BACK;
@@ -163,10 +157,10 @@
$VALUES['COMMENTS'] = translate("COMMENTS",$DBH);
$VALUES['NBCOMMENT'] = $num_cmt;
$VALUES['READ_MORE'] = "+" . $num_byte . " bytes";
-
$VALUES['COMMENT'] = translate("COMMENT",$DBH);
$VALUES['EMAIL_FRIEND'] = translate("EMAIL_FRIEND",$DBH);
- return(get_template($news_template, $VALUES));
+
+ return(get_hash_template($NEWS_HASH_TEMPLATE["ALL"], $VALUES));
}
@@ -224,20 +218,18 @@
function get_newsletter_form($DBH)
{
-
-
- $head = THEMES_PATH . "/area_h.html";
- $line = THEMES_PATH . "/area_l.html";
- $foot = THEMES_PATH . "/area_f.html";
- $VALUES['S_TITLE'] = translate("NEWS_LETTER",$DBH);
- $form = get_template($head, $VALUES);
+ $BOX_HASH_TEMPLATE = read_template(THEMES_PATH . "/box.html");
- $VALUES['TEXT'] = translate("ENTER_EMAIL", $DBH);
- $VALUES['VALUE'] = "<form name='emails' action='save_email.php'><input type='text' name='email' size='13'></form>";
- $form .= get_template($line, $VALUES);
- $form .= get_template($foot, $VALUES);
-
+ $VALUES['TITLE'] = translate("NEWS_LETTER",$DBH);
+ $form = get_hash_template($BOX_HASH_TEMPLATE["HEAD"], $VALUES);
+ $VALUES['CONTENT'] = translate("ENTER_EMAIL", $DBH);
+ $VALUES['CONTENT'] .= "<P>
+ <form name='emails' action='save_email.php'>
+ <input type='text' name='email' size='13'>
+ </form>";
+ $form .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
+ $form .= get_hash_template($BOX_HASH_TEMPLATE["FOOT"], $VALUES);
return($form);
}
@@ -245,46 +237,69 @@
function get_searchengine($seek, $DBH)
{
+ $BOX_HASH_TEMPLATE = read_template(THEMES_PATH . "/box.html");
+
if ($seek) {
-
- $search_tmpl = THEMES_PATH . "/search.html";
- $VALUES['NAME'] = translate('SEARCH', $DBH);
- $VALUES['VALUE'] = "<FORM name=\"seek\" action=\"seek.php3\"><font size='-1'><input type=\"text\" size=\"13\" name=\"kw\"></font></FORM>";
- $pannel = get_template($search_tmpl, $VALUES);
+ $VALUES['TITLE'] = translate('SEARCH', $DBH);
+ $VALUES['CONTENT'] = "<FORM name=\"seek\" action=\"seek.php3\">
+ <font size='-1'>
+ <input type=\"text\" size=\"13\" name=\"kw\">
+ </font>
+ </FORM>";
+ $pannel = get_hash_template($BOX_HASH_TEMPLATE["HEAD"], $VALUES) .
+ get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES) .
+ get_hash_template($BOX_HASH_TEMPLATE["FOOT"], $VALUES);
- }
+ }
return $pannel;
+
+ die();
}
function get_login_box($session, $show_login, $DBH)
{
+ $BOX_HASH_TEMPLATE = read_template(THEMES_PATH . "/box.html");
+
$login_box = "";
if ($show_login) {
-
- $login_tmpl = THEMES_PATH . "/login.html";
- $VALUES['NAME'] = translate('MEMBERS', $DBH);
+
+ $VALUES['TITLE'] = translate('MEMBERS', $DBH);
$login = get_login_from_session ($session, $DBH);
if (! $login) {
- $VALUES['VALUE'] = "<form name='login_form' action='set_session.php3' METHOD='POST'>
- <table align='center'>
- <tr><td valign=\"top\" align='center'><font size='-1'><input type=\"text\" name=\"user\" size=\"13\" value=\"".translate("USERNAME",$DBH)."\"></font></td></tr>
- <tr><td valign=\"top\" align='center'><font size='-1'><input type=\"password\" name=\"pass\" size=\"13\" value=\"password\"></font></td></tr>
- <tr><td valign='top' align=\"center\"><font size='-1'><input type=\"submit\" value=\"".translate("LOGIN",$DBH)."\"></font></td></tr>
- </table>
- </form>";
+ $VALUES['CONTENT'] = "<form name='login_form' action='set_session.php3' METHOD='POST'>
+ <table align='center'>
+ <tr><td valign=\"top\" align='center'>
+ <font size='-1'>
+ <input type=\"text\" name=\"user\" size=\"13\" value=\"".
+ translate("USERNAME",$DBH).
+ "\"></font></td></tr>
+ <tr><td valign=\"top\" align='center'>
+ <font size='-1'>
+ <input type=\"password\" name=\"pass\" size=\"13\" value=\"password\">
+ </font>
+ </td></tr>
+ <tr><td valign='top' align=\"center\"><font size='-1'>
+ <input type=\"submit\" value=\"".translate("LOGIN",$DBH)."\"></font>
+ </td></tr>
+ </table>
+ </form>";
} else {
- $VALUES['VALUE'] = translate('LOGGED_IN_AS', $DBH) . " $login<br><a href=\"logout\">[" . translate('LOGOUT', $DBH) . "]</a>";
+ $VALUES['CONTENT'] = translate('LOGGED_IN_AS', $DBH) .
+ " $login<br><a href=\"logout.php\">[" .
+ translate('LOGOUT', $DBH) . "]</a>";
}
- $login_box = get_template($login_tmpl, $VALUES);
+ $login_box = get_hash_template($BOX_HASH_TEMPLATE["HEAD"], $VALUES) .
+ get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES) .
+ get_hash_template($BOX_HASH_TEMPLATE["FOOT"], $VALUES);
}
return $login_box;
@@ -292,38 +307,36 @@
function get_control_panel($date, $flag, $time, $DBH)
{
-
-
- $head = THEMES_PATH . "/cp_h.html";
- $line = THEMES_PATH . "/cp_l.html";
- $foot = THEMES_PATH . "/cp_f.html";
+ $BOX_HASH_TEMPLATE = read_template(THEMES_PATH . "/box.html");
+
- $VALUES['S_TITLE'] = translate("CONTROL_PANEL",$DBH);
- $pannel = get_template($head, $VALUES);
+ $VALUES['TITLE'] = translate("CONTROL_PANEL",$DBH);
+ $pannel = get_hash_template($BOX_HASH_TEMPLATE["HEAD"], $VALUES);
if ($date) {
$today = date("Y/m/d");
- $VALUES['NAME'] = translate("TODAY",$DBH);
- $VALUES['VALUE'] = $today;
- $pannel .= get_template($line, $VALUES);
+ $VALUES['CONTENT'] = translate("TODAY",$DBH);
+ $VALUES['CONTENT'] .= " : " . $today . "<br>";
+ $pannel .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
}
if ($time) {
$date = date("H:i:s");
- $VALUES['NAME'] = translate("TIME",$DBH);
- $VALUES['VALUE'] = $date;
- $pannel .= get_template($line, $VALUES);
+ $VALUES['CONTENT'] = translate("TIME",$DBH);
+ $VALUES['CONTENT'] .= " : " . $date . "<br>";
+ $pannel .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
}
if ($flag) {
- $sql = "select name, flag from languages where id_lang='".USER_LANG."'";
- $rqt = new query($DBH);
- $rqt->query($DBH,$sql);
- $user_lang = $rqt->getrow();
- $flag = "<img border=\"0\" src=\"$user_lang[1]\" alt=\"$user_lang[0]\">";
- $VALUES['NAME'] = translate('LANGUAGE', $DBH);
- $VALUES['VALUE'] = "<a href=\"choose_da_language.php3\">$user_lang[0]</a>";
- $pannel .= get_template($line, $VALUES);
+ $sql = "select name, flag from languages where id_lang='".USER_LANG."'";
+ $rqt = new query($DBH);
+ $rqt->query($DBH,$sql);
+ $user_lang = $rqt->getrow();
+ $flag = "<img border=\"0\" src=\"$user_lang[1]\" alt=\"$user_lang[0]\">";
+ $VALUES['CONTENT'] = translate('LANGUAGE', $DBH);
+ $VALUES['CONTENT'] .= " : <a
+ href=\"choose_da_language.php3\">$user_lang[0]</a><br>";
+ $pannel .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
}
@@ -331,30 +344,39 @@
$the_theme = ACTIVE_THEME;
if (!strlen($the_theme)) { $the_theme = 'default'; }
$the_theme = "<a href='themes.php'>$the_theme</a>";
- $VALUES['NAME'] = '';
- $VALUES['VALUE'] = translate("THEME",$DBH) . " : " . $the_theme;
- $pannel .= get_template($line, $VALUES);
+ $VALUES['CONTENT'] = translate("THEME",$DBH) . " : " . $the_theme .
+ "<br>";
+ $pannel .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
}
if ($seek) {
- $VALUES['NAME'] = translate('SEARCH', $DBH);
- $VALUES['VALUE'] = "<FORM name=\"seek\" action=\"seek.php3\"><input type=\"text\" size=\"10\" name=\"kw\"></FORM>";
- $pannel .= get_template($line, $VALUES);
+ $VALUES['CONTENT'] = translate('SEARCH', $DBH);
+ $VALUES['CONTENT'] .= "<p>
+ <FORM name=\"seek\" action=\"seek.php3\"><input type=\"text\" size=\"10\" name=\"kw\"></FORM>";
+ $pannel .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
}
if ($login) {
- $VALUES['NAME'] = translate('MEMBERS', $DBH);
- $VALUES['VALUE'] = "<table><form name='foo' action='set_session.php3'>
- <tr><td valign=\"top\"><input type=\"text\" name=\"user\" size=\"8\" value=\"".translate("USERNAME",$DBH)."\"></td></tr>
- <tr><td valign=\"top\"><input type=\"password\" name=\"pass\" size=\"8\" value=\"password\"></td></tr>
- <tr><td align=\"center\"><input type=\"submit\" value=\"".translate("LOGIN",$DBH).":\"></td></tr>
- </form></table>";
- $pannel .= get_template($line, $VALUES);
+ $VALUES['CONTENT'] = translate('MEMBERS', $DBH);
+ $VALUES['CONTENT'] .= "<table><form name='foo' action='set_session.php3'>
+ <tr><td valign=\"top\">
+ <input type=\"text\" name=\"user\" size=\"8\" value=\"".
+ translate("USERNAME",$DBH).
+ "\"></td></tr>
+ <tr><td valign=\"top\">
+ <input type=\"password\" name=\"pass\" size=\"8\" value=\"password\">
+ </td></tr>
+ <tr><td align=\"center\">
+ <input type=\"submit\" value=\"".
+ translate("LOGIN",$DBH).
+ ":\"></td></tr>
+ </form></table>";
+ $pannel .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES);
}
- $pannel .= get_template($foot, $VALUES);
+ $pannel .= get_hash_template($BOX_HASH_TEMPLATE["FOOT"], $VALUES);
return($pannel);
}
@@ -370,35 +392,26 @@
function get_headlines($DBH, $site) {
- if (! file_exists(THEMES_PATH)) {
- $ERR = new beeper();
- $ERR->send_file_error(THEMES_PATH, "check that your tempaltes directory is defined in mydynaweb.init.php");
- return(0);
- }
-
+ $BOX_HASH_TEMPLATE = read_template(THEMES_PATH . "/box.html");
+
if (HEADLINES != "")
{
$headlines = new grabber($DBH);
$links = $headlines->getLinks($site);
- $head = THEMES_PATH . "/box_h.html";
- $line = THEMES_PATH . "/box_l.html";
- $foot = THEMES_PATH . "/box_f.html";
-
-
// getting the head of the box
- $VALUES['S_TITLE'] = $headlines->sites[$site][0];
- $VALUES['S_URL'] = $headlines->sites[$site][1];
- $PAGE = get_template($head, $VALUES);
+ $VALUES['TITLE'] = "<A HREF='" . $headlines->sites[$site][1] . "'>" .
+ $headlines->sites[$site][0] .
+ "</A>";
+ $PAGE = get_hash_template($BOX_HASH_TEMPLATE["HEAD"], $VALUES);
// putting the lines
while (list($title,$link) = each($links)) {
- $VALUES['LINK'] = $link;
- $VALUES['TITLE'] = $title;
- $PAGE .= get_template($line, $VALUES);
+ $VALUES['CONTENT'] = "<A HREF='$link'>$title</A>";
+ $PAGE .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES) . "<br>";
}
- $PAGE .= get_template($foot, $VALUES);
+ $PAGE .= get_hash_template($BOX_HASH_TEMPLATE["FOOT"], $VALUES);
}
else
{
@@ -445,11 +458,8 @@
function get_item_box ($num_item_box, $DBH)
{
-
- $head = THEMES_PATH . "/item_h.html";
- $line = THEMES_PATH . "/item_l.html";
- $foot = THEMES_PATH . "/item_f.html";
-
+ $BOX_HASH_TEMPLATE = read_template(THEMES_PATH . "/box.html");
+
$sql = "select titre, icon
from item_box_titles
where num_titre = $num_item_box";
@@ -476,9 +486,16 @@
else {
$VALUES['ICON'] = "images/pixel.gif";
}
+
- $VALUES['S_TITLE'] = $titre[0];
- $BOX = get_template ($head, $VALUES);
+ $TABLE_TITRE = "<table width='100%' border='0' cellpadding='2' cellspacing='0'><tr>
+ <td align='center' valign='middle' width='20'><img src='".$VALUES['ICON']."' width='16' height='16'></td>
+ <td align='center' width='100'>
+ <font size='-1'><b>$titre[0]</b></font></td></tr>
+ </table>";
+
+ $VALUES['TITLE'] = $TABLE_TITRE;
+ $BOX = get_hash_template ($BOX_HASH_TEMPLATE["HEAD"], $VALUES);
$sql = "select item_libelle, item_url, target
from item_box_content
@@ -490,15 +507,11 @@
while ($infos = $q->getrow()) {
- $VALUES['LINK'] = $infos[1];
- $VALUES['TITLE'] = $infos[0];
- $VALUES['TARGET'] = $infos[2];
-
- $BOX .= get_template($line, $VALUES);
+ $VALUES['CONTENT'] = "<A HREF='$infos[1]' TARGET='$infos[2]'>$infos[0]</A>";
+ $BOX .= get_hash_template($BOX_HASH_TEMPLATE["LINE"], $VALUES) . "<br>";
}
-
- $BOX .= get_template($foot, $VALUES);
+ $BOX .= get_hash_template($BOX_HASH_TEMPLATE["FOOT"], $VALUES);
return ($BOX);
}
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/include/mydynaweb.libs.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- mydynaweb.libs.php 2001/08/28 13:39:24 1.19
+++ mydynaweb.libs.php 2001/09/04 21:30:44 1.20
@@ -1,33 +1,5 @@
<?PHP
-/******************************************
-
- LIBRARIES TO USE
-
- *****************************************/
-
-include DYNA_ROOT . "/$db_file";
-include DYNA_ROOT . "/include/templates.inc.php";
-include DYNA_ROOT . "/include/datatypes.php";
-include DYNA_ROOT . "/include/gui.inc.php";
-include DYNA_ROOT . "/tools/content/graphic.php";
-include DYNA_ROOT . "/tools/content/mailer.php";
-include DYNA_ROOT . "/include/utils.inc.php";
-include DYNA_ROOT . "/tools/events/stats.php";
-include DYNA_ROOT . "/tools/events/session.php";
-include DYNA_ROOT . "/include/translate.inc.php";
-include DYNA_ROOT . "/include/objects.inc.php";
-include DYNA_ROOT . "/tools/events/alert.php";
-include DYNA_ROOT . "/tools/events/cache.php";
-include DYNA_ROOT . "/tools/admin/script_creator.php";
-include DYNA_ROOT . "/tools/content/rdf_grabber.php";
-include DYNA_ROOT . "/tools/content/url_grabber.php";
-include DYNA_ROOT . "/tools/content/rdf_maker.php";
-include DYNA_ROOT . "/tools/content/quoter.php";
-
-
-
-
/*****************************************
ENVIRONEMENT SETTINGS
@@ -80,5 +52,34 @@
}
+
+
+/******************************************
+
+ LIBRARIES TO USE
+
+ *****************************************/
+
+include DYNA_ROOT . "/$db_file";
+include DYNA_ROOT . "/include/templates.inc.php";
+include DYNA_ROOT . "/include/datatypes.php";
+include DYNA_ROOT . "/include/gui.inc.php";
+include DYNA_ROOT . "/tools/content/graphic.php";
+include DYNA_ROOT . "/tools/content/mailer.php";
+include DYNA_ROOT . "/include/utils.inc.php";
+include DYNA_ROOT . "/tools/events/stats.php";
+include DYNA_ROOT . "/tools/events/session.php";
+include DYNA_ROOT . "/include/translate.inc.php";
+include DYNA_ROOT . "/include/objects.inc.php";
+include DYNA_ROOT . "/tools/events/alert.php";
+include DYNA_ROOT . "/tools/events/cache.php";
+include DYNA_ROOT . "/tools/admin/script_creator.php";
+include DYNA_ROOT . "/tools/content/rdf_grabber.php";
+include DYNA_ROOT . "/tools/content/url_grabber.php";
+include DYNA_ROOT . "/tools/content/rdf_maker.php";
+include DYNA_ROOT . "/tools/content/quoter.php";
+
+
+
?>
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/include/templates.inc.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -3 -r1.20 -r1.21
--- templates.inc.php 2001/08/28 13:39:24 1.20
+++ templates.inc.php 2001/09/04 21:30:44 1.21
@@ -10,6 +10,117 @@
*******************************************/
+function init_main_values($template_path, $content, $titre, $DBH,$c, $IP='', $REFER='', $MSG='', $ZONE=99, $PAGE=99)
+///////////////////////////////////////////////////////////////
+// We define here each of main values used to print HTML output
+///////////////////////////////////////////////////////////////
+{
+ $news_sites = explode(",", HEADLINES);
+ for($i=0;$i<sizeof($news_sites);$i++) {
+ $VALUES["HEADLINES"] .= get_headlines($DBH, $news_sites[$i]);
+ }
+
+
+ $VALUES["TOPBAR"] = top_bar($DBH,$c);
+
+ $VALUES["NEWS_LETTER"] = get_newsletter_form($DBH);
+ $VALUES["SITE_TITLE"] = SITE_TITLE;
+ $VALUES["PAGE_TITLE"] = $titre;
+ $VALUES["WEBMASTER_EMAIL"] = WEBMASTER_EMAIL;
+ $VALUES["SITE_ROOT"] = SITE_ROOT;
+ $VALUES["LINKBAR"] = get_troving_bar($DBH);
+ $VALUES["PAGE_TITLE"]=$titre;
+ $VALUES["QUOTATION"]=get_quote();
+ $VALUES["MESSAGE"] = $MSG;
+
+ $VALUES["LEFT_CORNER"] = $titre;
+ $VALUES["CONTENT"] = $content;
+ $VALUES["TITLE"] = "<img src=\"".DOCUMENT_TITRE_IMAGE."\">";
+ $VALUES["RIGHT_CORNER"] = new_LastTopics($DBH);
+
+ $VALUES['SEARCH'] = get_searchengine(CP_SEARCH, $DBH);
+ //FIXME: doesnt work (DYNA_SESSION is undefined, surely because we are not in the main script)
+ $VALUES['LOGIN'] = get_login_box(DYNA_SESSION , CP_LOGIN, $DBH);
+ $VALUES["LINK_BOXES"] = get_link_boxes($DBH);
+ $VALUES["CONTROL_PANNEL"] = get_control_panel(CP_DATE,CP_LANG,CP_TIME,$DBH);
+
+ $VALUES["MYDYNAWEB_POWERED"] = translate("POWERED_BY",$DBH);
+
+ $VALUES["ZONE"] = $ZONE;
+ $VALUES["PAGE"] = $PAGE;
+
+
+ return ($VALUES);
+}
+
+
+function read_template($template_path)
+//////////////////////////////////////////////////////////////
+// sukria - 04/09/2001 - creation
+// read a template file and put its content in an hashtable.
+// keys are the block defined in the file by BLOCK:XXX
+// statement where XXX is the name of the block
+// then returns the hashtable
+//////////////////////////////////////////////////////////////
+{
+
+ if (! file_exists($template_path)) {
+ print "$template_path does not exists !";
+ die();
+ }
+
+ $file = file($template_path);
+ $hash_file = array();
+ $key = 'ALL';
+
+ for ($i=0;$i<sizeof($file);$i++) {
+ if (ereg("<!-- BLOCK:(.*) -->", $file[$i], $regs)) {
+ $key = $regs[1];
+ }
+ else {
+ $hash_file[$key] .= $file[$i];
+ }
+ }
+
+ return ($hash_file);
+}
+
+function get_hash_template($template_hash_entry, $tokens)
+///////////////////////////////////////////////////////////////
+// sukria - 04/09/2001
+// this fun return the substituted content of the
+// hash $template_hash_entry with the entries of
+// the hash $tokens :
+// ~KEY~ in the file $template is replaced with $tokens["KEY"]
+///////////////////////////////////////////////////////////////
+{
+
+
+ $OUT = "";
+
+
+ $words = explode("~", $template_hash_entry);
+
+ if (sizeof($words) > 1) {
+ $line = $template_hash_entry;
+ for ($j=0; $j<sizeof($words); $j++) {
+ if ($j % 2 != 0) {
+ $line = str_replace("~$words[$j]~", $tokens[$words[$j]], $line);
+ }
+ }
+ $OUT .= $line;
+ }
+ else {
+ $OUT .= ($template_hash_entry);
+ }
+
+
+ return($OUT);
+
+}
+
+
+
function get_template($template_path, $tokens)
///////////////////////////////////////////////////////////////
// sukria - 28/03/2001
@@ -46,73 +157,92 @@
}
-
-// open the template_path file and print it out
+function print_template_hash( $template_hash_entry, $content, $titre,
+ $DBH,$c, $IP='', $REFER='', $MSG='',
+ $ZONE=99, $PAGE=99)
+////////////////////////////////////////////////////////
+// open the t and print it out $template_hash_entry
// after replacing each keyword by its correct value
-
-function print_template($template_path, $content, $titre, $DBH,$c, $IP='', $REFER='', $MSG='', $ZONE=99, $PAGE=99)
+////////////////////////////////////////////////////////
{
+
+ $VALUES = init_main_values($template_hash_entry, $content, $titre,
+ $DBH,$c, $IP='', $REFER='', $MSG='',
+ $ZONE=99, $PAGE=99);
- // get the page name
- count_one_more($DBH, $IP, $REFER);
+ // get the page name
+ count_one_more($DBH, $IP, $REFER);
- $output = "";
+ $output = "";
- $news_sites = explode(",", HEADLINES);
- for($i=0;$i<sizeof($news_sites);$i++) {
- $VALUES["HEADLINES"] .= get_headlines($DBH, $news_sites[$i]);
- }
-
+ $file = explode("\n", $template_hash_entry);
+
+ for ($i=0; $i<sizeof($file); $i++) {
+
+ $words = explode("~", $file[$i]);
+
+ if (sizeof($words) > 1) {
+ $line = $file[$i];
+ for ($j=0; $j<sizeof($words); $j++) {
+ if ($j % 2 != 0) {
+ $line = str_replace("~$words[$j]~", $VALUES[$words[$j]], $line);
+ }
+ }
+ print $line;
+ $output .= $line;
+ }
+ else {
+ print ($file[$i]);
+ $output .= $file[$i];
+ }
+ }
- $VALUES["TOPBAR"] = top_bar($DBH,$c);
+ $ca = new cache($DBH);
+ $ca->write_file("$c.".USER_LANG.".".ACTIVE_THEME.".html",$output);
- $VALUES["NEWS_LETTER"] = get_newsletter_form($DBH);
- $VALUES["SITE_TITLE"] = SITE_TITLE;
- $VALUES["PAGE_TITLE"] = $titre;
- $VALUES["WEBMASTER_EMAIL"] = WEBMASTER_EMAIL;
- $VALUES["SITE_ROOT"] = SITE_ROOT;
- $VALUES["LINKBAR"] = get_troving_bar($DBH);
- $VALUES["PAGE_TITLE"]=$titre;
- $VALUES["QUOTATION"]=get_quote();
- $VALUES["MESSAGE"] = $MSG;
+ return;
+}
- $VALUES["LEFT_CORNER"] = $titre;
- $VALUES["CONTENT"] = $content;
- $VALUES["TITLE"] = "<img src=\"".DOCUMENT_TITRE_IMAGE."\">";
- $VALUES["RIGHT_CORNER"] = new_LastTopics($DBH);
-
- $VALUES['SEARCH'] = get_searchengine(CP_SEARCH, $DBH);
- //FIXME: doesnt work (DYNA_SESSION is undefined, surely because we are not in the main script)
- $VALUES['LOGIN'] = get_login_box(DYNA_SESSION , CP_LOGIN, $DBH);
- $VALUES["LINK_BOXES"] = get_link_boxes($DBH);
- $VALUES["CONTROL_PANNEL"] = get_control_panel(CP_DATE,CP_LANG,CP_TIME,$DBH);
- $VALUES["MYDYNAWEB_POWERED"] = translate("POWERED_BY",$DBH);
- $file = file($template_path);
-
- $VALUES["ZONE"] = $ZONE;
- $VALUES["PAGE"] = $PAGE;
+
+function print_template($template_path, $content, $titre,
+ $DBH,$c, $IP='', $REFER='', $MSG='',
+ $ZONE=99, $PAGE=99)
+////////////////////////////////////////////////////////
+// open the template_path file and print it out
+// after replacing each keyword by its correct value
+////////////////////////////////////////////////////////
+{
+
+ $VALUES = init_main_values($template_path, $content, $titre, $DBH,$c, $IP='', $REFER='', $MSG='', $ZONE=99, $PAGE=99);
+
+ // get the page name
+ count_one_more($DBH, $IP, $REFER);
+
+ $output = "";
- for ($i=0; $i<sizeof($file); $i++) {
+ $file = file($template_path);
+ for ($i=0; $i<sizeof($file); $i++) {
- $words = explode("~", $file[$i]);
+ $words = explode("~", $file[$i]);
if (sizeof($words) > 1) {
- $line = $file[$i];
- for ($j=0; $j<sizeof($words); $j++) {
- if ($j % 2 != 0) {
- $line = str_replace("~$words[$j]~", $VALUES[$words[$j]], $line);
- }
- }
- print $line;
- $output .= $line;
- }
- else {
- print ($file[$i]);
- $output .= $file[$i];
- }
- }
- $ca = new cache($DBH);
+ $line = $file[$i];
+ for ($j=0; $j<sizeof($words); $j++) {
+ if ($j % 2 != 0) {
+ $line = str_replace("~$words[$j]~", $VALUES[$words[$j]], $line);
+ }
+ }
+ print $line;
+ $output .= $line;
+ }
+ else {
+ print ($file[$i]);
+ $output .= $file[$i];
+ }
+ }
+
+ $ca = new cache($DBH);
$ca->write_file("$c.".USER_LANG.".".ACTIVE_THEME.".html",$output);
return;
|