PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / libraries / adapter / editor / classes / none.php
vikappointments / libraries / adapter / editor / classes Last commit date
codemirror.php 2 days ago none.php 2 days ago tinymce.php 2 days ago
none.php
110 lines
1 <?php
2 /**
3 * @package VikWP - Libraries
4 * @subpackage adapter.editor
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 JLoader::import('adapter.editor.editor');
15
16 /**
17 * Editor class to handle a simple textarea.
18 *
19 * @since 10.0
20 */
21 class JEditorNone extends JEditor
22 {
23 /**
24 * @override
25 * Renders the editor area.
26 *
27 * @param string $name The control name.
28 * @param string $html The contents of the text area.
29 * @param string $width The width of the text area (px or %).
30 * @param string $height The height of the text area (px or %).
31 * @param integer $col The number of columns for the textarea.
32 * @param integer $row The number of rows for the textarea.
33 * @param boolean $buttons True and the editor buttons will be displayed.
34 * @param string $id An optional ID for the textarea (@since 10.1.20).
35 * @param array $params Associative array of editor parameters (@since 10.1.35).
36 *
37 * @return string The editor.
38 */
39 protected function render($name, $html, $width, $height, $col, $row, $buttons, $id, $params)
40 {
41 // only add "px" to width and height if they are not given as a percentage
42 if (is_numeric($width))
43 {
44 $width .= 'px';
45 }
46
47 if (is_numeric($height))
48 {
49 $height .= 'px';
50 }
51
52 ?>
53 <textarea
54 name="<?php echo esc_attr($name); ?>"
55 id="<?php echo esc_attr($id); ?>"
56 rows="<?php echo esc_attr($row); ?>"
57 cols="<?php echo esc_attr($col); ?>"
58 style="width: <?php echo esc_attr($width); ?>; height: <?php echo esc_attr($height); ?>;"
59 <?php echo !empty($params['readonly']) ? 'readonly' : ''; ?>
60 <?php echo !empty($params['disabled']) ? 'disabled' : ''; ?>
61 ><?php echo htmlentities($html); ?></textarea>
62
63 <?php
64
65 /**
66 * Inject default editor instance within Joomla.editors pool.
67 *
68 * @since 10.1.17
69 */
70 JFactory::getDocument()->addScriptDeclaration(
71 <<<JS
72 (function($) {
73 'use strict';
74
75 $(function() {
76 Joomla.editors.instances['$id'] = {
77 id: '$id',
78 getValue: function() {
79 return $('textarea#' + this.id).val();
80 },
81 setValue: function(text) {
82 return $('textarea#' + this.id).val(text);
83 },
84 getSelection: function() {
85 const textarea = $('textarea#' + this.id)[0];
86
87 if (textarea.selectionStart || textarea.selectionStart === 0) {
88 // MOZILLA/NETSCAPE support
89 return textarea.value.substring(textarea.selectionStart, textarea.selectionEnd);
90 }
91
92 return textarea.value;
93 },
94 replaceSelection: function(text) {
95 const textarea = $('textarea#' + this.id)[0];
96
97 if (textarea.selectionStart || textarea.selectionStart === 0) {
98 textarea.value = textarea.value.substring(0, textarea.selectionStart) + text + textarea.value.substring(textarea.selectionEnd, textarea.value.length);
99 } else {
100 textarea.value += text;
101 }
102 },
103 };
104 });
105 })(jQuery);
106 JS
107 );
108 }
109 }
110