207{
209 ListedStringToStringArrayMap& mapQuery = session.
__ctx.__queryMap;
210
212 int nRows = __nRows;
213
214 String strDetailPage = __strDetailPage;
215 String strWritePage = __strWritePage;
216 StringBuilder strThisPage =
__pPage->__strPageID;
217 String strThisPageEnc;
218
219 String strCategoryID =
getDefault(mapQuery, L
"category");
220
221 TextTemplate& CATEGORY = (*this)[L"CATEGORY"];
223 "SELECT CATEGORY_ID, CATEGORY_NAME"
224 "\n FROM DCL_PAGE_CATEGORY"
225 "\n ORDER BY CATEGORY_ID"
226 );
229 CATEGORY.assign(q.
fields(), L
"");
230 append(L"CATEGORY", CATEGORY);
231
233 }
234
235 String strWhere;
236 if (!strCategoryID.isEmpty()) {
237 strWhere = L"\n WHERE P.CATEGORY_ID = " + strCategoryID;
238 strThisPage += L"&category=" + strCategoryID;
239 }
240
241 assign(L"DETAIL", strDetailPage);
242 assign(L"WRITE", strWritePage);
244 assign(L"CATEGORY_ID", strCategoryID);
245
246 int nUsingRecord = nRows;
247 int nTotalRecord = nUsingRecord;
248 int nTotalPart = 1;
249
250
252 "SELECT COUNT(*) "
253 "\n FROM DCL_PAGE AS P"
254 + strWhere
255 );
257 nTotalRecord = q.
fields()[0].asInteger();
258 if (nTotalRecord == 0) {
259 assign(L"EMPTY", (*this)[L"EMPTY"]);
261 return;
262 }
263
265
266 nTotalPart = nTotalRecord / nUsingRecord;
267 if (nTotalRecord % nUsingRecord)
268 nTotalPart++;
269
270 if (nCurrentPart <= 0 || nCurrentPart > nTotalPart)
271 nCurrentPart = nTotalPart;
272
273 StringBuilder strThisPageEx = strThisPage;
274 if (nCurrentPart > 1)
275 strThisPageEx += L"&part=" + String::valueOf(nCurrentPart);
276
278 assign(L"_THIS", strThisPageEnc);
279
280 int nOffset = (nCurrentPart - 1) * nUsingRecord;
281
282 int nNo = nTotalRecord - ((nCurrentPart - 1) * nUsingRecord);
283 int nRow = 1;
284 TextTemplate& PAGE = (*this)[L"PAGE"];
285
287 "SELECT P.PAGE_ID, P.TYPE, P.CHARSET, P.LANGUAGE, P.TITLE, P.COMMENT"
288 ", P.UPDATE_TIME, R.ROLE_NAME, C.CATEGORY_NAME"
289 "\n FROM DCL_PAGE AS P"
290 "\n INNER JOIN DCL_ROLE AS R ON (P.PERM_ID = R.ROLE_ID)"
291 "\n INNER JOIN DCL_PAGE_CATEGORY AS C ON (P.CATEGORY_ID = C.CATEGORY_ID)"
292 + strWhere + L""
293 "\n ORDER BY P.PAGE_ID DESC"
294 "\n LIMIT " + String::valueOf(nUsingRecord) + L""
295 "\n OFFSET " + String::valueOf(nOffset)
296 );
297
300 assign(L"EMPTY", (*this)[L"EMPTY"]);
301 else {
302 do {
303 PAGE.assign(q.
fields(), L
" ");
305 if (field.isNull()) {
306 PAGE.assign(L"COMMENT", L"");
307 PAGE.assign(L"SHORT_COMMENT", L" ");
308 }
309 else {
310 String strDesc = field.asString();
311 if ((ssize_t) strDesc.length() > __nShortComment)
312 PAGE.assign(L"SHORT_COMMENT", strDesc.left(__nShortComment) + L"...");
313 else
314 PAGE.assign(L"SHORT_COMMENT", strDesc);
315 }
316
317 PAGE.assign(L"NO", String::valueOf(nNo--));
318 PAGE.assign(L"DETAIL", strDetailPage);
319 PAGE.assign(L"WRITE", strWritePage);
320 PAGE.assign(L"_THIS", strThisPageEnc);
321
322 append(L"PAGE", PAGE);
323
326
327 TextTemplate* pPART_LINK = atP(L"PART_LINK");
328 if (pPART_LINK && nTotalPart > 1) {
329 PartLink pl(pPART_LINK, strThisPage, String());
330 pl.assign(this, nTotalPart, nCurrentPart, __nParts);
331 }
332 }
333
335}
#define __DCL_VERIFY(expr)
virtual void onPrint(Session &session) __DCL_THROWS1(Exception *)
static String getDefault(ListedStringToStringArrayMap &map, const String &strKey)
_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 *)
HttpServletContextEx & __ctx
static ByteString encode(const ByteString &_str)