Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
d53f3e39
Commit
d53f3e39
authored
Jan 26, 2010
by
Dries Buytaert
Browse files
- Patch
#685074
by pwolanin: some stream wrappers need to be hidden or read-only.
parent
420c27c4
Changes
6
Hide whitespace changes
Inline
Side-by-side
includes/file.inc
View file @
d53f3e39
...
...
@@ -90,16 +90,24 @@
*
* A stream is referenced as "scheme://target".
*
* @param $filter
* Optionally filter out all types except these. Defaults to
* STREAM_WRAPPERS_ALL, which returns all registered stream wrappers.
*
* @return
* Returns the entire Drupal stream wrapper registry.
* @see hook_stream_wrappers()
* @see hook_stream_wrappers_alter()
*/
function
file_get_stream_wrappers
()
{
$wrappers
=
&
drupal_static
(
__FUNCTION__
);
function
file_get_stream_wrappers
(
$filter
=
STREAM_WRAPPERS_ALL
)
{
$wrappers
_storage
=
&
drupal_static
(
__FUNCTION__
);
if
(
!
isset
(
$wrappers
))
{
if
(
!
isset
(
$wrappers
_storage
))
{
$wrappers
=
module_invoke_all
(
'stream_wrappers'
);
foreach
(
$wrappers
as
$scheme
=>
$info
)
{
// Add defaults.
$wrappers
[
$scheme
]
+=
array
(
'type'
=>
STREAM_WRAPPERS_NORMAL
);
}
drupal_alter
(
'stream_wrappers'
,
$wrappers
);
$existing
=
stream_get_wrappers
();
foreach
(
$wrappers
as
$scheme
=>
$info
)
{
...
...
@@ -115,9 +123,25 @@ function file_get_stream_wrappers() {
}
stream_wrapper_register
(
$scheme
,
$info
[
'class'
]);
}
// Pre-populate the static cache with the filters most typically used.
$wrappers_storage
[
STREAM_WRAPPERS_ALL
][
$scheme
]
=
$wrappers
[
$scheme
];
if
((
$info
[
'type'
]
&
STREAM_WRAPPERS_WRITE_VISIBLE
)
==
STREAM_WRAPPERS_WRITE_VISIBLE
)
{
$wrappers_storage
[
STREAM_WRAPPERS_WRITE_VISIBLE
][
$scheme
]
=
$wrappers
[
$scheme
];
}
}
}
return
$wrappers
;
if
(
!
isset
(
$wrappers_storage
[
$filter
]))
{
$wrappers_storage
[
$filter
]
=
array
();
foreach
(
$wrappers_storage
[
STREAM_WRAPPERS_ALL
]
as
$scheme
=>
$info
)
{
// Bit-wise filter.
if
(
$info
[
'type'
]
&
$filter
==
$filter
)
{
$wrappers_storage
[
$filter
][
$scheme
]
=
$info
;
}
}
}
return
$wrappers_storage
[
$filter
];
}
/**
...
...
includes/stream_wrappers.inc
View file @
d53f3e39
...
...
@@ -20,6 +20,65 @@
* @link http://bugs.php.net/bug.php?id=47070
*/
/**
* Stream wrapper bit flags that are the basis for composite types.
*/
/**
* Stream wrapper bit flag -- a filter that matches all wrappers.
*/
define
(
'STREAM_WRAPPERS_ALL'
,
0x0000
);
/**
* Stream wrapper bit flag -- refers to a local file system location.
*/
define
(
'STREAM_WRAPPERS_LOCAL'
,
0x0001
);
/**
* Stream wrapper bit flag -- refers to a remote filesystem location.
*/
define
(
'STREAM_WRAPPERS_REMOTE'
,
0x0002
);
/**
* Stream wrapper bit flag -- wrapper is readable (almost always true).
*/
define
(
'STREAM_WRAPPERS_READ'
,
0x0004
);
/**
* Stream wrapper bit flag -- wrapper is writeable.
*/
define
(
'STREAM_WRAPPERS_WRITE'
,
0x0008
);
/**
* Stream wrapper bit flag -- exposed in the UI and potentially web accessible.
*/
define
(
'STREAM_WRAPPERS_VISIBLE'
,
0x0010
);
/**
* Composite stream wrapper bit flags that are usually used as the types.
*/
/**
* Stream wrapper type flag -- not visible in the UI or accessible via web,
* but readable and writable. E.g. the temporary directory for uploads.
*/
define
(
'STREAM_WRAPPERS_HIDDEN'
,
STREAM_WRAPPERS_READ
|
STREAM_WRAPPERS_WRITE
);
/**
* Stream wrapper type flag -- visible, readable and writeable.
*/
define
(
'STREAM_WRAPPERS_WRITE_VISIBLE'
,
STREAM_WRAPPERS_READ
|
STREAM_WRAPPERS_WRITE
|
STREAM_WRAPPERS_VISIBLE
);
/**
* Stream wrapper type flag -- visible and read-only.
*/
define
(
'STREAM_WRAPPERS_READ_VISIBLE'
,
STREAM_WRAPPERS_READ
|
STREAM_WRAPPERS_VISIBLE
);
/**
* Stream wrapper type flag -- visible, readable and writeable using local files.
*/
define
(
'STREAM_WRAPPERS_NORMAL'
,
STREAM_WRAPPERS_LOCAL
|
STREAM_WRAPPERS_WRITE_VISIBLE
);
/**
* Generic PHP stream wrapper interface.
*
...
...
modules/file/file.field.inc
View file @
d53f3e39
...
...
@@ -86,10 +86,8 @@ function file_field_settings_form($field, $instance, $has_data) {
);
$scheme_options
=
array
();
foreach
(
file_get_stream_wrappers
()
as
$scheme
=>
$stream_wrapper
)
{
if
(
$scheme
!=
'temporary'
)
{
$scheme_options
[
$scheme
]
=
$stream_wrapper
[
'name'
];
}
foreach
(
file_get_stream_wrappers
(
STREAM_WRAPPERS_WRITE_VISIBLE
)
as
$scheme
=>
$stream_wrapper
)
{
$scheme_options
[
$scheme
]
=
$stream_wrapper
[
'name'
];
}
$form
[
'uri_scheme'
]
=
array
(
'#type'
=>
'radios'
,
...
...
modules/image/image.field.inc
View file @
d53f3e39
...
...
@@ -72,10 +72,8 @@ function image_field_settings_form($field, $instance) {
$settings
=
array_merge
(
$defaults
,
$field
[
'settings'
]);
$scheme_options
=
array
();
foreach
(
file_get_stream_wrappers
()
as
$scheme
=>
$stream_wrapper
)
{
if
(
$scheme
!=
'temporary'
)
{
$scheme_options
[
$scheme
]
=
$stream_wrapper
[
'name'
];
}
foreach
(
file_get_stream_wrappers
(
STREAM_WRAPPERS_WRITE_VISIBLE
)
as
$scheme
=>
$stream_wrapper
)
{
$scheme_options
[
$scheme
]
=
$stream_wrapper
[
'name'
];
}
$form
[
'uri_scheme'
]
=
array
(
'#type'
=>
'radios'
,
...
...
modules/system/system.admin.inc
View file @
d53f3e39
...
...
@@ -1743,11 +1743,11 @@ function system_file_system_settings() {
'#description'
=>
t
(
'A local file system path where temporary files will be stored. This directory should not be accessible over the web.'
),
'#after_build'
=>
array
(
'system_check_directory'
),
);
$wrappers
=
file_get_stream_wrappers
();
$options
=
array
(
'public'
=>
$wrappers
[
'public'
][
'description'
],
'private'
=
>
$
wrappers
[
'private'
]
[
'description'
]
);
// Any visible, writeable wrapper can potentially be used for the files
// directory, including a remote file system that integrates with a CDN.
foreach
(
file_get_stream_wrappers
(
STREAM_WRAPPERS_WRITE_VISIBLE
)
as
$scheme
=>
$info
)
{
$options
[
$scheme
]
=
$
info
[
'description'
]
;
}
$form
[
'file_default_scheme'
]
=
array
(
'#type'
=>
'radios'
,
'#title'
=>
t
(
'Default download method'
),
...
...
modules/system/system.module
View file @
d53f3e39
...
...
@@ -1458,6 +1458,7 @@ function system_stream_wrappers() {
'name'
=>
t
(
'Temporary files'
),
'class'
=>
'DrupalTemporaryStreamWrapper'
,
'description'
=>
t
(
'Temporary local files for upload and previews.'
),
'type'
=>
STREAM_WRAPPERS_HIDDEN
,
)
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment