1 | <?php |
---|
2 | /** |
---|
3 | * The Strangecode Codebase - a general application development framework for PHP |
---|
4 | * For details visit the project site: <http://trac.strangecode.com/codebase/> |
---|
5 | * Copyright 2001-2012 Strangecode, LLC |
---|
6 | * |
---|
7 | * This file is part of The Strangecode Codebase. |
---|
8 | * |
---|
9 | * The Strangecode Codebase is free software: you can redistribute it and/or |
---|
10 | * modify it under the terms of the GNU General Public License as published by the |
---|
11 | * Free Software Foundation, either version 3 of the License, or (at your option) |
---|
12 | * any later version. |
---|
13 | * |
---|
14 | * The Strangecode Codebase is distributed in the hope that it will be useful, but |
---|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
16 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
17 | * details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License along with |
---|
20 | * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | */ |
---|
22 | |
---|
23 | /** |
---|
24 | * %PUBLIC_SCRIPT% |
---|
25 | * |
---|
26 | * Generated by module_maker.cli.php on %DATE% |
---|
27 | */ |
---|
28 | |
---|
29 | require_once dirname(__FILE__) . '/_config.inc.php'; |
---|
30 | require_once 'codebase/lib/PageNumbers.inc.php'; |
---|
31 | require_once 'codebase/lib/SortOrder.inc.php'; |
---|
32 | |
---|
33 | |
---|
34 | /****************************************************************************** |
---|
35 | * CODE CONFIG |
---|
36 | *****************************************************************************/ |
---|
37 | |
---|
38 | // Titles and navigation header. |
---|
39 | $nav->add(sprintf(_("%TITLE%"), null)); |
---|
40 | $nav->setParam(array( |
---|
41 | 'title' => true, |
---|
42 | )); |
---|
43 | |
---|
44 | // Instantiate page numbers. Total items are set and calculation is done in the getRecordList function. |
---|
45 | $page = new PageNumbers(); |
---|
46 | $page->setPerPage(getFormData('per_page'), 50); |
---|
47 | $page->setPageNumber(getFormData('page_number')); |
---|
48 | |
---|
49 | %SORT_ORDER% |
---|
50 | |
---|
51 | /******************************************************************** |
---|
52 | * MAIN |
---|
53 | ********************************************************************/ |
---|
54 | |
---|
55 | if (getFormData('%PRIMARY_KEY%', false)) { |
---|
56 | |
---|
57 | // Get requested record. |
---|
58 | $qid = $db->query(" |
---|
59 | SELECT * FROM %DB_TBL% |
---|
60 | WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' |
---|
61 | AND publish = 'true' |
---|
62 | __///__AND (publish_date <= CURDATE() OR publish_date = '0000-00-00') |
---|
63 | __///__AND (expire_date > CURDATE() OR expire_date = '0000-00-00') |
---|
64 | "); |
---|
65 | if (!$item = mysql_fetch_assoc($qid)) { |
---|
66 | $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__); |
---|
67 | $app->dieBoomerangURL(); |
---|
68 | } |
---|
69 | |
---|
70 | // Update the hit counter for this record. |
---|
71 | $db->query(" |
---|
72 | UPDATE %DB_TBL% |
---|
73 | SET hit_count = hit_count + 1 |
---|
74 | WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' |
---|
75 | "); |
---|
76 | |
---|
77 | // Set title and main template. |
---|
78 | $nav->add($item['__///__']); |
---|
79 | $main_template = '%PUBLIC_DETAIL_TEMPLATE%'; |
---|
80 | |
---|
81 | } else { |
---|
82 | |
---|
83 | // Get the DEFAULT list. |
---|
84 | $%NAME_SINGULAR%_list = array(); |
---|
85 | $qid = $db->query(" |
---|
86 | SELECT * |
---|
87 | FROM %DB_TBL% |
---|
88 | WHERE publish = 'true' |
---|
89 | " . $so->getSortOrderSQL() . " |
---|
90 | LIMIT 100 |
---|
91 | "); |
---|
92 | while ($row = mysql_fetch_assoc($qid)) { |
---|
93 | $%NAME_SINGULAR%_list[] = $row; |
---|
94 | } |
---|
95 | |
---|
96 | // Set page numbers for default list. |
---|
97 | $page->setTotalItems(sizeof($%NAME_SINGULAR%_list)); |
---|
98 | $page->calculate(); |
---|
99 | |
---|
100 | |
---|
101 | // Get the FEATURED list. |
---|
102 | $featured_list = array(); |
---|
103 | $qid = $db->query(" |
---|
104 | SELECT * |
---|
105 | FROM %DB_TBL% |
---|
106 | WHERE publish = 'true' |
---|
107 | AND featured = 'true' |
---|
108 | ORDER BY %PRIMARY_KEY% DESC LIMIT 10 |
---|
109 | "); |
---|
110 | while ($row = mysql_fetch_assoc($qid)) { |
---|
111 | $featured_list[] = $row; |
---|
112 | } |
---|
113 | |
---|
114 | // Get the POPULAR list. |
---|
115 | $popular_list = array(); |
---|
116 | $qid = $db->query(" |
---|
117 | SELECT * |
---|
118 | FROM %DB_TBL% |
---|
119 | WHERE publish = 'true' |
---|
120 | ORDER BY hit_count DESC LIMIT 10 |
---|
121 | "); |
---|
122 | while ($row = mysql_fetch_assoc($qid)) { |
---|
123 | $popular_list[] = $row; |
---|
124 | } |
---|
125 | |
---|
126 | // Get the RECENT list. |
---|
127 | $recent_list = array(); |
---|
128 | $qid = $db->query(" |
---|
129 | SELECT * |
---|
130 | FROM %DB_TBL% |
---|
131 | WHERE publish = 'true' |
---|
132 | ORDER BY added_datetime DESC LIMIT 10 |
---|
133 | "); |
---|
134 | while ($row = mysql_fetch_assoc($qid)) { |
---|
135 | $recent_list[] = $row; |
---|
136 | } |
---|
137 | |
---|
138 | // Set main template. |
---|
139 | $main_template = '%PUBLIC_LIST_TEMPLATE%'; |
---|
140 | } |
---|
141 | |
---|
142 | // We have the data, and no errors, so here come the templates. |
---|
143 | include 'header.ihtml'; |
---|
144 | include $main_template; |
---|
145 | include 'footer.ihtml'; |
---|
146 | |
---|