From a70c0293e7ccb6fd1662ce661df3ef41abafad89 Mon Sep 17 00:00:00 2001 From: John Clause Date: Mon, 2 Feb 2015 01:24:15 -0700 Subject: [PATCH] 2.9.8.2 alpha pre-release --- .gitignore | 1 + admin/admin_utils.php | 49 ++++++++++++++ admin/js/common.js | 97 +++++++++++++++------------- admin/js/common.min.js | 2 +- admin/js/edit-custom-page.js | 4 +- admin/js/edit-custom-page.min.js | 2 +- admin/js/edit-nav-menus.js | 81 +++++++++++++++++++---- admin/js/edit-nav-menus.min.js | 2 +- admin/js/edit-options-general.js | 4 +- admin/js/edit-options-general.min.js | 2 +- admin/js/edit-post.js | 11 ++-- admin/js/edit-post.min.js | 2 +- admin/js/edit-tag.js | 6 +- admin/js/edit-tag.min.js | 2 +- admin/js/edit-tags.js | 46 +++++++------ admin/js/edit-tags.min.js | 2 +- qtranslate.php | 8 +-- qtranslate_compatibility.php | 8 +++ qtranslate_configuration.php | 19 ++++-- qtranslate_frontend.php | 5 +- qtranslate_hooks.php | 8 +-- readme.txt | 38 ++++++++++- 22 files changed, 288 insertions(+), 111 deletions(-) diff --git a/.gitignore b/.gitignore index a22ce7b..31b4306 100644 --- a/.gitignore +++ b/.gitignore @@ -214,6 +214,7 @@ pip-log.txt *.po.err *.po.bad *.po.org +*.po.cur *.po.q *.po.mq diff --git a/admin/admin_utils.php b/admin/admin_utils.php index 03c1a51..a8558d2 100644 --- a/admin/admin_utils.php +++ b/admin/admin_utils.php @@ -3,6 +3,7 @@ function qtranxf_detect_admin_language($language,$url_info) { global $q_config; $cs; + $lang; if(isset($_COOKIE[QTX_COOKIE_NAME_ADMIN])){ $lang=qtranxf_resolveLangCase($_COOKIE[QTX_COOKIE_NAME_ADMIN],$cs); } @@ -195,6 +196,54 @@ function qtranxf_languageColumn($column) { return $column; } +function qtranxf_admin_list_cats($text) { + global $pagenow; + //qtranxf_dbg_echo('qtranxf_admin_list_cats: $text',$text); + switch($pagenow){ + case 'edit-tags.php': + //replace [:] with <:> + $blocks = qtranxf_get_language_blocks($text); + if(count($blocks)<=1) return $text; + $texts = qtranxf_split_blocks($blocks); + $text = qtranxf_join_c($texts); + return $text; + default: return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text); + } +} +add_filter('list_cats', 'qtranxf_admin_list_cats',0); + +function qtranxf_admin_dropdown_cats($text) { + global $pagenow; + //qtranxf_dbg_echo('qtranxf_admin_list_cats: $text',$text); + switch($pagenow){ + case 'edit-tags.php': + return $text; + default: return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text); + } +} +add_filter('wp_dropdown_cats', 'qtranxf_admin_dropdown_cats',0); + +function qtranxf_admin_category_description($text) { + global $pagenow; + switch($pagenow){ + case 'edit-tags.php': + return $text; + default: return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text); + } +} +add_filter('category_description', 'qtranxf_admin_category_description',0); + +function qtranxf_admin_the_title($title) { + global $pagenow; + switch($pagenow){ + //case 'edit-tags.php': + case 'nav-menus.php': + return $title; + default: return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($title); + } +} +add_filter('the_title', 'qtranxf_admin_the_title', 0);//WP: fires for display purposes only + function qtranxf_the_editor($editor_div) { // remove wpautop, which causes unmatched

on combined language strings diff --git a/admin/js/common.js b/admin/js/common.js index 0cd58a5..24d81e1 100644 --- a/admin/js/common.js +++ b/admin/js/common.js @@ -1,10 +1,10 @@ /* //debuging tools, do not check in +*/ var cc=0; function c(v){ ++cc; console.log('== '+cc+': '+v); } function ct(v){ c(v); console.trace(); } function co(t,o){ ++cc; console.log('== '+cc+': '+t+': %o',o); } -*/ qtranxj_split = function(text,keep_neutral_text) { @@ -204,11 +204,11 @@ var qTranslateX=function(pg) return false; } - var initialLanguage=qtranxj_get_cookie('wp_qtrans_edit_language'); - if(!initialLanguage || !isLanguageEnabled(initialLanguage)) - initialLanguage=qTranslateConfig.language; + qTranslateConfig.activeLanguage = qtranxj_get_cookie('qtrans_edit_language'); + if(!qTranslateConfig.activeLanguage || !isLanguageEnabled(qTranslateConfig.activeLanguage)) + qTranslateConfig.activeLanguage = qTranslateConfig.language; - this.getInitialLanguage=function() { return initialLanguage; } + this.getActiveLanguage=function() { return qTranslateConfig.activeLanguage; } var displayHooks=[]; var contentHooks={}; @@ -226,7 +226,6 @@ var qTranslateX=function(pg) updateFusedValueH=function(id,value) { var h=contentHooks[id]; - //var lang=languageSwitch.getActiveLanguage(); var text=value.trim(); //c('updateFusedValueH['+id+'] lang='+h.lang+'; text:'+text); h.contents[h.lang]=text; @@ -243,7 +242,9 @@ var qTranslateX=function(pg) //h.id=inpField.id; h.contentField=inpField; //c('addContentHook:inpField.value='+inpField.value); - h.contents=qtranxj_split(inpField.value,false);//inpField.tagName + //h.contents=qtranxj_split(inpField.value,false); + h.contents=qtranxj_split(inpField.value,true);//keep neutral text from older times, just in case. + //inpField.tagName h.mlContentField=qtranxj_ce('input', {name: inpField.name, type: 'hidden', className: 'hidden', value: inpField.value}, form, true); if(!separator){ if(inpField.tagName==='TEXTAREA') @@ -253,7 +254,7 @@ var qTranslateX=function(pg) } h.separator=separator; inpField.name='edit-'+inpField.name; - h.lang=initialLanguage; + h.lang=qTranslateConfig.activeLanguage; var text = h.contents[h.lang]; inpField.value=text; //c('addContentHook['+inpField.id+']['+h.lang+']: inpField.value='+inpField.value); @@ -302,12 +303,13 @@ var qTranslateX=function(pg) //c('addDisplayHook: innerHTML='+elem.innerHTML); //c('addDisplayHook: content='+content); h.contents=qtranxj_split(content,true); - elem.innerHTML=h.contents[initialLanguage]; + elem.innerHTML=h.contents[qTranslateConfig.activeLanguage]; displayHooks.push(h); return true; } + this.addDisplayHookById=function(id) { return addDisplayHook(this.ge(id)); } - setLangCookie=function(lang) { document.cookie='wp_qtrans_edit_language='+lang; } + setLangCookie=function(lang) { document.cookie='qtrans_edit_language='+lang; } updateTinyMCE=function(ed,text) { @@ -382,24 +384,42 @@ var qTranslateX=function(pg) pg.onTabSwitch(this.lang,qtx); } - this.addDisplayHooksByClass=function(nm,form) + addDisplayHooks=function(elems) { - var elems=form.getElementsByClassName(nm); - //c('addDisplayHooksByClass: elems.length='+elems.length); + //c('addDisplayHooks: elems.length='+elems.length); for(var i=0; i]*>(\s| |]*>)*<\/p>$/)){ - text='';//workaround, need to learn how tinymce works ... - //c('tinymce: onblur: empty text'); - }else{ - var matches = text.match(/^

\s*([^<]*)\s*<\/p>$/); - if(matches){ - text=matches[1]; - //c('tinymce: onblur: removed plain

:'+text); - } - } - updateFusedValueH(ed.id,text); -*/ var h=contentHooks[ed.id]; //c('blur: h['+ed.id+'].contentField.value before save:'+h.contentField.value); ed.save(); @@ -456,9 +461,7 @@ var qTranslateX=function(pg) h.contents[h.lang] = h.contentField.value; updateFusedValueHooked(h); }); - //c('setEditorHooks: id='+id); - //c('h.contentField.value='+h.contentField.value); - updateTinyMCE(ed,h.contentField.value); + return h; } // Add listeners for fields change @@ -469,7 +472,11 @@ var qTranslateX=function(pg) } for(var i=0; i=0}function qtranxj_ce(n,t,e,a){var r=document.createElement(n);if(t)for(prop in t)r[prop]=t[prop];return e&&(a&&e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)),r}function qtranxj_LanguageSwitch(n,t){function e(){var n=this;if(!n.lang)return void alert("qTranslate-X: This should not have happened: Please, report this incident to the developers: !tabSwitch.lang");if(i!==n.lang){i&&o[i].classList.remove("active"),i=n.lang,n.classList.add("active");for(var t=0;t||\[:[a-z]{2}\])/gi,o=n.xsplit(i);if(!qtranxj_isArray(o))return e;if(1==o.length){for(var l=o[0],s=0;s/gi,u=//g,d=/\[:([a-z]{2})\]/gi;r=!1;for(var a=0;a",t+=r,t+="")}return t},qtranxj_join_b=function(n){var t=qtranxj_allthesame(n);if(null!=t)return t;for(var t="",e=0;e1&&a.push(t[1]),e=n.lastIndex;return e");return a.contents=qtranxj_split(r,!0),n.innerHTML=a.contents[t],e.push(a),!0},setLangCookie=function(n){document.cookie="wp_qtrans_edit_language="+n},updateTinyMCE=function(n,t){window.switchEditors&&(t=window.switchEditors.wpautop(t)),n.setContent(t,{format:"html"})},onTabSwitch=function(){setLangCookie(this.lang);for(var n=0;n=0}function qtranxj_ce(n,e,t,a){var i=document.createElement(n);if(e)for(prop in e)i[prop]=e[prop];return t&&(a&&t.firstChild?t.insertBefore(i,t.firstChild):t.appendChild(i)),i}function qtranxj_LanguageSwitch(n){function e(){var n=this;if(!n.lang)return void alert("qTranslate-X: This should not have happened: Please, report this incident to the developers: !tabSwitch.lang");if(qTranslateConfig.activeLanguage!==n.lang){qTranslateConfig.activeLanguage&&i[qTranslateConfig.activeLanguage].classList.remove("active"),qTranslateConfig.activeLanguage=n.lang,n.classList.add("active");for(var e=0;e||\[:[a-z]{2}\])/gi,o=n.xsplit(r);if(!qtranxj_isArray(o))return t;if(1==o.length){for(var s=o[0],l=0;l/gi,u=//g,c=/\[:([a-z]{2})\]/gi;i=!1;for(var a=0;a",e+=i,e+="")}return e},qtranxj_join_b=function(n){var e=qtranxj_allthesame(n);if(null!=e)return e;for(var e="",t=0;t1&&a.push(e[1]),t=n.lastIndex;return t");return t.contents=qtranxj_split(a,!0),n.innerHTML=t.contents[qTranslateConfig.activeLanguage],e.push(t),!0},this.addDisplayHookById=function(n){return addDisplayHook(this.ge(n))},setLangCookie=function(n){document.cookie="qtrans_edit_language="+n},updateTinyMCE=function(n,e){window.switchEditors&&(e=window.switchEditors.wpautop(e)),n.setContent(e,{format:"html"})},onTabSwitch=function(){setLangCookie(this.lang);for(var n=0;ndescription = apply_filters( 'nav_menu_description', wp_trim_words( $menu_item->post_content, 200 ) );" in /wp-includes/nav-menu.php + var matches; + var rxd = /(