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

Revision 405, 8.7 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: viewcat.php,v 1.6 2006/05/01 02:37:28 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
32$cid = intval($_GET['cid']);
33$xoopsOption['template_main'] = 'mylinks_viewcat.html';
34include XOOPS_ROOT_PATH."/header.php";
35
36if (isset($_GET['show'])) {
37        $show = intval($_GET['show']);
38} else {
39        $show = $xoopsModuleConfig['perpage'];
40}
41$min = isset($_GET['min']) ? intval($_GET['min']) : 0;
42if (!isset($max)) {
43        $max = $min + $show;
44}
45if(isset($_GET['orderby'])) {
46        $orderby = convertorderbyin($_GET['orderby']);
47} else {
48        $orderby = "title ASC";
49}
50
51$pathstring = "<a href='index.php'>"._MD_MAIN."</a>&nbsp;:&nbsp;";
52$pathstring .= $mytree->getNicePathFromId($cid, "title", "viewcat.php?op=");
53$xoopsTpl->assign('category_path', $pathstring);
54$xoopsTpl->assign('category_id', $cid);
55// get child category objects
56$arr=array();
57$arr=$mytree->getFirstChild($cid, "title");
58if ( count($arr) > 0 ) {
59    $scount = 1;
60    foreach($arr as $ele){
61        $sub_arr=array();
62        $sub_arr=$mytree->getFirstChild($ele['cid'], "title");
63        $space = 0;
64        $chcount = 0;
65        $infercategories = "";
66        foreach($sub_arr as $sub_ele){
67            $chtitle=$myts->makeTboxData4Show($sub_ele['title']);
68            if ($chcount>5){
69                $infercategories .= "...";
70                break;
71            }
72            if ($space>0) {
73                $infercategories .= ", ";
74            }
75            $infercategories .= "<a href=\"".XOOPS_URL."/modules/mylinks/viewcat.php?cid=".$sub_ele['cid']."\">".$chtitle."</a>";
76            $space++;
77            $chcount++;
78        }
79        $xoopsTpl->append('subcategories', array('title' => $myts->makeTboxData4Show($ele['title']), 'id' => $ele['cid'], 'infercategories' => $infercategories, 'totallinks' => getTotalItems($ele['cid'], 1), 'count' => $scount));
80        $scount++;
81    }
82}
83
84if ($xoopsModuleConfig['useshots'] == 1) {
85    $xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']);
86    $xoopsTpl->assign('tablewidth', $xoopsModuleConfig['shotwidth'] + 10);
87    $xoopsTpl->assign('show_screenshot', true);
88    $xoopsTpl->assign('lang_noscreenshot', _MD_NOSHOTS);
89}
90
91if (!empty($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
92    $isadmin = true;
93} else {
94    $isadmin = false;
95}
96$fullcountresult=$xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_links")." where cid=$cid and status>0");
97list($numrows) = $xoopsDB->fetchRow($fullcountresult);
98$page_nav = '';
99if($numrows>0){
100    $xoopsTpl->assign('lang_description', _MD_DESCRIPTIONC);
101    $xoopsTpl->assign('lang_lastupdate', _MD_LASTUPDATEC);
102    $xoopsTpl->assign('lang_hits', _MD_HITSC);
103    $xoopsTpl->assign('lang_rating', _MD_RATINGC);
104    $xoopsTpl->assign('lang_ratethissite', _MD_RATETHISSITE);
105    $xoopsTpl->assign('lang_reportbroken', _MD_REPORTBROKEN);
106    $xoopsTpl->assign('lang_tellafriend', _MD_TELLAFRIEND);
107    $xoopsTpl->assign('lang_modify', _MD_MODIFY);
108    $xoopsTpl->assign('lang_category' , _MD_CATEGORYC);
109    $xoopsTpl->assign('lang_visit' , _MD_VISIT);
110    $xoopsTpl->assign('show_links', true);
111    $xoopsTpl->assign('lang_comments' , _COMMENTS);
112    $sql = "select l.lid, l.cid, l.title, l.url, l.logourl, l.status, l.date, l.hits, l.rating, l.votes, l.comments, t.description from ".$xoopsDB->prefix("mylinks_links")." l, ".$xoopsDB->prefix("mylinks_text")." t where cid=$cid and l.lid=t.lid and status>0 order by $orderby";
113    $result=$xoopsDB->query($sql,$show,$min);
114
115    //if 2 or more items in result, show the sort menu
116    if($numrows>1){
117        $xoopsTpl->assign('show_nav', true);
118        $orderbyTrans = convertorderbytrans($orderby);
119        $xoopsTpl->assign('lang_sortby', _MD_SORTBY);
120        $xoopsTpl->assign('lang_title', _MD_TITLE);
121        $xoopsTpl->assign('lang_date', _MD_DATE);
122        $xoopsTpl->assign('lang_rating', _MD_RATING);
123        $xoopsTpl->assign('lang_popularity', _MD_POPULARITY);
124        $xoopsTpl->assign('lang_cursortedby', sprintf(_MD_CURSORTEDBY, convertorderbytrans($orderby)));
125    }
126    while(list($lid, $cid,$ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result)) {
127        if ($isadmin) {
128            $adminlink = '<a href="'.XOOPS_URL.'/modules/mylinks/admin/?op=modLink&amp;lid='.$lid.'"><img src="'.XOOPS_URL.'/modules/mylinks/images/editicon.gif" border="0" alt="'._MD_EDITTHISLINK.'" /></a>';
129        } else {
130            $adminlink = '';
131        }
132        if ($votes == 1) {
133            $votestring = _MD_ONEVOTE;
134        } else {
135            $votestring = sprintf(_MD_NUMVOTES,$votes);
136        }
137        $path = $mytree->getPathFromId($cid, "title");
138        $path = substr($path, 1);
139        $path = str_replace("/"," <img src='".XOOPS_URL."/modules/mylinks/images/arrow.gif' board='0' alt='' /> ",$path);
140        $new = newlinkgraphic($time, $status);
141        $pop = popgraphic($hits);
142        $xoopsTpl->append('links', array('id' => $lid, 'cid' => $cid, 'rating' => number_format($rating, 2), 'title' => $myts->makeTboxData4Show($ltitle).$new.$pop, 'category' => $path, 'logourl' => $myts->makeTboxData4Show($logourl), 'updated' => formatTimestamp($time,"m"), 'description' => $myts->makeTareaData4Show($description,0), 'adminlink' => $adminlink, 'hits' => $hits, 'comments' => $comments, 'votes' => $votestring, 'mail_subject' => rawurlencode(sprintf(_MD_INTRESTLINK,$xoopsConfig['sitename'])), 'mail_body' => rawurlencode(sprintf(_MD_INTLINKFOUND,$xoopsConfig['sitename']).':  '.XOOPS_URL.'/modules/mylinks/singlelink.php?cid='.$cid.'&lid='.$lid)));
143    }
144    $orderby = convertorderbyout($orderby);
145    //Calculates how many pages exist.  Which page one should be on, etc...
146    $linkpages = ceil($numrows / $show);
147    //Page Numbering
148    if ($linkpages!=1 && $linkpages!=0) {
149        $cid = intval($_GET['cid']);
150        $prev = $min - $show;
151        if ($prev>=0) {
152            $page_nav .= "<a href='viewcat.php?cid=$cid&amp;min=$prev&amp;orderby=$orderby&amp;show=$show'><b><u>&laquo;</u></b></a>&nbsp;";
153        }
154        $counter = 1;
155        $currentpage = ($max / $show);
156        while ( $counter<=$linkpages ) {
157            $mintemp = ($show * $counter) - $show;
158            if ($counter == $currentpage) {
159                $page_nav .= "<b>($counter)</b>&nbsp;";
160            } else {
161                $page_nav .= "<a href='viewcat.php?cid=$cid&amp;min=$mintemp&amp;orderby=$orderby&amp;show=$show'>$counter</a>&nbsp;";
162            }
163            $counter++;
164        }
165        if ( $numrows>$max ) {
166            $page_nav .= "<a href='viewcat.php?cid=$cid&amp;min=$max&amp;orderby=$orderby&amp;show=$show'>";
167            $page_nav .= "<b><u>&raquo;</u></b></a>";
168        }
169    }
170}
171$xoopsTpl->assign('page_nav', $page_nav);
172include XOOPS_ROOT_PATH.'/footer.php';
173?>
Note: See TracBrowser for help on using the repository browser.