|
From: mdw c. <myd...@li...> - 2002-02-20 22:07:05
|
MyDynaWeb CVS committal
Author : sukria
Project : mydynaweb
Module : htdocs
Dir : mydynaweb/htdocs
Modified Files:
comment.php
Log Message:
Some more stuff for the comment engine :
- navbar that provides threshold customization
- anchor link to messages
- smarter display than before ;)
===================================================================
RCS file: /cvsroot/mydynaweb/mydynaweb/htdocs/comment.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- comment.php 20 Feb 2002 15:48:18 -0000 1.19
+++ comment.php 20 Feb 2002 22:06:32 -0000 1.20
@@ -7,6 +7,7 @@
$DBH->open($dbName, $dbServer, $dbUser, $dbPass);
define("REACT", translate('REACT', $DBH));
+define("BASE_URL", ($PHP_SELF . "?" . $QUERY_STRING));
$ca = new cache($DBH);
if ($file_name=$ca->is_cached("COMMENT.$news", USER_LANG, ACTIVE_THEME))
@@ -50,6 +51,8 @@
$rqt2 = new query($DBH);
$rqt2->query($DBH, $sql) or send_sql_error($PHP_SELF, $sql, $rqt->error());
+//template init
+$template = read_template(THEMES_PATH."/comment.html");
$PAGE .= "";
@@ -59,16 +62,48 @@
///////////////
// Threshold
if (!isset($threshold)) {
- $threshold = -1;
+ $threshold = 0;
}
-// The react button
-$PAGE .= "<center><b><form action='add_comment.php'>
-<input type='hidden' name='num_news' value='$news'>
-<input type='submit' value='".translate("COMMENT_NEWS",$DBH)."'></form>
+// The navbar
+$PAGE .= "<center>
+<p>
+<hr>
+<table bgcolor='#eeeeee' align='center' width='100%'>
+<tr>
+ <td>
+ <form action='add_comment.php'>
+ <input type='hidden' name='num_news' value='$news'>
+ <input type='submit' value='".translate("NEW_THREAD",$DBH)."'>
+ </form>
+ </td>
+ <td>
+ <form action='comment.php'>
+ <input type='hidden' name='news' value='$news'>
+ ".translate("THRESHOLD", $DBH)."
+ <select name='threshold'>
+ <option value='-1'>".translate("NONE", $DBH)."</option>
+ <option value='0' selected>".translate("ONLY_THREADS", $DBH)."</option>
+ <option>1</option>
+ <option>2</option>
+ <option>3</option>
+ <option>4</option>
+ <option>5</option>
+ <option>10</option>
+ <option>15</option>
+ <option>20</option>
+ </select>
+
+ <input type='submit' value='OK'>
+ </form>
+ </td>
+
+</tr>
+</table>
</center>
-
-<p>";
+<hr>
+<p>
+";
$PAGE .= "<table width='100%'>";
@@ -80,7 +115,7 @@
// Step 2 : print out the threads
if ($num_comments) {
foreach ($get_parents as $thread) {
- $PAGE .= print_message($thread, 0, $threshold, $get_message, $get_children);
+ $PAGE .= print_message($thread, 0, $threshold, $get_message, $get_children, $template);
}
}
@@ -105,8 +140,9 @@
can draw messages and their children...
*/
-function print_message ($num_cmt, $level, $threshold, $get_message, $get_children)
+function print_message ($num_cmt, $level, $threshold, $get_message, $get_children, $template)
{
+
$HTML = "";
$get_message[$num_cmt]['REACT'] = REACT;
@@ -121,24 +157,25 @@
// a new thread
if ($level == 0) {
- $HTML .= "<tr><td>" . get_template(THEMES_PATH."/thread.html", $get_message[$num_cmt]) . "</td></tr>";
+ $HTML .= "<tr><td>" . get_hash_template($template["thread"], $get_message[$num_cmt]) . "</td></tr>";
}
// a comment fully displayed (under threshold)
else if (($threshold == -1) or ($threshold >= $level)) {
- $get_message[$num_cmt]['desc'] = ("Reply to ".$get_message[$get_message[$num_cmt]['pere']]['title']);
- $HTML .= "<tr><td>" . get_template(THEMES_PATH."/comment.html", $get_message[$num_cmt]) . "</td></tr>";
+ $pere = $get_message[$num_cmt]['pere'];
+ $get_message[$num_cmt]['desc'] = ("<a href='".BASE_URL."#$pere'>".$get_message[$pere]['title']."</a>");
+ $HTML .= "<tr><td>" . get_hash_template($template["comment"], $get_message[$num_cmt]) . "</td></tr>";
}
// a comment under the threshold : only the title
else {
$get_message[$num_cmt]['threshold'] = $level;
- $HTML .= "<tr><td>". get_template(THEMES_PATH."/comment_title.html", $get_message[$num_cmt])."</td></tr>";
+ $HTML .= "<tr><td>". get_hash_template($template["title"], $get_message[$num_cmt])."</td></tr>";
}
if (sizeof($get_children[$num_cmt])) {
foreach ($get_children[$num_cmt] as $child) {
- $HTML .= print_message($child, $level+1, $threshold, $get_message, $get_children);
+ $HTML .= print_message($child, $level+1, $threshold, $get_message, $get_children, $template);
}
}
|