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

Revision 405, 6.9 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2// $Id: index.php,v 1.3 2005/09/04 20:46:11 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 '../../mainfile.php';
28$xoopsOption['template_main'] = 'news_index.html';
29include XOOPS_ROOT_PATH.'/header.php';
30include_once XOOPS_ROOT_PATH.'/modules/news/class/class.newsstory.php';
31
32if (isset($_GET['storytopic'])) {
33    $xoopsOption['storytopic'] = intval($_GET['storytopic']);
34} else {
35    $xoopsOption['storytopic'] = 0;
36}
37if ( isset($_GET['storynum']) ) {
38    $xoopsOption['storynum'] = intval($_GET['storynum']);
39    if ($xoopsOption['storynum'] > 30) {
40        $xoopsOption['storynum'] = $xoopsModuleConfig['storyhome'];
41    }
42} else {
43    $xoopsOption['storynum'] = $xoopsModuleConfig['storyhome'];
44}
45
46if ( isset($_GET['start']) ) {
47    $start = intval($_GET['start']);
48} else {
49    $start = 0;
50}
51if ( $xoopsModuleConfig['displaynav'] == 1 ) {
52    $xoopsTpl->assign('displaynav', true);
53    $xt = new XoopsTopic($xoopsDB->prefix('topics'));
54    ob_start();
55    $xt->makeTopicSelBox(1, $xoopsOption['storytopic'], 'storytopic');
56    $topic_select = ob_get_contents();
57    ob_end_clean();
58    $xoopsTpl->assign('topic_select', $topic_select);
59    $storynum_options = '';
60    for ( $i = 5; $i <= 30; $i = $i + 5 ) {
61        $sel = '';
62        if ($i == $xoopsOption['storynum']) {
63            $sel = ' selected="selected"';
64        }
65        $storynum_options .= '<option value="'.$i.'"'.$sel.'>'.$i.'</option>';
66    }
67    $xoopsTpl->assign('storynum_options', $storynum_options);
68} else {
69    $xoopsTpl->assign('displaynav', false);
70}
71
72$sarray = NewsStory::getAllPublished($xoopsOption['storynum'], $start, $xoopsOption['storytopic']);
73
74$scount = count($sarray);
75for ( $i = 0; $i < $scount; $i++ ) {
76    $story = array();
77    $story['id'] = $sarray[$i]->storyid();
78    $story['poster'] = $sarray[$i]->uname();
79    if ( $story['poster'] != false ) {
80        $story['poster'] = "<a href='".XOOPS_URL."/userinfo.php?uid=".$sarray[$i]->uid()."'>".$story['poster']."</a>";
81    } else {
82        $story['poster'] = $xoopsConfig['anonymous'];
83    }
84    $story['posttime'] = formatTimestamp($sarray[$i]->published());
85    $story['text'] = $sarray[$i]->hometext();
86    $introcount = strlen($story['text']);
87    $fullcount = strlen($sarray[$i]->bodytext());
88    $totalcount = $introcount + $fullcount;
89    $morelink = '';
90    if ( $fullcount > 1 ) {
91        $morelink .= '<a href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$sarray[$i]->storyid().'';
92        $morelink .= '">'._NW_READMORE.'</a> | ';
93        $morelink .= sprintf(_NW_BYTESMORE,$totalcount);
94        $morelink .= ' | ';
95    }
96    $ccount = $sarray[$i]->comments();
97    $morelink .= '<a href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$sarray[$i]->storyid().'';
98    $morelink2 = '<a href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$sarray[$i]->storyid().'';
99    if ( $ccount == 0 ) {
100        $morelink .= '">'._NW_COMMENTS.'</a>';
101    } else {
102        if ( $fullcount < 1 ) {
103            if ( $ccount == 1 ) {
104                $morelink .= '">'._NW_READMORE.'</a> | '.$morelink2.'">'._NW_ONECOMMENT.'</a>';
105            } else {
106                $morelink .= '">'._NW_READMORE.'</a> | '.$morelink2.'">';
107                $morelink .= sprintf(_NW_NUMCOMMENTS, $ccount);
108                $morelink .= '</a>';
109            }
110        } else {
111            if ( $ccount == 1 ) {
112                $morelink .= '">'._NW_ONECOMMENT.'</a>';
113            } else {
114                $morelink .= '">';
115                $morelink .= sprintf(_NW_NUMCOMMENTS, $ccount);
116                $morelink .= '</a>';
117            }
118        }
119    }
120    $story['morelink'] = $morelink;
121    $story['adminlink'] = '';
122    if ( $xoopsUser && $xoopsUser->isAdmin($xoopsModule->mid()) ) {
123        $story['adminlink'] = $sarray[$i]->adminlink();
124    }
125    $story['mail_link'] = 'mailto:?subject='.sprintf(_NW_INTARTICLE,$xoopsConfig['sitename']).'&amp;body='.sprintf(_NW_INTARTFOUND, $xoopsConfig['sitename']).':  '.XOOPS_URL.'/modules/news/article.php?storyid='.$sarray[$i]->storyid();
126    $story['imglink'] = '';
127    $story['align'] = '';
128    if ( $sarray[$i]->topicdisplay() ) {
129        $story['imglink'] = $sarray[$i]->imglink();
130        $story['align'] = $sarray[$i]->topicalign();
131    }
132    $story['title'] = $sarray[$i]->textlink().'&nbsp;:&nbsp;'."<a href='".XOOPS_URL."/modules/news/article.php?storyid=".$sarray[$i]->storyid()."'>".$sarray[$i]->title()."</a>";
133    $story['hits'] = $sarray[$i]->counter();
134    // The line below can be used to display a Permanent Link image
135    // $story['title'] .= "&nbsp;&nbsp;<a href='".XOOPS_URL."/modules/news/article.php?storyid=".$sarray[$i]->storyid()."'><img src='".XOOPS_URL."/modules/news/images/x.gif' alt='Permanent Link' /></a>";
136
137    $xoopsTpl->append('stories', $story);
138    unset($story);
139}
140$totalcount = NewsStory::countPublishedByTopic($xoopsOption['storytopic']);
141if ( $totalcount > $scount ) {
142    include_once XOOPS_ROOT_PATH.'/class/pagenav.php';
143    $pagenav = new XoopsPageNav($totalcount, $xoopsOption['storynum'], $start, 'start', 'storytopic='.$xoopsOption['storytopic']);
144    $xoopsTpl->assign('pagenav', $pagenav->renderNav());
145    //$xoopsTpl->assign('pagenav', $pagenav->renderImageNav());
146
147} else {
148    $xoopsTpl->assign('pagenav', '');
149}
150$xoopsTpl->assign('lang_go', _GO);
151$xoopsTpl->assign('lang_on', _ON);
152$xoopsTpl->assign('lang_printerpage', _NW_PRINTERFRIENDLY);
153$xoopsTpl->assign('lang_sendstory', _NW_SENDSTORY);
154$xoopsTpl->assign('lang_postedby', _POSTEDBY);
155$xoopsTpl->assign('lang_reads', _READS);
156include_once XOOPS_ROOT_PATH.'/footer.php';
157?>
Note: See TracBrowser for help on using the repository browser.