1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Part of the Joomla Framework Form Package |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. |
6
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Joomla\Form; |
10
|
|
|
|
11
|
|
|
use Joomla\Language\Text; |
12
|
|
|
use Joomla\Database\DatabaseDriver; |
13
|
|
|
|
14
|
|
|
FormHelper::loadFieldClass('list'); |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Form Field class for the Joomla Framework. |
18
|
|
|
* Provides a list of available database connections, optionally limiting to |
19
|
|
|
* a given list. |
20
|
|
|
* |
21
|
|
|
* @see Joomla\Database\DatabaseDriver |
22
|
|
|
* @since 1.0 |
23
|
|
|
* @deprecated The joomla/form package is deprecated |
24
|
|
|
*/ |
25
|
|
|
class Field_DatabaseConnection extends Field_List |
|
|
|
|
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* The form field type. |
29
|
|
|
* |
30
|
|
|
* @var string |
31
|
|
|
* @since 1.0 |
32
|
|
|
*/ |
33
|
|
|
public $type = 'DatabaseConnection'; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Method to get the list of database options. |
37
|
|
|
* |
38
|
|
|
* This method produces a drop down list of available databases supported |
39
|
|
|
* by JDatabaseDriver classes that are also supported by the application. |
40
|
|
|
* |
41
|
|
|
* @return array The field option objects. |
42
|
|
|
* |
43
|
|
|
* @since 1.0 |
44
|
|
|
* @see Joomla\Database\DatabaseDriver |
45
|
|
|
*/ |
46
|
|
|
protected function getOptions() |
47
|
|
|
{ |
48
|
|
|
// This gets the connectors available in the platform and supported by the server. |
49
|
|
|
$available = DatabaseDriver::getConnectors(); |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* This gets the list of database types supported by the application. |
53
|
|
|
* This should be entered in the form definition as a comma separated list. |
54
|
|
|
* If no supported databases are listed, it is assumed all available databases |
55
|
|
|
* are supported. |
56
|
|
|
*/ |
57
|
|
|
$supported = $this->element['supported']; |
58
|
|
|
|
59
|
|
|
if (!empty($supported)) |
60
|
|
|
{ |
61
|
|
|
$supported = explode(',', $supported); |
62
|
|
|
|
63
|
|
|
foreach ($supported as $support) |
64
|
|
|
{ |
65
|
|
|
if (in_array($support, $available)) |
66
|
|
|
{ |
67
|
|
|
$options[$support] = Text::_(ucfirst($support)); |
|
|
|
|
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
else |
72
|
|
|
{ |
73
|
|
|
foreach ($available as $support) |
74
|
|
|
{ |
75
|
|
|
$options[$support] = Text::_(ucfirst($support)); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
// This will come into play if an application is installed that requires |
80
|
|
|
// a database that is not available on the server. |
81
|
|
|
if (empty($options)) |
82
|
|
|
{ |
83
|
|
|
$options[''] = Text::_('JNONE'); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
return $options; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.