From d5a3b29340ec60dd854ff0871fabc9c90a0834fe Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Mon, 23 Jul 2012 02:25:17 +0000 Subject: [PATCH] Blogger Import added. TinyMce Image fixes. Custom-pages fixes. Moved Upload-js out of admin header and into media-manager page only. Parser fixes for [html] bbcode. XML parser fix for rss tags. --- e107_admin/cpage.php | 8 +- e107_admin/header.php | 12 +- e107_admin/image.php | 6 +- e107_admin/plugin.php | 2 +- e107_core/bbcodes/html.bb | 4 +- e107_files/jslib/core/admin.jquery.js | 58 ------- e107_files/jslib/core/mediaManager.js | 87 +++++++++- e107_handlers/bbcode_handler.php | 38 +++- e107_handlers/e_parse_class.php | 12 +- e107_handlers/file_class.php | 9 +- e107_handlers/media_class.php | 2 +- e107_handlers/xml_class.php | 11 +- e107_plugins/import/admin_import.php | 77 ++++++--- e107_plugins/import/images/blogger.png | Bin 0 -> 2263 bytes e107_plugins/import/import_classes.php | 6 + .../import/providers/blogger_import_class.php | 112 ++++++++++++ .../import/providers/rss_import_class.php | 162 ++++++++++++++++-- .../tinymce/plugins/e107bbcode/parser.php | 2 +- 18 files changed, 475 insertions(+), 133 deletions(-) create mode 100644 e107_plugins/import/images/blogger.png create mode 100644 e107_plugins/import/providers/blogger_import_class.php diff --git a/e107_admin/cpage.php b/e107_admin/cpage.php index 2332bc988..a8b9b383b 100644 --- a/e107_admin/cpage.php +++ b/e107_admin/cpage.php @@ -299,7 +299,9 @@ class page_admin_ui extends e_admin_ui echo $text; exit; // return $text; - + /* +
+ */ } @@ -717,7 +719,7 @@ class page_admin_ui extends e_admin_ui $newData = ""; foreach($_POST as $k=>$v) { - if(substr($k,0,4)=='data') + if(substr($k,0,4)=='data' && trim($v)!='') { list($tm,$key) = explode("_",$k); @@ -728,7 +730,7 @@ class page_admin_ui extends e_admin_ui // return; } - // echo $newData; + // echo nl2br($newData); $page_text = $tp->toDB($newData); $pauthor = ($_POST['page_display_authordate_flag'] ? USERID : 0); // Ideally, this check should be done in the front-end. diff --git a/e107_admin/header.php b/e107_admin/header.php index 4f4922628..8645f81e2 100644 --- a/e107_admin/header.php +++ b/e107_admin/header.php @@ -29,15 +29,12 @@ e107::getDb()->db_Mark_Time('(Header Top)'); e107::js('core', 'colorbox/jquery.colorbox-min.js', 'jquery', 2); e107::css('core', 'colorbox/colorbox.css', 'jquery'); -// e107::js('core', 'fancybox/jquery.fancybox-1.3.4.js', 'jquery', 2); -// e107::css('core', 'fancybox/jquery.fancybox-1.3.4.css', 'jquery'); - e107::js('core', 'jquery.elastic.js', 'jquery', 2); e107::js('core', 'jquery-ui-timepicker-addon.js', 'jquery', 2); -e107::js('core', 'plupload/plupload.full.js', 'jquery', 2); -e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery'); -e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2); +//e107::js('core', 'plupload/plupload.full.js', 'jquery', 2); +//e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery'); +//e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2); e107::css('core', 'chosen/chosen.css', 'jquery'); e107::js('core', 'chosen/chosen.jquery.min.js', 'jquery', 2); @@ -46,13 +43,12 @@ e107::css('core', 'password/style.css', 'jquery'); e107::js('core', 'password/jquery.pwdMeter.js', 'jquery', 2); -e107::js("core", "core/mediaManager.js","jquery",3); +// e107::js("core", "core/mediaManager.js","jquery",3); e107::js("core", "tooltip/jquery.tipsy.js","jquery",3); e107::css('core', 'tooltip/tipsy.css', 'jquery'); e107::js("core", "tags/jquery.tagit.js","jquery",3); e107::css('core', 'tags/jquery.tagit.css', 'jquery'); -// e107::js("core", "tooltip/jquery.qtip-1.0.0-rc3.min.js","jquery",3); e107::css('core', 'core/admin.jquery.css', 'jquery'); diff --git a/e107_admin/image.php b/e107_admin/image.php index d061a60a5..cf240a1d4 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -24,6 +24,10 @@ if (!getperms("A") && ($_GET['action'] != 'dialog')) exit; } +e107::js('core', 'plupload/plupload.full.js', 'jquery', 2); +e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery'); +e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2); +e107::js("core", "core/mediaManager.js","jquery",3); /* * CLOSE - GO TO MAIN SCREEN @@ -670,7 +674,7 @@ class media_admin_ui extends e_admin_ui { $frm = e107::getForm(); $bbcodeMode = ($this->getQuery('bbcode')=='img') ? 'bbcode=img' : FALSE; - + $text = "
    diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index 0beb56234..46ddcb9a5 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -30,7 +30,7 @@ if(e_AJAX_REQUEST && isset($_GET['src'])) // Ajax $localfile = md5($remotefile.time()).".zip"; $status = "Downloading..."; - e107::getFile()->getRemoteFile($remotefile,$localfile); + e107::getFile()->getRemoteFile($remotefile,"temp/".$localfile); if(!file_exists(e_UPLOAD.$localfile)) { diff --git a/e107_core/bbcodes/html.bb b/e107_core/bbcodes/html.bb index c4dbdc05d..a75debb42 100644 --- a/e107_core/bbcodes/html.bb +++ b/e107_core/bbcodes/html.bb @@ -1,3 +1,5 @@ +//".$code_text.""; diff --git a/e107_files/jslib/core/admin.jquery.js b/e107_files/jslib/core/admin.jquery.js index 6eab12d80..6ca2650ff 100644 --- a/e107_files/jslib/core/admin.jquery.js +++ b/e107_files/jslib/core/admin.jquery.js @@ -392,65 +392,7 @@ $(document).ready(function() - // ----------------- Upload -------------------------------------- - - var upath = $("#uploader").attr("rel"); - $("#uploader").pluploadQueue({ - // General settings - runtimes : "html5,html4", - url : upath, - max_file_size : "10mb", - chunk_size : "1mb", - unique_names : false, - - // Resize images on clientside if we can - // resize : {width : 320, height : 240, quality : 90}, - - // Specify what files to browse for - filters : [ - {title : "Image files", extensions : "jpg,gif,png,jpeg"}, - {title : "Zip files", extensions : "zip,gz"} - ], - preinit : { - Init: function(up, info) { - //log('[Init]', 'Info:', info, 'Features:', up.features); - } - }, - init : { - - FilesAdded: function(up, files) { - - }, - FileUploaded: function(up, file, info) { // Called when a file has finished uploading - //log('[FileUploaded] File:', file, "Info:", info); - }, - UploadProgress: function(up, file) { // Called while a file is being uploaded - - // console.log(up.total); - // console.log('[UploadProgress]', 'File:', file, "Total:", up.total); - }, - UploadComplete: function(up, files){ - document.location.reload(); // refresh the page. - - }, - ChunkUploaded: function(up, file, info) { // Called when a file chunk has finished uploading - - //log('[ChunkUploaded] File:', file, "Info:", info); - // console.log(info); - }, - Error: function(up, args) { // Called when a error has occured - alert('There was an error'); - // console.log(args); - } - - } - }); - - - // ----------------------------------------------------------------- - - diff --git a/e107_files/jslib/core/mediaManager.js b/e107_files/jslib/core/mediaManager.js index 002c2771c..a7475c088 100644 --- a/e107_files/jslib/core/mediaManager.js +++ b/e107_files/jslib/core/mediaManager.js @@ -31,7 +31,7 @@ $(document).ready(function() { var style = ''; var bb = ''; - + var target = $(e).attr('data-target'); // var path = $(e).attr('data-path'); // var preview = $(e).attr('data-preview'); @@ -129,8 +129,14 @@ $(document).ready(function() // $('textarea#' + target, window.top.document).attr('value',bbpath); } + // if(bbcode == 'wysiwyg') + { + //alert('hello'); + } + if(bbcode == "img") { + // bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']'; //alert(bbpath); } @@ -144,17 +150,86 @@ $(document).ready(function() $('img#' + target + "_prev", window.top.document).attr('src',preview); // set new value $('div#' + target + "_prev", window.top.document).html(preview); // set new value $('span#' + target + "_prev", window.top.document).html(preview); // set new value - + // see $frm->filepicker() - $('input#' + target , window.top.document).attr('value',path); // set new value - - eMediaAttribute(this); + if(target !='') + { + $('input#' + target , window.top.document).attr('value',path); // set new value + } + eMediaAttribute(this); + // $(this).parent('#src').attr('value',preview); // set new value // $(this).parent('#preview').attr('src',preview); // set new value return false; - }); + }); + + + + // ----------------- Upload -------------------------------------- + + var upath = $("#uploader").attr("rel"); + + $("#uploader").pluploadQueue({ + // General settings + runtimes : "html5,html4", + url : upath, + max_file_size : "10mb", + chunk_size : "1mb", + unique_names : false, + + // Resize images on clientside if we can + // resize : {width : 320, height : 240, quality : 90}, + + // Specify what files to browse for + filters : [ + {title : "Image files", extensions : "jpg,gif,png,jpeg"}, + {title : "Zip files", extensions : "zip,gz"} + ], + preinit : { + Init: function(up, info) { + //log('[Init]', 'Info:', info, 'Features:', up.features); + } + }, + init : { + + FilesAdded: function(up, files) { + + }, + FileUploaded: function(up, file, info) { // Called when a file has finished uploading + //log('[FileUploaded] File:', file, "Info:", info); + }, + UploadProgress: function(up, file) { // Called while a file is being uploaded + + // console.log(up.total); + // console.log('[UploadProgress]', 'File:', file, "Total:", up.total); + }, + UploadComplete: function(up, files){ + document.location.reload(); // refresh the page. + + }, + ChunkUploaded: function(up, file, info) { // Called when a file chunk has finished uploading + + //log('[ChunkUploaded] File:', file, "Info:", info); + // console.log(info); + }, + Error: function(up, args) { // Called when a error has occured + alert('There was an error'); + // console.log(args); + } + + } + }); + + + // ----------------------------------------------------------------- + + + + + + }); \ No newline at end of file diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index dadf31de0..b4ed7c69b 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -111,7 +111,7 @@ class e_bbcode $strip_array = explode(',',$bbStrip); if ($strip_array[0] == 'PRE') { - $this->preProcess = TRUE; + $this->preProcess = "toDB"; unset($strip_array[0]); if (count($strip_array) == 0) { @@ -124,6 +124,9 @@ class e_bbcode } } + + + $pattern = '#^\[(/?)([A-Za-z_]+)(\d*)([=:]?)(.*?)]$#i'; // Pattern to split up bbcodes // $matches[0] - same as the input text // $matches[1] - '/' for a closing tag. Otherwise empty string @@ -352,14 +355,18 @@ class e_bbcode if (is_object($this->bbList[$code])) { - if ($this->preProcess) + if ($this->preProcess == 'toDB') { //echo "Preprocess: ".htmlspecialchars($code_text).", params: {$param1}
    "; return $this->bbList[$code]->bbPreSave($code_text, $param1); } + if($this->preProcess == 'toWYSIWYG')//XXX FixMe NOT working - messes with default toHTML behavior. + { + // return $this->bbList[$code]->bbWYSIWYG($code_text, $param1); + } return $this->bbList[$code]->bbPreDisplay($code_text, $param1); } - if ($this->preProcess) return $full_text; // No change + if ($this->preProcess == 'toDB') return $full_text; // No change /** * @todo - capturing output deprecated @@ -536,7 +543,13 @@ class e_bbcode */ function htmltoBBcode($text) { - + $text = str_replace("","[html]",$text); + $text = str_replace("","[/html]",$text); + + if(substr($text,0,6)=='[html]') + { + return $text; + } $text = preg_replace("/(.*?)<\/a>/i","[file=$2]$3[/file]",$text); @@ -678,6 +691,23 @@ class e_bb_base // Could add logging, security in here return $this->toHTML($code_text, $parm); } + + + /** + * Process bbcode prior to display in WYSIWYG + * Functionally this routine does exactly the same as the existing bbcodes + * Parameters passed by reference to minimise memory use + * + * @param string $code_text - text between the bbcode tags + * @param string $parm - any parameters specified for the bbcode + * + * @return string with $code_text transformed into displayable XHTML as necessary + */ + final public function bbWYSIWYG(&$code_text, &$parm) + { + // Could add logging, security in here + return $this->toWYSIWYG($code_text, $parm); + } } ?> \ No newline at end of file diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 77caee2b9..467c3cdaa 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -1407,10 +1407,16 @@ class e_parse } break; - case 'html' : + case 'html' : // This overrides and deprecates html.bb $proc_funcs = TRUE; $convertNL = FALSE; - $full_text = str_replace(array("[html]","[/html]"),"",$code_text); // quick fix.. security issue? + $code_text = str_replace("\r\n", " ", $code_text); + $code_text = html_entity_decode($code_text, ENT_QUOTES, CHARSET); + $html_start = ""; // markers for html-to-bbcode replacement. + $html_end = ""; + $full_text = str_replace(array("[html]","[/html]"), "",$code_text); // quick fix.. security issue? + $full_text =$this->replaceConstants($full_text,'abs'); + $full_text = $html_start.$full_text.$html_end; break; case 'table' : // strip
    from end of @@ -1439,7 +1445,7 @@ class e_parse if ($className) { $tempCode = new $className(); - $full_text = $tempCode->bbPreDisplay($matches[4], $parm); + $full_text = $tempCode->bbPreDisplay($matches[4], $parm); } elseif ($bbcode) { // Execute the file diff --git a/e107_handlers/file_class.php b/e107_handlers/file_class.php index 07006f2b7..404e5925e 100644 --- a/e107_handlers/file_class.php +++ b/e107_handlers/file_class.php @@ -20,6 +20,11 @@ */ if (!defined('e107_INIT')) { exit; } +@set_time_limit(10 * 60); +@session_write_close(); +@e107_ini_set("max_execution_time", 10 * 60); +while (@ob_end_clean()); // kill all output buffering else it eats server resources +@ob_implicit_flush(TRUE); /* @@ -287,7 +292,7 @@ class e_file // Grab a remote file and save it in the /temp directory. requires CURL function getRemoteFile($remote_url, $local_file) { - $fp = fopen(e_UPLOAD.$local_file, 'w'); // always download to temp directory. + $fp = fopen(e_MEDIA.$local_file, 'w'); // media-directory is the root. $cp = curl_init($remote_url); curl_setopt($cp, CURLOPT_FILE, $fp); @@ -297,7 +302,7 @@ class e_file curl_close($cp); fclose($fp); - return true; + return ($buffer) ? true : false; } diff --git a/e107_handlers/media_class.php b/e107_handlers/media_class.php index 18e7e59bf..c2be6a2d9 100644 --- a/e107_handlers/media_class.php +++ b/e107_handlers/media_class.php @@ -40,7 +40,7 @@ class e_media * Import files from specified path into media database. * @param string $cat Category nickname * @param string $epath path to file. - * @param string $fmask [optional] filetypes eg. .jpg|.gif + * @param string $fmask [optional] filetypes eg. .jpg|.gif IMAGES is the default mask. * @return e_media */ public function import($cat='',$epath,$fmask='') diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index 1be52096e..c7f782cbd 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -367,6 +367,9 @@ class xmlClass { return FALSE; } + + $xmlData = str_replace('content:encoded', 'content_encoded', $xmlData); + if(!$xml = simplexml_load_string($xmlData)) { $this->errors = $this->getErrors($xmlData); @@ -388,9 +391,12 @@ class xmlClass */ function xml2array($xml, $rec_parent = '') { + $ret = array(); + $tags = get_object_vars($xml); - + + //remove comments if($this->stripComments && isset($tags['comment'])) { @@ -465,6 +471,7 @@ class xmlClass //more cases? default: + $count = count($xml->{$tag}); if($count >= 1) //array of elements - loop { @@ -596,7 +603,7 @@ class xmlClass $vars[$vl] = array($vars[$vl]); } } - + return $vars; } diff --git a/e107_plugins/import/admin_import.php b/e107_plugins/import/admin_import.php index 4885e4d72..38d72dae1 100644 --- a/e107_plugins/import/admin_import.php +++ b/e107_plugins/import/admin_import.php @@ -84,6 +84,7 @@ foreach($importClassList as $file) } unset($importClassList); unset($fl); +asort($import_class_names); @@ -253,14 +254,14 @@ if(isset($_POST['do_conversion'])) if(dbImport() == false) { $abandon = true; - }; + } break; case 'rss' : if(rssImport() == false) { $abandon = true; - }; + } break; } @@ -274,13 +275,11 @@ if(isset($_POST['do_conversion'])) { // unset($_POST['do_conversion']); $text = " - -
    - - -
    - -
    "; +
    +
    + ".$frm->admin_button('dummy_continue',LAN_CONTINUE, 'execute')." +
    +
    "; $ns -> tablerender(LAN_CONVERT_30,$emessage->render(). $text); require_once(e_ADMIN."footer.php"); exit; @@ -291,10 +290,14 @@ if(isset($_POST['do_conversion'])) function rssImport() { global $current_db_type, $db_import_blocks, $import_delete_existing_data,$db_blocks_to_import; - + $mes = e107::getMessage(); - $mes->addDebug("Loading: RSS"); - $mes->addWarning("Under Construction"); + $mes->addDebug("Loading: RSS"); + if(!varset($_POST['do_conversion'])) + { + $mes->addWarning("Under Construction"); + } + return dbImport('xml'); } @@ -305,8 +308,6 @@ function dbImport($mode='db') $mes = e107::getMessage(); - define("RSS_IMPORT",vartrue($_POST['rss_feed'],false)); - // if (IMPORT_DEBUG) echo "Importing: {$current_db_type}
    "; $mes->addDebug("Loading: ".$current_db_type); @@ -314,6 +315,7 @@ function dbImport($mode='db') { $mes->addDebug("Class Available: ".$current_db_type); $converter = new $current_db_type; + $converter->init(); } else { @@ -420,9 +422,9 @@ function dbImport($mode='db') -if(varset($_POST['import_type']) || varset($_POST['do_conversion'])) +if(varset($_GET['import_type']) || varset($_POST['do_conversion'])) { - showImportOptions($_POST['import_type']); + showImportOptions($_GET['import_type']); } else { @@ -443,7 +445,7 @@ function showStartPage() global $ns, $emessage, $frm, $import_class_names, $import_class_support, $db_import_blocks, $import_class_comment; $text = " -
    +
    ".'DBLAN_10'." @@ -521,7 +523,18 @@ function showStartPage() function showImportOptions($mode='csv') { - global $text, $frm, $ns, $emessage, $csv_names, $import_class_names, $e_userclass, $db_import_blocks, $import_class_support, $import_default_prefix; + global $text, $emessage, $csv_names, $import_class_names, $e_userclass, $db_import_blocks, $import_class_support, $import_default_prefix; + + $frm = e107::getForm(); + $ns = e107::getRender(); + + $mes = e107::getMessage(); + + if (class_exists($mode)) + { + $mes->addDebug("Class Available: ".$mode); + $proObj = new $mode; + } $message = LAN_CONVERT_02."
    ".LAN_CONVERT_05.""; $emessage->add($message, E_MESSAGE_WARNING); @@ -565,14 +578,24 @@ function showImportOptions($mode='csv') "; } - elseif($mode == 'rss_import') + elseif(method_exists($proObj,"config")) { - $text .= " - - - "; + $ops = $proObj->config(); + foreach($ops as $key=>$val) + { + $text .= " + + + \n"; + } + + if($proObj->sourceType) + { + $text .= "\n"; + } + } else { @@ -634,7 +657,9 @@ function showImportOptions($mode='csv') $text .= $e_userclass->vetted_tree('classes_select',array($e_userclass,'checkbox'), $checked_class_list,'main,admin,classes,matchclass'); $text .= "
    Feed URL - -
    ".$val['caption']."".$val['html']; + $text .= (vartrue($val['help'])) ? "
    ".$val['help']."
    " : ""; + $text .= "
    -
    ".$frm->admin_button('do_conversion',LAN_CONTINUE, 'execute')." +
    ".$frm->admin_button('do_conversion',LAN_CONTINUE, 'execute'). + + $frm->admin_button('back',LAN_CANCEL, 'cancel')."
    diff --git a/e107_plugins/import/images/blogger.png b/e107_plugins/import/images/blogger.png new file mode 100644 index 0000000000000000000000000000000000000000..91583daebe1acfaef9f86130fd75d838ec6e4487 GIT binary patch literal 2263 zcmV;|2q^c7P)KLZ*U+Jq*2Ca%FW*?*D}Wh8P4Wdr>%DDir|AVW`<_0v`W{0Jt~tjQERe$gHfcfsjC^mhjs^ zW7kJ$=6}uPkrB71b1%3;nBWtY#3f!hVA2h-y;_R zh(kM3_4u)5YlAr$_@mu^Gz$B_fG5}5?f-7H+fQ!7zFqi1dri~o?pXW`Nx$8lZ@XQ3 z9w##akcI1~Vfg?od=6j!2}izxSHFYO5G#RaPFU!R^_gOae>F{a33wB%TcIu$lHRNzSw*Ap2~Y$`T=L|Y zAjHt1ijR-RCyydPVepCAcxI-ilwwJq2LwF8;PWv}6cU%SP@xx z+|NtjSN0qBTlT!2wND`J_v|VAq&;hA?RV`$@5T}VKIc&wBFbn2E+F^(ziuwc+X6r) zuL5O!PrCV>ESW~t*DCeQy&(LO_CL6A4c~7mdd2_%03c&XQcVB=ZI}Q6bB+K2@=gE% zg&qI^ZjJx|w3^aquQ5cKpJhN}jN<%iK*Q<9ExHL1 zj1D79+we+qiVL(@D?ZZ!nkN5!0!0=Qr6|(sDi}>t2m>^Y7DzyH7}F?!qK*F<2V5VF zTUTn6VN(c0tkwK&O%sR%G)>GZr*MpkfrGGesuR2==2D9r3K?- z955jOMFJT_LH?XCdJ-YsJvdk1hg5o-13UOD>3a{O2X}zq+8hOAK!f~eErBpZ<7lph zlc?W@d-Wp=1_zK8J-F9ChPHO0;l%v@3L}b9ttOCVXdI%+JQj@M^j?N6?>REP=~{`? zcSW8+(!^&RLL8yhCCJhgn*`WY8evlf1UX?%9f2~^PhKS3xh01(OEIUe$GiCMoELyO z@oemtEQi^cc|=4{*+f| zGfej?Xla{?(R~svcWp+;2T8wum*}fac_)d0wGd8V2>~e*Ku{DLjzbnBuAf(~79?#% z1(41PPG@C7E|^L$RC464cLQx&T&Zj5vTKMjR(kLJazkw&hu^ z83oul#D>!azZ5~Rny;`+ZMurQfZDt@wGfS22oO$?{qbuKX&qlg4CdI?xe(RnEjEeJ zECa{XcGzl3Zk20QYY-r{`I<=`lhc^VXKp0e{t@E&jk`>oQeJxt<=bCsP(4-2eb@Q7 z#qM0=fCcQ_l?1Ek)Nq4}ndLn=9mj(=tHn~qbf4U~1Y?J=X^hIu`9g|VH4Z5AA&|eS zktO|Q8{V3$iUeHBH$P4Jng{0YvtppFvtc&=@=a_I=E=^Mn3@s-R;Z!SU>;2MzlIL& zYmC?4HOr2k6FmEUfXOf4ATxrkL)jMbw6+&WBM}=&={Q7x?ql@X4cJ4wkC^@0o^Kg> zZUf2G7&vCGU&+m_XJpfE^Btyken#@>1+<-e6W*$GkR{75n&5&8;wsoUBXkOF{vXbx7$4Mu zG}FLX2)@~Ge=fCv_{H&E|0A>cv$RAQ9@pfD!~AA|>6druM|%%y(7D{;wl@mXVw$*6 z?iSh{*!-jI|6xRT3g7^zoWDZud}5umvF`*~ij$w5|LMJS!B-48jxauId2PUMfAAao z_+-L|RVK9or!OmU$%PejUQZ{>7Wra`5o97J`g%}**>*@j2Ks^h^+C!&rLc~wN-pw< lfIonJz+oW!YXGxoJux*7WpV%j002ovPDHLkV1hC-H90`fG7|s* literal 0 HcmV?d00001 diff --git a/e107_plugins/import/import_classes.php b/e107_plugins/import/import_classes.php index 0acd36575..a11360780 100644 --- a/e107_plugins/import/import_classes.php +++ b/e107_plugins/import/import_classes.php @@ -158,7 +158,13 @@ class base_import_class // Empty functions which descendants can inherit from + + function init() + { + return; + } + function copyUserData(&$target, &$source) { return $target; diff --git a/e107_plugins/import/providers/blogger_import_class.php b/e107_plugins/import/providers/blogger_import_class.php new file mode 100644 index 000000000..2c2a4cd1d --- /dev/null +++ b/e107_plugins/import/providers/blogger_import_class.php @@ -0,0 +1,112 @@ +feedUrl = rtrim($_POST['bloggerUrl'],"/")."/feeds/posts/default?max-results=999&alt=rss"; + } + + if(vartrue($_POST['bloggerCleanup'])) + { + $this->cleanupHtml = true; + } + + $mes->addDebug("Blogger Feed:".$this->feedUrl); + } + + + function config() + { + $var[0]['caption'] = "Blogger URL"; + $var[0]['html'] = ""; + $var[0]['help'] = "eg. http://blogname.blogspot.com"; + + $var[1]['caption'] = "Cleanup HTML in content"; + $var[1]['html'] = ""; + $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("
    ","
    ",$body); + return $body; + } + else + { + return $body; + } + break; + + default: + return $source[$type][0]; + break; + } + + + } + + //TODO Comment Import: + //http://blogname.blogspot.com/feeds/comments/default?alt=rss + +} + + +?> \ No newline at end of file diff --git a/e107_plugins/import/providers/rss_import_class.php b/e107_plugins/import/providers/rss_import_class.php index 4152e9d41..77fbdb85d 100644 --- a/e107_plugins/import/providers/rss_import_class.php +++ b/e107_plugins/import/providers/rss_import_class.php @@ -30,6 +30,23 @@ require_once('import_classes.php'); class rss_import extends base_import_class { + var $sourceType = 'rss'; + var $feedUrl = null; + + function init() + { + $this->feedUrl = vartrue($_POST['rss_feed'],false); + } + + function config() + { + $var[0]['caption'] = "Feed URL"; + $var[0]['html'] = ""; + + return $var; + } + + // Set up a query for the specified task. // Returns TRUE on success. FALSE on error function setupQuery($task, $blank_user=FALSE) @@ -37,32 +54,36 @@ class rss_import extends base_import_class $this->arrayData = array(); $xml = e107::getXml(); - $file = RSS_IMPORT; + $file = $this->feedUrl; switch ($task) { case 'news' : case 'page' : case 'links' : + + // $rawData = $xml->getRemoteFile($file); + // print_a($rawData); $array = $xml->loadXMLfile($file,'advanced'); - if ($array === FALSE || RSS_IMPORT === FALSE) return FALSE; + 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; + $this->copyUserInfo = !$blank_user; + $this->currentTask = $task; + return TRUE; } @@ -81,18 +102,45 @@ class rss_import extends base_import_class } /** - * Align source data to e107 News Table + * Align source data with e107 News Table * @param $target array - default e107 target values for e107_news table. * @param $source array - WordPress table data */ function copyNewsData(&$target, &$source) { - $target['news_title'] = $source['title'][0]; + 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("
    ",$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]".$source['description'][0]."[/html]"; + $target['news_body'] = "[html]".$body."[/html]"; // $target['news_extended'] = ''; - // $target['news_meta_keywords'] = ''; + $target['news_meta_keywords'] = implode(",",$keywords); // $target['news_meta_description'] = ''; $target['news_datestamp'] = strtotime($source['pubDate'][0]); // $target['news_author'] = $source['post_author']; @@ -107,14 +155,52 @@ class rss_import extends base_import_class // $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 @@ -123,11 +209,11 @@ class rss_import extends base_import_class */ 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]".$source['description'][0]."[/html]"; + $target['page_text'] = "[html]".$body."[/html]"; // $target['page_metakeys'] = ''; // $target['page_metadscr'] = ''; $target['page_datestamp'] = strtotime($source['pubDate'][0]); @@ -165,17 +251,61 @@ class rss_import extends base_import_class // $target['link_class'] = ''; // $target['link_sefurl'] = $source['post_password']; + + return $target; // comment out to debug $this->renderDebug($source,$target); } - //TODO Option to save remote images locally and replace urlss in news_body with local ones. eg. {e_MEDIA} - function saveBodyFiles($body) + + /** 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); + } diff --git a/e107_plugins/tinymce/plugins/e107bbcode/parser.php b/e107_plugins/tinymce/plugins/e107bbcode/parser.php index 1aecf9315..e68f504e1 100644 --- a/e107_plugins/tinymce/plugins/e107bbcode/parser.php +++ b/e107_plugins/tinymce/plugins/e107bbcode/parser.php @@ -17,7 +17,7 @@ if($_POST['mode'] == 'tohtml') { $content = $tp->toDB($_POST['content']); e107::getBB()->setClass($_SESSION['media_category']); - echo $tp->toHtml($content,true); + echo $tp->toHtml($content, true, 'wysiwyg'); e107::getBB()->clearClass(); }