Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1850
Modified Files:
serendipity_functions.inc.php serendipity_entries.php
serendipity_admin_entries.inc.php rss.php NEWS
Log Message:
Major functional redesign of "Edit entries".
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- NEWS 12 May 2004 14:52:48 -0000 1.121
+++ NEWS 13 May 2004 13:10:51 -0000 1.122
@@ -3,6 +3,13 @@
Version 0.7 ()
------------------------------------------------------------------------
+ * Redesigned admin interface for editing entries: Adjust items per
+ page, sort order, filter mode, combined EDIT+DELETE interface into
+ one. Introduced new css classes "serendipity_admin_list_item_even"
+ and "serendipity_admin_list_item_uneven" for displaying entries.
+ Can now search for entries in admin panel, can edit entries with
+ empty titles. (garvinhicking)
+
* Fixed image comment manager's "center" alignment mode and use
image width/height from the image manager to format the <img>-Tag,
with regards to Lewe.
Index: serendipity_entries.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_entries.php,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- serendipity_entries.php 7 Apr 2004 12:42:42 -0000 1.29
+++ serendipity_entries.php 13 May 2004 13:10:51 -0000 1.30
@@ -61,7 +61,6 @@
<div class="serendipitySideBarContent">
• <a href="?serendipity[adminModule]=entries&serendipity[adminAction]=new"><?php echo NEW_ENTRY; ?></a><br />
• <a href="?serendipity[adminModule]=entries&serendipity[adminAction]=editSelect"><?php echo EDIT_ENTRIES; ?></a><br />
- • <a href="?serendipity[adminModule]=entries&serendipity[adminAction]=deleteSelect"><?php echo DELETE_ENTRIES; ?></a><br />
<?php serendipity_plugin_api::hook_event('backend_sidebar_entries', $serendipity); ?>
</div>
</div>
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.265
retrieving revision 1.266
diff -u -d -r1.265 -r1.266
--- serendipity_functions.inc.php 13 May 2004 07:27:46 -0000 1.265
+++ serendipity_functions.inc.php 13 May 2004 13:10:50 -0000 1.266
@@ -527,7 +527,7 @@
* Give it a range in YYYYMMDD format to gather the desired entries
* (For february 2002 you would pass 200202 e.g.
**/
-function serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp') {
+function serendipity_fetchEntries($range = null, $full = true, $limit = '', $fetchDrafts = false, $modified_since = false, $orderby = 'timestamp DESC', $filter_sql = '') {
global $serendipity;
$and = '';
@@ -573,7 +573,7 @@
if (!empty($limit)) {
$limit = ($limit > 50 ? $limit : 50);
}
- $orderby = 'last_modified';
+ $orderby = 'last_modified DESC';
}
}
@@ -623,6 +623,14 @@
}
}
+ if (!empty($filter_sql)) {
+ if (!empty($and)) {
+ $and .= ' AND ' . $filter_sql;
+ } else {
+ $and = 'WHERE ' . $filter_sql;
+ }
+ }
+
$query = "SELECT
e.id,
e.title,
@@ -651,7 +659,7 @@
LEFT JOIN {$serendipity['dbPrefix']}authors a
ON e.authorid = a.authorid $and
ORDER BY
- $orderby DESC
+ $orderby
$limit";
$ret = serendipity_db_query($query);
@@ -2204,7 +2212,7 @@
<?php
}
?>
- <b><?php echo CATEGORY; ?></b> <?php echo $cat_list ; ?></td>
+ <b><?php echo CATEGORY; ?>:</b> <?php echo $cat_list ; ?></td>
</tr>
<tr>
<?php
Index: serendipity_admin_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_entries.inc.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- serendipity_admin_entries.inc.php 7 Apr 2004 12:42:42 -0000 1.20
+++ serendipity_admin_entries.inc.php 13 May 2004 13:10:51 -0000 1.21
@@ -13,105 +13,214 @@
die ("Don't hack!");
}
+function serendipity_drawList_sort() {
+ global $serendipity;
+
+ $sort = SORT_ORDER . ': ';
+ $sort .= '<select name="serendipity[order]">';
+
+ $sort_order = array(
+ 'timestamp' => DATE,
+ 'username' => AUTHOR,
+ 'category_name' => CATEGORY,
+ 'last_modified' => LAST_UPDATED,
+ 'title' => TITLE
+ );
+
+ foreach($sort_order AS $so_key => $so_val) {
+ $sort .= '<option value="' . $so_key . '" ' . (isset($serendipity['GET']['order']) && $serendipity['GET']['order'] == $so_key ? 'selected="selected"' : '') . '>' . $so_val . '</option>' . "\n";
+ }
+
+ $sort .= '</select><select name="serendipity[ordermode]">'
+ . '<option value="DESC" ' . (isset($serendipity['GET']['ordermode']) && $serendipity['GET']['ordermode'] == 'DESC' ? 'selected="selected"' : '') . '>' . SORT_ORDER_DESC . '</option>'
+ . '<option value="ASC" ' . (isset($serendipity['GET']['ordermode']) && $serendipity['GET']['ordermode'] == 'ASC' ? 'selected="selected"' : '') . '>' . SORT_ORDER_ASC . '</option>'
+ . '</select>'
+ . '<select name="serendipity[perPage]">';
+
+ $per_page = array('12', '16', '50', '100');
+ foreach($per_page AS $per_page_nr) {
+ $sort .= '<option value="' . $per_page_nr . '" ' . (isset($serendipity['GET']['perPage']) && $serendipity['GET']['perPage'] == $per_page_nr ? 'selected="selected"' : '') . '>' . $per_page_nr . ' ' . ENTRIES_PER_PAGE . '</option>' . "\n";
+ }
+
+ $sort .= '</select>';
+ return $sort;
+}
+
+function serendipity_drawList_filter() {
+ global $serendipity;
+
+ $sort = FILTER . ' ' . AUTHOR . ' ';
+ $sort .= '<select name="serendipity[filter_author]"><option value="">--</option>';
+ $users = serendipity_fetchUsers();
+ if (is_array($users)) {
+ foreach ($users AS $row) {
+ $sort .= '<option value="' . $row['authorid'] . '" ' . (isset($serendipity['GET']['filter_author']) && $serendipity['GET']['filter_author'] == $row['authorid'] ? 'selected="selected"' : '') . '>' . $row['username'] . '</option>' . "\n";
+ }
+ }
+
+ $sort .= '</select> ' . CATEGORY . ' <select name="serendipity[filter_category]"><option value="">--</option>';
+ $categories = serendipity_fetchCategories();
+ if (is_array($categories)) {
+ foreach($categories AS $row) {
+ $sort .= '<option value="' . $row['categoryid'] . '" ' . (isset($serendipity['GET']['filter_category']) && $serendipity['GET']['filter_category'] == $row['categoryid'] ? 'selected="selected"' : '') . '>' . $row['category_name'] . '</option>' . "\n";
+ }
+ }
+
+ $sort .= '</select> '
+ . ($serendipity['dbType'] == 'mysql' ? CONTENT . ': <input type="text" name="serendipity[filter_body]" value="' . (isset($serendipity['GET']['filter_body']) ? htmlspecialchars($serendipity['GET']['filter_body']) : '') . '" />' : '')
+ . ' <input type="submit" name="go" value="' . GO . ' " />';
+ return $sort;
+}
+
// A little helper we don't want in _functions.inc.php
function serendipity_drawList($action) {
global $serendipity;
+ $perPage = (!empty($serendipity['GET']['perPage']) ? $serendipity['GET']['perPage'] : 12);
+ $perRow = 3;
+ $full = false;
+
// Prepare variables
if (empty($serendipity['GET']['offset']) || !is_numeric($serendipity['GET']['offset'])) {
$serendipity['GET']['offset'] = 0;
}
- $perPage = 12;
+ if (!empty($serendipity['GET']['prevpage'])) {
+ $serendipity['GET']['offset'] = max(0, ($serendipity['GET']['offset'] - $perPage));
+ }
+
+ if (!empty($serendipity['GET']['nextpage'])) {
+ $serendipity['GET']['offset'] = $serendipity['GET']['offset'] + $perPage;
+ }
+
+ if (empty($serendipity['GET']['ordermode'])) {
+ $serendipity['GET']['ordermode'] = 'DESC';
+ }
+
+ if (!empty($serendipity['GET']['order'])) {
+ $orderby = serendipity_db_escape_string($serendipity['GET']['order'] . ' ' . $serendipity['GET']['ordermode']);
+ } else {
+ $orderby = 'timestamp ' . serendipity_db_escape_string($serendipity['GET']['ordermode']);
+ }
+
+ $filter = array();
+ if (!empty($serendipity['GET']['filter_author'])) {
+ $filter[] = "e.authorid = '" . serendipity_db_escape_string($serendipity['GET']['filter_author']) . "'";
+ }
+
+ if (!empty($serendipity['GET']['filter_category'])) {
+ $filter[] = "e.categoryid = '" . serendipity_db_escape_string($serendipity['GET']['filter_category']) . "'";
+ }
+
+ if (!empty($serendipity['GET']['filter_body'])) {
+ if ($serendipity['dbType'] == 'mysql') {
+ $filter[] = "MATCH (title,body,extended) AGAINST ('" . serendipity_db_escape_string($serendipity['GET']['filter_body']) . "')";
+ $full = true;
+ }
+ }
+
+ $filter_sql = implode(' AND ', $filter);
// Fetch the entries
$entries = serendipity_fetchEntries(
false,
- false,
+ $full,
serendipity_db_limit(
$serendipity['GET']['offset'],
$perPage
),
- true
+ true,
+ false,
+ $orderby,
+ $filter_sql
);
- $string_action = ($action == 'delete' ? DELETE_ENTRIES : EDIT_ENTRIES);
// Prepare table
?>
+<form action="?" method="get">
<div class="serendipity_admin_list">
- <div class="serendipity_admin_list_title"><?php echo $string_action; ?>:</div>
+ <input type="hidden" name="serendipity[action]" value="admin" />
+ <input type="hidden" name="serendipity[adminModule]" value="entries" />
+ <input type="hidden" name="serendipity[adminAction]" value="editSelect" />
+ <input type="hidden" name="serendipity[offset]" value="<?php echo $serendipity['GET']['offset']; ?>" />
- <table width="100%" class="serendipity_admin_list">
+ <div class="serendipity_admin_list_title"><?php echo EDIT_ENTRIES; ?>:</div>
+ <table class="serendipity_admin_list" cellpadding="5">
<?php
if (is_array($entries)) {
- $half = (int) ((count($entries) + 1)/2);
+ $halfRowLeft = ceil($perRow/2);
+ $halfRowRight = $perRow - $halfRowLeft;
+ $count = count($entries);
// Print the browse buttons
?>
<tr>
+ <td colspan="<?php echo $halfRowLeft; ?>">
+<?php if ($serendipity['GET']['offset'] > 0) { ?>
+ <input type="submit" name="serendipity[prevpage]" value="<<<" />
+<?php } ?>
+ </td>
+
<td>
-<?php
- if ($serendipity['GET']['offset'] > 0) {
-?>
- <input type="button" value="<<<" onclick="location.href='?serendipity[adminModule]=entries&serendipity[adminAction]=<?php echo $serendipity['GET']['adminAction']; ?>&serendipity[offset]=<?php echo max(0, ($serendipity['GET']['offset'] - $perPage)); ?>';" />
-<?php
- }
-?>
+ <?php echo serendipity_drawList_sort(); ?><br />
+ <?php echo serendipity_drawList_filter(); ?>
</td>
- <td align="right">
-<?php
- if (count($entries) == $perPage) {
-?>
- <input type="button" value=">>>" onclick="location.href='?serendipity[adminModule]=entries&serendipity[adminAction]=<?php echo $serendipity['GET']['adminAction']; ?>&serendipity[offset]=<?php echo $serendipity['GET']['offset'] + $perPage; ?>';" />
-<?php
- }
-?>
+ <td colspan="<?php echo $halfRowRight; ?>" align="right">
+<?php if ($count == $perPage) { ?>
+ <input type="submit" name="serendipity[nextpage]" value=">>>" />
+<?php } ?>
</td>
</tr>
+ </table>
+ <table class="serendipity_admin_list" cellpadding="5">
<?php
// Print the entries
- $count = count($entries);
- for ($x=0; $x < $half; $x++) {
+ $rows = 0;
+ for ($x = 0; $x < $count; $x += $perRow) {
+ $rows++;
?>
<tr>
- <td class="serendipity_admin_list_item">
- <?php echo date('d.m.y, H:i', $entries[$x]['timestamp']) . ': '; ?>
- <br />
- <?php if ($entries[$x]['isdraft'] == 'true') echo DRAFT . ':'; ?>
- <a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=<?php echo $action; ?>&serendipity[id]=<?php echo $entries[$x]['id']; ?>" title="#<?php echo $entries[$x]['id']; ?>">
- <?php echo htmlspecialchars(substr(empty($entries[$x]['title']) ? $entries[$x]['body'] : $entries[$x]['title'], 0, 40)); ?>
+<?php
+ for ($xx = 0; $xx < $perRow; $xx++) {
+ $entryIndex = $x + $xx;
+ if (isset($entries[$entryIndex])) {
+ // Find out if the entry has been modified later than 30 minutes after creation
+ if ($entries[$entryIndex]['timestamp'] <= ($entries[$entryIndex]['last_modified'] - 60*30)) {
+ $lm = '<a href="#" title="' . LAST_UPDATED . ': ' . serendipity_formatTime(DATE_FORMAT_SHORT, $entries[$entryIndex]['last_modified']) . '" onclick="alert(this.title)">*</a>';
+ } else {
+ $lm = '';
+ }
+?>
+ <td class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo ($rows % 2 ? 'even' : 'uneven'); ?>">
+ <a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=delete&serendipity[id]=<?php echo $entries[$entryIndex]['id']; ?>" title="#<?php echo $entries[$x]['id']; ?>">
+ <img style="float: right" class="serendipityImageButton" title="<?php echo DELETE; ?>" alt="<?php echo DELETE; ?>" src="<?php echo $serendipity['serendipityHTTPPath']; ?>pixel/delete.png" border="0" />
</a>
+ <?php echo serendipity_formatTime(DATE_FORMAT_SHORT, $entries[$entryIndex]['timestamp']); ?>
+ <br />
+ <?php if ($entries[$entryIndex]['isdraft'] == 'true') echo DRAFT . ':'; ?>
+ <a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=<?php echo $entries[$entryIndex]['id']; ?>" title="#<?php echo $entries[$x]['id']; ?>">
+ <?php echo htmlspecialchars(substr(empty($entries[$entryIndex]['title']) ? (empty($entries[$entryIndex]['body']) ? '---' : $entries[$entryIndex]['body']) : $entries[$entryIndex]['title'], 0, 40)); ?>
+ </a><br />
+ <?php echo POSTED_BY . ' ' . $entries[$entryIndex]['username'] . ' ' . IN . ' ' . $entries[$entryIndex]['category_name'] . $lm; ?><br />
</td>
-
- <td class="serendipity_admin_list_item">
<?php
- if ($x + $half < $count) {
+ } else {
?>
- <?php echo date('d.m.y, H:i', $entries[$x + $half]['timestamp']) . ': '; ?>
- <br />
- <?php if ($entries[$x + $half]['isdraft'] == 'true') echo DRAFT . ':'; ?>
- <a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=<?php echo $action; ?>&serendipity[id]=<?php echo $entries[$x + $half]['id']; ?>" title="#<?php echo $entries[$x + $half]['id']; ?>">
- <?php echo htmlspecialchars(substr(empty($entries[$x + $half]['title']) ? $entries[$x + $half]['body'] : $entries[$x + $half]['title'], 0, 40)); ?>
- </a>
+ <td class="serendipity_admin_list_item"> </td>
<?php
- }
+ }
+ } // end perRow output
?>
- </td>
</tr>
<?php
- }
+ } // end entries output
?>
+
<tr>
<td class="serendipity_admin_list_item">
<br />
- <form action="?" method="get">
- <input type="hidden" name="serendipity[action]" value="admin" />
- <input type="hidden" name="serendipity[adminModule]" value="entries" />
- <input type="hidden" name="serendipity[adminAction]" value="edit" />
- <?php echo EDIT_ENTRY . ': #<input type="text" size="3" name="serendipity[id]" /> <input type="submit" name="submit" value="' . GO . '" />'; ?>
- </form>
-
+ <?php echo EDIT_ENTRY . ': #<input type="text" size="3" name="serendipity[id]" /> <input type="submit" name="serendipity[editSubmit]" value="' . GO . '" />'; ?>
</td>
</tr>
<?php
@@ -119,8 +228,9 @@
// We've got nothing
?>
<tr>
- <td class="serendipity_admin_list_item" colspan="2">
- <?php echo NO_ENTRIES_TO_PRINT ?>
+ <td>
+ <?php echo serendipity_drawList_sort(); ?><br />
+ <?php echo serendipity_drawList_filter(); ?>
</td>
</tr>
<?php
@@ -128,9 +238,14 @@
?>
</table>
</div>
+</form>
<?php
}
+if (!empty($serendipity['GET']['editSubmit'])) {
+ $serendipity['GET']['adminAction'] = 'edit';
+}
+
switch($serendipity['GET']['adminAction']) {
case 'save':
$entry = array(
@@ -187,7 +302,7 @@
echo '<div style="border:1px solid #000000; padding: 15px;">';
serendipity_printEntries(array($entry), ($entry['extended'] != '' ? 1 : 0), true);
echo '</div>';
-
+
serendipity_printEntryForm(
'?',
array(
@@ -206,10 +321,6 @@
serendipity_drawList('edit');
break;
- case 'deleteSelect':
- serendipity_drawList('delete');
- break;
-
case 'delete':
$newLoc = '?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=doDelete&serendipity[id]=' . $serendipity['GET']['id'];
printf(DELETE_SURE, $serendipity['GET']['id']);
Index: rss.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/rss.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- rss.php 4 Apr 2004 16:24:46 -0000 1.24
+++ rss.php 13 May 2004 13:10:51 -0000 1.25
@@ -25,15 +25,15 @@
break;
case 'content':
default:
- $latest_entry = serendipity_fetchEntries(null, false, 1, false, false, 'last_modified');
+ $latest_entry = serendipity_fetchEntries(null, false, 1, false, false, 'last_modified DESC');
break;
}
-
+
/*
* Caching logic - Do not send feed if nothing has changed
* Implementation inspired by Simon Willison [http://simon.incutio.com/archive/2003/04/23/conditionalGet], Thiemo Maettig
*/
-
+
// See if the client has provided the required headers.
// Always convert the provided header into GMT timezone to allow comparing to the server-side last-modified header
$modified_since = !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])
@@ -42,14 +42,14 @@
$none_match = !empty($_SERVER['HTTP_IF_NONE_MATCH'])
? str_replace('"', '', stripslashes($_SERVER['HTTP_IF_NONE_MATCH']))
: false;
-
+
if (is_array($latest_entry) && isset($latest_entry[0]['last_modified'])) {
$last_modified = gmdate('D, d M Y H:i:s \G\M\T', $latest_entry[0]['last_modified']);
$etag = '"' . $last_modified . '"';
-
+
header('Last-Modified: ' . $last_modified);
header('ETag: ' . $etag);
-
+
if (($none_match == $last_modified && $modified_since == $last_modified) ||
(!$none_match && $modified_since == $last_modified) ||
(!$modified_since && $none_match == $last_modified)) {
@@ -125,7 +125,7 @@
serendipity_plugin_api::hook_event('frontend_display:rss-1.0:namespace', $eventData);
print <<<HEAD
<rdf:RDF {$eventData['display_dat']}
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:admin="http://webns.net/mvcb/"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
@@ -139,7 +139,7 @@
<admin:errorReportsTo rdf:resource="mailto:{$serendipity['email']}" />
{$additional_fields['image_rss1.0_channel']}
-
+
<items>
<rdf:Seq>{$rdf_seq_li}</rdf:Seq>
</items>
@@ -179,7 +179,7 @@
print <<<HEAD
<feed version="0.3"
xmlns="http://purl.org/atom/ns#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:admin="http://webns.net/mvcb/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
@@ -193,7 +193,7 @@
<modified>$modified</modified>
<generator url="http://www.s9y.org/" version="{$serendipity['version']}">Serendipity {$serendipity['version']} - http://www.s9y.org/</generator>
<dc:language>{$serendipity['lang']}</dc:language>
- <admin:errorReportsTo rdf:resource="mailto:{$serendipity['email']}" />
+ <admin:errorReportsTo rdf:resource="mailto:{$serendipity['email']}" />
<info mode="xml" type="text/html">
<div xmlns="http://www.w3.org/1999/xhtml">You are viewing an ATOM formatted XML site feed. Usually this file is inteded to be viewed in an aggregator or syndication software. If you want to know more about ATOM, please visist <a href="http://atomenabled.org/">Atomenabled.org</a></div>
</info>
|