DCL 3.7.4
Loading...
Searching...
No Matches
PageListView Class Reference

#include <Page.h>

Inheritance diagram for PageListView:
HtmlView TextTemplate Object

Public Member Functions

 PageListView (HtmlPage *pPage)
virtual void init (SQLFields &fields) __DCL_THROWS1(Exception *)
virtual void onPrint (Session &session) __DCL_THROWS1(Exception *)
Public Member Functions inherited from HtmlView
const HtmlPagepage () const
String SELF () const
String VNO () const
virtual void onGet (Session &session) __DCL_THROWS1(Exception *)
virtual void onPost (Session &session) __DCL_THROWS1(Exception *)
Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Additional Inherited Members

Static Public Member Functions inherited from HtmlView
static HtmlViewcreateObject (HtmlPage *pPage, int nClassID, int nIndex)
Protected Member Functions inherited from HtmlView
 HtmlView (HtmlPage *pPage)
Protected Member Functions inherited from TextTemplate
virtual String onSQLFieldValue (_CONST SQLField &_field, const String &_fieldIsNullValue)
void parseHelper (const char_t *_begin, const char_t *_end)
void parse (const char_t *_begin, const char_t *_end)
int append (const char_t *_name, const String &_value, bool _clearExists)
int append (const char_t *_name, const TextTemplate &_template, bool _clearExists)
int append (const StringStringArray &_nameToValues, bool _clearExists)
int append (_CONST SQLFields &_fields, const String &_fieldIsNullValue, bool _clearExists)
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()
Static Protected Member Functions inherited from HtmlView
static size_t split (const String &str, StringStringArray &v)
static void dump (Session &session)
static String getDefault (ListedStringToStringArrayMap &map, const String &strKey)
static size_t getShortString (SQLField &field, size_t _len, String &strLong, String &strShort)
Protected Attributes inherited from HtmlView
HtmlPage__pPage
int __nIndex
int __nClassID
StringToStringMap __mapParams
Protected Attributes inherited from TextTemplate
void * __textList
void * __subTemplateMap

Detailed Description

Definition at line 33 of file Page.h.

Constructor & Destructor Documentation

◆ PageListView()

PageListView::PageListView ( HtmlPage * pPage)

Member Function Documentation

◆ init()

void PageListView::init ( SQLFields & fields)
virtual

Reimplemented from HtmlView.

Definition at line 176 of file Page.cpp.

178{
179 HtmlView::init(fields);
180
181 __mapParams.lookup(L"DETAIL", __strDetailPage);
182 __mapParams.lookup(L"WRITE", __strWritePage);
183
184 String rValue;
185
186 if (__mapParams.lookup(L"PARTS", rValue) && !rValue.isEmpty()) {
187 __nParts = Integer::parse(rValue, 10, __nParts);
188 if (__nParts < 5 || __nParts > 20)
189 __nParts = 5;
190 }
191
192 if (__mapParams.lookup(L"ROWS", rValue) && !rValue.isEmpty()) {
193 __nRows = Integer::parse(rValue, 10, __nRows);
194 if (__nRows <= 0)
195 __nRows = 20;
196 }
197
198 if (__mapParams.lookup(L"SHORT_COMMENT", rValue) && !rValue.isEmpty()) {
199 int n = Integer::parse(rValue, 10, __nShortComment);
200 if (n > 0)
201 __nShortComment = n;
202 }
203}
StringToStringMap __mapParams
Definition HtmlView.h:112
virtual void init(SQLFields &fields) __DCL_THROWS1(Exception *)
Definition HtmlView.cpp:298
static int parse(const wchar_t *_number, unsigned _base=10) __DCL_THROWS1(NumericConvertException *)
Definition Numeric.inl:36

◆ onPrint()

void PageListView::onPrint ( Session & session)
virtual

Reimplemented from HtmlView.

Definition at line 205 of file Page.cpp.

207{
208 SQLQuery& q = session.__query;
209 ListedStringToStringArrayMap& mapQuery = session.__ctx.__queryMap;
210
211 int nCurrentPart = Integer::parse(getDefault(mapQuery, L"part"), 10, 1);
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"];
222 q.execute(L""
223 "SELECT CATEGORY_ID, CATEGORY_NAME"
224 "\n FROM DCL_PAGE_CATEGORY"
225 "\n ORDER BY CATEGORY_ID"
226 );
227 q.fetch();
228 while(!q.eof()) {
229 CATEGORY.assign(q.fields(), L"");
230 append(L"CATEGORY", CATEGORY);
231
232 q.fetch();
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);
243 assign(L"_THIS", URLEncoder::encode(strThisPage));
244 assign(L"CATEGORY_ID", strCategoryID);
245
246 int nUsingRecord = nRows;
247 int nTotalRecord = nUsingRecord;
248 int nTotalPart = 1;
249
250 // nNo를 표시하기 위해서 조건에 만족하는 전체레코드의 개수가 항상 필요하다.
251 q.execute(L""
252 "SELECT COUNT(*) "
253 "\n FROM DCL_PAGE AS P"
254 + strWhere
255 );
256 q.fetch();
257 nTotalRecord = q.fields()[0].asInteger();
258 if (nTotalRecord == 0) {
259 assign(L"EMPTY", (*this)[L"EMPTY"]);
260 HtmlView::onPrint(session);
261 return;
262 }
263
264 __DCL_VERIFY(nTotalRecord > 0);
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
277 strThisPageEnc = URLEncoder::encode(strThisPageEx);
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
286 q.execute(L""
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
298 q.fetch();
299 if (q.eof())
300 assign(L"EMPTY", (*this)[L"EMPTY"]);
301 else {
302 do {
303 PAGE.assign(q.fields(), L"&nbsp;");
304 SQLField& field = q.fields().byName(L"COMMENT");
305 if (field.isNull()) {
306 PAGE.assign(L"COMMENT", L"");
307 PAGE.assign(L"SHORT_COMMENT", L"&nbsp;");
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
324 q.fetch();
325 } while(!q.eof());
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
334 HtmlView::onPrint(session);
335}
#define __DCL_VERIFY(expr)
Definition Object.h:396
virtual void onPrint(Session &session) __DCL_THROWS1(Exception *)
Definition HtmlView.cpp:349
static String getDefault(ListedStringToStringArrayMap &map, const String &strKey)
Definition HtmlView.cpp:256
HtmlPage * __pPage
Definition HtmlView.h:108
_CONST SQLField & byName(const wchar_t *_name) _CONST __DCL_THROWS1(InvalidIndexException *)
Definition SQLQuery.cpp:77
_CONST SQLFields & fields() _CONST
Definition SQL.inl:101
void execute() __DCL_THROWS1(SQLException *)
Definition SQLQuery.cpp:316
bool eof() const
Definition SQL.inl:91
void fetch() __DCL_THROWS1(SQLException *)
Definition SQLQuery.cpp:336
HttpServletContextEx & __ctx
Definition Session.h:41
SQLQuery & __query
Definition Session.h:42
static ByteString encode(const ByteString &_str)
Definition URI.cpp:82

The documentation for this class was generated from the following files: