| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - e4j - Extensionsforjoomla.com |
| 6 |
* @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 12 |
|
| 13 |
$vbo_tn = $this->vbo_tn; |
| 14 |
|
| 15 |
$vbo_app = VikBooking::getVboApplication(); |
| 16 |
$vbo_app->loadVisualEditorAssets(); |
| 17 |
|
| 18 |
$editor = JEditor::getInstance(JFactory::getApplication()->get('editor')); |
| 19 |
|
| 20 |
$langs = $vbo_tn->getLanguagesList(); |
| 21 |
$xml_tables = $vbo_tn->getTranslationTables(); |
| 22 |
$active_table = ''; |
| 23 |
$active_table_key = ''; |
| 24 |
|
| 25 |
// JS lang vars |
| 26 |
JText::script('VBO_COPY_ORIGINAL_TN'); |
| 27 |
|
| 28 |
if (!(count($langs) > 1)) { |
| 29 |
//Error: only one language is published. Translations are useless |
| 30 |
?> |
| 31 |
<p class="err"><?php echo JText::translate('VBTRANSLATIONERRONELANG'); ?></p> |
| 32 |
<form name="adminForm" id="adminForm" action="index.php" method="post"> |
| 33 |
<input type="hidden" name="task" value=""> |
| 34 |
<input type="hidden" name="option" value="com_vikbooking"> |
| 35 |
</form> |
| 36 |
<?php |
| 37 |
} elseif (!$xml_tables || strlen($vbo_tn->getError())) { |
| 38 |
//Error: XML file not readable or errors occurred |
| 39 |
?> |
| 40 |
<p class="err"><?php echo $vbo_tn->getError(); ?></p> |
| 41 |
<form name="adminForm" id="adminForm" action="index.php" method="post"> |
| 42 |
<input type="hidden" name="task" value=""> |
| 43 |
<input type="hidden" name="option" value="com_vikbooking"> |
| 44 |
</form> |
| 45 |
<?php |
| 46 |
} else { |
| 47 |
$cur_langtab = VikRequest::getString('vbo_lang', '', 'request'); |
| 48 |
$table = VikRequest::getString('vbo_table', '', 'request'); |
| 49 |
if (!empty($table)) { |
| 50 |
$table = $vbo_tn->replacePrefix($table); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Allows to filter/search translations by a key-search value. |
| 55 |
* |
| 56 |
* @since 1.16.6 (J) - 1.6.6 (WP) |
| 57 |
*/ |
| 58 |
$keysearch = VikRequest::getString('keysearch', '', 'request'); |
| 59 |
$vbo_tn->setKeySearch($keysearch); |
| 60 |
?> |
| 61 |
|
| 62 |
<form action="index.php?option=com_vikbooking&task=translations" method="post" onsubmit="return vboCheckChanges();"> |
| 63 |
<div style="width: 100%; display: inline-block;" class="btn-toolbar vbo-btn-toolbar" id="filter-bar"> |
| 64 |
<div class="btn-group pull-right"> |
| 65 |
<button class="btn" type="submit"><?php echo JText::translate('VBOGETTRANSLATIONS'); ?></button> |
| 66 |
</div> |
| 67 |
<div class="btn-group pull-right"> |
| 68 |
<select name="vbo_table"> |
| 69 |
<option value="">-----------</option> |
| 70 |
<?php |
| 71 |
foreach ($xml_tables as $key => $value) { |
| 72 |
$active_table = $vbo_tn->replacePrefix($key) == $table ? $value : $active_table; |
| 73 |
$active_table_key = $vbo_tn->replacePrefix($key) == $table ? $key : $active_table_key; |
| 74 |
?> |
| 75 |
<option value="<?php echo $key; ?>"<?php echo $vbo_tn->replacePrefix($key) == $table ? ' selected="selected"' : ''; ?>><?php echo $value; ?></option> |
| 76 |
<?php |
| 77 |
} |
| 78 |
?> |
| 79 |
</select> |
| 80 |
</div> |
| 81 |
<?php |
| 82 |
if (!empty($active_table_key)) { |
| 83 |
?> |
| 84 |
<div class="btn-group pull-left"> |
| 85 |
<input type="text" name="keysearch" value="<?php echo JHtml::fetch('esc_attr', $keysearch); ?>" placeholder="<?php echo JHtml::fetch('esc_attr', JText::translate('VBODASHSEARCHKEYS')); ?>..." /> |
| 86 |
</div> |
| 87 |
<?php |
| 88 |
} |
| 89 |
?> |
| 90 |
</div> |
| 91 |
<input type="hidden" name="vbo_lang" class="vbo_lang" value="<?php echo $vbo_tn->default_lang; ?>"> |
| 92 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 93 |
<input type="hidden" name="task" value="translations" /> |
| 94 |
</form> |
| 95 |
<form name="adminForm" id="adminForm" action="index.php" method="post"> |
| 96 |
<div class="vbo-translation-langtabs"> |
| 97 |
<?php |
| 98 |
foreach ($langs as $ltag => $lang) { |
| 99 |
$is_def = ($ltag == $vbo_tn->default_lang); |
| 100 |
$lcountry = substr($ltag, 0, 2); |
| 101 |
$flag = ''; |
| 102 |
if (VBOPlatformDetection::isJoomla() && is_file(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'mod_languages' . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $lcountry . '.gif')) { |
| 103 |
$flag = '<img src="' . JUri::root() . 'media/mod_languages/images/' . $lcountry . '.gif"/>'; |
| 104 |
} |
| 105 |
?><div class="vbo-translation-tab<?php echo $is_def ? ' vbo-translation-tab-default' : ''; ?>" data-vbolang="<?php echo $ltag; ?>"> |
| 106 |
<?php |
| 107 |
if (!empty($flag)) { |
| 108 |
?> |
| 109 |
<span class="vbo-translation-flag"><?php echo $flag; ?></span> |
| 110 |
<?php |
| 111 |
} |
| 112 |
?> |
| 113 |
<span class="vbo-translation-langname"><?php echo $lang['name']; ?></span> |
| 114 |
</div><?php |
| 115 |
} |
| 116 |
|
| 117 |
if (VBOPlatformDetection::isJoomla()) { |
| 118 |
?> |
| 119 |
<div class="vbo-translation-tab vbo-translation-tab-ini" data-vbolang=""> |
| 120 |
<span class="vbo-translation-iniflag">.INI</span> |
| 121 |
<span class="vbo-translation-langname"><?php echo JText::translate('VBTRANSLATIONINISTATUS'); ?></span> |
| 122 |
</div> |
| 123 |
<?php |
| 124 |
} |
| 125 |
?> |
| 126 |
</div> |
| 127 |
<div class="vbo-translation-tabscontents"> |
| 128 |
<?php |
| 129 |
$table_cols = !empty($active_table_key) ? $vbo_tn->getTableColumns($active_table_key) : []; |
| 130 |
$table_def_dbvals = !empty($active_table_key) ? $vbo_tn->getTableDefaultDbValues($active_table_key, array_keys($table_cols)) : []; |
| 131 |
if (!empty($active_table_key)) { |
| 132 |
echo '<input type="hidden" name="vbo_table" value="'.$active_table_key.'"/>'."\n"; |
| 133 |
if (!empty($keysearch)) { |
| 134 |
echo '<input type="hidden" name="keysearch" value="' . JHtml::fetch('esc_attr', $keysearch) . '"/>'."\n"; |
| 135 |
} |
| 136 |
} |
| 137 |
foreach ($langs as $ltag => $lang) { |
| 138 |
$is_def = ($ltag == $vbo_tn->default_lang); |
| 139 |
?> |
| 140 |
<div class="vbo-translation-langcontent" style="display: <?php echo $is_def ? 'block' : 'none'; ?>;" id="vbo_langcontent_<?php echo $ltag; ?>"> |
| 141 |
<?php |
| 142 |
if (empty($active_table_key)) { |
| 143 |
?> |
| 144 |
<p class="warn"><?php echo JText::translate('VBTRANSLATIONSELTABLEMESS'); ?></p> |
| 145 |
<?php |
| 146 |
} elseif (strlen($vbo_tn->getError()) > 0) { |
| 147 |
?> |
| 148 |
<p class="err"><?php echo $vbo_tn->getError(); ?></p> |
| 149 |
<?php |
| 150 |
} else { |
| 151 |
?> |
| 152 |
<fieldset class="adminform"> |
| 153 |
<legend class="adminlegend"><?php echo $active_table; ?> - <?php echo $lang['name'].($is_def ? ' - '.JText::translate('VBTRANSLATIONDEFLANG') : ''); ?></legend> |
| 154 |
<div class="vbo-translations-tab-container"> |
| 155 |
<?php |
| 156 |
if ($is_def) { |
| 157 |
// values of Default Language to be translated |
| 158 |
foreach ($table_def_dbvals as $reference_id => $values) { |
| 159 |
?> |
| 160 |
<div class="vbo-translations-default-element"> |
| 161 |
<div class="vbo-translations-element-title" data-reference="<?php echo $ltag.'-'.$reference_id; ?>"> |
| 162 |
<div class="vbo-translate-element-cell"><?php echo $vbo_tn->getRecordReferenceName($table_cols, $values); ?></div> |
| 163 |
</div> |
| 164 |
<div class="vbo-translations-element-contents"> |
| 165 |
<?php |
| 166 |
foreach ($values as $field => $def_value) { |
| 167 |
$title = $table_cols[$field]['jlang']; |
| 168 |
$type = $table_cols[$field]['type']; |
| 169 |
if ($type == 'html') { |
| 170 |
$def_value = strip_tags($def_value); |
| 171 |
} |
| 172 |
?> |
| 173 |
<div class="vbo-translations-element-row" data-reference="<?php echo $ltag.'-'.$reference_id; ?>"> |
| 174 |
<div class="vbo-translations-element-lbl"><?php echo $title; ?></div> |
| 175 |
<div class="vbo-translations-element-val" data-origvalue="<?php echo $reference_id . '-' . $field; ?>"><?php echo $type != 'json' ? $def_value : ''; ?></div> |
| 176 |
</div> |
| 177 |
<?php |
| 178 |
if ($type == 'json') { |
| 179 |
$tn_keys = $table_cols[$field]['keys']; |
| 180 |
$keys = !empty($tn_keys) ? explode(',', $tn_keys) : []; |
| 181 |
$json_def_values = json_decode($def_value, true); |
| 182 |
if (count($json_def_values) > 0) { |
| 183 |
foreach ($json_def_values as $jkey => $jval) { |
| 184 |
if ((!in_array($jkey, $keys) && count($keys) > 0) || empty($jval)) { |
| 185 |
continue; |
| 186 |
} |
| 187 |
$json_lbl = ' '; |
| 188 |
if (!is_numeric($jkey)) { |
| 189 |
$guess_lbl = JText::translate('VBO_' . strtoupper($jkey)); |
| 190 |
$json_lbl = $guess_lbl != 'VBO_' . strtoupper($jkey) ? $guess_lbl : ucwords($jkey); |
| 191 |
} |
| 192 |
?> |
| 193 |
<div class="vbo-translations-element-row vbo-translations-element-row-nested" data-reference="<?php echo $ltag.'-'.$reference_id; ?>"> |
| 194 |
<div class="vbo-translations-element-lbl"><?php echo $json_lbl; ?></div> |
| 195 |
<div class="vbo-translations-element-val" data-origvalue="<?php echo $reference_id . '-' . $field . '-' . $jkey; ?>"><?php echo $jval; ?></div> |
| 196 |
</div> |
| 197 |
<?php |
| 198 |
} |
| 199 |
} |
| 200 |
} |
| 201 |
?> |
| 202 |
<?php |
| 203 |
} |
| 204 |
?> |
| 205 |
</div> |
| 206 |
</div> |
| 207 |
<?php |
| 208 |
} |
| 209 |
} else { |
| 210 |
// translation fields for this language |
| 211 |
$lang_record_tn = $vbo_tn->getTranslatedTable($active_table_key, $ltag); |
| 212 |
foreach ($table_def_dbvals as $reference_id => $values) { |
| 213 |
?> |
| 214 |
<div class="vbo-translations-language-element"> |
| 215 |
<div class="vbo-translations-element-title" data-reference="<?php echo $ltag.'-'.$reference_id; ?>"> |
| 216 |
<div class="vbo-translate-element-cell"><?php echo $vbo_tn->getRecordReferenceName($table_cols, $values); ?></div> |
| 217 |
</div> |
| 218 |
<div class="vbo-translations-element-contents"> |
| 219 |
<?php |
| 220 |
foreach ($values as $field => $def_value) { |
| 221 |
$title = $table_cols[$field]['jlang']; |
| 222 |
$type = $table_cols[$field]['type']; |
| 223 |
if ($type == 'skip') { |
| 224 |
continue; |
| 225 |
} |
| 226 |
$tn_value = ''; |
| 227 |
$tn_class = ' vbo-missing-translation'; |
| 228 |
if (array_key_exists($reference_id, $lang_record_tn) && array_key_exists($field, $lang_record_tn[$reference_id]['content']) && strlen($lang_record_tn[$reference_id]['content'][$field])) { |
| 229 |
if (in_array($type, array('text', 'textarea', 'html'))) { |
| 230 |
$tn_class = ' vbo-field-translated'; |
| 231 |
} else { |
| 232 |
$tn_class = ''; |
| 233 |
} |
| 234 |
} |
| 235 |
?> |
| 236 |
<div class="vbo-translations-element-row<?php echo $tn_class; ?>" data-reference="<?php echo $ltag.'-'.$reference_id; ?>" data-copyoriginal="<?php echo $reference_id . '-' . $field; ?>"> |
| 237 |
<div class="vbo-translations-element-lbl"><?php echo $title; ?></div> |
| 238 |
<div class="vbo-translations-element-val"> |
| 239 |
<?php |
| 240 |
if ($type == 'text') { |
| 241 |
if (array_key_exists($reference_id, $lang_record_tn) && array_key_exists($field, $lang_record_tn[$reference_id]['content'])) { |
| 242 |
$tn_value = $lang_record_tn[$reference_id]['content'][$field]; |
| 243 |
} |
| 244 |
?> |
| 245 |
<input type="text" name="tn[<?php echo $ltag; ?>][<?php echo $reference_id; ?>][<?php echo $field; ?>]" value="<?php echo htmlspecialchars($tn_value); ?>" size="40" placeholder="<?php echo htmlspecialchars($def_value); ?>"/> |
| 246 |
<?php |
| 247 |
} elseif ($type == 'textarea') { |
| 248 |
if (array_key_exists($reference_id, $lang_record_tn) && array_key_exists($field, $lang_record_tn[$reference_id]['content'])) { |
| 249 |
$tn_value = $lang_record_tn[$reference_id]['content'][$field]; |
| 250 |
} |
| 251 |
?> |
| 252 |
<textarea name="tn[<?php echo $ltag; ?>][<?php echo $reference_id; ?>][<?php echo $field; ?>]" rows="7" cols="170"><?php echo $tn_value; ?></textarea> |
| 253 |
<?php |
| 254 |
} elseif ($type == 'html') { |
| 255 |
if (array_key_exists($reference_id, $lang_record_tn) && array_key_exists($field, $lang_record_tn[$reference_id]['content'])) { |
| 256 |
$tn_value = $lang_record_tn[$reference_id]['content'][$field]; |
| 257 |
} |
| 258 |
if (VBOPlatformDetection::isWordPress() && interface_exists('Throwable')) { |
| 259 |
/** |
| 260 |
* With PHP >= 7 supporting throwable exceptions for Fatal Errors |
| 261 |
* we try to avoid issues with third party plugins that make use |
| 262 |
* of the WP native function get_current_screen(). |
| 263 |
* |
| 264 |
* @wponly |
| 265 |
*/ |
| 266 |
try { |
| 267 |
echo $editor->display( "tn[".$ltag."][".$reference_id."][".$field."]", $tn_value, '100%', 350, 70, 20, true, "tn_".$ltag."_".$reference_id."_".$field ); |
| 268 |
} catch (Throwable $t) { |
| 269 |
echo $t->getMessage() . ' in ' . $t->getFile() . ':' . $t->getLine() . '<br/>'; |
| 270 |
} |
| 271 |
} else { |
| 272 |
// we cannot catch Fatal Errors in PHP 5.x |
| 273 |
echo $editor->display( "tn[".$ltag."][".$reference_id."][".$field."]", $tn_value, '100%', 350, 70, 20, true, "tn_".$ltag."_".$reference_id."_".$field ); |
| 274 |
} |
| 275 |
} |
| 276 |
?> |
| 277 |
</div> |
| 278 |
</div> |
| 279 |
<?php |
| 280 |
if ($type == 'json') { |
| 281 |
$tn_keys = $table_cols[$field]['keys']; |
| 282 |
$keys = !empty($tn_keys) ? explode(',', $tn_keys) : []; |
| 283 |
$json_def_values = json_decode($def_value, true); |
| 284 |
if (count($json_def_values)) { |
| 285 |
$tn_json_value = []; |
| 286 |
if (array_key_exists($reference_id, $lang_record_tn) && array_key_exists($field, $lang_record_tn[$reference_id]['content'])) { |
| 287 |
$tn_json_value = json_decode($lang_record_tn[$reference_id]['content'][$field], true); |
| 288 |
} |
| 289 |
foreach ($json_def_values as $jkey => $jval) { |
| 290 |
if ((!in_array($jkey, $keys) && count($keys) > 0) || empty($jval)) { |
| 291 |
continue; |
| 292 |
} |
| 293 |
$json_lbl = ' '; |
| 294 |
if (!is_numeric($jkey)) { |
| 295 |
$guess_lbl = JText::translate('VBO_' . strtoupper($jkey)); |
| 296 |
$json_lbl = $guess_lbl != 'VBO_' . strtoupper($jkey) ? $guess_lbl : ucwords($jkey); |
| 297 |
} |
| 298 |
?> |
| 299 |
<div class="vbo-translations-element-row vbo-translations-element-row-nested" data-reference="<?php echo $ltag.'-'.$reference_id; ?>" data-copyoriginal="<?php echo $reference_id . '-' . $field . '-' . $jkey; ?>"> |
| 300 |
<div class="vbo-translations-element-lbl"><?php echo $json_lbl; ?></div> |
| 301 |
<div class="vbo-translations-element-val"> |
| 302 |
<?php |
| 303 |
if (strlen($jval) > 40) { |
| 304 |
// check if this translation field requires the rich text visual editor |
| 305 |
if ($jkey == 'tpl_text' && strpos($jval, '<') !== false) { |
| 306 |
// the original field contains HTML code built through the visual editor |
| 307 |
$veditor_name = 'tn[' . $ltag . '][' . $reference_id . '][' . $field . '][' . $jkey . ']'; |
| 308 |
$veditor_id = 'tn_' . $ltag . '_' . $reference_id . '_' . $field . '_' . $jkey; |
| 309 |
$tarea_attr = array( |
| 310 |
'id' => $veditor_id, |
| 311 |
'rows' => '7', |
| 312 |
'cols' => '170', |
| 313 |
'style' => 'min-width: 60%;', |
| 314 |
); |
| 315 |
$editor_opts = array( |
| 316 |
'modes' => array( |
| 317 |
'text', |
| 318 |
'visual', |
| 319 |
), |
| 320 |
); |
| 321 |
echo $vbo_app->renderVisualEditor($veditor_name, (isset($tn_json_value[$jkey]) ? $tn_json_value[$jkey] : ''), $tarea_attr, $editor_opts); |
| 322 |
} else { |
| 323 |
?> |
| 324 |
<textarea rows="7" cols="170" style="min-width: 60%;" name="tn[<?php echo $ltag; ?>][<?php echo $reference_id; ?>][<?php echo $field; ?>][<?php echo $jkey; ?>]"><?php echo isset($tn_json_value[$jkey]) ? $tn_json_value[$jkey] : ''; ?></textarea> |
| 325 |
<?php |
| 326 |
} |
| 327 |
} else { |
| 328 |
?> |
| 329 |
<input type="text" name="tn[<?php echo $ltag; ?>][<?php echo $reference_id; ?>][<?php echo $field; ?>][<?php echo $jkey; ?>]" value="<?php echo isset($tn_json_value[$jkey]) ? $tn_json_value[$jkey] : ''; ?>" size="40" placeholder="<?php echo htmlspecialchars($jval); ?>"/> |
| 330 |
<?php |
| 331 |
} |
| 332 |
?> |
| 333 |
</div> |
| 334 |
</div> |
| 335 |
<?php |
| 336 |
} |
| 337 |
} |
| 338 |
} |
| 339 |
} |
| 340 |
?> |
| 341 |
</div> |
| 342 |
</div> |
| 343 |
<?php |
| 344 |
} |
| 345 |
} |
| 346 |
?> |
| 347 |
</div> |
| 348 |
</fieldset> |
| 349 |
<?php |
| 350 |
} |
| 351 |
?> |
| 352 |
</div> |
| 353 |
<?php |
| 354 |
} |
| 355 |
|
| 356 |
// ini files status |
| 357 |
if (VBOPlatformDetection::isJoomla()) { |
| 358 |
$all_inis = $vbo_tn->getIniFiles(); |
| 359 |
?> |
| 360 |
<div class="vbo-translation-langcontent" style="display: none;" id="vbo_langcontent_ini"> |
| 361 |
<fieldset class="adminform"> |
| 362 |
<legend class="adminlegend">.INI <?php echo JText::translate('VBTRANSLATIONINISTATUS'); ?></legend> |
| 363 |
<div class="vbo-translations-tab-container"> |
| 364 |
<?php |
| 365 |
foreach ($all_inis as $initype => $inidet) { |
| 366 |
$inipath = $inidet['path']; |
| 367 |
?> |
| 368 |
<div class="vbo-translations-ini-element"> |
| 369 |
<div class="vbo-translations-element-title"> |
| 370 |
<div class="vbo-translate-element-cell"><?php echo JText::translate('VBINIEXPL'.strtoupper($initype)); ?></div> |
| 371 |
</div> |
| 372 |
<div class="vbo-translations-element-contents"> |
| 373 |
<?php |
| 374 |
foreach ($langs as $ltag => $lang) { |
| 375 |
$t_file_exists = file_exists(str_replace('en-GB', $ltag, $inipath)); |
| 376 |
$t_parsed_ini = $t_file_exists ? parse_ini_file(str_replace('en-GB', $ltag, $inipath)) : false; |
| 377 |
?> |
| 378 |
<div class="vbo-translations-element-row <?php echo $t_file_exists ? 'vbo-field-translated' : 'vbo-missing-translation'; ?>"> |
| 379 |
<div class="vbo-translations-element-lbl"><?php echo ($ltag == 'en-GB' ? 'Native ' : '').$lang['name']; ?></div> |
| 380 |
<div class="vbo-translations-element-val"> |
| 381 |
<span class="vbo-inifile-totrows <?php echo $t_file_exists ? 'vbo-inifile-exists' : 'vbo-inifile-notfound'; ?>"><?php echo $t_file_exists && $t_parsed_ini !== false ? JText::translate('VBOINIDEFINITIONS').': '.count($t_parsed_ini) : JText::translate('VBOINIMISSINGFILE'); ?></span> |
| 382 |
<span class="vbo-inifile-path <?php echo $t_file_exists ? 'vbo-inifile-exists' : 'vbo-inifile-notfound'; ?>"><?php echo JText::translate('VBOINIPATH').': '.str_replace('en-GB', $ltag, $inipath); ?></span> |
| 383 |
</div> |
| 384 |
</div> |
| 385 |
<?php |
| 386 |
} |
| 387 |
?> |
| 388 |
</div> |
| 389 |
</div> |
| 390 |
<?php |
| 391 |
} |
| 392 |
?> |
| 393 |
</div> |
| 394 |
</fieldset> |
| 395 |
</div> |
| 396 |
<?php |
| 397 |
// end ini files status |
| 398 |
} |
| 399 |
?> |
| 400 |
</div> |
| 401 |
<input type="hidden" name="vbo_lang" class="vbo_lang" value="<?php echo $vbo_tn->default_lang; ?>"> |
| 402 |
<input type="hidden" name="task" value="translations"> |
| 403 |
<input type="hidden" name="option" value="com_vikbooking"> |
| 404 |
<?php echo JHtml::fetch('form.token'); ?> |
| 405 |
|
| 406 |
<div class="vbo-translations-lim-wrap"> |
| 407 |
<table align="center"> |
| 408 |
<tr> |
| 409 |
<td align="center"><?php echo $vbo_tn->getPagination(); ?></td> |
| 410 |
</tr> |
| 411 |
<tr> |
| 412 |
<td align="center"> |
| 413 |
<select name="limit" onchange="vboHandleCustomLimit(this.value);"> |
| 414 |
<option value="2"<?php echo $vbo_tn->lim == 2 ? ' selected="selected"' : ''; ?>>2</option> |
| 415 |
<option value="5"<?php echo $vbo_tn->lim == 5 ? ' selected="selected"' : ''; ?>>5</option> |
| 416 |
<option value="10"<?php echo $vbo_tn->lim == 10 ? ' selected="selected"' : ''; ?>>10</option> |
| 417 |
<option value="20"<?php echo $vbo_tn->lim == 20 ? ' selected="selected"' : ''; ?>>20</option> |
| 418 |
</select> |
| 419 |
</td> |
| 420 |
</tr> |
| 421 |
</table> |
| 422 |
</div> |
| 423 |
</form> |
| 424 |
|
| 425 |
<script type="text/Javascript"> |
| 426 |
var vbo_tn_changes = false; |
| 427 |
var vbo_copy_delay = 500; |
| 428 |
var vbo_copy_timeout = null; |
| 429 |
|
| 430 |
function vboHandleCustomLimit(lim) { |
| 431 |
var cur_limstart = document.adminForm.limitstart; |
| 432 |
if (typeof cur_limstart === 'undefined') { |
| 433 |
// append hidden input field to form |
| 434 |
var limstart_node = document.createElement('INPUT'); |
| 435 |
limstart_node.setAttribute('type', 'hidden'); |
| 436 |
limstart_node.setAttribute('name', 'limitstart'); |
| 437 |
limstart_node.setAttribute('value', '0'); |
| 438 |
document.adminForm.appendChild(limstart_node); |
| 439 |
} else { |
| 440 |
// update existing value |
| 441 |
document.adminForm.limitstart.value = '0'; |
| 442 |
} |
| 443 |
// submit form |
| 444 |
document.adminForm.submit(); |
| 445 |
} |
| 446 |
|
| 447 |
function vboCheckChanges() { |
| 448 |
if (!vbo_tn_changes) { |
| 449 |
return true; |
| 450 |
} |
| 451 |
return confirm("<?php echo addslashes(JText::translate('VBTANSLATIONSCHANGESCONF')); ?>"); |
| 452 |
} |
| 453 |
|
| 454 |
function vboHoverCopyTranslation(elem) { |
| 455 |
if (!elem) { |
| 456 |
return false; |
| 457 |
} |
| 458 |
var copy_reference = elem.attr('data-copyoriginal'); |
| 459 |
if (!copy_reference) { |
| 460 |
return false; |
| 461 |
} |
| 462 |
var orig_elem = jQuery('.vbo-translations-element-val[data-origvalue="' + copy_reference + '"]'); |
| 463 |
if (!orig_elem || !orig_elem.length || !orig_elem.html().length) { |
| 464 |
return false; |
| 465 |
} |
| 466 |
// check if translation field has got a value |
| 467 |
var tn_field_val = elem.find('.vbo-translations-element-val').find('input,textarea').val(); |
| 468 |
if (!tn_field_val) { |
| 469 |
// append button to copy the original content |
| 470 |
elem. |
| 471 |
find('.vbo-translations-element-lbl'). |
| 472 |
append('<div class="vbo-tn-copyoriginal"><span title="' + Joomla.JText._('VBO_COPY_ORIGINAL_TN') + '" onclick="vboApplyCopyTranslation(this);"><?php VikBookingIcons::e('copy'); ?></span></div>'); |
| 473 |
} |
| 474 |
} |
| 475 |
|
| 476 |
function vboApplyCopyTranslation(elem) { |
| 477 |
elem = jQuery(elem).closest('.vbo-translations-element-row[data-copyoriginal]'); |
| 478 |
if (!elem || !elem.length) { |
| 479 |
return false; |
| 480 |
} |
| 481 |
var copy_reference = elem.attr('data-copyoriginal'); |
| 482 |
if (!copy_reference) { |
| 483 |
return false; |
| 484 |
} |
| 485 |
var orig_elem = jQuery('.vbo-translations-element-val[data-origvalue="' + copy_reference + '"]'); |
| 486 |
if (!orig_elem || !orig_elem.length) { |
| 487 |
return false; |
| 488 |
} |
| 489 |
|
| 490 |
// make sure to remove any copy-from-original button |
| 491 |
jQuery('.vbo-tn-copyoriginal').remove(); |
| 492 |
|
| 493 |
// set original content to translation field |
| 494 |
var input = elem.find('.vbo-translations-element-val').find('input'); |
| 495 |
if (input && input.length) { |
| 496 |
input.val(orig_elem.html()).trigger('change'); |
| 497 |
} |
| 498 |
var tarea = elem.find('.vbo-translations-element-val').find('textarea'); |
| 499 |
if (tarea && tarea.length) { |
| 500 |
tarea.val(orig_elem.html()).trigger('change'); |
| 501 |
} |
| 502 |
|
| 503 |
// grab lang tag, which could be part of the ID of a WYSIWYG editor |
| 504 |
var lang_reference_arr = elem.attr('data-reference').split('-'); |
| 505 |
lang_reference_arr.splice((lang_reference_arr.length - 1), 1); |
| 506 |
var current_lang = lang_reference_arr.join('-'); |
| 507 |
var wysiwyg_hipo_id = current_lang + '-' . copy_reference; |
| 508 |
wysiwyg_hipo_id.replaceAll('-', '_'); |
| 509 |
|
| 510 |
// attempt to inject value inside wysiwyg editor |
| 511 |
try { |
| 512 |
// native wysiwyg editor |
| 513 |
if (typeof Joomla !== undefined && Joomla.editors && Joomla.editors.instances) { |
| 514 |
if (Joomla.editors.instances.hasOwnProperty(wysiwyg_hipo_id)) { |
| 515 |
Joomla.editors.instances[wysiwyg_hipo_id].setValue(orig_elem.html()); |
| 516 |
} |
| 517 |
} |
| 518 |
} catch(e) { |
| 519 |
// do nothing |
| 520 |
} |
| 521 |
} |
| 522 |
|
| 523 |
jQuery(document).ready(function() { |
| 524 |
|
| 525 |
jQuery('.vbo-translation-tab').click(function() { |
| 526 |
var langtag = jQuery(this).attr('data-vbolang'); |
| 527 |
if (jQuery('#vbo_langcontent_'+langtag).length) { |
| 528 |
jQuery('.vbo_lang').val(langtag); |
| 529 |
jQuery('.vbo-translation-tab').removeClass('vbo-translation-tab-default'); |
| 530 |
jQuery(this).addClass('vbo-translation-tab-default'); |
| 531 |
jQuery('.vbo-translation-langcontent').hide(); |
| 532 |
jQuery('#vbo_langcontent_'+langtag).fadeIn(); |
| 533 |
} else { |
| 534 |
jQuery('.vbo-translation-tab').removeClass('vbo-translation-tab-default'); |
| 535 |
jQuery(this).addClass('vbo-translation-tab-default'); |
| 536 |
jQuery('.vbo-translation-langcontent').hide(); |
| 537 |
jQuery('#vbo_langcontent_ini').fadeIn(); |
| 538 |
} |
| 539 |
}); |
| 540 |
|
| 541 |
jQuery('#adminForm input[type=text], #adminForm textarea').change(function() { |
| 542 |
vbo_tn_changes = true; |
| 543 |
}); |
| 544 |
|
| 545 |
jQuery('.vbo-translations-element-row[data-copyoriginal]').hover(function() { |
| 546 |
var elem = jQuery(this); |
| 547 |
vbo_copy_timeout = setTimeout(function() { |
| 548 |
vboHoverCopyTranslation(elem); |
| 549 |
}, vbo_copy_delay); |
| 550 |
}, function() { |
| 551 |
// cancel scheduled hovering function |
| 552 |
clearTimeout(vbo_copy_timeout); |
| 553 |
// make sure to remove any copy-from-original button |
| 554 |
jQuery('.vbo-tn-copyoriginal').remove(); |
| 555 |
}); |
| 556 |
<?php |
| 557 |
if (!empty($cur_langtab)) { |
| 558 |
?> |
| 559 |
jQuery('.vbo-translation-tab').each(function() { |
| 560 |
var langtag = jQuery(this).attr('data-vbolang'); |
| 561 |
if (langtag != '<?php echo $cur_langtab; ?>') { |
| 562 |
return true; |
| 563 |
} |
| 564 |
if (jQuery('#vbo_langcontent_'+langtag).length) { |
| 565 |
jQuery('.vbo_lang').val(langtag); |
| 566 |
jQuery('.vbo-translation-tab').removeClass('vbo-translation-tab-default'); |
| 567 |
jQuery(this).addClass('vbo-translation-tab-default'); |
| 568 |
jQuery('.vbo-translation-langcontent').hide(); |
| 569 |
jQuery('#vbo_langcontent_'+langtag).fadeIn(); |
| 570 |
} |
| 571 |
}); |
| 572 |
<?php |
| 573 |
} |
| 574 |
?> |
| 575 |
}); |
| 576 |
</script> |
| 577 |
<?php |
| 578 |
} |
| 579 |
|