Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/Downloads/dl-navigation.php
<?php
// File: $Id: dl-navigation.php,v 1.5 2001/12/12 17:19:18 jgm Exp $ $Name:  $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file:
// ----------------------------------------------------------------------

/**
 * index
 * Display the main links categories
 */
function index() {
    global $pntable, $ModName, $dbconn, $modurl;
    include("header.php");
    $maindownload = 0;

    if (!authorised(0, 'Downloads::', '::', ACCESS_READ)) {
        echo _DOWNLOADSACCESSNOAUTH;
        include 'footer.php';
        return;
    }

    menu($maindownload);
    echo "<br>";

    OpenTable();

    // Main categories
    echo "<center><font class=\"pn-title\">"._DOWNLOADSMAINCAT."</font></center><br>";
    echo "<table border=\"0\" cellspacing=\"10\" cellpadding=\"0\" align=\"center\">";
    $column = &$pntable['downloads_categories_column'];
    $result=$dbconn->Execute("SELECT $column[cid], $column[title], $column[cdescription]
                            FROM $pntable[downloads_categories]
                            ORDER BY $column[title]");

    $count = 0;
    echo "<TR>";

//FTO : Test EOF and database error
    if (!$result) {
        PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
        die();
    }


    while(!$result->EOF) {

        list($cid, $title, $cdescription) = $result->fields;
        $result->MoveNext();

        if (authorised(0, 'Downloads::Category', "$title::$cid", ACCESS_READ)) {
            $cresult = $dbconn->Execute("SELECT count(*) FROM ".$pntable['downloads_downloads'].
            " WHERE ".$pntable['downloads_downloads_column']['cid']."=".$cid);

            list($cnumrows) = $cresult->fields;
            echo "<td><font class=\"pn-normal\"><strong><big>&middot;</big></strong> <a href=\"${modurl}&amp;req=viewdownload&amp;cid=$cid\">$title</a> ($cnumrows)</font>";
            categorynewdownloadgraphic($cid);
            if ($cdescription) {
                echo "<font class=\"pn-normal\">$cdescription</font>";
            }
            echo "<br>";
            $column = &$pntable['downloads_subcategories_column'];
            $sql = "SELECT $column[sid], $column[title]
                    FROM $pntable[downloads_subcategories]
                    WHERE $column[cid]=$cid
                    ORDER BY $column[title]";
            $result2 = $dbconn->SelectLimit($sql,3);
            $space = 0;

// FTO Check EOF and databse error
            if (!$result2) {
               PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
               die();
            }
            while(!$result2->EOF) {

                list($sid, $stitle) = $result2->fields;
                if ($space>0) {
                    echo ",&nbsp;";
                }
                if (authorised(0, 'Downloads::Category', "$stitle::$sid", ACCESS_READ)) {
                    echo "<font class=\"pn-normal\"><a class=\"pn-normal\" href=\"modules.php?op=modload&amp;name=$ModName&amp;file=index&amp;req=viewsdownload&amp;sid=$sid\">$stitle</a></font>";
                }
                $space++;
                $result2->MoveNext();
            }
            echo "</td>";
            $count++;
            if ($count==3) {
                echo "</tr><tr>";
                $count = 0;
            }
        }

    }
    for ($i=$count; $i<3; $i++) {
        echo "<td>&nbsp;</td>";
    }
    echo "</tr></table>";
    
    // Number of current categories and subcategories
    $result=$dbconn->Execute("SELECT count(*) FROM $pntable[downloads_downloads]");
    list($numrows) = $result->fields;
    /*
     * hootbah: FIXME
     * This can be done in one database hit.
     */
    $result=$dbconn->Execute("SELECT count(*) FROM $pntable[downloads_categories]");
    list($catnum1) = $result->fields;
    $result=$dbconn->Execute("SELECT count(*) FROM $pntable[downloads_subcategories]");
    list($catnum2) = $result->fields;
    $catnum = $catnum1+$catnum2;

    echo "<br><br><center><font class=\"pn-normal\">"._THEREARE." $numrows "._DOWNLOADS." "._AND." $catnum "._CATEGORIES." "._INDB."</font></center>";
    CloseTable();
    include("footer.php");
}


/**
 * menu
 * builds the standard navigation menu
 * @param maindownload  integer switch. 1 means show _DOWNLOADSMAIN, 0 not.
 */
function menu($maindownload) {
    global $user_adddownload, $ModName, $sitename, $query, $modurl;

    if (!authorised(0, 'Downloads::', '::', ACCESS_READ)) {
        echo _DOWNLOADSACCESSNOAUTH;
        include 'footer.php';
        return;
    }

    OpenTable();
    echo "<br><center><a class=\"pn-logo\"  href=\"$modurl\">$sitename -- "._DLOADPAGETITLE."</a><br><br>";
    echo "<form action=\"modules.php\" method=\"post\">"
    ."\n<input type=\"hidden\" name=\"op\" value=\"modload\">"
    ."\n<input type=\"hidden\" name=\"name\" value=\"$ModName\">"
    ."\n<input type=\"hidden\" name=\"file\" value=\"index\">"
    ."\n<input type=\"hidden\" name=\"req\" value=\"search\">"
    ."\n<input type=\"hidden\" name=\"query\" value=\"$query\">"
    ."\n<font class=\"pn-normal\"><input type=\"text\" size=\"25\" name=\"query\"> <input type=\"submit\" value=\""._SEARCH."\"></font>"
    ."\n</form>";
    echo "<font class=\"pn-normal\">[ ";
    if ($maindownload>0) {
        echo "<a class=\"pn-normal\" href=\"$modurl\">"._DOWNLOADSMAIN."</a> | ";
    }
    if (authorised(0, 'Downloads::Item', '::', ACCESS_COMMENT)) {
        echo "<a class=\"pn-normal\" href=\"$modurl&amp;req=AddDownload\">"._ADDDOWNLOAD."</a>"
        ." | ";
    }
    echo "<a class=\"pn-normal\" href=\"$modurl&amp;req=NewDownloads\">"._NEW."</a>"
    ." | <a class=\"pn-normal\" href=\"$modurl&amp;req=MostPopular\">"._POPULAR."</a>"
    ." | <a class=\"pn-normal\" href=\"$modurl&amp;req=TopRated\">"._TOPRATED."</a> ]"
    ."</font></center>";
    CloseTable();
}


?>
Return current item: ProNuke. Postnuke To Oracle