Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5042
Modified Files:
serendipity_functions_images.inc.php
serendipity_admin_images.inc.php
serendipity_admin_image_selector.php
Log Message:
Image manager: Make images sort by date, filename, whatever. Allow changing
sort order and items displayed.
Index: serendipity_functions_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_images.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- serendipity_functions_images.inc.php 9 Feb 2004 14:31:35 -0000 1.2
+++ serendipity_functions_images.inc.php 17 Feb 2004 12:10:04 -0000 1.3
@@ -4,15 +4,24 @@
/**
* Get a list of images
**/
-function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total) {
+function serendipity_fetchImagesFromDatabase($start=0, $limit=0, &$total, $order = false, $ordermode = false) {
global $serendipity;
- $rs = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}images ORDER BY date DESC", false, 'assoc');
- if ( !is_array($rs) ) {
+
+ if (empty($order)) {
+ $order = 'date';
+ }
+
+ if (empty($ordermode)) {
+ $ordermode = 'DESC';
+ }
+
+ $rs = serendipity_db_query("SELECT * FROM {$serendipity['dbPrefix']}images ORDER BY $order $ordermode", false, 'assoc');
+ if (!is_array($rs)) {
return array();
}
$total = sizeof($rs)+1;
- if ( $limit > 0 ) {
+ if ($limit > 0) {
$rs = @array_slice($rs, $start, $limit);
}
return $rs;
@@ -27,7 +36,7 @@
function serendipity_updateImageInDatabase($updates, $id) {
global $serendipity;
$i=0;
- if ( sizeof($updates) > 0 ) {
+ if (sizeof($updates) > 0) {
foreach ( $updates as $k => $v ) {
$q[] = $k ." = '". $v ."'";
}
@@ -43,14 +52,14 @@
$dFile = $file['name'] .'.'. $file['extension'];
$dThumb = $file['name'] .'.'. $file['thumbnail_name'] .'.'. $file['extension'];
- if ( file_exists($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dFile) ) {
- if ( @unlink($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dFile) ) {
+ if (file_exists($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dFile)) {
+ if (@unlink($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dFile)) {
printf(DELETE_IMAGE . '<br />', $dFile);
} else {
printf(DELETE_IMAGE_FAIL . '<br />', $dFile);
}
- if ( @unlink($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dThumb) ) {
+ if (@unlink($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $dThumb)) {
printf(DELETE_THUMBNAIL . '<br />', $dThumb);
}
} else {
@@ -97,7 +106,7 @@
function serendipity_makeThumbnail($file, $size=false) {
global $serendipity;
- if ($size===false) {
+ if ($size === false) {
$size = $serendipity['thumbSize'];
}
@@ -161,7 +170,7 @@
$i=0;
$serendipity['imageList'] = serendipity_fetchImagesFromDatabase(0, 0, $total);
- foreach ( $serendipity['imageList'] as $k => $file ) {
+ foreach ($serendipity['imageList'] as $k => $file) {
$filename = $file['name'] .'.'. $file['extension'];
$ffull = $serendipity['serendipityPath'] . $serendipity['uploadPath'] . $filename;
$fdim = @getimagesize($ffull);
@@ -185,7 +194,7 @@
}
function serendipity_guessMIME($extension) {
- switch ( $extension ) {
+ switch ($extension) {
}
return $mime;
@@ -308,15 +317,61 @@
function serendipity_displayImageList($start = 0, $end = 10, $lineBreak = NULL, $manage = false, $url = NULL) {
global $serendipity;
- $serendipity['imageList'] = serendipity_fetchImagesFromDatabase($start, $end, $totalImages);
+ $serendipity['imageList'] = serendipity_fetchImagesFromDatabase(
+ $start,
+ $end,
+ $totalImages,
+ ($serendipity['GET']['order'] ? $serendipity['GET']['order'] : false),
+ ($serendipity['GET']['ordermode'] ? $serendipity['GET']['ordermode'] : false)
+ );
+
$inc = $end - $start;
+ $extraParems = '';
if (isset($serendipity['GET']['adminModule'])) {
$extraParems = 'serendipity[adminModule]='. $serendipity['GET']['adminModule'] .'&';
}
+
+ if (isset($serendipity['GET']['order'])) {
+ $extraParems .= 'serendipity[order]='. $serendipity['GET']['order'] .'&';
+ }
- $left = '<input type="button" value="<<<" onclick="location.href=\'?'. $extraParems .'serendipity[start]=' . ($start-$end) . '\';" '. (($start <= 0) ? 'disabled' : '') .'>' . "\n";
+ if (isset($serendipity['GET']['ordermode'])) {
+ $extraParems .= 'serendipity[ordermode]='. $serendipity['GET']['ordermode'] .'&';
+ }
+
+ $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";
+
+ $sort = SORT_ORDER . ': <form style="display: inline; margin: 0px; padding: 0px;" method="get" action="?">';
+ foreach($serendipity['GET'] AS $g_key => $g_val) {
+ $sort .= '<input type="hidden" name="serendipity[' . $g_key . ']" value="' . htmlspecialchars($g_val) . '" />';
+ }
+ $sort .= '<select name="serendipity[order]">';
+
+ $sort_order = array(
+ 'date' => SORT_ORDER_DATE,
+ 'name' => SORT_ORDER_NAME,
+ 'extension' => SORT_ORDER_EXTENSION,
+ 'size' => SORT_ORDER_SIZE,
+ 'dimensions_width' => SORT_ORDER_WIDTH,
+ 'dimensions_height' => SORT_ORDER_HEIGHT
+ );
+ foreach($sort_order AS $so_key => $so_val) {
+ $sort .= '<option value="' . $so_key . '" ' . ($serendipity['GET']['order'] == $so_key ? 'selected="selected"' : '') . '>' . $so_val . '</option>';
+ }
+
+ $sort .= '</select><select name="serendipity[ordermode]">'
+ . '<option value="DESC" ' . ($serendipity['GET']['ordermode'] == 'DESC' ? 'selected="selected"' : '') . '>' . SORT_ORDER_DESC . '</option>'
+ . '<option value="ASC" ' . ($serendipity['GET']['ordermode'] == 'ASC' ? 'selected="selected"' : '') . '>' . SORT_ORDER_ASC . '</option>'
+ . '</select>'
+ . '<select name="serendipity[end]">'
+ . '<option value="8" ' . ($serendipity['GET']['end'] == 8 ? 'selected="selected"' : '') . '>8 ' . IMAGES_PER_PAGE . '</option>'
+ . '<option value="16" ' . ($serendipity['GET']['end'] == 16 ? 'selected="selected"' : '') . '>16 ' . IMAGES_PER_PAGE . '</option>'
+ . '<option value="50" ' . ($serendipity['GET']['end'] == 50 ? 'selected="selected"' : '') . '>50 ' . IMAGES_PER_PAGE . '</option>'
+ . '<option value="100" ' . ($serendipity['GET']['end'] == 100 ? 'selected="selected"' : '') . '>100 ' . IMAGES_PER_PAGE . '</option>'
+ . '<input type="submit" name="go" value="' . GO . ' " /></form>';
+
if (is_null($lineBreak)) {
$lineBreak = floor(750 / ($serendipity['thumbSize'] + 20));
}
@@ -331,6 +386,10 @@
<?php echo $right; ?>
</td>
</tr>
+
+ <tr>
+ <td align="center" colspan="<?php echo $lineBreak; ?>"><?php echo $sort; ?></td>
+ </tr>
<tr>
<?php
@@ -344,14 +403,18 @@
if ( $url ) { $preview = '<a href="'.$url.'&serendipity[image]='. $file['id'] .'">'. $preview .'</a>'; }
}
?>
- <td class="serendipity_admin_list_item" nowrap="nowrap" align="center" valign="bottom">
+ <td nowrap="nowrap" align="center" valign="bottom" <?php echo ( $manage ) ? 'style="border-bottom: 1px solid #000000"' : '' ?>>
<?php
echo $preview;
if ($manage) {
?>
-<table border="0" width="100%" style="border-bottom: 1px solid #000000">
+<table border="0" width="300">
<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>
+ <td valign="middle"><font size="1">
+ <?php echo $file['name'] . '.' . $file['extension']; ?><br />
+ <?php echo strftime(DATE_FORMAT_ENTRY . ' %H:%M', $file['date']); ?><br />
+ <?php echo ORIGINAL_SHORT . ': ' . $file['dimensions_width'] . 'x' . $file['dimensions_height']; ?><br />
+ <?php echo THUMBNAIL_SHORT . ': ' . $i[0] . 'x' . $i[1]; ?></font></td>
<td valign="middle" align="center"><img class="serendipityImageButton" title="<?php echo IMAGE_FULLSIZE; ?>" alt="<?php echo IMAGE_FULLSIZE; ?>" src="<?php echo $serendipity['serendipityHTTPPath']; ?>pixel/zoom.png" border="0" onclick="F1 = window.open('<?php echo $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['name'] . '.'. $file['extension']; ?>','Zoom','height=<?php echo ($file['dimensions_height'] + 20); ?>,width=<?php echo ($file['dimensions_width'] + 20); ?>,toolbar=no,menubar=no,location=no');" /></td>
<td valign="middle" align="center"><img class="serendipityImageButton" title="<?php echo IMAGE_RENAME; ?>" alt="<?php echo IMAGE_RENAME; ?>" src="<?php echo $serendipity['serendipityHTTPPath']; ?>pixel/rename.png" border="0" onclick="rename('<?php echo $file['id']; ?>', '<?php echo addslashes($file['name']); ?>')" /></td>
<td valign="middle" align="center"><img class="serendipityImageButton" title="<?php echo IMAGE_RESIZE; ?>" alt="<?php echo IMAGE_RESIZE; ?>" src="<?php echo $serendipity['serendipityHTTPPath']; ?>pixel/scale.png" border="0" onclick="location.href='?serendipity[adminModule]=images&serendipity[adminAction]=scaleSelect&serendipity[fid]=<?php echo $file['id']; ?>';" /></td>
@@ -363,7 +426,7 @@
<?php
// Newline?
- if ($x%$lineBreak == 0) {
+ if ($x % $lineBreak == 0) {
?>
</tr>
<tr>
@@ -372,6 +435,11 @@
}
?>
</tr>
+
+ <tr>
+ <td align="center" colspan="<?php echo $lineBreak; ?>"><?php echo $sort; ?></td>
+ </tr>
+
<tr>
<td align="left" colspan="<?php echo floor($lineBreak/2); ?>">
<?php echo $left; ?>
@@ -384,4 +452,4 @@
</table>
<?php
}
-?>
\ No newline at end of file
+?>
Index: serendipity_admin_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_images.inc.php,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- serendipity_admin_images.inc.php 8 Feb 2004 17:56:27 -0000 1.14
+++ serendipity_admin_images.inc.php 17 Feb 2004 12:10:04 -0000 1.15
@@ -258,11 +258,12 @@
<?php
- if (isset($serendipity['GET']['start'])) {
- serendipity_displayImageList($serendipity['GET']['start'], 8, 2, true);
- } else {
- serendipity_displayImageList(0, 8, 2, true);
- }
+ serendipity_displayImageList(
+ isset($serendipity['GET']['start']) ? $serendipity['GET']['start'] : 0,
+ isset($serendipity['GET']['end']) ? $serendipity['GET']['end'] : 8,
+ 2,
+ true
+ );
break;
}
Index: serendipity_admin_image_selector.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_image_selector.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- serendipity_admin_image_selector.php 8 Feb 2004 17:56:27 -0000 1.15
+++ serendipity_admin_image_selector.php 17 Feb 2004 12:10:05 -0000 1.16
@@ -82,7 +82,7 @@
}
if (!is_numeric($serendipity['GET']['end'])) {
- $serendipity['GET']['end'] = 15;
+ $serendipity['GET']['end'] = 16;
}
?>
<b><?php echo SELECT_IMAGE; ?></b>
@@ -91,7 +91,14 @@
<?php echo CLICK_IMAGE_TO_INSERT; ?>
<br />
- <?php serendipity_displayImageList($serendipity['GET']['start'], 8, 4, false, '?serendipity[step]=1');
+ <?php
+ serendipity_displayImageList(
+ isset($serendipity['GET']['start']) ? $serendipity['GET']['start'] : 0,
+ isset($serendipity['GET']['end']) ? $serendipity['GET']['end'] : 8,
+ 4,
+ false,
+ '?serendipity[step]=1'
+ );
}
?>
|