Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16220
Modified Files:
serendipity_functions_images.inc.php
Log Message:
Added missing CVS Tags
Corrected some coding guideline issues
Index: serendipity_functions_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_images.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- serendipity_functions_images.inc.php 8 Feb 2004 17:56:27 -0000 1.1
+++ serendipity_functions_images.inc.php 9 Feb 2004 14:31:35 -0000 1.2
@@ -1,10 +1,10 @@
-<?php
+<?php # $Id$
/**
* Get a list of images
**/
-function serendipity_fetchImagesFromDatabase($start = 0, $limit=0, &$total) {
+function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total) {
global $serendipity;
$rs = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}images ORDER BY date DESC", false, 'assoc');
if ( !is_array($rs) ) {
@@ -23,6 +23,7 @@
$rs = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}images WHERE id = ". $id, true, 'assoc');
return $rs;
}
+
function serendipity_updateImageInDatabase($updates, $id) {
global $serendipity;
$i=0;
@@ -185,7 +186,6 @@
function serendipity_guessMIME($extension) {
switch ( $extension ) {
-
}
return $mime;
@@ -199,41 +199,46 @@
$i=0;
$files = serendipity_fetchImages();
- for($x=0; $x<count($files); $x++) {
+ $fcount = count($files);
+ for ($x = 0; $x < $fcount; $x++) {
$update = $q = array();
- $f = serendipity_parseFileName($files[$x]);
- $ffull = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $files[$x];
+ $f = serendipity_parseFileName($files[$x]);
+ $ffull = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $files[$x];
$fthumb = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $f[0] . '.' . $serendipity['thumbSuffix'] . '.' . $f[1];
- $fdim = getimagesize($ffull);
+ $fdim = getimagesize($ffull);
- if ( !isset($fdim['mime']) ) {
+ if (!isset($fdim['mime'])) {
$fdim['mime'] = serendipity_guessMime($f[1]);
}
$rs = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}images
- WHERE name = '$f[0]'
- AND mime = '$fdim[mime]'", true, 'assoc');
- if ( is_array($rs) ) {
+ WHERE name = '$f[0]'
+ AND mime = '$fdim[mime]'", true, 'assoc');
+ if (is_array($rs)) {
$checkfile = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $rs['name'] . '.' . $rs['thumbnail_name'] . '.' . $rs['extension'];
- if ( $rs['dimensions_width'] != $fdim[0] ) {
+ if ($rs['dimensions_width'] != $fdim[0]) {
$update['dimensions_width'] = $fdim[0];
}
- if ( $rs['dimensions_height'] != $fdim[1] ) {
+
+ if ($rs['dimensions_height'] != $fdim[1]) {
$update['dimensions_height'] = $fdim[1];
}
- if ( $rs['size'] != filesize($ffull) ) {
+
+ if ($rs['size'] != filesize($ffull)) {
$update['size'] = filesize($ffull);
}
- if ( !file_exists($checkfile) && file_exists($fthumb) ) {
+
+ if (!file_exists($checkfile) && file_exists($fthumb)) {
$update['thumbnail_name'] = $serendipity['thumbSuffix'];
}
/* Do the database update, if needed */
serendipity_updateImageInDatabase($update, $rs['id']);
- if ( sizeof($update) != 0 ) { $i++; }
-
+ if (sizeof($update) != 0) {
+ $i++;
+ }
} else {
- if ( file_exists($fthumb) ) {
+ if (file_exists($fthumb)) {
$thumbnail = $serendipity['thumbSuffix'];
}
serendipity_insertImageInDatabase($f[0], $f[1], $fdim['mime'], filesize($ffull), $fdim[0], $fdim[1], $thumbnail, filemtime($ffull));
@@ -273,13 +278,13 @@
}
/* If our loader does not exist, we are doomed */
- if ( !function_exists($loadfn) ) {
+ if (!function_exists($loadfn)) {
return false;
}
/* If the save function does not exist (i.e. read-only GIF), we want to output it as PNG */
- if ( !function_exists($savefn) ) {
- if ( function_exists('imagepng') ) {
+ if (!function_exists($savefn)) {
+ if (function_exists('imagepng')) {
$savefn = 'imagepng';
} else {
return false;
@@ -300,19 +305,19 @@
return array($newwidth, $newheight);
}
-function serendipity_displayImageList($start = 0, $end = 10, $lineBreak=NULL, $manage=false, $url=NULL) {
+function serendipity_displayImageList($start = 0, $end = 10, $lineBreak = NULL, $manage = false, $url = NULL) {
global $serendipity;
$serendipity['imageList'] = serendipity_fetchImagesFromDatabase($start, $end, $totalImages);
- $inc = $end - $start;
+ $inc = $end - $start;
- if ( isset($serendipity['GET']['adminModule']) ) {
- $extraParems = 'serendipity[adminModule]='. $serendipity['GET']['adminModule'] .'&';
+ if (isset($serendipity['GET']['adminModule'])) {
+ $extraParems = 'serendipity[adminModule]='. $serendipity['GET']['adminModule'] .'&';
}
$left = '<input type="button" value="<<<" onclick="location.href=\'?'. $extraParems .'serendipity[start]=' . ($start-$end) . '\';" '. (($start <= 0) ? 'disabled' : '') .'>' . "\n";
$right = '<input type="button" value=">>>" onclick="location.href=\'?'. $extraParems .'serendipity[start]=' . ($start+$end) . '\';" '. (($totalImages < $start+$end) ? 'disabled' : '') .'>' . "\n";
- if ( is_null($lineBreak) ) {
+ if (is_null($lineBreak)) {
$lineBreak = floor(750 / ($serendipity['thumbSize'] + 20));
}
?>
@@ -329,7 +334,7 @@
<tr>
<?php
- foreach ( $serendipity['imageList'] as $k => $file ) {
+ foreach ($serendipity['imageList'] as $k => $file) {
++$x; $preview = '';
$i = getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . '/' . $file['name'] .'.'. $file['thumbnail_name'] .'.'. $file['extension']);
$imgsrc = $serendipity['uploadHTTPPath'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
@@ -340,8 +345,10 @@
}
?>
<td class="serendipity_admin_list_item" nowrap="nowrap" align="center" valign="bottom">
-<?php echo $preview; ?>
-<?php if ( $manage ) { ?>
+<?php
+ echo $preview;
+ if ($manage) {
+?>
<table border="0" width="100%" style="border-bottom: 1px solid #000000">
<tr>
<td valign="middle"><font size="1">Org: <?php echo $file['dimensions_width'] . 'x' . $file['dimensions_height']; ?><br>Thumb: <?php echo $i[0] . 'x' . $i[1]; ?></font></td>
@@ -377,4 +384,4 @@
</table>
<?php
}
-?>
+?>
\ No newline at end of file
|