summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrel O\'Pry2008-07-14 05:29:07 (GMT)
committer Darrel O\'Pry2008-07-14 05:29:07 (GMT)
commitc147cceb5c03d09610d2109cf9e9bd21fd24a8b3 (patch)
tree578a32b2b9856ae8d21f88e1bf3f3cae8552b455
parentd2f124d5ea482a6bd8a776dc69fd36f4551aba09 (diff)
continuing along...
-rw-r--r--UPGRADE.txt23
-rw-r--r--filefield.module31
-rw-r--r--filefield_formatter.inc (renamed from filefield.formatter.inc)13
-rw-r--r--filefield_widget.inc30
4 files changed, 53 insertions, 44 deletions
diff --git a/UPGRADE.txt b/UPGRADE.txt
new file mode 100644
index 0000000..cb37b30
--- /dev/null
+++ b/UPGRADE.txt
@@ -0,0 +1,23 @@
+Upgrading from 5.x-2.x to 6.x-2.x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+MODULE DEVELOPERS:
+
+Upgrading from 5.x-2.x to 6.x-2.x
+ the field type for filefields has changed from 'file' to 'filefield'.
+ I suggest you just reread the whole module...
+
+
diff --git a/filefield.module b/filefield.module
index 176540b..33eb78a 100644
--- a/filefield.module
+++ b/filefield.module
@@ -85,20 +85,29 @@ function filefield_elements() {
*/
function filefield_theme() {
return array(
+ 'filefield_file' => array(
+ 'arguments' => array('file' => NULL),
+ 'file' => 'filefield_formatter.inc',
+ ),
+ 'filefield_icon' => array(
+ 'arguments' => array('file' => NULL),
+ 'file' => 'filefield.theme.inc',
+ ),
'filefield_widget' => array(
'arguments' => array('element' => NULL),
'file' => 'filefield_widget.inc',
),
+
+ 'filefield_formatter_filefield_default' => array(
+ 'arguments' => array('element' => NULL),
+ 'file' => 'filefield_formatter.inc',
+ ),
// @todo: verify the need for the rest one by one.
'filefield_container_item' => array(
'arguments' => array('element' => NULL),
'file' => 'filefield.theme.inc',
),
- 'filefield_icon' => array(
- 'arguments' => array('file' => NULL),
- 'file' => 'filefield.theme.inc',
- ),
'filefield_file_upload' => array(
'arguments' => array('element' => NULL),
'file' => 'filefield_widget.inc',
@@ -113,21 +122,15 @@ function filefield_theme() {
),
'filefield_formatter_default' => array(
'arguments' => array('element' => NULL),
- 'file' => 'filefield.formatter.inc',
+ 'file' => 'filefield_formatter.inc',
),
'filefield_unguarded' => array(
'arguments' => array('file' => NULL, 'field' => NULL),
- 'file' => 'filefield.formatter.inc',
+ 'file' => 'filefield_formatter.inc',
),
'filefield' => array(
'arguments' => array('file' => NULL, 'field' => NULL),
- 'file' => 'filefield.formatter.inc',
- ),
- 'filefield_file_formatter_generic' => array(
- 'arguments' => array(
- 'file' => NULL, 'field' => NULL, 'file_formatter_settings' => NULL,
- ),
- 'file' => 'filefield.formatter.inc',
+ 'file' => 'filefield_formatter.inc',
),
);
}
@@ -329,7 +332,7 @@ function filefield_field_formatter_info() {
'filefield_default' => array(
'label' => t('Generic files'),
'suitability callback' => TRUE,
- 'field types' => array('file','image'),
+ 'field types' => array('filefield','image'),
'multiple values' => CONTENT_HANDLE_CORE,
'description' => t('Displays all kinds of files with an icon and a linked file description.'),
),
diff --git a/filefield.formatter.inc b/filefield_formatter.inc
index a30f91e..5ce7fd3 100644
--- a/filefield.formatter.inc
+++ b/filefield_formatter.inc
@@ -13,10 +13,9 @@
/**
* Theme function for the 'default' filefield formatter.
*/
-function theme_filefield_formatter_default($element) {
+function theme_filefield_formatter_filefield_default($element) {
$file = $element['#item'];
- $field = content_fields($element['#field_name']);
- return theme('filefield', $file, $field);
+ return 'filefiedl' . theme('filefield', $file);
}
/**
@@ -77,10 +76,10 @@ function theme_filefield_unguarded($file, $field) {
/**
* Theme function for the 'generic' single file formatter.
*/
-function theme_filefield_file_formatter_generic($file, $field, $file_formatter_settings) {
- $path = $file->filepath;
+function theme_filefield_file($file) {
+ $path = $file['filepath'];
$url = file_create_url($path);
$icon = theme('filefield_icon', $file);
- $desc = $file->description;
- return '<div class="filefield-formatter-generic">'. $icon . l($desc, $url) .'</div>';
+ $desc = $file['description'];
+ return '<div class="filefield-file">'. $icon . l($desc, $url) .'</div>';
}
diff --git a/filefield_widget.inc b/filefield_widget.inc
index b1ef4d4..0f433fa 100644
--- a/filefield_widget.inc
+++ b/filefield_widget.inc
@@ -22,8 +22,8 @@ function filefield_widget_value($element, $edit = FALSE) {
$file = field_file_load($edit['fid']);
$item = array(
'fid' => $edit['fid'],
- 'alt' => $edit['alt'],
- 'title' => $edit['title'],
+ 'description' => $edit['description'],
+ 'list' => empty($edit['list']),
'data' => '',
);
}
@@ -43,7 +43,7 @@ function filefield_widget_process($element, $edit, &$form_state, $form) {
$element['fid'] = array('#type' => 'hidden', '#value' => $file['fid']);
if ($file['fid'] != 0) {
- $element['preview'] = array('#type' => 'markup', '#value' => theme('imagefield_item', $file));
+ $element['preview'] = array('#type' => 'markup', '#value' => theme('filefield_file', $file));
if (empty($file['filepath'])) {
//dsm($file);
}
@@ -70,7 +70,7 @@ function filefield_widget_process($element, $edit, &$form_state, $form) {
'#name' => $field_name .'_'. $delta .'_remove_btn',
'#type' => 'submit',
'#value' => t('Remove'),
- '#submit' => array('imagefield_widget_submit_remove_btn'),
+ '#submit' => array('filefield_widget_submit_remove_btn'),
'#field_name' => $field_name,
'#delta' => $delta,
);
@@ -90,7 +90,7 @@ function filefield_widget_process($element, $edit, &$form_state, $form) {
'#name' => $field_name .'_'. $delta .'_upload_btn',
'#type' => 'submit',
'#value' => t('Upload'),
- '#submit' => array('imagefield_widget_submit_upload_btn'),
+ '#submit' => array('filefield_widget_submit_upload_btn'),
'#field_name' => $field_name,
'#delta' => $delta,
);
@@ -138,11 +138,7 @@ function filefield_widget_submit_upload_btn($form, &$form_state) {
return $file;
}
- $validators = array(
- 'file_validate_extensions' => array($field['widget']['file_extensions']),
- 'file_validate_size' => array($field['widget']['max_filesize']),
- 'file_validate_image_resolution' => array($field['widget']['max_resolution']),
- );
+ $validators = _filefield_filefield_validators($field, $field['widget'], $form_state['values'][$field_name]);
if (!$file = field_file_save_upload($upload_name, $validators, $complete_file_path)) {
watchdog('imagefield', 'The file upload failed. %upload', array('%upload' => $upload_name));
@@ -476,9 +472,7 @@ function _filefield_filefield_validators($field, $widget, $existing_files) {
// Thanks to the php.ini restrictions, there is always a maximum file size.
// Therefore we can rely on at least one restriction always being in force.
- $max_filesize = _filefield_maximum_filesize(
- $field, $widget, $existing_files
- );
+ $max_filesize = _filefield_maximum_filesize($field, $widget, $existing_files);
$filesize_message = ($max_filesize > 0)
? t('Maximum file size: !size.', array('!size' => format_size($max_filesize)))
: t('The allowed maximum file size total has been exceeded.');
@@ -497,16 +491,6 @@ function _filefield_filefield_validators($field, $widget, $existing_files) {
)),
);
}
-
- $supported_file_widgets = _filefield_supported_file_widgets($widget);
- if (!empty($supported_file_widgets)) {
- $validators['filefield_validate_file_widget_support'] = array(
- 'validator arguments' => array($field, $widget, $supported_file_widgets),
- 'requirement message' => t('Uploads are restricted to the following categories: !widgets.', array(
- '!widgets' => implode(', ', $supported_file_widgets),
- )),
- );
- }
return $validators;
}