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

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

Q - global comments formatting change

File size: 3.4 KB
RevLine 
[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
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->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
33if (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'
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)) {
[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.
56    $nav->addPage($item['<##>']);
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.
121include 'header.ihtml';
122include $main_template;
123include 'footer.ihtml';
124
125?>
Note: See TracBrowser for help on using the repository browser.