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

Revision 405, 6.4 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: index.php,v 1.5 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$xoopsOption['template_main'] = 'mylinks_index.html';
32include XOOPS_ROOT_PATH."/header.php";
33$result=$xoopsDB->query("SELECT cid, title, imgurl FROM ".$xoopsDB->prefix("mylinks_cat")." WHERE pid = 0 ORDER BY title") or exit("Error");
34
35$count = 1;
36while($myrow = $xoopsDB->fetchArray($result)) {
37    $imgurl = '';
38    if ($myrow['imgurl'] && $myrow['imgurl'] != "http://"){
39        $imgurl = $myts->makeTboxData4Edit($myrow['imgurl']);
40    }
41    $totallink = getTotalItems($myrow['cid'], 1);
42    // get child category objects
43    $arr = array();
44    $arr = $mytree->getFirstChild($myrow['cid'], "title");
45    $space = 0;
46    $chcount = 0;
47    $subcategories = '';
48    foreach($arr as $ele){
49        $chtitle = $myts->makeTboxData4Show($ele['title']);
50        if ($chcount > 5) {
51            $subcategories .= "...";
52            break;
53        }
54        if ($space>0) {
55            $subcategories .= ", ";
56        }
57        $subcategories .= "<a href=\"".XOOPS_URL."/modules/mylinks/viewcat.php?cid=".$ele['cid']."\">".$chtitle."</a>";
58        $space++;
59        $chcount++;
60    }
61    $xoopsTpl->append('categories', array('image' => $imgurl, 'id' => $myrow['cid'], 'title' => $myts->makeTboxData4Show($myrow['title']), 'subcategories' => $subcategories, 'totallink' => $totallink, 'count' => $count));
62    $count++;
63}
64list($numrows) = $xoopsDB->fetchRow($xoopsDB->query("select count(*) from ".$xoopsDB->prefix("mylinks_links")." where status>0"));
65$xoopsTpl->assign('lang_thereare', sprintf(_MD_THEREARE,$numrows));
66
67if ($xoopsModuleConfig['useshots'] == 1) {
68    $xoopsTpl->assign('shotwidth', $xoopsModuleConfig['shotwidth']);
69    $xoopsTpl->assign('tablewidth', $xoopsModuleConfig['shotwidth'] + 10);
70    $xoopsTpl->assign('show_screenshot', true);
71    $xoopsTpl->assign('lang_noscreenshot', _MD_NOSHOTS);
72}
73
74if ($xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid())) {
75    $isadmin = true;
76} else {
77    $isadmin = false;
78}
79
80$xoopsTpl->assign('lang_description', _MD_DESCRIPTIONC);
81$xoopsTpl->assign('lang_lastupdate', _MD_LASTUPDATEC);
82$xoopsTpl->assign('lang_hits', _MD_HITSC);
83$xoopsTpl->assign('lang_rating', _MD_RATINGC);
84$xoopsTpl->assign('lang_ratethissite', _MD_RATETHISSITE);
85$xoopsTpl->assign('lang_reportbroken', _MD_REPORTBROKEN);
86$xoopsTpl->assign('lang_tellafriend', _MD_TELLAFRIEND);
87$xoopsTpl->assign('lang_modify', _MD_MODIFY);
88$xoopsTpl->assign('lang_latestlistings' , _MD_LATESTLIST);
89$xoopsTpl->assign('lang_category' , _MD_CATEGORYC);
90$xoopsTpl->assign('lang_visit' , _MD_VISIT);
91$xoopsTpl->assign('lang_comments' , _COMMENTS);
92
93$result = $xoopsDB->query("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 l.status>0 and l.lid=t.lid ORDER BY date DESC", $xoopsModuleConfig['newlinks'], 0);
94while(list($lid, $cid, $ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result)) {
95    if ($isadmin) {
96        $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>';
97    } else {
98        $adminlink = '';
99    }
100    if ($votes == 1) {
101        $votestring = _MD_ONEVOTE;
102    } else {
103        $votestring = sprintf(_MD_NUMVOTES,$votes);
104    }
105    $path = $mytree->getPathFromId($cid, "title");
106    $path = substr($path, 1);
107    $path = str_replace("/"," <img src='".XOOPS_URL."/modules/mylinks/images/arrow.gif' board='0' alt='' /> ",$path);
108    $new = newlinkgraphic($time, $status);
109    $pop = popgraphic($hits);
110    $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, 'votes' => $votestring, 'comments' => $comments, '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)));
111}
112include XOOPS_ROOT_PATH.'/footer.php';
113?>
Note: See TracBrowser for help on using the repository browser.