1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01: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

@ -149,6 +149,10 @@ class e_parse
array(
'defs'=>TRUE, 'constants'=>'full', 'parse_sc'=>TRUE
),
'WYSIWYG' =>
array(
'defs'=>FALSE, 'constants'=>'full', 'parse_sc'=>FALSE, 'wysiwyg'=>TRUE
),
// text is user-entered (i.e. untrusted)'body' or 'bulk' text (e.g. custom page body, content body)
'USER_BODY' =>
array(
@ -229,7 +233,8 @@ class e_parse
'defs' => array('defs' => TRUE),
'parse_sc' => array('parse_sc' => TRUE),
'constants' => array('constants' => 'rel'),
'value' => array('value' => TRUE)
'value' => array('value' => TRUE),
'wysiwyg' => array('wysiwyg'=>TRUE)
);
@ -1325,6 +1330,9 @@ class e_parse
$last_bbcode = '';
// So we can change them on each loop
$saveOpts = $opts;
if ($parseBB == FALSE)
{
$content = array($text);
@ -1375,6 +1383,7 @@ class e_parse
$className = '';
$full_text = '';
$code_text = $matches[4];
$parm = $matches[3] ? substr($matches[3],1) : '';
$last_bbcode = $matches[2];
switch ($matches[2])
@ -1401,6 +1410,7 @@ class e_parse
case 'html' :
$proc_funcs = TRUE;
$convertNL = FALSE;
$full_text = str_replace(array("[html]","[/html]"),"",$code_text); // quick fix.. security issue?
break;
case 'table' : // strip <br /> from end of <table>
@ -1570,8 +1580,16 @@ class e_parse
if ($parseBB === TRUE)
{
// 'Normal' or 'legacy' processing
if($modifiers == "WYSIWYG")
{
$sub_blk = $this->e_bb->parseBBCodes($sub_blk, $postID, 'wysiwyg');
}
else
{
$sub_blk = $this->e_bb->parseBBCodes($sub_blk, $postID);
}
}
elseif ($parseBB === 'STRIP')
{
// Need to strip all BBCodes

View File

@ -313,7 +313,7 @@ class e_media
$query .= " LIMIT ".$from." ,".$amount;
}
e107::getDb()->db_Select_gen($query);
while($row = e107::getDb()->db_Fetch(mySQL_ASSOC))
while($row = e107::getDb()->db_Fetch(MYSQL_ASSOC))
{
$id = $row['media_id'];
$ret[$id] = $row;

View File

@ -106,7 +106,7 @@ class override {
}
$tmp = strpos($this->functions[$override],"::") ? explode("::",$this->functions[$override]) : $this->functions[$override];
$tmp = (varset($this->functions[$override]) && strpos($this->functions[$override],"::")) ? explode("::",$this->functions[$override]) : $this->functions[$override];
if(is_array($tmp) && class_exists($tmp[0]))
{
$cl = new $tmp[0];

View File

@ -305,6 +305,8 @@ function dbImport($mode='db')
$mes = e107::getMessage();
define("RSS_IMPORT",vartrue($_POST['rss_feed'],false));
// if (IMPORT_DEBUG) echo "Importing: {$current_db_type}<br />";
$mes->addDebug("Loading: ".$current_db_type);

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
$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' :
if ($result === FALSE) return FALSE;
break;
case 'media' :
break;
case 'links' :
$array = $xml->loadXMLfile($file,'advanced');
if ($array === FALSE || RSS_IMPORT === FALSE) return FALSE;
foreach($array['channel']['item'] as $val)
{
$this->arrayData[] = $val;
}
reset($this->arrayData);
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
return $target; // comment out to debug
// DEBUG INFO BELOW.
$this->renderDebug($source,$target);
}
@ -277,6 +181,10 @@ 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['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'] = '';
// $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'];
// return $target; // comment out to debug
return $target; // comment out to debug
// DEBUG INFO BELOW.
$this->renderDebug($source,$target);