class FeedsFileFetcher in Feeds 6
Same name and namespace in other branches
- 7.2 plugins/FeedsFileFetcher.inc \FeedsFileFetcher
- 7 plugins/FeedsFileFetcher.inc \FeedsFileFetcher
Fetches data via HTTP.
Hierarchy
- class \FeedsConfigurable
- class \FeedsPlugin implements FeedsSourceInterface
- class \FeedsFetcher
- class \FeedsFileFetcher
- class \FeedsFetcher
- class \FeedsPlugin implements FeedsSourceInterface
Expanded class hierarchy of FeedsFileFetcher
14 string references to 'FeedsFileFetcher'
- FeedsCSVtoTermsTest::test in tests/
feeds_processor_term.test - Test node creation, refreshing/deleting feeds and feed items.
- FeedsCSVtoUsersTest::test in tests/
feeds_processor_user.test - Test node creation, refreshing/deleting feeds and feed items.
- FeedsMapperContentTaxonomyTestCase::test in tests/
feeds_mapper_content_taxonomy.test - Basic test loading a single entry CSV file.
- FeedsMapperContentTestCase::test in tests/
feeds_mapper_content.test - Basic test loading a doulbe entry CSV file.
- FeedsMapperDateTestCase::test in tests/
feeds_mapper_date.test - Basic test loading a single entry CSV file.
File
- plugins/
FeedsFileFetcher.inc, line 44 - Home of the FeedsFileFetcher and related classes.
View source
class FeedsFileFetcher extends FeedsFetcher {
/**
* Implementation of FeedsFetcher::fetch().
*/
public function fetch(FeedsSource $source) {
$source_config = $source
->getConfigFor($this);
return new FeedsFileBatch($source_config['source'], $source->feed_nid);
}
/**
* Source form.
*/
public function sourceForm($source_config) {
$form = $info = array();
if (!empty($source_config['source']) && file_exists($source_config['source'])) {
$info = array(
'path' => $source_config['source'],
'size' => filesize(realpath($source_config['source'])),
);
if (module_exists('mimedetect')) {
$file = new stdClass();
$file->filepath = realpath($source_config['source']);
$info['mime'] = mimedetect_mime($file);
}
}
$form['source'] = array(
'#type' => empty($this->config['direct']) ? 'value' : 'textfield',
'#title' => t('File'),
'#description' => t('Specify a file in the site\'s file system path or upload a file below.'),
'#default_value' => empty($source_config['source']) ? '' : $source_config['source'],
);
$form['upload'] = array(
'#type' => 'file',
'#title' => empty($this->config['direct']) ? t('File') : NULL,
'#description' => empty($source_config['source']) ? t('Select the file to be imported from your local system.') : t('Select a different file to be imported from your local system.'),
'#theme' => 'feeds_upload',
'#file_info' => $info,
'#size' => 10,
);
return $form;
}
/**
* Override parent::sourceFormValidate().
*/
public function sourceFormValidate(&$values) {
$feed_dir = file_directory_path() . '/feeds';
file_check_directory($feed_dir, TRUE);
$values['source'] = trim($values['source']);
// If there is a file uploaded, save it, otherwise validate input on
// file.
if ($file = file_save_upload('feeds', array(), $feed_dir)) {
file_set_status($file, FILE_STATUS_PERMANENT);
$values['source'] = $file->filepath;
}
elseif (empty($values['source'])) {
form_set_error('feeds][source', t('Upload a file first.'));
}
elseif (!file_check_location($values['source'], file_directory_path())) {
form_set_error('feeds][source', t('File needs to point to a file in your Drupal file system path.'));
}
}
/**
* Override parent::configDefaults().
*/
public function configDefaults() {
return array(
'direct' => FALSE,
);
}
/**
* Override parent::configForm().
*/
public function configForm(&$form_state) {
$form = array();
$form['direct'] = array(
'#type' => 'checkbox',
'#title' => t('Supply path to file directly'),
'#description' => t('For experts. If checked users can specify a path to a file when importing rather than uploading a file. This is useful when files to be imported are already present on server.'),
'#default_value' => $this->config['direct'],
);
return $form;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FeedsConfigurable:: |
protected | property | ||
FeedsConfigurable:: |
protected | property | CTools export enabled status of this object. | |
FeedsConfigurable:: |
protected | property | ||
FeedsConfigurable:: |
protected | property | ||
FeedsConfigurable:: |
public | function | Similar to setConfig but adds to existing configuration. | 1 |
FeedsConfigurable:: |
public | function | Submission handler for configForm(). | 3 |
FeedsConfigurable:: |
public | function | Validation handler for configForm(). | 3 |
FeedsConfigurable:: |
public | function | Copy a configuration. | 1 |
FeedsConfigurable:: |
public | function | Determine whether this object is persistent and enabled. I. e. it is defined either in code or in the database and it is enabled. | 1 |
FeedsConfigurable:: |
public | function | Implementation of getConfig(). | 1 |
FeedsConfigurable:: |
public static | function | Instantiate a FeedsConfigurable object. | 1 |
FeedsConfigurable:: |
public | function | Set configuration. | 1 |
FeedsConfigurable:: |
public | function | Override magic method __get(). Make sure that $this->config goes through getConfig() | |
FeedsConfigurable:: |
public | function | Override magic method __isset(). This is needed due to overriding __get(). | |
FeedsFetcher:: |
public | function | Clear all caches for results for given source. | 1 |
FeedsFetcher:: |
public | function | Override import period settings. This can be used to force a certain import interval. | 1 |
FeedsFetcher:: |
public | function | Menu item definition for fetchers of this class. Note how the path component in the item definition matches the return value of FeedsFetcher::path(); | |
FeedsFetcher:: |
public | function | Construct a path for a concrete fetcher/source combination. The result of this method matches up with the general path definition in FeedsFetcher::menuItem(). For example usage look at FeedsHTTPFetcher. | |
FeedsFetcher:: |
public | function | Request handler invoked if callback URL is requested. Locked down by default. For a example usage see FeedsHTTPFetcher. | 1 |
FeedsFetcher:: |
public | function | Subscribe to a source. Only implement if fetcher requires subscription. | 1 |
FeedsFetcher:: |
public | function | Unsubscribe from a source. Only implement if fetcher requires subscription. | 1 |
FeedsFileFetcher:: |
public | function |
Override parent::configDefaults(). Overrides FeedsConfigurable:: |
|
FeedsFileFetcher:: |
public | function |
Override parent::configForm(). Overrides FeedsConfigurable:: |
|
FeedsFileFetcher:: |
public | function |
Implementation of FeedsFetcher::fetch(). Overrides FeedsFetcher:: |
|
FeedsFileFetcher:: |
public | function |
Source form. Overrides FeedsPlugin:: |
|
FeedsFileFetcher:: |
public | function |
Override parent::sourceFormValidate(). Overrides FeedsPlugin:: |
|
FeedsPlugin:: |
public | function |
Returns TRUE if $this->sourceForm() returns a form. Overrides FeedsSourceInterface:: |
|
FeedsPlugin:: |
protected static | function | Loads on-behalf implementations from mappers/ directory. | |
FeedsPlugin:: |
public | function |
Save changes to the configuration of this object.
Delegate saving to parent (= Feed) which will collect
information from this object by way of getConfig() and store it. Overrides FeedsConfigurable:: |
|
FeedsPlugin:: |
public | function |
Implementation of FeedsSourceInterface::sourceDefaults(). Overrides FeedsSourceInterface:: |
1 |
FeedsPlugin:: |
public | function |
A source is being deleted. Overrides FeedsSourceInterface:: |
1 |
FeedsPlugin:: |
public | function |
A source is being saved. Overrides FeedsSourceInterface:: |
1 |
FeedsPlugin:: |
protected | function |
Constructor. Overrides FeedsConfigurable:: |