Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
feeds
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
feeds
Commits
5ae1fd73
Commit
5ae1fd73
authored
14 years ago
by
Alex Barth
Browse files
Options
Downloads
Patches
Plain Diff
Upgrade file handling.
parent
0be4cf20
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
includes/FeedsBatch.inc
+7
-3
7 additions, 3 deletions
includes/FeedsBatch.inc
plugins/FeedsFileFetcher.inc
+2
-4
2 additions, 4 deletions
plugins/FeedsFileFetcher.inc
plugins/FeedsParser.inc
+3
-2
3 additions, 2 deletions
plugins/FeedsParser.inc
with
12 additions
and
9 deletions
includes/FeedsBatch.inc
+
7
−
3
View file @
5ae1fd73
...
...
@@ -142,6 +142,7 @@ class FeedsBatch {
* @see FeedsHTTPBatch
*/
class
FeedsImportBatch
extends
FeedsBatch
{
protected
$file_path
;
protected
$title
;
protected
$description
;
protected
$link
;
...
...
@@ -159,6 +160,7 @@ class FeedsImportBatch extends FeedsBatch {
FEEDS_PARSING
=>
FEEDS_BATCH_COMPLETE
,
FEEDS_PROCESSING
=>
FEEDS_BATCH_COMPLETE
,
);
$this
->
file_path
=
NULL
;
$this
->
title
=
''
;
$this
->
description
=
''
;
$this
->
link
=
''
;
...
...
@@ -189,15 +191,17 @@ class FeedsImportBatch extends FeedsBatch {
*/
public
function
getFilePath
()
{
if
(
!
isset
(
$this
->
file_path
))
{
$dir
=
file_directory_path
()
.
'
/feeds'
;
$dir
=
'public:/
/feeds'
;
if
(
!
file_prepare_directory
(
$dir
,
FILE_CREATE_DIRECTORY
|
FILE_MODIFY_PERMISSIONS
))
{
throw
new
Exception
(
t
(
'Feeds directory either cannot be created or is not writable.'
));
}
$dest
=
file_destination
(
$dir
.
'/'
.
get_class
(
$this
)
.
'_'
.
drupal_get_token
(
$this
->
url
)
.
'_'
.
time
(),
FILE_EXISTS_RENAME
);
$this
->
file_path
=
file_save_data
(
$this
->
getRaw
(),
$dest
);
if
(
$this
->
file_path
===
0
)
{
$this
->
file_path
=
FALSE
;
$file
=
file_save_data
(
$this
->
getRaw
(),
$dest
);
if
(
$file
===
FALSE
)
{
throw
new
Exception
(
t
(
'Cannot write content to %dest'
,
array
(
'%dest'
=>
$dest
)));
}
$this
->
file_path
=
$file
->
uri
;
}
return
$this
->
file_path
;
}
...
...
This diff is collapsed.
Click to expand it.
plugins/FeedsFileFetcher.inc
+
2
−
4
View file @
5ae1fd73
...
...
@@ -11,8 +11,6 @@
* FeedsFileFetcher.
*/
class
FeedsFileBatch
extends
FeedsImportBatch
{
protected
$file_path
;
/**
* Constructor.
*/
...
...
@@ -87,8 +85,8 @@ class FeedsFileFetcher extends FeedsFetcher {
* Override parent::sourceFormValidate().
*/
public
function
sourceFormValidate
(
&
$values
)
{
$feed_dir
=
file_directory_path
()
.
'
/feeds'
;
file_prepare_directory
(
$dir
,
FILE_CREATE_DIRECTORY
|
FILE_MODIFY_PERMISSIONS
);
$feed_dir
=
'public:/
/feeds'
;
file_prepare_directory
(
$
feed_
dir
,
FILE_CREATE_DIRECTORY
|
FILE_MODIFY_PERMISSIONS
);
// If there is a file uploaded, save it, otherwise validate input on
// file.
...
...
This diff is collapsed.
Click to expand it.
plugins/FeedsParser.inc
+
3
−
2
View file @
5ae1fd73
...
...
@@ -247,7 +247,7 @@ class FeedsEnclosure extends FeedsElement {
if
(
empty
(
$this
->
file
)
&&
$this
->
getValue
())
{
// Check if this enclosure contains a local file.
if
(
!
parse_url
(
$this
->
getValue
(),
PHP_URL_SCHEME
))
{
if
(
file_check_location
(
$this
->
getValue
(),
file_directory_path
())
)
{
if
(
strpos
(
$this
->
getValue
(),
'public://'
)
===
0
)
{
if
(
file_exists
(
$this
->
getValue
()))
{
$this
->
file
=
$this
->
getValue
();
return
$this
->
file
;
...
...
@@ -265,7 +265,8 @@ class FeedsEnclosure extends FeedsElement {
$this
->
file
=
copy
(
$this
->
getValue
(),
$dest
)
?
$dest
:
0
;
}
else
{
$this
->
file
=
file_save_data
(
$this
->
getContent
(),
$dest
);
$file
=
file_save_data
(
$this
->
getContent
(),
$dest
);
$this
->
file
=
$file
?
$file
->
uri
:
0
;
}
if
(
$this
->
file
===
0
)
{
throw
new
Exception
(
t
(
'Cannot write content to %dest'
,
array
(
'%dest'
=>
$dest
)));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment