HomeHelpTrac

source: tags/6.1/news.php @ 10242

Revision 10242, 4.1 KB checked in by Alexander Trofimov, 3 years ago (diff)

dolphin 6.1.5, initial commit

Line 
1<?
2
3/***************************************************************************
4*                            Dolphin Smart Community Builder
5*                              -----------------
6*     begin                : Mon Mar 23 2006
7*     copyright            : (C) 2006 BoonEx Group
8*     website              : http://www.boonex.com/
9* This file is part of Dolphin - Smart Community Builder
10*
11* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12* http://creativecommons.org/licenses/by/3.0/
13*
14* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16* See the Creative Commons Attribution 3.0 License for more details.
17* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18* see license.txt file; if not, write to marketing@boonex.com
19***************************************************************************/
20
21require_once( 'inc/header.inc.php' );
22require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
23require_once( BX_DIRECTORY_PATH_INC . 'news.inc.php' );
24require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
25require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
26
27// --------------- page variables / login
28
29$_page['name_index']    = 20;
30$_page['css_name']      = 'news.css';
31
32$logged['member'] = member_auth( 0, false );
33
34$_page['header'] = _t("_NEWS_H");
35$_page['header_text'] = _t("_NEWS_H");
36
37// --------------- page components
38
39$_ni = $_page['name_index'];
40$_page_cont[$_ni]['page_main_code'] = isset($_GET['ID']) || isset($_GET['newsUri']) ? getNews() : printNewsList();
41
42// --------------- [END] page components
43
44PageCode();
45
46// --------------- page components functions
47
48
49/**
50 * Print news
51 */
52function printNewsList()
53{
54    global $news_limit_chars;
55    global $short_date_format;
56    global $tmpl;
57
58    $bNewsFriendly = getParam('permalinks_news') == 'on' ? true : false;
59
60    $res = getNewsList();
61
62    ob_start();
63
64    if ( !mysql_num_rows($res) )
65    {
66        ?>
67            <div class="no_news">
68                <?=_t("_No news available")?>
69            </div>
70        <?
71    }
72    else
73    {
74        while ( $news_arr = mysql_fetch_array($res))
75        {
76            ?>
77            <div class="news_cont">
78                <div class="clear_both"></div>
79                <div class="news_header">
80                    <a href="<?=getNewsUrl($news_arr['newsID'], $news_arr['NewsUri'], $bNewsFriendly)?>">
81                        <?=process_line_output( $news_arr['Header'] )?>
82                    </a>
83                </div>
84                <div class="news_date"><?=date( str_replace('%','',$short_date_format), $news_arr['Date'] )?></div>
85                <div class="news_snippet">
86                    <?=process_html_output( $news_arr['Snippet'] )?>
87                </div>
88                <div class="clear_both"></div>
89            </div>
90            <?
91        }
92    }
93   
94    return ob_get_clean();
95}
96
97function getNewsByField($sField, $sVal)
98{
99    global $date_format;
100   
101    $sField = process_db_input($sField);
102    $sVal   = process_db_input($sVal);
103   
104    $sqlQuery = "
105    SELECT
106        `Header`,
107        `Snippet`,
108        `Text`,
109        DATE_FORMAT(`Date`, '$date_format' ) AS 'Date'
110    FROM `News`
111    WHERE `$sField`='$sVal'";
112
113    return db_arr( $sqlQuery );
114}
115   
116function printNews($news_arr)
117{
118    if ($news_arr)
119    {
120        $sCode  = '<div class="news_cont">';
121        $sCode .= '<div class="news_header">'.process_line_output( $news_arr['Header'] ).'</div>';
122        $sCode .= '<div class="news_date">'.$news_arr['Date'].'</div>';
123        //$sCode .= '<div class="news_snippet">'.process_text_output( $news_arr['Snippet'] ).'</div>';
124        $sCode .= '<div class="news_snippet">'.process_html_output( $news_arr['Snippet'] ).'</div>';
125        //$sCode .= '<div class="news_text">'.process_text_withlinks_output( $news_arr['Text'] ).'</div></div>';
126        $sCode .= '<div class="news_text">'.process_html_output( $news_arr['Text'] ).'</div></div>';
127    }
128    else
129    {
130        $sCode = MsgBox( _t( '_No news available' ) );
131    }
132
133    return $sCode;
134}
135
136function getNews()
137{
138    if (isset($_GET['newsUri']))
139    {
140        $sCode = printNews(getNewsByField('NewsUri', $_GET['newsUri']));
141    }
142    elseif (isset($_GET['ID']))
143    {
144        $sCode = printNews(getNewsByField('ID', $_GET['ID']));
145    }
146
147    return $sCode;
148}
149
150?>
Note: See TracBrowser for help on using the repository browser.