From 0f2ab37d476b4a66aabdb282090d0a76d2c316e4 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 6 May 2020 16:15:52 -0700 Subject: [PATCH] Backward compatibility fixes. --- e107_core/templates/header_default.php | 1 + e107_handlers/e_parse_class.php | 6 +++++ e107_plugins/news/news.php | 11 +++++---- e107_tests/tests/unit/e_parseTest.php | 33 ++++++++++++++++++++++++++ e107_web/css/backcompat.css | 3 +++ e107_web/js/core/backcompat.js | 13 ++++++++++ 6 files changed, 63 insertions(+), 4 deletions(-) create mode 100644 e107_web/js/core/backcompat.js diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index 8fd7dcd34..a0193c79d 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -210,6 +210,7 @@ if (/*!defined("PREVIEWTHEME") && */! (isset($no_core_css) && $no_core_css !==tr if(THEME_LEGACY === true || !deftrue('BOOTSTRAP')) { $e_js->otherCSS('{e_WEB_CSS}backcompat.css'); + $e_js->footerFile('{e_WEB_JS}core/backcompat.js'); } diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 01ae2560d..4344b6311 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -1605,6 +1605,12 @@ class e_parse extends e_parser { $opts['nobreak'] = true; $text = trim($text); + + if(strpos($text,'[center]') === 0) // quick bc fix TODO Find a better solution. [center][/center] containing HTML. + { + $text = str_replace("[center]","
",$text); + $text = str_replace("[/center]","
",$text); + } } $fromadmin = $opts['fromadmin']; diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index 90aae1973..7c75b2a0b 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -1607,9 +1607,9 @@ class news_front require_once(THEME."news_template.php"); - if(empty($ALTERNATECLASS1)) + if(!empty($ALTERNATECLASS1)) { - return TRUE; + return true; } $newscolumns = (isset($NEWSCOLUMNS) ? $NEWSCOLUMNS : 1); @@ -1618,7 +1618,9 @@ class news_front $loop = 1; $param = array(); $param['current_action'] = $action; - foreach($newsAr as $news) { + + foreach($newsAr as $news) + { if(is_array($ALTERNATECLASSES)) { @@ -1630,7 +1632,8 @@ class news_front $newsdata[$loop] .= $this->ix->render_newsitem($news, 'return', '', '', $param); } $loop ++; - if($loop > $newscolumns) { + if($loop > $newscolumns) + { $loop = 1; } } diff --git a/e107_tests/tests/unit/e_parseTest.php b/e107_tests/tests/unit/e_parseTest.php index 756969aa6..a745e56a7 100644 --- a/e107_tests/tests/unit/e_parseTest.php +++ b/e107_tests/tests/unit/e_parseTest.php @@ -65,6 +65,39 @@ TMP; $expected = "
Blank Avatar
"; $this->assertEquals($expected, $actual, "BBcode parsing failed on [img]"); + + + $src = << + +[/center] +SRC; + + $expected = << + +EXPECTED; + + $actual = $this->tp->toHTML($src,true); + $this->assertEquals($expected,$actual); + /* $src = "[html]
$sql = e107::getDb();
diff --git a/e107_web/css/backcompat.css b/e107_web/css/backcompat.css
index b29e52f30..9bdae29fe 100644
--- a/e107_web/css/backcompat.css
+++ b/e107_web/css/backcompat.css
@@ -65,6 +65,9 @@ table.table { width: 100% }
     background-color: #f9f9f9;
 }
 
+.s-message a.close { cursor: pointer }
+
+
 /* Bootstrap classes that hide content for all devices except screen readers (accessibility) */
 .sr-only {
   position: absolute;
diff --git a/e107_web/js/core/backcompat.js b/e107_web/js/core/backcompat.js
new file mode 100644
index 000000000..505d862a6
--- /dev/null
+++ b/e107_web/js/core/backcompat.js
@@ -0,0 +1,13 @@
+
+/* Legacy Theme v1.x compat when bootstrap not in use */
+
+// (function ($)
+
+
+    $('.s-message a.close').on('click', function ()
+    {
+
+        $(this).parent('.s-message').hide('slow');
+    }
+    );
+