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