1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 06:38:00 +02:00

e_TEMP added for system temp folder. Import options added for LiveJournal and html (non-CMS) pages. (work in progress)

This commit is contained in:
CaMer0n
2012-08-06 08:55:51 +00:00
parent c7c9bfe517
commit e660ed3a43
12 changed files with 680 additions and 31 deletions

View File

@@ -30,18 +30,18 @@ if(e_AJAX_REQUEST && isset($_GET['src'])) // Ajax
$localfile = md5($remotefile.time()).".zip"; $localfile = md5($remotefile.time()).".zip";
$status = "Downloading..."; $status = "Downloading...";
e107::getFile()->getRemoteFile($remotefile,"temp/".$localfile); e107::getFile()->getRemoteFile($remotefile,$localfile);
if(!file_exists(e_UPLOAD.$localfile)) if(!file_exists(e_TEMP.$localfile))
{ {
echo 'There was a problem retrieving the file'; echo 'There was a problem retrieving the file';
exit; exit;
} }
// chmod(e_PLUGIN,0777); // chmod(e_PLUGIN,0777);
chmod(e_UPLOAD.$localfile,0755); chmod(e_TEMP.$localfile,0755);
require_once(e_HANDLER."pclzip.lib.php"); require_once(e_HANDLER."pclzip.lib.php");
$archive = new PclZip(e_UPLOAD.$localfile); $archive = new PclZip(e_TEMP.$localfile);
$unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0755)); $unarc = ($fileList = $archive -> extract(PCLZIP_OPT_PATH, e_PLUGIN, PCLZIP_OPT_SET_CHMOD, 0755));
// chmod(e_PLUGIN,0755); // chmod(e_PLUGIN,0755);
$dir = basename($unarc[0]['filename']); $dir = basename($unarc[0]['filename']);
@@ -83,7 +83,7 @@ if(e_AJAX_REQUEST && isset($_GET['src'])) // Ajax
} }
echo $status; echo $status;
@unlink(e_UPLOAD.$localfile); // @unlink(e_TEMP.$localfile);
// echo "file=".$file; // echo "file=".$file;
exit; exit;

View File

@@ -1052,7 +1052,10 @@ function update_706_to_800($type='')
{ {
mkdir(e_CACHE_URL,0755); mkdir(e_CACHE_URL,0755);
} }
if(!is_dir(e_TEMP))
{
mkdir(e_TEMP,0755);
}
$root_media = str_replace(basename(e_MEDIA)."/","",e_MEDIA); $root_media = str_replace(basename(e_MEDIA)."/","",e_MEDIA);
$user_media_dirs = array("images","avatars","files","temp","videos","icons"); $user_media_dirs = array("images","avatars","files","temp","videos","icons");

View File

@@ -453,8 +453,8 @@ $(document).ready(function()
var target = $(this).attr("data-target"); // support for input buttons etc. var target = $(this).attr("data-target"); // support for input buttons etc.
var loading = $(this).attr('data-loading'); // image to show loading. var loading = $(this).attr('data-loading'); // image to show loading.
var nav = $(this).attr('data-nav-inc'); var nav = $(this).attr('data-nav-inc');
if(nav !== null) if(nav != null)
{ {
eNav(this,'.e-ajax'); //modify data-src value for next/prev. 'from=' eNav(this,'.e-ajax'); //modify data-src value for next/prev. 'from='
} }

View File

@@ -448,7 +448,7 @@ class e107
$ret['LOGS_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'logs/'; $ret['LOGS_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'logs/';
$ret['BACKUP_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'backup/'; $ret['BACKUP_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'backup/';
$ret['TEMP_DIRECTORY'] = $ret['SYSTEM_DIRECTORY'].'temp/';
//TODO create directories which don't exist. //TODO create directories which don't exist.
return $ret; return $ret;
@@ -2578,6 +2578,7 @@ class e107
define('e_LOG', $this->get_override_rel('LOGS')); define('e_LOG', $this->get_override_rel('LOGS'));
define('e_BACKUP', $this->get_override_rel('BACKUP')); define('e_BACKUP', $this->get_override_rel('BACKUP'));
define('e_TEMP', $this->get_override_rel('TEMP'));
// //
// HTTP absolute paths // HTTP absolute paths

View File

@@ -290,9 +290,11 @@ class e_file
} }
// Grab a remote file and save it in the /temp directory. requires CURL // Grab a remote file and save it in the /temp directory. requires CURL
function getRemoteFile($remote_url, $local_file) function getRemoteFile($remote_url, $local_file, $type='temp')
{ {
$fp = fopen(e_MEDIA.$local_file, 'w'); // media-directory is the root. $path = ($type == 'media') ? e_MEDIA : e_TEMP;
$fp = fopen($path.$local_file, 'w'); // media-directory is the root.
$cp = curl_init($remote_url); $cp = curl_init($remote_url);
curl_setopt($cp, CURLOPT_FILE, $fp); curl_setopt($cp, CURLOPT_FILE, $fp);

View File

@@ -319,7 +319,7 @@ function dbImport($mode='db')
} }
else else
{ {
$mes->addError(LAN_CONVERT_42); $mes->addError(LAN_CONVERT_42. "[".$current_db_type."]");
return false; return false;
} }
@@ -339,6 +339,13 @@ function dbImport($mode='db')
} }
} }
if(!is_array($db_import_blocks))
{
$mes->addError("No areas selected for import"); // db connect failed
return false;
}
foreach ($db_import_blocks as $k => $v) foreach ($db_import_blocks as $k => $v)
{ {
@@ -408,6 +415,16 @@ function dbImport($mode='db')
array($loopCounter,$loopCounter-$errorCounter,$errorCounter, $k),LAN_CONVERT_47); array($loopCounter,$loopCounter-$errorCounter,$errorCounter, $k),LAN_CONVERT_47);
$mes->addSuccess($msg); // couldn't set query $mes->addSuccess($msg); // couldn't set query
} }
else
{
$mes->addDebug("Error: _POST['import_block_{$k}'] = ".$_POST['import_block_{$k}']); // cou
}
}
else
{
$mes->addDebug("\$db_blocks_to_import doesn't contain key: ".$k); // cou
} }
} }
@@ -534,13 +551,17 @@ function showImportOptions($mode='csv')
{ {
$mes->addDebug("Class Available: ".$mode); $mes->addDebug("Class Available: ".$mode);
$proObj = new $mode; $proObj = new $mode;
if($proObj->init()===FALSE)
{
return;
}
} }
$message = LAN_CONVERT_02."<br /><strong>".LAN_CONVERT_05."</strong>"; $message = LAN_CONVERT_02."<br /><strong>".LAN_CONVERT_05."</strong>";
$emessage->add($message, E_MESSAGE_WARNING); $emessage->add($message, E_MESSAGE_WARNING);
$text = " $text = "
<form method='post' action='".e_SELF."'> <form method='post' action='".e_SELF."?import_type=".$_GET['import_type']."'>
<table class='adminform'> <table class='adminform'>
<colgroup> <colgroup>
<col class='col-label' /> <col class='col-label' />
@@ -608,15 +629,15 @@ function showImportOptions($mode='csv')
</tr> </tr>
<tr> <tr>
<td >$importType ".LAN_CONVERT_20."</td> <td >$importType ".LAN_CONVERT_20."</td>
<td ><input class='tbox' type='text' name='dbParamUsername' size='30' value='".$_POST['dbParamUsername']."' maxlength='100' /></td> <td ><input class='tbox' type='text' name='dbParamUsername' size='30' value='".varset($_POST['dbParamUsername'])."' maxlength='100' /></td>
</tr> </tr>
<tr> <tr>
<td >$importType ".LAN_CONVERT_21."</td> <td >$importType ".LAN_CONVERT_21."</td>
<td ><input class='tbox' type='text' name='dbParamPassword' size='30' value='".$_POST['dbParamPassword']."' maxlength='100' /></td> <td ><input class='tbox' type='text' name='dbParamPassword' size='30' value='".varset($_POST['dbParamPassword'])."' maxlength='100' /></td>
</tr> </tr>
<tr> <tr>
<td >$importType ".LAN_CONVERT_22."</td> <td >$importType ".LAN_CONVERT_22."</td>
<td ><input class='tbox' type='text' name='dbParamDatabase' size='30' value='".$_POST['dbParamDatabase']."' maxlength='100' /></td> <td ><input class='tbox' type='text' name='dbParamDatabase' size='30' value='".varset($_POST['dbParamDatabase'])."' maxlength='100' /></td>
</tr> </tr>
<tr> <tr>
<td >$importType ".LAN_CONVERT_23."</td> <td >$importType ".LAN_CONVERT_23."</td>
@@ -648,16 +669,22 @@ function showImportOptions($mode='csv')
$text .= "<tr><td>".LAN_CONVERT_38."</td> $text .= "<tr><td>".LAN_CONVERT_38."</td>
<td><input type='checkbox' name='import_delete_existing_data' value='1'".($import_delete_existing_data ? " checked='checked'" : '')."/> <td><input type='checkbox' name='import_delete_existing_data' value='1'".(varset($_POST['import_delete_existing_data']) ? " checked='checked'" : '')."/>
<span class='smallblacktext'>".LAN_CONVERT_39."</span></td> <span class='smallblacktext'>".LAN_CONVERT_39."</span></td>
</tr> </tr>";
<tr><td>".LAN_CONVERT_16."</td> if(varset($proObj->defaultClass) !== false)
<td>"; {
$text .= $e_userclass->vetted_tree('classes_select',array($e_userclass,'checkbox'), $checked_class_list,'main,admin,classes,matchclass'); $text .= "
<tr><td>".LAN_CONVERT_16."</td>
$text .= "</td></tr></table> <td>";
<div class='buttons-bar center'>".$frm->admin_button('do_conversion',LAN_CONTINUE, 'execute'). $text .= $e_userclass->vetted_tree('classes_select',array($e_userclass,'checkbox'), varset($_POST['classes_select']),'main,admin,classes,matchclass');
$text .= "</td></tr>";
}
$action = varset($proObj->action,'do_conversion');
$text .= "</table>
<div class='buttons-bar center'>".$frm->admin_button($action,LAN_CONTINUE, 'execute').
$frm->admin_button('back',LAN_CANCEL, 'cancel')." $frm->admin_button('back',LAN_CANCEL, 'cancel')."
<input type='hidden' name='db_import_type' value='$mode' /> <input type='hidden' name='db_import_type' value='$mode' />
@@ -667,9 +694,9 @@ function showImportOptions($mode='csv')
// Now a little bit of JS to initialise some of the display divs etc // Now a little bit of JS to initialise some of the display divs etc
$temp = ''; $temp = '';
if ($import_source) $temp .= "disp('{$import_source}');"; if(varset($import_source)) { $temp .= "disp('{$import_source}');"; }
if ($current_db_type) $temp .= " flagbits('{$current_db_type}');"; if (varset($current_db_type)) $temp .= " flagbits('{$current_db_type}');";
if ($temp) $text .= "<script type=\"text/javascript\"> {$temp}</script>"; if (varset($temp)) $text .= "<script type=\"text/javascript\"> {$temp}</script>";
$ns -> tablerender(LAN_CONVERT_01." :: ".$importType, $emessage->render().$text); $ns -> tablerender(LAN_CONVERT_01." :: ".$importType, $emessage->render().$text);

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@@ -34,7 +34,7 @@ $import_default_prefix['blogger_import'] = '';
class blogger_import extends rss_import class blogger_import extends rss_import
{ {
var $cleanupHtml = false; var $cleanupHtml = false;
var $defaultClass = false;
/* /*
If the first 500 posts of your blog feed are here: If the first 500 posts of your blog feed are here:

View File

@@ -0,0 +1,519 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2009 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/import/wordpress_import_class.php,v $
* $Revision: 11315 $
* $Date: 2010-02-10 10:18:01 -0800 (Wed, 10 Feb 2010) $
* $Author: secretr $
*/
$import_class_names['html_import'] = 'HTML';
$import_class_comment['html_import'] = 'Import content from an html website. eg. created with Frontpage, Dreamweaver or Notepad etc. ';
$import_class_support['html_import'] = array('news','page');
$import_default_prefix['html_import'] = '';
require_once('import_classes.php');
class html_import extends base_import_class
{
var $sourceType = 'rss';
var $feedUrl = null;
var $defaultClass = false;
var $useTidy = true;
var $action = 'preview'; // default action after setup page;
function init()
{
$this->feedUrl = vartrue($_POST['siteUrl'],false);
$this->feedUrl = "http://drboylan.com/";
$this->feedUrl = rtrim($this->feedUrl,"/");
if($_POST['preview'])
{
$this->previewContent();
return false;
}
}
function config()
{
$var[0]['caption'] = "Website Home-page URL";
$var[0]['html'] = "<input class='tbox' type='text' name='siteUrl' size='80' value='{$_POST['rss_feed']}' maxlength='250' />";
return $var;
}
// Set up a query for the specified task.
// Returns TRUE on success. FALSE on error
function setupQuery($task, $blank_user=FALSE)
{
$this->arrayData = array();
print_a($_POST);
$file = $this->feedUrl;
switch ($task)
{
case 'news' :
case 'page' :
case 'links' :
// $rawData = $xml->getRemoteFile($file);
// print_a($rawData);
//$content = $this->getAll();
if ($array === FALSE || $file === FALSE) return FALSE;
foreach($array['channel']['item'] as $val)
{
$this->arrayData[] = $val;
}
$this->arrayData = array_reverse($this->arrayData); // most recent last.
reset($this->arrayData);
break;
default :
return FALSE;
}
$this->copyUserInfo = !$blank_user;
$this->currentTask = $task;
return TRUE;
}
private function getAll()
{
$html = $this->getRawHtml();
$pages = $this->findLinks($html);
$c = 0;
foreach($pages as $url=>$p)
{
// echo "url=".$url;
$html = $this->getRawHtml($url);
$html = str_replace("\n","",$html); // strip line-breaks.
$html = preg_replace("/<title>([^<]*)<\/title>/i","",$html);
$html = trim($html,"\n");
$body = trim(strip_tags($html,"<b><i><u><strong><br><img><object><embed>"));
$content[$url] = array(
'title' => str_replace("\n","",$p['title']),
// 'raw' => $html,
'body' => $body
);
$c++;
if($c == 15)
{
break;
}
}
return $content;
}
private function previewContent()
{
$frm = e107::getForm();
$ns = e107::getRender();
$tp = e107::getParser();
$content = $this->getAll();
$text = "<form method='post' action='".e_SELF."?import_type=html_import' id='core-import-form'>
<fieldset id='core-import-select-type'>
<legend class='e-hideme'>".DBLAN_10."</legend>
<table class='adminlist'>
<colgroup>
<col style='width:40%' />
<col />
<col />
<col />
</colgroup>
<thead>
<tr>
<th>".LAN_TITLE."</th>
<th>Sample</th>
<th>".LAN_URL."</th>
<th class='center'>".LAN_OPTIONS."</th>
</tr>
</thead>
<tbody>\n";
foreach ($content as $key=>$data)
{
$text .= "<tr>
<td>".$data['title']."</td>\n
<td>".$tp->text_truncate($data['body'],150)."</td>\n
<td class='center middle'>
".$key."
</td>
";
$text .= "
<td class='center middle'>
".$frm->selectbox('import_'.$key,array('news'=>'News','page'=>'Page','0'=>'Ignore'))."
</td>
</tr>";
}
$text .= "
</tbody>
</table>
<div class='buttons-bar center'>
".$frm->admin_button('do_conversion',LAN_CONTINUE, 'execute').
$frm->admin_button('back',LAN_CANCEL, 'cancel')."
<input type='hidden' name='db_import_type' value='html_import' />
<input type='hidden' name='import_type' value='html_import' />
<input type='hidden' name='import_source' value='".$this->sourceType."' />
<input type='hidden' name='import_block_news' value='1' />
<input type='hidden' name='siteUrl' value='".$this->feedUrl."' />
</div>
</fieldset>
</form>";
$ns->tablerender(LAN_CONVERT_01,$text);
}
private function getRawHtml($file='')
{
$url = $this->feedUrl."/".$file;
if($file == '') { $file = "index.html"; } // just for local file, not url.
$path = md5($this->feedUrl);
$local_file = $path."/".$file;
if(!is_dir(e_TEMP.$path))
{
mkdir(e_TEMP.$path,0755);
}
if(!file_exists(e_TEMP.$local_file))
{
e107::getFile()->getRemoteFile($url, $local_file); // downloads to e107_system/.../temp
}
if($this->useTidy)
{
$tidy = new tidy();
$options = array("output-xhtml" => true, "clean" => true);
$parsed = tidy_parse_file(e_TEMP.$local_file,$options);
return $parsed->value;
}
elseif(!$html = file_get_contents(e_TEMP.$local_file))
{
return "Couldn't read file";
}
return $html;
}
private function findLinks($content,$type='html')
{
$doc = new DOMDocument();
$doc->loadHTML($content);
$urls = $doc->getElementsByTagName('a');
$pages = array();
foreach ($urls as $u)
{
$title = str_replace("\n","",$u->nodeValue);
$href = $u->attributes->getNamedItem('href')->value;
$href = ltrim(str_replace($this->feedUrl,"",$href),"/");
if($type == 'html' && (substr($href,-5,5)=='.html' || substr($href,-4,4)=='.htm'))
{
$pages[$href] = array('title'=>$title, 'href'=>$href);
}
}
return $pages;
}
//------------------------------------
// Internal functions below here
//------------------------------------
/**
* Align source data to e107 User Table
* @param $target array - default e107 target values for e107_user table.
* @param $source array - WordPress table data
*/
function copyUserData(&$target, &$source)
{
}
/**
* Align source data with e107 News Table
* @param $target array - default e107 target values for e107_news table.
* @param $source array - RSS data
*/
function copyNewsData(&$target, &$source)
{
if(!$content = $this->process('content_encoded',$source))
{
$body = $this->process('description',$source);
}
else
{
$body = $content;
}
$body = $this->saveImages($body,'news');
$keywords = $this->process('category',$source);
if(!vartrue($source['title'][0]))
{
list($title,$newbody) = explode("<br />",$body,2);
$title = strip_tags($title);
if(trim($newbody)!='')
{
$body = $newbody;
}
}
else
{
$title = $source['title'][0];
}
$target['news_title'] = $title;
// $target['news_sef'] = $source['post_name'];
$target['news_body'] = "[html]".$body."[/html]";
// $target['news_extended'] = '';
$target['news_meta_keywords'] = implode(",",$keywords);
// $target['news_meta_description'] = '';
$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'] = '';
return $target; // comment out to debug
$this->renderDebug($source,$target);
// DEBUG INFO BELOW.
}
function process($type='description',$source)
{
switch ($type)
{
case 'category':
$keywords = array();
if(is_array(varset($source['category'][0])))
{
foreach($source['category'] as $val)
{
if(varset($val['@value']))
{
$keywords[] = $val['@value'];
}
}
return $keywords;
}
elseif(is_array(varset($source['category'])))
{
foreach($source['category'] as $val)
{
if(varset($val) && is_string($val))
{
$keywords[] = $val;
}
}
return $keywords;
}
break;
default:
return varset($source[$type][0]);
break;
}
}
/**
* Align source data to e107 Page Table
* @param $target array - default e107 target values for e107_page table.
* @param $source array - WordPress table data
*/
function copyPageData(&$target, &$source)
{
$body = $this->saveImages($source['description'][0],'page');
// $target['page_id'] = $source['ID']; // auto increment
$target['page_title'] = $source['title'][0];
// $target['page_sef'] = $source['post_name'];
$target['page_text'] = "[html]".$body."[/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'];
return $target; // comment out to debug
// DEBUG INFO BELOW.
$this->renderDebug($source,$target);
}
/**
* Align source data to e107 Links Table
* @param $target array - default e107 target values for e107_links table.
* @param $source array - WordPress table data
*/
function copyLinksData(&$target, &$source)
{
$tp = e107::getParser();
// $target['page_id'] = $source['ID']; // auto increment
$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
$this->renderDebug($source,$target);
}
/** Download and Import remote images and update body text with local relative-links. eg. {e_MEDIA}
* @param returns text-body with remote links replaced with local ones for the images downloaded.
*/
function saveImages($body,$cat='news')
{
$mes = e107::getMessage();
$med = e107::getMedia();
$tp = e107::getParser();
$search = array();
$replace = array();
// echo htmlentities($body);
preg_match_all("/(((http:\/\/www)|(http:\/\/)|(www))[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)\.(jpg|jpeg|gif|png|svg)/im",$body,$matches);
$fl = e107::getFile();
if(is_array($matches[0]))
{
$relPath = 'images/'.md5($this->feedUrl);
if(!is_dir(e_MEDIA.$relPath))
{
mkdir(e_MEDIA.$relPath,'0755');
}
foreach($matches[0] as $link)
{
if(file_exists($relPath."/".$filename))
{
continue;
}
$filename = basename($link);
$fl->getRemoteFile($link,$relPath."/".$filename);
$search[] = $link;
$replace[] = $tp->createConstants(e_MEDIA.$relPath."/".$filename,1);
}
}
if(count($search))
{
$med->import($cat,e_MEDIA.$relPath);
}
return str_replace($search,$replace,$body);
}
function renderDebug($source,$target)
{
// echo print_a($target);
// return;
echo "
<div style='width:1000px'>
<table style='width:100%'>
<tr>
<td style='width:500px;padding:10px'>".print_a($source,TRUE)."</td>
<td style='border-left:1px solid black;padding:10px'>".print_a($target,TRUE)."</td>
</tr>
</table>
</div>";
}
}
?>

View File

@@ -0,0 +1,96 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/import/wordpress_import_class.php,v $
* $Revision: 11315 $
* $Date: 2010-02-10 10:18:01 -0800 (Wed, 10 Feb 2010) $
* $Author: secretr $
*/
// require_once('import_classes.php');
require_once('rss_import_class.php');
$import_class_names['livejournal_import'] = 'LiveJournal';
$import_class_comment['livejournal_import'] = 'Import up to 500 items from yourblog.livejournal.com';
$import_class_support['livejournal_import'] = array('news');
$import_default_prefix['livejournal_import'] = '';
class livejournal_import extends rss_import
{
var $cleanupHtml = false;
var $defaultClass = false;
/*
*/
function init()
{
$mes = e107::getMessage();
if(vartrue($_POST['siteUrl']))
{
$domain = preg_replace("/https?:\/\//i",'',$_POST['siteUrl']);
list($site,$dom,$tld) = explode(".",$domain);
$this->feedUrl = "http://".$site.".livejournal.com/data/rss";
}
if(vartrue($_POST['siteCleanup']))
{
$this->cleanupHtml = true;
}
$mes->addDebug("LiveJournal Feed:".$this->feedUrl);
}
function config()
{
$var[0]['caption'] = "Your LiveJournal URL";
$var[0]['html'] = "<input class='tbox' type='text' name='siteUrl' size='80' value='{$_POST['bloggerUrl']}' maxlength='250' />";
$var[0]['help'] = "eg. http://blogname.livejournal.com";
$var[1]['caption'] = "Cleanup HTML in content";
$var[1]['html'] = "<input class='tbox' type='checkbox' name='siteCleanup' size='80' value='1' />";
$var[1]['help'] = "Tick to enable";
return $var;
}
function process($type,$source)
{
switch ($type)
{
case 'description':
$body = $source[$type][0];
if($this->cleanupHtml == TRUE)
{
$body = preg_replace("/font-family: [\w]*;/i","", $body);
$body = preg_replace('/class="[\w]*" /i',"", $body);
$body = str_replace("<br>","<br />",$body);
return $body;
}
else
{
return $body;
}
break;
default:
return $source[$type][0];
break;
}
}
//TODO Comment Import:
}
?>

View File

@@ -32,6 +32,7 @@ class rss_import extends base_import_class
{ {
var $sourceType = 'rss'; var $sourceType = 'rss';
var $feedUrl = null; var $feedUrl = null;
var $defaultClass = false;
function init() function init()
{ {
@@ -104,7 +105,7 @@ class rss_import extends base_import_class
/** /**
* Align source data with e107 News Table * Align source data with e107 News Table
* @param $target array - default e107 target values for e107_news table. * @param $target array - default e107 target values for e107_news table.
* @param $source array - WordPress table data * @param $source array - RSS data
*/ */
function copyNewsData(&$target, &$source) function copyNewsData(&$target, &$source)
{ {
@@ -293,7 +294,7 @@ class rss_import extends base_import_class
} }
$filename = basename($link); $filename = basename($link);
$fl->getRemoteFile($link,$relPath."/".$filename); $fl->getRemoteFile($link,$relPath."/".$filename,'media');
$search[] = $link; $search[] = $link;
$replace[] = $tp->createConstants(e_MEDIA.$relPath."/".$filename,1); $replace[] = $tp->createConstants(e_MEDIA.$relPath."/".$filename,1);
} }