[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Plugin 5 * @subpackage Editors.tinymce 6 * 7 * @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 defined('_JEXEC') or die; 12 13 use Joomla\CMS\Document\HtmlDocument; 14 use Joomla\CMS\Factory; 15 use Joomla\CMS\Form\Form; 16 use Joomla\CMS\Language\Text; 17 use Joomla\CMS\Layout\FileLayout; 18 19 extract($displayData); 20 21 /** 22 * Layout variables 23 * ----------------- 24 * @var string $autocomplete Autocomplete attribute for the field. 25 * @var boolean $autofocus Is autofocus enabled? 26 * @var string $class Classes for the input. 27 * @var string $description Description of the field. 28 * @var boolean $disabled Is this field disabled? 29 * @var string $group Group the field belongs to. <fields> section in form XML. 30 * @var boolean $hidden Is this field hidden in the form? 31 * @var string $hint Placeholder for the field. 32 * @var string $id DOM id of the field. 33 * @var string $label Label of the field. 34 * @var string $labelclass Classes to apply to the label. 35 * @var boolean $multiple Does this field support multiple values? 36 * @var string $name Name of the input field. 37 * @var string $onchange Onchange attribute for the field. 38 * @var string $onclick Onclick attribute for the field. 39 * @var string $pattern Pattern (Reg Ex) of value of the form field. 40 * @var boolean $readonly Is this field read only? 41 * @var boolean $repeat Allows extensions to duplicate elements. 42 * @var boolean $required Is this field required? 43 * @var integer $size Size attribute of the input. 44 * @var boolean $spellcheck Spellcheck state for the form field. 45 * @var string $validate Validation rules to apply. 46 * @var array $value Value of the field. 47 * @var array $menus List of the menu items 48 * @var array $menubarSource Menu items for builder 49 * @var array $buttons List of the buttons 50 * @var array $buttonsSource Buttons by group, for the builder 51 * @var array $toolbarPreset Toolbar preset (default values) 52 * @var int $setsAmount Amount of sets 53 * @var array $setsNames List of Sets names 54 * @var Form[] $setsForms Form with extra options for an each set 55 * @var string $languageFile TinyMCE language file to translate the buttons 56 * @var FileLayout $this Context 57 */ 58 59 /** @var HtmlDocument $doc */ 60 $doc = Factory::getApplication()->getDocument(); 61 $wa = $doc->getWebAssetManager(); 62 63 $wa->registerScript('tinymce', 'media/vendor/tinymce/tinymce.min.js', [], ['defer' => true]) 64 ->registerScript('plg_editors_tinymce', 'plg_editors_tinymce/tinymce.min.js', [], ['defer' => true], ['core', 'tinymce']) 65 ->registerAndUseStyle('tinymce.skin', 'media/vendor/tinymce/skins/ui/oxide/skin.min.css') 66 ->registerAndUseStyle('plg_editors_tinymce.builder', 'plg_editors_tinymce/tinymce-builder.css', [], [], ['tinymce.skin', 'dragula']) 67 ->registerScript('plg_editors_tinymce.builder', 'plg_editors_tinymce/tinymce-builder.js', [], ['type' => 'module'], ['dragula', 'plg_editors_tinymce']) 68 ->useScript('plg_editors_tinymce.builder') 69 ->useStyle('webcomponent.joomla-tab') 70 ->useScript('webcomponent.joomla-tab'); 71 72 // Add TinyMCE language file to translate the buttons 73 if ($languageFile) { 74 $wa->registerAndUseScript('tinymce.language', $languageFile, [], ['defer' => true], []); 75 } 76 77 // Add the builder options 78 $doc->addScriptOptions( 79 'plg_editors_tinymce_builder', 80 [ 81 'menus' => $menus, 82 'buttons' => $buttons, 83 'toolbarPreset' => $toolbarPreset, 84 'formControl' => $name . '[toolbars]', 85 ] 86 ); 87 88 ?> 89 <div id="joomla-tinymce-builder"> 90 <h3><?php echo Text::_('PLG_TINY_SET_TARGET_PANEL_TITLE'); ?></h3> 91 <p><?php echo Text::_('PLG_TINY_SET_TARGET_PANEL_DESCRIPTION'); ?></p> 92 <p><?php echo Text::_('PLG_TINY_SET_SOURCE_PANEL_DESCRIPTION'); ?></p> 93 <div class="tox tox-tinymce"> 94 <div class="tox-editor-container"> 95 <div class="tox-menubar tinymce-builder-menu source" data-group="menu" 96 data-value="<?php echo $this->escape(json_encode($menubarSource)); ?>"> 97 </div> 98 <div class="tox-toolbar tinymce-builder-toolbar source" data-group="toolbar" 99 data-value="<?php echo $this->escape(json_encode($buttonsSource)); ?>"> 100 </div> 101 </div> 102 </div> 103 <hr> 104 <joomla-tab orientation="vertical" id="joomla-tinymce-builder-sets" recall breakpoint="974"> 105 <?php foreach ($setsNames as $num => $title) : ?> 106 <?php $isActive = $num === $setsAmount - 1; ?> 107 <joomla-tab-element class="tab-pane" id="set-<?php echo $num; ?>" <?php echo $isActive; ?> name="<?php echo $title; ?>"> 108 <?php // Render tab content for each set ?> 109 <?php 110 $presetButtonClasses = [ 111 'simple' => 'btn-success', 112 'medium' => 'btn-info', 113 'advanced' => 'btn-warning', 114 ]; 115 // Check whether the values exists, and if empty then use from preset 116 if ( 117 empty($value['toolbars'][$num]['menu']) 118 && empty($value['toolbars'][$num]['toolbar1']) 119 && empty($value['toolbars'][$num]['toolbar2']) 120 ) { 121 // Take the preset for default value 122 switch ($num) { 123 case 0: 124 $preset = $toolbarPreset['advanced']; 125 break; 126 case 1: 127 $preset = $toolbarPreset['medium']; 128 break; 129 default: 130 $preset = $toolbarPreset['simple']; 131 } 132 133 $value['toolbars'][$num] = $preset; 134 } 135 136 // Take existing values 137 $valMenu = empty($value['toolbars'][$num]['menu']) ? array() : $value['toolbars'][$num]['menu']; 138 $valBar1 = empty($value['toolbars'][$num]['toolbar1']) ? array() : $value['toolbars'][$num]['toolbar1']; 139 $valBar2 = empty($value['toolbars'][$num]['toolbar2']) ? array() : $value['toolbars'][$num]['toolbar2']; 140 141 ?> 142 <?php echo $this->sublayout('setaccess', array('form' => $setsForms[$num])); ?> 143 <div class="btn-toolbar float-end mt-3"> 144 <div class="btn-group btn-group-sm"> 145 146 <?php foreach (array_keys($toolbarPreset) as $presetName) : 147 $btnClass = empty($presetButtonClasses[$presetName]) ? 'btn-primary' : $presetButtonClasses[$presetName]; 148 ?> 149 <button type="button" class="btn <?php echo $btnClass; ?> button-action" 150 data-action="setPreset" data-preset="<?php echo $presetName; ?>" data-set="<?php echo $num; ?>"> 151 <?php echo Text::_('PLG_TINY_SET_PRESET_BUTTON_' . $presetName); ?> 152 </button> 153 <?php endforeach; ?> 154 155 <button type="button" class="btn btn-danger button-action" 156 data-action="clearPane" data-set="<?php echo $num; ?>"> 157 <?php echo Text::_('JCLEAR'); ?> 158 </button> 159 </div> 160 </div> 161 162 <div class="clearfix mb-1"></div> 163 164 <div class="tox tox-tinymce mb-3"> 165 <div class="tox-editor-container"> 166 <div class="tox-menubar tinymce-builder-menu target" 167 data-group="menu" data-set="<?php echo $num; ?>" 168 data-value="<?php echo $this->escape(json_encode($valMenu)); ?>"> 169 </div> 170 <div class="tox-toolbar tinymce-builder-toolbar target" 171 data-group="toolbar1" data-set="<?php echo $num; ?>" 172 data-value="<?php echo $this->escape(json_encode($valBar1)); ?>"> 173 </div> 174 <div class="tox-toolbar tinymce-builder-toolbar target" 175 data-group="toolbar2" data-set="<?php echo $num; ?>" 176 data-value="<?php echo $this->escape(json_encode($valBar2)); ?>"> 177 </div> 178 </div> 179 </div> 180 181 <?php // Render the form for extra options ?> 182 <?php echo $this->sublayout('setoptions', array('form' => $setsForms[$num])); ?> 183 </joomla-tab-element> 184 <?php endforeach; ?> 185 </joomla-tab> 186 </div>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |