| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Mambo 4 * @subpackage Media Manager 5 * @author Mambo Foundation Inc see README.php 6 * @copyright (C) 2000 - 2009 Mambo Foundation Inc. 7 * See COPYRIGHT.php for copyright notices and details. 8 * @license GNU/GPL Version 2, see LICENSE.php 9 * 10 * Redistributions of files must retain the above copyright notice. 11 * 12 * Mambo is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; version 2 of the License. 15 */ 16 17 /** ensure this file is being included by a parent file */ 18 defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 19 20 /** 21 * @package Mambo 22 * @subpackage Media Manager 23 */ 24 class HTML_Media { 25 function showMedia($dirPath,$listdir ) { 26 27 ?> 28 <html style="width: 580; height: 440;"> 29 <style type="text/css"> 30 <!-- 31 .buttonHover { 32 border: 1px solid; 33 border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; 34 cursor: hand; 35 } 36 .buttonOut 37 { 38 border: 1px solid ButtonFace; 39 } 40 41 .separator { 42 position: relative; 43 margin: 3px; 44 border-left: 1px solid ButtonShadow; 45 border-right: 1px solid ButtonHighlight; 46 width: 0px; 47 height: 16px; 48 padding: 0px; 49 } 50 .manager 51 { 52 } 53 .statusLayer 54 { 55 background:#FFFFFF; 56 border: 1px solid #CCCCCC; 57 } 58 .statusText { 59 font-family: Verdana, Arial, Helvetica, sans-serif; 60 font-size: 15px; 61 font-weight: bold; 62 color: #6699CC; 63 text-decoration: none; 64 } 65 --> 66 </style> 67 </head> 68 69 <script type="text/javascript"> 70 function dirup(){ 71 var urlquery=frames['imgManager'].location.search.substring(1); 72 var curdir= urlquery.substring(urlquery.indexOf('listdir=')+8); 73 var listdir=curdir.substring(0,curdir.lastIndexOf('/')); 74 frames['imgManager'].location.href='index3.php?option=com_media&task=list&listdir=' + listdir; 75 } 76 77 78 function goUpDir() 79 { 80 var selection = document.forms[0].dirPath; 81 var dir = selection.options[selection.selectedIndex].value; 82 frames['imgManager'].location.href='index3.php?option=com_media&task=list&listdir=' + dir; 83 } 84 85 </script> 86 <body> 87 <form action="index2.php" name="adminForm" method="post" enctype="multipart/form-data" > 88 <table class="adminheading"> 89 <tr> 90 <th class="mediamanager"><?php echo T_('Media Manager'); ?></th> 91 <tr> 92 <td align="center"> <fieldset> 93 <table width="99%" align="center" border="0" cellspacing="2" cellpadding="2"> 94 <tr> 95 <td><table border="0" cellspacing="1" cellpadding="3"> 96 <tr> 97 <td><?php echo T_('Directory'); ?></td> 98 <td> 99 <?php echo $dirPath;?> 100 </td> 101 <td class="buttonOut"> 102 <a href="javascript:dirup()"><img src="components/com_media/images/btnFolderUp.gif" width="15" height="15" border="0" alt="Up"></a></td> 103 </tr> 104 </table></td> 105 </tr> 106 <tr> 107 <td align="center" bgcolor="white"><div name="manager" class="manager"> 108 <iframe src="index3.php?option=com_media&task=list&listdir=<?php echo $listdir?>" name="imgManager" id="imgManager" width="100%" height="170" marginwidth="0" marginheight="0" align="top" scrolling="auto" frameborder="0" hspace="0" vspace="0" background="white"></iframe> 109 </div> 110 </td> 111 </tr> 112 </table> 113 </fieldset></td> 114 </tr> 115 <tr> 116 <td><table border="0" align="center" cellpadding="2" cellspacing="2" width="100%"> 117 <tr> 118 <td align="left"><?php echo T_('Upload'); ?></td> 119 <td> 120 <input class="inputbox" type="file" name="upload" id="upload" size="79"> 121 <?php echo T_('Max size'); ?> = <?php echo ini_get( 'post_max_size' );?> 122 </td> 123 </tr> 124 <tr> 125 <td align="left"><?php echo T_('Code'); ?></td> 126 <td><input class="inputbox" type="text" name="imagecode" size="80" /></td> 127 </tr> 128 <tr> 129 <td align="left"><?php echo T_('Create Directory'); ?></td> 130 <td><input class="inputbox" type="text" name="foldername" size="80" /> 131 </td> 132 </tr> 133 </table> 134 135 </td> 136 </tr> 137 <tr> 138 <td><div style="text-align: right;"> 139 </div></td> 140 </tr> 141 </table> 142 <input type="hidden" name="option" value="com_media" /> 143 <input type="hidden" name="task" value="" /> 144 <input type="hidden" name="cb1" id="cb1" value="0"> 145 </form> 146 </body> 147 </html> 148 149 <?php 150 } 151 152 153 //Built in function of dirname is faulty 154 //It assumes that the directory nane can not contain a . (period) 155 function dir_name($dir){ 156 $lastSlash = intval(strrpos($dir, '/')); 157 if($lastSlash == strlen($dir)-1){ 158 return substr($dir, 0, $lastSlash); 159 } 160 else { 161 return dirname($dir); 162 } 163 } 164 165 function draw_no_results(){ 166 ?> 167 <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> 168 <tr> 169 <td><div align="center" style="font-size:large;font-weight:bold;color:#CCCCCC;font-family: Helvetica, sans-serif;"><?php echo T_('No Images Found'); ?></div></td> 170 </tr> 171 </table> 172 <?php 173 } 174 175 function draw_no_dir() { 176 global $BASE_DIR, $BASE_ROOT; 177 ?> 178 <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0"> 179 <tr> 180 <td><div align="center" style="font-size:small;font-weight:bold;color:#CC0000;font-family: Helvetica, sans-serif;"><?php printf(T_('Configuration Problem: " %s " does not exist.'), $BASE_DIR.$BASE_ROOT) ?></div></td> 181 </tr> 182 </table> 183 <?php 184 } 185 186 187 function draw_table_header() { 188 echo '<table border="0" cellpadding="0" cellspacing="2">'; 189 echo '<tr>'; 190 } 191 192 function draw_table_footer() { 193 echo '</tr>'; 194 echo '</table>'; 195 } 196 197 function show_image($img, $file, $info, $size, $listdir) { 198 global $mosConfig_live_site; 199 200 $img_file = basename($img); 201 $img_url = $mosConfig_live_site.'/images/stories'.$listdir.'/'.$img_file; 202 203 $filesize = HTML_Media::parse_size($size); 204 ?> 205 <td> 206 <table width="102" border="0" cellpadding="0" cellspacing="2"> 207 <tr> 208 <td align="center" class="imgBorder"> 209 <a href="javascript:;" onClick="javascript:window.top.document.forms[0].imagecode.value = '<img src="<?php echo $img_url;?>" align="left" hspace="6" alt="<?php echo $img_file;?>" />';"><img src="<?php echo $img_url; ?>" <?php echo HTML_Media::imageResize($info[0], $info[1], 80); ?> alt="<?php echo $file; ?> - <?php echo $filesize; ?>" border="0"></a></td> 210 </tr> 211 <tr> 212 <td> <?php echo $file; ?> </td> 213 </tr> 214 <tr> 215 <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> 216 <tr> 217 <td width="1%" class="buttonOut"> 218 <a href="javascript:;" onClick="javascript:window.top.document.forms[0].imagecode.value = '<img src="<?php echo $img_url;?>" align="left" hspace="6" alt="Code" />';"><img src="components/com_media/images/edit_pencil.gif" width="15" height="15" border="0" alt="<?php echo T_('Code'); ?>"></a></td> 219 <td width="1%" class="buttonOut"> 220 <a href="index2.php?option=com_media&task=delete&delFile=<?php echo $file; ?>&listdir=<?php echo $listdir; ?>" target="_top" onClick="return deleteImage('<?php echo $file; ?>');"><img src="components/com_media/images/edit_trash.gif" width="15" height="15" border="0" alt="<?php echo T_('Delete'); ?>"></a></td> 221 <td width="98%" class="imgCaption"><?php echo $info[0].'x'.$info[1]; ?></td> 222 </tr> 223 </table></td> 224 </tr> 225 </table> 226 </td> 227 <?php 228 } 229 230 function show_dir($path, $dir,$listdir) { 231 global $mosConfig_absolute_path; 232 233 $num_files = HTML_Media::num_files($mosConfig_absolute_path.$path); 234 235 // Fix for Bug [0000577] 236 if ($listdir=='/') { 237 $listdir=''; 238 } 239 240 ?> 241 <td> 242 <table width="102" border="0" cellpadding="0" cellspacing="2"> 243 <tr> 244 <td align="center" class="imgBorder")"> 245 <a href="index3.php?option=com_media&task=list&listdir=<?php echo $listdir.$path; ?>" target="imgManager" onClick="javascript:updateDir();"> 246 <img src="components/com_media/images/folder.gif" width="80" height="80" border="0" alt="<?php echo $dir; ?>"> 247 </a> 248 </td> 249 </tr> 250 <tr> 251 <td> <?php echo $dir; ?> </td> 252 </tr> 253 <tr> 254 <td><table width="100%" border="0" cellspacing="1" cellpadding="2"> 255 <tr> 256 <td width="1%" class="buttonOut"> 257 <a href="index2.php?option=com_media&task=deletefolder&delFolder=<?php echo $path; ?>&listdir=<?php echo $listdir; ?>" target="_top" onClick="return deleteFolder('<?php echo $dir; ?>', <?php echo $num_files; ?>);"><img src="components/com_media/images/edit_trash.gif" width="15" height="15" border="0" alt="<?php echo T_('Delete'); ?>"></a></td> 258 <td width="99%" class="imgCaption"></td> 259 </tr> 260 </table></td> 261 </tr> 262 </table> 263 </td> 264 <?php 265 } 266 267 function show_doc($doc, $listdir, $icon) { 268 global $mosConfig_absolute_path,$mosConfig_live_site; 269 270 ?> 271 272 <td> 273 <table width="102" border="0" cellpadding="0" cellspacing="2"> 274 <tr> 275 <td align="center" class="imgBorder"> 276 <a href="index3.php?option=com_media&task=list&listdir=<?php echo $listdir; ?>" onClick="javascript:window.top.document.forms[0].imagecode.value = '<a href="<?php echo $mosConfig_live_site.'/images/stories'.$listdir.'/'.$doc;?>"><?php echo T_('Insert your text here'); ?></a>';"> 277 <img border="0" src="<?php echo $icon ?>" alt="<?php echo $doc; ?>"></a> 278 </td> 279 </tr> 280 <tr> 281 <td> <?php echo $doc; ?> </td> 282 </tr> 283 <tr> 284 <td><table width="100%" border="0" cellspacing="0" cellpadding="2"> 285 <tr> 286 <td width="1%" class="buttonOut"> 287 <a href="javascript:;" onClick="javascript:window.top.document.forms[0].imagecode.value = '<a href="<?php echo $mosConfig_live_site.'/images/stories'.$listdir.'/'.$doc;?>">Insert your text here</a>';"><img src="components/com_media/images/edit_pencil.gif" width="15" height="15" border="0" alt="<?php echo T_('Code'); ?>"></a></td> 288 <td width="1%" class="buttonOut"> 289 <a href="index2.php?option=com_media&task=delete&delFile=<?php echo $doc; ?>&listdir=<?php echo $listdir; ?>" target="_top" onClick="return deleteImage('<?php echo $doc; ?>');"><img src="components/com_media/images/edit_trash.gif" width="15" height="15" border="0" alt="<?php echo T_('Delete'); ?>"></a></td> 290 <td width="98%" class="imgCaption"></td> 291 </tr> 292 </table></td> 293 </tr> 294 </table> 295 </td> 296 <?php 297 } 298 299 function parse_size($size){ 300 if($size < 1024) { 301 return $size.' bytes'; 302 } 303 else if($size >= 1024 && $size < 1024*1024) 304 { 305 return sprintf('%01.2f',$size/1024.0).' Kb'; 306 } 307 else 308 { 309 return sprintf('%01.2f',$size/(1024.0*1024)).' Mb'; 310 } 311 } 312 313 function imageResize($width, $height, $target) { 314 315 //takes the larger size of the width and height and applies the 316 //formula accordingly...this is so this script will work 317 //dynamically with any size image 318 319 if ($width > $height) { 320 $percentage = ($target / $width); 321 } else { 322 $percentage = ($target / $height); 323 } 324 325 //gets the new value and applies the percentage, then rounds the value 326 $width = round($width * $percentage); 327 $height = round($height * $percentage); 328 329 //returns the new sizes in html image tag format...this is so you 330 //can plug this function inside an image tag and just get the 331 332 return "width=\"$width\" height=\"$height\""; 333 334 } 335 336 function num_files($dir) 337 { 338 $total = 0; 339 340 if(is_dir($dir)) 341 { 342 $d = @dir($dir); 343 344 while (false !== ($entry = $d->read())) 345 { 346 //echo $entry."<br>"; 347 if(substr($entry,0,1) != '.') { 348 $total++; 349 } 350 } 351 $d->close(); 352 } 353 return $total; 354 } 355 356 357 function imageStyle($listdir){ 358 359 ?> 360 <script type="text/javascript"> 361 function updateDir(){ 362 var allPaths = window.top.document.forms[0].dirPath.options; 363 for(i=0; i<allPaths.length; i++) 364 { 365 allPaths.item(i).selected = false; 366 if((allPaths.item(i).value)== '<?php if (strlen($listdir)>0) { echo $listdir ;} else { echo '/';} ?>') 367 { 368 allPaths.item(i).selected = true; 369 } 370 } 371 } 372 373 function deleteImage(file) 374 { 375 if(confirm(<?php echo T_('"Delete file \""+file+"\"?"'); ?>)) 376 return true; 377 378 return false; 379 } 380 function deleteFolder(folder, numFiles) 381 { 382 if(numFiles > 0) { 383 alert(<?php echo T_('"There are "+numFiles+" files/folders in \""+folder+"\".\n\nPlease delete all files/folder in \""+folder+"\" first."'); ?>); 384 return false; 385 } 386 387 if(confirm(<?php echo T_('"Delete folder \""+folder+"\"?"'); ?>)) 388 return true; 389 390 return false; 391 } 392 </script> 393 </head> 394 <body onLoad="updateDir()"> 395 <style type="text/css"> 396 <!-- 397 .imgBorder { 398 height: 96px; 399 border: 1px solid threedface; 400 vertical-align: middle; 401 } 402 .imgBorderHover { 403 height: 96px; 404 border: 1px solid threedface; 405 vertical-align: middle; 406 background: #FFFFCC; 407 cursor: hand; 408 } 409 410 .buttonHover { 411 border: 1px solid; 412 border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight; 413 cursor: hand; 414 background: #FFFFCC; 415 } 416 417 .buttonOut 418 { 419 border: 0px; 420 } 421 422 .imgCaption { 423 font-size: 9pt; 424 font-family: "MS Shell Dlg", Helvetica, sans-serif; 425 text-align: center; 426 } 427 .dirField { 428 font-size: 9pt; 429 font-family: "MS Shell Dlg", Helvetica, sans-serif; 430 width:110px; 431 } 432 --> 433 </style> 434 435 <?php 436 } 437 438 } 439 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed May 23 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |