1 | <?php |
---|
2 | /** |
---|
3 | * %PUBLIC_SCRIPT% |
---|
4 | * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information |
---|
5 | * |
---|
6 | * Generated by module_maker.cli.php on %DATE% |
---|
7 | */ |
---|
8 | |
---|
9 | require_once dirname(__FILE__) . '/_config.inc.php'; |
---|
10 | require_once 'codebase/lib/PageNumbers.inc.php'; |
---|
11 | require_once 'codebase/lib/SortOrder.inc.php'; |
---|
12 | |
---|
13 | |
---|
14 | /****************************************************************************** |
---|
15 | * CODE CONFIG |
---|
16 | *****************************************************************************/ |
---|
17 | |
---|
18 | // Titles and navigation header. |
---|
19 | $nav->addPage(_("%TITLE%"), $_SERVER['PHP_SELF']); |
---|
20 | $nav->setFeature(array('title'=>true)); |
---|
21 | |
---|
22 | // Instantiate page numbers. Total items are set and calculation is done in the getRecordList function. |
---|
23 | $page = new PageNumbers(); |
---|
24 | $page->setPerPage(getFormData('per_page'), 50); |
---|
25 | $page->setPageNumber(getFormData('page_number')); |
---|
26 | |
---|
27 | %SORT_ORDER% |
---|
28 | |
---|
29 | /******************************************************************** |
---|
30 | * MAIN |
---|
31 | ********************************************************************/ |
---|
32 | |
---|
33 | if (getFormData('%PRIMARY_KEY%', false)) { |
---|
34 | |
---|
35 | // Get requested record. |
---|
36 | $qid = $db->query(" |
---|
37 | SELECT * FROM %DB_TBL% |
---|
38 | WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' |
---|
39 | AND publish = 'true' |
---|
40 | __///__AND (publish_date <= CURDATE() OR publish_date = '0000-00-00') |
---|
41 | __///__AND (expire_date > CURDATE() OR expire_date = '0000-00-00') |
---|
42 | "); |
---|
43 | if (!$item = mysql_fetch_assoc($qid)) { |
---|
44 | $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__); |
---|
45 | $app->dieBoomerangURL(); |
---|
46 | } |
---|
47 | |
---|
48 | // Update the hit counter for this record. |
---|
49 | $db->query(" |
---|
50 | UPDATE %DB_TBL% |
---|
51 | SET hit_count = hit_count + 1 |
---|
52 | WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' |
---|
53 | "); |
---|
54 | |
---|
55 | // Set title and main template. |
---|
56 | $nav->addPage($item['__///__']); |
---|
57 | $main_template = '%PUBLIC_DETAIL_TEMPLATE%'; |
---|
58 | |
---|
59 | } else { |
---|
60 | |
---|
61 | // Get the DEFAULT list. |
---|
62 | $%NAME_SINGULAR%_list = array(); |
---|
63 | $qid = $db->query(" |
---|
64 | SELECT * |
---|
65 | FROM %DB_TBL% |
---|
66 | WHERE publish = 'true' |
---|
67 | " . $so->getSortOrderSQL() . " |
---|
68 | LIMIT 100 |
---|
69 | "); |
---|
70 | while ($row = mysql_fetch_assoc($qid)) { |
---|
71 | $%NAME_SINGULAR%_list[] = $row; |
---|
72 | } |
---|
73 | |
---|
74 | // Set page numbers for default list. |
---|
75 | $page->setTotalItems(sizeof($%NAME_SINGULAR%_list)); |
---|
76 | $page->calculate(); |
---|
77 | |
---|
78 | |
---|
79 | // Get the FEATURED list. |
---|
80 | $featured_list = array(); |
---|
81 | $qid = $db->query(" |
---|
82 | SELECT * |
---|
83 | FROM %DB_TBL% |
---|
84 | WHERE publish = 'true' |
---|
85 | AND featured = 'true' |
---|
86 | ORDER BY %PRIMARY_KEY% DESC LIMIT 10 |
---|
87 | "); |
---|
88 | while ($row = mysql_fetch_assoc($qid)) { |
---|
89 | $featured_list[] = $row; |
---|
90 | } |
---|
91 | |
---|
92 | // Get the POPULAR list. |
---|
93 | $popular_list = array(); |
---|
94 | $qid = $db->query(" |
---|
95 | SELECT * |
---|
96 | FROM %DB_TBL% |
---|
97 | WHERE publish = 'true' |
---|
98 | ORDER BY hit_count DESC LIMIT 10 |
---|
99 | "); |
---|
100 | while ($row = mysql_fetch_assoc($qid)) { |
---|
101 | $popular_list[] = $row; |
---|
102 | } |
---|
103 | |
---|
104 | // Get the RECENT list. |
---|
105 | $recent_list = array(); |
---|
106 | $qid = $db->query(" |
---|
107 | SELECT * |
---|
108 | FROM %DB_TBL% |
---|
109 | WHERE publish = 'true' |
---|
110 | ORDER BY added_datetime DESC LIMIT 10 |
---|
111 | "); |
---|
112 | while ($row = mysql_fetch_assoc($qid)) { |
---|
113 | $recent_list[] = $row; |
---|
114 | } |
---|
115 | |
---|
116 | // Set main template. |
---|
117 | $main_template = '%PUBLIC_LIST_TEMPLATE%'; |
---|
118 | } |
---|
119 | |
---|
120 | // We have the data, and no errors, so here come the templates. |
---|
121 | include 'header.ihtml'; |
---|
122 | include $main_template; |
---|
123 | include 'footer.ihtml'; |
---|
124 | |
---|
125 | ?> |
---|