1
0
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:
Tijn Kuyper
2019-11-26 10:17:55 +01:00
parent 9102e275d4
commit e45a358a3a

View File

@@ -6,12 +6,6 @@
* 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';
@@ -87,14 +81,10 @@ class html_import extends base_import_class
function doConversion($data)
{
print_a($data);
print_a($data);
}
function config()
{
$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.
// Returns TRUE on success. FALSE on error
// Set up a query for the specified task.
// Returns TRUE on success. FALSE on error
function setupQuery($task, $blank_user=FALSE)
{
$this->arrayData = array();
@@ -144,18 +134,15 @@ class html_import extends base_import_class
$this->copyUserInfo = !$blank_user;
$this->currentTask = $task;
return TRUE;
}
}
private function getAll($root = '')
{
$html = $this->getRawHtml($root);
$pages = $this->findLinks($html);
$c = 0;
foreach($pages as $url=>$p)
{
// echo "url=".$url;
@@ -169,7 +156,7 @@ class html_import extends base_import_class
$this->content[$url] = array(
'title' => str_replace("\n","",$p['title']),
// 'raw' => $html,
// 'raw' => $html,
'body' => $body
);
@@ -186,8 +173,6 @@ class html_import extends base_import_class
}
private function previewContent()
{
@@ -197,8 +182,8 @@ class html_import extends base_import_class
$content = $this->getAll();
$text = "<form method='post' action='".e_SELF."?import_type=html_import' id='core-import-form'>
$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='table adminlist'>
@@ -220,9 +205,8 @@ class html_import extends base_import_class
<tbody>\n";
foreach ($content as $key=>$data)
foreach($content as $key=>$data)
{
$text .= "<tr>
<td>".$data['title']."</td>\n
@@ -240,7 +224,6 @@ class html_import extends base_import_class
</tr>";
}
$text .= "
</tbody>
</table>
@@ -254,12 +237,10 @@ class html_import extends base_import_class
<input type='hidden' name='siteUrl' value='".$this->feedUrl."' />
</div>
</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)
{
$tidy = new tidy();
$options = array("output-xhtml" => true, "clean" => true);
$parsed = tidy_parse_file(e_TEMP.$local_file,$options);
$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))
@@ -304,14 +286,14 @@ class html_import extends base_import_class
$doc = new DOMDocument();
$doc->loadHTML($content);
$urls = $doc->getElementsByTagName('a');
$pages = array();
$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),"/");
$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'))
{
@@ -324,8 +306,6 @@ class html_import extends base_import_class
}
//------------------------------------
// Internal functions below here
//------------------------------------
@@ -381,7 +361,7 @@ class html_import extends base_import_class
// $target['news_extended'] = '';
$target['news_meta_keywords'] = implode(",",$keywords);
// $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_category'] = '';
// $target['news_allow_comments'] = ($source['comment_status']=='open') ? 1 : 0;
@@ -395,7 +375,6 @@ class html_import extends base_import_class
// $target['news_sticky'] = '';
return $target; // comment out to debug
$this->renderDebug($source,$target);
@@ -491,7 +470,6 @@ class html_import extends base_import_class
// $target['link_sefurl'] = $source['post_password'];
return $target; // comment out to debug
$this->renderDebug($source,$target);
@@ -549,10 +527,6 @@ class html_import extends base_import_class
function renderDebug($source,$target)
{