[ 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 Fields.Sql 6 * 7 * @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 10 * @phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace 11 */ 12 13 use Joomla\CMS\Access\Access; 14 use Joomla\CMS\Form\Form; 15 use Joomla\CMS\Language\Text; 16 17 // phpcs:disable PSR1.Files.SideEffects 18 \defined('_JEXEC') or die; 19 // phpcs:enable PSR1.Files.SideEffects 20 21 /** 22 * Fields Sql Plugin 23 * 24 * @since 3.7.0 25 */ 26 class PlgFieldsSql extends \Joomla\Component\Fields\Administrator\Plugin\FieldsListPlugin 27 { 28 /** 29 * Transforms the field into a DOM XML element and appends it as a child on the given parent. 30 * 31 * @param stdClass $field The field. 32 * @param DOMElement $parent The field node parent. 33 * @param Form $form The form. 34 * 35 * @return DOMElement 36 * 37 * @since 3.7.0 38 */ 39 public function onCustomFieldsPrepareDom($field, DOMElement $parent, Form $form) 40 { 41 $fieldNode = parent::onCustomFieldsPrepareDom($field, $parent, $form); 42 43 if (!$fieldNode) { 44 return $fieldNode; 45 } 46 47 $fieldNode->setAttribute('value_field', 'text'); 48 $fieldNode->setAttribute('key_field', 'value'); 49 50 return $fieldNode; 51 } 52 53 /** 54 * The save event. 55 * 56 * @param string $context The context 57 * @param \Joomla\CMS\Table\Table $item The table 58 * @param boolean $isNew Is new item 59 * @param array $data The validated data 60 * 61 * @return boolean 62 * 63 * @since 3.7.0 64 */ 65 public function onContentBeforeSave($context, $item, $isNew, $data = []) 66 { 67 // Only work on new SQL fields 68 if ($context != 'com_fields.field' || !isset($item->type) || $item->type != 'sql') { 69 return true; 70 } 71 72 // If we are not a super admin, don't let the user create or update a SQL field 73 if (!Access::getAssetRules(1)->allow('core.admin', $this->app->getIdentity()->getAuthorisedGroups())) { 74 $item->setError(Text::_('PLG_FIELDS_SQL_CREATE_NOT_POSSIBLE')); 75 76 return false; 77 } 78 79 return true; 80 } 81 }
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 |