00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#include "IWeb.h"
00026
#include "ThreadListForm.h"
00027
00028
00029
00030
00031 ThreadListForm::ThreadListForm(Web *w) :
BaseForm(w, "
ThreadListForm")
00032 {
00033 }
00034
00035
00036 ThreadListForm::~ThreadListForm()
00037 {
00038 }
00039
00040
00041 void ThreadListForm::Process()
00042 {
00043
IWeb *pWeb = static_cast<IWeb *>(GetWeb());
00044
00045
char action[200];
00046
00047
00048
if (GetForm() -> getvalue( (
char *)GetFormName().c_str(), action, 200) && *action)
00049 {
00050
if (!strcmp(action,
"view"))
00051 {
00052 std::string thread = GetForm() -> getvalue(
"thread");
00053
long num = atol(thread.c_str());
00054 pWeb -> SetThread( num );
00055 pWeb -> SetPage( 5 );
00056 }
00057 }
00058 }
00059
00060
00061 void ThreadListForm::Display(
long)
00062 {
00063
IWeb *pWeb = static_cast<IWeb *>(GetWeb());
00064 Database& db = pWeb -> GetDatabase();
00065 Query q(db);
00066 Query q2(db);
00067
char sql[1000];
00068
00069
00070 Navigator(pWeb -> GetForum());
00071
if (pWeb -> GetForum())
00072 {
00073 printf(
"</td><td align=center>");
00074 printf(
" [ <a href=\"%s?page=6\">new topic</a> ]",GetCgiName().c_str());
00075 }
00076 printf(
"</td><td align=right>");
00077
00078 printf(
"[ <a href=\"%s?page=2\">settings</a> ",GetCgiName().c_str());
00079 printf(
"| <a href=\"%s?logout=1\">logout</a> ",GetCgiName().c_str());
00080
00081 printf(
"]</td></tr></table>");
00082 printf(
"</div>");
00083
00084 sprintf(sql,
"select * from thread where forum=%ld and deleted=0 order by updated desc",pWeb -> GetForum());
00085 q.get_result(sql);
00086 printf(
"<table cellpadding=\"0\" cellspacing=\"0\" class=threadlist width=\"100%%\">");
00087 printf(
"<tr>");
00088 printf(
"<th class=threadlist>Image</th>");
00089 printf(
"<th class=threadlist>Topic</th>");
00090 printf(
"<th class=threadlist>Messages</th>");
00091 printf(
"<th class=threadlist>Started</th>");
00092
00093 printf(
"<th class=threadlist>Last</th>");
00094 printf(
"</tr>");
00095
while (q.fetch_row())
00096 {
00097 db::Thread thread(&db, &q);
00098 db::Account account(db, thread.started_by);
00099 printf(
"<tr class=threadlist>");
00100
00101 printf(
"<td class=threadlist width=\"1%%\">");
00102 viewtn( thread.image );
00103 printf(
"</td>");
00104
00105 printf(
"<td class=threadlist>", thread.title.c_str());
00106 printf(
"<a href=\"%s?ThreadListForm=view&thread=%ld\"> %s </a></td>",GetCgiName().c_str(),thread.num,thread.title.c_str());
00107
00108 sprintf(sql,
"select count(*) from message where thread=%ld and deleted=0",thread.num);
00109 printf(
"<td class=threadlist align=right width=\"1%%\">%ld</td>",q2.get_count(sql));
00110
00111 printf(
"<td class=threadlist width=\"1%%\">");
00112 printf(
"%s<br>",GetAccountName(account).c_str());
00113 nbprintf(
"%s</td>", thread.started.c_str());
00114
00115
00116
00117 {
00118 db::Account account(db, thread.updated_by);
00119 printf(
"<td class=threadlist width=\"1%%\">");
00120 printf(
"%s<br>",GetAccountName(account).c_str());
00121 nbprintf(
"%s</td>", thread.updated.c_str());
00122 }
00123 printf(
"</tr>");
00124 }
00125 printf(
"</table>");
00126 q.free_result();
00127 }
00128
00129