[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Form\Field; 11 12 use Joomla\CMS\Language\Text; 13 use Joomla\Database\DatabaseDriver; 14 15 // phpcs:disable PSR1.Files.SideEffects 16 \defined('JPATH_PLATFORM') or die; 17 // phpcs:enable PSR1.Files.SideEffects 18 19 /** 20 * Form Field class for the Joomla Platform. 21 * Provides a list of available database connections, optionally limiting to 22 * a given list. 23 * 24 * @see DatabaseDriver 25 * @since 1.7.3 26 */ 27 class DatabaseconnectionField extends ListField 28 { 29 /** 30 * The form field type. 31 * 32 * @var string 33 * @since 1.7.3 34 */ 35 protected $type = 'Databaseconnection'; 36 37 /** 38 * Method to get the list of database options. 39 * 40 * This method produces a drop down list of available databases supported 41 * by DatabaseDriver classes that are also supported by the application. 42 * 43 * @return array The field option objects. 44 * 45 * @since 1.7.3 46 * @see DatabaseDriver::getConnectors() 47 */ 48 protected function getOptions() 49 { 50 // This gets the connectors available in the platform and supported by the server. 51 $available = array_map('strtolower', DatabaseDriver::getConnectors()); 52 53 /** 54 * This gets the list of database types supported by the application. 55 * This should be entered in the form definition as a comma separated list. 56 * If no supported databases are listed, it is assumed all available databases 57 * are supported. 58 */ 59 $supported = $this->element['supported']; 60 61 if (!empty($supported)) { 62 $supported = explode(',', $supported); 63 64 foreach ($supported as $support) { 65 if (\in_array($support, $available)) { 66 $options[$support] = Text::_(ucfirst($support)); 67 } 68 } 69 } else { 70 foreach ($available as $support) { 71 $options[$support] = Text::_(ucfirst($support)); 72 } 73 } 74 75 // This will come into play if an application is installed that requires 76 // a database that is not available on the server. 77 if (empty($options)) { 78 $options[''] = Text::_('JNONE'); 79 } 80 81 return $options; 82 } 83 }
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 |