Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1:/tmp/cvs-serv22864
Modified Files:
serendipity_admin_images.inc.php
Log Message:
Fixed layout; Added Delete feature; Improved rename JS; Suppressed errors from getimagesize
Index: serendipity_admin_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_images.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- serendipity_admin_images.inc.php 6 Apr 2003 21:33:40 -0000 1.3
+++ serendipity_admin_images.inc.php 18 May 2003 20:52:20 -0000 1.4
@@ -21,7 +21,7 @@
<script language="javascript">
<!--
function rename(fname) {
- if(newname = prompt('Enter the new name for '+fname))
+ if(newname = prompt('Enter the new name for '+fname, fname))
location.href='?serendipity[adminModule]=images&serendipity[adminAction]=rename&serendipity[oldname]='+
escape(fname)+'&serendipity[newname]='+escape(newname);
}
@@ -45,25 +45,25 @@
// Parse filename and image info
$f = serendipity_parseFileName($files[$x]);
- $i = getimagesize($serendipity["serendipityPath"].$serendipity["uploadPath"]."/".$files[$x]);
+ $i = @getimagesize($serendipity["serendipityPath"].$serendipity["uploadPath"]."/".$files[$x]);
- echo "<td class='serendipity_admin_list_item'>";
+ echo "<td class='serendipity_admin_list_item' width='50%' nowrap>";
// Display a thumbnail?
- if (file_exists($serendipity["serendipityPath"] . $serendipity["uploadPath"] . $f[0] . "." . $serendipity["thumbSuffix"] . "." . $f[1])) {
+ echo "<b>".$files[$x]."</b><br>";
+ if (file_exists($serendipity["serendipityPath"] . $serendipity["uploadPath"] . $f[0] . "." . $serendipity["thumbSuffix"] . "." . $f[1])) {
echo "<img align='left' src='".$serendipity['serendipityHTTPPath'] . $serendipity["uploadHTTPPath"].$f[0].".".$serendipity["thumbSuffix"].".".$f[1]."' hspace='15'>";
}
// Display image name and resolution
- echo "<b>".$files[$x]."</b><br>";
- echo $i[0]."x".$i[1]."<br>";
+ echo "<br>". $i[0]."x".$i[1]."<br>";
// Display tools
- echo "<img class='serendipityImageButton' alt='Fullsize' src='".$serendipity["serendipityHTTPPath"]."pixel/zoom.png' border='0' onClick=\"F1 = window.open(".
- "'".$serendipity["serendipityHTTPPath"].$serendipity["uploadHTTPPath"].$files[$x]."','Zoom','height=".($i[1]+20).",width=".($i[0]+20)."');\">";
+ echo "<img class='serendipityImageButton' alt='Fullsize' src='".$serendipity["serendipityHTTPPath"]."pixel/zoom.png' border='0' onClick=\"F1 = window.open('".$serendipity["serendipityHTTPPath"].$serendipity["uploadHTTPPath"].$files[$x]."','Zoom','height=".($i[1]+20).",width=".($i[0]+20).",toolbar=no,menubar=no,location=no');\">";
echo "<img class='serendipityImageButton' alt='Rename this image' src='".$serendipity["serendipityHTTPPath"]."pixel/rename.png' onClick='rename(\"".addslashes($files[$x])."\")' border='0'>";
echo "<img class='serendipityImageButton' alt='Resize this image' src='".$serendipity["serendipityHTTPPath"]."pixel/scale.png' border='0' onClick='location.href=\"?serendipity[adminModule]=images&serendipity[adminAction]=scaleSelect&serendipity[fname]=".rawurlencode($files[$x])."\";'>";
- echo "</td>";
+ echo "<img class='serendipityImageButton' alt='Delete this image' src='".$serendipity["serendipityHTTPPath"]."pixel/delete.png' onClick='location.href=\"?serendipity[adminModule]=images&serendipity[adminAction]=delete&serendipity[fname]=".rawurlencode($files[$x])."\";' border='0'>";
+ echo "</td>";
// Linebreak?
if (($x+1)%2 == 0) echo "</tr><tr>";
@@ -78,14 +78,43 @@
switch ($serendipity["GET"]["adminAction"]) {
case "genThumbs":
- set_time_limit(0);
- ignore_user_abort();
- echo "<b>Resizing:</b><p>";
- flush();
+ set_time_limit(0);
+ ignore_user_abort();
+ echo "<b>Resizing:</b><p>";
+ flush();
$i = serendipity_generateThumbs();
- echo "Done (resized $i images).";
- break;
+ echo "Done (resized $i images).";
+ break;
+ case "DoDelete":
+ if ( file_exists($serendipity["serendipityPath"].$serendipity["uploadPath"].$serendipity["fname"]) ) {
+ if ( @unlink($serendipity["serendipityPath"].$serendipity["uploadPath"].$serendipity["fname"]) ) {
+ echo "Deleted the image entitled <b>". $serendipity['fname'] ."</b>";
+ } else {
+ echo "Unable to delete <b>". $serendipity['fname'] ."</b>";
+ }
+ } else {
+ echo "I was unable to locate the file entitled <b>". $serendipity['fname'] ."</b>, maybe it has already been deleted?";
+ }
+
+ break;
+ case "delete":
+ $file = $serendipity['fname'];
+
+
+ echo "You are about to delete <b>$file</b><br>";
+ echo "If you are using this file in some of your entries, it will cause dead images<br>";
+ echo "Are you sure you wish to proceed?<p>";
+
+ $newLoc = $serendipity['serendipityHTTPPath'] ."serendipity_entries.php?serendipity[adminModule]=images&serendipity[adminAction]=DoDelete&serendipity[fname]=". $serendipity['fname'];
+ echo "<input type='button' value='Delete the image' onClick='location.href=\"$newLoc\"'>";
+
+ echo str_repeat(" ", 10);
+
+ $newLoc = $serendipity['serendipityHTTPPath'] ."serendipity_entries.php?serendipity[adminModule]=images";
+ echo "<input type='button' value='Abort now' onClick='location.href=\"$newLoc\"'>";
+ break;
+
case "rename":
if ($serendipity["GET"]["oldname"] != "" && $serendipity["GET"]["newname"]!= "" &&
file_exists($serendipity["serendipityPath"].$serendipity["uploadPath"].$serendipity["GET"]["oldname"]) &&
|