| 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 | // ------------------------------------------------------------------------ // |
|---|
| 27 | include "header.php"; |
|---|
| 28 | $myts =& MyTextSanitizer::getInstance(); // MyTextSanitizer object |
|---|
| 29 | include_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'; |
|---|
| 34 | include XOOPS_ROOT_PATH."/header.php"; |
|---|
| 35 | |
|---|
| 36 | if (isset($_GET['show'])) { |
|---|
| 37 | $show = intval($_GET['show']); |
|---|
| 38 | } else { |
|---|
| 39 | $show = $xoopsModuleConfig['perpage']; |
|---|
| 40 | } |
|---|
| 41 | $min = isset($_GET['min']) ? intval($_GET['min']) : 0; |
|---|
| 42 | if (!isset($max)) { |
|---|
| 43 | $max = $min + $show; |
|---|
| 44 | } |
|---|
| 45 | if(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> : "; |
|---|
| 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"); |
|---|
| 58 | if ( 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 | |
|---|
| 84 | if ($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 | |
|---|
| 91 | if (!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"); |
|---|
| 97 | list($numrows) = $xoopsDB->fetchRow($fullcountresult); |
|---|
| 98 | $page_nav = ''; |
|---|
| 99 | if($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 | $xoopsTpl->assign('lang_siteurl', _MD_SITEURL); |
|---|
| 113 | $xoopsTpl->assign('lang_developer', _MD_DEVELOPER); |
|---|
| 114 | $xoopsTpl->assign('lang_release_date', _MD_RELEASE_DATE); |
|---|
| 115 | $xoopsTpl->assign('lang_development_time', _MD_DEVELOPMENT_TIME); |
|---|
| 116 | $xoopsTpl->assign('lang_site_status', _MD_SITE_STATUS); |
|---|
| 117 | $xoopsTpl->assign('lang_customize', _MD_CUSTOMIZE); |
|---|
| 118 | $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, l.developer, l.release_date, l.development_time, l.site_status, l.customize_flag 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"; |
|---|
| 119 | $result=$xoopsDB->query($sql,$show,$min); |
|---|
| 120 | |
|---|
| 121 | //if 2 or more items in result, show the sort menu |
|---|
| 122 | if($numrows>1){ |
|---|
| 123 | $xoopsTpl->assign('show_nav', true); |
|---|
| 124 | $orderbyTrans = convertorderbytrans($orderby); |
|---|
| 125 | $xoopsTpl->assign('lang_sortby', _MD_SORTBY); |
|---|
| 126 | $xoopsTpl->assign('lang_title', _MD_TITLE); |
|---|
| 127 | $xoopsTpl->assign('lang_date', _MD_DATE); |
|---|
| 128 | $xoopsTpl->assign('lang_rating', _MD_RATING); |
|---|
| 129 | $xoopsTpl->assign('lang_popularity', _MD_POPULARITY); |
|---|
| 130 | $xoopsTpl->assign('lang_cursortedby', sprintf(_MD_CURSORTEDBY, convertorderbytrans($orderby))); |
|---|
| 131 | } |
|---|
| 132 | while(list($lid, $cid,$ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description, $developer, $release_date, $development_time, $site_status, $customize_flag) = $xoopsDB->fetchRow($result)) { |
|---|
| 133 | if ($isadmin) { |
|---|
| 134 | $adminlink = '<a href="'.XOOPS_URL.'/modules/mylinks/admin/?op=modLink&lid='.$lid.'"><img src="'.XOOPS_URL.'/modules/mylinks/images/editicon.gif" border="0" alt="'._MD_EDITTHISLINK.'" /></a>'; |
|---|
| 135 | } else { |
|---|
| 136 | $adminlink = ''; |
|---|
| 137 | } |
|---|
| 138 | if ($votes == 1) { |
|---|
| 139 | $votestring = _MD_ONEVOTE; |
|---|
| 140 | } else { |
|---|
| 141 | $votestring = sprintf(_MD_NUMVOTES,$votes); |
|---|
| 142 | } |
|---|
| 143 | $path = $mytree->getPathFromId($cid, "title"); |
|---|
| 144 | $path = substr($path, 1); |
|---|
| 145 | $path = str_replace("/"," <img src='".XOOPS_URL."/modules/mylinks/images/arrow.gif' board='0' alt='' /> ",$path); |
|---|
| 146 | $new = newlinkgraphic($time, $status); |
|---|
| 147 | $pop = popgraphic($hits); |
|---|
| 148 | |
|---|
| 149 | switch($site_status) { |
|---|
| 150 | case 1: |
|---|
| 151 | $site_status = _MD_NEW_OPEN; |
|---|
| 152 | break; |
|---|
| 153 | case 2: |
|---|
| 154 | $site_status = _MD_RENEWAL; |
|---|
| 155 | break; |
|---|
| 156 | default: |
|---|
| 157 | $site_status = _MD_NEW_OPEN; |
|---|
| 158 | } |
|---|
| 159 | |
|---|
| 160 | switch($customize_flag) { |
|---|
| 161 | case 1: |
|---|
| 162 | $customize = _MD_ON; |
|---|
| 163 | break; |
|---|
| 164 | case 2: |
|---|
| 165 | $customize = _MD_OFF; |
|---|
| 166 | break; |
|---|
| 167 | default: |
|---|
| 168 | $customize = _MD_OFF; |
|---|
| 169 | } |
|---|
| 170 | |
|---|
| 171 | $xoopsTpl->append('links', array('id' => $lid, 'cid' => $cid, 'rating' => number_format($rating, 2), 'url' => $url, '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' => _SITE_NAME, 'mail_body' => _SITE_NAME.': '.XOOPS_URL.'/modules/mylinks/singlelink.php?cid='.$cid.'&lid='.$lid,'developer' => $developer, 'release_date' => $release_date, 'development_time' => $development_time, 'site_status' => $site_status, 'customize_flag' => $customize)); |
|---|
| 172 | } |
|---|
| 173 | $orderby = convertorderbyout($orderby); |
|---|
| 174 | //Calculates how many pages exist. Which page one should be on, etc... |
|---|
| 175 | $linkpages = ceil($numrows / $show); |
|---|
| 176 | //Page Numbering |
|---|
| 177 | if ($linkpages!=1 && $linkpages!=0) { |
|---|
| 178 | $cid = intval($_GET['cid']); |
|---|
| 179 | $prev = $min - $show; |
|---|
| 180 | if ($prev>=0) { |
|---|
| 181 | $page_nav .= "<a href='viewcat.php?cid=$cid&min=$prev&orderby=$orderby&show=$show'><b><u>«</u></b></a> "; |
|---|
| 182 | } |
|---|
| 183 | $counter = 1; |
|---|
| 184 | $currentpage = ($max / $show); |
|---|
| 185 | while ( $counter<=$linkpages ) { |
|---|
| 186 | $mintemp = ($show * $counter) - $show; |
|---|
| 187 | if ($counter == $currentpage) { |
|---|
| 188 | $page_nav .= "<b>($counter)</b> "; |
|---|
| 189 | } else { |
|---|
| 190 | $page_nav .= "<a href='viewcat.php?cid=$cid&min=$mintemp&orderby=$orderby&show=$show'>$counter</a> "; |
|---|
| 191 | } |
|---|
| 192 | $counter++; |
|---|
| 193 | } |
|---|
| 194 | if ( $numrows>$max ) { |
|---|
| 195 | $page_nav .= "<a href='viewcat.php?cid=$cid&min=$max&orderby=$orderby&show=$show'>"; |
|---|
| 196 | $page_nav .= "<b><u>»</u></b></a>"; |
|---|
| 197 | } |
|---|
| 198 | } |
|---|
| 199 | } |
|---|
| 200 | $xoopsTpl->assign('page_nav', $page_nav); |
|---|
| 201 | include XOOPS_ROOT_PATH.'/footer.php'; |
|---|
| 202 | ?> |
|---|