Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
databaseconnection.php
Aller à la documentation de ce fichier.
1 <?php
2 /**
3  * @package Joomla.Platform
4  * @subpackage Form
5  *
6  * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
7  * @license GNU General Public License version 2 or later; see LICENSE
8  */
9 
10 defined('JPATH_PLATFORM') or die;
11 
12 JFormHelper::loadFieldClass('list');
13 
14 /**
15  * Form Field class for the Joomla Platform.
16  * Provides a list of available database connections, optionally limiting to
17  * a given list.
18  *
19  * @package Joomla.Platform
20  * @subpackage Form
21  * @see JDatabaseDriver
22  * @since 11.3
23  */
25 {
26  /**
27  * The form field type.
28  *
29  * @var string
30  * @since 11.3
31  */
32  protected $type = 'DatabaseConnection';
33 
34  /**
35  * Method to get the list of database options.
36  *
37  * This method produces a drop down list of available databases supported
38  * by JDatabaseDriver classes that are also supported by the application.
39  *
40  * @return array The field option objects.
41  *
42  * @since 11.3
43  * @see JDatabaseDriver::getConnectors()
44  */
45  protected function getOptions()
46  {
47  // This gets the connectors available in the platform and supported by the server.
48  $available = JDatabaseDriver::getConnectors();
49 
50  /**
51  * This gets the list of database types supported by the application.
52  * This should be entered in the form definition as a comma separated list.
53  * If no supported databases are listed, it is assumed all available databases
54  * are supported.
55  */
56  $supported = $this->element['supported'];
57 
58  if (!empty($supported))
59  {
60  $supported = explode(',', $supported);
61 
62  foreach ($supported as $support)
63  {
64  if (in_array($support, $available))
65  {
66  $options[$support] = JText::_(ucfirst($support));
67  }
68  }
69  }
70  else
71  {
72  foreach ($available as $support)
73  {
74  $options[$support] = JText::_(ucfirst($support));
75  }
76  }
77 
78  // This will come into play if an application is installed that requires
79  // a database that is not available on the server.
80  if (empty($options))
81  {
82  $options[''] = JText::_('JNONE');
83  }
84 
85  return $options;
86  }
87 }