Version 0.9 ()
------------------------------------------------------------------------
+ * Reduce memory usage by splitting up function files, optimizing
+ spartacus parsing. New files:
+ include/functions_rss.inc.php
+ include/functions_entries_admin.inc.php
+ (garvinhicking)
+
* Inserting links via the Serendipity Toolbar over the entry area
now also asks for a link tooltipe/title.
$entry['id'] = $serendipity['lastSavedEntry'];
}
+ include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php';
serendipity_printEntryForm(
'?',
array(
$entry = serendipity_fetchEntry('id', $serendipity['GET']['id'], 1, 1);
default:
+ include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php';
+
serendipity_printEntryForm(
'?',
array(
include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
include_once S9Y_INCLUDE_PATH . 'include/plugin_internal.inc.php';
+include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php';
function serendipity_groupname($group) {
if (defined('PLUGIN_GROUP_' . $group)) {
}
}
+/* Function to get a snapshot uf used memory */
+function memSnap($tshow = '') {
+ static $avail = null;
+ static $show = true;
+ static $memUsage = 0;
+
+ if (!$show) {
+ return false;
+ }
+
+ if ($avail === false) {
+ return true;
+ } elseif ($avail === null) {
+ if (function_exists('memory_get_usage')) {
+ $avail = memory_get_usage();
+ } else {
+ $avail = false;
+ return false;
+ }
+ }
+
+ if ($memUsage === 0) {
+ $memUsage = $avail;
+ }
+
+ $current = memory_get_usage();
+ echo '[' . date('d.m.Y H:i') . '] ' . number_format($current - $memUsage, 2, ',', '.') . ' label "' . $tshow . '", totalling ' . number_format($current, 2, ',', '.') . '<br />' . "\n";
+ $memUsage = $current;
+}
+
if (!function_exists('file_get_contents')) {
function file_get_contents($filename, $use_include_path = 0) {
$file = fopen($filename, 'rb', $use_include_path);
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
-
if (@include_once(S9Y_INCLUDE_PATH . "include/db/{$serendipity['dbType']}.inc.php")) {
@define('S9Y_DB_INCLUDED', TRUE);
}
include_once(S9Y_INCLUDE_PATH . "include/db/db.inc.php");
include_once(S9Y_INCLUDE_PATH . "include/compat.inc.php");
include_once(S9Y_INCLUDE_PATH . "include/functions_config.inc.php");
-include_once(S9Y_PEAR_PATH . "XML/RPC.php");
include_once(S9Y_INCLUDE_PATH . "include/plugin_api.inc.php");
include_once(S9Y_INCLUDE_PATH . "include/functions_images.inc.php");
include_once(S9Y_INCLUDE_PATH . "include/functions_installer.inc.php");
include_once(S9Y_INCLUDE_PATH . "include/functions_entries.inc.php");
include_once(S9Y_INCLUDE_PATH . "include/functions_comments.inc.php");
include_once(S9Y_INCLUDE_PATH . "include/functions_permalinks.inc.php");
-include_once(S9Y_INCLUDE_PATH . "include/functions_trackbacks.inc.php");
include_once(S9Y_INCLUDE_PATH . "include/functions_smarty.inc.php");
function serendipity_truncateString($s, $len) {
define("serendipity_FUNCTIONS_LOADED", true);
/* vim: set sts=4 ts=4 expandtab : */
-?>
global $serendipity;
if ($serendipity['GET']['is_iframe'] && is_array($_SESSION['save_entry'])) {
+ include_once S9Y_INCLUDE_PATH . 'include/functions_entries_admin.inc.php';
// An iframe may NOT contain <html> and </html> tags, that's why we emit different headers here than on serendipity_admin.php
?>
<head>
} // end function serendipity_printEntries
-function serendipity_printEntries_rss($entries, $version, $comments = false, $fullFeed = false, $showMail = true) {
- global $serendipity;
-
- if (is_array($entries)) {
- foreach ($entries as $entry) {
- $id = (isset($entry['entryid']) && !empty($entry['entryid']) ? $entry['entryid'] : $entry['id']);
- $guid = serendipity_rss_getguid($entry, $comments);
- $entryLink = serendipity_archiveURL($id, $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp']));
- if ($comments == true) {
- // Display username as part of the title for easier feed-readability
- $entry['title'] = $entry['author'] . ': ' . $entry['title'];
- }
-
- // Embed a link to extended entry, if existing
- if ($fullFeed) {
- $entry['body'] .= ' ' . $entry['extended'];
- } elseif ($entry['exflag']) {
- $ext = '<br /><a href="' . $guid . '#extended">' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . '</a>';
- } else {
- $ext = '';
- }
-
- serendipity_plugin_api::hook_event('frontend_display', $entry);
- // Do some relative -> absolute URI replacing magic. Replaces all HREF/SRC (<a>, <img>, ...) references to only the serendipitypath with the full baseURL URI
- // garvin: Could impose some problems. Closely watch this one.
- $entry['body'] = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\1=\2' . $serendipity['baseURL'] . '\4\2\6>', $entry['body']);
- // jbalcorn: clean up body for XML compliance as best we can.
- $entry['body'] = xhtml_cleanup($entry['body']);
-
- // extract author information
- if ((isset($entry['no_email']) && $entry['no_email']) || !$showMail) {
- $entry['email'] = 'nospam@example.com'; // RSS Feeds need an E-Mail address!
- } elseif (empty($entry['email'])) {
- $query = "select email FROM {$serendipity['dbPrefix']}authors WHERE authorid = '". serendipity_db_escape_string($entry['authorid']) ."'";
- $results = serendipity_db_query($query);
- $entry['email'] = $results[0]['email'];
- }
-
- if (!is_array($entry['categories'])) {
- $entry['categories'] = array(0 => array('category_name' => $entry['category_name']));
- }
-
- if ($version == 'atom0.3') {
- /*********** ATOM 0.3 FEED *************/
-?>
-<entry>
- <link href="<?php echo $entryLink; ?>" rel="alternate" title="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" type="text/html" />
- <author>
- <name><?php echo serendipity_utf8_encode(htmlspecialchars($entry['author'])); ?></name>
- <email><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])); ?></email>
- </author>
-
- <issued><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></issued>
- <created><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></created>
- <modified><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['last_modified'])); ?></modified>
- <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
-
-<?php
- if ($comments === false) {
-?>
- <slash:comments><?php echo $entry['comments']; ?></slash:comments>
- <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $version; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>
-<?php
- }
-?>
-
- <id><?php echo $guid; ?></id>
- <title mode="escaped" type="text/html"><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>
- <content type="application/xhtml+xml" xml:base="<?php echo $serendipity['baseURL']; ?>">
- <div xmlns="http://www.w3.org/1999/xhtml">
-<?php
- echo serendipity_utf8_encode($entry['body'].$ext);
-?>
- </div>
- </content>
-<?php
- $entry['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:atom-0.3:per_entry', $entry);
- echo $entry['display_dat'];
-?>
-</entry>
-<?php
- } elseif ($version == 'atom1.0') {
- /*********** ATOM 1.0 FEED *************/
-?>
-<entry>
- <link href="<?php echo $entryLink; ?>" rel="alternate" title="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" />
- <author>
- <name><?php echo serendipity_utf8_encode(htmlspecialchars($entry['author'])); ?></name>
- <email><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])); ?></email>
- </author>
-
- <published><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></published>
- <updated><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['last_modified'])); ?></updated>
- <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
-
-<?php
- if ($comments === false) {
-?>
- <slash:comments><?php echo $entry['comments']; ?></slash:comments>
- <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $version; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>
-<?php
- }
-
- foreach ($entry['categories'] AS $idx => $cat) {
- $name = serendipity_utf8_encode(htmlspecialchars($cat['category_name'])); ?>
- <category scheme="<?php echo serendipity_categoryURL($cat, 'baseURL'); ?>" label="<?php echo $name; ?>" term="<?php echo $name; ?>" />
-<?php
- }
-?>
- <id><?php echo $guid; ?></id>
- <title type="html"><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>
- <content type="xhtml" xml:base="<?php echo $serendipity['baseURL']; ?>">
- <div xmlns="http://www.w3.org/1999/xhtml">
-<?php
- echo serendipity_utf8_encode($entry['body'].$ext);
-?>
- </div>
- </content>
-<?php
- $entry['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:atom-1.0:per_entry', $entry);
- echo $entry['display_dat'];
-?>
-</entry>
-<?php
-
- } elseif ($version == '0.91' || $version == '2.0') {
- /*********** BEGIN RSS 0.91/2.0 FEED *************/
-?>
-<item>
- <title><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>
- <link><?php echo $entryLink; ?></link>
-<?php
- /*********** END RSS 0.91/2.0 FEED *************/
-
- if ($version == '2.0') {
- /*********** RSS 2.0 FEED EXTRAS *************/
- foreach ($entry['categories'] AS $idx => $cat) {
- ?><category><?php echo serendipity_utf8_encode(htmlspecialchars($cat['category_name'])); ?></category><?php
- }
-?>
- <comments><?php echo $entryLink; ?>#comments</comments>
- <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
-<?php
- if ($comments === false) {
-?>
- <slash:comments><?php echo $entry['comments']; ?></slash:comments>
- <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $version; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>
-<?php
- }
-?>
- <author><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></author>
- <content:encoded>
-<?php
- echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));
-?>
- </content:encoded>
- <pubDate><?php echo date('r', serendipity_serverOffsetHour($entry['timestamp'])); ?></pubDate>
- <guid isPermaLink="false"><?php echo $guid; ?></guid>
- <?php
- $entry['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:rss-2.0:per_entry', $entry);
- echo $entry['display_dat'];
- ?>
-</item>
-<?php
- /*********** END 2.0 FEED EXTRAS *************/
- } else {
- /*********** BEGIN RSS 0.91 FEED EXTRAS *************/
-?>
- <description>
- <?php echo serendipity_utf8_encode(htmlspecialchars($entry['body'] . $ext)); ?>
- </description>
-</item>
-<?php
- /*********** END RSS 0.91 FEED EXTRAS *************/
- }
- } else if ($version == '1.0') {
- $categories = array();
- foreach ($entry['categories'] AS $idx => $cat) {
- $categories[] = $cat['category_name'];
- }
-
-?>
-<item rdf:about="<?php echo $guid; ?>">
- <title><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>
- <link><?php echo $entryLink; ?></link>
- <description>
-<?php
- echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));
-?>
- </description>
- <?php
- $entry['display_dat'] = '';
- serendipity_plugin_api::hook_event('frontend_display:rss-1.0:per_entry', $entry);
- echo $entry['display_dat'];
- ?>
- <dc:publisher><?php echo serendipity_utf8_encode(htmlspecialchars($serendipity['blogTitle'])); ?></dc:publisher>
- <dc:creator><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></dc:creator>
- <dc:subject><?php echo serendipity_utf8_encode(htmlspecialchars(implode(', ', $categories))); ?></dc:subject>
- <dc:date><?php echo date('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></dc:date>
- <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>
-<?php
- if ($comments === false) {
-?>
- <slash:comments><?php echo $entry['comments']; ?></slash:comments>
- <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $version; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>
-<?php
- }
-?>
-</item>
-<?php
- } elseif ($version == 'opml1.0') {
-?>
- <outline text="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" type="url" htmlUrl="<?php echo $entryLink; ?>" urlHTTP="<?php echo $entryLink; ?>" />
-<?php
- }
- }
- }
-}
-
-
/**
/**
* purge a statically pregenerated entry
return $ret;
}
-/**
-* Prints a form to enter new diary entries
-**/
-function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = array(), $errMsg = "") {
- global $serendipity;
-
- $serendipity['EditorBrowsers'] = '(IE|Mozilla)';
-
- $draftD = '';
- $draftP = '';
- $categoryselector_expanded = false;
-
- serendipity_plugin_api::hook_event('backend_entryform', $entry);
-
- if ( (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft'])) ||
- (!isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') ) {
- $draftD = ' selected="selected"';
- } else {
- $draftP = ' selected="selected"';
- }
-
- if (isset($entry['moderate_comments']) && (serendipity_db_bool($entry['moderate_comments']))) {
- $moderate_comments = ' checked="checked"';
- } elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) {
- // This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration.
- $moderate_comments = ' checked="checked"';
- } else {
- $moderate_comments = '';
- }
-
-
- if (isset($entry['allow_comments']) && (serendipity_db_bool($entry['allow_comments']))) {
- $allow_comments = ' checked="checked"';
- } elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) {
- // This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration.
- $allow_comments = ' checked="checked"';
- } else {
- $allow_comments = '';
- }
-
- // Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost.
- if (is_array($entry['categories']) && !is_array($entry['categories'][0])) {
- $categories = (array)$entry['categories'];
- $entry['categories'] = array();
- foreach ($categories as $catid) {
- $entry['categories'][] = serendipity_fetchCategoryInfo($catid);
- }
- }
-
- $n = "\n";
- $cat_list = '<select id="categoryselector" name="serendipity[categories][]" style="vertical-align: middle;" multiple="multiple">' . $n;
- $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n;
- $selected = array();
- if (is_array($entry['categories'])) {
- if (count($entry['categories']) > 1) {
- $categoryselector_expanded = true;
- }
-
- foreach ($entry['categories'] as $cat) {
- $selected[] = $cat['categoryid'];
- }
- }
-
- if (count($selected) > 1 ||
- (isset($serendipity['POST']['categories']) && is_array($serendipity['POST']['categories']) && sizeof($serendipity['POST']['categories']) > 1)) {
- $categoryselector_expanded = true;
- }
-
- if (is_array($cats = serendipity_fetchCategories())) {
- $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
- foreach ( $cats as $cat ) {
- $cat_list .= '<option value="'. $cat['categoryid'] .'"'. (in_array($cat['categoryid'], $selected) ? ' selected="selected"' : '') .'>'. str_repeat(' ', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
- }
- }
- $cat_list .= '</select>' . $n;
-
- if (!empty($serendipity['GET']['title'])) {
- $entry['title'] = utf8_decode(urldecode($serendipity['GET']['title']));
- }
-
- if (!empty($serendipity['GET']['body'])) {
- $entry['body'] = utf8_decode(urldecode($serendipity['GET']['body']));
- }
-
- if (!empty($serendipity['GET']['url'])) {
- $entry['body'] .= "\n" . '<br /><a href="' . htmlspecialchars(utf8_decode(urldecode($serendipity['GET']['url']))) . '">' . $entry['title'] . '</a>';
- }
-
- $hidden = '';
- foreach($hiddens as $key => $value) {
- $hidden .= ' <input type="hidden" name="' . $key . '" value="' . $value . '" />' . $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']) : serendipity_serverOffsetHour(time())) . '" />' . $n;
- $hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />';
-
- if (!empty($errMsg)) {
-?>
- <div class="serendipityAdminMsgError"><?php echo $errMsg; ?></div>
-<?php } ?>
- <form action="<?php echo $targetURL; ?>" method="post" <?php echo ($serendipity['XHTML11'] ? 'id' : 'name'); ?>="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px">
- <?php echo $hidden; ?>
-
- <table class="serendipityEntryEdit" border="0" width="100%">
- <tr>
- <td>
- <b><?php echo TITLE; ?>:</b>
- </td>
- <td colspan="2">
- <table width="100%" cellspacing="0" cellpadding="0" border="0">
- <tr>
- <td><input type="text" id="entryTitle" name="serendipity[title]" value="<?php echo isset($entry['title']) ? htmlspecialchars($entry['title']) : ''; ?>" size="60" /></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>
- </select>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
-<?php
- if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) {
-?>
- <td>
- <b><?php echo DATE; ?>:</b>
- </td>
- <td>
- <input type="hidden" name="serendipity[chk_timestamp]" value="<?php echo serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); ?>" />
- <input type="text" name="serendipity[new_timestamp]" id="serendipityNewTimestamp" value="<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time())); ?>" />
- <a href="#" onclick="document.getElementById('serendipityNewTimestamp').value = '<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(time())) ?>'; return false;" title="<?php echo RESET_DATE_DESC ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png') ?>" border="0" style="vertical-align: text-top;" alt="<?php echo RESET_DATE ?>" /></a>
- </td>
- <td align="right">
-<?php
- } else {
-?>
- <td align="right" colspan="3">
-<?php
- }
-?>
- <a style="border:0; text-decoration: none" href="#" onclick="showItem('categoryselector'); return false" title="<?php echo TOGGLE_OPTION; ?>"><img src="<?php echo serendipity_getTemplateFile('img/plus.png') ?>" id="option_categoryselector" style="border: 20px" alt="" border="0" /></a> <b><?php echo CATEGORY; ?>:</b> <?php echo $cat_list ; ?>
- <script type="text/javascript" language="JavaScript">
-
- function toggle_extended(setCookie) {
- var textarea = document.getElementById('serendipity[extended]');
- var button = document.getElementById('option_extended');
- var tools = document.getElementById('tools_extended');
- if ( textarea.style.display == 'none' ) {
- textarea.style.display = '';
- tools.style.display = '';
- button.src = '<?php echo serendipity_getTemplateFile('img/minus.png') ?>';
- if (setCookie == true) {
- document.cookie = 'serendipity[toggle_extended]=true;';
- }
- } else {
- textarea.style.display = 'none';
- tools.style.display = 'none';
- button.src = '<?php echo serendipity_getTemplateFile('img/plus.png') ?>';
- if (setCookie == true) {
- document.cookie = 'serendipity[toggle_extended]=;';
- }
- }
- }
-
- var selector_toggle = new Array();
- var selector_store = new Array();
- var selector_restore = new Array();
-
- function showItem(id) {
- var selected = 0;
- if (typeof(id) == 'undefined' || typeof(id) == 'object') {
- id = 'categoryselector';
- }
-
- if (document.getElementById) {
- el = document.getElementById(id);
- if (selector_toggle[id] && selector_toggle[id] == 'off') {
- selector_restore[id] = new Array();
- selector_toggle[id] = 'on';
-
- /* Hack to make sure that when the single dropdown is shown, don't have multiple selections */
- last = 0;
-
- for (i=0; i < el.options.length; i++) {
- if (el.options[i].selected == true) {
- selected++;
- last = i;
- selector_restore[id][last] = 'on';
- }
-
- if (selected > 1) {
- /* If there is more than one selected, we reset all those to false
- This is because otherwise the label will say 'No Category', but the categories will still be selected */
- for (j=0; j < el.options.length; j++) {
- /* Save selection in array to later restore them */
- if (el.options[j].selected == true) {
- el.options[j].selected = false;
- selector_restore[id][j] = 'on';
- last = j;
- } else {
- selector_restore[id][j] = false;
- }
- }
- break;
- }
- }
-
- el.selectedIndex = null;
- if (last > 0) {
- el.selectedIndex = last;
- }
-
- el.size = 1;
-
- /* Show a normal dropdown */
- if (el.multiple) {
- el.multiple = false;
- }
-
- document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/plus.png') ?>';
- } else {
- selector_store[id] = el.size;
- if (selector_store[id] == 0) {
- selector_store[id] = 5;
- }
-
- last = 0;
- if (el.selectedIndex > 0) {
- if (!selector_restore[id]) {
- selector_restore[id] = new Array();
- }
-
- for (j=0; j < el.options.length; j++) {
- /* Save selection in array to later restore them */
- if (el.options[j].selected == true) {
- selector_restore[id][j] = 'on';
- last = j;
- }
- }
- }
- el.selectedIndex = -1;
- el.size = <?php echo count($cats)+1; ?>;
- selector_toggle[id] = 'off';
-
- /* Show multiple items */
- el.multiple = true;
-
- /* Restore previously selected items? */
- last = 0;
- for (i = 0; i < el.options.length; i++) {
- if (selector_restore && selector_restore[id] && selector_restore[id][i] && selector_restore[id][i] == 'on') {
- val = el.options[i].value;
- if (el.options[i].selected != true) {
- el.options[i].selected = true;
- last = i;
- // [TODO] IE Bug: Don't ask me why, but this restoring only works in Internet Explorer if you put this:
- // alert('it doesnt matter what, just the alert is important');
- }
- }
- }
-
- document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/minus.png') ?>';
- }
- }
- }
-
- function checkSave() {
-<?php
- $void = null;
- serendipity_plugin_api::hook_event('backend_entry_checkSave', $void);
-?>
- return true;
- }
-
- selector_toggle['categoryselector'] = '<?php echo ($categoryselector_expanded ? 'on' : 'off'); ?>';
- addLoadEvent(showItem);
- </script>
- </td>
- </tr>
- <tr>
-<?php
- if (!$serendipity['wysiwyg']) {
-?>
- <td colspan="2"><b><?php echo ENTRY_BODY; ?></b></td>
- <td align="right">
-<?php
- /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */
- if (!$serendipity['wysiwyg'] && eregi($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) {
-?>
- <script type="text/javascript" language="JavaScript">
- document.write('<input type="button" class="serendipityPrettyButton" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<i>\',\'</i>\')" />');
- document.write('<input type="button" class="serendipityPrettyButton" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<b>\',\'</b>\')" />');
- document.write('<input type="button" class="serendipityPrettyButton" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<u>\',\'</u>\')" />');
- document.write('<input type="button" class="serendipityPrettyButton" name="insQ" value="<?php echo QUOTE ?>" accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<blockquote>\',\'</blockquote>\')" />');
- document.write('<input type="button" class="serendipityPrettyButton" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />');
- document.write('<input type="button" class="serendipityPrettyButton" name="insImage" value="<?php echo MEDIA; ?>" style="" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" />');
- document.write('<input type="button" class="serendipityPrettyButton" name="insU" value="URL" accesskey="l" style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />');
- </script>
-<?php
- /* Do the "old" non-WYSIWYG editor */
- } elseif (!$serendipity['wysiwyg']) { ?>
- <script type="text/javascript" language="JavaScript">
- document.write('<input type="button" class="serendipityPrettyButton" value=" B " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'b\')">');
- document.write('<input type="button" class="serendipityPrettyButton" value=" U " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'u\')">');
- document.write('<input type="button" class="serendipityPrettyButton" value=" I " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'i\')">');
- document.write('<input type="button" class="serendipityPrettyButton" value="<img>" onclick="serendipity_insImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">');
- document.write('<input type="button" class="serendipityPrettyButton" value="<?php echo MEDIA; ?>" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no\');">');
- document.write('<input type="button" class="serendipityPrettyButton" value="Link" onclick="serendipity_insLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">');
- </script>
-<?php }
-
- serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry);
- } else {
-?>
- <td colspan="2"><b><?php echo ENTRY_BODY; ?></b></td>
- <td><?php serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); ?>
-
-<?php } ?>
- </td>
- </tr>
-
- <tr>
- <td colspan="3">
- <textarea style="width: 100%" name="serendipity[body]" id="serendipity[body]" cols="80" rows="20"><?php echo isset($entry['body']) ? htmlspecialchars($entry['body']) : ''; ?></textarea>
- </td>
- </tr>
-
- <tr>
- <td colspan="3">
- <table width="100%" cellpadding="0" cellspacing="0">
- <tr>
- <td align="left" width="70%">
- <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" width="30%">
- <input accesskey="p" type="submit" value="- <?php echo PREVIEW; ?> -" class="serendipityPrettyButton" style="width: 150px" onclick="document.forms['serendipityEntry'].elements['serendipity[preview]'].value='true';" /><br />
- <input accesskey="s" type="submit" onclick="return checkSave();" value="- <?php echo SAVE; ?> -" class="serendipityPrettyButton" style="width: 150px" />
- </td>
- </tr>
- </table>
- <br />
- </td>
- </tr>
-
- <tr>
- <td colspan="2">
-<?php if (!$serendipity['wysiwyg']) { ?>
- <a style="border:0; text-decoration: none" href="#" onclick="toggle_extended(true); return false;" title="<?php echo TOGGLE_OPTION; ?>"><img src="<?php echo serendipity_getTemplateFile('img/plus.png') ?>" id="option_extended" alt="+/-" border="0" /></a>
-<?php } ?> <b><?php echo EXTENDED_BODY; ?></b></td>
- <td align="right">
- <?php
-if (!$serendipity['wysiwyg']) {
-?>
- <div id="tools_extended" style="display: none">
-<?php
- /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */
- if (eregi($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) {
-?>
- <input type="button" class="serendipityPrettyButton" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<i>','</i>')" />
- <input type="button" class="serendipityPrettyButton" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<b>','</b>')" />
- <input type="button" class="serendipityPrettyButton" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<u>','</u>')" />
- <input type="button" class="serendipityPrettyButton" name="insQ" value="<?php echo QUOTE ?>" accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<blockquote>','</blockquote>')" />
- <input type="button" class="serendipityPrettyButton" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[extended]'])" />
- <input type="button" class="serendipityPrettyButton" name="insImage" value="<?php echo MEDIA; ?>" onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" />
- <input type="button" class="serendipityPrettyButton" name="insU" value="URL" accesskey="l" style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[extended]'])" />
-<?php
- /* Do the "old" non-WYSIWYG editor */
- } else { ?>
- <input type="button" class="serendipityPrettyButton" value=" B " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'b')">
- <input type="button" class="serendipityPrettyButton" value=" U " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'u')">
- <input type="button" class="serendipityPrettyButton" value=" I " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'i')">
- <input type="button" class="serendipityPrettyButton" value="<img>" onclick="serendipity_insImage(document.forms['serendipityEntry']['serendipity[extended]'])">
- <input type="button" class="serendipityPrettyButton" value="<?php echo MEDIA; ?>" onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no');">
- <input type="button" class="serendipityPrettyButton" value="Link" onclick="serendipity_insLink(document.forms['serendipityEntry']['serendipity[extended]'])">
-<?php
- }
-
- serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry);
-?>
- </div>
-<?php } else {
- serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry);
-} ?>
- </td>
- </tr>
-
- <tr>
- <td colspan="3">
- <textarea style="width: 100%;" name="serendipity[extended]" id="serendipity[extended]" cols="80" rows="20"><?php echo isset($entry['extended']) ? htmlspecialchars($entry['extended']) : ''; ?></textarea>
-<?php if (!$serendipity['wysiwyg']) { ?>
- <script type="text/javascript" language="JavaScript">
- toggle_extended();
- </script>
-<?php } ?>
- </td>
- </tr>
-
- <tr>
- <td colspan="3">
- <br />
- <fieldset>
- <legend><b><?php echo ADVANCED_OPTIONS; ?></b></legend>
-<?php
- serendipity_plugin_api::hook_event('backend_display', $entry);
-?>
- </fieldset>
- </td>
- </tr>
- </table>
- </form>
-<?php
- if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) {
-?>
- <script type="text/javascript" language="JavaScript">
- toggle_extended();
- </script>
-<?php } ?>
-<?php
- if ($serendipity['wysiwyg']) {
- $fields = array(
- 'body' => 'serendipity[body]',
- 'extended' => 'serendipity[extended]'
- );
-
- foreach($fields AS $f_jsname => $f_item) {
- serendipity_emit_htmlarea_code($f_item, $f_jsname);
- }
- serendipity_plugin_api::hook_event('backend_wysiwyg_finish', $fields);
- }
-
- echo ' <script type="text/javascript" language="JavaScript" src="serendipity_define.js.php"></script>';
- echo ' <script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>';
-}
-
-function serendipity_emit_htmlarea_code($item, $jsname, $spawnMulti = false) {
- static $init = false;
- global $serendipity;
-
- if ($init && $spawnMulti) {
- return true;
- }
-
- if (isset($serendipity['wysiwyg']) && $serendipity['wysiwyg']) {
-
- $eventData = array(
- 'init' => &$init,
- 'item' => &$item,
- 'jsname' => &$jsname,
- 'skip' => false
- );
- serendipity_plugin_api::hook_event('backend_wysiwyg', $eventData);
-
- if ($eventData['skip']) {
- return true;
- }
-
- if (!$init) {
-?>
- <script type="text/javascript">
- _editor_url = "<?php echo $serendipity['serendipityHTTPPath'] . 'htmlarea/'; ?>";
- _editor_lang = "<?php echo WYSIWYG_LANG; ?>";
- var editorref = '';
- </script>
- <script type="text/javascript" src="htmlarea/htmlarea.js"></script>
- <script type="text/javascript" src="htmlarea/lang/<?php echo WYSIWYG_LANG; ?>.js"></script>
- <script type="text/javascript" src="htmlarea/dialog.js"></script>
- <style type="text/css">@import url(htmlarea/htmlarea.css);</style>
-<?php
- }
-
- $csscode = str_replace(
- array(
- "\n",
- "'",
- "\r"
- ),
-
- array(
- '\n',
- "\'",
- ""
- ),
-
- file_get_contents(serendipity_getTemplateFile('htmlarea.css', 'serendipityPath'))
- );
-?>
- <script type="text/javascript">
- // IF you want to enable HTMLArea's spellchecker, download the SpellChecker plugin from the HTMLArea homepage
- // (http://www.sourceforge.net/projects/itools-htmlarea) and uncomment the lines suffixed with ' // [SPELLCHECK]'
- // Note that the SpellChecker is a CGI-based application which needs setup in your Apache host ("Options +CGIExec")
- // Thanks to Randall for pointing this out!
-
- // HTMLArea.loadPlugin("SpellChecker"); // [SPELLCHECK]
- var editor<?php echo $jsname; ?> = null; var config<?php echo $jsname; ?> = null;
- function Spawn<?php echo $jsname; ?>(<?php echo $spawnMulti ? 'id' : ''; ?>) {
- var editor<?php echo $jsname; ?> = new HTMLArea("<?php echo $item; ?>"<?php echo $spawnMulti ? ' + id' : ''; ?>);
- var config<?php echo $jsname; ?> = editor<?php echo $jsname; ?>.config;
- config<?php echo $jsname; ?>.registerButton('image_selector', '<?PHP echo MANAGE_IMAGES; ?>', 'htmlarea/images/ed_s9yimage.gif', false,
- function(editor, id) {
- window.open('serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo $jsname; ?>', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');
- editorref = editor<?php echo $jsname; ?>;
- }
- );
- config<?php echo $jsname; ?>.toolbar.push([ "image_selector"]);
- config<?php echo $jsname; ?>.cssFile = '<?php echo $csscode; ?>';
- config<?php echo $jsname; ?>.toolbar = [
- [ "fontname", "space",
- "fontsize", "space",
- "formatblock", "space",
- "bold", "italic", "underline", "strikethrough", "separator",
- "subscript", "superscript", "separator",
- "copy", "cut", "paste", "space", "undo", "redo" ],
-
- [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",
- "lefttoright", "righttoleft", "separator",
- "orderedlist", "unorderedlist", "outdent", "indent", "separator",
- "forecolor", "hilitecolor", "separator",
- "inserthorizontalrule", "createlink", "insertimage", "image_selector", "inserttable", "htmlmode", "separator",
- "popupeditor", "separator", "showhelp", "about" ]
- ];
- // editor<?php echo $jsname; ?>.registerPlugin(SpellChecker); // [SPELLCHECK]
- editor<?php echo $jsname; ?>.generate();
- editor<?php echo $jsname; ?>._textArea.className = 'serendipity_entry';
- }
- </script>
-<?php
- }
-
- $init = true;
-}
-
function serendipity_updateEntryCategories($postid, $categories) {
global $serendipity;
--- /dev/null
+<?php # $Id: functions_entries.inc.php 435 2005-08-25 12:36:39Z garvinhicking $\r
+# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)\r
+# All rights reserved. See LICENSE file for licensing details\r
+\r
+include_once(S9Y_INCLUDE_PATH . "include/functions_trackbacks.inc.php");\r
+\r
+/**\r
+* Prints a form to enter new diary entries\r
+**/\r
+function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = array(), $errMsg = "") {\r
+ global $serendipity;\r
+\r
+ $serendipity['EditorBrowsers'] = '(IE|Mozilla)';\r
+\r
+ $draftD = '';\r
+ $draftP = '';\r
+ $categoryselector_expanded = false;\r
+\r
+ serendipity_plugin_api::hook_event('backend_entryform', $entry);\r
+\r
+ if ( (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft'])) ||\r
+ (!isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') ) {\r
+ $draftD = ' selected="selected"';\r
+ } else {\r
+ $draftP = ' selected="selected"';\r
+ }\r
+\r
+ if (isset($entry['moderate_comments']) && (serendipity_db_bool($entry['moderate_comments']))) {\r
+ $moderate_comments = ' checked="checked"';\r
+ } elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) {\r
+ // This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration.\r
+ $moderate_comments = ' checked="checked"';\r
+ } else {\r
+ $moderate_comments = '';\r
+ }\r
+\r
+\r
+ if (isset($entry['allow_comments']) && (serendipity_db_bool($entry['allow_comments']))) {\r
+ $allow_comments = ' checked="checked"';\r
+ } elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) {\r
+ // This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration.\r
+ $allow_comments = ' checked="checked"';\r
+ } else {\r
+ $allow_comments = '';\r
+ }\r
+\r
+ // Fix category list. If the entryForm is displayed after a POST request, the additional category information is lost.\r
+ if (is_array($entry['categories']) && !is_array($entry['categories'][0])) {\r
+ $categories = (array)$entry['categories'];\r
+ $entry['categories'] = array();\r
+ foreach ($categories as $catid) {\r
+ $entry['categories'][] = serendipity_fetchCategoryInfo($catid);\r
+ }\r
+ }\r
+\r
+ $n = "\n";\r
+ $cat_list = '<select id="categoryselector" name="serendipity[categories][]" style="vertical-align: middle;" multiple="multiple">' . $n;\r
+ $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n;\r
+ $selected = array();\r
+ if (is_array($entry['categories'])) {\r
+ if (count($entry['categories']) > 1) {\r
+ $categoryselector_expanded = true;\r
+ }\r
+\r
+ foreach ($entry['categories'] as $cat) {\r
+ $selected[] = $cat['categoryid'];\r
+ }\r
+ }\r
+\r
+ if (count($selected) > 1 ||\r
+ (isset($serendipity['POST']['categories']) && is_array($serendipity['POST']['categories']) && sizeof($serendipity['POST']['categories']) > 1)) {\r
+ $categoryselector_expanded = true;\r
+ }\r
+\r
+ if (is_array($cats = serendipity_fetchCategories())) {\r
+ $cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);\r
+ foreach ( $cats as $cat ) {\r
+ $cat_list .= '<option value="'. $cat['categoryid'] .'"'. (in_array($cat['categoryid'], $selected) ? ' selected="selected"' : '') .'>'. str_repeat(' ', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";\r
+ }\r
+ }\r
+ $cat_list .= '</select>' . $n;\r
+\r
+ if (!empty($serendipity['GET']['title'])) {\r
+ $entry['title'] = utf8_decode(urldecode($serendipity['GET']['title']));\r
+ }\r
+\r
+ if (!empty($serendipity['GET']['body'])) {\r
+ $entry['body'] = utf8_decode(urldecode($serendipity['GET']['body']));\r
+ }\r
+\r
+ if (!empty($serendipity['GET']['url'])) {\r
+ $entry['body'] .= "\n" . '<br /><a href="' . htmlspecialchars(utf8_decode(urldecode($serendipity['GET']['url']))) . '">' . $entry['title'] . '</a>';\r
+ }\r
+\r
+ $hidden = '';\r
+ foreach($hiddens as $key => $value) {\r
+ $hidden .= ' <input type="hidden" name="' . $key . '" value="' . $value . '" />' . $n;\r
+ }\r
+ $hidden .= ' <input type="hidden" id="entryid" name="serendipity[id]" value="' . (isset($entry['id']) ? $entry['id'] : '') . '" />' . $n;\r
+ $hidden .= ' <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : serendipity_serverOffsetHour(time())) . '" />' . $n;\r
+ $hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />';\r
+\r
+ if (!empty($errMsg)) {\r
+?>\r
+ <div class="serendipityAdminMsgError"><?php echo $errMsg; ?></div>\r
+<?php } ?>\r
+ <form action="<?php echo $targetURL; ?>" method="post" <?php echo ($serendipity['XHTML11'] ? 'id' : 'name'); ?>="serendipityEntry" style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px">\r
+ <?php echo $hidden; ?>\r
+\r
+ <table class="serendipityEntryEdit" border="0" width="100%">\r
+ <tr>\r
+ <td>\r
+ <b><?php echo TITLE; ?>:</b>\r
+ </td>\r
+ <td colspan="2">\r
+ <table width="100%" cellspacing="0" cellpadding="0" border="0">\r
+ <tr>\r
+ <td><input type="text" id="entryTitle" name="serendipity[title]" value="<?php echo isset($entry['title']) ? htmlspecialchars($entry['title']) : ''; ?>" size="60" /></td>\r
+ <td align="right">\r
+ <select name="serendipity[isdraft]">\r
+ <?php if ($_SESSION['serendipityRightPublish']) { ?><option value="false" <?php echo $draftP; ?>><?php echo PUBLISH; ?></option><?php } ?>\r
+ <option value="true" <?php echo $draftD; ?>><?php echo DRAFT; ?></option>\r
+ </select>\r
+ </td>\r
+ </tr>\r
+ </table>\r
+ </td>\r
+ </tr>\r
+ <tr>\r
+<?php\r
+ if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) {\r
+?>\r
+ <td>\r
+ <b><?php echo DATE; ?>:</b>\r
+ </td>\r
+ <td>\r
+ <input type="hidden" name="serendipity[chk_timestamp]" value="<?php echo serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time()); ?>" />\r
+ <input type="text" name="serendipity[new_timestamp]" id="serendipityNewTimestamp" value="<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time())); ?>" />\r
+ <a href="#" onclick="document.getElementById('serendipityNewTimestamp').value = '<?php echo date(DATE_FORMAT_2, serendipity_serverOffsetHour(time())) ?>'; return false;" title="<?php echo RESET_DATE_DESC ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/clock.png') ?>" border="0" style="vertical-align: text-top;" alt="<?php echo RESET_DATE ?>" /></a>\r
+ </td>\r
+ <td align="right">\r
+<?php\r
+ } else {\r
+?>\r
+ <td align="right" colspan="3">\r
+<?php\r
+ }\r
+?>\r
+ <a style="border:0; text-decoration: none" href="#" onclick="showItem('categoryselector'); return false" title="<?php echo TOGGLE_OPTION; ?>"><img src="<?php echo serendipity_getTemplateFile('img/plus.png') ?>" id="option_categoryselector" style="border: 20px" alt="" border="0" /></a> <b><?php echo CATEGORY; ?>:</b> <?php echo $cat_list ; ?>\r
+ <script type="text/javascript" language="JavaScript">\r
+\r
+ function toggle_extended(setCookie) {\r
+ var textarea = document.getElementById('serendipity[extended]');\r
+ var button = document.getElementById('option_extended');\r
+ var tools = document.getElementById('tools_extended');\r
+ if ( textarea.style.display == 'none' ) {\r
+ textarea.style.display = '';\r
+ tools.style.display = '';\r
+ button.src = '<?php echo serendipity_getTemplateFile('img/minus.png') ?>';\r
+ if (setCookie == true) {\r
+ document.cookie = 'serendipity[toggle_extended]=true;';\r
+ }\r
+ } else {\r
+ textarea.style.display = 'none';\r
+ tools.style.display = 'none';\r
+ button.src = '<?php echo serendipity_getTemplateFile('img/plus.png') ?>';\r
+ if (setCookie == true) {\r
+ document.cookie = 'serendipity[toggle_extended]=;';\r
+ }\r
+ }\r
+ }\r
+\r
+ var selector_toggle = new Array();\r
+ var selector_store = new Array();\r
+ var selector_restore = new Array();\r
+\r
+ function showItem(id) {\r
+ var selected = 0;\r
+ if (typeof(id) == 'undefined' || typeof(id) == 'object') {\r
+ id = 'categoryselector';\r
+ }\r
+\r
+ if (document.getElementById) {\r
+ el = document.getElementById(id);\r
+ if (selector_toggle[id] && selector_toggle[id] == 'off') {\r
+ selector_restore[id] = new Array();\r
+ selector_toggle[id] = 'on';\r
+\r
+ /* Hack to make sure that when the single dropdown is shown, don't have multiple selections */\r
+ last = 0;\r
+ \r
+ for (i=0; i < el.options.length; i++) {\r
+ if (el.options[i].selected == true) {\r
+ selected++;\r
+ last = i;\r
+ selector_restore[id][last] = 'on';\r
+ }\r
+\r
+ if (selected > 1) {\r
+ /* If there is more than one selected, we reset all those to false\r
+ This is because otherwise the label will say 'No Category', but the categories will still be selected */\r
+ for (j=0; j < el.options.length; j++) {\r
+ /* Save selection in array to later restore them */\r
+ if (el.options[j].selected == true) {\r
+ el.options[j].selected = false;\r
+ selector_restore[id][j] = 'on';\r
+ last = j;\r
+ } else {\r
+ selector_restore[id][j] = false;\r
+ }\r
+ }\r
+ break;\r
+ }\r
+ }\r
+ \r
+ el.selectedIndex = null;\r
+ if (last > 0) {\r
+ el.selectedIndex = last;\r
+ }\r
+\r
+ el.size = 1;\r
+\r
+ /* Show a normal dropdown */\r
+ if (el.multiple) {\r
+ el.multiple = false;\r
+ }\r
+\r
+ document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/plus.png') ?>';\r
+ } else {\r
+ selector_store[id] = el.size;\r
+ if (selector_store[id] == 0) {\r
+ selector_store[id] = 5;\r
+ }\r
+\r
+ last = 0;\r
+ if (el.selectedIndex > 0) {\r
+ if (!selector_restore[id]) {\r
+ selector_restore[id] = new Array();\r
+ }\r
+\r
+ for (j=0; j < el.options.length; j++) {\r
+ /* Save selection in array to later restore them */\r
+ if (el.options[j].selected == true) {\r
+ selector_restore[id][j] = 'on';\r
+ last = j;\r
+ }\r
+ }\r
+ }\r
+ el.selectedIndex = -1;\r
+ el.size = <?php echo count($cats)+1; ?>;\r
+ selector_toggle[id] = 'off';\r
+\r
+ /* Show multiple items */\r
+ el.multiple = true;\r
+\r
+ /* Restore previously selected items? */\r
+ last = 0;\r
+ for (i = 0; i < el.options.length; i++) {\r
+ if (selector_restore && selector_restore[id] && selector_restore[id][i] && selector_restore[id][i] == 'on') {\r
+ val = el.options[i].value;\r
+ if (el.options[i].selected != true) {\r
+ el.options[i].selected = true;\r
+ last = i;\r
+ // [TODO] IE Bug: Don't ask me why, but this restoring only works in Internet Explorer if you put this:\r
+ // alert('it doesnt matter what, just the alert is important');\r
+ }\r
+ }\r
+ }\r
+\r
+ document.getElementById('option_' + id).src = '<?php echo serendipity_getTemplateFile('img/minus.png') ?>';\r
+ }\r
+ }\r
+ }\r
+\r
+ function checkSave() {\r
+<?php\r
+ $void = null;\r
+ serendipity_plugin_api::hook_event('backend_entry_checkSave', $void);\r
+?>\r
+ return true;\r
+ }\r
+ \r
+ selector_toggle['categoryselector'] = '<?php echo ($categoryselector_expanded ? 'on' : 'off'); ?>';\r
+ addLoadEvent(showItem);\r
+ </script>\r
+ </td>\r
+ </tr>\r
+ <tr>\r
+<?php\r
+ if (!$serendipity['wysiwyg']) {\r
+?>\r
+ <td colspan="2"><b><?php echo ENTRY_BODY; ?></b></td>\r
+ <td align="right">\r
+<?php\r
+ /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */\r
+ if (!$serendipity['wysiwyg'] && eregi($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) {\r
+?>\r
+ <script type="text/javascript" language="JavaScript">\r
+ document.write('<input type="button" class="serendipityPrettyButton" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<i>\',\'</i>\')" />');\r
+ document.write('<input type="button" class="serendipityPrettyButton" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<b>\',\'</b>\')" />');\r
+ document.write('<input type="button" class="serendipityPrettyButton" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<u>\',\'</u>\')" />');\r
+ document.write('<input type="button" class="serendipityPrettyButton" name="insQ" value="<?php echo QUOTE ?>" accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms[\'serendipityEntry\'][\'serendipity[body]\'],\'<blockquote>\',\'</blockquote>\')" />');\r
+ document.write('<input type="button" class="serendipityPrettyButton" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />');\r
+ document.write('<input type="button" class="serendipityPrettyButton" name="insImage" value="<?php echo MEDIA; ?>" style="" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" />');\r
+ document.write('<input type="button" class="serendipityPrettyButton" name="insU" value="URL" accesskey="l" style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])" />');\r
+ </script>\r
+<?php\r
+ /* Do the "old" non-WYSIWYG editor */\r
+ } elseif (!$serendipity['wysiwyg']) { ?>\r
+ <script type="text/javascript" language="JavaScript">\r
+ document.write('<input type="button" class="serendipityPrettyButton" value=" B " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'b\')">');\r
+ document.write('<input type="button" class="serendipityPrettyButton" value=" U " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'u\')">');\r
+ document.write('<input type="button" class="serendipityPrettyButton" value=" I " onclick="serendipity_insBasic(document.forms[\'serendipityEntry\'][\'serendipity[body]\'], \'i\')">');\r
+ document.write('<input type="button" class="serendipityPrettyButton" value="<img>" onclick="serendipity_insImage(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">');\r
+ document.write('<input type="button" class="serendipityPrettyButton" value="<?php echo MEDIA; ?>" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[textarea]=body\', \'ImageSel\', \'width=800,height=600,toolbar=no\');">');\r
+ document.write('<input type="button" class="serendipityPrettyButton" value="Link" onclick="serendipity_insLink(document.forms[\'serendipityEntry\'][\'serendipity[body]\'])">');\r
+ </script>\r
+<?php }\r
+\r
+ serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry);\r
+ } else {\r
+?>\r
+ <td colspan="2"><b><?php echo ENTRY_BODY; ?></b></td>\r
+ <td><?php serendipity_plugin_api::hook_event('backend_entry_toolbar_body', $entry); ?>\r
+\r
+<?php } ?>\r
+ </td>\r
+ </tr>\r
+\r
+ <tr>\r
+ <td colspan="3">\r
+ <textarea style="width: 100%" name="serendipity[body]" id="serendipity[body]" cols="80" rows="20"><?php echo isset($entry['body']) ? htmlspecialchars($entry['body']) : ''; ?></textarea>\r
+ </td>\r
+ </tr>\r
+\r
+ <tr>\r
+ <td colspan="3">\r
+ <table width="100%" cellpadding="0" cellspacing="0">\r
+ <tr>\r
+ <td align="left" width="70%">\r
+ <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 />\r
+ <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>\r
+ </td>\r
+ <td align="right" rowspan="2" valign="middle" width="30%">\r
+ <input accesskey="p" type="submit" value="- <?php echo PREVIEW; ?> -" class="serendipityPrettyButton" style="width: 150px" onclick="document.forms['serendipityEntry'].elements['serendipity[preview]'].value='true';" /><br />\r
+ <input accesskey="s" type="submit" onclick="return checkSave();" value="- <?php echo SAVE; ?> -" class="serendipityPrettyButton" style="width: 150px" />\r
+ </td>\r
+ </tr>\r
+ </table>\r
+ <br />\r
+ </td>\r
+ </tr>\r
+\r
+ <tr>\r
+ <td colspan="2">\r
+<?php if (!$serendipity['wysiwyg']) { ?>\r
+ <a style="border:0; text-decoration: none" href="#" onclick="toggle_extended(true); return false;" title="<?php echo TOGGLE_OPTION; ?>"><img src="<?php echo serendipity_getTemplateFile('img/plus.png') ?>" id="option_extended" alt="+/-" border="0" /></a>\r
+<?php } ?> <b><?php echo EXTENDED_BODY; ?></b></td>\r
+ <td align="right">\r
+ <?php\r
+if (!$serendipity['wysiwyg']) {\r
+?>\r
+ <div id="tools_extended" style="display: none">\r
+<?php\r
+ /* Since the user has WYSIWYG editor disabled, we want to check if we should use the "better" non-WYSIWYG editor */\r
+ if (eregi($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) {\r
+?>\r
+ <input type="button" class="serendipityPrettyButton" name="insI" value="I" accesskey="i" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<i>','</i>')" />\r
+ <input type="button" class="serendipityPrettyButton" name="insB" value="B" accesskey="b" style="font-weight: bold" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<b>','</b>')" />\r
+ <input type="button" class="serendipityPrettyButton" name="insU" value="U" accesskey="u" style="text-decoration: underline;" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<u>','</u>')" />\r
+ <input type="button" class="serendipityPrettyButton" name="insQ" value="<?php echo QUOTE ?>" accesskey="q" style="font-style: italic" onclick="wrapSelection(document.forms['serendipityEntry']['serendipity[extended]'],'<blockquote>','</blockquote>')" />\r
+ <input type="button" class="serendipityPrettyButton" name="insJ" value="img" accesskey="j" onclick="wrapInsImage(document.forms['serendipityEntry']['serendipity[extended]'])" />\r
+ <input type="button" class="serendipityPrettyButton" name="insImage" value="<?php echo MEDIA; ?>" onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');" />\r
+ <input type="button" class="serendipityPrettyButton" name="insU" value="URL" accesskey="l" style="color: blue; text-decoration: underline;" onclick="wrapSelectionWithLink(document.forms['serendipityEntry']['serendipity[extended]'])" />\r
+<?php\r
+ /* Do the "old" non-WYSIWYG editor */\r
+ } else { ?>\r
+ <input type="button" class="serendipityPrettyButton" value=" B " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'b')">\r
+ <input type="button" class="serendipityPrettyButton" value=" U " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'u')">\r
+ <input type="button" class="serendipityPrettyButton" value=" I " onclick="serendipity_insBasic(document.forms['serendipityEntry']['serendipity[extended]'], 'i')">\r
+ <input type="button" class="serendipityPrettyButton" value="<img>" onclick="serendipity_insImage(document.forms['serendipityEntry']['serendipity[extended]'])">\r
+ <input type="button" class="serendipityPrettyButton" value="<?php echo MEDIA; ?>" onclick="window.open('serendipity_admin_image_selector.php?serendipity[textarea]=extended', 'ImageSel', 'width=800,height=600,toolbar=no');">\r
+ <input type="button" class="serendipityPrettyButton" value="Link" onclick="serendipity_insLink(document.forms['serendipityEntry']['serendipity[extended]'])">\r
+<?php\r
+ }\r
+\r
+ serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry);\r
+?>\r
+ </div>\r
+<?php } else {\r
+ serendipity_plugin_api::hook_event('backend_entry_toolbar_extended', $entry);\r
+} ?>\r
+ </td>\r
+ </tr>\r
+\r
+ <tr>\r
+ <td colspan="3">\r
+ <textarea style="width: 100%;" name="serendipity[extended]" id="serendipity[extended]" cols="80" rows="20"><?php echo isset($entry['extended']) ? htmlspecialchars($entry['extended']) : ''; ?></textarea>\r
+<?php if (!$serendipity['wysiwyg']) { ?>\r
+ <script type="text/javascript" language="JavaScript">\r
+ toggle_extended();\r
+ </script>\r
+<?php } ?>\r
+ </td>\r
+ </tr>\r
+\r
+ <tr>\r
+ <td colspan="3">\r
+ <br />\r
+ <fieldset>\r
+ <legend><b><?php echo ADVANCED_OPTIONS; ?></b></legend>\r
+<?php\r
+ serendipity_plugin_api::hook_event('backend_display', $entry);\r
+?>\r
+ </fieldset>\r
+ </td>\r
+ </tr>\r
+ </table>\r
+ </form>\r
+<?php\r
+ if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) {\r
+?>\r
+ <script type="text/javascript" language="JavaScript">\r
+ toggle_extended();\r
+ </script>\r
+<?php } ?>\r
+<?php\r
+ if ($serendipity['wysiwyg']) {\r
+ $fields = array(\r
+ 'body' => 'serendipity[body]', \r
+ 'extended' => 'serendipity[extended]'\r
+ );\r
+ \r
+ foreach($fields AS $f_jsname => $f_item) {\r
+ serendipity_emit_htmlarea_code($f_item, $f_jsname);\r
+ }\r
+ serendipity_plugin_api::hook_event('backend_wysiwyg_finish', $fields);\r
+ }\r
+\r
+ echo ' <script type="text/javascript" language="JavaScript" src="serendipity_define.js.php"></script>';\r
+ echo ' <script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>';\r
+}\r
+\r
+function serendipity_emit_htmlarea_code($item, $jsname, $spawnMulti = false) {\r
+ static $init = false;\r
+ global $serendipity;\r
+\r
+ if ($init && $spawnMulti) {\r
+ return true;\r
+ }\r
+\r
+ if (isset($serendipity['wysiwyg']) && $serendipity['wysiwyg']) {\r
+\r
+ $eventData = array(\r
+ 'init' => &$init,\r
+ 'item' => &$item,\r
+ 'jsname' => &$jsname,\r
+ 'skip' => false\r
+ );\r
+ serendipity_plugin_api::hook_event('backend_wysiwyg', $eventData);\r
+\r
+ if ($eventData['skip']) {\r
+ return true;\r
+ }\r
+\r
+ if (!$init) {\r
+?>\r
+ <script type="text/javascript">\r
+ _editor_url = "<?php echo $serendipity['serendipityHTTPPath'] . 'htmlarea/'; ?>";\r
+ _editor_lang = "<?php echo WYSIWYG_LANG; ?>";\r
+ var editorref = '';\r
+ </script>\r
+ <script type="text/javascript" src="htmlarea/htmlarea.js"></script>\r
+ <script type="text/javascript" src="htmlarea/lang/<?php echo WYSIWYG_LANG; ?>.js"></script>\r
+ <script type="text/javascript" src="htmlarea/dialog.js"></script>\r
+ <style type="text/css">@import url(htmlarea/htmlarea.css);</style>\r
+<?php\r
+ }\r
+\r
+ $csscode = str_replace(\r
+ array(\r
+ "\n",\r
+ "'",\r
+ "\r"\r
+ ),\r
+\r
+ array(\r
+ '\n',\r
+ "\'",\r
+ ""\r
+ ),\r
+\r
+ file_get_contents(serendipity_getTemplateFile('htmlarea.css', 'serendipityPath'))\r
+ );\r
+?>\r
+ <script type="text/javascript">\r
+ // IF you want to enable HTMLArea's spellchecker, download the SpellChecker plugin from the HTMLArea homepage\r
+ // (http://www.sourceforge.net/projects/itools-htmlarea) and uncomment the lines suffixed with ' // [SPELLCHECK]'\r
+ // Note that the SpellChecker is a CGI-based application which needs setup in your Apache host ("Options +CGIExec")\r
+ // Thanks to Randall for pointing this out!\r
+\r
+ // HTMLArea.loadPlugin("SpellChecker"); // [SPELLCHECK]\r
+ var editor<?php echo $jsname; ?> = null; var config<?php echo $jsname; ?> = null;\r
+ function Spawn<?php echo $jsname; ?>(<?php echo $spawnMulti ? 'id' : ''; ?>) {\r
+ var editor<?php echo $jsname; ?> = new HTMLArea("<?php echo $item; ?>"<?php echo $spawnMulti ? ' + id' : ''; ?>);\r
+ var config<?php echo $jsname; ?> = editor<?php echo $jsname; ?>.config;\r
+ config<?php echo $jsname; ?>.registerButton('image_selector', '<?PHP echo MANAGE_IMAGES; ?>', 'htmlarea/images/ed_s9yimage.gif', false,\r
+ function(editor, id) {\r
+ window.open('serendipity_admin_image_selector.php?serendipity[textarea]=<?php echo $jsname; ?>', 'ImageSel', 'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1');\r
+ editorref = editor<?php echo $jsname; ?>;\r
+ }\r
+ );\r
+ config<?php echo $jsname; ?>.toolbar.push([ "image_selector"]);\r
+ config<?php echo $jsname; ?>.cssFile = '<?php echo $csscode; ?>';\r
+ config<?php echo $jsname; ?>.toolbar = [\r
+ [ "fontname", "space",\r
+ "fontsize", "space",\r
+ "formatblock", "space",\r
+ "bold", "italic", "underline", "strikethrough", "separator",\r
+ "subscript", "superscript", "separator",\r
+ "copy", "cut", "paste", "space", "undo", "redo" ],\r
+\r
+ [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",\r
+ "lefttoright", "righttoleft", "separator",\r
+ "orderedlist", "unorderedlist", "outdent", "indent", "separator",\r
+ "forecolor", "hilitecolor", "separator",\r
+ "inserthorizontalrule", "createlink", "insertimage", "image_selector", "inserttable", "htmlmode", "separator",\r
+ "popupeditor", "separator", "showhelp", "about" ]\r
+ ];\r
+ // editor<?php echo $jsname; ?>.registerPlugin(SpellChecker); // [SPELLCHECK]\r
+ editor<?php echo $jsname; ?>.generate();\r
+ editor<?php echo $jsname; ?>._textArea.className = 'serendipity_entry';\r
+ }\r
+ </script>\r
+<?php\r
+ }\r
+\r
+ $init = true;\r
+}\r
--- /dev/null
+<?php # $Id: functions_entries.inc.php 435 2005-08-25 12:36:39Z garvinhicking $\r
+# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)\r
+# All rights reserved. See LICENSE file for licensing details\r
+\r
+function serendipity_printEntries_rss($entries, $version, $comments = false, $fullFeed = false, $showMail = true) {\r
+ global $serendipity;\r
+\r
+ if (is_array($entries)) {\r
+ foreach ($entries as $entry) {\r
+ $id = (isset($entry['entryid']) && !empty($entry['entryid']) ? $entry['entryid'] : $entry['id']);\r
+ $guid = serendipity_rss_getguid($entry, $comments);\r
+ $entryLink = serendipity_archiveURL($id, $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp']));\r
+ if ($comments == true) {\r
+ // Display username as part of the title for easier feed-readability\r
+ $entry['title'] = $entry['author'] . ': ' . $entry['title'];\r
+ }\r
+\r
+ // Embed a link to extended entry, if existing\r
+ if ($fullFeed) {\r
+ $entry['body'] .= ' ' . $entry['extended'];\r
+ } elseif ($entry['exflag']) {\r
+ $ext = '<br /><a href="' . $guid . '#extended">' . sprintf(VIEW_EXTENDED_ENTRY, htmlspecialchars($entry['title'])) . '</a>';\r
+ } else {\r
+ $ext = '';\r
+ }\r
+\r
+ serendipity_plugin_api::hook_event('frontend_display', $entry);\r
+ // Do some relative -> absolute URI replacing magic. Replaces all HREF/SRC (<a>, <img>, ...) references to only the serendipitypath with the full baseURL URI\r
+ // garvin: Could impose some problems. Closely watch this one.\r
+ $entry['body'] = preg_replace('@(href|src)=("|\')(' . preg_quote($serendipity['serendipityHTTPPath']) . ')(.*)("|\')(.*)>@imsU', '\1=\2' . $serendipity['baseURL'] . '\4\2\6>', $entry['body']);\r
+ // jbalcorn: clean up body for XML compliance as best we can.\r
+ $entry['body'] = xhtml_cleanup($entry['body']);\r
+\r
+ // extract author information\r
+ if ((isset($entry['no_email']) && $entry['no_email']) || !$showMail) {\r
+ $entry['email'] = 'nospam@example.com'; // RSS Feeds need an E-Mail address!\r
+ } elseif (empty($entry['email'])) {\r
+ $query = "select email FROM {$serendipity['dbPrefix']}authors WHERE authorid = '". serendipity_db_escape_string($entry['authorid']) ."'";\r
+ $results = serendipity_db_query($query);\r
+ $entry['email'] = $results[0]['email'];\r
+ }\r
+\r
+ if (!is_array($entry['categories'])) {\r
+ $entry['categories'] = array(0 => array('category_name' => $entry['category_name']));\r
+ }\r
+\r
+ if ($version == 'atom0.3') {\r
+ /*********** ATOM 0.3 FEED *************/\r
+?>\r
+<entry>\r
+ <link href="<?php echo $entryLink; ?>" rel="alternate" title="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" type="text/html" />\r
+ <author>\r
+ <name><?php echo serendipity_utf8_encode(htmlspecialchars($entry['author'])); ?></name>\r
+ <email><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])); ?></email>\r
+ </author>\r
+\r
+ <issued><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></issued>\r
+ <created><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></created>\r
+ <modified><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['last_modified'])); ?></modified>\r
+ <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>\r
+\r
+<?php\r
+ if ($comments === false) {\r
+?>\r
+ <slash:comments><?php echo $entry['comments']; ?></slash:comments>\r
+ <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $version; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>\r
+<?php\r
+ }\r
+?>\r
+\r
+ <id><?php echo $guid; ?></id>\r
+ <title mode="escaped" type="text/html"><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>\r
+ <content type="application/xhtml+xml" xml:base="<?php echo $serendipity['baseURL']; ?>">\r
+ <div xmlns="http://www.w3.org/1999/xhtml">\r
+<?php\r
+ echo serendipity_utf8_encode($entry['body'].$ext);\r
+?>\r
+ </div>\r
+ </content>\r
+<?php\r
+ $entry['display_dat'] = '';\r
+ serendipity_plugin_api::hook_event('frontend_display:atom-0.3:per_entry', $entry);\r
+ echo $entry['display_dat'];\r
+?>\r
+</entry>\r
+<?php\r
+ } elseif ($version == 'atom1.0') {\r
+ /*********** ATOM 1.0 FEED *************/\r
+?>\r
+<entry>\r
+ <link href="<?php echo $entryLink; ?>" rel="alternate" title="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" />\r
+ <author>\r
+ <name><?php echo serendipity_utf8_encode(htmlspecialchars($entry['author'])); ?></name>\r
+ <email><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])); ?></email>\r
+ </author>\r
+\r
+ <published><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></published>\r
+ <updated><?php echo gmdate('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['last_modified'])); ?></updated>\r
+ <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>\r
+\r
+<?php\r
+ if ($comments === false) {\r
+?>\r
+ <slash:comments><?php echo $entry['comments']; ?></slash:comments>\r
+ <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $version; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>\r
+<?php\r
+ }\r
+\r
+ foreach ($entry['categories'] AS $idx => $cat) { \r
+ $name = serendipity_utf8_encode(htmlspecialchars($cat['category_name'])); ?>\r
+ <category scheme="<?php echo serendipity_categoryURL($cat, 'baseURL'); ?>" label="<?php echo $name; ?>" term="<?php echo $name; ?>" />\r
+<?php\r
+ }\r
+?>\r
+ <id><?php echo $guid; ?></id>\r
+ <title type="html"><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>\r
+ <content type="xhtml" xml:base="<?php echo $serendipity['baseURL']; ?>">\r
+ <div xmlns="http://www.w3.org/1999/xhtml">\r
+<?php\r
+ echo serendipity_utf8_encode($entry['body'].$ext);\r
+?>\r
+ </div>\r
+ </content>\r
+<?php\r
+ $entry['display_dat'] = '';\r
+ serendipity_plugin_api::hook_event('frontend_display:atom-1.0:per_entry', $entry);\r
+ echo $entry['display_dat'];\r
+?>\r
+</entry>\r
+<?php\r
+\r
+ } elseif ($version == '0.91' || $version == '2.0') {\r
+ /*********** BEGIN RSS 0.91/2.0 FEED *************/\r
+?>\r
+<item>\r
+ <title><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>\r
+ <link><?php echo $entryLink; ?></link>\r
+<?php\r
+ /*********** END RSS 0.91/2.0 FEED *************/\r
+\r
+ if ($version == '2.0') {\r
+ /*********** RSS 2.0 FEED EXTRAS *************/\r
+ foreach ($entry['categories'] AS $idx => $cat) {\r
+ ?><category><?php echo serendipity_utf8_encode(htmlspecialchars($cat['category_name'])); ?></category><?php\r
+ }\r
+?>\r
+ <comments><?php echo $entryLink; ?>#comments</comments>\r
+ <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>\r
+<?php\r
+ if ($comments === false) {\r
+?>\r
+ <slash:comments><?php echo $entry['comments']; ?></slash:comments>\r
+ <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $version; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>\r
+<?php\r
+ }\r
+?>\r
+ <author><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></author>\r
+ <content:encoded>\r
+<?php\r
+ echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));\r
+?>\r
+ </content:encoded>\r
+ <pubDate><?php echo date('r', serendipity_serverOffsetHour($entry['timestamp'])); ?></pubDate>\r
+ <guid isPermaLink="false"><?php echo $guid; ?></guid>\r
+ <?php\r
+ $entry['display_dat'] = '';\r
+ serendipity_plugin_api::hook_event('frontend_display:rss-2.0:per_entry', $entry);\r
+ echo $entry['display_dat'];\r
+ ?>\r
+</item>\r
+<?php\r
+ /*********** END 2.0 FEED EXTRAS *************/\r
+ } else {\r
+ /*********** BEGIN RSS 0.91 FEED EXTRAS *************/\r
+?>\r
+ <description>\r
+ <?php echo serendipity_utf8_encode(htmlspecialchars($entry['body'] . $ext)); ?>\r
+ </description>\r
+</item>\r
+<?php\r
+ /*********** END RSS 0.91 FEED EXTRAS *************/\r
+ }\r
+ } else if ($version == '1.0') {\r
+ $categories = array();\r
+ foreach ($entry['categories'] AS $idx => $cat) {\r
+ $categories[] = $cat['category_name'];\r
+ }\r
+\r
+?>\r
+<item rdf:about="<?php echo $guid; ?>">\r
+ <title><?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?></title>\r
+ <link><?php echo $entryLink; ?></link>\r
+ <description>\r
+<?php\r
+ echo serendipity_utf8_encode(htmlspecialchars($entry['body'].$ext));\r
+?>\r
+ </description>\r
+ <?php\r
+ $entry['display_dat'] = '';\r
+ serendipity_plugin_api::hook_event('frontend_display:rss-1.0:per_entry', $entry);\r
+ echo $entry['display_dat'];\r
+ ?>\r
+ <dc:publisher><?php echo serendipity_utf8_encode(htmlspecialchars($serendipity['blogTitle'])); ?></dc:publisher>\r
+ <dc:creator><?php echo serendipity_utf8_encode(htmlspecialchars($entry['email'])) . ' (' . serendipity_utf8_encode(htmlspecialchars($entry['author'])) . ')'; ?></dc:creator>\r
+ <dc:subject><?php echo serendipity_utf8_encode(htmlspecialchars(implode(', ', $categories))); ?></dc:subject>\r
+ <dc:date><?php echo date('Y-m-d\TH:i:s\Z', serendipity_serverOffsetHour($entry['timestamp'])); ?></dc:date>\r
+ <wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo $id; ?></wfw:comment>\r
+<?php\r
+ if ($comments === false) {\r
+?>\r
+ <slash:comments><?php echo $entry['comments']; ?></slash:comments>\r
+ <wfw:commentRss><?php echo $serendipity['baseURL']; ?>rss.php?version=<?php echo $version; ?>&type=comments&cid=<?php echo $id; ?></wfw:commentRss>\r
+<?php\r
+ }\r
+?>\r
+</item>\r
+<?php\r
+ } elseif ($version == 'opml1.0') {\r
+?>\r
+ <outline text="<?php echo serendipity_utf8_encode(htmlspecialchars($entry['title'])); ?>" type="url" htmlUrl="<?php echo $entryLink; ?>" urlHTTP="<?php echo $entryLink; ?>" />\r
+<?php\r
+ }\r
+ }\r
+ }\r
+}\r
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
+function serendipity_fetchTrackbacks($id, $limit = null, $showAll = false) {
+ global $serendipity;
+
+ if (!$showAll) {
+ $and = "AND status = 'approved'";
+ }
+
+ $query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id = '". (int)$id ."' AND type = 'TRACKBACK' $and ORDER BY id";
+ if (isset($limit)) {
+ $limit = serendipity_db_limit_sql($limit);
+ $query .= " $limit";
+ }
+
+ $comments = serendipity_db_query($query);
+ if (!is_array($comments)) {
+ return array();
+ }
+
+ return $comments;
+}
+
+function serendipity_printTrackbacks($trackbacks) {
+ global $serendipity;
+
+ $serendipity['smarty']->assign('trackbacks', $trackbacks);
+
+ return serendipity_smarty_fetch('TRACKBACKS', 'trackbacks.tpl');
+}
+
function &serendipity_smarty_fetch($block, $file, $echo = false) {
global $serendipity;
}
$serendipity['smarty']->display(serendipity_getTemplateFile($serendipity['smarty_file'], 'serendipityPath'));
}
+
# Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team)
# All rights reserved. See LICENSE file for licensing details
-function serendipity_fetchTrackbacks($id, $limit = null, $showAll = false) {
- global $serendipity;
-
- if (!$showAll) {
- $and = "AND status = 'approved'";
- }
-
- $query = "SELECT * FROM {$serendipity['dbPrefix']}comments WHERE entry_id = '". (int)$id ."' AND type = 'TRACKBACK' $and ORDER BY id";
- if (isset($limit)) {
- $limit = serendipity_db_limit_sql($limit);
- $query .= " $limit";
- }
-
- $comments = serendipity_db_query($query);
- if (!is_array($comments)) {
- return array();
- }
-
- return $comments;
-}
-
-function serendipity_printTrackbacks($trackbacks) {
- global $serendipity;
-
- $serendipity['smarty']->assign('trackbacks', $trackbacks);
-
- return serendipity_smarty_fetch('TRACKBACKS', 'trackbacks.tpl');
-}
-
/**
* validate trackback response
*/
}
return false;
}
-
+
return $event_plugins;
}
$conf_array[] = $element['name'];
}
$propbag->add('configuration', $conf_array);
-
- // Only allow numbers and characters for CSS: "red", "#FF0000", ...
- $pattern_css = '([ 0-9a-z#-]+?)';
-
- // Only allow strings occuring in emails: .-_@, 0-9, a-z
- $pattern_mail = '([\.\-\+~@_0-9a-z]+?)';
-
- // Only allow strings occuring in URLs: &;?:.-_@/, 0-9, a-z
- $pattern_url = '([@!=~\?:&;0-9a-z#\.\-_\/]+?)';
-
- // Disallow possibly evil HTML characters which may lead to Javascript XSS: '"();
- $pattern_query = '([^"\'\(\);]+?)';
-
- // Note:
- // * Anything between <xxx>...</xxx> tags will be caught by htmlspecialchars() and disallows custom HTML tags.
- // * (?::\w+)? means "non capturing" match on any word character.
- // * (?<!\\\\) means any bbcode which is not prefixed by \[...]
- $this->bbcodes = array(
- '/(?<!\\\\)\[color(?::\w+)?=' . $pattern_css . '\](.*?)\[\/color(?::\w+)?\]/si' => "<span style=\"color:\\1\">\\2</span>",
- '/(?<!\\\\)\[size(?::\w+)?=' . $pattern_css . '\](.*?)\[\/size(?::\w+)?\]/si' => "<span style=\"font-size:\\1\">\\2</span>",
- '/(?<!\\\\)\[font(?::\w+)?=' . $pattern_css . '\](.*?)\[\/font(?::\w+)?\]/si' => "<span style=\"font-family:\\1\">\\2</span>",
- '/(?<!\\\\)\[align(?::\w+)?=' . $pattern_css . '\](.*?)\[\/align(?::\w+)?\]/si' => "<div style=\"text-align:\\1\">\\2</div>",
-
- '/(?<!\\\\)\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si' => "<span style=\"font-weight:bold\">\\1</span>",
- '/(?<!\\\\)\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si' => "<span style=\"font-style:italic\">\\1</span>",
- '/(?<!\\\\)\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si' => "<span style=\"text-decoration:underline\">\\1</span>",
- '/(?<!\\\\)\[center(?::\w+)?\](.*?)\[\/center(?::\w+)?\]/si' => "<div style=\"text-align:center\">\\1</div>",
-
- // [email]
- '/(?<!\\\\)\[email(?::\w+)?\]' . $pattern_mail . '\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\1</a>",
- '/(?<!\\\\)\[email(?::\w+)?=' . $pattern_mail . '\](.*?)\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\2</a>",
-
- // [url]
- '/(?<!\\\\)\[(google|search)\]' . $pattern_query . '\[\/(google|search)\]/si' => "<a href=\"http://www.google.com/search?q=\\2\" target=\"_blank\" class=\"bb-url\">\\2</a>",
- '/(?<!\\\\)\[url(?::\w+)?\]www\.' . $pattern_url . '\[\/url(?::\w+)?\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
- '/(?<!\\\\)\[url(?::\w+)?\]' . $pattern_url . '\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
- '/(?<!\\\\)\[url(?::\w+)?=' . $pattern_url . '?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>",
-
- // [img]
- '/(?<!\\\\)\[img(?::\w+)?\]' . $pattern_url . '\[\/img(?::\w+)?\]/si' => "<img src=\"\\1\" alt=\"\\1\" class=\"bb-image\" />",
- '/(?<!\\\\)\[img(?::\w+)?=([0-9]*?)x([0-9]*?)\]' . $pattern_url . '\[\/img(?::\w+)?\]/si' => "<img width=\"\\1\" height=\"\\2\" src=\"\\3\" alt=\"\\3\" class=\"bb-image\" />",
-
- // [quote]
- '/(?<!\\\\)\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si' => "<div class=\"bb-code-title\">QUOTE:<div class=\"bb-code\">\\1</div></div>",
- '/(?<!\\\\)\[quote(?::\w+)?=(?:"|"|\')?(.*?)["\']?(?:"|"|\')?\](.*?)\[\/quote\]/si' => "<div class=\"bb-code-title\">QUOTE \\1:<div class=\"bb-code\">\\2</div></div>",
-
- // [list]
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\*(?::\w+)?\](.*?)(?=(?:\s*<br\s*\/?>\s*)?\[\*|(?:\s*<br\s*\/?>\s*)?\[\/?list)/si' => "\n<li class=\"bb-listitem\">\\1</li>",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list(:(?!u|o)\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:u(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:o(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ol>",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(:(?!u|o)\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:u(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:o(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ol class=\"bb-list-ordered\">",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=1\]\s*(?:<br\s*\/?>)?/si' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-d\">",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=i\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-lr\">",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=I\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ur\">",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=a\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-la\">",
- '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=A\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ua\">",
-
- // escaped tags like \[b], \[color], \[url], ...
- '/\\\\(\[\/?\w+(?::\w+)*\])/' => "\\1"
- );
}
}
function bbcode($input) {
+ static $bbcodes = null;
+
+ // Only allow numbers and characters for CSS: "red", "#FF0000", ...
+ static $pattern_css = '([ 0-9a-z#-]+?)';
+
+ // Only allow strings occuring in emails: .-_@, 0-9, a-z
+ static $pattern_mail = '([\.\-\+~@_0-9a-z]+?)';
+
+ // Only allow strings occuring in URLs: &;?:.-_@/, 0-9, a-z
+ static $pattern_url = '([@!=~\?:&;0-9a-z#\.\-_\/]+?)';
+
+ // Disallow possibly evil HTML characters which may lead to Javascript XSS: '"();
+ static $pattern_query = '([^"\'\(\);]+?)';
+
+ // Note:
+ // * Anything between <xxx>...</xxx> tags will be caught by htmlspecialchars() and disallows custom HTML tags.
+ // * (?::\w+)? means "non capturing" match on any word character.
+ // * (?<!\\\\) means any bbcode which is not prefixed by \[...]
+
+ if ($bbcodes === null) {
+ $bbcodes = array(
+ '/(?<!\\\\)\[color(?::\w+)?=' . $pattern_css . '\](.*?)\[\/color(?::\w+)?\]/si' => "<span style=\"color:\\1\">\\2</span>",
+ '/(?<!\\\\)\[size(?::\w+)?=' . $pattern_css . '\](.*?)\[\/size(?::\w+)?\]/si' => "<span style=\"font-size:\\1\">\\2</span>",
+ '/(?<!\\\\)\[font(?::\w+)?=' . $pattern_css . '\](.*?)\[\/font(?::\w+)?\]/si' => "<span style=\"font-family:\\1\">\\2</span>",
+ '/(?<!\\\\)\[align(?::\w+)?=' . $pattern_css . '\](.*?)\[\/align(?::\w+)?\]/si' => "<div style=\"text-align:\\1\">\\2</div>",
+
+ '/(?<!\\\\)\[b(?::\w+)?\](.*?)\[\/b(?::\w+)?\]/si' => "<span style=\"font-weight:bold\">\\1</span>",
+ '/(?<!\\\\)\[i(?::\w+)?\](.*?)\[\/i(?::\w+)?\]/si' => "<span style=\"font-style:italic\">\\1</span>",
+ '/(?<!\\\\)\[u(?::\w+)?\](.*?)\[\/u(?::\w+)?\]/si' => "<span style=\"text-decoration:underline\">\\1</span>",
+ '/(?<!\\\\)\[center(?::\w+)?\](.*?)\[\/center(?::\w+)?\]/si' => "<div style=\"text-align:center\">\\1</div>",
+
+ // [email]
+ '/(?<!\\\\)\[email(?::\w+)?\]' . $pattern_mail . '\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\1</a>",
+ '/(?<!\\\\)\[email(?::\w+)?=' . $pattern_mail . '\](.*?)\[\/email(?::\w+)?\]/si' => "<a href=\"mailto:\\1\" class=\"bb-email\">\\2</a>",
+
+ // [url]
+ '/(?<!\\\\)\[(google|search)\]' . $pattern_query . '\[\/(google|search)\]/si' => "<a href=\"http://www.google.com/search?q=\\2\" target=\"_blank\" class=\"bb-url\">\\2</a>",
+ '/(?<!\\\\)\[url(?::\w+)?\]www\.' . $pattern_url . '\[\/url(?::\w+)?\]/si' => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
+ '/(?<!\\\\)\[url(?::\w+)?\]' . $pattern_url . '\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
+ '/(?<!\\\\)\[url(?::\w+)?=' . $pattern_url . '?\](.*?)\[\/url(?::\w+)?\]/si' => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>",
+
+ // [img]
+ '/(?<!\\\\)\[img(?::\w+)?\]' . $pattern_url . '\[\/img(?::\w+)?\]/si' => "<img src=\"\\1\" alt=\"\\1\" class=\"bb-image\" />",
+ '/(?<!\\\\)\[img(?::\w+)?=([0-9]*?)x([0-9]*?)\]' . $pattern_url . '\[\/img(?::\w+)?\]/si' => "<img width=\"\\1\" height=\"\\2\" src=\"\\3\" alt=\"\\3\" class=\"bb-image\" />",
+
+ // [quote]
+ '/(?<!\\\\)\[quote(?::\w+)?\](.*?)\[\/quote(?::\w+)?\]/si' => "<div class=\"bb-code-title\">QUOTE:<div class=\"bb-code\">\\1</div></div>",
+ '/(?<!\\\\)\[quote(?::\w+)?=(?:"|"|\')?(.*?)["\']?(?:"|"|\')?\](.*?)\[\/quote\]/si' => "<div class=\"bb-code-title\">QUOTE \\1:<div class=\"bb-code\">\\2</div></div>",
+
+ // [list]
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\*(?::\w+)?\](.*?)(?=(?:\s*<br\s*\/?>\s*)?\[\*|(?:\s*<br\s*\/?>\s*)?\[\/?list)/si' => "\n<li class=\"bb-listitem\">\\1</li>",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list(:(?!u|o)\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:u(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ul>",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[\/list:o(:\w+)?\](?:<br\s*\/?>)?/si' => "\n</ol>",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(:(?!u|o)\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:u(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ul class=\"bb-list-unordered\">",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list:o(:\w+)?\]\s*(?:<br\s*\/?>)?/si' => "\n<ol class=\"bb-list-ordered\">",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=1\]\s*(?:<br\s*\/?>)?/si' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-d\">",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=i\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-lr\">",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=I\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ur\">",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=a\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-la\">",
+ '/(?<!\\\\)(?:\s*<br\s*\/?>\s*)?\[list(?::o)?(:\w+)?=A\]\s*(?:<br\s*\/?>)?/s' => "\n<ol class=\"bb-list-ordered,bb-list-ordered-ua\">",
+
+ // escaped tags like \[b], \[color], \[url], ...
+ '/\\\\(\[\/?\w+(?::\w+)*\])/' => "\\1"
+ );
+ }
+
/* Regular expressions taken from http://smarty.incutio.com/?page=BBCodePlugin Wiki (Andre Rabold) */
- $input = preg_replace(array_keys($this->bbcodes), array_values($this->bbcodes), $input);
+ $input = preg_replace(array_keys($bbcodes), array_values($bbcodes), $input);
// [code] & [php]
$input = preg_replace_callback('/(?<!\\\\)\[(code|php)(?::\w+)?\](.*?)\[\/\\1(?::\w+)?\]/si', array($this, 'bbcode_callback'), $input);
$propbag->add('description', PLUGIN_EVENT_SPARTACUS_DESC);
$propbag->add('stackable', false);
$propbag->add('author', 'Garvin Hicking');
- $propbag->add('version', '2.02');
+ $propbag->add('version', '2.1');
$propbag->add('requirements', array(
'serendipity' => '0.9',
'smarty' => '2.6.7',
case 'close':
return $children;
}
+ unset($vals[$i]);
}
}
$target = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/package_' . $url_type . $lang . '.xml';
$xml = $this->fetchfile($url, $target, $cacheTimeout, true);
-
echo '<br /><br />';
$new_crc = md5($xml);
}
// XML functions
- $p = xml_parser_create();
- xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
- xml_parse_into_struct($p, $xml, $vals, $index);
- xml_parser_free($p);
-
+ $xml_string = '<?xml version="1.0" encoding="ISO-8859-1" ?>';
+ if (preg_match('@(<\?xml.+\?>)@imsU', $xml, $xml_head)) {
+ $xml_string = $xml_head[1];
+ }
+
+ preg_match_all('@(<package version="[^"]+">.*</package>)@imsU', $xml, $xml_matches);
+ if (!is_array($xml_matches)) {
+ return 'cached';
+ }
+
$i = 0;
$tree = array();
- $tree[] = array(
- 'tag' => $vals[$i]['tag'],
- 'attributes' => $vals[$i]['attributes'],
- 'value' => $vals[$i]['value'],
- 'children' => $this->GetChildren($vals, $i)
+ $tree[$i] = array(
+ 'tag' => 'packages',
+ 'attributes' => '',
+ 'value' => '',
+ 'children' => array()
);
-
+
+ foreach($xml_matches[0] as $xml_index => $xml_package) {
+ $i = 0;
+ $p = xml_parser_create();
+ xml_parser_set_option($p, XML_OPTION_CASE_FOLDING, 0);
+ $xml_package = $xml_string . "\n" . $xml_package;
+ xml_parse_into_struct($p, $xml_package, $vals);
+ xml_parser_free($p);
+ $tree[0]['children'][] = array(
+ 'tag' => $vals[$i]['tag'],
+ 'attributes' => $vals[$i]['attributes'],
+ 'value' => $vals[$i]['value'],
+ 'children' => $this->GetChildren($vals, $i)
+ );
+ unset($vals);
+ }
+
$this->set_config('last_crc_' . $url_type, $new_crc);
return $tree;
}
/* vim: set sts=4 ts=4 expandtab : */
-?>
\ No newline at end of file
break;
case 'backend_publish':
+ include_once(S9Y_PEAR_PATH . "XML/RPC.php");
+
// First cycle through list of services to remove superseding services which may have been checked
foreach ($this->services as $index => $service) {
if (!empty($service['supersedes']) && isset($serendipity['POST']['announce_entries_' . $service['name']])) {
header('Content-Type: text/xml; charset=utf-8');
session_cache_limiter('public');
include_once('serendipity_config.inc.php');
+include_once(S9Y_INCLUDE_PATH . 'functions_rss.inc.php');
+
$version = $_GET['version'];
$description = $serendipity['blogDescription'];
$title = $serendipity['blogTitle'];
define('IN_upgrader', true);
define('IN_serendipity', true);
include('serendipity_config.inc.php');
+
header('Content-Type: text/html; charset=' . LANG_CHARSET);
if (IS_installed === false) {
serendipity_plugin_api::hook_event('frontend_configure', $serendipity);
/* vim: set sts=4 ts=4 expandtab : */
-?>