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
0ccaed76
Commit
0ccaed76
authored
15 years ago
by
Alex Barth
Browse files
Options
Downloads
Patches
Plain Diff
Add file fetcher, add source form handling.
parent
fae024b0
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
feeds.module
+5
-0
5 additions, 0 deletions
feeds.module
feeds_ui/feeds_ui.admin.inc
+1
-0
1 addition, 0 deletions
feeds_ui/feeds_ui.admin.inc
includes/feed.inc
+26
-13
26 additions, 13 deletions
includes/feed.inc
plugins/FeedsFileFetcher.inc
+33
-0
33 additions, 0 deletions
plugins/FeedsFileFetcher.inc
with
65 additions
and
13 deletions
feeds.module
+
5
−
0
View file @
0ccaed76
...
@@ -43,6 +43,11 @@ function feeds_feeds_plugin() {
...
@@ -43,6 +43,11 @@ function feeds_feeds_plugin() {
'file'
=>
drupal_get_path
(
'module'
,
'feeds'
)
.
'/plugins/FeedsHttpFetcher.inc'
,
'file'
=>
drupal_get_path
(
'module'
,
'feeds'
)
.
'/plugins/FeedsHttpFetcher.inc'
,
'parent'
=>
'FeedsFetcher'
,
'parent'
=>
'FeedsFetcher'
,
),
),
'FeedsFileFetcher'
=>
array
(
'name'
=>
t
(
'File fetcher'
),
'file'
=>
drupal_get_path
(
'module'
,
'feeds'
)
.
'/plugins/FeedsFileFetcher.inc'
,
'parent'
=>
'FeedsFetcher'
,
),
'FeedsCSVParser'
=>
array
(
'FeedsCSVParser'
=>
array
(
'name'
=>
t
(
'CSV parser'
),
'name'
=>
t
(
'CSV parser'
),
'file'
=>
drupal_get_path
(
'module'
,
'feeds'
)
.
'/plugins/FeedsCSVParser.inc'
,
'file'
=>
drupal_get_path
(
'module'
,
'feeds'
)
.
'/plugins/FeedsCSVParser.inc'
,
...
...
This diff is collapsed.
Click to expand it.
feeds_ui/feeds_ui.admin.inc
+
1
−
0
View file @
0ccaed76
...
@@ -64,6 +64,7 @@ function feeds_ui_build_create_form(&$form_state) {
...
@@ -64,6 +64,7 @@ function feeds_ui_build_create_form(&$form_state) {
);
);
}
}
else
{
else
{
// @todo: present plugin form first.
feeds_include
(
'feed'
);
feeds_include
(
'feed'
);
$feed
=
feeds_get_feed
(
$form_state
[
'storage'
][
'id'
]);
$feed
=
feeds_get_feed
(
$form_state
[
'storage'
][
'id'
]);
$form
[
'settings'
]
=
array
(
$form
[
'settings'
]
=
array
(
...
...
This diff is collapsed.
Click to expand it.
includes/feed.inc
+
26
−
13
View file @
0ccaed76
...
@@ -56,25 +56,15 @@ class Feed extends FeedsConfigurable {
...
@@ -56,25 +56,15 @@ class Feed extends FeedsConfigurable {
'#options'
=>
array
(
''
=>
t
(
'None'
))
+
node_get_types
(
'names'
),
'#options'
=>
array
(
''
=>
t
(
'None'
))
+
node_get_types
(
'names'
),
'#default_value'
=>
$this
->
config
[
'content_type'
],
'#default_value'
=>
$this
->
config
[
'content_type'
],
);
);
$form
[
'source'
]
=
array
(
$form
[
'source'
]
=
$this
->
fetcher
->
sourceForm
(
$form_state
);
'#type'
=>
'textfield'
,
$period
=
drupal_map_assoc
(
array
(
1
,
900
,
1800
,
3600
,
10800
,
21600
,
43200
,
86400
,
259200
,
604800
,
2419200
),
'format_interval'
);
'#title'
=>
t
(
'URL'
),
'#description'
=>
t
(
'Enter the URL for this feed @todo: delegate this form to plugin, hide if content type is picked.'
),
'#default_value'
=>
$config
[
'source'
][
'id'
],
);
$form
[
'update'
]
=
array
(
'#type'
=>
'radios'
,
'#title'
=>
t
(
'Update existing'
),
'#options'
=>
array
(
1
=>
t
(
'Yes'
),
0
=>
t
(
'No'
)),
'#default_value'
=>
$this
->
config
[
'update'
],
);
$period
=
drupal_map_assoc
(
array
(
1
,
900
,
1800
,
3600
,
10800
,
21600
,
32400
,
43200
,
86400
,
172800
,
259200
,
604800
,
1209600
,
2419200
,
3628800
,
4838400
,
7257600
,
15724800
,
31536000
),
'format_interval'
);
$period
[
FEEDAPI_CRON_NEVER_REFRESH
]
=
t
(
'Do not refresh periodically'
);
$period
[
FEEDAPI_CRON_NEVER_REFRESH
]
=
t
(
'Do not refresh periodically'
);
$period
[
1
]
=
t
(
'As often as possible'
);
$period
[
1
]
=
t
(
'As often as possible'
);
$form
[
'refresh_period'
]
=
array
(
$form
[
'refresh_period'
]
=
array
(
'#type'
=>
'select'
,
'#type'
=>
'select'
,
'#title'
=>
t
(
'Minimum refresh period'
),
'#title'
=>
t
(
'Minimum refresh period'
),
'#options'
=>
$period
,
'#options'
=>
$period
,
'#description'
=>
t
(
'This is the minimum time that must elapse before a feed may be refreshed automatically.'
),
'#default_value'
=>
$this
->
config
[
'refresh_period'
],
'#default_value'
=>
$this
->
config
[
'refresh_period'
],
);
);
return
$form
;
return
$form
;
...
@@ -327,6 +317,29 @@ class FeedsConfigurable {
...
@@ -327,6 +317,29 @@ class FeedsConfigurable {
* plugin type. See hook_feeds_plugin().
* plugin type. See hook_feeds_plugin().
*/
*/
class
FeedsFetcher
extends
FeedsConfigurable
{
class
FeedsFetcher
extends
FeedsConfigurable
{
/**
* Source form.
*/
public
function
sourceForm
(
&
$form_state
)
{
$form
=
array
();
$form
[
'source'
]
=
array
(
'#type'
=>
'textfield'
,
'#title'
=>
t
(
'URL'
),
'#description'
=>
t
(
'Enter the URL for this feed.'
),
'#default_value'
=>
$this
->
config
[
'source'
],
);
return
$form
;
}
/**
* Fetch content from a source and return it.
*
* Stub method. Every class that extends FeedsFetcher must implement this method.
*
* @param $source
* Source value as entered by user through sourceForm().
*/
public
function
fetch
(
$source
)
{
public
function
fetch
(
$source
)
{
return
NULL
;
return
NULL
;
}
}
...
...
This diff is collapsed.
Click to expand it.
plugins/FeedsFileFetcher.inc
0 → 100644
+
33
−
0
View file @
0ccaed76
<?php
// $Id$
/**
* @file
* Home of the FeedsFileFetcher.
*/
/**
* Fetches data via HTTP.
*/
class
FeedsFileFetcher
extends
FeedsFetcher
{
/**
* Source form.
*/
public
function
sourceForm
(
&
$form_state
)
{
$form
=
array
();
$form
[
'source'
]
=
array
(
'#type'
=>
'file'
,
'#title'
=>
t
(
'File'
),
'#description'
=>
t
(
'Upload a file.'
),
'#default_value'
=>
$this
->
config
[
'source'
],
);
return
$form
;
}
/**
* Fetch a local resource.
*/
public
function
fetch
(
$source
)
{
// @todo
}
}
\ No newline at end of file
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