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\Form\Html\Select as HtmlSelect; |
12
|
|
|
use Joomla\Language\Text; |
13
|
|
|
use Joomla\Filesystem\Folder; |
14
|
|
|
|
15
|
|
|
FormHelper::loadFieldClass('list'); |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Supports an HTML select list of folder |
19
|
|
|
* |
20
|
|
|
* @since 1.0 |
21
|
|
|
* @deprecated The joomla/form package is deprecated |
22
|
|
|
*/ |
23
|
|
|
class Field_FolderList extends Field_List |
|
|
|
|
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* The form field type. |
27
|
|
|
* |
28
|
|
|
* @var string |
29
|
|
|
* @since 1.0 |
30
|
|
|
*/ |
31
|
|
|
public $type = 'FolderList'; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Method to get the field options. |
35
|
|
|
* |
36
|
|
|
* @return array The field option objects. |
37
|
|
|
* |
38
|
|
|
* @since 1.0 |
39
|
|
|
*/ |
40
|
|
|
protected function getOptions() |
41
|
|
|
{ |
42
|
|
|
$options = array(); |
43
|
|
|
|
44
|
|
|
// Initialize some field attributes. |
45
|
|
|
$filter = (string) $this->element['filter']; |
46
|
|
|
$exclude = (string) $this->element['exclude']; |
47
|
|
|
$hideNone = (string) $this->element['hide_none']; |
48
|
|
|
$hideDefault = (string) $this->element['hide_default']; |
49
|
|
|
|
50
|
|
|
// Get the path in which to search for file options. |
51
|
|
|
$path = (string) $this->element['directory']; |
52
|
|
|
|
53
|
|
|
if (!is_dir($path)) |
54
|
|
|
{ |
55
|
|
|
$path = JPATH_ROOT . '/' . $path; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
// Prepend some default options based on field attributes. |
59
|
|
View Code Duplication |
if (!$hideNone) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
$options[] = HtmlSelect::option('-1', Text::alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname))); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
View Code Duplication |
if (!$hideDefault) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
$options[] = HtmlSelect::option('', Text::alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname))); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
// Get a list of folders in the search path with the given filter. |
70
|
|
|
$folders = Folder::folders($path, $filter); |
71
|
|
|
|
72
|
|
|
// Build the options list from the list of folders. |
73
|
|
|
if (is_array($folders)) |
74
|
|
|
{ |
75
|
|
|
foreach ($folders as $folder) |
76
|
|
|
{ |
77
|
|
|
// Check to see if the file is in the exclude mask. |
78
|
|
View Code Duplication |
if ($exclude) |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
if (preg_match(chr(1) . $exclude . chr(1), $folder)) |
81
|
|
|
{ |
82
|
|
|
continue; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
$options[] = HtmlSelect::option($folder, $folder); |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
// Merge any additional options in the XML definition. |
91
|
|
|
$options = array_merge(parent::getOptions(), $options); |
92
|
|
|
|
93
|
|
|
return $options; |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|
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.