source: temp/test-xoops.ec-cube.net/html/modules/mylinks/topten.php @ 405

Revision 405, 3.9 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: topten.php,v 1.2 2005/03/18 12:52:24 onokazu Exp $
3//  ------------------------------------------------------------------------ //
4//                XOOPS - PHP Content Management System                      //
5//                    Copyright (c) 2000 XOOPS.org                           //
6//                       <http://www.xoops.org/>                             //
7// ------------------------------------------------------------------------- //
8//  This program is free software; you can redistribute it and/or modify     //
9//  it under the terms of the GNU General Public License as published by     //
10//  the Free Software Foundation; either version 2 of the License, or        //
11//  (at your option) any later version.                                      //
12//                                                                           //
13//  You may not change or alter any portion of this comment or credits       //
14//  of supporting developers from this source code or any supporting         //
15//  source code which is considered copyrighted (c) material of the          //
16//  original comment or credit authors.                                      //
17//                                                                           //
18//  This program is distributed in the hope that it will be useful,          //
19//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
20//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
21//  GNU General Public License for more details.                             //
22//                                                                           //
23//  You should have received a copy of the GNU General Public License        //
24//  along with this program; if not, write to the Free Software              //
25//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
26//  ------------------------------------------------------------------------ //
27include "header.php";
28$myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object
29include_once XOOPS_ROOT_PATH."/class/xoopstree.php";
30$mytree = new XoopsTree($xoopsDB->prefix("mylinks_cat"),"cid","pid");
31$xoopsOption['template_main'] = 'mylinks_topten.html';
32include XOOPS_ROOT_PATH."/header.php";
33//generates top 10 charts by rating and hits for each main category
34
35if(!empty($_GET['rate'])){
36    $sort = _MD_RATING;
37    $sortDB = "rating";
38}else{
39    $sort = _MD_HITS;
40    $sortDB = "hits";
41}
42$xoopsTpl->assign('lang_sortby' ,$sort);
43$xoopsTpl->assign('lang_rank' , _MD_RANK);
44$xoopsTpl->assign('lang_title' , _MD_TITLE);
45$xoopsTpl->assign('lang_category' , _MD_CATEGORY);
46$xoopsTpl->assign('lang_hits' , _MD_HITS);
47$xoopsTpl->assign('lang_rating' , _MD_RATING);
48$xoopsTpl->assign('lang_vote' , _MD_VOTE);
49$arr=array();
50$result=$xoopsDB->query("select cid, title from ".$xoopsDB->prefix("mylinks_cat")." where pid=0");
51$e = 0;
52$rankings = array();
53while(list($cid, $ctitle)=$xoopsDB->fetchRow($result)){
54    $rankings[$e]['title'] = sprintf(_MD_TOP10, $myts->htmlSpecialChars($ctitle));
55    $query = "select lid, cid, title, hits, rating, votes from ".$xoopsDB->prefix("mylinks_links")." where status>0 and (cid=$cid";
56    // get all child cat ids for a given cat id
57    $arr=$mytree->getAllChildId($cid);
58    $size = count($arr);
59    for($i=0;$i<$size;$i++){
60        $query .= " or cid=".$arr[$i]."";
61    }
62    $query .= ") order by ".$sortDB." DESC";
63    $result2 = $xoopsDB->query($query,10,0);
64    $rank = 1;
65    while(list($lid,$lcid,$ltitle,$hits,$rating,$votes)=$xoopsDB->fetchRow($result2)){
66        $catpath = $mytree->getPathFromId($lcid, "title");
67        $catpath= substr($catpath, 1);
68        $catpath = str_replace("/"," <span class='fg2'>&raquo;</span> ",$catpath);
69        $rankings[$e]['links'][] = array('id' => $lid, 'cid' => $cid, 'rank' => $rank, 'title' => $myts->htmlSpecialChars($ltitle), 'category' => $catpath, 'hits' => $hits, 'rating' => number_format($rating, 2), 'votes' => $votes);
70        $rank++;
71    }
72    $e++;
73}
74$xoopsTpl->assign('rankings', $rankings);
75include XOOPS_ROOT_PATH.'/footer.php';
76?>
Note: See TracBrowser for help on using the repository browser.