| 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 | // Project: The XOOPS Project // |
|---|
| 27 | // ------------------------------------------------------------------------- // |
|---|
| 28 | |
|---|
| 29 | if( ! defined( 'TC_BLOCK_CONTENT_INCLUDED' ) ) { |
|---|
| 30 | |
|---|
| 31 | define( 'TC_BLOCK_CONTENT_INCLUDED' , 1 ) ; |
|---|
| 32 | |
|---|
| 33 | function b_tinycontent_content_show( $options ) |
|---|
| 34 | { |
|---|
| 35 | global $xoopsDB , $xoopsConfig ; |
|---|
| 36 | |
|---|
| 37 | $mydirname = $options[0] ; |
|---|
| 38 | if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ; |
|---|
| 39 | $mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ; |
|---|
| 40 | |
|---|
| 41 | $mytablename = $xoopsDB->prefix( "tinycontent{$mydirnumber}" ) ; |
|---|
| 42 | $mymodpath = XOOPS_ROOT_PATH . "/modules/$mydirname" ; |
|---|
| 43 | $mymoddir = XOOPS_URL . "/modules/$mydirname" ; |
|---|
| 44 | |
|---|
| 45 | if( ! class_exists( 'TinyDTextSanitizer' ) ) { |
|---|
| 46 | include_once( "$mymodpath/class/tinyd.textsanitizer.php" ) ; |
|---|
| 47 | } |
|---|
| 48 | if( ! defined( 'TC_RENDER_FUNCTIONS_INCLUDED' ) ) { |
|---|
| 49 | include_once( "$mymodpath/include/render_function.inc.php" ) ; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | if( ! defined( 'TINYCONTENT_MB_LOADED' ) ) { |
|---|
| 53 | if ( file_exists( "$mymodpath/language/{$xoopsConfig['language']}/main.php" ) ) { |
|---|
| 54 | include_once( "$mymodpath/language/{$xoopsConfig['language']}/main.php" ) ; |
|---|
| 55 | } else { |
|---|
| 56 | include_once( "$mymodpath/language/english/main.php" ) ; |
|---|
| 57 | } |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | // get my config |
|---|
| 61 | $module_handler =& xoops_gethandler('module'); |
|---|
| 62 | $config_handler =& xoops_gethandler('config'); |
|---|
| 63 | $module =& $module_handler->getByDirname($mydirname); |
|---|
| 64 | $config =& $config_handler->getConfigsByCat(0, $module->getVar('mid')); |
|---|
| 65 | $space2nbsp = empty( $config['tc_space2nbsp'] ) ? 0 : 1 ; |
|---|
| 66 | |
|---|
| 67 | $result = $xoopsDB->query( "SELECT text,title,link,nohtml,nosmiley,nobreaks,address FROM $mytablename WHERE storyid='{$options[1]}'" ) ; |
|---|
| 68 | list( $text,$title,$link,$nohtml,$nosmiley,$nobreaks,$address ) = $xoopsDB->fetchRow( $result ) ; |
|---|
| 69 | |
|---|
| 70 | // getting "content" |
|---|
| 71 | if( $link > 0 ) { |
|---|
| 72 | |
|---|
| 73 | // external (=wrapped) content |
|---|
| 74 | $wrap_file = "$mymodpath/content/$address" ; |
|---|
| 75 | if( ! file_exists( $wrap_file ) ) { |
|---|
| 76 | redirect_header( XOOPS_URL , 2 , _TC_FILENOTFOUND ) ; |
|---|
| 77 | exit ; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | ob_start() ; |
|---|
| 81 | include( $wrap_file ) ; |
|---|
| 82 | $content = tc_convert_wrap_to_ie( ob_get_contents() ) ; |
|---|
| 83 | /* if( $link == TC_WRAPTYPE_CHANGESRCHREF ) */ $content = tc_change_srchref( $content , "$mymoddir/content" ) ; |
|---|
| 84 | ob_end_clean() ; |
|---|
| 85 | |
|---|
| 86 | } else { |
|---|
| 87 | |
|---|
| 88 | $myts =& TinyDTextSanitizer::getInstance(); |
|---|
| 89 | $shorten_text = $myts->tinyExtractSummary( $text ) ; |
|---|
| 90 | $is_summary = ( $shorten_text != $text ) ; |
|---|
| 91 | $content = tc_content_render( $shorten_text , $nohtml , $nosmiley , $nobreaks , $space2nbsp ) ; |
|---|
| 92 | |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | // if template file exists, parse it. |
|---|
| 96 | if( file_exists( "$mymodpath/templates/blocks/tinycontent_content_block.html" ) ) { |
|---|
| 97 | $myts =& TinyDTextSanitizer::getInstance() ; |
|---|
| 98 | $tpl = new XoopsTpl(); |
|---|
| 99 | $tpl->assign( array( |
|---|
| 100 | 'storyid' => $options[1] , |
|---|
| 101 | 'mymoddir' => $mymoddir , |
|---|
| 102 | 'is_summary' => $is_summary , |
|---|
| 103 | 'lang_more' => _MORE , |
|---|
| 104 | 'title' => $myts->makeTboxData4Show( $title ) , |
|---|
| 105 | 'content' => $content |
|---|
| 106 | ) ) ; |
|---|
| 107 | $block['content'] = $tpl->fetch( "file:$mymodpath/templates/blocks/tinycontent_content_block.html" ) ; |
|---|
| 108 | |
|---|
| 109 | } else { |
|---|
| 110 | |
|---|
| 111 | $block['content'] = $content ; |
|---|
| 112 | |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | return $block ; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | function b_tinycontent_content_edit( $options ) |
|---|
| 121 | { |
|---|
| 122 | global $xoopsDB , $xoopsConfig ; |
|---|
| 123 | |
|---|
| 124 | $mydirname = $options[0] ; |
|---|
| 125 | if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ; |
|---|
| 126 | $mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ; |
|---|
| 127 | |
|---|
| 128 | $mytablename = $xoopsDB->prefix( "tinycontent{$mydirnumber}" ) ; |
|---|
| 129 | $mymoddir = XOOPS_URL . "/modules/$mydirname" ; |
|---|
| 130 | $mydirname4edit = htmlspecialchars( $mydirname , ENT_QUOTES ) ; |
|---|
| 131 | $old_storyid = empty( $options[1] ) ? 0 : intval( $options[1] ) ; |
|---|
| 132 | |
|---|
| 133 | $storyid_options = "<option value='0'>----</option>\n" ; |
|---|
| 134 | $result = $xoopsDB->query( "SELECT storyid,title FROM $mytablename" ) ; |
|---|
| 135 | while( list( $storyid , $title ) = $xoopsDB->fetchRow( $result ) ) { |
|---|
| 136 | $selected = $storyid == $old_storyid ? "selected='selected'" : "" ; |
|---|
| 137 | $storyid_options .= "<option value='$storyid' $selected>".htmlspecialchars(xoops_substr($title,0,50),ENT_QUOTES)."</option>\n" ; |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | $ret = " |
|---|
| 141 | <input type='hidden' name='options[0]' value='$mydirname4edit' /> |
|---|
| 142 | <input type='hidden' name='id4js' value='$old_storyid' /> |
|---|
| 143 | <input type='hidden' name='title4js' value='----' /> |
|---|
| 144 | <select name='options[1]' onchange='document.blockform.id4js.value=this.value;document.blockform.title4js.value=this.options[this.selectedIndex].text;'>$storyid_options</select> |
|---|
| 145 | <img src='$mymoddir/images/reflect.gif' onClick=\"document.blockform.btitle.value=document.blockform.title4js.value\" alt='reflect' /> |
|---|
| 146 | <img src='$mymoddir/images/editicon.gif' onClick=\"window.open('{$mymoddir}/admin/index.php?op=edit&id='+document.blockform.id4js.value,'','');return(false);\" alt='"._EDIT."' /> |
|---|
| 147 | \n" ; |
|---|
| 148 | |
|---|
| 149 | return $ret ; |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | } |
|---|
| 155 | |
|---|
| 156 | |
|---|
| 157 | ?> |
|---|