Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7959
Modified Files:
Tag: branch-smarty
NEWS serendipity_admin_entries.inc.php
serendipity_admin_image_selector.php
serendipity_admin_images.inc.php serendipity_functions.inc.php
serendipity_functions_images.inc.php
Log Message:
* Fixed entry preview in backend for usage with smarty
* New "quicksave" button to save an entry as draft without being
redirected to entry overview, and immediately showing the preview.
Use Accesskeys: Alt-S saves entry, Alt-P previews, ALT-Q
quicksaves.
* Media browser now allows to immediately upload a file from the
entry creation screen and use that file/image easily
Please test the media browser thingie especially, as I have not tested
all possible circumstances.
Index: serendipity_functions_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions_images.inc.php,v
retrieving revision 1.36.2.3
retrieving revision 1.36.2.4
diff -u -d -r1.36.2.3 -r1.36.2.4
--- serendipity_functions_images.inc.php 29 Oct 2004 10:11:08 -0000 1.36.2.3
+++ serendipity_functions_images.inc.php 4 Nov 2004 11:56:43 -0000 1.36.2.4
@@ -174,6 +174,12 @@
echo $query . '<br />';
echo $sql . '<br />';
}
+
+ $image_id = serendipity_db_insert_id('images', 'id');
+ if ($image_id > 0) {
+ return $image_id;
+ }
+
return true;
}
@@ -215,7 +221,7 @@
/* Lets assume we are all done, now we add the image to the image database */
if ($insertMode) {
- serendipity_insertImageInDatabase($f, $suf, $fdim['mime'], filesize($infile), $fdim[0], $fdim[1], $serendipity['thumbSuffix'], time(), $authorid, $directory);
+ $r['image_id'] = serendipity_insertImageInDatabase($f, $suf, $fdim['mime'], filesize($infile), $fdim[0], $fdim[1], $serendipity['thumbSuffix'], time(), $authorid, $directory);
}
return $r;
@@ -662,12 +668,12 @@
return array($newwidth, $newheight);
}
-function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = false, $url = NULL) {
+function serendipity_displayImageList($page = 0, $lineBreak = NULL, $manage = false, $url = NULL, $show_upload = false) {
global $serendipity;
$sort_row_interval = array(8, 16, 50, 100);
$perPage = (isset($serendipity['GET']['sortorder']['perpage']) ? $serendipity['GET']['sortorder']['perpage'] : $sort_row_interval[0]);
- $start = ($page-1)*$perPage;
+ $start = ($page-1) * $perPage;
$serendipity['imageList'] = serendipity_fetchImagesFromDatabase(
$start,
@@ -767,6 +773,13 @@
</tr>
<tr>
<td align="right" colspan="6">
+<?php
+ if ($show_upload) {
+?>
+ <input type="button" value="<?php echo htmlspecialchars(ADD_MEDIA); ?>" onclick="location.href='<?php echo $url; ?>&serendipity[adminAction]=addSelect'; return false" />
+<?php
+ }
+?>
<input type="submit" name="go" value=" - <?php echo GO ?> - " />
</td>
</tr>
Index: serendipity_admin_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_entries.inc.php,v
retrieving revision 1.37
retrieving revision 1.37.2.1
diff -u -d -r1.37 -r1.37.2.1
--- serendipity_admin_entries.inc.php 1 Sep 2004 17:17:41 -0000 1.37
+++ serendipity_admin_entries.inc.php 4 Nov 2004 11:56:43 -0000 1.37.2.1
@@ -281,6 +281,27 @@
}
}
+ if ($serendipity['POST']['quicksave'] == 'true') {
+ // When quicksaving a new entry, set it to 'draft'
+ if (!is_numeric($entry['id'])) {
+ $entry['isdraft'] = 'true';
+ }
+
+ $serendipity['POST']['preview'] = 'true';
+ $res = serendipity_updertEntry($entry);
+ if (is_string($res)) {
+ echo '<div class="serendipity_msg_error">' . QUICKSAVE . ': <b>' . $res . '</b></div><br />';
+ } else {
+ // serendipity_updertEntry sets this global variable to store the entry id. Couldn't pass this
+ // by reference or as return value because it affects too many places inside our API and dependant
+ // function calls.
+ if (!empty($serendipity['lastSavedEntry'])) {
+ $entry['id'] = $serendipity['lastSavedEntry'];
+ }
+ echo '<div class="serendipity_msg_notice">' . QUICKSAVE . ': ' . ENTRY_SAVED . '</div><br />';
+ }
+ }
+
// Save the entry, or just display a preview
if ($serendipity['POST']['preview'] != 'true') {
$res = serendipity_updertEntry($entry);
@@ -311,6 +332,7 @@
$entry['categories'][] = serendipity_fetchCategoryInfo($catid);
}
+ $serendipity['smarty_raw_mode'] = true; // Force output of Smarty stuff in the backend
echo '<strong>' . PREVIEW . '</strong>';
echo '<div style="border:1px solid #000000; padding: 15px;">';
serendipity_printEntries(array($entry), ($entry['extended'] != '' ? 1 : 0), true);
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.214.2.46
retrieving revision 1.214.2.47
diff -u -d -r1.214.2.46 -r1.214.2.47
--- NEWS 3 Nov 2004 10:00:50 -0000 1.214.2.46
+++ NEWS 4 Nov 2004 11:56:42 -0000 1.214.2.47
@@ -3,6 +3,15 @@
Version 0.8 ()
------------------------------------------------------------------------
+ * New "quicksave" button to save an entry as draft without being
+ redirected to entry overview, and immediately showing the preview.
+ Use Accesskeys: Alt-S saves entry, Alt-P previews, ALT-Q
+ quicksaves. (garvinhicking)
+
+ * Media browser now allows to immediately upload a file from the
+ entry creation screen and use that file/image easily
+ (garvinhicking)
+
* exit.php redirection will emit a 301 Moved Permanently header for
the new location. (garvinhicking)
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.419.2.61
retrieving revision 1.419.2.62
diff -u -d -r1.419.2.61 -r1.419.2.62
--- serendipity_functions.inc.php 4 Nov 2004 09:31:50 -0000 1.419.2.61
+++ serendipity_functions.inc.php 4 Nov 2004 11:56:43 -0000 1.419.2.62
@@ -2144,7 +2144,7 @@
$res = serendipity_db_insert('entries', $entry);
if ($res) {
- $entry['id'] = serendipity_db_insert_id('entries', 'id');
+ $entry['id'] = $serendipity['lastSavedEntry'] = serendipity_db_insert_id('entries', 'id');
if (is_array($categories)) {
foreach ($categories as $cat) {
if (is_numeric($cat))
@@ -2668,6 +2668,7 @@
$hidden .= ' <input type="hidden" name="serendipity[id]" value="' . (isset($entry['id']) ? $entry['id'] : '') . '" />' . $n;
$hidden .= ' <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? $entry['timestamp'] : '') . '" />' . $n;
$hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />';
+ $hidden .= ' <input type="hidden" name="serendipity[quicksave]" value="false" />';
if (!empty($errMsg)) {
?>
@@ -2685,9 +2686,10 @@
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><input type="text" name="serendipity[title]" value="<?php echo isset($entry['title']) ? htmlspecialchars($entry['title']) : ''; ?>" size="72" /></td>
- <td align="right"><select name="serendipity[isdraft]">
- <?php if ($_SESSION['serendipityRightPublish']) { ?><option value="false" <?php echo $draftP; ?>><?php echo PUBLISH; ?></option><?php } ?>
- <option value="true" <?php echo $draftD; ?>><?php echo DRAFT; ?></option>
+ <td align="right">
+ <select name="serendipity[isdraft]">
+ <?php if ($_SESSION['serendipityRightPublish']) { ?><option value="false" <?php echo $draftP; ?>><?php echo PUBLISH; ?></option><?php } ?>
+ <option value="true" <?php echo $draftD; ?>><?php echo DRAFT; ?></option>
</select>
</td>
</tr>
@@ -2862,17 +2864,13 @@
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="left">
- <input id="checkbox_allow_comments" type="checkbox" name="serendipity[allow_comments]" value="true" <?php echo $allow_comments; ?> /><label for="checkbox_allow_comments"><?php echo COMMENTS_ENABLE; ?></label>
+ <input id="checkbox_allow_comments" type="checkbox" name="serendipity[allow_comments]" value="true" <?php echo $allow_comments; ?> /><label for="checkbox_allow_comments"><?php echo COMMENTS_ENABLE; ?></label><br />
+ <input id="checkbox_moderate_comments" type="checkbox" name="serendipity[moderate_comments]" value="true" <?php echo $moderate_comments; ?> /><label for="checkbox_moderate_comments"><?php echo COMMENTS_MODERATE; ?></label>
</td>
<td align="right" rowspan="2" valign="middle">
- <input type="submit" value="- <?php echo PREVIEW; ?> -" style="font-weight: bold;" onclick="document.forms['serendipityEntry'].elements['serendipity[preview]'].value='true';" />
- <input type="submit" value="- <?php echo SAVE; ?> -" style="font-weight: bold;" />
- </td>
-
- </tr>
- <tr>
- <td align="left">
- <input id="checkbox_moderate_comments" type="checkbox" name="serendipity[moderate_comments]" value="true" <?php echo $moderate_comments; ?> /><label for="checkbox_moderate_comments"><?php echo COMMENTS_MODERATE; ?></label>
+ <input accesskey="p" type="submit" value="- <?php echo PREVIEW; ?> -" style="font-weight: bold; margin: 2px; width: 100%; text-align: center" onclick="document.forms['serendipityEntry'].elements['serendipity[preview]'].value='true';" /><br />
+ <input accesskey="q" type="submit" value="- <?php echo QUICKSAVE; ?> -" style="font-size: x-small; margin: 2px; width: 100%; text-align: center" onclick="document.forms['serendipityEntry'].elements['serendipity[quicksave]'].value='true';" /><br />
+ <input accesskey="s" type="submit" value="- <?php echo SAVE; ?> -" style="font-weight: bold; margin: 2px; width: 100%; text-align: center" />
</td>
</tr>
</table>
Index: serendipity_admin_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_images.inc.php,v
retrieving revision 1.30.2.1
retrieving revision 1.30.2.2
diff -u -d -r1.30.2.1 -r1.30.2.2
--- serendipity_admin_images.inc.php 27 Sep 2004 10:24:38 -0000 1.30.2.1
+++ serendipity_admin_images.inc.php 4 Nov 2004 11:56:43 -0000 1.30.2.2
@@ -133,7 +133,7 @@
printf(FILE_FETCHED . '<br />', $serendipity['POST']['imageurl'], $tfile);
// Create thumbnail
- serendipity_makeThumbnail($tfile, false, $authorid, $serendipity['POST']['target_directory']);
+ $created_thumbnail = serendipity_makeThumbnail($tfile, false, $authorid, $serendipity['POST']['target_directory']);
echo THUMB_CREATED_DONE . '<br />';
}
}
@@ -158,7 +158,7 @@
@chmod($target, 0664);
// Create thumbnail
- serendipity_makeThumbnail($tfile, false, $authorid, $serendipity['POST']['target_directory']);
+ $created_thumbnail = serendipity_makeThumbnail($tfile, false, $authorid, $serendipity['POST']['target_directory']);
echo THUMB_CREATED_DONE . '<br />';
} else {
echo ERROR_UNKNOWN_NOUPLOAD . '<br />';
@@ -296,7 +296,14 @@
<input type="hidden" name="serendipity[action]" value="admin" />
<input type="hidden" name="serendipity[adminModule]" value="images" />
<input type="hidden" name="serendipity[adminAction]" value="add" />
-
+<?php
+ if (isset($image_selector_addvars) && is_array($image_selector_addvars)) {
+ // These variables may come frmo serendipity_admin_image_selector.php to show embedded upload form
+ foreach($image_selector_addvars AS $imgsel_key => $imgsel_val) {
+ echo ' <input type="hidden" name="serendipity[' . htmlspecialchars($imgsel_key) . ']" value="' . htmlspecialchars($imgsel_val) . '" />' . "\n";
+ }
+ }
+?>
<table>
<tr>
<td nowrap="nowrap"><?php echo ENTER_MEDIA_URL; ?></td>
Index: serendipity_admin_image_selector.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_image_selector.php,v
retrieving revision 1.32
retrieving revision 1.32.2.1
diff -u -d -r1.32 -r1.32.2.1
--- serendipity_admin_image_selector.php 30 Aug 2004 18:56:19 -0000 1.32
+++ serendipity_admin_image_selector.php 4 Nov 2004 11:56:43 -0000 1.32.2.1
@@ -22,6 +22,14 @@
die(HAVE_TO_BE_LOGGED_ON);
}
+if (!isset($serendipity['GET']['adminModule'])) {
+ $serendipity['GET']['adminModule'] = (isset($serendipity['POST']['adminModule']) ? $serendipity['POST']['adminModule'] : '');
+}
+
+if (!isset($serendipity['GET']['step'])) {
+ $serendipity['GET']['step'] = (isset($serendipity['POST']['step']) ? $serendipity['POST']['step'] : '');
+}
+
?>
<html>
<head>
@@ -31,10 +39,46 @@
</head>
<body class="s9y_wrap" id="serendipity_admin_image_page">
+<div style="margin: 5px">
<?php
switch ($serendipity['GET']['step']) {
case '1':
- $file = serendipity_fetchImageFromDatabase($serendipity['GET']['image']);
+ if (isset($serendipity['GET']['adminAction'])) { // Embedded upload form
+ switch ($serendipity['GET']['adminAction']) {
+ case 'addSelect':
+ $image_selector_addvars = array(
+ 'step' => 1,
+ 'textarea' => (!empty($serendipity['GET']['textarea']) ? $serendipity['GET']['textarea'] : ''),
+ 'htmltarget' => (!empty($serendipity['GET']['htmltarget']) ? $serendipity['GET']['htmltarget'] : ''),
+ 'filename_only' => (!empty($serendipity['GET']['filename_only']) ? $serendipity['GET']['filename_only'] : '')
+ );
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_images.inc.php';
+ break 2;
+
+ case 'add':
+ include S9Y_INCLUDE_PATH . 'serendipity_admin_images.inc.php';
+ if (isset($created_thumbnail) && is_array($created_thumbnail) && isset($created_thumbnail['image_id'])) {
+ $serendipity['GET']['image'] = (int)$created_thumbnail['image_id'];
+
+ if (!empty($serendipity['POST']['htmltarget'])) {
+ $serendipity['GET']['htmltarget'] = $serendipity['POST']['htmltarget'];
+ }
+
+ if (!empty($serendipity['POST']['filename_only'])) {
+ $serendipity['GET']['filename_only'] = $serendipity['POST']['filename_only'];
+ }
+
+ if (!empty($serendipity['POST']['textarea'])) {
+ $serendipity['GET']['textarea'] = $serendipity['POST']['textarea'];
+ }
+ break;
+ } else {
+ break 2;
+ }
+ }
+ }
+
+ $file = serendipity_fetchImageFromDatabase($serendipity['GET']['image']);
$imgsrc = $serendipity['serendipityHTTPPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
$imgName = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] .'.'. $file['extension'];
$thumbbasename = $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension'];
@@ -46,7 +90,9 @@
<script type="text/javascript" language="Javascript" src="<?php echo $serendipity['serendipityHTTPPath']; ?>serendipity_editor.js"></script>
<div>
-<?php if ($is_image) {?>
+<?php
+ if ($is_image) {
+?>
<img align="right" src="<?php echo $imgsrc; ?>">
<h1><?php printf(YOU_CHOSE, $file['name']); ?></h1>
<p>
@@ -135,10 +181,8 @@
$add_url .= '&serendipity[filename_only]=' . $serendipity['GET']['filename_only'];
}
?>
- <b><?php echo SELECT_FILE; ?></b>
- <br />
-
- <?php echo CLICK_FILE_TO_INSERT; ?>
+ <h1><?php echo SELECT_FILE; ?></h1>
+ <h2><?php echo CLICK_FILE_TO_INSERT; ?></h2>
<br />
<?php
@@ -146,11 +190,13 @@
isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1,
4,
false,
- '?serendipity[step]=1' . $add_url . '&serendipity[textarea]='. $serendipity['GET']['textarea']
+ '?serendipity[step]=1' . $add_url . '&serendipity[textarea]='. $serendipity['GET']['textarea'],
+ true
);
}
?>
+</div>
</body>
</html>
|