Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23021
Modified Files:
NEWS comment.php index.php serendipity_admin_category.inc.php
serendipity_admin_entries.inc.php
serendipity_admin_plugins.inc.php
serendipity_admin_upgrader.inc.php serendipity_config.inc.php
serendipity_functions.inc.php serendipity_sidebar_items.php
Log Message:
Great patch by Evan nemerson: Subcategories, post to multiple categories, threaded comments.
My basic tests left no problems or issues with it, but make sure you update your databases when testing!
Index: index.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/index.php,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- index.php 7 Apr 2004 12:42:42 -0000 1.38
+++ index.php 7 Jun 2004 14:22:47 -0000 1.39
@@ -10,7 +10,7 @@
include_once('serendipity_config.inc.php');
serendipity_login();
header('Content-Type: text/html; charset='. LANG_CHARSET);
-
+
$track_referer = true;
$uri = $_SERVER['REQUEST_URI'];
@@ -78,6 +78,7 @@
$comment['name'] = $serendipity['POST']['name'];
$comment['email'] = $serendipity['POST']['email'];
$comment['subscribe'] = $serendipity['POST']['subscribe'];
+ $comment['parent_id'] = $serendipity['POST']['replyTo'];
if (!empty($comment['comment'])) {
if (serendipity_saveComment($serendipity['POST']['entry_id'], $comment, 'NORMAL')) {
header('Location: ' . $_SERVER['REQUEST_URI'] . (strstr($_SERVER['REQUEST_URI'], '?') ? '&' : '?') . 'serendipity[csuccess]=true');
Index: serendipity_config.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_config.inc.php,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- serendipity_config.inc.php 26 May 2004 17:02:32 -0000 1.76
+++ serendipity_config.inc.php 7 Jun 2004 14:22:47 -0000 1.77
@@ -12,7 +12,7 @@
}
include_once(S9Y_INCLUDE_PATH . 'compat.php');
-$serendipity['version'] = '0.6.4-CVS';
+$serendipity['version'] = '0.6.5-CVS';
$serendipity['production'] = 1;
$serendipity['rewrite'] = 'none';
$serendipity['messagestack'] = array();
Index: serendipity_admin_plugins.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_plugins.inc.php,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- serendipity_admin_plugins.inc.php 13 Apr 2004 10:00:36 -0000 1.24
+++ serendipity_admin_plugins.inc.php 7 Jun 2004 14:22:47 -0000 1.25
@@ -453,6 +453,9 @@
<?php
serendipity_emit_htmlarea_code('nugget', 'nugget');
break;
+ case 'hidden':
+ ?><tr><td colspan="2"><input type="hidden" id="hidden" name="serendipity[plugin][<?php echo $config_item; ?>]" /></td></tr><?php
+ break;
}
}
?>
Index: serendipity_admin_entries.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_entries.inc.php,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- serendipity_admin_entries.inc.php 13 May 2004 20:29:08 -0000 1.23
+++ serendipity_admin_entries.inc.php 7 Jun 2004 14:22:47 -0000 1.24
@@ -61,9 +61,7 @@
$sort .= '</select> ' . CATEGORY . ' <select name="serendipity[filter_category]"><option value="">--</option>';
$categories = serendipity_fetchCategories();
if (is_array($categories)) {
- foreach($categories AS $row) {
- $sort .= '<option value="' . $row['categoryid'] . '" ' . (isset($serendipity['GET']['filter_category']) && $serendipity['GET']['filter_category'] == $row['categoryid'] ? 'selected="selected"' : '') . '>' . $row['category_name'] . '</option>' . "\n";
- }
+ $sort .= serendipity_generateCategoryList($categories, (isset($serendipity['GET']['filter_category']) ? array($serendipity['GET']['filter_category']) : array(0)), 2);
}
$sort .= '</select> '
@@ -109,7 +107,7 @@
}
if (!empty($serendipity['GET']['filter_category'])) {
- $filter[] = "e.categoryid = '" . serendipity_db_escape_string($serendipity['GET']['filter_category']) . "'";
+ $filter[] = "ec.categoryid = '" . serendipity_db_escape_string($serendipity['GET']['filter_category']) . "'";
}
if (!empty($serendipity['GET']['filter_body'])) {
@@ -197,7 +195,18 @@
<?php if ($entries[$entryIndex]['isdraft'] == 'true') echo DRAFT . ':'; ?>
<a href="?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=<?php echo $entries[$entryIndex]['id']; ?>" title="#<?php echo $entries[$x]['id']; ?>">
<?php echo htmlspecialchars(substr(empty($entries[$entryIndex]['title']) ? (empty($entries[$entryIndex]['body']) ? '---' : $entries[$entryIndex]['body']) : $entries[$entryIndex]['title'], 0, 40)); ?></a><br />
- <?php echo POSTED_BY . ' ' . $entries[$entryIndex]['username'] . ( !empty($entries[$entryIndex]['category_name']) ? ' ' . IN . ' ' . $entries[$entryIndex]['category_name'] :''); ?><br />
+ <?php
+ echo POSTED_BY . ' ' . $entries[$entryIndex]['username'];
+ if (count($entries[$entryIndex]['categories'])) {
+ echo ' ' . IN . ' ';
+ $cats = array();
+ foreach ($entries[$entryIndex]['categories'] as $cat) {
+ $cats[] = '<a href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'categories/' . $cat['categoryid'] . '_' . serendipity_makeFilename($cat['category_name']) . '">' . $cat['category_name'] . '</a>';
+ }
+ echo implode(', ', $cats);
+ }
+ ?>
+ <br />
</td>
<?php
} else {
@@ -249,7 +258,7 @@
'timestamp' => $serendipity['POST']['timestamp'],
'body' => $serendipity['POST']['body'],
'extended' => $serendipity['POST']['extended'],
- 'categoryid' => $serendipity['POST']['categoryid'],
+ 'categories' => $serendipity['POST']['categories'],
'isdraft' => $serendipity['POST']['isdraft'],
'allow_comments' => $serendipity['POST']['allow_comments']
);
@@ -293,6 +302,12 @@
if (!isset($entry['comments']) || !$entry['comments']) $entry['comments'] = 0;
if (!isset($entry['username']) || !$entry['username']) $entry['username'] = $serendipity['serendipityUser'];
+ $categories = $entry['categories'];
+ $entry['categories'] = array();
+ foreach ( $categories as $catid ) {
+ $entry['categories'][] = serendipity_fetchCategoryInfo($catid);
+ }
+
echo '<strong>' . PREVIEW . '</strong>';
echo '<div style="border:1px solid #000000; padding: 15px;">';
serendipity_printEntries(array($entry), ($entry['extended'] != '' ? 1 : 0), true);
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.278
retrieving revision 1.279
diff -u -d -r1.278 -r1.279
--- serendipity_functions.inc.php 7 Jun 2004 12:12:21 -0000 1.278
+++ serendipity_functions.inc.php 7 Jun 2004 14:22:47 -0000 1.279
@@ -215,10 +215,15 @@
<?php
}
-function serendipity_displayCommentForm($id, $url = '?') {
+function serendipity_displayCommentForm($id, $url = '?', $comments = NULL) {
global $serendipity;
+
+ if ( $comments == NULL ) {
+ $comments = serendipity_fetchComments($id);
+ }
?>
<div class="serendipityCommentForm">
+ <a name="serendipity_CommentForm"></a>
<form <?php echo ($serendipity['XHTML11'] ? 'id' : 'name'); ?>="serendipity_comment" action="<?php echo $url; ?>" method="post" onsubmit="if (document.getElementById('serendipity_remember') && document.getElementById('serendipity_remember').checked) rememberMe(this, '<?php echo $_SERVER['HTTP_HOST']; ?>')">
<div><input type="hidden" name="serendipity[entry_id]" value="<?php echo $id; ?>" /></div>
<table border="0" width="100%" cellpadding="3">
@@ -238,6 +243,11 @@
</tr>
<tr>
+ <td class="serendipity_commentsLabel"><?php echo IN_REPLY_TO; ?></td>
+ <td class="serendipity_commentsValue"><?php echo serendipity_generateCommentList($id, $comments, ((isset($serendipity['POST']['serendipity']['replyTo']) && ($_POST['serendipity']['replyTo'])) ? $serendipity['POST']['serendipity']['replyTo'] : 0)); ?></td>
+ </tr>
+
+ <tr>
<td class="serendipity_commentsLabel"><?php echo COMMENT; ?></td>
<td class="serendipity_commentsValue">
<textarea rows="10" cols="40" name="serendipity[comment]"><?php echo (isset($serendipity['POST']['comment']) ? $serendipity['POST']['comment'] : ''); ?></textarea><br />
@@ -382,7 +392,6 @@
}
// Find out about diary entries
- $querystring = "SELECT timestamp from {$serendipity['dbPrefix']}entries WHERE timestamp >= $ts and timestamp <= $endts AND isdraft = 'false'";
$add_query = '';
$base_query = '';
if (isset($serendipity['GET']['category'])) {
@@ -390,12 +399,27 @@
$categoryid = serendipity_db_escape_string($_categoryid[0]);
if (is_numeric($categoryid)) {
- $querystring .= " AND categoryid = $categoryid";
$base_query = '?serendipity[category]=' . $categoryid;
$add_query = '&' . $base_query;
+ $querystring = "SELECT timestamp
+ FROM {$serendipity['dbPrefix']}entries e,
+ {$serendipity['dbPrefix']}category c,
+ {$serendipity['dbPrefix']}entrycat ec
+ WHERE e.timestamp >= $ts
+ AND e.timestamp <= $endts
+ AND e.isdraft = 'false'
+ AND e.id = ec.entryid
+ AND c.categoryid = ec.categoryid
+ AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid)) . ")";
}
}
+ if (!isset($querystring)) {
+ $querystring = "SELECT timestamp
+ FROM {$serendipity['dbPrefix']}entries e
+ WHERE e.timestamp >= $ts and e.timestamp <= $endts AND e.isdraft = 'false'";
+ }
+
$rows = serendipity_db_query($querystring);
$activeDays = array();
if (is_array($rows)) {
@@ -523,6 +547,51 @@
<?php
} // end function: serendipity_drawCalendar
+function serendipity_fetchCategoryRange($categoryid) {
+ global $serendipity;
+
+ $res = serendipity_db_query("SELECT category_left, category_right FROM {$serendipity['dbPrefix']}category WHERE categoryid='{$categoryid}'");
+ return array('category_left' => $res[0]['category_left'], 'category_right' => $res[0]['category_right']);
+}
+
+function serendipity_fetchCategoryInfo($categoryid) {
+ global $serendipity;
+
+ if (is_numeric($categoryid)) {
+ $query = "SELECT
+ c.categoryid,
+ c.category_name,
+ c.category_description,
+ c.category_icon,
+ c.parentid
+ FROM {$serendipity['dbPrefix']}category AS c
+ WHERE categoryid = {$categoryid}";
+
+ $ret = serendipity_db_query($query);
+ return $ret[0];
+ }
+}
+
+function serendipity_fetchEntryCategories($entryid) {
+ global $serendipity;
+
+ if (is_numeric($entryid)) {
+ $query = "SELECT
+ c.categoryid,
+ c.category_name,
+ c.category_description,
+ c.category_icon,
+ c.parentid
+ FROM {$serendipity['dbPrefix']}category AS c
+ LEFT JOIN {$serendipity['dbPrefix']}entrycat AS ec
+ ON ec.categoryid = c.categoryid
+ WHERE ec.entryid = {$entryid}";
+
+ return serendipity_db_query($query);
+ }
+}
+
+
/**
* Give it a range in YYYYMMDD format to gather the desired entries
* (For february 2002 you would pass 200202 e.g.
@@ -592,9 +661,9 @@
if (is_numeric($categoryid)) {
if (!empty($and)) {
- $and .= " AND e.categoryid = $categoryid";
+ $and .= " AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid));
} else {
- $and = "WHERE e.categoryid = $categoryid";
+ $and = "WHERE c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid));
}
}
}
@@ -639,25 +708,25 @@
e.exflag,
e.author,
e.authorid,
- e.categoryid,
e.trackbacks,
e.isdraft,
e.allow_comments,
e.last_modified,
a.username,
- a.email,
+ a.email
- c.category_name,
- c.categoryid,
- c.category_icon
$body
FROM
- ({$serendipity['dbPrefix']}entries AS e
- LEFT JOIN {$serendipity['dbPrefix']}category c
- ON e.categoryid = c.categoryid)
+ {$serendipity['dbPrefix']}entries AS e
LEFT JOIN {$serendipity['dbPrefix']}authors a
- ON e.authorid = a.authorid $and
+ ON e.authorid = a.authorid
+ LEFT JOIN {$serendipity['dbPrefix']}entrycat ec
+ ON e.id = ec.entryid
+ LEFT JOIN {$serendipity['dbPrefix']}category c
+ ON ec.categoryid = c.categoryid $and
+ GROUP BY
+ e.id
ORDER BY
$orderby
$limit";
@@ -668,6 +737,11 @@
die("Query failed: $ret");
}
+ if (is_array($ret)) {
+ foreach ($ret as $i => $entry) {
+ $ret[$i]['categories'] = $ret[$i][] = serendipity_fetchEntryCategories($entry['id']);
+ }
+ }
return $ret;
}
@@ -689,24 +763,21 @@
$querystring = "SELECT
*,
- c.category_name,
- c.categoryid,
- c.category_icon,
a.username,
a.email
FROM
- {$serendipity['dbPrefix']}entries e
- LEFT JOIN {$serendipity['dbPrefix']}category c
- ON e.categoryid = c.categoryid,
+ {$serendipity['dbPrefix']}entries e,
{$serendipity['dbPrefix']}authors a
WHERE
a.authorid = e.authorid
- AND $key LIKE $val
+ AND e.$key LIKE $val
$admin
$drafts
LIMIT 1";
- return serendipity_db_query($querystring, true);
+ $ret = serendipity_db_query($querystring, true);
+ $ret['categories'] = $ret[] = serendipity_fetchEntryCategories($ret['id']);
+ return $ret;
}
/**
@@ -729,11 +800,35 @@
$where = '';
}
- $querystring = "SELECT c.*, a.username FROM {$serendipity['dbPrefix']}category AS c LEFT OUTER JOIN {$serendipity['dbPrefix']}authors AS a ON c.authorid = a.authorid $where ORDER BY category_name";
+ $querystring = "SELECT
+ c.*,
+ a.username
+ FROM {$serendipity['dbPrefix']}category AS c
+ LEFT OUTER JOIN {$serendipity['dbPrefix']}authors AS a
+ ON c.authorid = a.authorid $where
+ ORDER BY category_name";
return serendipity_db_query($querystring);
}
+function serendipity_rebuildCategoryTree($parent = 0, $left = 0) {
+ // Based on http://www.sitepoint.com/article/hierarchical-data-database/1
+ global $serendipity;
+ $right = $left + 1;
+
+ $result = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}category WHERE parentid='" . $parent . "'");
+ if ( is_array($result) ) {
+ foreach ( $result as $category ) {
+ $right = serendipity_rebuildCategoryTree($category['categoryid'], $right);
+ }
+ }
+ if ( $parent > 0 ) {
+ serendipity_db_query("UPDATE {$serendipity['dbPrefix']}category SET category_left='{$left}', category_right='{$right}' WHERE categoryid='{$parent}'");
+ }
+
+ return $right + 1;
+}
+
function serendipity_fetchUsers($user = '') {
global $serendipity;
@@ -758,8 +853,7 @@
e.author,
a.username,
a.email,
- e.categoryid,
- c.category_name,
+ ec.categoryid,
e.timestamp,
e.comments,
e.title,
@@ -768,14 +862,16 @@
e.trackbacks,
e.exflag
FROM
- {$serendipity['dbPrefix']}entries e
- LEFT JOIN {$serendipity['dbPrefix']}category c
- ON e.categoryid = c.categoryid,
- {$serendipity['dbPrefix']}authors a
+ {$serendipity['dbPrefix']}entries e,
+ {$serendipity['dbPrefix']}authors a,
+ {$serendipity['dbPrefix']}entrycat ec
WHERE
a.authorid = e.authorid
+ AND e.id = ec.entryid
AND MATCH (title,body,extended) AGAINST ('".addslashes($term)."')
AND isdraft = 'false'
+ GROUP BY
+ e.id
ORDER BY
timestamp DESC";
@@ -883,13 +979,17 @@
}
}
- $querystring = "SELECT count(id) FROM {$serendipity['dbPrefix']}entries WHERE isdraft = 'false'";
+ $querystring = "SELECT count(id)
+ FROM {$serendipity['dbPrefix']}entries e,
+ {$serendipity['dbPrefix']}entrycat ec
+ WHERE isdraft = 'false'
+ AND e.id = ec.entryid";
if (isset($serendipity['GET']['category'])) {
$_categoryid = explode('_', $serendipity['GET']['category']);
$categoryid = serendipity_db_escape_string($_categoryid[0]);
if (is_numeric($categoryid)) {
- $querystring .= " AND categoryid = $categoryid";
+ $querystring .= " e.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($categoryid));
}
}
@@ -975,15 +1075,34 @@
<h4 class="serendipity_title"><a href="<?php echo $entryLink; ?>"><?php echo htmlspecialchars($entry['title']); ?></a></h4>
<div class="serendipity_entry">
- <?php if ($entry['category_icon'] != '') {
- echo '<a class="serendipity_entryIcon" href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'categories/' . $entry['categoryid'] . '_' . serendipity_makeFilename($entry['category_name']) . '"><img class="serendipity_entryIcon" alt="' . htmlspecialchars($entry['category_name']) . '" src="' . htmlspecialchars($entry['category_icon']) . '"/></a>';
- } ?>
+ <?php
+ if (is_array($entry['categories'])) {
+ $icon_string = '';
+ foreach ($entry['categories'] as $cat) {
+ if ($cat['category_icon'] != '') {
+ $icon_string .= '<a href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'categories/' . $cat['categoryid'] . '_' . serendipity_makeFilename($cat['category_name']) . '"><img class="serendipity_entryIcon" alt="' . htmlspecialchars($cat['category_name']) . '" src="' . htmlspecialchars($cat['category_icon']) . '"/></a>';
+ }
+ }
+ if ($icon_string != '') {
+ echo '<span class="serendipity_entryIcon">' . $icon_string . '</span>';
+ }
+ }
+ ?>
<span class="<?php echo $extended_css; ?>"><?php echo $entry['body']; ?></span>
<?php echo $html_extended; ?>
<div class='serendipity_entryFooter'>
<?php
- echo ' ' . POSTED_BY . ' ' . htmlspecialchars($entry['username']) . (!empty($entry['category_name']) ? ' ' . IN . ' <a href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'categories/' . $entry['categoryid'] . '_' . serendipity_makeFilename($entry['category_name']) . '">' . $entry['category_name'] . '</a> ' : ' ') . AT . ' <a href="' . $entryLink . '">' . date('H:i', $entry['timestamp']) . '</a>'. "\n";
+ echo ' ' . POSTED_BY . ' ' . htmlspecialchars($entry['username']);
+ if (is_array($entry['categories'])) {
+ echo ' ' . IN . ' ';
+ $cats = array();
+ foreach ($entry['categories'] as $cat) {
+ $cats[] = '<a href="' . $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . 'categories/' . $cat['categoryid'] . '_' . serendipity_makeFilename($cat['category_name']) . '">' . $cat['category_name'] . '</a>';
+ }
+ echo implode(', ', $cats);
+ echo ' ' . AT . ' <a href="' . $entryLink . '">' . date('H:i', $entry['timestamp']) . '</a>'. "\n";
+ }
if (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['comments'] > 0) {
if (!isset($serendipity['GET']['id'])) {
@@ -1051,11 +1170,13 @@
'author' => $serendipity['POST']['name'],
'body' => $serendipity['POST']['comment'],
'url' => $serendipity['POST']['url'],
+ 'parent_id' => $serendipity['POST']['replyTo'],
'timestamp' => time()
)
),
false,
- false
+ false,
+ $serendipity['POST']['replyTo']
);
}
@@ -1177,12 +1298,15 @@
e.id AS entryid,
e.authorid,
co.id AS commentid,
+ co.parent_id AS parent_id,
c.category_name
FROM
{$serendipity['dbPrefix']}comments co
LEFT JOIN {$serendipity['dbPrefix']}entries e ON (co.entry_id = e.id)
- LEFT JOIN {$serendipity['dbPrefix']}category c ON (e.categoryid = c.categoryid)
+ LEFT JOIN {$serendipity['dbPrefix']}entrycat ec ON (e.id = ec.entryid)
+ LEFT JOIN {$serendipity['dbPrefix']}category c ON (ec.categoryid = c.categoryid)
WHERE co.type LIKE 'NORMAL' AND entry_id > 0 $and
+ GROUP BY co.id
ORDER BY
co.id " . ($order != '' ? $order : '') . "
$limit";
@@ -1213,68 +1337,95 @@
return $comments;
}
-function serendipity_printComments($comments, $allow_comments = true, $show_admin = true)
+function serendipity_generateCommentList($id, $comments = NULL, $selected = 0, $parent = 0, $level = 0) {
+ global $serendipity;
+
+ if ( !is_array($comments) ) {
+ $comments = serendipity_fetchComments($id);
+ }
+
+ $retval = $parent ? '' : '<select id="serendipity[replyTo]" name="serendipity[replyTo]"><option value="0">[ ' . TOP_LEVEL . ' ]</option>';
+ foreach ($comments as $comment) {
+ if ($comment['parent_id'] == $parent) {
+ $retval .= '<option value="' . $comment['id'] . '"'. ($selected == $comment['id'] || (isset($serendipity['POST']['replyTo']) && $comment['id'] == $serendipity['POST']['replyTo']) ? ' selected="selected"' : '') .'>' . str_repeat(' ', $level * 2) . '#' . $comment['id'] . ': ' . (empty($comment['author']) ? ANONYMOUS : $comment['author']) . ' ' . ON . ' ' . ucfirst(strftime('%b %e %Y, %H:%M', $comment['timestamp'])) . "</option>\n";
+ $retval .= serendipity_generateCommentList($id, $comments, $selected, $comment['id'], $level + 1);
+ }
+ }
+ $retval .= $parent ? '' : '</select>';
+
+ return $retval;
+}
+
+function serendipity_printComments($comments, $allow_comments = true, $show_admin = true, $parentid = 0)
{
global $serendipity;
?>
<?php
- if (!count($comments)) {
+ if (!count($comments) && !$parentid) {
?>
<div align="center"><?php echo NO_COMMENTS; ?></div>
<?php
}
- $x = 0;
foreach ($comments as $comment) {
- $x++;
+ if (!isset($comment['parent_id']) || $comment['parent_id'] == $parentid) {
- $comment['comment'] = htmlspecialchars(strip_tags($comment['body']));
- if (!empty($comment['url']) && substr($comment['url'], 0, 7) != 'http://' && substr($comment['url'], 0, 8) != 'https://') {
- $comment['url'] = 'http://' . $comment['url'];
- }
+ $comment['comment'] = htmlspecialchars(strip_tags($comment['body']));
+ if (!empty($comment['url']) && substr($comment['url'], 0, 7) != 'http://' && substr($comment['url'], 0, 8) != 'https://') {
+ $comment['url'] = 'http://' . $comment['url'];
+ }
- serendipity_plugin_api::hook_event('frontend_display', $comment);
+ serendipity_plugin_api::hook_event('frontend_display', $comment);
- /* Protect submitted mails against spam, by replacing @ with [at]*/
- if (!empty($comment['email'])) {
- $comment['email'] = str_replace('@', '[at]', $comment['email']);
- }
+ /* Protect submitted mails against spam, by replacing @ with [at]*/
+ if (!empty($comment['email'])) {
+ $comment['email'] = str_replace('@', '[at]', $comment['email']);
+ }
- $name = empty($comment['author']) ? ANONYMOUS : $comment['author'];
- $body = $comment['comment'];
+ $name = empty($comment['author']) ? ANONYMOUS : $comment['author'];
+ $body = $comment['comment'];
?>
<div class="serendipity_comment">
<a <?php echo ($serendipity['XHTML11'] ? 'id' : 'name'); ?>="c<?php echo $comment['id']; ?>"></a>
<?php echo $body; ?><br />
<div class="serendipity_comment_source">
- <a href="#c<?php echo $comment['id']; ?>" title="<?php echo LINK_TO_COMMENT . $x; ?>">#<?php echo $x ; ?></a>
+ <a href="#c<?php echo $comment['id']; ?>" title="<?php echo LINK_TO_COMMENT . $comment['id']; ?>">#<?php echo $comment['id'] ; ?></a>
<?php
/* Link to the user's email */
- if (!empty($comment['email'])) {
- echo '<a href="mailto:' . htmlspecialchars($comment['email']) . '" title="' . SEND_MAIL_TO . ' ' . htmlspecialchars($name) . ' (' . $comment['email'] . ')">' . htmlspecialchars($name) . '</a>';
- } else {
- echo htmlspecialchars($name);
- }
+ if (!empty($comment['email'])) {
+ echo '<a href="mailto:' . htmlspecialchars($comment['email']) . '" title="' . SEND_MAIL_TO . ' ' . htmlspecialchars($name) . ' (' . $comment['email'] . ')">' . htmlspecialchars($name) . '</a>';
+ } else {
+ echo htmlspecialchars($name);
+ }
- /* Link to the user's website, if the URL is valid */
- if ((!isset($comment['type']) || $comment['type'] != 'trackback') && !empty($comment['url']) && $comment['url'] != 'http://' && eregi('^https?://', $comment['url'])) {
- echo ' (<a href="' . str_replace('"', '"', $comment['url']) . '" ' . serendipity_xhtml_target('_blank') . ' title="' . htmlspecialchars($comment['url']) . '">Link</a>)';
- }
+ /* Link to the user's website, if the URL is valid */
+ if ((!isset($comment['type']) || $comment['type'] != 'trackback') && !empty($comment['url']) && $comment['url'] != 'http://' && eregi('^https?://', $comment['url'])) {
+ echo ' (<a href="' . str_replace('"', '"', $comment['url']) . '" ' . serendipity_xhtml_target('_blank') . ' title="' . htmlspecialchars($comment['url']) . '">Link</a>)';
+ }
- /* Show when the entry was made */
- echo ' ' . ON . ' ' . ucfirst(strftime('%b %e %Y, %H:%M', $comment['timestamp']));
+ /* Show when the entry was made */
+ echo ' ' . ON . ' ' . ucfirst(strftime('%b %e %Y, %H:%M', $comment['timestamp']));
- if ($show_admin && $_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityUserlevel'] >= USERLEVEL_CHIEF || $_SESSION['serendipityAuthorid'] == $comment['authorid'])) {
- echo ' (<a href="' . $serendipity['baseURL'] . 'comment.php?serendipity[delete]=' . $comment['id'] . '&serendipity[entry]=' . $comment['entry_id'] . '&serendipity[type]=comments">' . DELETE . '</a>)';
- }
+ if ($show_admin && $_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityUserlevel'] >= USERLEVEL_CHIEF || $_SESSION['serendipityAuthorid'] == $comment['authorid'])) {
+ echo ' (<a href="' . $serendipity['baseURL'] . 'comment.php?serendipity[delete]=' . $comment['id'] . '&serendipity[entry]=' . $comment['entry_id'] . '&serendipity[type]=comments">' . DELETE . '</a>)';
+ }
+
+ /* Allow people to easily reply to this comment */
+ echo ' <a href="#serendipity_CommentForm" onclick="document.getElementById(\'serendipity[replyTo]\').value=\'' . $comment['id'] . '\';">' . REPLY . '</a>';
?>
</div>
+ <?php serendipity_printComments($comments, $allow_comments, $show_admin, $comment['id']); ?>
</div>
<br />
<?php
+ }
+ }
+
+ if ($parentid != 0) {
+ return true;
}
if ($show_admin && $_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityUserlevel'] >= USERLEVEL_CHIEF || $_SESSION['serendipityAuthorid'] == $comment['authorid'])) {
@@ -1349,6 +1500,7 @@
$name = serendipity_db_escape_string($commentInfo['name']);
$url = serendipity_db_escape_string($commentInfo['url']);
$email = serendipity_db_escape_string($commentInfo['email']);
+ $parentid = (isset($commentInfo['parent_id']) && is_numeric($commentInfo['parent_id'])) ? $commentInfo['parent_id'] : 0;
if (isset($commentInfo['subscribe'])) {
$subscribe = 'true';
@@ -1357,8 +1509,8 @@
}
$t = time();
- $query = "INSERT INTO {$serendipity['dbPrefix']}comments (entry_id, author, email, url, body, type, timestamp, title, subscribed)";
- $query .= " VALUES ('$id', '$name', '$email', '$url', '$commentsFixed', '$type', '$t', '$title', '$subscribe')";
+ $query = "INSERT INTO {$serendipity['dbPrefix']}comments (entry_id, parent_id, author, email, url, body, type, timestamp, title, subscribed)";
+ $query .= " VALUES ('$id', '$parentid', '$name', '$email', '$url', '$commentsFixed', '$type', '$t', '$title', '$subscribe')";
serendipity_db_query($query);
@@ -1573,6 +1725,10 @@
$entry['email'] = $results[0]['email'];
}
+ if (!is_array($entry['categories'])) {
+ $entry['categories'] = array(0 => $entry['category_name']);
+ }
+
if ($version == 'atom0.3') {
/*********** ATOM 0.3 FEED *************/
?>
@@ -1619,8 +1775,10 @@
if ($version == '2.0') {
/*********** RSS 2.0 FEED EXTRAS *************/
+ foreach ($entry['categories'] AS $idx => $cat) {
+ ?><category><?php echo utf8_encode(htmlspecialchars($cat['category_name'])); ?></category><?php
+ }
?>
- <category><?php echo serendipity_utf8_encode(htmlspecialchars($entry['category_name'])); ?></category>
<comments><?php echo $guid; ?></comments>
<wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo (isset($entry['entryid']) && $entry['entryid'] != '' ? $entry['entryid'] : $entry['id']); ?></wfw:comment>
<?php
@@ -1658,6 +1816,11 @@
/*********** 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>
@@ -1674,7 +1837,7 @@
?>
<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['username'])) . ')'; ?></dc:creator>
- <dc:subject><?php echo serendipity_utf8_encode(htmlspecialchars($entry['category_name'])); ?></dc:subject>
+ <dc:subject><?php echo utf8_encode(htmlspecialchars(implode(', ', $categories))); ?></dc:subject>
<dc:date><?php echo date('Y-m-d\TH:i:s\Z', $entry['timestamp']); ?></dc:date>
<wfw:comment><?php echo $serendipity['baseURL']; ?>wfwcomment.php?cid=<?php echo (isset($entry['entryid']) && $entry['entryid'] != '' ? $entry['entryid'] : $entry['id']); ?></wfw:comment>
<?php
@@ -2019,6 +2182,9 @@
function serendipity_updertEntry($entry) {
global $serendipity;
+ $categories = $entry['categories'];
+ unset($entry['categories']);
+
$newEntry = 0;
$exflag = 0;
@@ -2054,8 +2220,15 @@
$res = serendipity_db_insert('entries', $entry);
- if ($res)
+ if ($res) {
$entry['id'] = serendipity_db_insert_id();
+ if (is_array($categories)) {
+ foreach ($categories as $cat) {
+ if (is_numeric($cat))
+ serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entrycat (entryid, categoryid) VALUES ({$entry['id']}, {$cat})");
+ }
+ }
+ }
else {
//Some error message here
return ENTRIES_NOT_SUCCESSFULLY_INSERTED;
@@ -2072,6 +2245,11 @@
unset($entry['isdraft']);
}
+ serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}entrycat WHERE entryid={$entry['id']}");
+ foreach ($categories as $cat) {
+ serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}entrycat (entryid, categoryid) VALUES ({$entry['id']}, {$cat})");
+ }
+
$res = serendipity_db_update('entries', array('id' => $entry['id']), $entry);
$newEntry = 0;
}
@@ -2133,6 +2311,47 @@
return array($f, $suf);
}
+function serendipity_generateCategoryList($cats, $select = array(0), $type = 0, $id = 0, $level = 0) {
+ global $serendipity;
+
+ if ( !is_array($cats) || !count($cats) )
+ return;
+
+ $ret = '';
+ foreach ($cats as $cat) {
+ if ($cat['parentid'] == $id) {
+ switch ($type) {
+ case 0:
+ $ret .= str_repeat(' ', $level * 2).'• <span id="catItem_' . $cat['categoryid'] . '"' . (($cat['categoryid'] && in_array($cat['categoryid'], $select)) ? ' selected="selected"' : '') . '><a href="?serendipity[adminModule]=category&serendipity[cat][catid]=' . $cat['categoryid'] . '">' . (!empty($cat['category_icon']) ? '<img style="vertical-align: middle;" src="' . $cat['category_icon'] . '" alt="' . $cat['category_name'] . '"/> ' : '') . htmlspecialchars($cat['category_name']) . ' - ' . htmlspecialchars($cat['category_description']) . '</a></span><br/>' . "\n";
+ break;
+ case 1:
+ case 2:
+ $ret .= '<option value="' . $cat['categoryid'] . '"' . (($cat['categoryid'] && in_array($cat['categoryid'], $select)) ? ' selected="selected"' : '') . '>';
+ $ret .= str_repeat(' ', $level * 2) . htmlspecialchars($cat['category_name']) . ($type == 1 ? (' - ' . htmlspecialchars($cat['category_description'])) : '');
+ $ret .= '</option>';
+ break;
+ case 3:
+ $category_id = serendipity_makeFilename($cat['category_name']);
+ $ret .= sprintf(
+ '<a href="%s" title="%s"><img alt="xml" %s src="%s" /></a> %s' .
+ '<a href="%s" title="%s">%s</a><br />',
+
+ $serendipity['serendipityHTTPPath'] . 'rss.php?category=' . $cat['categoryid'] . '_' . $category_id,
+ htmlspecialchars($cat['category_description']),
+ ($serendipity['XHTML11'] ? 'style="display: inline; border: 0px"' : 'border="0"'),
+ serendipity_getTemplateFile('img/xml.gif'),
+ str_repeat(' ', $level * 3),
+ $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_CATEGORIES . '/' . $cat['categoryid'] . '_' . $category_id,
+ htmlspecialchars($cat['category_description']),
+ htmlspecialchars($cat['category_name']));
+ break;
+ }
+ $ret .= serendipity_generateCategoryList($cats, $select, $type, $cat['categoryid'], $level + 1);
+ }
+ }
+ return $ret;
+}
+
/**
* Prints a form to enter new diary entries
**/
@@ -2140,7 +2359,6 @@
global $serendipity;
$serendipity['EditorBrowsers'] = '(IE|Mozilla)';
- $cats = serendipity_fetchCategories();
$draftD = '';
$draftP = '';
@@ -2160,38 +2378,18 @@
$allow_comments = '';
}
- if (isset($entry['categoryid']) && $entry['categoryid'] != 0) {
- $edit_cat=0;
- if (is_array($cats)) {
- foreach ($cats as $cat_data) {
- if ($cat_data['categoryid'] == $entry['categoryid'] ) {
- $edit_cat = 1;
- }
- }
- }
- } else {
- $edit_cat=1;
- }
-
$n = "\n";
- if ($edit_cat) {
- $cat_list = '<select name="serendipity[categoryid]">' . $n;
- $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n;
- if (is_array($cats)) {
- foreach ($cats as $cat_data) {
- $selected = (isset($entry['categoryid']) && $cat_data['categoryid'] == $entry['categoryid'] ? ' selected="selected"' : '');
- $cat_list .= ' <option value="' . $cat_data['categoryid'] . '" ' . $selected . '>'
- . htmlspecialchars($cat_data['category_name'])
- . ' - '
- . htmlspecialchars($cat_data['category_description'])
- . '</option>' . $n;
- }
- }
- $cat_list .= '</select>' . $n;
- } else {
- $cat_list = CANNOT_EDIT_CATEGORY . $n;
- $cat_list .= '<input type="hidden" name="serendipity[categoryid]" value="' . $entry['categoryid'] . '" />' . $n;
+ $cat_list = '<select id="categoryselector" name="serendipity[categories][]" multiple="multiple" style="vertical-align: middle;" size="3">' . $n;
+ $cat_list .= ' <option value="0">[' . NO_CATEGORY . ']</option>' . $n;
+ $selected = array();
+ if (is_array($entry['categories'])) {
+ foreach ($entry['categories'] as $cat)
+ $selected[] = $cat['categoryid'];
}
+ if (is_array($cats = serendipity_fetchCategories())) {
+ $cat_list .= serendipity_generateCategoryList($cats, ($selected == array() ? array(0) : $selected), 1);
+ }
+ $cat_list .= '</select>' . $n;
$hidden = '';
foreach($hiddens as $key => $value) {
@@ -2242,7 +2440,27 @@
<?php
}
?>
- <b><?php echo CATEGORY; ?>:</b> <?php echo $cat_list ; ?></td>
+ <script type="text/javascript" language="JavaScript">
+ var selector_toggle = new Array();
+ var selector_store = new Array();
+
+ function showItem(id) {
+ if (document.getElementById) {
+ el = document.getElementById(id);
+ if (selector_toggle[id] && selector_toggle[id] == 'off') {
+ el.size = selector_store[id];
+ selector_toggle[id] = 'on';
+ document.getElementById('option_' + id).src = 'pixel/plus.png';
+ } else {
+ selector_store[id] = el.size;
+ el.size = <?php echo count($cats)+1; ?>;
+ selector_toggle[id] = 'off';
+ document.getElementById('option_' + id).src = 'pixel/minus.png';
+ }
+ }
+ }
+ </script>
+ <a style="border:0; text-decoration: none" href="#" onclick="showItem('categoryselector'); return false" title="<?php echo TOGGLE_OPTION; ?>"><img src="pixel/plus.png" id="option_categoryselector" alt="+/-" border="0" /></a> <b><?php echo CATEGORY; ?>:</b> <?php echo $cat_list ; ?></td>
</tr>
<tr>
<?php
@@ -2635,8 +2853,12 @@
if (!$postid || !$categories) {
return;
}
- $query = "UPDATE $serendipity[dbPrefix]entries set categoryid = $categories[0] where id = $postid";
- $err = serendipity_db_query($query);
+
+ $query = "DELETE FORM $serendipity[dbPrefix]entrycat WHERE entryid = $postid";
+ serendipity_db_query($query);
+
+ $query = "INSERT INTO $serendipity[dbPrefix]entrycat (entryid, categoryid) VALUES ($categories[0], $postid)";
+ serendipity_db_query($query);
}
/*
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.141
retrieving revision 1.142
diff -u -d -r1.141 -r1.142
--- NEWS 7 Jun 2004 10:39:24 -0000 1.141
+++ NEWS 7 Jun 2004 14:22:47 -0000 1.142
@@ -3,7 +3,13 @@
Version 0.7 ()
------------------------------------------------------------------------
- * WYSIWYG-Editor: Links were prefixed with '/' wrongly (IE only).
+ * Post to multiple categories and subcategories implemented.
+ (Evan Nemerson, garvinhicking)
+
+ * Threaded comments.
+ (Evan Nemerson) [DB Layout change - > 0.6.5]
+
+ * WYSIWYG-Editor: Links were prefixed with '/' wrongly (IE only).
Now all entered links will be put to an absolute URL consistently.
(garvinhicking)
Index: serendipity_sidebar_items.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_sidebar_items.php,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- serendipity_sidebar_items.php 21 Apr 2004 14:03:40 -0000 1.57
+++ serendipity_sidebar_items.php 7 Jun 2004 14:22:47 -0000 1.58
@@ -554,22 +554,7 @@
$html = '';
if (is_array($categories) && count($categories)) {
- foreach ($categories as $category) {
- $category_id = serendipity_makeFilename($category['category_name']);
-
- $html .= sprintf(
- '<a href="%s" title="%s"><img alt="xml" %s src="%s" /></a> ' .
- '<a href="%s" title="%s">%s</a><br />',
-
- $serendipity['serendipityHTTPPath'] . 'rss.php?category=' . $category['categoryid'] . '_' . $category_id,
- htmlspecialchars($category['category_description']),
- ($serendipity['XHTML11'] ? 'style="display: inline; border: 0px"' : 'border="0"'),
- serendipity_getTemplateFile('img/xml.gif'),
- $serendipity['serendipityHTTPPath'] . ($serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '') . PATH_CATEGORIES.'/' . $category['categoryid'] . '_' . $category_id,
- htmlspecialchars($category['category_description']),
- htmlspecialchars($category['category_name'])
- );
- }
+ $html .= serendipity_generateCategoryList($categories, array(0), 3, 0);
}
$html .= sprintf(
Index: comment.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/comment.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- comment.php 14 May 2004 08:19:54 -0000 1.33
+++ comment.php 7 Jun 2004 14:22:47 -0000 1.34
@@ -119,7 +119,7 @@
?>
<div class="serendipity_commentsTitle"><?php echo ADD_COMMENT; ?></div>
<?php
- serendipity_displayCommentForm($id);
+ serendipity_displayCommentForm($id, '?', $comments);
}
}
} else {
@@ -128,6 +128,7 @@
$comment['name'] = $serendipity['POST']['name'];
$comment['email'] = $serendipity['POST']['email'];
$comment['subscribe'] = $serendipity['POST']['subscribe'];
+ $comment['parent_id'] = $serendipity['POST']['replyTo'];
if (!empty($comment['comment'])) {
if (serendipity_saveComment($serendipity['POST']['entry_id'], $comment, 'NORMAL')) {
header('Location: ' . $serendipity['baseURL'] . 'comment.php?entry_id=' . $serendipity['POST']['entry_id'] . '&success=true&url=' . urlencode($_SERVER['HTTP_REFERER']));
Index: serendipity_admin_category.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_category.inc.php,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- serendipity_admin_category.inc.php 19 May 2004 21:03:46 -0000 1.13
+++ serendipity_admin_category.inc.php 7 Jun 2004 14:22:47 -0000 1.14
@@ -14,14 +14,24 @@
$desc = addslashes($_POST['serendipity']['cat']['description']);
$authorid = (isset($_POST['serendipity']['cat']['all_authors']) && $_POST['serendipity']['cat']['all_authors'] == 'true') ? '0' : $serendipity['authorid'];
$icon = addslashes($_POST['serendipity']['cat']['icon']);
+ $parentid = (isset($_POST['serendipity']['cat']['parent_cat']) && is_numeric($_POST['serendipity']['cat']['parent_cat'])) ? $_POST['serendipity']['cat']['parent_cat'] : 0;
if ($cat_to_edit == 0) {
- $query = "INSERT INTO {$serendipity['dbPrefix']}category (category_name, category_description, authorid, category_icon) values ('$name', '$desc', $authorid, '$icon')";
+ $query = "INSERT INTO {$serendipity['dbPrefix']}category (category_name, category_description, authorid, category_icon, parentid) values ('$name', '$desc', $authorid, '$icon', $parentid)";
} else {
- $query = "UPDATE {$serendipity['dbPrefix']}category SET category_name='$name', category_description='$desc', authorid=$authorid, category_icon='$icon' WHERE categoryid=$cat_to_edit $admin_category";
+ /* Check to make sure parent is not a child of self */
+ $r = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}category c WHERE c.categoryid={$parentid} AND c.category_left BETWEEN " . implode(' AND ', serendipity_fetchCategoryRange($cat_to_edit)));
+ if ( !is_array($r) ) {
+ $query = "UPDATE {$serendipity['dbPrefix']}category SET category_name='$name', category_description='$desc', authorid=$authorid, category_icon='$icon', parentid=$parentid WHERE categoryid=$cat_to_edit $admin_category";
+ }
+ else {
+ $r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category WHERE categoryid={$parentid}");
+ $msg = sprintf(ALREADY_SUBCATEGORY, $r[0]['category_name'], $name);
+ }
}
- $r = serendipity_db_query($query);
+ $r = empty($msg) ? serendipity_db_query($query) : $msg;
+ serendipity_rebuildCategoryTree();
if (is_string($r)) {
$msg = $r;
} else {
@@ -126,6 +136,28 @@
<th><label for="all_authors"><?php echo ALL_AUTHORS; ?></label></th>
<td><input id="all_authors" type="checkbox" name="serendipity[cat][all_authors]" value="true" <?php echo (isset($this_cat['authorid']) && $this_cat['authorid'] == '0') ? 'checked="checked"' : ''; ?> /></td>
</tr>
+<?php
+ if (isset($cats) && is_array($cats) && count($cats)) {
+?>
+ <tr>
+ <th><label for="parent_cat"><?php echo PARENT_CATEGORY; ?></label></th>
+ <td>
+ <select id="parent_cat" name="serendipity[cat][parent_cat]">
+ <option value="0"<?php if ( $cat_to_edit == 0 ) echo ' selected="selected"'; ?>>[ <?php echo NO_CATEGORY; ?> ]</option>
+<?php
+ foreach ( $cats as $cat ) {
+ if ( $cat['categoryid'] == $cat_to_edit ) {
+ $parentid = $cat['parentid'];
+ }
+ }
+ echo serendipity_generateCategoryList($cats, array($parentid), 2);
+?>
+ </select>
+ </td>
+ </tr>
+<?php
+}
+?>
</table>
<div>
@@ -136,14 +168,11 @@
<hr>
<b><?php echo CLICK_CAT_TO_EDIT; ?></b>
-<table>
-<?php echo $existing_cats_table; ?>
- <tr>
- <td>
- • <a href="?serendipity[adminModule]=category&serendipity[cat][catid]=0"><?php echo CREATE_NEW_CAT; ?></a>
- </td>
- </tr>
-</table>
+<div>
+ <?php echo serendipity_generateCategoryList($cats, array($cat_to_edit)); ?>
+ <p><a href="?serendipity[adminModule]=category&serendipity[cat][catid]=0"><?php echo CREATE_NEW_CAT; ?></a></li></p>
+</div>
+
</form>
<?php
/* vim: set sts=4 ts=4 expandtab : */
Index: serendipity_admin_upgrader.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_upgrader.inc.php,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- serendipity_admin_upgrader.inc.php 3 Jun 2004 21:18:46 -0000 1.10
+++ serendipity_admin_upgrader.inc.php 7 Jun 2004 14:22:47 -0000 1.11
@@ -5,7 +5,8 @@
$upgradeLoc = $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[action]=upgrade';
/* Functions which needs to be run if installed version is equal or lower */
-$tasks = array('0.5.1' => 'serendipity_syncThumbs');
+$tasks = array('0.5.1' => 'serendipity_syncThumbs',
+ '0.6.5' => 'serendipity_rebuildCategoryTree');
/* Fetch SQL files which needs to be run */
@@ -47,6 +48,7 @@
foreach ($tasks as $version => $function) {
if (version_compare(serendipity_version($serendipity['versionInstalled']), $version, '<=') ) {
if (is_callable($function)) {
+ echo 'Calling ' . $function . '...<br />';
call_user_func($function);
} else {
$errors[] = 'Unable to call '. $function;
@@ -132,6 +134,13 @@
}</pre><br />';
}
+ if (version_compare(serendipity_version($serendipity['versionInstalled']), '0.6.5', '<')) {
+ echo '<br /><strong>0.6.5 - Nested subcategories, post to multiple categories</strong>';
+ echo '<br />[<strong style="color: red">INFO</strong>] This update will update the categories table of your database and update the relations from entries to categories. This is a possibly dangerous task to perform, so <strong style="color: red">make sure you have a backup of your database!</strong><br />';
+ echo '<br />The categories-update syntax feature has only been tested for MySQL. PostgreSQL support should be tested first!!!<br/>';
+ $taskCount++;
+ }
+
/*
Add more versions here using:
|