[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 <?php 2 /** 3 * This file implements the UI for file viewing. 4 * 5 * This file is part of the evoCore framework - {@link http://evocore.net/} 6 * See also {@link http://sourceforge.net/projects/evocms/}. 7 * 8 * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/} 9 * Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}. 10 * 11 * {@internal License choice 12 * - If you have received this file as part of a package, please find the license.txt file in 13 * the same folder or the closest folder above for complete license terms. 14 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) 15 * then you must choose one of the following licenses before using the file: 16 * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php 17 * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php 18 * }} 19 * 20 * {@internal Open Source relicensing agreement: 21 * Daniel HAHLER grants Francois PLANQUE the right to license 22 * Daniel HAHLER's contributions to this file and the b2evolution project 23 * under any OSI approved OSS license (http://www.opensource.org/licenses/). 24 * }} 25 * 26 * @package admin 27 * 28 * {@internal Below is a list of authors who have contributed to design/coding of this file: }} 29 * @author blueyed: Daniel HAHLER. 30 * @author fplanque: Francois PLANQUE. 31 * 32 * @todo skin compliant header! 33 * 34 * @version $Id: viewfile.php,v 1.16 2007/09/23 18:55:17 fplanque Exp $ 35 */ 36 37 /** 38 * Load config, init and get the {@link $mode mode param}. 39 */ 40 require_once dirname(__FILE__).'/../conf/_config.php'; 41 require_once $inc_path.'/_main.inc.php'; 42 43 44 // Check permission: 45 if( ! isset($current_User) ) 46 { 47 debug_die( 'No permissions to view file (not logged in)!' ); 48 } 49 $current_User->check_perm( 'files', 'view', true ); 50 51 // Load params 52 param( 'viewtype', 'string', true ); 53 param( 'root', 'string', true ); // the root directory from the dropdown box (user_X or blog_X; X is ID - 'user' for current user (default)) 54 param( 'path', 'string', true ); 55 56 // Load fileroot infos 57 $FileRootCache = & get_Cache( 'FileRootCache' ); 58 $FileRoot = & $FileRootCache->get_by_ID( $root ); 59 60 // Create file object 61 $selected_File = & new File( $FileRoot->type , $FileRoot->in_type_ID, $path ); 62 63 header( 'Content-type: text/html; charset='.$io_charset ); 64 ?> 65 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 66 <html xml:lang="<?php locale_lang() ?>" lang="<?php locale_lang() ?>"> 67 <head> 68 <title><?php echo $selected_File->dget('name').' ('.T_('Preview').')'; ?></title> 69 <link href="<?php echo $rsc_url ?>css/viewfile.css" rel="stylesheet" type="text/css" /> 70 </head> 71 72 <body> 73 <?php 74 75 switch( $viewtype ) 76 { 77 case 'image': 78 /* 79 * Image file view: 80 */ 81 echo '<div class="img_preview">'; 82 83 if( $imgSize = $selected_File->get_image_size( 'widthheight' ) ) 84 { 85 echo '<img '; 86 if( $alt = $selected_File->dget( 'alt', 'htmlattr' ) ) 87 { 88 echo 'alt="'.$alt.'" '; 89 } 90 if( $title = $selected_File->dget( 'title', 'htmlattr' ) ) 91 { 92 echo 'title="'.$title.'" '; 93 } 94 echo 'src="'.$selected_File->get_url().'"' 95 .' width="'.$imgSize[0].'" height="'.$imgSize[1].'" />'; 96 97 echo '<div class="subline">'; 98 echo '<p><strong>'.$selected_File->dget( 'title' ).'</strong></p>'; 99 echo '<p>'.$selected_File->dget( 'desc' ).'</p>'; 100 echo '<p>'.$selected_File->dget('name').' · '; 101 echo $selected_File->get_image_size().' · '; 102 echo $selected_File->get_size_formatted().'</p>'; 103 echo '</div>'; 104 105 } 106 else 107 { 108 echo 'error'; 109 } 110 echo ' </div>'; 111 break; 112 113 case 'text': 114 /* 115 * Text file view: 116 */ 117 if( ($buffer = @file( $selected_File->get_full_path() )) !== false ) 118 { // Display raw file 119 param( 'showlinenrs', 'integer', 0 ); 120 121 $buffer_lines = count( $buffer ); 122 123 echo '<div class="fileheader">'; 124 125 echo '<p>'; 126 echo T_('File').': <strong>'.$selected_File->dget('name').'</strong>'; 127 echo ' · '; 128 echo T_('Title').': <strong>'.$selected_File->dget( 'title' ).'</strong>'; 129 echo '</p>'; 130 131 echo '<p>'; 132 echo T_('Description').': '.$selected_File->dget( 'desc' ); 133 echo '</p>'; 134 135 136 if( !$buffer_lines ) 137 { 138 echo '<p>** '.T_('Empty file!').' ** </p></div>'; 139 } 140 else 141 { 142 echo '<p>'; 143 printf( T_('%d lines'), $buffer_lines ); 144 145 $linenr_width = strlen( $buffer_lines+1 ); 146 147 echo ' ['; 148 ?> 149 <noscript type="text/javascript"> 150 <a href="<?php echo $selected_File->get_url().'&showlinenrs='.(1-$showlinenrs); ?>"> 151 152 <?php echo $showlinenrs ? T_('Hide line numbers') : T_('Show line numbers'); 153 ?></a> 154 </noscript> 155 <script type="text/javascript"> 156 <!-- 157 document.write('<a id="togglelinenrs" href="javascript:toggle_linenrs()">toggle</a>'); 158 159 showlinenrs = <?php var_export( !$showlinenrs ); ?>; 160 161 toggle_linenrs(); 162 163 function toggle_linenrs() 164 { 165 if( showlinenrs ) 166 { 167 var replace = document.createTextNode('<?php echo TS_('Show line numbers') ?>'); 168 showlinenrs = false; 169 var text = document.createTextNode( '' ); 170 for( var i = 0; i<document.getElementsByTagName("span").length; i++ ) 171 { 172 if( document.getElementsByTagName("span")[i].hasChildNodes() ) 173 document.getElementsByTagName("span")[i].firstChild.data = ''; 174 else 175 { 176 document.getElementsByTagName("span")[i].appendChild( text ); 177 } 178 } 179 } 180 else 181 { 182 var replace = document.createTextNode('<?php echo TS_('Hide line numbers') ?>'); 183 showlinenrs = true; 184 for( var i = 0; i<document.getElementsByTagName("span").length; i++ ) 185 { 186 var text = String(i+1); 187 var upto = <?php echo $linenr_width ?>-text.length; 188 for( var j=0; j<upto; j++ ){ text = ' '+text; } 189 if( document.getElementsByTagName("span")[i].hasChildNodes() ) 190 document.getElementsByTagName("span")[i].firstChild.data = ' '+text+' '; 191 else 192 document.getElementsByTagName("span")[i].appendChild( document.createTextNode( ' '+text+' ' ) ); 193 } 194 } 195 196 document.getElementById('togglelinenrs').replaceChild(replace, document.getElementById( 'togglelinenrs' ).firstChild); 197 } 198 --> 199 </script> 200 <?php 201 202 echo ']</p>'; 203 echo '</div>'; 204 205 echo '<pre class="rawcontent">'; 206 207 for( $i = 0; $i < $buffer_lines; $i++ ) 208 { 209 echo '<span name="linenr" class="linenr">'; 210 if( $showlinenrs ) 211 { 212 echo ' '.str_pad($i+1, $linenr_width, ' ', STR_PAD_LEFT).' '; 213 } 214 echo '</span>'.htmlspecialchars( str_replace( "\t", ' ', $buffer[$i] ) ); // TODO: customize tab-width 215 } 216 217 echo '</pre>'; 218 219 echo '<div class="eof">** '.T_('End Of File').' **</div>'; 220 } 221 } 222 else 223 { 224 echo '<p class="error">'.sprintf( T_('The file «%s» could not be accessed!'), $selected_File->get_rdfs_rel_path( $selected_File ) ).'</p>'; 225 } 226 break; 227 228 default: 229 echo '<p class="error">'.sprintf( T_('The file «%s» could not be accessed!'), $selected_File->dget('name') ).'</p>'; 230 break; 231 } 232 233 debug_info(); 234 ?> 235 236 </body> 237 </html> 238 239 <?php 240 /* 241 * $Log: viewfile.php,v $ 242 * Revision 1.16 2007/09/23 18:55:17 fplanque 243 * attempting to debloat. The Log class is insane. 244 * 245 * Revision 1.15 2007/04/26 00:11:14 fplanque 246 * (c) 2007 247 * 248 * Revision 1.14 2006/12/23 22:53:11 fplanque 249 * extra security 250 * 251 * Revision 1.13 2006/12/07 15:23:42 fplanque 252 * filemanager enhanced, refactored, extended to skins directory 253 * 254 * Revision 1.12 2006/11/24 18:27:22 blueyed 255 * Fixed link to b2evo CVS browsing interface in file docblocks 256 * 257 * Revision 1.11 2006/10/18 00:15:32 blueyed 258 * Major rewrite of styleswitcher.js, started out with a single fix and fixed some more. 259 * 260 * Revision 1.10 2006/08/19 07:56:29 fplanque 261 * Moved a lot of stuff out of the automatic instanciation in _main.inc 262 * 263 * Revision 1.9 2006/05/19 18:15:04 blueyed 264 * Merged from v-1-8 branch 265 * 266 * Revision 1.8.2.1 2006/05/19 15:06:23 fplanque 267 * dirty sync 268 * 269 * Revision 1.8 2006/04/29 01:24:04 blueyed 270 * More decent charset support; 271 * unresolved issues include: 272 * - front office still forces the blog's locale/charset! 273 * - if there's content in utf8, it cannot get displayed with an I/O charset of latin1 274 * 275 * Revision 1.7 2006/04/19 20:13:48 fplanque 276 * do not restrict to :// (does not catch subdomains, not even www.) 277 * 278 * Revision 1.6 2006/04/04 22:20:29 blueyed 279 * "Gracefully" die, if no $current_User set 280 * 281 * Revision 1.5 2006/03/12 23:08:53 fplanque 282 * doc cleanup 283 * 284 * Revision 1.4 2006/03/12 03:03:32 blueyed 285 * Fixed and cleaned up "filemanager". 286 * 287 * Revision 1.3 2006/02/23 21:11:47 fplanque 288 * File reorganization to MVC (Model View Controller) architecture. 289 * See index.hml files in folders. 290 * (Sorry for all the remaining bugs induced by the reorg... :/) 291 * 292 * Revision 1.2 2005/12/16 13:50:49 blueyed 293 * FileRoot::get_by_ID() from post-phoenix 294 * 295 * Revision 1.1 2005/12/14 19:36:16 fplanque 296 * Enhanced file management 297 * 298 * Revision 1.17 2005/11/21 18:33:19 fplanque 299 * Too many undiscussed changes all around: Massive rollback! :(( 300 * As said before, I am only taking CLEARLY labelled bugfixes. 301 * 302 */ 303 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |