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( array(
'defs'=>TRUE, 'constants'=>'full', 'parse_sc'=>TRUE '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) // text is user-entered (i.e. untrusted)'body' or 'bulk' text (e.g. custom page body, content body)
'USER_BODY' => 'USER_BODY' =>
array( array(
@ -229,7 +233,8 @@ class e_parse
'defs' => array('defs' => TRUE), 'defs' => array('defs' => TRUE),
'parse_sc' => array('parse_sc' => TRUE), 'parse_sc' => array('parse_sc' => TRUE),
'constants' => array('constants' => 'rel'), '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 = ''; $last_bbcode = '';
// So we can change them on each loop // So we can change them on each loop
$saveOpts = $opts; $saveOpts = $opts;
if ($parseBB == FALSE) if ($parseBB == FALSE)
{ {
$content = array($text); $content = array($text);
@ -1375,6 +1383,7 @@ class e_parse
$className = ''; $className = '';
$full_text = ''; $full_text = '';
$code_text = $matches[4]; $code_text = $matches[4];
$parm = $matches[3] ? substr($matches[3],1) : ''; $parm = $matches[3] ? substr($matches[3],1) : '';
$last_bbcode = $matches[2]; $last_bbcode = $matches[2];
switch ($matches[2]) switch ($matches[2])
@ -1401,6 +1410,7 @@ class e_parse
case 'html' : case 'html' :
$proc_funcs = TRUE; $proc_funcs = TRUE;
$convertNL = FALSE; $convertNL = FALSE;
$full_text = str_replace(array("[html]","[/html]"),"",$code_text); // quick fix.. security issue?
break; break;
case 'table' : // strip <br /> from end of <table> case 'table' : // strip <br /> from end of <table>
@ -1429,7 +1439,7 @@ class e_parse
if ($className) if ($className)
{ {
$tempCode = new $className(); $tempCode = new $className();
$full_text = $tempCode->bbPreDisplay($matches[4], $parm); $full_text = $tempCode->bbPreDisplay($matches[4], $parm);
} }
elseif ($bbcode) elseif ($bbcode)
{ // Execute the file { // Execute the file
@ -1570,7 +1580,15 @@ class e_parse
if ($parseBB === TRUE) if ($parseBB === TRUE)
{ {
// 'Normal' or 'legacy' processing // 'Normal' or 'legacy' processing
$sub_blk = $this->e_bb->parseBBCodes($sub_blk, $postID); 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') elseif ($parseBB === 'STRIP')
{ {

View File

@ -313,7 +313,7 @@ class e_media
$query .= " LIMIT ".$from." ,".$amount; $query .= " LIMIT ".$from." ,".$amount;
} }
e107::getDb()->db_Select_gen($query); 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']; $id = $row['media_id'];
$ret[$id] = $row; $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])) if(is_array($tmp) && class_exists($tmp[0]))
{ {
$cl = new $tmp[0]; $cl = new $tmp[0];

View File

@ -305,6 +305,8 @@ function dbImport($mode='db')
$mes = e107::getMessage(); $mes = e107::getMessage();
define("RSS_IMPORT",vartrue($_POST['rss_feed'],false));
// if (IMPORT_DEBUG) echo "Importing: {$current_db_type}<br />"; // if (IMPORT_DEBUG) echo "Importing: {$current_db_type}<br />";
$mes->addDebug("Loading: ".$current_db_type); $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 // 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_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_class_support['rss_import'] = array('news','page','links');
$import_default_prefix['rss_import'] = ''; $import_default_prefix['rss_import'] = '';
@ -34,49 +34,26 @@ class rss_import extends base_import_class
// Returns TRUE on success. FALSE on error // Returns TRUE on success. FALSE on error
function setupQuery($task, $blank_user=FALSE) function setupQuery($task, $blank_user=FALSE)
{ {
$this->arrayData = array();
$xml = e107::getXml(); $xml = e107::getXml();
require_once(e_HANDLER."magpie_rss.php"); $file = RSS_IMPORT;
// $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
switch ($task) switch ($task)
{ {
case 'users' :
//$query = "SELECT * FROM {$this->DBPrefix}users WHERE `user_id` != 1";
break;
case 'news' : 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 'page' :
case 'links' :
$array = $xml->loadXMLfile($file,'advanced');
if ($array === FALSE || RSS_IMPORT === FALSE) return FALSE;
if ($result === FALSE) return FALSE; foreach($array['channel']['item'] as $val)
break; {
$this->arrayData[] = $val;
case 'media' : }
break; reset($this->arrayData);
case 'links':
if ($result === FALSE) return FALSE;
break; break;
default : default :
@ -110,56 +87,29 @@ class rss_import extends base_import_class
*/ */
function copyNewsData(&$target, &$source) function copyNewsData(&$target, &$source)
{ {
/* Example: $target['news_title'] = $source['title'][0];
[ID] => 88 // $target['news_sef'] = $source['post_name'];
[post_author] => 1 $target['news_body'] = "[html]".$source['description'][0]."[/html]";
[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_extended'] = ''; // $target['news_extended'] = '';
// $target['news_meta_keywords'] = ''; // $target['news_meta_keywords'] = '';
// $target['news_meta_description'] = ''; // $target['news_meta_description'] = '';
$target['news_datestamp'] = strtotime($source['post_date']); $target['news_datestamp'] = strtotime($source['pubDate'][0]);
$target['news_author'] = $source['post_author']; // $target['news_author'] = $source['post_author'];
// $target['news_category'] = ''; // $target['news_category'] = '';
$target['news_allow_comments'] = ($source['comment_status']=='open') ? 1 : 0; // $target['news_allow_comments'] = ($source['comment_status']=='open') ? 1 : 0;
$target['news_start'] = ''; // $target['news_start'] = '';
$target['news_end'] = ''; // $target['news_end'] = '';
$target['news_class'] = ''; /// $target['news_class'] = '';
$target['news_render_type'] = ''; // $target['news_render_type'] = '';
$target['news_comment_total'] = $source['comment_count']; // $target['news_comment_total'] = $source['comment_count'];
$target['news_summary'] = $source['post_excerpt']; // $target['news_summary'] = $source['post_excerpt'];
$target['news_thumbnail'] = ''; // $target['news_thumbnail'] = '';
$target['news_sticky'] = ''; // $target['news_sticky'] = '';
// return $target; // comment out to debug return $target; // comment out to debug
// DEBUG INFO BELOW. // DEBUG INFO BELOW.
$this->renderDebug($source,$target);
} }
@ -172,33 +122,18 @@ class rss_import extends base_import_class
*/ */
function copyPageData(&$target, &$source) 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_id'] = $source['ID']; // auto increment
$target['page_title'] = $source['post_title']; $target['page_title'] = $source['title'][0];
$target['page_sef'] = $source['post_name']; // $target['page_sef'] = $source['post_name'];
$target['page_text'] = "[html]".$source['post_content']."[/html]"; $target['page_text'] = "[html]".$source['description'][0]."[/html]";
$target['page_metakeys'] = ''; // $target['page_metakeys'] = '';
$target['page_metadscr'] = ''; // $target['page_metadscr'] = '';
$target['page_datestamp'] = strtotime($source['post_date']); $target['page_datestamp'] = strtotime($source['pubDate'][0]);
$target['page_author'] = $source['post_author']; // $target['page_author'] = $source['post_author'];
// $target['page_category'] = '', // $target['page_category'] = '',
$target['page_comment_flag'] = ($source['comment_status']=='open') ? 1 : 0; // $target['page_comment_flag'] = ($source['comment_status']=='open') ? 1 : 0;
$target['page_password'] = $source['post_password']; // $target['page_password'] = $source['post_password'];
return $target; // comment out to debug return $target; // comment out to debug
@ -216,52 +151,21 @@ class rss_import extends base_import_class
function copyLinksData(&$target, &$source) function copyLinksData(&$target, &$source)
{ {
$tp = e107::getParser(); $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['page_id'] = $source['ID']; // auto increment
$target['link_name'] = $source['post_title']; $target['link_name'] = $source['title'][0];
$target['link_url'] = $source['post_name']; $target['link_url'] = $source['link'][0];
$target['link_description'] = "[html]".$source['post_content']."[/html]"; // $target['link_description'] = "[html]".$source['post_content']."[/html]";
$target['link_button'] = ''; // $target['link_button'] = '';
$target['link_category'] = ''; // $target['link_category'] = '';
$target['link_order'] = strtotime($source['post_date']); // $target['link_order'] = strtotime($source['post_date']);
$target['link_parent'] = $source['post_author']; // $target['link_parent'] = $source['post_author'];
$target['link_open'] = ''; // $target['link_open'] = '';
$target['link_class'] = ''; // $target['link_class'] = '';
$target['link_sefurl'] = $source['post_password']; // $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); $this->renderDebug($source,$target);
} }
@ -276,7 +180,11 @@ class rss_import extends base_import_class
function renderDebug($source,$target) function renderDebug($source,$target)
{ {
// echo print_a($target);
// return;
echo " echo "
<div style='width:1000px'> <div style='width:1000px'>
<table style='width:100%'> <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_visits'] = $source['user_visits'];
$target['user_class'] = $source['user_class']; $target['user_class'] = $source['user_class'];
$target['user_perms'] = $source['user_perms']; $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_language'] = $source['user_language'];
$target['user_country'] = $source['user_country']; $target['user_country'] = $source['user_country'];
$target['user_location'] = $source['user_location']; $target['user_location'] = $source['user_location'];
@ -199,7 +199,7 @@ class wordpress_import extends base_import_class
// $target['news_id'] = $source['ID']; // $target['news_id'] = $source['ID'];
$target['news_title'] = $source['post_title']; $target['news_title'] = $source['post_title'];
$target['news_sef'] = $source['post_name']; $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_extended'] = '';
// $target['news_meta_keywords'] = ''; // $target['news_meta_keywords'] = '';
// $target['news_meta_description'] = ''; // $target['news_meta_description'] = '';
@ -251,7 +251,7 @@ class wordpress_import extends base_import_class
// $target['page_id'] = $source['ID']; // auto increment // $target['page_id'] = $source['ID']; // auto increment
$target['page_title'] = $source['post_title']; $target['page_title'] = $source['post_title'];
$target['page_sef'] = $source['post_name']; $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_metakeys'] = '';
$target['page_metadscr'] = ''; $target['page_metadscr'] = '';
$target['page_datestamp'] = strtotime($source['post_date']); $target['page_datestamp'] = strtotime($source['post_date']);
@ -306,20 +306,18 @@ class wordpress_import extends base_import_class
link_sefurl link_sefurl
*/ */
$target['link_name'] = $source['link_name'];
// $target['page_id'] = $source['ID']; // auto increment $target['link_url'] = $source['link_url'];
$target['link_name'] = $source['post_title']; $target['link_description'] = (vartrue($source['link_description'])) ? "[html]".$source['link_description']."[/html]" : "";
$target['link_url'] = $source['post_name']; // $target['link_button'] = '';
$target['link_description'] = "[html]".$source['post_content']."[/html]"; // $target['link_category'] = '';
$target['link_button'] = ''; // $target['link_order'] = '';
$target['link_category'] = ''; // $target['link_parent'] = '';
$target['link_order'] = strtotime($source['post_date']); $target['link_open'] = ''; // link_target
$target['link_parent'] = $source['post_author']; $target['link_class'] = ($source['link_visible'] == 'Y') ? '0' : e_UC_MAINADMIN;
$target['link_open'] = ''; // $target['link_sefurl'] = '';
$target['link_class'] = '';
$target['link_sefurl'] = $source['post_password'];
// return $target; // comment out to debug return $target; // comment out to debug
// DEBUG INFO BELOW. // DEBUG INFO BELOW.
$this->renderDebug($source,$target); $this->renderDebug($source,$target);