[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. |
---|
| 19 | $nav->addPage(_("%TITLE%"), $_SERVER['PHP_SELF']); |
---|
[42] | 20 | $nav->setFeature(array('title'=>true)); |
---|
[1] | 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 | |
---|
[143] | 29 | /******************************************************************** |
---|
| 30 | * MAIN |
---|
| 31 | ********************************************************************/ |
---|
[1] | 32 | |
---|
| 33 | if (getFormData('%PRIMARY_KEY%', false)) { |
---|
[42] | 34 | |
---|
[1] | 35 | // Get requested record. |
---|
[136] | 36 | $qid = $db->query(" |
---|
[1] | 37 | SELECT * FROM %DB_TBL% |
---|
[136] | 38 | WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' |
---|
[1] | 39 | AND publish = 'true' |
---|
[154] | 40 | __///__AND (publish_date <= CURDATE() OR publish_date = '0000-00-00') |
---|
| 41 | __///__AND (expire_date > CURDATE() OR expire_date = '0000-00-00') |
---|
[1] | 42 | "); |
---|
| 43 | if (!$item = mysql_fetch_assoc($qid)) { |
---|
[136] | 44 | $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__); |
---|
| 45 | $app->dieBoomerangURL(); |
---|
[1] | 46 | } |
---|
| 47 | |
---|
| 48 | // Update the hit counter for this record. |
---|
[136] | 49 | $db->query(" |
---|
[1] | 50 | UPDATE %DB_TBL% |
---|
| 51 | SET hit_count = hit_count + 1 |
---|
[136] | 52 | WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "' |
---|
[1] | 53 | "); |
---|
[42] | 54 | |
---|
[1] | 55 | // Set title and main template. |
---|
[154] | 56 | $nav->addPage($item['__///__']); |
---|
[1] | 57 | $main_template = '%PUBLIC_DETAIL_TEMPLATE%'; |
---|
| 58 | |
---|
| 59 | } else { |
---|
[42] | 60 | |
---|
[1] | 61 | // Get the DEFAULT list. |
---|
| 62 | $%NAME_SINGULAR%_list = array(); |
---|
[136] | 63 | $qid = $db->query(" |
---|
[42] | 64 | SELECT * |
---|
| 65 | FROM %DB_TBL% |
---|
| 66 | WHERE publish = 'true' |
---|
[1] | 67 | " . $so->getSortOrderSQL() . " |
---|
| 68 | LIMIT 100 |
---|
| 69 | "); |
---|
| 70 | while ($row = mysql_fetch_assoc($qid)) { |
---|
| 71 | $%NAME_SINGULAR%_list[] = $row; |
---|
| 72 | } |
---|
[42] | 73 | |
---|
[1] | 74 | // Set page numbers for default list. |
---|
| 75 | $page->setTotalItems(sizeof($%NAME_SINGULAR%_list)); |
---|
| 76 | $page->calculate(); |
---|
| 77 | |
---|
[42] | 78 | |
---|
[1] | 79 | // Get the FEATURED list. |
---|
| 80 | $featured_list = array(); |
---|
[136] | 81 | $qid = $db->query(" |
---|
[42] | 82 | SELECT * |
---|
| 83 | FROM %DB_TBL% |
---|
[1] | 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 | } |
---|
[42] | 91 | |
---|
[1] | 92 | // Get the POPULAR list. |
---|
| 93 | $popular_list = array(); |
---|
[136] | 94 | $qid = $db->query(" |
---|
[42] | 95 | SELECT * |
---|
| 96 | FROM %DB_TBL% |
---|
| 97 | WHERE publish = 'true' |
---|
[1] | 98 | ORDER BY hit_count DESC LIMIT 10 |
---|
| 99 | "); |
---|
| 100 | while ($row = mysql_fetch_assoc($qid)) { |
---|
| 101 | $popular_list[] = $row; |
---|
| 102 | } |
---|
[42] | 103 | |
---|
[1] | 104 | // Get the RECENT list. |
---|
| 105 | $recent_list = array(); |
---|
[136] | 106 | $qid = $db->query(" |
---|
[42] | 107 | SELECT * |
---|
| 108 | FROM %DB_TBL% |
---|
| 109 | WHERE publish = 'true' |
---|
[1] | 110 | ORDER BY added_datetime DESC LIMIT 10 |
---|
| 111 | "); |
---|
| 112 | while ($row = mysql_fetch_assoc($qid)) { |
---|
| 113 | $recent_list[] = $row; |
---|
| 114 | } |
---|
[42] | 115 | |
---|
[1] | 116 | // Set main template. |
---|
| 117 | $main_template = '%PUBLIC_LIST_TEMPLATE%'; |
---|
[42] | 118 | } |
---|
[1] | 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 | ?> |
---|