source: temp/test-xoops.ec-cube.net/html/modules/tinyd0/include/render_function.inc.php @ 405

Revision 405, 5.1 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2//  ------------------------------------------------------------------------ //
3//                XOOPS - PHP Content Management System                      //
4//                    Copyright (c) 2000 XOOPS.org                           //
5//                       <http://www.xoops.org/>                             //
6//  ------------------------------------------------------------------------ //
7//  This program is free software; you can redistribute it and/or modify     //
8//  it under the terms of the GNU General Public License as published by     //
9//  the Free Software Foundation; either version 2 of the License, or        //
10//  (at your option) any later version.                                      //
11//                                                                           //
12//  You may not change or alter any portion of this comment or credits       //
13//  of supporting developers from this source code or any supporting         //
14//  source code which is considered copyrighted (c) material of the          //
15//  original comment or credit authors.                                      //
16//                                                                           //
17//  This program is distributed in the hope that it will be useful,          //
18//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
19//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
20//  GNU General Public License for more details.                             //
21//                                                                           //
22//  You should have received a copy of the GNU General Public License        //
23//  along with this program; if not, write to the Free Software              //
24//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
25// ------------------------------------------------------------------------- //
26// Hacker: GIJ=CHECKMATE (AKA GIJOE)                                         //
27// Site: http://www.peak.ne.jp/xoops/                                        //
28// ------------------------------------------------------------------------- //
29
30if( ! defined( 'TC_RENDER_FUNCTIONS_INCLUDED' ) ) {
31
32define( 'TC_RENDER_FUNCTIONS_INCLUDED' , 1 ) ;
33
34function tc_content_render( $text , $nohtml , $nosmiley , $nobreaks , $nbsp = 0 )
35{
36    $myts =& TinyDTextSanitizer::getInstance();
37
38    if( $nohtml >= 16 ) {
39
40        // db content (PEAR wiki)
41        if( ! defined( 'PATH_SEPARATOR' ) ) define( 'PATH_SEPARATOR' , DIRECTORY_SEPARATOR == '/' ? ':' : ';' ) ;
42        ini_set( 'include_path' , ini_get('include_path') . PATH_SEPARATOR . XOOPS_ROOT_PATH . '/common/PEAR' ) ;
43        include_once "Text/Wiki.php";
44        // include_once "Text/sunday_Wiki.php";
45        $wiki = new Text_Wiki(); // create instance
46
47        // Configuration
48        $wiki->deleteRule( 'Wikilink' ); // remove a rule for auto-linking
49        $wiki->setFormatConf( 'Xhtml' , 'translate' , HTML_SPECIALCHARS ) ; // HTML_ENTITIES -> HTML_SPECIALCHARS
50
51        // $wiki = new sunday_Text_Wiki(); // create instance
52        //$text = str_replace ( "\r\n", "\n", $text );
53        //$text = str_replace ( "~\n", "[br]", $text );
54        //$text = $wiki->transform($text);
55        //$content = str_replace ( "[br]", "<br/>", $text );
56        // special thx to minahito! you are great!!
57        $content = $wiki->transform($text);
58
59        if( $nohtml & 2 ) {
60            $content = $myts->displayTarea( $content , 1 , ! $nosmiley , 1 , 1 , ! $nobreaks , $nbsp ) ;
61        }
62
63    } else if( $nohtml >= 8 ) {
64
65        // db content (PHP)
66        ob_start() ;
67        eval( $text ) ;
68        $content = ob_get_contents() ;
69        ob_end_clean() ;
70
71        if( $nohtml & 2 ) {
72            $content = $myts->displayTarea( $content , 1 , ! $nosmiley , 1 , 1 , ! $nobreaks , $nbsp ) ;
73        }
74
75    } else if( $nohtml < 4 ) {
76
77        switch( $nohtml ) {
78            case 0 : // HTML with BB
79                $content = $myts->displayTarea( $text , 1 , ! $nosmiley , 1 , 1 , ! $nobreaks , $nbsp ) ;
80                break ;
81            case 1 : // Text with BB
82                $content = $myts->displayTarea( $text , 0 , ! $nosmiley , 1 , 1 , ! $nobreaks , $nbsp ) ;
83                break ;
84            case 2 : // HTML without BB
85                $content = $text ;
86                break ;
87            case 3 : // Text without BB
88                $content = htmlspecialchars( $text , ENT_QUOTES ) ;
89                if( ! $nobreaks ) $content = nl2br( $content ) ;
90                break ;
91        }
92
93    } else {
94
95        $content = $text ;
96
97    }
98
99    return $content ;
100}
101
102
103function tc_change_srchref( $content , $wrap_base_url )
104{
105    $patterns = array( "/src\=\"(?!http:|https:)([^, \r\n\"\(\)'<>]+)/i" , "/src\=\'(?!http:|https:)([^, \r\n\"\(\)'<>]+)/i" , "/src\=(?!http:|https:)([^, \r\n\"\(\)'<>]+)/i" , "/href\=\"(?!http:|https:)([^, \r\n\"\(\)'<>]+)/i" , "/href\=\'(?!http:|https:)([^, \r\n\"\(\)'<>]+)/i" , "/href\=(?!http:|https:)([^, \r\n\"\(\)'<>]+)/i" ) ;
106    $replacements = array( "src=\"$wrap_base_url/\\1" , "src='$wrap_base_url/\\1" , "src=$wrap_base_url/\\1" , "href=\"$wrap_base_url/\\1" , "href='$wrap_base_url/\\1" , "href=$wrap_base_url/\\1" ) ;
107
108    return preg_replace($patterns, $replacements, $content);
109}
110
111
112
113if( ! function_exists( 'mb_convert_encoding' ) ) {
114    function mb_convert_encoding( $str ) { return $str ; }
115}
116
117if( ! function_exists( 'mb_internal_encoding' ) ) {
118    function mb_internal_encoding( $str ) { return "UTF-8" ; }
119}
120
121
122}
123
124?>
Note: See TracBrowser for help on using the repository browser.