PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
vikbooking / admin / views / edittmplfile / tmpl / default.php

default.php in VikBooking Hotel Booking Engine & PMS 1.8.16, at admin/views/edittmplfile/tmpl/default.php

99 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 /**
14 * Determine whether we are rendering the template through AJAX.
15 *
16 * @since 1.17.6 (J) - 1.7.6 (WP)
17 */
18 $is_ajax = JFactory::getApplication()->input->getBool('ajax', false);
19
20 $editor = JEditor::getInstance('codemirror');
21 $fcode = '';
22 $fp = !empty($this->fpath) ? fopen($this->fpath, "rb") : false;
23 if (empty($this->fpath) || $fp === false) {
24 ?>
25 <p class="err"><?php echo JText::translate('VBOTMPLFILENOTREAD'); ?></p>
26 <?php
27 } else {
28 // read file bytes in chunks
29 while (!feof($fp)) {
30 $fcode .= fread($fp, 8192);
31 }
32 fclose($fp);
33
34 if ($is_ajax) {
35 ?>
36 <p class="vbo-path-tmpl-file no-margin-top"><?php echo $this->fpath; ?></p>
37 <div class="vbo-codemirror-modal-container">
38 <?php
39 /**
40 * With PHP >= 7 supporting throwable exceptions for Fatal Errors
41 * we try to avoid issues with third party plugins that make use
42 * of the WP native function get_current_screen().
43 */
44 try {
45 echo $editor->display("cont", $fcode, '100%', 300, 70, 20, $buttons = false, $id = "vik_editor_cont", $asset = null, $author = null, $params = ['syntax' => 'php']);
46 } catch (Throwable $t) {
47 echo $t->getMessage() . ' in ' . $t->getFile() . ':' . $t->getLine() . '<br/>';
48 }
49 ?>
50 </div>
51 <?php
52 } else {
53 // regular rendering
54 ?>
55 <form name="adminForm" id="adminForm" action="index.php" method="post">
56 <fieldset class="adminform">
57 <legend class="adminlegend"><?php echo JText::translate('VBOEDITTMPLFILE'); ?></legend>
58 <p class="vbo-path-tmpl-file"><?php echo $this->fpath; ?></p>
59 <?php
60 /**
61 * With PHP >= 7 supporting throwable exceptions for Fatal Errors
62 * we try to avoid issues with third party plugins that make use
63 * of the WP native function get_current_screen().
64 */
65 try {
66 echo $editor->display("cont", $fcode, '100%', 300, 70, 20, $buttons = false, $id = "vik_editor_cont", $asset = null, $author = null, $params = ['syntax' => 'php']);
67 } catch (Throwable $t) {
68 echo $t->getMessage() . ' in ' . $t->getFile() . ':' . $t->getLine() . '<br/>';
69 }
70 ?>
71 <br clear="all" />
72 <p style="text-align: center;">
73 <button type="button" class="btn btn-success" onclick="vboSubmitTmplFile(this);"><?php echo JText::translate('VBOSAVETMPLFILE'); ?></button>
74 </p>
75 </fieldset>
76 <input type="hidden" name="path" value="<?php echo $this->escape($this->fpath); ?>">
77 <input type="hidden" name="option" value="com_vikbooking" />
78 <input type="hidden" name="task" value="savetmplfile" />
79 <?php echo JHtml::fetch('form.token'); ?>
80 </form>
81
82 <script type="text/javascript">
83 function vboSubmitTmplFile(elem) {
84 /**
85 * On some CMSs, the real textarea may not update with the new codemirror content
86 * and so we force the update of the textarea before submitting the form.
87 */
88 try {
89 Joomla.editors.instances['vik_editor_cont'].element.codemirror.save();
90 } catch (err) {
91 console.error(err);
92 }
93 jQuery(elem).closest('form').submit();
94 }
95 </script>
96 <?php
97 }
98 }
99