mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Import plugin - HTML import provider code clean-up
This commit is contained in:
@@ -6,12 +6,6 @@
|
|||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* 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_names['html_import'] = 'HTML';
|
||||||
@@ -87,14 +81,10 @@ class html_import extends base_import_class
|
|||||||
|
|
||||||
function doConversion($data)
|
function doConversion($data)
|
||||||
{
|
{
|
||||||
|
|
||||||
print_a($data);
|
print_a($data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function config()
|
function config()
|
||||||
{
|
{
|
||||||
$var[0]['caption'] = "Website Home-page URL";
|
$var[0]['caption'] = "Website Home-page URL";
|
||||||
@@ -104,8 +94,8 @@ class html_import extends base_import_class
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set up a query for the specified task.
|
// Set up a query for the specified task.
|
||||||
// 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();
|
$this->arrayData = array();
|
||||||
@@ -144,11 +134,7 @@ class html_import extends base_import_class
|
|||||||
$this->copyUserInfo = !$blank_user;
|
$this->copyUserInfo = !$blank_user;
|
||||||
$this->currentTask = $task;
|
$this->currentTask = $task;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function getAll($root = '')
|
private function getAll($root = '')
|
||||||
@@ -156,6 +142,7 @@ class html_import extends base_import_class
|
|||||||
$html = $this->getRawHtml($root);
|
$html = $this->getRawHtml($root);
|
||||||
$pages = $this->findLinks($html);
|
$pages = $this->findLinks($html);
|
||||||
$c = 0;
|
$c = 0;
|
||||||
|
|
||||||
foreach($pages as $url=>$p)
|
foreach($pages as $url=>$p)
|
||||||
{
|
{
|
||||||
// echo "url=".$url;
|
// echo "url=".$url;
|
||||||
@@ -169,7 +156,7 @@ class html_import extends base_import_class
|
|||||||
|
|
||||||
$this->content[$url] = array(
|
$this->content[$url] = array(
|
||||||
'title' => str_replace("\n","",$p['title']),
|
'title' => str_replace("\n","",$p['title']),
|
||||||
// 'raw' => $html,
|
// 'raw' => $html,
|
||||||
'body' => $body
|
'body' => $body
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -187,8 +174,6 @@ class html_import extends base_import_class
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private function previewContent()
|
private function previewContent()
|
||||||
{
|
{
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
@@ -197,8 +182,8 @@ class html_import extends base_import_class
|
|||||||
|
|
||||||
$content = $this->getAll();
|
$content = $this->getAll();
|
||||||
|
|
||||||
|
$text = "
|
||||||
$text = "<form method='post' action='".e_SELF."?import_type=html_import' id='core-import-form'>
|
<form method='post' action='".e_SELF."?import_type=html_import' id='core-import-form'>
|
||||||
<fieldset id='core-import-select-type'>
|
<fieldset id='core-import-select-type'>
|
||||||
<legend class='e-hideme'>".DBLAN_10."</legend>
|
<legend class='e-hideme'>".DBLAN_10."</legend>
|
||||||
<table class='table adminlist'>
|
<table class='table adminlist'>
|
||||||
@@ -220,9 +205,8 @@ class html_import extends base_import_class
|
|||||||
<tbody>\n";
|
<tbody>\n";
|
||||||
|
|
||||||
|
|
||||||
foreach ($content as $key=>$data)
|
foreach($content as $key=>$data)
|
||||||
{
|
{
|
||||||
|
|
||||||
$text .= "<tr>
|
$text .= "<tr>
|
||||||
|
|
||||||
<td>".$data['title']."</td>\n
|
<td>".$data['title']."</td>\n
|
||||||
@@ -240,7 +224,6 @@ class html_import extends base_import_class
|
|||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$text .= "
|
$text .= "
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -254,11 +237,9 @@ class html_import extends base_import_class
|
|||||||
<input type='hidden' name='siteUrl' value='".$this->feedUrl."' />
|
<input type='hidden' name='siteUrl' value='".$this->feedUrl."' />
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>";
|
</form>";
|
||||||
|
|
||||||
$ns->tablerender(LAN_PLUGIN_IMPORT_NAME.SEP.$this->feedUrl,$text);
|
|
||||||
|
|
||||||
|
|
||||||
|
$ns->tablerender(LAN_PLUGIN_IMPORT_NAME.SEP.$this->feedUrl,$text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,9 +266,10 @@ class html_import extends base_import_class
|
|||||||
|
|
||||||
if($this->useTidy)
|
if($this->useTidy)
|
||||||
{
|
{
|
||||||
$tidy = new tidy();
|
$tidy = new tidy();
|
||||||
$options = array("output-xhtml" => true, "clean" => true);
|
$options = array("output-xhtml" => true, "clean" => true);
|
||||||
$parsed = tidy_parse_file(e_TEMP.$local_file,$options);
|
$parsed = tidy_parse_file(e_TEMP.$local_file,$options);
|
||||||
|
|
||||||
return $parsed->value;
|
return $parsed->value;
|
||||||
}
|
}
|
||||||
elseif(!$html = file_get_contents(e_TEMP.$local_file))
|
elseif(!$html = file_get_contents(e_TEMP.$local_file))
|
||||||
@@ -304,14 +286,14 @@ class html_import extends base_import_class
|
|||||||
$doc = new DOMDocument();
|
$doc = new DOMDocument();
|
||||||
$doc->loadHTML($content);
|
$doc->loadHTML($content);
|
||||||
|
|
||||||
$urls = $doc->getElementsByTagName('a');
|
$urls = $doc->getElementsByTagName('a');
|
||||||
$pages = array();
|
$pages = array();
|
||||||
|
|
||||||
foreach ($urls as $u)
|
foreach ($urls as $u)
|
||||||
{
|
{
|
||||||
$title = str_replace("\n","",$u->nodeValue);
|
$title = str_replace("\n","",$u->nodeValue);
|
||||||
$href = $u->attributes->getNamedItem('href')->value;
|
$href = $u->attributes->getNamedItem('href')->value;
|
||||||
$href = ltrim(str_replace($this->feedUrl,"",$href),"/");
|
$href = ltrim(str_replace($this->feedUrl,"",$href),"/");
|
||||||
|
|
||||||
if($type == 'html' && (substr($href,-5,5)=='.html' || substr($href,-4,4)=='.htm'))
|
if($type == 'html' && (substr($href,-5,5)=='.html' || substr($href,-4,4)=='.htm'))
|
||||||
{
|
{
|
||||||
@@ -324,8 +306,6 @@ class html_import extends base_import_class
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
// Internal functions below here
|
// Internal functions below here
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
@@ -381,7 +361,7 @@ class html_import extends base_import_class
|
|||||||
// $target['news_extended'] = '';
|
// $target['news_extended'] = '';
|
||||||
$target['news_meta_keywords'] = implode(",",$keywords);
|
$target['news_meta_keywords'] = implode(",",$keywords);
|
||||||
// $target['news_meta_description'] = '';
|
// $target['news_meta_description'] = '';
|
||||||
$target['news_datestamp'] = strtotime($source['pubDate'][0]);
|
$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;
|
||||||
@@ -395,7 +375,6 @@ class html_import extends base_import_class
|
|||||||
// $target['news_sticky'] = '';
|
// $target['news_sticky'] = '';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $target; // comment out to debug
|
return $target; // comment out to debug
|
||||||
|
|
||||||
$this->renderDebug($source,$target);
|
$this->renderDebug($source,$target);
|
||||||
@@ -491,7 +470,6 @@ class html_import extends base_import_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
|
||||||
|
|
||||||
$this->renderDebug($source,$target);
|
$this->renderDebug($source,$target);
|
||||||
@@ -549,10 +527,6 @@ class html_import extends base_import_class
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function renderDebug($source,$target)
|
function renderDebug($source,$target)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user