Update of /cvsroot/php-blog/serendipity/include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30356/include
Modified Files:
functions_entries.inc.php
Log Message:
Since I'm gone for the weekend, here's something for you to play with.
Tom basically agreed to it, and I get it working well on my setup.
However this is EXPERIMENTAL. You have been warned.
If it breaks seriously, I won't be offended if anyone reverts the commit - but I don't think it's unstable, though. :-)
Index: functions_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_entries.inc.php,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- functions_entries.inc.php 26 Nov 2004 14:10:01 -0000 1.9
+++ functions_entries.inc.php 26 Nov 2004 14:40:13 -0000 1.10
@@ -1145,7 +1145,7 @@
foreach($hiddens as $key => $value) {
$hidden .= ' <input type="hidden" name="' . $key . '" value="' . $value . '" />' . $n;
}
- $hidden .= ' <input type="hidden" name="serendipity[id]" value="' . (isset($entry['id']) ? $entry['id'] : '') . '" />' . $n;
+ $hidden .= ' <input type="hidden" id="entryid" name="serendipity[id]" value="' . (isset($entry['id']) ? $entry['id'] : '') . '" />' . $n;
$hidden .= ' <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : '') . '" />' . $n;
$hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />';
$hidden .= ' <input type="hidden" name="serendipity[quicksave]" value="false" />';
@@ -1582,3 +1582,111 @@
serendipity_smarty_fetch('ARCHIVES', 'entries_archives.tpl', true);
}
+
+function serendipity_is_iframe() {
+ global $serendipity;
+
+ if ($serendipity['GET']['is_iframe'] && is_array($_SESSION['save_entry'])) {
+ // An iframe may NOT contain <html> and </html> tags, that's why we emit different headers here than on serendipity_admin.php
+?>
+ <head>
+ <title><?php echo SERENDIPITY_ADMIN_SUITE; ?></title>
+ <meta http-equiv="Content-Type" content="text/html; charset=<?php echo LANG_CHARSET; ?>" />
+ <link rel="stylesheet" type="text/css" href="<?php echo (isset($serendipity['serendipityHTTPPath']) ? $serendipity['serendipityHTTPPath'] : ''); ?>serendipity.css.php" />
+<?php
+ if (!empty($serendipity['extCSS']) && strtolower($serendipity['extCSS']) != 'none') {
+?>
+ <link rel="stylesheet" type="text/css" href="<?php echo $serendipity['extCSS']; ?>" />
+<?php
+ }
+?>
+ </head>
+
+ <body style="padding: 0px; margin: 0px;">
+ <div id="mainpane" style="padding: 0px; margin: 0px;">
+ <div id="content" style="height: 100%; padding: 0px; margin: 0px">
+<?php
+ // We need to restore GET/POST variables to that depending plugins inside the iframe
+ // can still fetch all that variables; and we also tighten security by not allowing
+ // to pass any different GET/POST variables to our iframe.
+ $iframe_mode = $serendipity['GET']['iframe_mode'];
+ $serendipity['POST'] = &$_SESSION['save_entry_POST'];
+ $serendipity['GET'] = &$_SESSION['save_entry_POST']; // GET-Vars are the same as POST to ensure compatibility.
+ ignore_user_abort(true);
+ serendipity_iframe($_SESSION['save_entry'], $iframe_mode);
+?>
+ </div>
+ </div>
+ </body>
+<?php
+ return true;
+ }
+ return false;
+}
+
+function serendipity_iframe(&$entry, $mode = null) {
+ global $serendipity;
+
+ if (empty($mode) || !is_array($entry)) {
+ return false;
+ }
+
+ switch ($mode) {
+ case 'save':
+ $res = serendipity_updertEntry($entry);
+ if (is_string($res)) {
+ echo '<div class="serendipity_msg_error">' . ERROR . ': <b>' . $res . '</b></div>';
+ } else {
+ if (!empty($serendipity['lastSavedEntry'])) {
+ // Last saved entry must be propagated to entry form so that if the user re-edits it,
+ // it needs to be stored with the new ID.
+ echo '<script type="text/javascript">parent.document.forms[\'serendipityEntry\'][\'serendipity[id]\'].value = "' . $serendipity['lastSavedEntry'] . '";</script>';
+ }
+ echo '<div class="serendipity_msg_notice">' . ENTRY_SAVED . '</div>';
+ }
+
+ return true;
+ break;
+
+ case 'preview':
+ $serendipity['smarty_raw_mode'] = true; // Force output of Smarty stuff in the backend
+ serendipity_smarty_init();
+ $serendipity['smarty']->assign('is_preview', true);
+
+ echo '<strong>' . PREVIEW . '</strong>';
+ echo '<div style="border:1px solid #000000; padding: 15px;">';
+ serendipity_printEntries(array($entry), ($entry['extended'] != '' ? 1 : 0), true);
+ echo '</div>';
+
+ return true;
+ break;
+ }
+
+ return false;
+}
+
+function serendipity_iframe_create($mode, &$entry) {
+ global $serendipity;
+
+ $_SESSION['save_entry'] = $entry;
+ $_SESSION['save_entry_POST'] = $serendipity['POST'];
+
+ // TODO: Use a language constant for those strings
+
+ $attr = '';
+ switch($mode) {
+ case 'save':
+ $attr = ' height="100" ';
+ echo '<div class="serendipity_msg_notice">' . IFRAME_PREVIEW . '</div><br />';
+ break;
+
+ case 'preview':
+ $attr = ' height="300" ';
+ echo '<div class="serendipity_msg_notice">' . IFRAME_SAVE . '</div><br />';
+ break;
+ }
+
+ echo '<iframe src="serendipity_admin.php?serendipity[is_iframe]=true&serendipity[iframe_mode]=' . $mode . '" name="serendipity_iframe" ' . $attr . ' width="95%" frameborder="1" marginwidth="0" marginheight="0" scrolling="auto" title="Serendipity">'
+ . IFRAME_WARNING
+ . '</iframe><br /><br />';
+}
|