source: temp/test-xoops.ec-cube.net/html/modules/rssj/include/functions.php @ 405

Revision 405, 4.4 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2###############################################################################
3##                RSSFit - Extendable XML news feed generator                ##
4##                   Copyright (c) 2004 NS Tai (aka tuff)                    ##
5##                       <http://www.brandycoke.com/>                        ##
6##                      Modified By 2005 CACHE RSSfitJ                       ##
7##                       <http://gyakubiki.kir.jp/>                          ##
8###############################################################################
9##                    XOOPS - PHP Content Management System                  ##
10##                       Copyright (c) 2000 XOOPS.org                        ##
11##                          <http://www.xoops.org/>                          ##
12###############################################################################
13##  This program is free software; you can redistribute it and/or modify     ##
14##  it under the terms of the GNU General Public License as published by     ##
15##  the Free Software Foundation; either version 2 of the License, or        ##
16##  (at your option) any later version.                                      ##
17##                                                                           ##
18##  You may not change or alter any portion of this comment or credits       ##
19##  of supporting developers from this source code or any supporting         ##
20##  source code which is considered copyrighted (c) material of the          ##
21##  original comment or credit authors.                                      ##
22##                                                                           ##
23##  This program is distributed in the hope that it will be useful,          ##
24##  but WITHOUT ANY WARRANTY; without even the implied warranty of           ##
25##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            ##
26##  GNU General Public License for more details.                             ##
27##                                                                           ##
28##  You should have received a copy of the GNU General Public License        ##
29##  along with this program; if not, write to the Free Software              ##
30##  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA ##
31###############################################################################
32##  Author of this file: CACHE                                               ##
33##  URL: http://gyakubiki.kir.jp/                                            ##
34##  Project: RSSFitJ                                                         ##
35###############################################################################
36function sortTimestamp($a, $b){
37    if( $a['timestamp'] == $b['timestamp'] ){
38        return 0;
39    }
40    return ($a['timestamp'] > $b['timestamp']) ? -1 : 1;
41}
42
43function doSubstr($text, $endwith='...', $charset=_CHARSET){
44    global $xoopsModuleConfig;
45    $ret = $text;
46    $add = array('.', '!', '?', ']', ')', '%');
47    $remove = array(',', '/', ';', ':', ' ');
48    if( strlen($ret) > $xoopsModuleConfig['max_char'] && $xoopsModuleConfig['max_char'] > 0 ){
49        $ret = substrDetect($ret, 0, $xoopsModuleConfig['max_char']);
50        if( false === strrpos($ret, ' ') ){
51            if( false !== strpos($text, ' ',strlen($ret)) ){
52                $ret = substrDetect($text, 0, strpos($text, ' ',strlen($ret)));
53            }
54        }
55        if( in_array(substrDetect($text, strlen($ret), 1), $add) ){
56            $ret .= substrDetect($text, strlen($ret), 1);
57        }else{
58            if( in_array(substrDetect($ret, -1, 1), $remove) ){
59                $ret = substrDetect($ret, 0, -1);
60            }
61        }
62        $ret .= $endwith;
63    }
64    return $ret;
65}
66
67function substrDetect($text, $start, $len){
68    if( function_exists('mb_substr') ){
69        return mb_substr($text, $start, $len, _CHARSET);
70    }
71    return substr($text, $start, $len);
72}
73
74function utf8Encode(&$text){
75    global $xoopsModuleConfig;
76    if( !$xoopsModuleConfig['utf8'] ){
77        return $text;
78    }
79    return xoops_utf8_encode($text);
80}
81
82function adminHtmlHeader(){
83    global $xoopsModule, $xoopsConfig;
84
85    xoops_cp_header();
86    include('./mymenu.php');
87}
88
89// grab intro; temp solution
90function grabIntro(){
91    global $xoopsDB;
92    $sql = 'SELECT misc_title, misc_content FROM '.$xoopsDB->prefix('rssfitJ_misc')." WHERE misc_category = 'intro'";
93    list($t, $c) = $xoopsDB->fetchRow($xoopsDB->query($sql));
94    return array('title' => $t, 'content' => $c);
95}
96
97// generate timestamp in valid RFC-822 date format; temp solution
98function rssTimeStamp($time){
99    return date("D, j M Y H:i:s O", $time);
100}
101?>
Note: See TracBrowser for help on using the repository browser.