Google
Web alhem.net
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

ThreadListForm.cpp

Go to the documentation of this file.
00001 00006 /* 00007 Copyright (C) 2004 Anders Hedstrom 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00022 */ 00023 //#include <stdio.h> 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 // Database& db = pWeb -> GetDatabase(); 00045 char action[200]; 00046 00047 // <input type="submit" name="ThreadListForm" value="action" ... 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 // printf("<h3>Thread list</h3>"); 00070 Navigator(pWeb -> GetForum()); 00071 if (pWeb -> GetForum()) 00072 { 00073 printf("</td><td align=center>"); 00074 printf("&nbsp;[&nbsp;<a href=\"%s?page=6\">new topic</a>&nbsp;]",GetCgiName().c_str()); 00075 } 00076 printf("</td><td align=right>"); 00077 // printf("<div align=right>"); 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 // printf("]</div>"); 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 // printf("<th class=threadlist>Views</th>"); 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 // thumbnail 00101 printf("<td class=threadlist width=\"1%%\">"); 00102 viewtn( thread.image ); 00103 printf("</td>"); 00104 // title 00105 printf("<td class=threadlist>", thread.title.c_str()); 00106 printf("<a href=\"%s?ThreadListForm=view&thread=%ld\">&nbsp;%s&nbsp;</a></td>",GetCgiName().c_str(),thread.num,thread.title.c_str()); 00107 // message count 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 // started 00111 printf("<td class=threadlist width=\"1%%\">"); 00112 printf("%s<br>",GetAccountName(account).c_str()); 00113 nbprintf("%s</td>", thread.started.c_str()); 00114 // views 00115 // printf("<td class=threadlist width=\"1%%\"></td>"); 00116 // last 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

Generated on Sat Feb 12 00:14:57 2005 for IBank by doxygen 1.3.7