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

Revision 911, 7.4 KB checked in by uehara, 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$xoopsTpl->assign('lang_siteurl', _MD_SITEURL);
94$xoopsTpl->assign('lang_developer', _MD_DEVELOPER);
95$xoopsTpl->assign('lang_release_date', _MD_RELEASE_DATE);
96$xoopsTpl->assign('lang_development_time', _MD_DEVELOPMENT_TIME);
97$xoopsTpl->assign('lang_site_status', _MD_SITE_STATUS);
98$xoopsTpl->assign('lang_customize', _MD_CUSTOMIZE);
99$xoopsTpl->assign('lang_new_open', _MD_NEW_OPEN);
100$xoopsTpl->assign('lang_renewal', _MD_RENEWAL);
101   
102$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, 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 l.status>0 and l.lid=t.lid ORDER BY date DESC", $xoopsModuleConfig['newlinks'], 0);
103
104while(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)) {
105    if ($isadmin) {
106        $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>';
107    } else {
108        $adminlink = '';
109    }
110    if ($votes == 1) {
111        $votestring = _MD_ONEVOTE;
112    } else {
113        $votestring = sprintf(_MD_NUMVOTES,$votes);
114    }
115    $path = $mytree->getPathFromId($cid, "title");
116    $path = substr($path, 1);
117    $path = str_replace("/"," <img src='".XOOPS_URL."/modules/mylinks/images/arrow.gif' board='0' alt='' /> ",$path);
118    $new = newlinkgraphic($time, $status);
119    $pop = popgraphic($hits);
120
121    switch($site_status) {
122        case 1:
123        $site_status = _MD_NEW_OPEN;
124        break;
125        case 2:
126        $site_status = _MD_RENEWAL;
127        break;
128        default:
129        $site_status = _MD_NEW_OPEN;
130    }
131
132    switch($customize_flag) {
133        case 1:
134        $customize = _MD_ON;
135        break;
136        case 2:
137        $customize = _MD_OFF;
138        break;
139        default:
140        $customize = _MD_OFF;
141    }   
142    $xoopsTpl->append('links', array('id' => $lid, 'cid' => $cid, 'rating' => number_format($rating, 2), 'title' => $myts->makeTboxData4Show($ltitle).$new.$pop, 'url' => $url, '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' => _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));
143}
144include XOOPS_ROOT_PATH.'/footer.php';
145?>
Note: See TracBrowser for help on using the repository browser.