Created
May 25, 2012 13:03
-
-
Save bangpound/2788011 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = File entity hacks | |
description = Temporary hacks to File entity module. | |
core = 7.x | |
php = 5.2.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function file_entity_hacks_menu_alter(&$items) { | |
// Override file upload form page callback to inject new allowed file extensions. | |
if (module_exists('file_entity')) { | |
$items['file/add']['page arguments'] = array('file_entity_hacks_file_entity_add_upload'); | |
$items['file/add']['file'] = 'file_entity_hacks.pages.inc'; | |
$items['file/add']['file path'] = drupal_get_path('module', 'file_entity_hacks'); | |
if (module_exists('plupload') && module_exists('multiform')) { | |
$items['file/add']['page arguments'] = array('file_entity_hacks_file_entity_add_upload_multiple'); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Upload file form with new file extensions. | |
*/ | |
function file_entity_hacks_file_entity_add_upload($form, &$form_state, $params = array()) { | |
module_load_include('inc', 'file_entity', 'file_entity.pages'); | |
$params['file_extensions'] = variable_get('media__file_extensions', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'); | |
$form = file_entity_add_upload($form, $form_state, $params); | |
$form['#submit'] = array('file_entity_add_upload_submit'); | |
return $form; | |
} | |
/** | |
* Mulstiple upload file form with new file extensions. | |
*/ | |
function file_entity_hacks_file_entity_add_upload_multiple($form, &$form_state, $params = array()) { | |
module_load_include('inc', 'file_entity', 'file_entity.pages'); | |
$params['file_extensions'] = variable_get('media__file_extensions', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp'); | |
$form = file_entity_add_upload_multiple($form, $form_state, $params); | |
$form['#submit'] = array('file_entity_add_upload_multiple_submit'); | |
return $form; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment