1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-23 14:44:29 +02:00

Import routines and quick [html] bbcode fix.

This commit is contained in:
CaMer0n
2012-07-22 10:03:00 +00:00
parent 2dda03de71
commit 818c0fe92c
6 changed files with 95 additions and 169 deletions

View File

@@ -22,7 +22,7 @@
// Array element key defines the function prefix and the class name; value is displayed in drop-down selection box
$import_class_names['rss_import'] = 'RSS';
$import_class_comment['rss_import'] = '(work in progress)';
$import_class_comment['rss_import'] = 'Import RSS v2.0 feeds';
$import_class_support['rss_import'] = array('news','page','links');
$import_default_prefix['rss_import'] = '';
@@ -34,49 +34,26 @@ class rss_import extends base_import_class
// Returns TRUE on success. FALSE on error
function setupQuery($task, $blank_user=FALSE)
{
$this->arrayData = array();
$xml = e107::getXml();
require_once(e_HANDLER."magpie_rss.php");
// $file = "http://www.e107.org/releases.php"; //pluginfeed.php or similar.
// $file = "http://localhost:8080/e107_0.8/e107_plugins/release/release.php"; // temporary testing
$file = "http://raelianews.org/rss";
$xml->setOptArrayTags('plugin'); // make sure 'plugin' tag always returns an array
$xml = e107::getXml();
$file = RSS_IMPORT;
switch ($task)
{
case 'users' :
//$query = "SELECT * FROM {$this->DBPrefix}users WHERE `user_id` != 1";
break;
{
case 'news' :
// $result = $xml->loadXMLfile($file,true);
// $rawData = $xml->getRemoteFile($file);
// $rss = new MagpieRSS( $rawData );
// $array = $xml->xml2array($rss);
$xml->setOptArrayTags('item'); // make sure 'plugin' tag always returns an array
$array = $xml->loadXMLfile($file,'advanced');
$this->arrayData = $array['channel']['item'];
if ($result === FALSE) return FALSE;
break;
case 'page' :
case 'links' :
$array = $xml->loadXMLfile($file,'advanced');
if ($array === FALSE || RSS_IMPORT === FALSE) return FALSE;
if ($result === FALSE) return FALSE;
break;
case 'media' :
foreach($array['channel']['item'] as $val)
{
$this->arrayData[] = $val;
}
break;
reset($this->arrayData);
case 'links':
if ($result === FALSE) return FALSE;
break;
default :
@@ -110,56 +87,29 @@ class rss_import extends base_import_class
*/
function copyNewsData(&$target, &$source)
{
/* Example:
[ID] => 88
[post_author] => 1
[post_date] => 2012-01-25 04:11:22
[post_date_gmt] => 2012-01-25 09:11:22
[post_content] => [gallery itemtag="div" icontag="span" captiontag="p" link="file"]
[post_title] => Media Gallery
[post_excerpt] =>
[post_status] => inherit
[comment_status] => open
[ping_status] => open
[post_password] =>
[post_name] => 10-revision-6
[to_ping] =>
[pinged] =>
[post_modified] => 2012-01-25 04:11:22
[post_modified_gmt] => 2012-01-25 09:11:22
[post_content_filtered] =>
[post_parent] => 10
[guid] => http://siteurl.com/2012/01/25/10-revision-6/
[menu_order] => 0
[post_type] => post
[post_mime_type] =>
[comment_count] => 0
*/
// $target['news_id'] = $source['ID'];
$target['news_title'] = $source['post_title'];
$target['news_sef'] = $source['post_name'];
$target['news_body'] = $source['post_content'];
$target['news_title'] = $source['title'][0];
// $target['news_sef'] = $source['post_name'];
$target['news_body'] = "[html]".$source['description'][0]."[/html]";
// $target['news_extended'] = '';
// $target['news_meta_keywords'] = '';
// $target['news_meta_description'] = '';
$target['news_datestamp'] = strtotime($source['post_date']);
$target['news_author'] = $source['post_author'];
$target['news_datestamp'] = strtotime($source['pubDate'][0]);
// $target['news_author'] = $source['post_author'];
// $target['news_category'] = '';
$target['news_allow_comments'] = ($source['comment_status']=='open') ? 1 : 0;
$target['news_start'] = '';
$target['news_end'] = '';
$target['news_class'] = '';
$target['news_render_type'] = '';
$target['news_comment_total'] = $source['comment_count'];
$target['news_summary'] = $source['post_excerpt'];
$target['news_thumbnail'] = '';
$target['news_sticky'] = '';
// $target['news_allow_comments'] = ($source['comment_status']=='open') ? 1 : 0;
// $target['news_start'] = '';
// $target['news_end'] = '';
/// $target['news_class'] = '';
// $target['news_render_type'] = '';
// $target['news_comment_total'] = $source['comment_count'];
// $target['news_summary'] = $source['post_excerpt'];
// $target['news_thumbnail'] = '';
// $target['news_sticky'] = '';
// return $target; // comment out to debug
return $target; // comment out to debug
// DEBUG INFO BELOW.
$this->renderDebug($source,$target);
}
@@ -172,33 +122,18 @@ class rss_import extends base_import_class
*/
function copyPageData(&$target, &$source)
{
$tp = e107::getParser();
/* post_status:
publish - A published post or page
inherit - a revision
pending - post is pending review
private - a private post
future - a post to publish in the future
draft - a post in draft status
trash - post is in trashbin (available with 2.9)
*/
if($source['post_status']=='private' || $source['post_status']=='future' || $source['post_status'] == 'draft')
{
$target['page_class'] = e_UC_ADMIN;
}
// $target['page_id'] = $source['ID']; // auto increment
$target['page_title'] = $source['post_title'];
$target['page_sef'] = $source['post_name'];
$target['page_text'] = "[html]".$source['post_content']."[/html]";
$target['page_metakeys'] = '';
$target['page_metadscr'] = '';
$target['page_datestamp'] = strtotime($source['post_date']);
$target['page_author'] = $source['post_author'];
$target['page_title'] = $source['title'][0];
// $target['page_sef'] = $source['post_name'];
$target['page_text'] = "[html]".$source['description'][0]."[/html]";
// $target['page_metakeys'] = '';
// $target['page_metadscr'] = '';
$target['page_datestamp'] = strtotime($source['pubDate'][0]);
// $target['page_author'] = $source['post_author'];
// $target['page_category'] = '',
$target['page_comment_flag'] = ($source['comment_status']=='open') ? 1 : 0;
$target['page_password'] = $source['post_password'];
// $target['page_comment_flag'] = ($source['comment_status']=='open') ? 1 : 0;
// $target['page_password'] = $source['post_password'];
return $target; // comment out to debug
@@ -216,52 +151,21 @@ class rss_import extends base_import_class
function copyLinksData(&$target, &$source)
{
$tp = e107::getParser();
/* WP
link_id
link_url
link_name
link_image
link_target
link_description
link_visible
link_owner
link_rating
link_updated
link_rel
link_notes
link_rss
*
* e107
* link_id
link_name
link_url
link_description
link_button
link_category
link_order
link_parent
link_open
link_class
link_function
link_sefurl
*/
// $target['page_id'] = $source['ID']; // auto increment
$target['link_name'] = $source['post_title'];
$target['link_url'] = $source['post_name'];
$target['link_description'] = "[html]".$source['post_content']."[/html]";
$target['link_button'] = '';
$target['link_category'] = '';
$target['link_order'] = strtotime($source['post_date']);
$target['link_parent'] = $source['post_author'];
$target['link_open'] = '';
$target['link_class'] = '';
$target['link_sefurl'] = $source['post_password'];
$target['link_name'] = $source['title'][0];
$target['link_url'] = $source['link'][0];
// $target['link_description'] = "[html]".$source['post_content']."[/html]";
// $target['link_button'] = '';
// $target['link_category'] = '';
// $target['link_order'] = strtotime($source['post_date']);
// $target['link_parent'] = $source['post_author'];
// $target['link_open'] = '';
// $target['link_class'] = '';
// $target['link_sefurl'] = $source['post_password'];
// return $target; // comment out to debug
// DEBUG INFO BELOW.
return $target; // comment out to debug
$this->renderDebug($source,$target);
}
@@ -276,7 +180,11 @@ class rss_import extends base_import_class
function renderDebug($source,$target)
{
{
// echo print_a($target);
// return;
echo "
<div style='width:1000px'>
<table style='width:100%'>

View File

@@ -146,7 +146,7 @@ class wordpress_import extends base_import_class
$target['user_visits'] = $source['user_visits'];
$target['user_class'] = $source['user_class'];
$target['user_perms'] = $source['user_perms'];
$target['user_xup'] = $source['user_xup'];
// $target['user_xup'] = $source['user_xup'];
$target['user_language'] = $source['user_language'];
$target['user_country'] = $source['user_country'];
$target['user_location'] = $source['user_location'];
@@ -199,7 +199,7 @@ class wordpress_import extends base_import_class
// $target['news_id'] = $source['ID'];
$target['news_title'] = $source['post_title'];
$target['news_sef'] = $source['post_name'];
$target['news_body'] = $source['post_content'];
$target['news_body'] = (vartrue($source['post_content'])) ? "[html]".$source['post_content']."[/html]" : "";
// $target['news_extended'] = '';
// $target['news_meta_keywords'] = '';
// $target['news_meta_description'] = '';
@@ -251,7 +251,7 @@ class wordpress_import extends base_import_class
// $target['page_id'] = $source['ID']; // auto increment
$target['page_title'] = $source['post_title'];
$target['page_sef'] = $source['post_name'];
$target['page_text'] = "[html]".$source['post_content']."[/html]";
$target['page_text'] = (vartrue($source['post_content'])) ? "[html]".$source['post_content']."[/html]" : "";
$target['page_metakeys'] = '';
$target['page_metadscr'] = '';
$target['page_datestamp'] = strtotime($source['post_date']);
@@ -306,20 +306,18 @@ class wordpress_import extends base_import_class
link_sefurl
*/
// $target['page_id'] = $source['ID']; // auto increment
$target['link_name'] = $source['post_title'];
$target['link_url'] = $source['post_name'];
$target['link_description'] = "[html]".$source['post_content']."[/html]";
$target['link_button'] = '';
$target['link_category'] = '';
$target['link_order'] = strtotime($source['post_date']);
$target['link_parent'] = $source['post_author'];
$target['link_open'] = '';
$target['link_class'] = '';
$target['link_sefurl'] = $source['post_password'];
$target['link_name'] = $source['link_name'];
$target['link_url'] = $source['link_url'];
$target['link_description'] = (vartrue($source['link_description'])) ? "[html]".$source['link_description']."[/html]" : "";
// $target['link_button'] = '';
// $target['link_category'] = '';
// $target['link_order'] = '';
// $target['link_parent'] = '';
$target['link_open'] = ''; // link_target
$target['link_class'] = ($source['link_visible'] == 'Y') ? '0' : e_UC_MAINADMIN;
// $target['link_sefurl'] = '';
// return $target; // comment out to debug
return $target; // comment out to debug
// DEBUG INFO BELOW.
$this->renderDebug($source,$target);