| [ Index ] |
|
Code source de CMS made simple 1.0.5 |
1 <?php 2 /** 3 * Show a list of images in a long horizontal table. 4 * @author $Author: Wei Zhuo $ 5 * @version $Id: images.php 2755 2006-05-10 00:51:46Z wishy $ 6 * @package ImageManager 7 */ 8 9 require_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/include.php'); 10 check_login(); 11 $userid = get_userid(); 12 if (!check_permission($userid, 'Modify Files')) die(); 13 14 require_once ('config.inc.php'); 15 require_once ('Classes/ImageManager.php'); 16 17 //default path is / 18 $relative = '/'; 19 $manager = new ImageManager($IMConfig); 20 21 //process any file uploads 22 $manager->processUploads(); 23 24 $manager->deleteFiles(); 25 26 $refreshDir = false; 27 //process any directory functions 28 if($manager->deleteDirs() || $manager->processNewDir()) 29 $refreshDir = true; 30 31 //check for any sub-directory request 32 //check that the requested sub-directory exists 33 //and valid 34 35 if(isset($_REQUEST['dir'])) 36 { 37 $path = rawurldecode($_REQUEST['dir']); 38 if($manager->validRelativePath($path)) 39 $relative = $path; 40 } 41 42 43 $manager = new ImageManager($IMConfig); 44 45 46 //get the list of files and directories 47 $list = $manager->getFiles($relative); 48 49 50 /* ================= OUTPUT/DRAW FUNCTIONS ======================= */ 51 52 /** 53 * Draw the files in an table. 54 */ 55 function drawFiles($list, &$manager, $i) 56 { 57 global $relative; 58 $image_per_line = 5; 59 60 foreach($list as $entry => $file) 61 { 62 $i++; 63 if ($i==1) { echo "<tr>";} 64 ?> 65 <td><table width="100" cellpadding="0" cellspacing="0"><tr><td class="block"> 66 <a href="<?php echo "{$manager->config['base_url']}{$file['relative']}";?>" TARGET="_blank" title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"><img src="<?php 67 68 if (function_exists('imagecreate')) 69 { 70 echo $manager->getThumbnail($file['relative']); 71 } else { 72 if ($file['image']) { 73 $size_x = $file['image'][0]; 74 $size_y = $file['image'][1]; 75 } 76 if (($size_x < 96) && ($size_y < 96)) 77 { 78 } 79 elseif ($size_x > $size_y) 80 { 81 $size_y = round($size_y / ($size_x / 96)); 82 $size_x = 96; 83 } 84 else 85 { 86 $size_x = round($size_x / ($size_y / 96)); 87 $size_y = 96; 88 } 89 echo "{$manager->config['base_url']}{$file['relative']}"; 90 echo "\" width=\"$size_x\" height=\"$size_y"; 91 } 92 93 ?>" alt="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"/></a> 94 </td></tr><tr><td class="edit"> 95 <a href="images.php?dir=<?php echo $relative; ?>&delf=<?php echo rawurlencode($file['relative']);?>" title="Trash" onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="img/edit_trash.gif" height="15" width="15" alt="Trash"/></a><a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']);?>');"><img src="img/edit_pencil.gif" height="15" width="15" alt="Edit"/></a> 96 <?php if($file['image']){ echo $file['image'][0].'x'.$file['image'][1]; } else echo $entry;?> 97 </td></tr></table></td> 98 <?php 99 if ($i==$image_per_line) { 100 echo "</tr>"; 101 $i=0; 102 } 103 }//foreach 104 105 return ($i); 106 107 }//function drawFiles 108 109 110 /** 111 * Draw the directory. 112 */ 113 function drawDirs($list, &$manager, $i) 114 { 115 global $relative; 116 117 $image_per_line = 5; 118 foreach($list as $path => $dir) 119 { 120 $i++; 121 if ($i==1) { echo "<tr>";} 122 ?> 123 <td><table width="100" cellpadding="0" cellspacing="0"><tr><td class="block"> 124 <a href="images.php?dir=<?php echo rawurlencode($path); ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img src="img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>" /></a> 125 </td></tr><tr> 126 <td class="edit"> 127 <?php if ($dir['entry']!='..') { ?> 128 <a href="images.php?dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>" title="Trash" onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);"><img src="img/edit_trash.gif" height="15" width="15" alt="Trash"/></a> 129 <?php }; ?> 130 <?php echo $dir['entry']; ?> 131 132 </td> 133 </tr></table></td> 134 <?php 135 if ($i==$image_per_line) { 136 echo "</tr>"; 137 $i=0; 138 } 139 } //foreach 140 return ($i); 141 }//function drawDirs 142 143 function addEmpties($list, &$manager, $j) 144 { 145 global $relative; 146 147 $image_per_line = 5; 148 149 if ($j != 0) { 150 for ($i=$j; $i <= $image_per_line; $i++) { 151 ?> 152 <td></td> 153 <?php 154 if ($i==$image_per_line) { 155 echo "</tr>"; 156 $i=0; 157 break; 158 } 159 } //for 160 } 161 }//function addEmpties 162 163 164 165 /** 166 * No directories and no files. 167 */ 168 function drawNoResults() 169 { 170 ?> 171 <table width="100%"> 172 <tr> 173 <td class="noResult">No Images Found</td> 174 </tr> 175 </table> 176 <?php 177 } 178 179 /** 180 * No directories and no files. 181 */ 182 function drawErrorBase(&$manager) 183 { 184 ?> 185 <table width="100%"> 186 <tr> 187 <td class="error">Invalid base directory: <?php echo $manager->config['base_dir']; ?></td> 188 </tr> 189 </table> 190 <?php 191 } 192 193 ?> 194 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 195 196 <html> 197 <head> 198 <title>Image List</title> 199 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 200 <link href="assets/imagelist.css" rel="stylesheet" type="text/css" /> 201 <script type="text/javascript" src="assets/dialog.js"></script> 202 <script type="text/javascript"> 203 204 /*<![CDATA[*/ 205 206 if(window.top) 207 I18N = window.top.I18N; 208 209 210 function hideMessage() 211 { 212 var topDoc = window.top.document; 213 var messages = topDoc.getElementById('messages'); 214 if(messages) 215 messages.style.display = "none"; 216 } 217 218 init = function() 219 { 220 hideMessage(); 221 var topDoc = window.top.document; 222 window.parent.document.uploader.reldir.value = "<?php echo $relative; ?>"; 223 224 <?php 225 //we need to refesh the drop directory list 226 //save the current dir, delete all select options 227 //add the new list, re-select the saved dir. 228 if($refreshDir) 229 { 230 $dirs = $manager->getDirs(); 231 ?> 232 var selection = topDoc.getElementById('dirPath'); 233 var currentDir = selection.options[selection.selectedIndex].text; 234 235 while(selection.length > 0) 236 { selection.remove(0); } 237 238 selection.options[selection.length] = new Option("/","<?php echo rawurlencode('/'); ?>"); 239 <?php foreach($dirs as $relative=>$fullpath) { ?> 240 selection.options[selection.length] = new Option("<?php echo $relative; ?>","<?php echo rawurlencode($relative); ?>"); 241 <?php } ?> 242 243 for(var i = 0; i < selection.length; i++) 244 { 245 var thisDir = selection.options[i].text; 246 if(thisDir == currentDir) 247 { 248 selection.selectedIndex = i; 249 break; 250 } 251 } 252 <?php } ?> 253 } 254 255 function editImage(image) 256 { 257 var url = "editor.php?img="+image; 258 Dialog(url, function(param) 259 { 260 if (!param) // user must have pressed Cancel 261 return false; 262 else 263 { 264 return true; 265 } 266 }, null); 267 } 268 269 /*]]>*/ 270 </script> 271 <script type="text/javascript" src="assets/images.js"></script> 272 <script language="javascript"> 273 </script> 274 275 </head> 276 277 <body> 278 279 280 <?php if ($manager->isValidBase() == false) { drawErrorBase($manager); } 281 282 elseif(count($list[0]) > 0 || count($list[1]) > 0) { ?> 283 284 <table width="560" cellpadding="0" cellspacing="0"> 285 <?php 286 $i = 0; 287 $i = drawDirs($list[0], $manager,$i); 288 $i = drawFiles($list[1], $manager,$i); 289 addEmpties($list[1], $manager,$i); 290 ?> 291 292 </table> 293 <?php } else { drawNoResults(); } ?> 294 </body> 295 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Tue Apr 3 18:50:37 2007 | par Balluche grâce à PHPXref 0.7 |