19#if __DCL_HAVE_THIS_FILE__
28MessageListView::MessageListView(
HtmlPage* pPage)
40 __nThumbnail = TN_NONE;
45void MessageListView::init(
SQLFields& fields)
50 __mapParams.lookup(L
"DETAIL", __strDetailPage);
51 __mapParams.lookup(L
"WRITE", __strWritePage);
52 __mapParams.lookup(L
"LIST", __strListPage);
55 if (__mapParams.lookup(L
"OVERRIDE", rValue) &&
56 !rValue.compareNoCase(L
"YES"))
59 if (__mapParams.lookup(L
"NO", rValue) && !rValue.isEmpty()) {
60 if (!rValue.compareNoCase(L
"ASC"))
64 if (__mapParams.lookup(L
"PARTS", rValue) && !rValue.isEmpty()) {
66 if (__nParts < 5 || __nParts > 20)
70 if (__mapParams.lookup(L
"ROWS", rValue) && !rValue.isEmpty()) {
76 if (__mapParams.lookup(L
"COLS", rValue) && !rValue.isEmpty()) {
78 if (!(2 <= __nCols && __nCols <= 10)) {
79 __DCL_TRACE1(L
"Warning! Invalid Params: COLS=%ls\n", rValue.data());
84 if (__mapParams.lookup(L
"GROUP", rValue) && !rValue.isEmpty()) {
86 if (!(1 <= __nGroup && __nGroup <= 10)) {
87 __DCL_TRACE1(L
"Warning! Invalid Params: GROUP=%ls\n", rValue.data());
92 if (__mapParams.lookup(L
"SUBJECT_SHORT", rValue) && !rValue.isEmpty()) {
94 if (__nSubjectShort < 0) {
95 __DCL_TRACE1(L
"Warning! Invalid Params: SUBJECT_SHORT=%ls\n", rValue.data());
100 if (__mapParams.lookup(L
"BODY_LENGTH", rValue) && !rValue.isEmpty()) {
104 if (__mapParams.lookup(L
"FILTER", rValue) && !rValue.isEmpty()) {
106 rValue.split(L
',', list);
107 StringArray::Iterator itList = list.begin();
108 for(; itList != list.end(); itList++) {
110 if (!(*itList).isEmpty()) {
111 if (!(*itList).compareNoCase(L
"NOTICE"))
112 __nFilter |= FILTER_NOTICE;
113 else if (!(*itList).compareNoCase(L
"START"))
114 __nFilter |= FILTER_START;
115 else if (!(*itList).compareNoCase(L
"REPLY"))
116 __nFilter |= FILTER_REPLY;
117 else if (!(*itList).compareNoCase(L
"SELF"))
118 __nFilter |= FILTER_SELF;
119 else if (!(*itList).compareNoCase(L
"CHILDREN"))
120 __nFilter |= FILTER_CHILDREN;
121 else if (!(*itList).compareNoCase(L
"DEPTH_1"))
122 __nFilter |= FILTER_DEPTH_1;
125 __DCL_TRACE1(L
"Warning! Invalid Params: FILTER=%ls\n", rValue.data());
129 if ((__nFilter & 0x000f) && (__nFilter & 0x00f0) && (__nFilter & 0x0f00)) {
131 __DCL_TRACE1(L
"Warning! Invalid Params: FILTER=%ls\n", rValue.data());
136 if (__nFilter & (FILTER_SELF | FILTER_CHILDREN)
137 && __mapParams.lookup(L
"MSG", rValue) && !rValue.isEmpty()
139 __strMsg = rValue.trim(L
", ");;
142 if (__mapParams.lookup(L
"RECENT", rValue)) {
143 rValue = rValue.trim();
144 if (!rValue.isEmpty()) {
146 if (0 < nHour && nHour < 100)
147 __nRecentHour = nHour;
149 __DCL_TRACE1(L
"Warning! Invalid Params: RECENT=%ls\n", rValue.data());
154 if (__mapParams.lookup(L
"SORT", rValue) && !rValue.isEmpty()) {
155 if (!rValue.compareNoCase(L
"ASC") || !rValue.compareNoCase(L
"DESC"))
158 __DCL_TRACE1(L
"Warning! Invalid Params: SORT=%ls\n", rValue.data());
168 if (__mapParams.lookup(L
"TYPE", rValue) && !rValue.isEmpty()) {
169 if (!rValue.compareNoCase(L
"GRID"))
171 else if (!rValue.compareNoCase(L
"LIST"))
173 else if (!rValue.compareNoCase(L
"ATTACH"))
174 __nType = TYPE_ATTACH;
176 __DCL_TRACE1(L
"Warning! Invalid Params: TYPE=%ls\n", rValue.data());
180 if (__mapParams.lookup(L
"THUMBNAIL", rValue) && !rValue.isEmpty()) {
181 if (!rValue.compareNoCase(L
"CHILD"))
182 __nThumbnail = TN_CHILD;
183 else if (!rValue.compareNoCase(L
"SELF"))
184 __nThumbnail = TN_SELF;
186 __DCL_TRACE1(L
"Warning! Invalid Params: THUMBNAIL=%ls\n", rValue.data());
191void MessageListView::onPrint(
Session& session)
199 ListedStringToStringArrayMap& mapQuery = session.__ctx.__queryMap;
201 String strTableID = String::valueOf(__nTableID);
202 String strDsID = String::valueOf(__nDsID);
204 int nCurrentPart =
Integer::parse(getDefault(mapQuery, L
"part"), 10, 1);
207 int nFilter = __nFilter;
216 String strDetailPage = __strDetailPage;
217 String strWritePage = __strWritePage;
218 String strListPage = getDefault(mapQuery, L
"list");
219 String strListPageEnc;
220 StringBuilder strThisPage = __pPage->__strPageID;
221 String strThisPageEnc;
222 String strMsg = getDefault(mapQuery, L
"msg");
224 if (strListPage.isEmpty())
225 strListPage = __strListPage;
229 if (!strMsg.isEmpty()) {
230 assign(L
"MSG", strMsg);
231 strThisPage += L
"&msg=" + strMsg;
234 if (!__strMsg.isEmpty())
237 if (!strMsg.isEmpty()) {
238 strMsg = strMsg.trim().trim(L
",");
241 if (strMsg.split(L
',', list) > 0) {
242 if (*(list.begin()) == L
"-1") {
243 nFilter = FILTER_DEPTH_1;
250 String str = getDefault(mapQuery, L
"rows");
251 if (!str.isEmpty()) {
256 strThisPage += L
"&rows=" + String::valueOf(nRows);
259 if (__nType == TYPE_GRID) {
260 str = getDefault(mapQuery, L
"cols");
261 if (!str.isEmpty()) {
263 if (!(2 <= __nCols && __nCols <= 10))
266 strThisPage += L
"&cols=" + String::valueOf(nCols);
281 String strRowName = L
"EMPTY";
283 pEMPTY = &((*this)[L
"EMPTY"]);
284 if (__nType == TYPE_GRID) {
285 pROW = &((*this)[L
"ROW"]);
286 pNOTICE = &((*pROW)[L
"NOTICE"]);
287 pSTART = &((*pROW)[L
"START"]);
288 pREPLY = &((*pROW)[L
"REPLY"]);
289 pPADDING = &((*pROW)[L
"PADDING"]);
291 strRecName = L
"PADDING";
292 pROW->erase(L
"NOTICE");
293 pROW->erase(L
"START");
294 pROW->erase(L
"REPLY");
298 pNOTICE = &((*this)[L
"NOTICE"]);
299 pSTART = &((*this)[L
"START"]);
300 pREPLY = &((*this)[L
"REPLY"]);
302 strRecName = L
"EMPTY";
308 assign(L
"IS_GUEST", session.isSysGuest() ? L
"true" : L
"false");
309 assign(L
"DETAIL", strDetailPage);
310 assign(L
"WRITE", strWritePage);
311 assign(L
"LIST", strListPage);
314 if (nFilter & (FILTER_SELF | FILTER_CHILDREN)) {
316 if (strMsg.isEmpty()) {
317 assign(strRowName, *pEMPTY);
326 case FILTER_NOTICE | FILTER_START | FILTER_REPLY :
329 strWhereEx = L
" AND M.MESSAGE_ID = M.START_ID AND M.MESSAGE_ID > 2000000000";
332 strWhereEx = L
" AND M.MESSAGE_ID = M.START_ID AND M.MESSAGE_ID <= 2000000000";
334 case FILTER_NOTICE | FILTER_START :
335 strWhereEx = L
" AND M.MESSAGE_ID = M.START_ID";
337 case FILTER_START | FILTER_REPLY :
338 strWhereEx = L
" AND M.MESSAGE_ID <= 2000000000";
341 strWhereEx = L
" AND M.MESSAGE_ID IN (L" + strMsg + L
")";
343 case FILTER_CHILDREN :
344 strWhereEx = L
" AND M.PARENT_ID IN (L" + strMsg + L
")";
346 case FILTER_SELF | FILTER_CHILDREN :
347 strWhereEx = L
" AND ((M.MESSAGE_ID IN (L" + strMsg + L
") OR M.PARENT_ID IN (L" + strMsg + L
")))";
349 case FILTER_DEPTH_1 :
350 strWhereEx = L
" AND (M.PARENT_ID = M.START_ID)";
357 int nUsingRecord = nRows;
358 if (__nType == TYPE_GRID)
359 nUsingRecord *= nCols;
361 int nTotalRecord = nUsingRecord;
370 " FROM DCL_MESSAGE_" + strTableID + L
" AS M"
371 " WHERE M.DS_ID = " + strDsID + strWhereEx
374 nTotalRecord = q.
fields()[0].asInteger();
376 if (nTotalRecord == 0) {
377 assign(strRowName, *pEMPTY);
383 nTotalPart = nTotalRecord / nUsingRecord;
384 if (nTotalRecord % nUsingRecord)
387 if (nCurrentPart <= 0 || nCurrentPart > nTotalPart)
388 nCurrentPart = nTotalPart;
390 StringBuilder strThisPageEx = strThisPage;
391 if (nCurrentPart > 1)
392 strThisPageEx += L
"&part=" + String::valueOf(nCurrentPart);
394 if (!strListPageEnc.isEmpty())
395 strThisPageEx += L
"&list=" + strListPageEnc;
399 assign(L
"_LIST", strListPageEnc);
400 assign(L
"_THIS", strThisPageEnc);
401 if (!session.isSysGuest()) {
403 _ADD.assign(L
"WRITE", strWritePage);
404 _ADD.assign(L
"PARENT_ID", L
"0");
405 _ADD.assign(L
"_LIST", strListPageEnc);
406 _ADD.assign(L
"_THIS", strThisPageEnc);
407 assign(L
"_ADD", _ADD);
410 StringBuilder strFieldEx;
411 switch(__nThumbnail) {
415 strFieldEx = L
", M.CHILD_ID AS TN_ID";
418 strFieldEx = L
", M.MESSAGE_ID AS TN_ID";
424 if (__nBodyLength >= 0)
425 strFieldEx += L
", M.BODY_PLAIN";
428 StringBuilder strOrderBy;
429 if (nFilter == FILTER_DEPTH_1)
430 strOrderBy = L
"M.MESSAGE_ID DESC";
432 strOrderBy = L
"M.START_ID " + __strSort + L
", M.REPLY_ID ASC";
434 if (__nType == TYPE_ATTACH) {
435 strFrom = L
"DCL_MESSAGE_A_" + strTableID + L
" AS A"
436 "\n INNER JOIN DCL_MESSAGE_" + strTableID + L
" AS M"
437 " ON (A.DS_ID = M.DS_ID AND A.MESSAGE_ID = M.MESSAGE_ID)";
438 strFieldEx += L
", A.NO, A.FILENAME, A.NDOWNLOAD, A.ICON, CEILING(A.SIZE / 1024) AS KSIZE";
439 strOrderBy += L
", A.NO ASC";
442 strFrom = L
"DCL_MESSAGE_" + strTableID + L
" AS M";
445 int nOffset = (nCurrentPart - 1) * nUsingRecord;
448 "SELECT M.DS_ID, M.MESSAGE_ID, M.REPLY_ID, M.NCHILD,"
449 "\n M.NREAD, M.NAGREE, M.NDISAGREE, (M.NAGREE + M.NDISAGREE) AS NVOTE,"
450 "\n (M.NAGREE - M.NDISAGREE) AS NDECISION, M.VOTE_END, M.TYPE AS BODY_TYPE,"
451 "\n M.SUBJECT, M.UPDATE_TIME, M.USER_ID, U.USER_NAME AS WRITER"
452 + strFieldEx.toString() + L
""
453 "\n FROM " + strFrom.toString() + L
""
454 "\n INNER JOIN DCLWC_USER AS U ON (M.USER_ID = U.USER_ID)" + L
""
455 "\n WHERE M.DS_ID = " + strDsID + strWhereEx + L
""
456 "\n ORDER BY " + strOrderBy.toString() + L
""
457 "\n LIMIT " + String::valueOf(nUsingRecord) + L
""
458 "\n OFFSET " + String::valueOf(nOffset);
467 assign(strRowName, *pEMPTY);
470 UpdateLink ul(atP(L
"UPDATE_LINK"), strDetailPage, strWritePage, strThisPageEnc, strListPageEnc);
472 RowGroup rg(atP(L
"RGROUP"), __nGroup);
477 nNo = nTotalRecord - ((nCurrentPart - 1) * nUsingRecord);
483 int nMessageID = fields.
byName(L
"MESSAGE_ID").asInteger();
484 int64_t nReplyID = fields.
byName(L
"REPLY_ID").asInt64();
485 String strMessageID = String::valueOf(nMessageID);
488 mt.getPosition(nReplyID, rPos);
494 StringBuilder strIndent;
496 strIndent += L
" ";
497 pDest->assign(L
"INDENT", strIndent);
506 ul.assign(pDest, fields, session, strMessageID, strListPage, mt, rPos);
507 rg.assign(pDest, nRow++);
509 pDest->assign(fields, L
" ");
510 pDest->assign(L
"NO", String::valueOf(nNo));
515 pDest->assign(L
"WRITE", strWritePage);
516 pDest->assign(L
"DETAIL", strDetailPage);
517 pDest->assign(L
"_THIS", strThisPageEnc);
518 pDest->assign(L
"_LIST", strListPageEnc);
521 StringBuilder strThumbnail =
Files::dirname(session.__ctx.path());
523 if (fTN_ID.asInteger() == 0)
524 strThumbnail += L
"images/default_tn.gif";
526 strThumbnail += L
"thumbnail/" + strDsID + L
"/"
527 + fTN_ID.asString() + L
"-1.dat.jpg";
529 pDest->assign(L
"THUMBNAIL", strThumbnail);
533 int nBodyType = fields.
byName(L
"BODY_TYPE").asInteger();
537 strSubject = fields.
byName(L
"SUBJECT").asString();
538 if (strSubject.isEmpty())
539 strSubject = L
"제목없음";
541 pDest->assign(L
"SUBJECT", strSubject);
542 if (__nSubjectShort > 0) {
543 String strSubjectShort;
544 if ((ssize_t) strSubject.length() > __nSubjectShort)
545 strSubjectShort = strSubject.left(__nSubjectShort) + L
"...";
547 strSubjectShort = strSubject;
549 pDest->assign(L
"SUBJECT_SHORT", strSubjectShort);
552 if (__nBodyLength >= 0) {
553 String str = fields.
byName(L
"BODY_PLAIN").asString();
554 if (__nBodyLength > 0 && str.length() > (
size_t) __nBodyLength)
555 str = str.left(__nBodyLength) + L
"...";
556 pDest->assign(L
"BODY_PLAIN", str);
560 pDest->assign(L
"UPDATE_DATE", dtUpdate.
date().
toString());
561 ri.assign(pDest, dtUpdate);
563 if (__nType == TYPE_GRID) {
564 pROW->append(strRecName, *pDest);
565 if (nCol == __nCols) {
567 append(strRowName, *pROW);
574 append(strRowName, *pDest);
579 if (__nType == TYPE_GRID && nCol > 1) {
580 for(; nCol <= __nCols; nCol++)
581 pROW->append(strRecName, *pPADDING);
583 append(strRowName, *pROW);
588 if (pPART_LINK && nTotalPart > 1) {
589 PartLink pl(pPART_LINK, strThisPage, strListPageEnc);
590 pl.assign(
this, nTotalPart, nCurrentPart, __nParts);
#define IMPLEMENT_CLASSINFO_EX(class_name, base_class_name)
#define IS_NOTICE_ID(nMessageID)
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_ASSERT(expr)
static DateTime getCurrentLocalTime()
static String dirname(const String &_path)
static int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
virtual void init(SQLFields &fields) __DCL_THROWS1(Exception *)
virtual void onPrint(Session &session) __DCL_THROWS1(Exception *)
_CONST SQLField & byName(const wchar_t *_name) _CONST __DCL_THROWS1(InvalidIndexException *)
_CONST SQLFields & fields() _CONST
void execute() __DCL_THROWS1(SQLException *)
void fetch() __DCL_THROWS1(SQLException *)
static ByteString encode(const ByteString &_str)