Variable File module will provide uploadfile type for Variable module.
Variable File allow you upload file as configuration, support thumbnail when
file has filemime is image/jpeg.
Note: when you load vairable with type uploadfile, it just a file id, you need
use file_load to load other properties of file.
How?
===========================
Implement hook_variable_info() with type is uploadfile.
/**
* Implements hook_variable_info().
*/
function hook_variable_info($options) {
$variables['myuploadfile'] = array(
'type' => 'uploadfile',
'title' => t('My Upload File', array(), $options),
'description' => t('Upload my config file.', array(), $options),
'required' => TRUE,
'upload_location' => 'public://myuploaddir',
'upload_validators' => array(
'file_validate_extensions' => array('gif png jpg jpeg'),
),
'group' => 'variable_example',
);
return $variables;
}
More information about hook_variable_info and config you can look at Variable module.
Project Page: https://drupal.org/sandbox/flashvnn/2072321
Git: git clone http://git.drupal.org/sandbox/flashvnn/2072321.git variable_file
Comments
Comment #1
zipme_hkt CreditAttribution: zipme_hkt commentedChange status to need review
Comment #2
xiukun.zhou CreditAttribution: xiukun.zhou commentedReview of the 7.x-1.x branch:
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.
Source: http://pareview.sh/ - PAReview.sh online service
Comment #3
zipme_hkt CreditAttribution: zipme_hkt commentedFix PAReview.sh
Comment #4
zipme_hkt CreditAttribution: zipme_hkt commentedAdd tag PAReview: review bonus
Comment #5
sergei_brill CreditAttribution: sergei_brill commentedHi. I did manual review for your module.
1. As I know, module.api.php file is used to describe hooks which provides the module. Since your module do not provides a hooks, may be it is better to move description of additional options for hook_variable_info to README and remove variables_file.api.php?
2. Could you display the thumbnail for other mime types? At least for png and gif. Files of this types are used often.
3. I define custom variable of type 'uploadfile' via hook_variable_info. I added 'options' for the variable. When I uploaded file via variable form and clicked 'Save configuratio' I got error 'An illegal choice detected'. Now I understand the reason. But may be it would be nice to describe an available options which developer can use in the hook.
4. just a feature request, do not fix for now. Try to integrate with views. It could be useful to display a variable as a file, not file id.
Comment #6
zipme_hkt CreditAttribution: zipme_hkt commentedUpdate points 1-3 of @sergei_brill.
Comment #7
Jay.Chen CreditAttribution: Jay.Chen commentedOne issue on the hook_help().
$output = file_get_contents(drupal_get_path('module', 'variable_file') . '/README.txt');
You should wrap the output by using the t function. Otherwise, the string can not be translated.
Comment #8
zipme_hkt CreditAttribution: zipme_hkt commentedFix @Jay.Chen issue.
Now easy translate README help by define README file with format "README.{lang_code}.txt".
Comment #9
bohartHi zipme_hkt
I found next problems:
Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.
Comment #10
zipme_hkt CreditAttribution: zipme_hkt commentedFixed issue reported by @bohart, thank you.
Comment #11
Jay.Chen CreditAttribution: Jay.Chen commentedFor the #8, I think your solution is no good.
1. It is not a standard Drupal way to translate string.
2. User can't search the string via the admin UI.
3. The string can't be imported or exported via the admin UI.
4. It is difficult to update your module.
5. In your way, user has to manually create a translated file like "README.{lang_code}.txt" in your module folder. But not all end users have FTP permission to do that or they even don't know how to do that.
My suggestion:
Why don't you use the t() function? If you think the help text is too long, you can make it shorter as possible.
Comment #12
zipme_hkt CreditAttribution: zipme_hkt commentedFixed #8
Thanks
Comment #13
kscheirerCan you talk a little more about why someone would want to use this module on your project page? From reading the description it sounds interesting, but I'm not sure what use case it solves.
You have a couple minor errors reported here: http://pareview.sh/pareview/httpgitdrupalorgsandboxflashvnn2072321git.
----
Top Shelf Modules - Crafted, Curated, Contributed.
Comment #14
zipme_hkt CreditAttribution: zipme_hkt commentedFixed pareview.sh warning.
Thanks.
Comment #15
klausiSorry for the delay, but you have not listed any reviews of other project applications in your issue summary as strongly recommended in the application documentation.
manual review:
Otherwise looks good to me, so ...
Thanks for your contribution, zipme_hkt!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #15.0
klausiCorrect upload_validators