source: trunk/bin/module_maker/skel/public.php @ 202

Last change on this file since 202 was 202, checked in by scdev, 18 years ago

Q - updated usage of $nav.

File size: 3.4 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 dirname(__FILE__) . '/_config.inc.php';
10require_once 'codebase/lib/PageNumbers.inc.php';
11require_once 'codebase/lib/SortOrder.inc.php';
12
13
14/******************************************************************************
15 * CODE CONFIG
16 *****************************************************************************/
17
18// Titles and navigation header.
19$nav->add(sprintf(_("%TITLE%"), null));
20$nav->setParam(array(
21    'title' => true,
22));
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
31/********************************************************************
32* MAIN
33********************************************************************/
34
35if (getFormData('%PRIMARY_KEY%', false)) {
36
37    // Get requested record.
38    $qid = $db->query("
39        SELECT * FROM %DB_TBL%
40        WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "'
41        AND publish = 'true'
42        __///__AND (publish_date <= CURDATE() OR publish_date = '0000-00-00')
43        __///__AND (expire_date > CURDATE() OR expire_date = '0000-00-00')
44    ");
45    if (!$item = mysql_fetch_assoc($qid)) {
46        $app->raiseMsg(_("Sorry that %ITEM_TITLE% could not be found"), MSG_WARNING, __FILE__, __LINE__);
47        $app->dieBoomerangURL();
48    }
49
50    // Update the hit counter for this record.
51    $db->query("
52        UPDATE %DB_TBL%
53        SET hit_count = hit_count + 1
54        WHERE %PRIMARY_KEY% = '" . $db->escapeString(getFormData('%PRIMARY_KEY%')) . "'
55    ");
56
57    // Set title and main template.
58    $nav->add($item['__///__']);
59    $main_template = '%PUBLIC_DETAIL_TEMPLATE%';
60
61} else {
62
63    // Get the DEFAULT list.
64    $%NAME_SINGULAR%_list = array();
65    $qid = $db->query("
66        SELECT *
67        FROM %DB_TBL%
68        WHERE publish = 'true'
69        " . $so->getSortOrderSQL() . "
70        LIMIT 100
71    ");
72    while ($row = mysql_fetch_assoc($qid)) {
73        $%NAME_SINGULAR%_list[] = $row;
74    }
75
76    // Set page numbers for default list.
77    $page->setTotalItems(sizeof($%NAME_SINGULAR%_list));
78    $page->calculate();
79
80
81    // Get the FEATURED list.
82    $featured_list = array();
83    $qid = $db->query("
84        SELECT *
85        FROM %DB_TBL%
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    }
93
94    // Get the POPULAR list.
95    $popular_list = array();
96    $qid = $db->query("
97        SELECT *
98        FROM %DB_TBL%
99        WHERE publish = 'true'
100        ORDER BY hit_count DESC LIMIT 10
101    ");
102    while ($row = mysql_fetch_assoc($qid)) {
103        $popular_list[] = $row;
104    }
105
106    // Get the RECENT list.
107    $recent_list = array();
108    $qid = $db->query("
109        SELECT *
110        FROM %DB_TBL%
111        WHERE publish = 'true'
112        ORDER BY added_datetime DESC LIMIT 10
113    ");
114    while ($row = mysql_fetch_assoc($qid)) {
115        $recent_list[] = $row;
116    }
117
118    // Set main template.
119    $main_template = '%PUBLIC_LIST_TEMPLATE%';
120}
121
122// We have the data, and no errors, so here come the templates.
123include 'header.ihtml';
124include $main_template;
125include 'footer.ihtml';
126
127?>
Note: See TracBrowser for help on using the repository browser.