Update of /cvsroot/php-blog/serendipity
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26050
Modified Files:
NEWS serendipity_functions.inc.php
serendipity_admin_interop.inc.php
serendipity_rss_exchange.inc.php
Log Message:
improve RSS import. PLEASE TEST!!! :-)
Index: NEWS
===================================================================
RCS file: /cvsroot/php-blog/serendipity/NEWS,v
retrieving revision 1.169
retrieving revision 1.170
diff -u -d -r1.169 -r1.170
--- NEWS 9 Jul 2004 18:59:13 -0000 1.169
+++ NEWS 13 Jul 2004 08:49:40 -0000 1.170
@@ -3,6 +3,9 @@
Version 0.7 ()
------------------------------------------------------------------------
+ * RSS Import: Allow toggling of draft/publish import, category
+ association, more description. (garvinhicking)
+
* Allow HTML nugget to be displayable on extended article only, over-
view only or both (default) (garvinhicking)
Index: serendipity_rss_exchange.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_rss_exchange.inc.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- serendipity_rss_exchange.inc.php 8 Jul 2003 12:10:09 -0000 1.4
+++ serendipity_rss_exchange.inc.php 13 Jul 2004 08:49:41 -0000 1.5
@@ -2,8 +2,10 @@
require_once 'bundled-libs/Onyx/RSS.php';
-function serendipity_rss_buildEntry($item, &$entry)
+function serendipity_rss_buildEntry($item, &$entry)
{
+ global $serendipity;
+
$entry = array();
if ($item['description']) {
@@ -16,24 +18,41 @@
} else {
$data = &$entry['extended'];
}
-
+
if ($entry['body'] != substr($item['content:encoded'], 0, strlen($entry['body']))) {
$data .= substr($item['content:encoded'], strlen($entry['body']));
} else {
$data = $item['content:encoded'];
}
}
-
+
$entry['title'] = $item['title'];
- $entry['timestamp'] = strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']);
+ $entry['timestamp'] = strtotime(isset($item['pubdate']) ? $item['pubdate'] : $item['dc:date']);
if ($entry['timestamp'] == -1) {
$entry['timestamp'] = time();
}
+ if ($serendipity['POST']['type'] == 'draft') {
+ $entry['isdraft'] = 'true';
+ } else {
+ $entry['isdraft'] = 'false';
+ }
+
+ if (!empty($entry['category'])) {
+ $cat = serendipity_fetchCategoryInfo(0, trim($entry['category']));
+ if (is_array($cat) && isset($cat['categoryid'])) {
+ $entry['categories'][] = $cat['categoryid'];
+ }
+ }
+
+ if (!is_array($entry['categories'])) {
+ $entry['categories'][] = $serendipity['POST']['category'];
+ }
+
return true;
}
-function serendipity_rss_import($url)
+function serendipity_rss_import($url)
{
global $serendipity;
@@ -46,7 +65,7 @@
serendipity_updertEntry($entry);
}
}
-
+
return true;
}
Index: serendipity_admin_interop.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_admin_interop.inc.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- serendipity_admin_interop.inc.php 21 Mar 2004 16:35:31 -0000 1.6
+++ serendipity_admin_interop.inc.php 13 Jul 2004 08:49:41 -0000 1.7
@@ -7,13 +7,13 @@
session_start();
-if (!empty($_POST['url'])) {
- if (serendipity_rss_import($_POST['url'])) {
+if (!empty($serendipity['POST']['url'])) {
+ if (serendipity_rss_import($serendipity['POST']['url'])) {
echo ENTRIES_SUCCESSFULLY_INSERTED . "\n<br />\n";
} else {
echo ENTRIES_NOT_SUCCESSFULLY_INSERTED . "\n<br />\n";
}
-} else if (!empty($_POST['export'])) {
+} else if (!empty($serendipity['POST']['export'])) {
?>
<a href="<?php echo $serendipity['serendipityHTTPPath']; ?>rss.php?version=2.0&all=1"><?php echo VIEW_FEED_EXPORT; ?></a>
<?php
@@ -26,18 +26,33 @@
<form method="POST">
<div>
- RSS URL: <input type="text" name="url" size="30" />
+ <?php echo RSS_IMPORT_DESC; ?><br /><br />
+
+ RSS URL: <input type="text" name="serendipity[url]" size="30" /> <?php echo TYPE . ': '; ?><select name="type">
+ <option value="draft"><?php echo DRAFT; ?></option>
+ <option value="publish"><?php echo PUBLISH; ?></option>
+ </select><br />
+
+ <?php
+ $cats = serendipity_fetchCategories('all');
+ echo RSS_IMPORT_CATEGORY . ': ';
+ ?>
+ <select name="serendipity[category]">
+ <option value="0">[ <?php echo NO_CATEGORY; ?> ]</option>
+ <?php echo serendipity_generateCategoryList($cats, array(), 1); ?>
+ </select>
<input type="submit" value="<?php echo IMPORT; ?> RSS" />
+
</div>
</form>
</p>
<p>
<h3><?php echo EXPORT; ?></h3>
-
+
<form method="POST">
<div>
- <input type="submit" name="export" value="<?php echo EXPORT; ?> RSS" />
+ <input type="submit" name="serendipity[export]" value="<?php echo EXPORT; ?> RSS" />
</div>
</form>
</p>
Index: serendipity_functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/serendipity_functions.inc.php,v
retrieving revision 1.325
retrieving revision 1.326
diff -u -d -r1.325 -r1.326
--- serendipity_functions.inc.php 12 Jul 2004 12:47:28 -0000 1.325
+++ serendipity_functions.inc.php 13 Jul 2004 08:49:40 -0000 1.326
@@ -562,10 +562,22 @@
return array('category_left' => $res[0]['category_left'], 'category_right' => $res[0]['category_right']);
}
-function serendipity_fetchCategoryInfo($categoryid) {
+function serendipity_fetchCategoryInfo($categoryid, $categoryname = '') {
global $serendipity;
- if (is_numeric($categoryid)) {
+ if (!empty($categoryname)) {
+ $query = "SELECT
+ c.categoryid,
+ c.category_name,
+ c.category_description,
+ c.category_icon,
+ c.parentid
+ FROM {$serendipity['dbPrefix']}category AS c
+ WHERE category_name = '" . serendipity_db_escape_string($categoryname) . "'";
+
+ $ret = serendipity_db_query($query);
+ return $ret[0];
+ } else if (is_numeric($categoryid)) {
$query = "SELECT
c.categoryid,
c.category_name,
|