Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/Web_Links/wl-viewlink.php
<?php
// File: $Id: wl-viewlink.php,v 1.3 2001/12/05 13:04:25 gregorrothfuss 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:
// ----------------------------------------------------------------------
// 11-30-2001:ahumphr - created file as part of modularistation

/**
 *sortLinksByMenu
 * generates the sort links by menu
 */
function sortLinksByMenu($cid, $orderbyTrans)
{
    global $modurl;

    echo "<center><font class=\"pn-normal\">"._SORTLINKSBY.": "
        .""._TITLE." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;orderby=titleA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;orderby=titleD\">D</a>) "
        .""._DATE." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;orderby=dateA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;orderby=dateD\">D</a>) "
        .""._RATING." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;orderby=ratingA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;orderby=ratingD\">D</a>) "
        .""._POPULARITY." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;orderby=hitsA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;orderby=hitsD\">D</a>)"
        ."<br><b>"._SITESSORTED.": $orderbyTrans</b></font></center><br><br>";
}

/**
 * viewlink
 */
function viewlink($cid, $min, $orderby, $show) {
    global $admin, $perpage, $pntable, $dbconn, $ModName;
    global $modurl;
    global $web_links_show_star;
    include("header.php");

    if (!isset($min)) $min=0;
    if (!isset($max)) $max=$min+$perpage;

    if(isset($orderby)) {
        $orderby = convertorderbyin($orderby);
    } else {
        $orderby = convertorderbyin("titleA");
    }
    if ($show!="") {
        $perpage = $show;
    } else {
        $show=$perpage;
    }
    menu(1);
    echo "<br>";

    OpenTable();
    $column = &$pntable['links_categories_column'];
    $result=$dbconn->Execute("SELECT $column[title] , $column[cdescription] FROM $pntable[links_categories] WHERE $column[cat_id]=$cid");
    list($title, $description) = $result->fields;
    echo "<center><font class=\"pn-normal\"><b>"._CATEGORY.": ".CatPath($cid,1,1,0)."</b></font>"
    ."<br>".$description."</center><br>";
    $carrytitle = $title;

    $column = &$pntable['links_categories_column'];
    $subresult=$dbconn->Execute("SELECT $column[cat_id], $column[title]
                                        FROM $pntable[links_categories] WHERE $column[parent_id]=$cid");

    //FTO Check db error and EOF + don't use record count to stay portable
    if (!$subresult) {
          PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
          die();
        }


    //$numrows = $subresult->PO_Record Count();
     $numrows=0;
    
//    if ($numrows != 0) {
     if (!$subresult->EOF) {
        $scount = 0;
        echo "<center><font class=\"pn-normal\">"._LALSOAVAILABLE." <i>$title</i> "._SUBCATEGORIES.":</font></center><br>"
            ."<table align=\"center\" border=\"0\"><tr>";
    //FTO Check EOF
        while(!$subresult->EOF) {
            list($sid, $title) = $subresult->fields;
            $subresult->MoveNext();
            $column = &$pntable['links_links_column'];
            $result2 = $dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_links] WHERE $column[cat_id]=$sid");
            list($numrows) = $result2->fields;

            echo "<td><a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$sid\">"
            .$title."</a><font class=\"pn-normal\"> (".CountSubLinks($sid).")&nbsp;</font>";
            subcategorynewlinkgraphic($sid);
            echo "&nbsp;&nbsp;</td>";

            $scount++;
            if ($scount==4) {
                echo "</tr><tr>";
                $scount = 0;
            }
        }
        if ($count != 0) {
            echo "</tr></table>";
        } else {
            echo "<td></td></tr></table>";
        }
        echo "<hr noshade size=\"1\">";
    }
    $orderbyTrans = convertorderbytrans($orderby);

    sortLinksByMenu($cid, $orderbyTrans);


    $column = &$pntable['links_links_column'];
    $fullcountresult=$dbconn->Execute("SELECT count(*) FROM $pntable[links_links] WHERE $column[cat_id]=$cid");
    list($totalselectedlinks) = $fullcountresult->fields;
    echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"pn-normal\">";
    $x=0;

    $query = buildSimpleQuery ('links_links', array ('lid', 'title', 'description', 'date', 'hits', 'linkratingsummary', 'totalvotes', 'totalcomments'), "$column[cat_id]=$cid", $orderby, $perpage, $min);
    $result=$dbconn->Execute($query);

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

    while(!$result->EOF) {
        list($lid, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=$result->fields;
        $result->MoveNext();
        $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
        $title = stripslashes($title);
        $description = stripslashes($description);
        echo "<a class=\"pn-title\" href=\"${modurl}&amp;req=visit&amp;lid=$lid\" target=\"new\">$title</a>";
        newlinkgraphic($datetime, $time);
        popgraphic($hits);
        /* INSERT code for *editor review* here */
        echo "<br>";
        echo ""._DESCRIPTION.": $description<br>";
        setlocale ("LC_TIME", "$locale");
        ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
        $datetime = ml_ftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
        $datetime = ucfirst($datetime);
        echo ""._ADDEDON.": $datetime "._HITS.": $hits";
        $transfertitle = str_replace (" ", "_", $title);
        /* voting & comments stats */
        if ($totalvotes == 1) {
            $votestring = _VOTE;
        } else {
            $votestring = _VOTES;
        }
        if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
            echo " "._RATING.": $linkratingsummary ($totalvotes $votestring)";
            if ($web_links_show_star) {
                echo " ".web_links_rateMakeStar($linkratingsummary, 10);
            }
        }
        LinksBottomMenu($lid, $transfertitle, $totalvotes, $totalcomments);
        detecteditorial($lid, $transfertitle);
        echo "<br><br>";
        $x++;
    }
    echo "</font>";
    $orderby = convertorderbyout($orderby);
    /* Calculates how many pages exist. Which page one should be on, etc... */
    $linkpagesint = ($totalselectedlinks / $perpage);
    $linkpageremainder = ($totalselectedlinks % $perpage);
    if ($linkpageremainder != 0) {
        $linkpages = ceil($linkpagesint);
        if ($totalselectedlinks < $perpage) {
            $linkpageremainder = 0;
        }
    } else {
        $linkpages = $linkpagesint;
    }
    /* Page Numbering */
    if ($linkpages!=1 && $linkpages!=0) {
        echo "<br><br>";
        echo ""._SELECTPAGE.": ";
        $prev=$min-$perpage;
        if ($prev>=0) {
            echo "&nbsp;&nbsp;<b>[ <a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;min=$prev&amp;orderby=$orderby&amp;show=$show\">";
            echo " &lt;&lt; "._PREVIOUS."</a> ]</b> ";
        }
        $counter = 1;
        $currentpage = ($max / $perpage);
        while ($counter<=$linkpages ) {
            $cpage = $counter;
            $mintemp = ($perpage * $counter) - $perpage;
            if ($counter == $currentpage) {
                echo "<b>$counter</b>&nbsp";
            } else {
                echo "<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;min=$mintemp&amp;orderby=$orderby&amp;show=$show\">$counter</a> ";
            }
            $counter++;
        }
        $next=$min+$perpage;
        if ($x>=$perpage) {
            echo "&nbsp;&nbsp;<b>[ <a class=\"pn-normal\" href=\"${modurl}&amp;req=viewlink&amp;cid=$cid&amp;min=$max&amp;orderby=$orderby&amp;show=$show\">";
            echo " "._NEXT." &gt;&gt;</a> ]</b> ";
        }
    }
    echo "</td></tr></table>";
    CloseTable();
    include("footer.php");
}

function viewslink($sid, $min, $orderby, $show) {
    global $admin, $ModName, $pntable, $dbconn;
    global $modurl;
    global $web_links_show_star;
    include(WHERE_IS_PERSO."config.php");
    include("header.php");
    menu(1);
    if (!isset($min)) $min=0;
    if (!isset($max)) $max=$min+$perpage;
    if(isset($orderby)) {
        $orderby = convertorderbyin($orderby);
    } else {
        $orderby = convertorderbyin("titleA");
    }
    if ($show!="") {
        $perpage = $show;
    } else {
        $show=$perpage;
    }
    echo "<br>";
    OpenTable();
    $column = &$pntable['links_subcategories_column'];
    $result = $dbconn->Execute("SELECT $column[cid], $column[title] FROM $pntable[links_subcategories] WHERE $column[sid]=$sid");
    list($cid, $stitle) = $result->fields;

    $column = &$pntable['links_categories_column'];
    $result2 = $dbconn->Execute("SELECT $column[cid], $column[title] FROM $pntable[links_categories] WHERE $column[cid]=$cid");
    list($cid, $title) = $result2->fields;

    echo "<center><font class=\"pn-normal\"><b><a class=\"pn-normal\" href=\"${modurl}\">"._MAIN."</a> / <a class=\"pn-normal\" href=\"${modurl}&ampreq=viewlink&amp;cid=$cid\">$title</a> / $stitle</b></font></center>";
    $orderbyTrans = convertorderbytrans($orderby);
    echo "<br><center><font class=\"pn-normal\">"._SORTLINKSBY.": "
        .""._TITLE." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;orderby=titleA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;orderby=titleD\">D</a>)"
        ." "._DATE." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;orderby=dateA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;orderby=dateD\">D</a>)"
        ." "._RATING." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;orderby=ratingA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;orderby=ratingD\">D</a>)"
        ." "._POPULARITY." (<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;orderby=hitsA\">A</a>/<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;orderby=hitsD\">D</a>)"
        ."<br><b>"._SITESSORTED.": $orderbyTrans</b></font></center><br><br>";
    $column = &$pntable['links_links_column'];
    $fullcountresult=$dbconn->Execute("SELECT COUNT(*) FROM $pntable[links_links] WHERE $column[cat_id]=$sid");
    list($totalselectedlinks) = $fullcountresult->fields;
    echo "<table width=\"100%\" cellspacing=\"0\" cellpadding=\"10\" border=\"0\"><tr><td><font class=\"pn-normal\">";
    $x=0;
    $myquery = buildSimpleQuery ('links_links', array ('lid', 'url', 'title', 'description', 'date', 'hits', 'linkratingsummary', 'totalvotes', 'totalcomments'), "$column[cat_id]=$sid", $orderby, $perpage, $min);
    $result=$dbconn->Execute($myquery);

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

    while(!$result->EOF) {
        list($lid, $url, $title, $description, $time, $hits, $linkratingsummary, $totalvotes, $totalcomments)=$result->fields;
        $result->MoveNext();
        $linkratingsummary = number_format($linkratingsummary, $mainvotedecimal);
        $title = stripslashes($title); $description = stripslashes($description);
        echo "<a class=\"pn-title\" href=\"${modurl}&amp;req=visit&amp;lid=$lid\" target=\"new\">$title</a>";
        newlinkgraphic($datetime, $time);
        popgraphic($hits);
        /* code for *editor review* insert here */
        echo "<br>"._DESCRIPTION.": $description<br>";
        setlocale ("LC_TIME", "$locale");
        ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})", $time, $datetime);
        $datetime = ml_ftime(""._LINKSDATESTRING."", mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]));
        $datetime = ucfirst($datetime);
        echo ""._ADDEDON.": $datetime "._HITS.": $hits";
        $transfertitle = str_replace (" ", "_", $title);
        /* voting & comments stats */
        if ($totalvotes == 1) {
            $votestring = _VOTE;
        } else {
            $votestring = _VOTES;
        }
        if ($linkratingsummary!="0" || $linkratingsummary!="0.0") {
            echo " "._RATING.": $linkratingsummary ($totalvotes $votestring)";
            if ($web_links_show_star) {
                echo " ".web_links_rateMakeStar($linkratingsummary, 10);
            }
        }
        LinksBottomMenu($lid, $transfertitle, $totalvotes, $totalcomments);
        detecteditorial($lid, $transfertitle);
        echo "<br><br>";
        $x++;
    }
    echo "</font>";
    $orderby = convertorderbyout($orderby);
    /* Calculates how many pages exist.  Which page one should be on, etc... */
    $linkpagesint = ($totalselectedlinks / $perpage);
    $linkpageremainder = ($totalselectedlinks % $perpage);
    if ($linkpageremainder != 0) {
        $linkpages = ceil($linkpagesint);
        if ($totalselectedlinks < $perpage) {
            $linkpageremainder = 0;
        }
    } else {
        $linkpages = $linkpagesint;
    }
    /* Page Numbering */
    if ($linkpages!=1 && $linkpages!=0) {
        echo "<br><br>"
            .""._SELECTPAGE.": ";
        $prev=$min-$perpage;
        if ($prev>=0) {
            echo "&nbsp;&nbsp;<b>[ <a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;min=$prev&amp;orderby=$orderby&amp;show=$show\">"
            ." &lt;&lt; "._PREVIOUS."</a> ]</b> ";
        }
        $counter = 1;
        $currentpage = ($max / $perpage);
        while ($counter<=$linkpages ) {
            $cpage = $counter;
            $mintemp = ($perpage * $counter) - $perpage;
            if ($counter == $currentpage) {
            echo "<b>$counter</b>&nbsp";
        } else {
            echo "<a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;min=$mintemp&amp;orderby=$orderby&amp;show=$show\">$counter</a> ";
        }
            $counter++;
        }
        $next=$min+$perpage;
        if ($x>=$perpage) {
            echo "&nbsp;&nbsp;<b>[ <a class=\"pn-normal\" href=\"${modurl}&amp;req=viewslink&amp;sid=$sid&amp;min=$max&amp;orderby=$orderby&amp;show=$show\">"
            ." "._NEXT." &gt;&gt;</a> ]</b> ";
        }
    }
    echo "</td></tr></table>";
    CloseTable();
    include("footer.php");
}

?>
Return current item: ProNuke. Postnuke To Oracle