| 1 | <?php
|
|---|
| 2 | // $Id: viewcat.php,v 1.1 2004/09/09 05:15:10 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 | // ------------------------------------------------------------------------ //
|
|---|
| 27 |
|
|---|
| 28 | include "header.php";
|
|---|
| 29 | include_once XOOPS_ROOT_PATH."/class/xoopstree.php";
|
|---|
| 30 | $xoopsOption['template_main'] = 'mydownloads_viewcat.html';
|
|---|
| 31 | $myts =& MyTextSanitizer::getInstance();// MyTextSanitizer object
|
|---|
| 32 | $mytree = new XoopsTree($xoopsDB->prefix("mydownloads_cat"),"cid","pid");
|
|---|
| 33 |
|
|---|
| 34 | $cid = intval($HTTP_GET_VARS['cid']);
|
|---|
| 35 | include XOOPS_ROOT_PATH."/header.php";
|
|---|
| 36 |
|
|---|
| 37 | if (isset($HTTP_GET_VARS['show']) && $HTTP_GET_VARS['show']!="") {
|
|---|
| 38 | $show = intval($HTTP_GET_VARS['show']);
|
|---|
| 39 | } else {
|
|---|
| 40 | $show = $xoopsModuleConfig['perpage'];
|
|---|
| 41 | }
|
|---|
| 42 | $min = isset($HTTP_GET_VARS['min']) ? intval($HTTP_GET_VARS['min']) : 0;
|
|---|
| 43 | if (!isset($max)) {
|
|---|
| 44 | $max = $min + $show;
|
|---|
| 45 | }
|
|---|
| 46 | if(isset($HTTP_GET_VARS['orderby'])) {
|
|---|
| 47 | $orderby = convertorderbyin($HTTP_GET_VARS['orderby']);
|
|---|
| 48 | } else {
|
|---|
| 49 | $orderby = "title ASC";
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 | $pathstring = "<a href='index.php'>"._MD_MAIN."</a> : ";
|
|---|
| 54 | $pathstring .= $mytree->getNicePathFromId($cid, "title", "viewcat.php?op=");
|
|---|
| 55 | $xoopsTpl->assign('category_path', $pathstring);
|
|---|
| 56 | $xoopsTpl->assign('category_id', $cid);
|
|---|
| 57 | // get child category objects
|
|---|
| 58 | $arr=array();
|
|---|
| 59 | $arr=$mytree->getFirstChild($cid, "title");
|
|---|
| 60 | if ( count($arr) > 0 ) {
|
|---|
| 61 | $scount = 1;
|
|---|
| 62 | foreach($arr as $ele){
|
|---|
| 63 | $sub_arr=array();
|
|---|
| 64 | $sub_arr=$mytree->getFirstChild($ele['cid'], "title");
|
|---|
| 65 | $space = 0;
|
|---|
| 66 | $chcount = 0;
|
|---|
| 67 | $infercategories = "";
|
|---|
| 68 | foreach($sub_arr as $sub_ele){
|
|---|
| 69 | $chtitle=$myts->makeTboxData4Show($sub_ele['title']);
|
|---|
| 70 | if ($chcount>5){
|
|---|
| 71 | $infercategories .= "...";
|
|---|
| 72 | break;
|
|---|
| 73 | }
|
|---|
| 74 | if ($space>0) {
|
|---|
| 75 | $infercategories .= ", ";
|
|---|
| 76 | }
|
|---|
| 77 | $infercategories .= "<a href=\"".XOOPS_URL."/modules/mydownloads/viewcat.php?cid=".$sub_ele['cid']."\">".$chtitle."</a>";
|
|---|
| 78 | $space++;
|
|---|
| 79 | $chcount++;
|
|---|
| 80 | }
|
|---|
| 81 | $xoopsTpl->append('subcategories', array('title' => $myts->makeTboxData4Show($ele['title']), 'id' => $ele['cid'], 'infercategories' => $infercategories, 'totallinks' => getTotalItems($ele['cid'], 1), 'count' => $scount));
|
|---|
| 82 | $scount++;
|
|---|
| 83 | }
|
|---|
| 84 | }
|
|---|
| 85 |
|
|---|
| 86 | if ($xoopsModuleConfig['useshots'] == 1) {
|
|---|
| 87 | $xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']);
|
|---|
| 88 | $xoopsTpl->assign('tablewidth', $xoopsModuleConfig['shotwidth'] + 10);
|
|---|
| 89 | $xoopsTpl->assign('show_screenshot', true);
|
|---|
| 90 | $xoopsTpl->assign('lang_noscreenshot', _MD_NOSHOTS);
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | if (!empty($xoopsUser) && $xoopsUser->isAdmin($xoopsModule->mid())) {
|
|---|
| 94 | $isadmin = true;
|
|---|
| 95 | } else {
|
|---|
| 96 | $isadmin = false;
|
|---|
| 97 | }
|
|---|
| 98 | $fullcountresult=$xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_downloads")." WHERE cid=$cid AND status>0");
|
|---|
| 99 | list($numrows) = $xoopsDB->fetchRow($fullcountresult);
|
|---|
| 100 | $page_nav = '';
|
|---|
| 101 | if($numrows>0){
|
|---|
| 102 | $xoopsTpl->assign('lang_description', _MD_DESCRIPTIONC);
|
|---|
| 103 | $xoopsTpl->assign('lang_lastupdate', _MD_LASTUPDATEC);
|
|---|
| 104 | $xoopsTpl->assign('lang_hits', _MD_HITSC);
|
|---|
| 105 | $xoopsTpl->assign('lang_ratingc', _MD_RATINGC);
|
|---|
| 106 | $xoopsTpl->assign('lang_email', _MD_EMAILC);
|
|---|
| 107 | $xoopsTpl->assign('lang_ratethissite', _MD_RATETHISFILE);
|
|---|
| 108 | $xoopsTpl->assign('lang_reportbroken', _MD_REPORTBROKEN);
|
|---|
| 109 | $xoopsTpl->assign('lang_tellafriend', _MD_TELLAFRIEND);
|
|---|
| 110 | $xoopsTpl->assign('lang_modify', _MD_MODIFY);
|
|---|
| 111 | $xoopsTpl->assign('lang_version' , _MD_VERSION);
|
|---|
| 112 | $xoopsTpl->assign('lang_subdate' , _MD_SUBMITDATE);
|
|---|
| 113 | $xoopsTpl->assign('lang_dlnow' , _MD_DLNOW);
|
|---|
| 114 | $xoopsTpl->assign('lang_category' , _MD_CATEGORYC);
|
|---|
| 115 | $xoopsTpl->assign('lang_size' , _MD_FILESIZE);
|
|---|
| 116 | $xoopsTpl->assign('lang_platform' , _MD_SUPPORTEDPLAT);
|
|---|
| 117 | $xoopsTpl->assign('lang_homepage' , _MD_HOMEPAGE);
|
|---|
| 118 | $xoopsTpl->assign('lang_comments' , _COMMENTS);
|
|---|
| 119 | $xoopsTpl->assign('show_links', true);
|
|---|
| 120 | $q = "SELECT d.lid, d.title, d.url, d.homepage, d.version, d.size, d.platform, d.logourl, d.status, d.date, d.hits, d.rating, d.votes, d.comments, t.description FROM ".$xoopsDB->prefix("mydownloads_downloads")." d, ".$xoopsDB->prefix("mydownloads_text")." t WHERE cid=".$cid." AND d.status>0 AND d.lid=t.lid ORDER BY ".$orderby."";
|
|---|
| 121 | $result = $xoopsDB->query($q,$show,$min);
|
|---|
| 122 |
|
|---|
| 123 | //if 2 or more items in result, show the sort menu
|
|---|
| 124 | if($numrows>1){
|
|---|
| 125 | $xoopsTpl->assign('show_nav', true);
|
|---|
| 126 | $orderbyTrans = convertorderbytrans($orderby);
|
|---|
| 127 | $xoopsTpl->assign('lang_sortby', _MD_SORTBY);
|
|---|
| 128 | $xoopsTpl->assign('lang_title', _MD_TITLE);
|
|---|
| 129 | $xoopsTpl->assign('lang_date', _MD_DATE);
|
|---|
| 130 | $xoopsTpl->assign('lang_rating', _MD_RATING);
|
|---|
| 131 | $xoopsTpl->assign('lang_popularity', _MD_POPULARITY);
|
|---|
| 132 | $xoopsTpl->assign('lang_cursortedby', sprintf(_MD_CURSORTBY, convertorderbytrans($orderby)));
|
|---|
| 133 | }
|
|---|
| 134 | while(list($lid, $dtitle, $url, $homepage, $version, $size, $platform, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description)=$xoopsDB->fetchRow($result)) {
|
|---|
| 135 | $path = $mytree->getPathFromId($cid, "title");
|
|---|
| 136 | $path = substr($path, 1);
|
|---|
| 137 | $path = str_replace("/"," <img src='".XOOPS_URL."/modules/mydownloads/images/arrow.gif' board='0' alt=''> ",$path);
|
|---|
| 138 | $rating = number_format($rating, 2);
|
|---|
| 139 | $dtitle = $myts->makeTboxData4Show($dtitle);
|
|---|
| 140 | $url = $myts->makeTboxData4Show($url);
|
|---|
| 141 | $homepage = $myts->makeTboxData4Show($homepage);
|
|---|
| 142 | $version = $myts->makeTboxData4Show($version);
|
|---|
| 143 | $size = PrettySize($myts->makeTboxData4Show($size));
|
|---|
| 144 | $platform = $myts->makeTboxData4Show($platform);
|
|---|
| 145 | $logourl = $myts->makeTboxData4Show($logourl);
|
|---|
| 146 | $datetime = formatTimestamp($time,"s");
|
|---|
| 147 | $description = $myts->makeTareaData4Show($description,0); //no html
|
|---|
| 148 | $new = newdownloadgraphic($time, $status);
|
|---|
| 149 | $pop = popgraphic($hits);
|
|---|
| 150 | if ($isadmin) {
|
|---|
| 151 | $adminlink = '<a href="'.XOOPS_URL.'/modules/mydownloads/admin/index.php?lid='.$lid.'&fct=mydownloads&op=modDownload"><img src="'.XOOPS_URL.'/modules/mydownloads/images/editicon.gif" border="0" alt="'._MD_EDITTHISDL.'" /></a>';
|
|---|
| 152 | } else {
|
|---|
| 153 | $adminlink = '';
|
|---|
| 154 | }
|
|---|
| 155 | if ($votes == 1) {
|
|---|
| 156 | $votestring = _MD_ONEVOTE;
|
|---|
| 157 | } else {
|
|---|
| 158 | $votestring = sprintf(_MD_NUMVOTES,$votes);
|
|---|
| 159 | }
|
|---|
| 160 | $xoopsTpl->append('file', array('id' => $lid, 'cid' => $cid, 'rating' => $rating,'title' => $dtitle.$new.$pop,'logourl' => $logourl,'updated' => $datetime,'description' => $description,'adminlink' => $adminlink,'hits' => $hits,'votes' => $votestring, 'comments' => $comments, 'platform' => $platform,'size' => $size,'homepage' => $homepage,'version' => $version,'category' => $path,'lang_dltimes' => sprintf(_MD_DLTIMES,$hits),'mail_subject' => rawurlencode(sprintf(_MD_INTFILEFOUND,$xoopsConfig['sitename'])),'mail_body' => rawurlencode(sprintf(_MD_INTFILEFOUND,$xoopsConfig['sitename']).': '.XOOPS_URL.'/modules/mydownloads/singlefile.php?cid='.$cid.'&lid='.$lid)));
|
|---|
| 161 | }
|
|---|
| 162 | $orderby = convertorderbyout($orderby);
|
|---|
| 163 | //Calculates how many pages exist. Which page one should be on, etc...
|
|---|
| 164 | $downpages = ceil($numrows / $show);
|
|---|
| 165 | //Page Numbering
|
|---|
| 166 | if ($downpages!=1 && $downpages!=0) {
|
|---|
| 167 | $prev = $min - $show;
|
|---|
| 168 | if ($prev>=0) {
|
|---|
| 169 | $page_nav .= "<a href='viewcat.php?cid=$cid&min=$prev&orderby=$orderby&show=$show'><b><u>«</u></b></a> ";
|
|---|
| 170 | }
|
|---|
| 171 | $counter = 1;
|
|---|
| 172 | $currentpage = ($max / $show);
|
|---|
| 173 | while ( $counter<=$downpages ) {
|
|---|
| 174 | $mintemp = ($show * $counter) - $show;
|
|---|
| 175 | if ($counter == $currentpage) {
|
|---|
| 176 | $page_nav .= "<b>($counter)</b> ";
|
|---|
| 177 | } else {
|
|---|
| 178 | $page_nav .= "<a href='viewcat.php?cid=$cid&min=$mintemp&orderby=$orderby&show=$show'>$counter</a> ";
|
|---|
| 179 | }
|
|---|
| 180 | $counter++;
|
|---|
| 181 | }
|
|---|
| 182 | if ( $numrows>$max ) {
|
|---|
| 183 | $page_nav .= "<a href='viewcat.php?cid=$cid&min=$max&orderby=$orderby&show=$show'>";
|
|---|
| 184 | $page_nav .= "<b><u>»</u></b></a>";
|
|---|
| 185 | }
|
|---|
| 186 | }
|
|---|
| 187 | }
|
|---|
| 188 | $xoopsTpl->assign('page_nav', $page_nav);
|
|---|
| 189 | include XOOPS_ROOT_PATH."/modules/mydownloads/footer.php";
|
|---|
| 190 | ?>
|
|---|