source: tags/1.0.0/bin/module_maker/skel/public.php @ 1

Last change on this file since 1 was 1, checked in by scdev, 19 years ago

Initial import.

File size: 3.5 KB
Line 
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
9require_once './_config.inc.php';
10require_once CODE_BASE . '/lib/PageNumbers.inc.php';
11require_once CODE_BASE . '/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
33if (getFormData('%PRIMARY_KEY%', false)) {
34   
35    // Get requested record.
36    $qid = dbQuery("
37        SELECT * FROM %DB_TBL%
38        WHERE %PRIMARY_KEY% = '" . addslashes(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        raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);
45        dieBoomerangURL();
46    }
47
48    // Update the hit counter for this record.
49    dbQuery("
50        UPDATE %DB_TBL%
51        SET hit_count = hit_count + 1
52        WHERE %PRIMARY_KEY% = '" . addslashes(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 = dbQuery("
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 = dbQuery("
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 = dbQuery("
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 = dbQuery("
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.
121include 'header.ihtml';
122include $main_template;
123include 'footer.ihtml';
124
125?>
Note: See TracBrowser for help on using the repository browser.