qTranslate X - Version 3.0

Version Description

stable = * Includes all changes after version 2.9.6. * Please, do not forget to respond to survey on 'Translate Service' feature by courtesy of Gunu (Marius Siroen), whose continuous help is much appreciated. * Feature: framework for integration with other plugins and themes. * Maintenance: po/mo files updated.

Download this release

Release Info

Developer johnclause
Plugin Icon wp plugin qTranslate X
Version 3.0
Comparing to
See all releases

Code changes from version 2.9.6 to 3.0

Files changed (63) hide show
  1. admin/activation_hook.php +36 -0
  2. admin/admin_utils.php +300 -0
  3. admin/import_export.php +4 -3
  4. admin/js/common.js +626 -0
  5. admin/js/common.min.js +1 -0
  6. admin/js/edit-custom-page.js +20 -0
  7. admin/js/edit-custom-page.min.js +1 -0
  8. admin/js/edit-nav-menus.js +66 -0
  9. admin/js/edit-nav-menus.min.js +1 -0
  10. admin/js/edit-options-general.js +16 -0
  11. admin/js/edit-options-general.min.js +1 -0
  12. admin/js/edit-post.js +104 -0
  13. admin/js/edit-post.min.js +1 -0
  14. admin/js/edit-tag.js +24 -0
  15. admin/js/edit-tag.min.js +1 -0
  16. admin/js/edit-tags.js +79 -0
  17. admin/js/edit-tags.min.js +1 -0
  18. admin/update-gettext-db.php +99 -0
  19. lang/qtranslate-az_AZ.po +1005 -0
  20. lang/qtranslate-bg_BG.po +1017 -0
  21. lang/qtranslate-cs_CZ.mo +0 -0
  22. lang/qtranslate-cs_CZ.po +967 -0
  23. lang/qtranslate-da_DK.po +1020 -0
  24. lang/qtranslate-de_DE.po +1053 -0
  25. lang/qtranslate-eo.po +944 -0
  26. lang/qtranslate-es_CA.po +1020 -0
  27. lang/qtranslate-es_ES.po +1019 -0
  28. lang/qtranslate-fr_FR.po +1099 -0
  29. lang/qtranslate-hu_HU.po +1087 -0
  30. lang/qtranslate-id_ID.po +1017 -0
  31. lang/qtranslate-it_IT.po +1017 -0
  32. lang/qtranslate-ja_JP.po +1020 -0
  33. lang/qtranslate-mk_MK.po +1000 -0
  34. lang/qtranslate-ms_MY.po +1021 -0
  35. lang/qtranslate-nl_NL.mo +0 -0
  36. lang/qtranslate-nl_NL.po +1355 -0
  37. lang/qtranslate-pl_PL.po +1019 -0
  38. lang/qtranslate-pt_BR.mo +0 -0
  39. lang/qtranslate-pt_BR.po +958 -0
  40. lang/qtranslate-pt_PT.mo +0 -0
  41. lang/qtranslate-pt_PT.po +1028 -0
  42. lang/qtranslate-ro_RO.po +1017 -0
  43. lang/qtranslate-ru_RU.mo +0 -0
  44. lang/qtranslate-ru_RU.po +966 -0
  45. lang/qtranslate-sr_RS.po +1005 -0
  46. lang/qtranslate-sv_SE.po +987 -0
  47. lang/qtranslate-tr_TR.po +1005 -0
  48. lang/qtranslate-zh_CN.po +1021 -0
  49. lang/qtranslate.pot +475 -378
  50. qtranslate.js +0 -807
  51. qtranslate.min.js +0 -1
  52. qtranslate.php +34 -16
  53. qtranslate_compatibility.php +13 -0
  54. qtranslate_configuration.css +56 -2
  55. qtranslate_configuration.php +478 -177
  56. qtranslate_core.php +665 -531
  57. qtranslate_frontend.php +269 -72
  58. qtranslate_hooks.php +64 -77
  59. qtranslate_services.php +110 -73
  60. qtranslate_utils.php +42 -24
  61. qtranslate_widget.php +4 -4
  62. readme.txt +160 -16
  63. screenshot-3.png +0 -0
admin/activation_hook.php CHANGED
@@ -147,4 +147,40 @@ function qtranxf_admin_notices_plugin_conflicts()
147
qtranxf_admin_notice_plugin_conflict('zTranslate','ztranslate/ztranslate.php');
148
}
149
add_action('admin_notices', 'qtranxf_admin_notices_plugin_conflicts');
150
?>
147
qtranxf_admin_notice_plugin_conflict('zTranslate','ztranslate/ztranslate.php');
148
}
149
add_action('admin_notices', 'qtranxf_admin_notices_plugin_conflicts');
150
+
151
+ function qtranxf_admin_notices_survey_request()
152
+ {
153
+ $messages = get_option('qtranslate_admin_notices');
154
+ if(isset($messages['survey-translation-service'])) return;
155
+ ?>
156
+ <script type="text/javascript">
157
+ function qtranxj_dismiss_admin_notice(id) {
158
+ jQuery('#qtranxs_'+id).css('display','none');
159
+ jQuery.post(ajaxurl, { action: 'qtranslate_admin_notice', notice_id: id }
160
+ //,function(response) { eval(response); }
161
+ );
162
+ }
163
+ </script>
164
+ <?php
165
+ echo '<div class="updated" id="qtranxs_survey-translation-service"><p style="font-size: larger;">';// text-align: center;
166
+ printf(__('Thank you for using %s plugin!','qtranslate'), '<a href="https://wordpress.org/plugins/qtranslate-x/" style="color:blue" target="_blank">qTranslate&#8209;X</a>');
167
+ echo '<br>';
168
+ printf(__('Please, help us to make decision on "%s" feature, press the button below.','qtranslate'),__('Translation Service', 'qtranslate'));
169
+ echo '</p><p><a class="button" href="http://www.marius-siroen.com/qTranslate-X/TranslateServices/" target="_blank">';
170
+ printf(__('Survey on "%s" feature','qtranslate'),__('Translation Service', 'qtranslate'));
171
+ echo '</a>&nbsp;&nbsp;&nbsp;<a class="button" href="javascript:qtranxj_dismiss_admin_notice(\'survey-translation-service\');">'.__('I have already done it, dismiss this message.', 'qtranslate');
172
+ echo '</a></p></div>';
173
+ }
174
+ add_action('admin_notices', 'qtranxf_admin_notices_survey_request');
175
+
176
+ function qtranxf_ajax_qtranslate_admin_notice()
177
+ {
178
+ if(!isset($_POST['notice_id'])) return;
179
+ $id = $_POST['notice_id'];
180
+ $messages = get_option('qtranslate_admin_notices',array());
181
+ $messages[$id] = time();
182
+ update_option('qtranslate_admin_notices',$messages);
183
+ //echo "jQuery('#qtranxs_+$id').css('display','none');"; die();
184
+ }
185
+ add_action('wp_ajax_qtranslate_admin_notice', 'qtranxf_ajax_qtranslate_admin_notice');
186
?>
admin/admin_utils.php ADDED
@@ -0,0 +1,300 @@
1
+ <?php
2
+
3
+ function qtranxf_detect_admin_language($url_info) {
4
+ global $q_config;
5
+ $cs=null;
6
+ $lang=null;
7
+ if(isset($_COOKIE[QTX_COOKIE_NAME_ADMIN])){
8
+ $lang=qtranxf_resolveLangCase($_COOKIE[QTX_COOKIE_NAME_ADMIN],$cs);
9
+ $url_info['lang_cookie_admin'] = $lang;
10
+ }
11
+ if(!$lang){
12
+ $locale = get_locale();
13
+ $url_info['locale'] = $locale;
14
+ $lang = qtranxf_resolveLangCase(substr($locale,0,2),$cs);
15
+ $url_info['lang_locale'] = $lang;
16
+ if(!$lang) $lang = $q_config['default_language'];
17
+ }
18
+ $url_info['doing_front_end'] = false;
19
+ $url_info['lang_admin'] = $lang;
20
+ return $url_info;
21
+ }
22
+ add_filter('qtranslate_detect_admin_language','qtranxf_detect_admin_language');
23
+
24
+ function qtranxf_mark_default($text) {
25
+ global $q_config;
26
+ $blocks = qtranxf_get_language_blocks($text);
27
+ if( count($blocks) > 1 ) return $text;//already have other languages.
28
+ $content=array();
29
+ foreach($q_config['enabled_languages'] as $language) {
30
+ if($language == $q_config['default_language']) {
31
+ $content[$language] = $text;
32
+ }else{
33
+ $content[$language] = '';
34
+ }
35
+ }
36
+ return qtranxf_join_c($content);
37
+ }
38
+
39
+ function qtranxf_get_term_joined($obj,$taxonomy=null) {
40
+ global $q_config;
41
+ if(is_object($obj)) {
42
+ // object conversion
43
+ if(isset($q_config['term_name'][$obj->name])) {
44
+ //'[:'.$q_config['language'].']'.$obj->name
45
+ $obj->name = qtranxf_join_b($q_config['term_name'][$obj->name]);
46
+ //qtranxf_dbg_log('qtranxf_get_term_joined: object:',$obj);
47
+ }
48
+ }elseif(isset($q_config['term_name'][$obj])) {
49
+ $obj = qtranxf_join_b($q_config['term_name'][$obj]);
50
+ //'[:'.$q_config['language'].']'.$obj.
51
+ //qtranxf_dbg_echo('qtranxf_get_term_joined: string:',$obj,true);//never fired, we probably do not need it
52
+ }
53
+ return $obj;
54
+ }
55
+
56
+ function qtranxf_get_terms_joined($terms, $taxonomies=null, $args=null) {
57
+ global $q_config;
58
+ if(is_array($terms)){
59
+ // handle arrays recursively
60
+ foreach($terms as $key => $term) {
61
+ $terms[$key] = qtranxf_get_terms_joined($term);
62
+ }
63
+ }else{
64
+ $terms = qtranxf_get_term_joined($terms);
65
+ }
66
+ return $terms;
67
+ }
68
+
69
+ function qtranxf_useAdminTermLibJoin($obj, $taxonomies=null, $args=null) {
70
+ global $pagenow;
71
+ //qtranxf_dbg_echo('qtranxf_useAdminTermLibJoin: $pagenow='.$pagenow);
72
+ //qtranxf_dbg_echo('qtranxf_useAdminTermLibJoin: $obj:',$obj);
73
+ //qtranxf_dbg_echo('qtranxf_useAdminTermLibJoin: $taxonomies:',$taxonomies);
74
+ //qtranxf_dbg_echo('qtranxf_useAdminTermLibJoin: $args:',$args);
75
+ switch($pagenow){
76
+ case 'nav-menus.php':
77
+ case 'edit-tags.php':
78
+ return qtranxf_get_terms_joined($obj);
79
+ default: return qtranxf_useTermLib($obj);
80
+ }
81
+ }
82
+ add_filter('get_term', 'qtranxf_useAdminTermLibJoin',0, 2);
83
+ add_filter('get_terms', 'qtranxf_useAdminTermLibJoin',0, 3);
84
+
85
+ //does someone use it?
86
+ function qtranxf_useAdminTermLib($obj) {
87
+ //qtranxf_dbg_echo('qtranxf_useAdminTermLib: $obj: ',$obj,true);
88
+ if ($script_name==='/wp-admin/edit-tags.php' &&
89
+ strstr($_SERVER['QUERY_STRING'], 'action=edit' )!==FALSE)
90
+ {
91
+ return $obj;
92
+ }
93
+ else
94
+ {
95
+ return qtranxf_useTermLib($obj);
96
+ }
97
+ }
98
+ //add_filter('get_term', 'qtranxf_useAdminTermLib',0);
99
+ //add_filter('get_terms', 'qtranxf_useAdminTermLib',0);
100
+
101
+
102
+ function qtranxf_updateTermLibrary() {
103
+ global $q_config;
104
+ if(!isset($_POST['action'])) return;
105
+ switch($_POST['action']) {
106
+ case 'editedtag':
107
+ case 'addtag':
108
+ case 'editedcat':
109
+ case 'addcat':
110
+ case 'add-cat':
111
+ case 'add-tag':
112
+ case 'add-link-cat':
113
+ if(isset($_POST['qtrans_term_'.$q_config['default_language']]) && $_POST['qtrans_term_'.$q_config['default_language']]!='') {
114
+ $default = htmlspecialchars(qtranxf_stripSlashesIfNecessary($_POST['qtrans_term_'.$q_config['default_language']]), ENT_NOQUOTES);
115
+ if(!isset($q_config['term_name'][$default]) || !is_array($q_config['term_name'][$default])) $q_config['term_name'][$default] = array();
116
+ foreach($q_config['enabled_languages'] as $lang) {
117
+ $_POST['qtrans_term_'.$lang] = qtranxf_stripSlashesIfNecessary($_POST['qtrans_term_'.$lang]);
118
+ if($_POST['qtrans_term_'.$lang]!='') {
119
+ $q_config['term_name'][$default][$lang] = htmlspecialchars($_POST['qtrans_term_'.$lang], ENT_NOQUOTES);
120
+ } else {
121
+ $q_config['term_name'][$default][$lang] = $default;
122
+ }
123
+ }
124
+ update_option('qtranslate_term_name',$q_config['term_name']);
125
+ }
126
+ break;
127
+ }
128
+ }
129
+
130
+ function qtranxf_updateTermLibraryJoin() {
131
+ global $q_config;
132
+ if(!isset($_POST['action'])) return;
133
+ $action=$_POST['action'];
134
+ if(!isset($_POST['qtrans_term_field_name'])) return;
135
+ $field=$_POST['qtrans_term_field_name'];
136
+ $default_name_original=$_POST['qtrans_term_field_default_name'];
137
+ //qtranxf_dbg_log('$_POST:',$_POST);
138
+ $field_value = qtranxf_stripSlashesIfNecessary($_POST[$field]);
139
+ //qtranxf_dbg_log('$field_value='.$field_value);
140
+ $names=qtranxf_split($field_value);
141
+ //qtranxf_dbg_log('names=',$names);
142
+ $default_name=htmlspecialchars($names[$q_config['default_language']], ENT_NOQUOTES);
143
+ $_POST[$field]=$default_name;
144
+ if(empty($default_name))
145
+ return;//will generate error later from WP
146
+ foreach($names as $lang => $name){
147
+ $q_config['term_name'][$default_name_original][$lang] = htmlspecialchars($name, ENT_NOQUOTES);
148
+ }
149
+ if($default_name_original != $default_name){
150
+ $q_config['term_name'][$default_name]=$q_config['term_name'][$default_name_original];
151
+ unset($q_config['term_name'][$default_name_original]);
152
+ }
153
+ update_option('qtranslate_term_name',$q_config['term_name']);
154
+ }
155
+
156
+ /*
157
+ function qtranxf_edit_terms($term_id, $taxonomy){
158
+ //qtranxf_dbg_log('qtranxf_edit_terms: $name='.$name);
159
+ }
160
+ add_action('edit_terms','qtranxf_edit_terms');
161
+ */
162
+
163
+ function qtranxf_language_columns($columns) {
164
+ return array(
165
+ 'flag' => __('Flag', 'qtranslate'),
166
+ 'name' => __('Name', 'qtranslate'),
167
+ 'status' => __('Action', 'qtranslate'),
168
+ 'status2' => '',
169
+ 'status3' => ''
170
+ );
171
+ }
172
+
173
+ function qtranxf_languageColumnHeader($columns){
174
+ $new_columns = array();
175
+ if(isset($columns['cb'])) $new_columns['cb'] = '';
176
+ if(isset($columns['title'])) $new_columns['title'] = '';
177
+ if(isset($columns['author'])) $new_columns['author'] = '';
178
+ if(isset($columns['categories'])) $new_columns['categories'] = '';
179
+ if(isset($columns['tags'])) $new_columns['tags'] = '';
180
+ $new_columns['language'] = __('Languages', 'qtranslate');
181
+ return array_merge($new_columns, $columns);;
182
+ }
183
+
184
+ function qtranxf_languageColumn($column) {
185
+ global $q_config, $post;
186
+ if ($column == 'language') {
187
+ $available_languages = qtranxf_getAvailableLanguages($post->post_content);
188
+ $missing_languages = array_diff($q_config['enabled_languages'], $available_languages);
189
+ $available_languages_name = array();
190
+ $missing_languages_name = array();
191
+ foreach($available_languages as $language) {
192
+ $available_languages_name[] = $q_config['language_name'][$language];
193
+ }
194
+ $available_languages_names = join(", ", $available_languages_name);
195
+
196
+ echo apply_filters('qtranslate_available_languages_names',$available_languages_names);
197
+ do_action('qtranslate_languageColumn', $available_languages, $missing_languages);
198
+ }
199
+ return $column;
200
+ }
201
+
202
+ function qtranxf_admin_list_cats($text) {
203
+ global $pagenow;
204
+ //qtranxf_dbg_echo('qtranxf_admin_list_cats: $text',$text);
205
+ switch($pagenow){
206
+ case 'edit-tags.php':
207
+ //replace [:] with <:>
208
+ $blocks = qtranxf_get_language_blocks($text);
209
+ if(count($blocks)<=1) return $text;
210
+ $texts = qtranxf_split_blocks($blocks);
211
+ $text = qtranxf_join_c($texts);
212
+ return $text;
213
+ default: return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text);
214
+ }
215
+ }
216
+ add_filter('list_cats', 'qtranxf_admin_list_cats',0);
217
+
218
+ function qtranxf_admin_dropdown_cats($text) {
219
+ global $pagenow;
220
+ //qtranxf_dbg_echo('qtranxf_admin_list_cats: $text',$text);
221
+ switch($pagenow){
222
+ case 'edit-tags.php':
223
+ return $text;
224
+ default: return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text);
225
+ }
226
+ }
227
+ add_filter('wp_dropdown_cats', 'qtranxf_admin_dropdown_cats',0);
228
+
229
+ function qtranxf_admin_category_description($text) {
230
+ global $pagenow;
231
+ switch($pagenow){
232
+ case 'edit-tags.php':
233
+ return $text;
234
+ default: return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text);
235
+ }
236
+ }
237
+ add_filter('category_description', 'qtranxf_admin_category_description',0);
238
+
239
+ function qtranxf_admin_the_title($title) {
240
+ global $pagenow;
241
+ switch($pagenow){
242
+ //case 'edit-tags.php':
243
+ case 'nav-menus.php':
244
+ return $title;
245
+ default: return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($title);
246
+ }
247
+ }
248
+ add_filter('the_title', 'qtranxf_admin_the_title', 0);//WP: fires for display purposes only
249
+
250
+ //filter added in qtranslate_hooks.php
251
+ function qtranxf_trim_words( $text, $num_words, $more, $original_text ) {
252
+ global $q_config;
253
+ //qtranxf_dbg_log('qtranxf_trim_words: $text: ',$text);
254
+ //qtranxf_dbg_log('qtranxf_trim_words: $original_text: ',$original_text);
255
+ $blocks = qtranxf_get_language_blocks($original_text);
256
+ //qtranxf_dbg_log('qtranxf_trim_words: $blocks: ',$blocks);
257
+ if ( count($blocks) <= 1 )
258
+ return $text;
259
+ $lang = $q_config['language'];
260
+ $texts = qtranxf_split_blocks($blocks);
261
+ foreach($texts as $key => $txt){
262
+ $texts[$key] = wp_trim_words($txt, $num_words, $more);
263
+ }
264
+ return qtranxf_join_b($texts);//has to be 'b', because 'c' gets stripped in /wp-admin/includes/nav-menu.php:182: esc_html( $item->description )
265
+ }
266
+
267
+ /**
268
+ * The same as core wp_htmledit_pre in /wp-includes/formatting.php,
269
+ * but with last argument of htmlspecialchars $double_encode off,
270
+ * which makes it to survive multiple applications from other plugins,
271
+ * for example, "PS Disable Auto Formatting" (https://wordpress.org/plugins/ps-disable-auto-formatting/)
272
+ * cited on support thread https://wordpress.org/support/topic/incompatibility-with-ps-disable-auto-formatting.
273
+ * @since 2.9.8.9
274
+ */
275
+ if(!function_exists('qtranxf_htmledit_pre')){
276
+ function qtranxf_htmledit_pre($output) {
277
+ if ( !empty($output) )
278
+ $output = htmlspecialchars($output, ENT_NOQUOTES, get_option( 'blog_charset' ), false ); // convert only < > &
279
+ return apply_filters( 'htmledit_pre', $output );
280
+ }
281
+ }
282
+
283
+ function qtranxf_the_editor($editor_div)
284
+ {
285
+ // remove wpautop, which causes unmatched <p> on combined language strings
286
+ if('html' != wp_default_editor()) {
287
+ remove_filter('the_editor_content', 'wp_richedit_pre');
288
+ add_filter('the_editor_content', 'qtranxf_htmledit_pre', 99);
289
+ }
290
+ return $editor_div;
291
+ }
292
+ //applied in /wp-includes/class-wp-editor.php
293
+ add_filter('the_editor', 'qtranxf_the_editor');
294
+
295
+ add_filter('manage_language_columns', 'qtranxf_language_columns');
296
+ add_filter('manage_posts_columns', 'qtranxf_languageColumnHeader');
297
+ add_filter('manage_posts_custom_column', 'qtranxf_languageColumn');
298
+ add_filter('manage_pages_columns', 'qtranxf_languageColumnHeader');
299
+ add_filter('manage_pages_custom_column', 'qtranxf_languageColumn');
300
+ ?>
admin/import_export.php CHANGED
@@ -70,7 +70,7 @@ function qtranxf_migrate_plugins()
70
qtranxf_migrate_plugin('qtranslate-xp');
71
//qtranxf_migrate_plugin('ztranslate');//ok same db
72
}
73
- add_action('qtranxf_init_begin','qtranxf_migrate_plugins',11);
74
75
function qtranxf_add_row_migrate($nm,$plugin) {
76
if(!file_exists(WP_CONTENT_DIR.'/plugins/'.$plugin)) return;
@@ -96,9 +96,10 @@ function qtranxf_add_row_migrate($nm,$plugin) {
96
97
function qtranxf_admin_section_import_export($request_uri)
98
{
99
- qtranxf_admin_section_start(__('Import').'/'.__('Export'),'import');
100
?>
101
- <table class="form-table" id="qtranslate-admin-import" style="display: none">
102
<tr valign="top" id="qtranslate-convert-database">
103
<th scope="row"><?php _e('Convert Database', 'qtranslate');?></th>
104
<td>
70
qtranxf_migrate_plugin('qtranslate-xp');
71
//qtranxf_migrate_plugin('ztranslate');//ok same db
72
}
73
+ add_action('qtranslate_init_begin','qtranxf_migrate_plugins',11);
74
75
function qtranxf_add_row_migrate($nm,$plugin) {
76
if(!file_exists(WP_CONTENT_DIR.'/plugins/'.$plugin)) return;
96
97
function qtranxf_admin_section_import_export($request_uri)
98
{
99
+ qtranxf_admin_section_start(__('Import', 'qtranslate').'/'.__('Export', 'qtranslate'),'import');
100
+ //id="qtranslate-admin-import" style="display: none"
101
?>
102
+ <table class="form-table">
103
<tr valign="top" id="qtranslate-convert-database">
104
<th scope="row"><?php _e('Convert Database', 'qtranslate');?></th>
105
<td>
admin/js/common.js ADDED
@@ -0,0 +1,626 @@
1
+ /*
2
+ //debuging tools, do not check in
3
+ */
4
+ var cc=0;
5
+ function c(v){ ++cc; console.log('== '+cc+': '+v); }
6
+ function ct(v){ c(v); console.trace(); }
7
+ function co(t,o){ ++cc; console.log('== '+cc+': '+t+': %o',o); }
8
+
9
+ qtranxj_split = function(text,keep_neutral_text)
10
+ {
11
+ var result = new Object;
12
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
13
+ {
14
+ var lang=qTranslateConfig.enabled_languages[i];
15
+ result[lang] = '';
16
+ }
17
+ var split_regex = /(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\])/gi;
18
+ var blocks = text.xsplit(split_regex);
19
+ if(!qtranxj_isArray(blocks))
20
+ return result;
21
+ if(blocks.length==1){//no language separator found, enter it to all languages
22
+ var b=blocks[0];
23
+ for(var j=0; j<qTranslateConfig.enabled_languages.length; ++j){
24
+ var lang=qTranslateConfig.enabled_languages[j];
25
+ result[lang] += b;
26
+ }
27
+ return result;
28
+ }
29
+ var clang_regex=/<!--:([a-z]{2})-->/gi;
30
+ var c_end_regex=/<!--:-->/g;
31
+ var blang_regex=/\[:([a-z]{2})\]/gi;
32
+ lang = false;
33
+ for(var i = 0;i<blocks.length;++i){
34
+ var b=blocks[i];
35
+ //c('blocks['+i+']='+b);
36
+ if(!b.length) continue;
37
+ matches = clang_regex.exec(b); clang_regex.lastIndex=0;
38
+ if(matches!=null){
39
+ lang = matches[1];
40
+ continue;
41
+ }
42
+ matches = c_end_regex.exec(b); c_end_regex.lastIndex=0;
43
+ if(matches!=null){
44
+ lang = false;
45
+ continue;
46
+ }
47
+ matches = blang_regex.exec(b); blang_regex.lastIndex=0;
48
+ if(matches!=null){
49
+ lang = matches[1];
50
+ continue;
51
+ }
52
+ if(lang){
53
+ result[lang] += b;
54
+ lang = false;
55
+ }else if(keep_neutral_text){
56
+ for(var key in result){
57
+ result[key] += b;
58
+ }
59
+ }
60
+ }
61
+ return result;
62
+ }
63
+
64
+ qtranxj_allthesame = function(texts)
65
+ {
66
+ if(qTranslateConfig.enabled_languages.length==0) return '';
67
+ var text = '';
68
+ //take first not empty
69
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
70
+ {
71
+ var lang=qTranslateConfig.enabled_languages[i];
72
+ var t = texts[lang];
73
+ if ( !t || t=='' ) continue;
74
+ text = t;
75
+ break;
76
+ }
77
+ if ( text=='' ) return text;
78
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
79
+ {
80
+ var lang=qTranslateConfig.enabled_languages[i];
81
+ var t = texts[lang];
82
+ if ( t == text ) continue;
83
+ return null;
84
+ }
85
+ return text;
86
+ }
87
+
88
+ //"_c" stands for "comment"
89
+ qtranxj_join_c = function(texts)
90
+ {
91
+ var text = qtranxj_allthesame(texts);
92
+ if(text!=null) return text;
93
+ text='';
94
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
95
+ {
96
+ var lang=qTranslateConfig.enabled_languages[i];
97
+ var t = texts[lang];
98
+ if ( !t || t=='' ) continue;
99
+ text += '<!--:'+lang+'-->';
100
+ text += t;
101
+ text += '<!--:-->';
102
+ }
103
+ //c('qtranxj_join_c:text:'+text);
104
+ return text;
105
+ }
106
+
107
+ //"b" stands for "bracket"
108
+ qtranxj_join_b = function(texts)
109
+ {
110
+ var text = qtranxj_allthesame(texts);
111
+ if(text!=null) return text;
112
+ var text = '';
113
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
114
+ {
115
+ var lang=qTranslateConfig.enabled_languages[i];
116
+ var t = texts[lang];
117
+ if ( !t || t=='' ) continue;
118
+ text += '[:'+lang+']';
119
+ text += t;
120
+ }
121
+ return text;
122
+ }
123
+
124
+ function qtranxj_get_cookie(cname)
125
+ {
126
+ var nm = cname + "=";
127
+ var ca = document.cookie.split(';');
128
+ //c('ca='+ca);
129
+ for(var i=0; i<ca.length; ++i){
130
+ var s = ca[i];
131
+ var sa = s.split('=');
132
+ if(sa[0].trim()!=cname) continue;
133
+ if(ca.length<2) continue;
134
+ return sa[1].trim();
135
+ }
136
+ return '';
137
+ }
138
+
139
+ String.prototype.xsplit = function(_regEx){
140
+ // Most browsers can do this properly, so let them work, they'll do it faster
141
+ if ('a~b'.split(/(~)/).length === 3){ return this.split(_regEx); }
142
+
143
+ if (!_regEx.global)
144
+ { _regEx = new RegExp(_regEx.source, 'g' + (_regEx.ignoreCase ? 'i' : '')); }
145
+
146
+ // IE (and any other browser that can't capture the delimiter)
147
+ // will, unfortunately, have to be slowed down
148
+ var start = 0, arr=[];
149
+ var result;
150
+ while((result = _regEx.exec(this)) != null){
151
+ arr.push(this.slice(start, result.index));
152
+ if(result.length > 1) arr.push(result[1]);
153
+ start = _regEx.lastIndex;
154
+ }
155
+ if(start < this.length) arr.push(this.slice(start));
156
+ if(start == this.length) arr.push(''); //delim at the end
157
+ return arr;
158
+ };
159
+
160
+ function qtranxj_isArray(obj){ return obj.constructor.toString().indexOf('Array') >= 0; }
161
+
162
+ function qtranxj_ce(tagName, props, pNode, isFirst)
163
+ {
164
+ var el= document.createElement(tagName);
165
+ if (props)
166
+ {
167
+ for(prop in props)
168
+ {
169
+ //try
170
+ {
171
+ el[prop]=props[prop];
172
+ }
173
+ //catch(err)
174
+ {
175
+ //Handle errors here
176
+ }
177
+ }
178
+ }
179
+ if (pNode)
180
+ {
181
+ if (isFirst && pNode.firstChild)
182
+ {
183
+ pNode.insertBefore(el, pNode.firstChild);
184
+ }
185
+ else
186
+ {
187
+ pNode.appendChild(el);
188
+ }
189
+ }
190
+ return el;
191
+ }
192
+
193
+ var qTranslateX=function(pg)
194
+ {
195
+ this.ge=function(id){ return document.getElementById(id); }
196
+
197
+ isLanguageEnabled=function(lang)
198
+ {
199
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i){
200
+ if(qTranslateConfig.enabled_languages[i]==lang) return true;
201
+ }
202
+ return false;
203
+ }
204
+
205
+ qTranslateConfig.activeLanguage = qtranxj_get_cookie('qtrans_edit_language');
206
+ if(!qTranslateConfig.activeLanguage || !isLanguageEnabled(qTranslateConfig.activeLanguage))
207
+ qTranslateConfig.activeLanguage = qTranslateConfig.language;
208
+
209
+ this.getActiveLanguage=function() { return qTranslateConfig.activeLanguage; }
210
+
211
+ var displayHooks=[];
212
+ var contentHooks={};
213
+
214
+ updateFusedValueHooked=function(h)
215
+ {
216
+ if(h.separator==='<'){
217
+ h.mlContentField.value = qtranxj_join_c(h.contents);
218
+ }else{
219
+ h.mlContentField.value = qtranxj_join_b(h.contents);
220
+ }
221
+ //c('updateFusedValueHooked['+h.mce.id+'] text:'+h.mlContentField.value);
222
+ }
223
+
224
+ updateFusedValueH=function(id,value)
225
+ {
226
+ var h=contentHooks[id];
227
+ var text=value.trim();
228
+ //c('updateFusedValueH['+id+'] lang='+h.lang+'; text:'+text);
229
+ h.contents[h.lang]=text;
230
+ updateFusedValueHooked(h);
231
+ }
232
+
233
+ addContentHook=function(inpField,form,separator)
234
+ {
235
+ //co('inpField:',inpField);
236
+ if( !inpField ) return false;
237
+ //if( typeof inpField.value !== 'string' ) return false;
238
+ if(contentHooks[inpField.id]) return true;
239
+ var h=contentHooks[inpField.id]={};
240
+ //h.id=inpField.id;
241
+ h.contentField=inpField;
242
+ //c('addContentHook:inpField.value='+inpField.value);
243
+ //h.contents=qtranxj_split(inpField.value,false);
244
+ h.contents=qtranxj_split(inpField.value,true);//keep neutral text from older times, just in case.
245
+ //inpField.tagName
246
+ h.mlContentField=qtranxj_ce('input', {name: inpField.name, type: 'hidden', className: 'hidden', value: inpField.value}, form, true);
247
+ if(!separator){
248
+ if(inpField.tagName==='TEXTAREA')
249
+ separator='<';
250
+ else
251
+ separator='[';
252
+ }
253
+ h.separator=separator;
254
+ inpField.name='edit-'+inpField.name;
255
+ h.lang=qTranslateConfig.activeLanguage;
256
+ var text = h.contents[h.lang];
257
+ inpField.value=text;
258
+ //c('addContentHook['+inpField.id+']['+h.lang+']: inpField.value='+inpField.value);
259
+ inpField.onblur=function(){ updateFusedValueH(this.id,this.value); }
260
+ /*
261
+ if(inpField.tagName==='TEXTAREA'){
262
+ //c('addContentHook:inpField.value='+inpField.value);
263
+ for(var lang in h.contents){
264
+ //c('addContentHook:h.contents['+lang+']:'+h.contents[lang]);
265
+ }
266
+ }
267
+ */
268
+ if(window.tinyMCE){//never fired yet
269
+ for(var i=0; i<tinyMCE.editors.length; ++i){
270
+ var ed=tinyMCE.editors[i];
271
+ if(ed.id != inpField.id) continue;
272
+ //c('addContentHook:updateTinyMCE');
273
+ h.mce=ed;
274
+ updateTinyMCE(ed,text);
275
+ }
276
+ }
277
+ return h;
278
+ }
279
+ this.addContentHookC=function(inpField,form) { return addContentHook(inpField,form,'<'); }
280
+ this.addContentHookB=function(inpField,form) { return addContentHook(inpField,form,'['); }
281
+
282
+ this.addContentHookById=function(id,form,sep) { return addContentHook(this.ge(id),form,sep); }
283
+ this.addContentHookByIdName=function(nm,form)
284
+ {
285
+ var sep;
286
+ if(nm.indexOf('<')==0 || nm.indexOf('[')==0){
287
+ sep=nm.substring(0,1);
288
+ nm=nm.substring(1);
289
+ }
290
+ return this.addContentHookById(nm,form,sep);
291
+ }
292
+ this.addContentHookByIdC=function(id,form) { return this.addContentHookById(id,form,'<'); }
293
+ this.addContentHookByIdB=function(id,form) { return this.addContentHookById(id,form,'['); }
294
+
295
+ addDisplayHook=function(elem)
296
+ {
297
+ if(!elem) return false;
298
+ var h={};
299
+ h.elem=elem;
300
+ var content = elem.innerHTML.replace(/&lt;!--:([a-z]{2}|)--&gt;/gi,'<!--:$1-->');//un-escape language HTML
301
+ //c('addDisplayHook: innerHTML='+elem.innerHTML);
302
+ //c('addDisplayHook: content='+content);
303
+ h.contents=qtranxj_split(content,true);
304
+ elem.innerHTML=h.contents[qTranslateConfig.activeLanguage];
305
+ displayHooks.push(h);
306
+ return true;
307
+ }
308
+ this.addDisplayHookById=function(id) { return addDisplayHook(this.ge(id)); }
309
+
310
+ setLangCookie=function(lang) { document.cookie='qtrans_edit_language='+lang; }
311
+
312
+ updateTinyMCE=function(ed,text)
313
+ {
314
+ /*
315
+ //c('updateTinyMCE: text:'+text);
316
+ if(!text.match(/^</)){
317
+ text='<p>'+text+'</p>';
318
+ //c('updateTinyMCE: updated text:'+text);
319
+ }
320
+ */
321
+ //c('updateTinyMCE: text:'+text);
322
+ if(window.switchEditors){
323
+ //text = window.switchEditors.pre_wpautop( text );
324
+ text = window.switchEditors.wpautop(text);
325
+ //c('updateTinyMCE:wpautop:'+text);
326
+ }
327
+ ed.setContent(text,{format: 'html'});
328
+ //ed.load({initial: false, format: 'html'});
329
+ }
330
+
331
+ onTabSwitch=function()
332
+ {
333
+ setLangCookie(this.lang);
334
+ for(var i=0; i<displayHooks.length; ++i){
335
+ var h=displayHooks[i];
336
+ h.elem.innerHTML=h.contents[this.lang];
337
+ }
338
+ for(var key in contentHooks){
339
+ var h=contentHooks[key];
340
+ var mce = h.mce && !h.mce.hidden;
341
+ if(mce){
342
+ //c('onTabSwitch: h['+key+'].contentField.value before save:'+h.contentField.value);
343
+ h.mce.save({format: 'html'});
344
+ h.contents[h.lang] = h.contentField.value;
345
+ }
346
+ h.lang = this.lang;
347
+ h.contentField.value=h.contents[this.lang];
348
+ //c('onTabSwitch: h['+key+'].contentField.value:'+h.contentField.value);
349
+ if(mce){
350
+ updateTinyMCE(h.mce,h.contentField.value);
351
+ }
352
+ }
353
+ /*
354
+ if (window.tinyMCE)
355
+ for(var i=0; i<tinyMCE.editors.length; ++i){
356
+ var ed=tinyMCE.editors[i];
357
+ var h=contentHooks[ed.id];
358
+ if(!h) continue;
359
+ updateTinyMCE(ed,h.contentField.value);
360
+ }
361
+ */
362
+ }
363
+
364
+ var qtx=this;
365
+ onTabSwitchCustom=function()
366
+ {
367
+ //co('onTabSwitch: this',this);
368
+ //co('onTabSwitch: pg',pg);
369
+ //co('onTabSwitch: qtx',qtx);
370
+ pg.onTabSwitch(this.lang,qtx);
371
+ }
372
+
373
+ addDisplayHooks=function(elems)
374
+ {
375
+ //c('addDisplayHooks: elems.length='+elems.length);
376
+ for(var i=0; i<elems.length; ++i){
377
+ var e=elems[i];
378
+ //co('addDisplayHooks: e=',e);
379
+ addDisplayHook(e);
380
+ }
381
+ }
382
+
383
+ this.addDisplayHooksByClass=function(nm,container)
384
+ {
385
+ var elems=container.getElementsByClassName(nm);
386
+ addDisplayHooks(elems);
387
+ }
388
+
389
+ this.addDisplayHooksByTagInClass=function(nm,tag,container)
390
+ {
391
+ var elems=container.getElementsByClassName(nm);
392
+ //c('addDisplayHooksByClass: elems.length='+elems.length);
393
+ for(var i=0; i<elems.length; ++i){
394
+ var elem=elems[i];
395
+ var items=elem.getElementsByTagName(tag);
396
+ addDisplayHooks(items);
397
+ }
398
+ }
399
+
400
+ addContentHooksByClassName=function(nm,form,container,sep)
401
+ {
402
+ if(!container) container=form;
403
+ var fields=container.getElementsByClassName(nm);
404
+ //if(sep=='[') //c('addContentHooksByClass: fields.length='+fields.length);
405
+ for(var i=0; i<fields.length; ++i){
406
+ var f=fields[i];
407
+ //if(sep=='[') //co('addContentHooksByClass: f: ',f);
408
+ addContentHook(f,form,sep);
409
+ }
410
+ }
411
+
412
+ this.addContentHooksByClass=function(nm,form,container)
413
+ {
414
+ var sep;
415
+ if(nm.indexOf('<')==0 || nm.indexOf('[')==0){
416
+ sep=nm.substring(0,1);
417
+ nm=nm.substring(1);
418
+ }
419
+ addContentHooksByClassName(nm,form,container,sep);
420
+ }
421
+
422
+ // adds custom hooks from configuration
423
+ this.addContentHooks=function(form)
424
+ {
425
+ //c('qTranslateConfig.custom_fields.length='+qTranslateConfig.custom_fields.length);
426
+ for(var i=0; i<qTranslateConfig.custom_fields.length; ++i){
427
+ var nm=qTranslateConfig.custom_fields[i];
428
+ this.addContentHookByIdName(nm,form);
429
+ }
430
+ for(var i=0; i<qTranslateConfig.custom_field_classes.length; ++i){
431
+ var nm=qTranslateConfig.custom_field_classes[i];
432
+ this.addContentHooksByClass(nm,form);
433
+ }
434
+ }
435
+
436
+ this.addPageHooks=function(page_config)
437
+ {
438
+ for(var i=0; i < page_config.forms.length; ++i){
439
+ var frm = page_config.forms[i];
440
+ var form = document.getElementById(frm.form.id);
441
+ //co('form=',form);
442
+ if(!form) continue;
443
+ for(var k=0; k < frm.fields.length; ++k){
444
+ var fld = frm.fields[k];
445
+ var sep = fld.encode;
446
+ //co('fld=',fld);
447
+ //c('sep='+sep);
448
+ if(fld.id) this.addContentHookById(fld.id,form,sep);
449
+ else if(fld.class) addContentHooksByClassName(fld.class,form,form,sep);
450
+ else{
451
+ //todo tag, name
452
+ continue;
453
+ }
454
+ }
455
+ }
456
+ return true;
457
+ }
458
+
459
+ this.addContentHooksTinyMCE=function()
460
+ {
461
+ function setEditorHooks(ed)
462
+ {
463
+ var id = ed.id;
464
+ //c('setEditorHooks: id='+id);
465
+ //ct('setEditorHooks: id='+id);
466
+ if (!id) return;
467
+ var h=contentHooks[id];
468
+ if(!h) return;
469
+ if(h.mce) return;
470
+ h.mce=ed;
471
+ ed.getBody().addEventListener('blur',function(){
472
+ var h=contentHooks[ed.id];
473
+ //c('blur: h['+ed.id+'].contentField.value before save:'+h.contentField.value);
474
+ ed.save();
475
+ //c('blur: h['+ed.id+'].contentField.value after save:'+h.contentField.value);
476
+ h.contents[h.lang] = h.contentField.value;
477
+ updateFusedValueHooked(h);
478
+ });
479
+ return h;
480
+ }
481
+
482
+ // Add listeners for fields change
483
+ window.addEventListener('load', function(){
484
+ if (!window.tinyMCE){
485
+ //alert('qTranslate-X error: !window.tinyMCE. Please report this incident to the developers.');
486
+ return;
487
+ }
488
+ for(var i=0; i<tinyMCE.editors.length; ++i){
489
+ var ed=tinyMCE.editors[i];
490
+ var h=setEditorHooks(ed);
491
+ if(!h) continue;
492
+ //c('addEventListener: id='+ed.id);
493
+ //c('h.contentField.value='+h.contentField.value);
494
+ updateTinyMCE(ed,h.contentField.value);
495
+ }
496
+ for(var key in contentHooks){
497
+ var h=contentHooks[key];
498
+ if(h.mce) continue;
499
+ if(h.contentField.tagName!=='TEXTAREA') continue;
500
+ tinyMCEPreInit.mceInit[key].init_instance_callback=function(ed){ setEditorHooks(ed); }
501
+ }
502
+ });
503
+ }
504
+
505
+ this.getWrapForm=function(){
506
+ var wraps = document.getElementsByClassName('wrap');
507
+ for(var i=0; i < wraps.length; ++i){
508
+ var w = wraps[i];
509
+ var forms = w.getElementsByTagName('form');
510
+ if(forms.length) return forms[0];
511
+ }
512
+ var forms = document.getElementsByTagName('form');
513
+ for(var i=0; i < forms.length; ++i){
514
+ var f = forms[i];
515
+ wraps = f.getElementsByClassName('wrap');
516
+ if(wraps.length) return f;
517
+ }
518
+ return null;
519
+ }
520
+
521
+ this.getFormWrap=function(){
522
+ var forms = document.getElementsByTagName('form');
523
+ for(var i=0; i < forms.length; ++i){
524
+ var f = forms[i];
525
+ var wraps = f.getElementsByClassName('wrap');
526
+ if(wraps.length) return wraps[0];
527
+ }
528
+ var wraps = document.getElementsByClassName('wrap');
529
+ for(var i=0; i < wraps.length; ++i){
530
+ var w = wraps[i];
531
+ forms = w.getElementsByTagName('form');
532
+ if(forms.length) return w;
533
+ }
534
+ return null;
535
+ }
536
+
537
+ if( typeof(pg.addContentHooks) == "function" && !pg.addContentHooks(this) )
538
+ return;
539
+
540
+ if( qTranslateConfig.page_config && !this.addPageHooks(qTranslateConfig.page_config) )
541
+ return;
542
+
543
+ {
544
+ var anchors=[];
545
+ if(qTranslateConfig.page_config && qTranslateConfig.page_config.anchors){
546
+ for(var i=0; i < qTranslateConfig.page_config.anchors.length; ++i){
547
+ var anchor = qTranslateConfig.page_config.anchors[i];
548
+ var f = document.getElementById(anchor);
549
+ if(f) anchors.push(f);
550
+ }
551
+ }
552
+ if(!anchors.length){
553
+ var f=pg.langSwitchWrapAnchor;
554
+ if(!f){
555
+ f = this.getWrapForm();
556
+ }
557
+ if(!f){
558
+ f = this.getWrapForm();
559
+ //var w = document.getElementsByClassName('wrap')[0];
560
+ //f = w.getElementsByTagName('form')[0];
561
+ }
562
+ if(f) anchors.push(f);
563
+ }
564
+ for(var i=0; i < anchors.length; ++i){
565
+ var anchor = anchors[i];
566
+ var langSwitchWrap=qtranxj_ce('ul', {className: 'qtranxs-lang-switch-wrap'});
567
+ //var header=w.getElementsByTagName('h2')[0];
568
+ //header.parentNode.insertBefore(langSwitchWrap, header.nextElementSibling);
569
+ anchor.parentNode.insertBefore( langSwitchWrap, anchor );
570
+ var languageSwitch = new qtranxj_LanguageSwitch(langSwitchWrap);
571
+ languageSwitch.onSwitch(onTabSwitch);
572
+ if(pg.onTabSwitch)
573
+ languageSwitch.onSwitch(onTabSwitchCustom);
574
+ }
575
+ }
576
+ }
577
+
578
+ function qtranxj_LanguageSwitch(target)
579
+ {
580
+ var langs=qTranslateConfig.enabled_languages, langNames=qTranslateConfig.language_name;
581
+ var tabSwitches={};
582
+ var onTabSwitchFunctions=[];
583
+ function switchTab()
584
+ {
585
+ var tabSwitch=this;
586
+ if (!tabSwitch.lang){
587
+ alert('qTranslate-X: This should not have happened: Please, report this incident to the developers: !tabSwitch.lang');
588
+ return;
589
+ }
590
+ if ( qTranslateConfig.activeLanguage === tabSwitch.lang ){
591
+ return;
592
+ }
593
+ if (qTranslateConfig.activeLanguage)
594
+ {
595
+ tabSwitches[qTranslateConfig.activeLanguage].classList.remove('active');
596
+ }
597
+ qTranslateConfig.activeLanguage=tabSwitch.lang;
598
+ tabSwitch.classList.add('active');
599
+ for(var i=0; i<onTabSwitchFunctions.length; ++i)
600
+ {
601
+ onTabSwitchFunctions[i].call(this);
602
+ }
603
+ }
604
+ //location.pathname.indexOf();
605
+ for(var i=0; i<langs.length; ++i)
606
+ {
607
+ //var flags_location=qTranslateConfig.WP_CONTENT_URL+qTranslateConfig.flag_location;
608
+ var flag_location=qTranslateConfig.flag_location;
609
+ var lang=langs[i];
610
+ var tabSwitch=qtranxj_ce ('li', {lang: lang, className: 'qtranxs-lang-switch', onclick: switchTab }, target );
611
+ qtranxj_ce('img', {src: flag_location+qTranslateConfig.flag[lang]}, tabSwitch);
612
+ qtranxj_ce('span', {innerHTML: langNames[lang]}, tabSwitch);
613
+ tabSwitches[lang]=tabSwitch;
614
+ if ( qTranslateConfig.activeLanguage == lang )
615
+ tabSwitch.classList.add('active');
616
+ }
617
+ this.onSwitch=function(callback)
618
+ {
619
+ if (typeof callback==='function')
620
+ {
621
+ onTabSwitchFunctions.push(callback);
622
+ }
623
+ }
624
+ }
625
+
626
+ jQuery(document).ready(function($){ new qTranslateX(qTranslateConfig.js); });
admin/js/common.min.js ADDED
@@ -0,0 +1 @@
1
+ function c(n){++cc,console.log("== "+cc+": "+n)}function ct(n){c(n),console.trace()}function co(n,e){++cc,console.log("== "+cc+": "+n+": %o",e)}function qtranxj_get_cookie(n){for(var e=document.cookie.split(";"),a=0;a<e.length;++a){var t=e[a],o=t.split("=");if(o[0].trim()==n&&!(e.length<2))return o[1].trim()}return""}function qtranxj_isArray(n){return n.constructor.toString().indexOf("Array")>=0}function qtranxj_ce(n,e,a,t){var o=document.createElement(n);if(e)for(prop in e)o[prop]=e[prop];return a&&(t&&a.firstChild?a.insertBefore(o,a.firstChild):a.appendChild(o)),o}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&&o[qTranslateConfig.activeLanguage].classList.remove("active"),qTranslateConfig.activeLanguage=n.lang,n.classList.add("active");for(var e=0;e<i.length;++e)i[e].call(this)}}for(var a=qTranslateConfig.enabled_languages,t=qTranslateConfig.language_name,o={},i=[],r=0;r<a.length;++r){var s=qTranslateConfig.flag_location,l=a[r],g=qtranxj_ce("li",{lang:l,className:"qtranxs-lang-switch",onclick:e},n);qtranxj_ce("img",{src:s+qTranslateConfig.flag[l]},g),qtranxj_ce("span",{innerHTML:t[l]},g),o[l]=g,qTranslateConfig.activeLanguage==l&&g.classList.add("active")}this.onSwitch=function(n){"function"==typeof n&&i.push(n)}}var cc=0;qtranxj_split=function(n,e){for(var a=new Object,t=0;t<qTranslateConfig.enabled_languages.length;++t){var o=qTranslateConfig.enabled_languages[t];a[o]=""}var i=/(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\])/gi,r=n.xsplit(i);if(!qtranxj_isArray(r))return a;if(1==r.length){for(var s=r[0],l=0;l<qTranslateConfig.enabled_languages.length;++l){var o=qTranslateConfig.enabled_languages[l];a[o]+=s}return a}var g=/<!--:([a-z]{2})-->/gi,d=/<!--:-->/g,u=/\[:([a-z]{2})\]/gi;o=!1;for(var t=0;t<r.length;++t){var s=r[t];if(s.length)if(matches=g.exec(s),g.lastIndex=0,null==matches)if(matches=d.exec(s),d.lastIndex=0,null==matches)if(matches=u.exec(s),u.lastIndex=0,null==matches){if(o)a[o]+=s,o=!1;else if(e)for(var c in a)a[c]+=s}else o=matches[1];else o=!1;else o=matches[1]}return a},qtranxj_allthesame=function(n){if(0==qTranslateConfig.enabled_languages.length)return"";for(var e="",a=0;a<qTranslateConfig.enabled_languages.length;++a){var t=qTranslateConfig.enabled_languages[a],o=n[t];if(o&&""!=o){e=o;break}}if(""==e)return e;for(var a=0;a<qTranslateConfig.enabled_languages.length;++a){var t=qTranslateConfig.enabled_languages[a],o=n[t];if(o!=e)return null}return e},qtranxj_join_c=function(n){var e=qtranxj_allthesame(n);if(null!=e)return e;e="";for(var a=0;a<qTranslateConfig.enabled_languages.length;++a){var t=qTranslateConfig.enabled_languages[a],o=n[t];o&&""!=o&&(e+="<!--:"+t+"-->",e+=o,e+="<!--:-->")}return e},qtranxj_join_b=function(n){var e=qtranxj_allthesame(n);if(null!=e)return e;for(var e="",a=0;a<qTranslateConfig.enabled_languages.length;++a){var t=qTranslateConfig.enabled_languages[a],o=n[t];o&&""!=o&&(e+="[:"+t+"]",e+=o)}return e},String.prototype.xsplit=function(n){if(3==="a~b".split(/(~)/).length)return this.split(n);n.global||(n=new RegExp(n.source,"g"+(n.ignoreCase?"i":"")));for(var e,a=0,t=[];null!=(e=n.exec(this));)t.push(this.slice(a,e.index)),e.length>1&&t.push(e[1]),a=n.lastIndex;return a<this.length&&t.push(this.slice(a)),a==this.length&&t.push(""),t};var qTranslateX=function(n){this.ge=function(n){return document.getElementById(n)},isLanguageEnabled=function(n){for(var e=0;e<qTranslateConfig.enabled_languages.length;++e)if(qTranslateConfig.enabled_languages[e]==n)return!0;return!1},qTranslateConfig.activeLanguage=qtranxj_get_cookie("qtrans_edit_language"),qTranslateConfig.activeLanguage&&isLanguageEnabled(qTranslateConfig.activeLanguage)||(qTranslateConfig.activeLanguage=qTranslateConfig.language),this.getActiveLanguage=function(){return qTranslateConfig.activeLanguage};var e=[],a={};updateFusedValueHooked=function(n){n.mlContentField.value="<"===n.separator?qtranxj_join_c(n.contents):qtranxj_join_b(n.contents)},updateFusedValueH=function(n,e){var t=a[n],o=e.trim();t.contents[t.lang]=o,updateFusedValueHooked(t)},addContentHook=function(n,e,t){if(!n)return!1;if(a[n.id])return!0;var o=a[n.id]={};o.contentField=n,o.contents=qtranxj_split(n.value,!0),o.mlContentField=qtranxj_ce("input",{name:n.name,type:"hidden",className:"hidden",value:n.value},e,!0),t||(t="TEXTAREA"===n.tagName?"<":"["),o.separator=t,n.name="edit-"+n.name,o.lang=qTranslateConfig.activeLanguage;var i=o.contents[o.lang];if(n.value=i,n.onblur=function(){updateFusedValueH(this.id,this.value)},window.tinyMCE)for(var r=0;r<tinyMCE.editors.length;++r){var s=tinyMCE.editors[r];s.id==n.id&&(o.mce=s,updateTinyMCE(s,i))}return o},this.addContentHookC=function(n,e){return addContentHook(n,e,"<")},this.addContentHookB=function(n,e){return addContentHook(n,e,"[")},this.addContentHookById=function(n,e,a){return addContentHook(this.ge(n),e,a)},this.addContentHookByIdName=function(n,e){var a;return(0==n.indexOf("<")||0==n.indexOf("["))&&(a=n.substring(0,1),n=n.substring(1)),this.addContentHookById(n,e,a)},this.addContentHookByIdC=function(n,e){return this.addContentHookById(n,e,"<")},this.addContentHookByIdB=function(n,e){return this.addContentHookById(n,e,"[")},addDisplayHook=function(n){if(!n)return!1;var a={};a.elem=n;var t=n.innerHTML.replace(/&lt;!--:([a-z]{2}|)--&gt;/gi,"<!--:$1-->");return a.contents=qtranxj_split(t,!0),n.innerHTML=a.contents[qTranslateConfig.activeLanguage],e.push(a),!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;n<e.length;++n){var t=e[n];t.elem.innerHTML=t.contents[this.lang]}for(var o in a){var t=a[o],i=t.mce&&!t.mce.hidden;i&&(t.mce.save({format:"html"}),t.contents[t.lang]=t.contentField.value),t.lang=this.lang,t.contentField.value=t.contents[this.lang],i&&updateTinyMCE(t.mce,t.contentField.value)}};var t=this;if(onTabSwitchCustom=function(){n.onTabSwitch(this.lang,t)},addDisplayHooks=function(n){for(var e=0;e<n.length;++e){var a=n[e];addDisplayHook(a)}},this.addDisplayHooksByClass=function(n,e){var a=e.getElementsByClassName(n);addDisplayHooks(a)},this.addDisplayHooksByTagInClass=function(n,e,a){for(var t=a.getElementsByClassName(n),o=0;o<t.length;++o){var i=t[o],r=i.getElementsByTagName(e);addDisplayHooks(r)}},addContentHooksByClassName=function(n,e,a,t){a||(a=e);for(var o=a.getElementsByClassName(n),i=0;i<o.length;++i){var r=o[i];addContentHook(r,e,t)}},this.addContentHooksByClass=function(n,e,a){var t;(0==n.indexOf("<")||0==n.indexOf("["))&&(t=n.substring(0,1),n=n.substring(1)),addContentHooksByClassName(n,e,a,t)},this.addContentHooks=function(n){for(var e=0;e<qTranslateConfig.custom_fields.length;++e){var a=qTranslateConfig.custom_fields[e];this.addContentHookByIdName(a,n)}for(var e=0;e<qTranslateConfig.custom_field_classes.length;++e){var a=qTranslateConfig.custom_field_classes[e];this.addContentHooksByClass(a,n)}},this.addPageHooks=function(n){for(var e=0;e<n.forms.length;++e){var a=n.forms[e],t=document.getElementById(a.form.id);if(t)for(var o=0;o<a.fields.length;++o){var i=a.fields[o],r=i.encode;if(i.id)this.addContentHookById(i.id,t,r);else{if(!i.class)continue;addContentHooksByClassName(i.class,t,t,r)}}}return!0},this.addContentHooksTinyMCE=function(){function n(n){var e=n.id;if(e){var t=a[e];if(t&&!t.mce)return t.mce=n,n.getBody().addEventListener("blur",function(){var e=a[n.id];n.save(),e.contents[e.lang]=e.contentField.value,updateFusedValueHooked(e)}),t}}window.addEventListener("load",function(){if(window.tinyMCE){for(var e=0;e<tinyMCE.editors.length;++e){var t=tinyMCE.editors[e],o=n(t);o&&updateTinyMCE(t,o.contentField.value)}for(var i in a){var o=a[i];o.mce||"TEXTAREA"===o.contentField.tagName&&(tinyMCEPreInit.mceInit[i].init_instance_callback=function(e){n(e)})}}})},this.getWrapForm=function(){for(var n=document.getElementsByClassName("wrap"),e=0;e<n.length;++e){var a=n[e],t=a.getElementsByTagName("form");if(t.length)return t[0]}for(var t=document.getElementsByTagName("form"),e=0;e<t.length;++e){var o=t[e];if(n=o.getElementsByClassName("wrap"),n.length)return o}return null},this.getFormWrap=function(){for(var n=document.getElementsByTagName("form"),e=0;e<n.length;++e){var a=n[e],t=a.getElementsByClassName("wrap");if(t.length)return t[0]}for(var t=document.getElementsByClassName("wrap"),e=0;e<t.length;++e){var o=t[e];if(n=o.getElementsByTagName("form"),n.length)return o}return null},("function"!=typeof n.addContentHooks||n.addContentHooks(this))&&(!qTranslateConfig.page_config||this.addPageHooks(qTranslateConfig.page_config))){var o=[];if(qTranslateConfig.page_config&&qTranslateConfig.page_config.anchors)for(var i=0;i<qTranslateConfig.page_config.anchors.length;++i){var r=qTranslateConfig.page_config.anchors[i],s=document.getElementById(r);s&&o.push(s)}if(!o.length){var s=n.langSwitchWrapAnchor;s||(s=this.getWrapForm()),s||(s=this.getWrapForm()),s&&o.push(s)}for(var i=0;i<o.length;++i){var r=o[i],l=qtranxj_ce("ul",{className:"qtranxs-lang-switch-wrap"});r.parentNode.insertBefore(l,r);var g=new qtranxj_LanguageSwitch(l);g.onSwitch(onTabSwitch),n.onTabSwitch&&g.onSwitch(onTabSwitchCustom)}}};jQuery(document).ready(function(){new qTranslateX(qTranslateConfig.js)});
admin/js/edit-custom-page.js ADDED
@@ -0,0 +1,20 @@
1
+ /*
2
+ Loaded for a page requested by the user on configuration
3
+ */
4
+ qTranslateConfig.js={
5
+ addContentHooks: function(qtx)
6
+ {
7
+ var form = qtx.getWrapForm();
8
+ if(!form) return false;
9
+ qtx.addContentHooks(form);
10
+ this.langSwitchWrapAnchor=form;
11
+ return true;
12
+ }
13
+ /*
14
+ ,
15
+ onTabSwitch: function(lang,qtx)
16
+ {
17
+ //implement additional actions on tab click, if applicable.
18
+ }
19
+ */
20
+ };
admin/js/edit-custom-page.min.js ADDED
@@ -0,0 +1 @@
1
+ qTranslateConfig.js={addContentHooks:function(n){var o=n.getWrapForm();return o?(n.addContentHooks(o),this.langSwitchWrapAnchor=o,!0):!1}};
admin/js/edit-nav-menus.js ADDED
@@ -0,0 +1,66 @@
1
+ /* loaded in
2
+ /wp-admin/nav-menus.php
3
+ */
4
+ qTranslateConfig.js={
5
+ addContentHooks: function(qtx)
6
+ {
7
+ var form=document.getElementById('update-nav-menu');
8
+ if(!form) return false;
9
+
10
+ addMenuItemHooks=function(li,form)
11
+ {
12
+ qtx.addContentHooksByClass('edit-menu-item-title',form,li);
13
+ qtx.addContentHooksByClass('edit-menu-item-attr-title',form,li);
14
+ qtx.addContentHooksByClass('[edit-menu-item-description',form,li);//must use '[:]' separator style
15
+
16
+ qtx.addDisplayHooksByClass('menu-item-title',li);
17
+ qtx.addDisplayHooksByTagInClass('link-to-original','A',li);
18
+ }
19
+
20
+ function addPageHooks(qtx,form)
21
+ {
22
+ var items=document.getElementsByClassName('menu-item');
23
+ for(var i=0; i<items.length; ++i)
24
+ {
25
+ var li=items[i];
26
+ addMenuItemHooks(li,form);
27
+ }
28
+ var sst = document.getElementById('side-sortables');
29
+ if(sst) qtx.addDisplayHooksByClass('menu-item-title',sst);
30
+ }
31
+ addPageHooks(qtx,form);
32
+
33
+ if(wpNavMenu){
34
+ var wp_addMenuItemToBottom = wpNavMenu.addMenuItemToBottom;
35
+ if( typeof wp_addMenuItemToBottom == 'function'){
36
+ wpNavMenu.addMenuItemToBottom = function( menuMarkup, req ) {
37
+ wp_addMenuItemToBottom( menuMarkup, req );
38
+ var rx = /id="menu-item-(\d+)"/gi;
39
+ while((matches = rx.exec(menuMarkup))){
40
+ var id = 'menu-item-'+matches[1];
41
+ var li = document.getElementById(id);
42
+ if(li)
43
+ addMenuItemHooks(li,form);
44
+ }
45
+ };
46
+ }
47
+ }
48
+
49
+ this.onTabSwitch(qtx.getActiveLanguage(),qtx);
50
+ this.langSwitchWrapAnchor=form;//causes buttons to be inserted in front of this form instead of the first form in div "wrap"
51
+
52
+ return true;
53
+ }
54
+ ,
55
+ onTabSwitch: function(lang,qtx)
56
+ {
57
+ if(wpNavMenu){
58
+ if( typeof wpNavMenu.refreshKeyboardAccessibility == 'function'){
59
+ wpNavMenu.refreshKeyboardAccessibility();
60
+ }
61
+ if( typeof wpNavMenu.refreshAdvancedAccessibility == 'function'){
62
+ wpNavMenu.refreshAdvancedAccessibility();
63
+ }
64
+ }
65
+ }
66
+ };
admin/js/edit-nav-menus.min.js ADDED
@@ -0,0 +1 @@
1
+ qTranslateConfig.js={addContentHooks:function(e){function t(e,t){for(var n=document.getElementsByClassName("menu-item"),a=0;a<n.length;++a){var o=n[a];addMenuItemHooks(o,t)}var i=document.getElementById("side-sortables");i&&e.addDisplayHooksByClass("menu-item-title",i)}var n=document.getElementById("update-nav-menu");if(!n)return!1;if(addMenuItemHooks=function(t,n){e.addContentHooksByClass("edit-menu-item-title",n,t),e.addContentHooksByClass("edit-menu-item-attr-title",n,t),e.addContentHooksByClass("[edit-menu-item-description",n,t),e.addDisplayHooksByClass("menu-item-title",t),e.addDisplayHooksByTagInClass("link-to-original","A",t)},t(e,n),wpNavMenu){var a=wpNavMenu.addMenuItemToBottom;"function"==typeof a&&(wpNavMenu.addMenuItemToBottom=function(e,t){a(e,t);for(var o=/id="menu-item-(\d+)"/gi;matches=o.exec(e);){var i="menu-item-"+matches[1],s=document.getElementById(i);s&&addMenuItemHooks(s,n)}})}return this.onTabSwitch(e.getActiveLanguage(),e),this.langSwitchWrapAnchor=n,!0},onTabSwitch:function(){wpNavMenu&&("function"==typeof wpNavMenu.refreshKeyboardAccessibility&&wpNavMenu.refreshKeyboardAccessibility(),"function"==typeof wpNavMenu.refreshAdvancedAccessibility&&wpNavMenu.refreshAdvancedAccessibility())}};
admin/js/edit-options-general.js ADDED
@@ -0,0 +1,16 @@
1
+ /*
2
+ Loaded for /wp-admin/options-general.php
3
+ */
4
+ qTranslateConfig.js={
5
+ addContentHooks: function(qtx)
6
+ {
7
+ var forms=document.getElementsByTagName('FORM');
8
+ if(!forms.length) return false;
9
+ var form=forms[0];
10
+
11
+ qtx.addContentHookById('blogname',form,'[');
12
+ qtx.addContentHookById('blogdescription',form,'[');
13
+
14
+ return true;
15
+ }
16
+ };
admin/js/edit-options-general.min.js ADDED
@@ -0,0 +1 @@
1
+ qTranslateConfig.js={addContentHooks:function(n){var o=document.getElementsByTagName("FORM");if(!o.length)return!1;var t=o[0];return n.addContentHookById("blogname",t,"["),n.addContentHookById("blogdescription",t,"["),!0}};
admin/js/edit-post.js ADDED
@@ -0,0 +1,104 @@
1
+ /* loaded in
2
+ /wp-admin/post.php
3
+ /wp-admin/post-new.php
4
+ */
5
+ qTranslateConfig.js={
6
+
7
+ addContentHooks: function addContentHooks(qtx)
8
+ {
9
+ var form=document.getElementById('post');
10
+ if(!form) return false;
11
+
12
+ qtx.addContentHookByIdC('title',form);
13
+ qtx.addContentHookByIdC('excerpt',form);
14
+
15
+ var wpEditorAreas=form.getElementsByClassName('wp-editor-area');
16
+ for(var i=0; i<wpEditorAreas.length; ++i){
17
+ var wpEditorArea=wpEditorAreas[i];
18
+ qtx.addContentHookC(wpEditorArea,form);
19
+ }
20
+
21
+ qtx.addContentHookByIdC('attachment_caption',form);
22
+ qtx.addContentHookByIdB('attachment_alt',form);
23
+
24
+ qtx.addContentHooks(form);
25
+
26
+ // Slug
27
+ function convertURL(url,lang)
28
+ {
29
+ switch (qTranslateConfig.url_mode.toString())
30
+ {
31
+ case '1':
32
+ if (url.search){
33
+ url.search+="&lang="+lang;
34
+ }else{
35
+ url.search="?lang="+lang;
36
+ }
37
+ break;
38
+ case '2':
39
+ var homepath=qTranslateConfig.url_info_home;
40
+ var i=url.pathname.indexOf(homepath);
41
+ url.pathname=homepath+lang+url.pathname.substring(i+homepath.length-1);
42
+ break;
43
+ case '3':
44
+ url.host=lang+'.'+url.host;
45
+ break;
46
+ case '4':
47
+ url.host=qTranslateConfig.domains[lang];
48
+ break;
49
+ }
50
+ }
51
+
52
+ var btnViewPostA;//a node of 'View Page/Post' link.
53
+ var origUrl, langUrl;
54
+ var slugSamplePermalink;//'sample-permalink' node
55
+ var origSamplePermalink;
56
+ this.setSlugLanguage=function(lang)
57
+ {
58
+ if(!btnViewPostA){
59
+ var btnViewPost=document.getElementById('view-post-btn');
60
+ if (!btnViewPost || !btnViewPost.children.length) return;
61
+ btnViewPostA=btnViewPost.children[0];
62
+ if(btnViewPostA.tagName != 'A') return;
63
+ origUrl=btnViewPostA.href;
64
+ langUrl=qtranxj_ce('a',{});
65
+ }
66
+
67
+ langUrl.href=origUrl;
68
+ convertURL(langUrl,lang);
69
+ btnViewPostA.href=langUrl.href;
70
+
71
+ var btnPreviewAction=document.getElementById('preview-action');
72
+ if (btnPreviewAction && btnPreviewAction.children.length)
73
+ {
74
+ btnPreviewAction.children[0].href=langUrl.href;
75
+ }
76
+
77
+ if(qTranslateConfig.url_mode!=1){//!QTX_URL_QUERY
78
+ if(!slugSamplePermalink){
79
+ var slugEl=document.getElementById('sample-permalink');
80
+ if (slugEl && slugEl.childNodes.length){
81
+ slugSamplePermalink=slugEl.childNodes[0];//span
82
+ origSamplePermalink=slugSamplePermalink.nodeValue;
83
+ //var slugEdit=document.getElementById('editable-post-name');
84
+ }
85
+ }
86
+ if(slugSamplePermalink){
87
+ langUrl.href=origSamplePermalink;
88
+ convertURL(langUrl,lang);
89
+ slugSamplePermalink.nodeValue=langUrl.href;
90
+ }
91
+ }
92
+ }
93
+ this.setSlugLanguage(qtx.getActiveLanguage());
94
+
95
+ qtx.addContentHooksTinyMCE();
96
+
97
+ return true;
98
+ }
99
+ ,
100
+ onTabSwitch: function(lang,qtx)
101
+ {
102
+ this.setSlugLanguage(lang);
103
+ }
104
+ };
admin/js/edit-post.min.js ADDED
@@ -0,0 +1 @@
1
+ qTranslateConfig.js={addContentHooks:function(e){function t(e,t){switch(qTranslateConfig.url_mode.toString()){case"1":e.search?e.search+="&lang="+t:e.search="?lang="+t;break;case"2":var n=qTranslateConfig.url_info_home,a=e.pathname.indexOf(n);e.pathname=n+t+e.pathname.substring(a+n.length-1);break;case"3":e.host=t+"."+e.host;break;case"4":e.host=qTranslateConfig.domains[t]}}var n=document.getElementById("post");if(!n)return!1;e.addContentHookByIdC("title",n),e.addContentHookByIdC("excerpt",n);for(var a=n.getElementsByClassName("wp-editor-area"),o=0;o<a.length;++o){var r=a[o];e.addContentHookC(r,n)}e.addContentHookByIdC("attachment_caption",n),e.addContentHookByIdB("attachment_alt",n),e.addContentHooks(n);var d,i,s,h,l;return this.setSlugLanguage=function(e){if(!d){var n=document.getElementById("view-post-btn");if(!n||!n.children.length)return;if(d=n.children[0],"A"!=d.tagName)return;i=d.href,s=qtranxj_ce("a",{})}s.href=i,t(s,e),d.href=s.href;var a=document.getElementById("preview-action");if(a&&a.children.length&&(a.children[0].href=s.href),1!=qTranslateConfig.url_mode){if(!h){var o=document.getElementById("sample-permalink");o&&o.childNodes.length&&(h=o.childNodes[0],l=h.nodeValue)}h&&(s.href=l,t(s,e),h.nodeValue=s.href)}},this.setSlugLanguage(e.getActiveLanguage()),e.addContentHooksTinyMCE(),!0},onTabSwitch:function(e){this.setSlugLanguage(e)}};
admin/js/edit-tag.js ADDED
@@ -0,0 +1,24 @@
1
+ /* loaded in
2
+ /wp-admin/edit-tag.php?action=edit
3
+ */
4
+ qTranslateConfig.js={
5
+ addContentHooks: function(qtx)
6
+ {
7
+ var prefix, form = document.getElementById('edittag');
8
+ if(!form) return false;
9
+
10
+ var h=qtx.addContentHookByIdB('name',form);
11
+ if(!h) return false;
12
+
13
+ qtranxj_ce('input', {name: 'qtrans_term_field_name', type: 'hidden', className: 'hidden', value: h.mlContentField.name }, form, true);
14
+
15
+ var default_name=h.contents[qTranslateConfig.default_language];
16
+ qtranxj_ce('input', {name: 'qtrans_term_field_default_name', type: 'hidden', className: 'hidden', value: default_name }, form, true);
17
+
18
+ qtx.addContentHookByIdC('description',form);
19
+
20
+ qtx.addDisplayHookById('parent');
21
+
22
+ return true;
23
+ }
24
+ };
admin/js/edit-tag.min.js ADDED
@@ -0,0 +1 @@
1
+ qTranslateConfig.js={addContentHooks:function(e){var n=document.getElementById("edittag");if(!n)return!1;var t=e.addContentHookByIdB("name",n);if(!t)return!1;qtranxj_ce("input",{name:"qtrans_term_field_name",type:"hidden",className:"hidden",value:t.mlContentField.name},n,!0);var a=t.contents[qTranslateConfig.default_language];return qtranxj_ce("input",{name:"qtrans_term_field_default_name",type:"hidden",className:"hidden",value:a},n,!0),e.addContentHookByIdC("description",n),e.addDisplayHookById("parent"),!0}};
admin/js/edit-tags.js ADDED
@@ -0,0 +1,79 @@
1
+ /* loaded in
2
+ /wp-admin/edit-tag.php
3
+ */
4
+ qTranslateConfig.js={
5
+ addContentHooks: function(qtx)
6
+ {
7
+ var form = document.getElementById('addtag');//AjaxForm
8
+ if(!form) return false;
9
+
10
+ var h=qtx.addContentHookByIdB('tag-name',form);
11
+ if(!h) return false;
12
+
13
+ qtx.addContentHookByIdC('tag-description',form);
14
+
15
+ qtranxj_ce('input', {name: 'qtrans_term_field_name', type: 'hidden', className: 'hidden', value: h.mlContentField.name }, form, true);
16
+
17
+ var default_name=h.contents[qTranslateConfig.default_language];
18
+ qtranxj_ce('input', {name: 'qtrans_term_field_default_name', type: 'hidden', className: 'hidden', value: default_name }, form, true);
19
+
20
+ qtx.addDisplayHookById('parent');
21
+
22
+ var theList=document.getElementById('the-list');
23
+
24
+ hideQuickEditRow=function(tr)
25
+ {
26
+ var tds=tr.getElementsByTagName('TD');
27
+ if(!tds.length) return;
28
+ var td=tds[0];
29
+ var items=td.getElementsByClassName('inline');
30
+ for(var i=0; i<items.length; ++i)
31
+ {
32
+ var e=items[i];
33
+ e.style.display='none';
34
+ }
35
+ }
36
+
37
+ addDisplayHookRows=function(theList)
38
+ {
39
+ addDisplayHookRows.running=true;
40
+ if(!theList) return;
41
+ var rows=theList.getElementsByTagName('TR');
42
+ for(var r=0; r<rows.length; r++)
43
+ {
44
+ var tr=rows[r];
45
+ //qtx.addDisplayHooksByClass('check-column',tr);
46
+ qtx.addDisplayHooksByClass('row-title',tr);
47
+ qtx.addDisplayHooksByClass('description',tr);
48
+ qtx.addDisplayHooksByClass('slug',tr);
49
+ hideQuickEditRow(tr);
50
+ }
51
+ addDisplayHookRows.running=false;
52
+ }
53
+ addDisplayHookRows(theList);
54
+
55
+ addDisplayHookTagCloud=function()
56
+ {
57
+ var tagClouds=document.getElementsByClassName('tagcloud');
58
+ for(var i=0; i<tagClouds.length; ++i) {
59
+ var tagCloud = tagClouds[i];
60
+ var items=tagCloud.getElementsByTagName('A');
61
+ for(var i=0; i<items.length; ++i) {
62
+ var e=items[i];
63
+ addDisplayHook(e);
64
+ }
65
+ }
66
+ }
67
+ addDisplayHookTagCloud();
68
+
69
+ var submit_button = document.getElementById('submit');
70
+ if(submit_button){
71
+ submit_button.addEventListener("click",function(){
72
+ setTimeout(function(){window.location.reload();},500);
73
+ //addDisplayHookRows(theList);//does not work, because the updates on theList has not yet propagated
74
+ });
75
+ }
76
+
77
+ return true;
78
+ }
79
+ };
admin/js/edit-tags.min.js ADDED
@@ -0,0 +1 @@
1
+ qTranslateConfig.js={addContentHooks:function(e){var a=document.getElementById("addtag");if(!a)return!1;var n=e.addContentHookByIdB("tag-name",a);if(!n)return!1;e.addContentHookByIdC("tag-description",a),qtranxj_ce("input",{name:"qtrans_term_field_name",type:"hidden",className:"hidden",value:n.mlContentField.name},a,!0);var t=n.contents[qTranslateConfig.default_language];qtranxj_ce("input",{name:"qtrans_term_field_default_name",type:"hidden",className:"hidden",value:t},a,!0),e.addDisplayHookById("parent");var d=document.getElementById("the-list");hideQuickEditRow=function(e){var a=e.getElementsByTagName("TD");if(a.length)for(var n=a[0],t=n.getElementsByClassName("inline"),d=0;d<t.length;++d){var o=t[d];o.style.display="none"}},addDisplayHookRows=function(a){if(addDisplayHookRows.running=!0,a){for(var n=a.getElementsByTagName("TR"),t=0;t<n.length;t++){var d=n[t];e.addDisplayHooksByClass("row-title",d),e.addDisplayHooksByClass("description",d),e.addDisplayHooksByClass("slug",d),hideQuickEditRow(d)}addDisplayHookRows.running=!1}},addDisplayHookRows(d),(addDisplayHookTagCloud=function(){for(var e=document.getElementsByClassName("tagcloud"),a=0;a<e.length;++a)for(var n=e[a],t=n.getElementsByTagName("A"),a=0;a<t.length;++a){var d=t[a];addDisplayHook(d)}})();var o=document.getElementById("submit");return o&&o.addEventListener("click",function(){setTimeout(function(){window.location.reload()},500)}),!0}};
admin/update-gettext-db.php ADDED
@@ -0,0 +1,99 @@
1
+ <?php
2
+
3
+ function qtranxf_updateGettextDatabaseFile($lcr,$mo){
4
+ $tmpfile=$mo.'.filepart';
5
+ $ll = fopen($tmpfile,'w');
6
+ if(!$ll) return false;
7
+ while(!feof($lcr)) {
8
+ // try to get some more time
9
+ @set_time_limit(30);
10
+ $lc = fread($lcr, 8192);
11
+ if(!$lc){
12
+ fclose($lcr);
13
+ fclose($ll);
14
+ unlink($tmpfile);
15
+ return false;
16
+ }
17
+ fwrite($ll,$lc);
18
+ }
19
+ fclose($lcr);
20
+ fclose($ll);
21
+ // only use completely download .mo files
22
+ rename($tmpfile,$mo);
23
+ return true;
24
+ }
25
+
26
+ function qtranxf_updateGettextDatabaseFiles($lcr,$locale,$dstdir,$srcdir){
27
+ if($lcr){
28
+ $mo=$dstdir.$locale.'.mo';
29
+ qtranxf_updateGettextDatabaseFile($lcr,$mo);
30
+ }
31
+ if(!$srcdir) return;
32
+ }
33
+
34
+ function qtranxf_updateGettextDatabase($locale,$repository){
35
+ //wp_download_language_pack() - todo: use this function
36
+ $dstdir=trailingslashit(WP_LANG_DIR);
37
+ $tmpfile=$dstdir.$locale.'.mo.filepart';
38
+ if(!$ll = @fopen($tmpfile,'a'))
39
+ return false; // cannot access .mo file
40
+ fclose($ll);
41
+ $m='';
42
+ $wp_version = $GLOBALS['wp_version'];
43
+ // try to find a .mo file
44
+ if(!($locale == 'en_US' && $lcr=@fopen('http://www.qianqin.de/wp-content/languages/'.$locale.'.mo','r')))
45
+ if(!$lcr=@fopen(($m=$repository.$locale.'/tags/'.$wp_version.'/messages/').$locale.'.mo','r'))
46
+ if(!$lcr=@fopen(($m=$repository.substr($locale,0,2).'/tags/'.$wp_version.'/messages/').$locale.'.mo','r'))
47
+ if(!$lcr=@fopen(($m=$repository.$locale.'/branches/'.$wp_version.'/messages/').$locale.'.mo','r'))
48
+ if(!$lcr=@fopen(($m=$repository.substr($locale,0,2).'/branches/'.$wp_version.'/messages/').$locale.'.mo','r'))
49
+ if(!$lcr=@fopen($repository.$locale.'/branches/'.$wp_version.'/'.$locale.'.mo','r'))
50
+ if(!$lcr=@fopen($repository.substr($locale,0,2).'/branches/'.$wp_version.'/'.$locale.'.mo','r'))
51
+ if(!$lcr=@fopen($repository.$locale.'/trunk/messages/'.$locale.'.mo','r'))
52
+ if(!$lcr=@fopen($repository.substr($locale,0,2).'/trunk/messages/'.$locale.'.mo','r'))
53
+ {
54
+ $tagsfile=file($repository.$locale.'/tags/');
55
+ $tags=array();
56
+ foreach( $tagsfile as $ln ){
57
+ if(!preg_match('/href="(\d.*)"/',$ln,$match)) continue;
58
+ $tag=$match[1];
59
+ $tags[]=$tag;
60
+ }
61
+ $tags=array_reverse($tags);
62
+ foreach( $tags as $tag ){
63
+ $m=$repository.$locale.'/tags/'.$tag.'messages/';
64
+ $mo=$m.$locale.'.mo';
65
+ //if(file_exists())
66
+ if(!$lcr=@fopen($mo,'r')) continue;
67
+ break;
68
+ }
69
+ if(!$lcr){// couldn't find a .mo file
70
+ if(filesize($tmpfile)==0) unlink($tmpfile);
71
+ return false;
72
+ }
73
+ }
74
+ // found a .mo file, update local .mo
75
+ qtranxf_updateGettextDatabaseFiles($lcr,$locale,$dstdir,$m);
76
+ return true;
77
+ }
78
+
79
+ function qtranxf_updateGettextDatabases($force = false, $only_for_language = '') {
80
+ global $q_config;
81
+ if($only_for_language && !qtranxf_isEnabled($only_for_language)) return false;
82
+ if(!is_dir(WP_LANG_DIR)) {
83
+ if(!@mkdir(WP_LANG_DIR))
84
+ return false;
85
+ }
86
+ $next_update = get_option('qtranslate_next_update_mo');
87
+ if(time() < $next_update && !$force) return true;
88
+ update_option('qtranslate_next_update_mo', time() + 7*24*60*60);
89
+ //$repository='http://i18n.svn.wordpress.org/';
90
+ $repository='http://svn.automattic.com/wordpress-i18n/';
91
+ foreach($q_config['locale'] as $lang => $locale) {
92
+ if($only_for_language && $lang != $only_for_language) continue;
93
+ if(!qtranxf_isEnabled($lang)) continue;
94
+ qtranxf_updateGettextDatabase($locale,$repository);
95
+ }
96
+ return true;
97
+ }
98
+
99
+ ?>
lang/qtranslate-az_AZ.po ADDED
@@ -0,0 +1,1005 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: qTranslate-X 3.0\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2015-02-10 18:54-0700\n"
6
+ "PO-Revision-Date: 2009-09-10 12:00+0400\n"
7
+ "Last-Translator: Rashad Aliyev <rashadaliyev@gmail.com>\n"
8
+ "Language-Team: LANGUAGE <LL@li.org>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+
13
+ #: admin/activation_hook.php:37
14
+ #, php-format
15
+ msgid "Activation of plugin %s deactivated plugin %s since they cannot run simultaneously."
16
+ msgstr ""
17
+
18
+ #: admin/activation_hook.php:39
19
+ #, php-format
20
+ msgid "The compatible settings from %s have been imported to %s. Further tuning, import, export and reset of options can be done at Settings/Languages configuration page, once %s is running.%sContinue%s"
21
+ msgstr ""
22
+
23
+ #: admin/activation_hook.php:41
24
+ #, php-format
25
+ msgid "You may import/export compatible settings from %s to %s on Settings/Languages configuration page, once %s is running.%sContinue%s"
26
+ msgstr ""
27
+
28
+ #: admin/activation_hook.php:134
29
+ msgid "Error"
30
+ msgstr ""
31
+
32
+ #: admin/activation_hook.php:134
33
+ #, php-format
34
+ msgid "plugin %s cannot run concurrently with plugin %s. You may import and export compatible settings between %s and %s on Settings/<a href=\"%s\">Languages</a> configuration page. Then you have to deactivate one of the plugins to continue."
35
+ msgstr ""
36
+
37
+ #: admin/activation_hook.php:136 admin/activation_hook.php:138
38
+ msgid "Deactivate "
39
+ msgstr ""
40
+
41
+ #: admin/activation_hook.php:166
42
+ #, php-format
43
+ msgid "Thank you for using %s plugin!"
44
+ msgstr ""
45
+
46
+ #: admin/activation_hook.php:168
47
+ #, php-format
48
+ msgid "Please, help us to make decision on \"%s\" feature, press the button below."
49
+ msgstr ""
50
+
51
+ #: admin/activation_hook.php:168 admin/activation_hook.php:170
52
+ #: qtranslate_services.php:786
53
+ #, fuzzy
54
+ msgid "Translation Service"
55
+ msgstr "qTranslate"
56
+
57
+ #: admin/activation_hook.php:170
58
+ #, php-format
59
+ msgid "Survey on \"%s\" feature"
60
+ msgstr ""
61
+
62
+ #: admin/activation_hook.php:171
63
+ msgid "I have already done it, dismiss this message."
64
+ msgstr ""
65
+
66
+ #: admin/admin_utils.php:165 qtranslate_configuration.php:404
67
+ msgid "Flag"
68
+ msgstr "Bayraq"
69
+
70
+ #: admin/admin_utils.php:166 qtranslate_configuration.php:444
71
+ msgid "Name"
72
+ msgstr "İsim"
73
+
74
+ #: admin/admin_utils.php:167 qtranslate_services.php:382
75
+ msgid "Action"
76
+ msgstr "Fəaliyyət"
77
+
78
+ #: admin/admin_utils.php:180 qtranslate_configuration.php:391
79
+ #: qtranslate_configuration.php:1064
80
+ msgid "Languages"
81
+ msgstr "Dillər"
82
+
83
+ #: admin/import_export.php:79
84
+ msgid "Plugin"
85
+ msgstr ""
86
+
87
+ #: admin/import_export.php:83
88
+ msgid "There is no need to migrate any setting, the database schema is compatible with this plugin."
89
+ msgstr ""
90
+
91
+ #: admin/import_export.php:86
92
+ msgid "Do not migrate any setting"
93
+ msgstr ""
94
+
95
+ #: admin/import_export.php:88
96
+ #, fuzzy
97
+ msgid "Import settings from "
98
+ msgstr "qTranslate-i Sıfırla"
99
+
100
+ #: admin/import_export.php:90
101
+ #, fuzzy
102
+ msgid "Export settings to "
103
+ msgstr "qTranslate-i Sıfırla"
104
+
105
+ #: admin/import_export.php:99 qtranslate_configuration.php:906
106
+ msgid "Export"
107
+ msgstr ""
108
+
109
+ #: admin/import_export.php:99 qtranslate_configuration.php:906
110
+ msgid "Import"
111
+ msgstr ""
112
+
113
+ #: admin/import_export.php:104 qtranslate_configuration.php:906
114
+ msgid "Convert Database"
115
+ msgstr "Məlumat Bazasını Çevir"
116
+
117
+ #: admin/import_export.php:106
118
+ #, php-format
119
+ msgid "If you are updating from qTranslate 1.x or Polyglot, <a href=\"%s\">click here</a> to convert posts to the new language tag format."
120
+ msgstr "Əyər qTranslate 1.x ya da Polyglot'dan yeniləşdirmə aparırsanız, məzmunları yeni dil etiket formasına çevirmək üçün <a href=\"%s\">buraya tıqlayın</a>."
121
+
122
+ #: admin/import_export.php:107
123
+ #, php-format
124
+ msgid "If you have installed qTranslate for the first time on a Wordpress with existing posts, you can either go through all your posts manually and save them in the correct language or <a href=\"%s\">click here</a> to mark all existing posts as written in the default language."
125
+ msgstr "Əyər qTranslate-i məzmunları olan bir Wordpress-e yükləmişsəniz, mövcud məzmunları tək-tək tənzimləyib doğru dildə yaddaşda saxlaya bilər, ya da <a href=\"%s\">buraya tıqlayaraq</a> mövcud bütün məzmunları Ana D