From 97cb741907f95f3154ae95e96f017ba2fd24523b Mon Sep 17 00:00:00 2001 From: Garvin Hicking Date: Fri, 23 Sep 2016 11:27:38 +0200 Subject: [PATCH] upstream patch by ian --- serendipity_event_multilingual/ChangeLog | 20 +++++++++- .../serendipity_event_multilingual.php | 34 +++++++++-------- .../serendipity_plugin_multilingual.php | 38 ++++++++++++++++++- 3 files changed, 74 insertions(+), 18 deletions(-) diff --git a/serendipity_event_multilingual/ChangeLog b/serendipity_event_multilingual/ChangeLog index 984c3b50..66c10017 100644 --- a/serendipity_event_multilingual/ChangeLog +++ b/serendipity_event_multilingual/ChangeLog @@ -1,5 +1,23 @@ +2.32: +----- + + * Remove S8y 2.0+ inline style for the fieldset + +2.31: +----- + + * Better recognize $serendipity['dbType'] query check for all supported + postgres and all sqlite versions + * Set strip_langs() method static + +2.30 & 1.15 (sidebar): +---------------------- + + * Fix Invalid argument supplied for foreach() error in case the + $serendipity['languages'] array is missing (ie. by emerge.sh call) + 2.29 & 1.14 (sidebar): ---------------- +---------------------- * Fix config sidebar selected langs on save diff --git a/serendipity_event_multilingual/serendipity_event_multilingual.php b/serendipity_event_multilingual/serendipity_event_multilingual.php index cf8717fb..f3dea52e 100755 --- a/serendipity_event_multilingual/serendipity_event_multilingual.php +++ b/serendipity_event_multilingual/serendipity_event_multilingual.php @@ -27,7 +27,7 @@ class serendipity_event_multilingual extends serendipity_event 'php' => '4.1.0' )); $propbag->add('groups', array('FRONTEND_ENTRY_RELATED', 'BACKEND_EDITOR')); - $propbag->add('version', '2.29'); + $propbag->add('version', '2.32'); $propbag->add('configuration', array('copytext', 'placement', 'tagged_title', 'tagged_entries', 'tagged_sidebar', 'langswitch')); $propbag->add('event_hooks', array( 'frontend_fetchentries' => true, @@ -39,7 +39,6 @@ class serendipity_event_multilingual extends serendipity_event 'backend_display' => true, 'frontend_entryproperties' => true, 'backend_sidebar_entries' => true, -/* 'external_plugin' => true,*/ 'css' => true, 'backend_entryform' => true, 'backend_entry_presave' => true, @@ -74,7 +73,9 @@ class serendipity_event_multilingual extends serendipity_event $_REQUEST['user_language'] = $serendipity['GET']['user_language']; // normal fallback if (!isset($serendipity['GET']['lang_selected']) && !isset($_REQUEST['user_language'])) { - if (!empty($_SESSION['serendipityLanguage'])) $this->showlang = $_SESSION['serendipityLanguage']; + if (!empty($_SESSION['serendipityLanguage'])) { + $this->showlang = $_SESSION['serendipityLanguage']; + } } } elseif (!isset($_COOKIE['serendipityLanguage'])) $resetlang = true; // force == false and we only want the translated article, nothing else being touched multilingual } @@ -287,21 +288,23 @@ class serendipity_event_multilingual extends serendipity_event $langs[$default_lang] = '' . $default_lang . ''; } $lang = implode(', ', $langs); + return $lang; } + // currently unused method for years //function neglang($lang) { function neglang($lang, $assert = '?!') { /* Creates the negation pattern from a two letter language identifier. */ - // Negative look ahead assertion. ".*" is used because any letter except of the language string shall be allowed, without it, nothing would ever match */ + // Negative look ahead assertion. ".*" is used because any letter except of the language string shall be allowed, without it, nothing would ever match return '(' . $assert . $lang . ').*'; //return '(?!' . $lang . ').*'; //return '[^'.$lang[0].'][^'.$lang[1].']'; } - function strip_langs($msg) + static function strip_langs($msg) { global $serendipity; @@ -449,6 +452,7 @@ class serendipity_event_multilingual extends serendipity_event // never init in genpage without adding previously set $vars, which is $view etc! serendipity_smarty_init($serendipity['plugindata']['smartyvars']); } + // set lang strip change more global, since we need this in the email subject too for example $serendipity['blogTitle'] = $this->strip_langs($serendipity['blogTitle']); $serendipity['blogDescription'] = $this->strip_langs($serendipity['blogDescription']); @@ -534,9 +538,9 @@ class serendipity_event_multilingual extends serendipity_event case 'frontend_display': // cannot use tag_title() method here and use with Smarty3+ only // check for single entry multilingual context only, to set the correct themes banner title - if (defined('Smarty::SMARTY_VERSION') && - isset($eventData['properties']['multilingual_title_'.$this->showlang]) && - serendipity_db_bool($this->get_config('tagged_title', 'true')) && + if (defined('Smarty::SMARTY_VERSION') && + isset($eventData['properties']['multilingual_title_'.$this->showlang]) && + serendipity_db_bool($this->get_config('tagged_title', 'true')) && $serendipity['view'] == 'entry') { $serendipity['smarty']->assign('head_title', $eventData['title']); @@ -601,7 +605,7 @@ class serendipity_event_multilingual extends serendipity_event $this->tag_title(); if (serendipity_db_bool($this->get_config('tagged_entries', 'true'))) { - foreach ($eventData as $key => $entry) { + foreach ($eventData AS $key => $entry) { if (isset($eventData[$key]['title'])) { $eventData[$key]['title'] = $this->strip_langs($eventData[$key]['title']); $eventData[$key]['body'] = $this->strip_langs($eventData[$key]['body']); @@ -638,7 +642,7 @@ class serendipity_event_multilingual extends serendipity_event -
+
get_config('tagged_entries', 'true'))) { - foreach ($eventData as $key => $entry) { + foreach ($eventData AS $key => $entry) { $eventData[$key]['title'] = $this->strip_langs($eventData[$key]['title']); $eventData[$key]['body'] = $this->strip_langs($eventData[$key]['body']); } @@ -748,10 +752,10 @@ class serendipity_event_multilingual extends serendipity_event if ($addData['source'] == 'search' && isset($eventData['find_part'])) { $term =& $addData['term']; $cond =& $eventData; - if ($serendipity['dbType'] == 'postgres') { + if (stristr($serendipity['dbType'], 'postgres')) { $cond['find_part'] .= " OR (multilingual_body.value ILIKE '%$term%' OR multilingual_extended.value ILIKE '%$term%' OR multilingual_title.value ILIKE '%$term%')"; - } elseif ($serendipity['dbType'] == 'sqlite') { - $term = serendipity_mb('strtolower', $term); + } elseif (stristr($serendipity['dbType'], 'sqlite')) { + $term = serendipity_mb('strtolower', $term); $cond['find_part'] .= " OR (lower(multilingual_body.value) LIKE '%$term%' OR lower(multilingual_extended.value) LIKE '%$term%' OR lower(multilingual_title.value) LIKE '%$term%')"; } else { if (preg_match('@["\+\-\*~<>\(\)]+@', $term)) { @@ -780,7 +784,7 @@ class serendipity_event_multilingual extends serendipity_event case 'frontend_sidebar_plugins': if (serendipity_db_bool($this->get_config('tagged_sidebar', 'true'))) { - foreach ($eventData as $key => $entry) { + foreach ($eventData AS $key => $entry) { $eventData[$key]['title'] = $this->strip_langs($eventData[$key]['title']); $eventData[$key]['content'] = $this->strip_langs($eventData[$key]['content']); } diff --git a/serendipity_event_multilingual/serendipity_plugin_multilingual.php b/serendipity_event_multilingual/serendipity_plugin_multilingual.php index 69865a1e..2ad89aa3 100644 --- a/serendipity_event_multilingual/serendipity_plugin_multilingual.php +++ b/serendipity_event_multilingual/serendipity_plugin_multilingual.php @@ -25,11 +25,45 @@ class serendipity_plugin_multilingual extends serendipity_event )); $conf = array('title', 'show_submit', 'size'); + /* Available languages */ + if (!is_array($serendipity['languages'])) { + $serendipity['languages'] = array('en' => 'English', + 'de' => 'German', + 'da' => 'Danish', + 'es' => 'Spanish', + 'fr' => 'French', + 'fi' => 'Finnish', + 'cs' => 'Czech (Win-1250)', + 'cz' => 'Czech (ISO-8859-2)', + 'sk' => 'Slovak', + 'nl' => 'Dutch', + 'is' => 'Icelandic', + 'tr' => 'Turkish', + 'se' => 'Swedish', + 'pt' => 'Portuguese Brazilian', + 'pt_PT' => 'Portuguese European', + 'bg' => 'Bulgarian', + 'hu' => 'Hungarian', + 'no' => 'Norwegian', + 'pl' => 'Polish', + 'ro' => 'Romanian', + 'it' => 'Italian', + 'ru' => 'Russian', + 'fa' => 'Persian', + 'tw' => 'Traditional Chinese (Big5)', + 'tn' => 'Traditional Chinese (UTF-8)', + 'zh' => 'Simplified Chinese (GB2312)', + 'cn' => 'Simplified Chinese (UTF-8)', + 'ja' => 'Japanese', + 'ko' => 'Korean', + 'sa' => 'Arabic', + 'ta' => 'Tamil'); + } foreach($serendipity['languages'] AS $lkey => $lval) { $conf[] = $lkey; } $propbag->add('configuration', $conf); - $propbag->add('version', '1.14'); + $propbag->add('version', '1.15'); $propbag->add('groups', array('FRONTEND_VIEWS')); $this->dependencies = array('serendipity_event_multilingual' => 'remove'); } @@ -84,7 +118,7 @@ class serendipity_plugin_multilingual extends serendipity_event echo '
'; echo '