[1] | 1 | <?php |
---|
| 2 | /** |
---|
[362] | 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-2009 Strangecode Internet Consultancy |
---|
| 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 | /** |
---|
[42] | 24 | * %PUBLIC_SCRIPT% |
---|
[1] | 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. |
---|
[202] | 39 | $nav->add(sprintf(_("%TITLE%"), null)); |
---|
| 40 | $nav->setParam(array( |
---|
| 41 | 'title' => true, |
---|
| 42 | )); |
---|
[1] | 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 | |
---|
[143] | 51 | /******************************************************************** |
---|
| 52 | * MAIN |
---|
| 53 | ********************************************************************/ |
---|
[1] | 54 | |
---|
| 55 | if (getFormData('%PRIMARY_KEY%', false)) { |
---|
[42] | 56 | |
---|
[1] | 57 | // Get requested record. |
---|
[136] | 58 | $qid = $db->query(" |
---|
[1] | 59 | SELECT * FROM %DB_TBL% |
---|
[136] | 60 | WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' |
---|
[1] | 61 | AND publish = 'true' |
---|
[154] | 62 | __///__AND (publish_date <= CURDATE() OR publish_date = '0000-00-00') |
---|
| 63 | __///__AND (expire_date > CURDATE() OR expire_date = '0000-00-00') |
---|
[1] | 64 | "); |
---|
| 65 | if (!$item = mysql_fetch_assoc($qid)) { |
---|
[136] | 66 | $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__); |
---|
| 67 | $app->dieBoomerangURL(); |
---|
[1] | 68 | } |
---|
| 69 | |
---|
| 70 | // Update the hit counter for this record. |
---|
[136] | 71 | $db->query(" |
---|
[1] | 72 | UPDATE %DB_TBL% |
---|
| 73 | SET hit_count = hit_count + 1 |
---|
[136] | 74 | WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' |
---|
[1] | 75 | "); |
---|
[42] | 76 | |
---|
[1] | 77 | // Set title and main template. |
---|
[202] | 78 | $nav->add($item['__///__']); |
---|
[1] | 79 | $main_template = '%PUBLIC_DETAIL_TEMPLATE%'; |
---|
| 80 | |
---|
| 81 | } else { |
---|
[42] | 82 | |
---|
[1] | 83 | // Get the DEFAULT list. |
---|
| 84 | $%NAME_SINGULAR%_list = array(); |
---|
[136] | 85 | $qid = $db->query(" |
---|
[42] | 86 | SELECT * |
---|
| 87 | FROM %DB_TBL% |
---|
| 88 | WHERE publish = 'true' |
---|
[1] | 89 | " . $so->getSortOrderSQL() . " |
---|
| 90 | LIMIT 100 |
---|
| 91 | "); |
---|
| 92 | while ($row = mysql_fetch_assoc($qid)) { |
---|
| 93 | $%NAME_SINGULAR%_list[] = $row; |
---|
| 94 | } |
---|
[42] | 95 | |
---|
[1] | 96 | // Set page numbers for default list. |
---|
| 97 | $page->setTotalItems(sizeof($%NAME_SINGULAR%_list)); |
---|
| 98 | $page->calculate(); |
---|
| 99 | |
---|
[42] | 100 | |
---|
[1] | 101 | // Get the FEATURED list. |
---|
| 102 | $featured_list = array(); |
---|
[136] | 103 | $qid = $db->query(" |
---|
[42] | 104 | SELECT * |
---|
| 105 | FROM %DB_TBL% |
---|
[1] | 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 | } |
---|
[42] | 113 | |
---|
[1] | 114 | // Get the POPULAR list. |
---|
| 115 | $popular_list = array(); |
---|
[136] | 116 | $qid = $db->query(" |
---|
[42] | 117 | SELECT * |
---|
| 118 | FROM %DB_TBL% |
---|
| 119 | WHERE publish = 'true' |
---|
[1] | 120 | ORDER BY hit_count DESC LIMIT 10 |
---|
| 121 | "); |
---|
| 122 | while ($row = mysql_fetch_assoc($qid)) { |
---|
| 123 | $popular_list[] = $row; |
---|
| 124 | } |
---|
[42] | 125 | |
---|
[1] | 126 | // Get the RECENT list. |
---|
| 127 | $recent_list = array(); |
---|
[136] | 128 | $qid = $db->query(" |
---|
[42] | 129 | SELECT * |
---|
| 130 | FROM %DB_TBL% |
---|
| 131 | WHERE publish = 'true' |
---|
[1] | 132 | ORDER BY added_datetime DESC LIMIT 10 |
---|
| 133 | "); |
---|
| 134 | while ($row = mysql_fetch_assoc($qid)) { |
---|
| 135 | $recent_list[] = $row; |
---|
| 136 | } |
---|
[42] | 137 | |
---|
[1] | 138 | // Set main template. |
---|
| 139 | $main_template = '%PUBLIC_LIST_TEMPLATE%'; |
---|
[42] | 140 | } |
---|
[1] | 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 | |
---|
| 147 | ?> |
---|