summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoloc2012-12-12 19:27:28 (GMT)
committer Moloc2012-12-12 19:27:28 (GMT)
commit0a61666fb15d85d96e13523969a6210c2b03fc12 (patch)
tree107f91fd4abf5e3ff47a2123be68c0b42bb64965
parent660d8772b728e158c59b33735e030401b6b6e75f (diff)
Issue #1848912: Fixed using file_entity edit functions.
-rw-r--r--media_gallery.module22
-rw-r--r--media_gallery.pages.inc19
2 files changed, 22 insertions, 19 deletions
diff --git a/media_gallery.module b/media_gallery.module
index ecb6ee2..876d685 100644
--- a/media_gallery.module
+++ b/media_gallery.module
@@ -895,10 +895,12 @@ function media_gallery_form($node, $form_state) {
* Implements hook_form_alter().
*/
function media_gallery_form_alter(&$form, &$form_state, $form_id) {
- if (strpos($form_id, 'media_edit') === 0) {
+ // $form_id = 'media_edit_*' by using multiple file editing
+ // $form_id = 'file_entity_edit' by using regular file edit
+ if (strpos($form_id, 'media_edit') === 0 || strpos($form_id, 'file_entity_edit')) {
// Act on both the regular and multiform versions of the edit form.
- if ($form_id === 'media_edit' || preg_match('/^media_edit_[0-9]+$/', $form_id)) {
- // Prepopulate the media_edit form with our best guess at the image title.
+ if ($form_id === 'file_entity_edit' || preg_match('/^media_edit_[0-9]+$/', $form_id)) {
+ // Prepopulate the file_entity_edit form with our best guess at the image title.
if (!empty($form['media_title']) && empty($form['media_title'][LANGUAGE_NONE][0]['value']['#default_value'])) {
$fid = $form['fid']['#value'];
$file = file_load($fid);
@@ -1021,8 +1023,8 @@ function media_gallery_form_media_gallery_node_form_alter(&$form, &$form_state)
/**
* Implements hook_form_FORM_ID_alter().
*/
-function media_gallery_form_media_edit_alter(&$form, &$form_state) {
- // Adjust the media edit form when it is shown within a gallery context.
+function media_gallery_form_file_entity_edit_alter(&$form, &$form_state) {
+ // Adjust the file entity edit form when it is shown within a gallery context.
if (isset($form_state['media_gallery']['gallery'])) {
// Remove the Delete button, since media entities can't be deleted when they
// are in use.
@@ -1038,9 +1040,9 @@ function media_gallery_form_media_edit_alter(&$form, &$form_state) {
// Make sure to add this for the form-level submit handlers and also for the
// button-level submit handlers of the "Save" button, in case those are
// being used.
- $form['#submit'][] = 'media_gallery_media_edit_submit';
+ $form['#submit'][] = 'media_gallery_file_entity_edit_submit';
if (isset($form['actions']['submit']['#submit'])) {
- $form['actions']['submit']['#submit'][] = 'media_gallery_media_edit_submit';
+ $form['actions']['submit']['#submit'][] = 'media_gallery_file_entity_edit_submit';
}
}
// On the media gallery multiedit page, add a "Remove" checkbox to each item.
@@ -1097,11 +1099,11 @@ function media_gallery_multiedit_remove_item($form, &$form_state) {
}
/**
- * Form submit handler for media entity edit form in gallery context.
+ * Form submit handler for file_entity edit form in gallery context.
*
- * @see media_gallery_form_media_edit_alter()
+ * @see media_gallery_form_file_entity_edit_alter()
*/
-function media_gallery_media_edit_submit($form, &$form_state) {
+function media_gallery_file_entity_edit_submit($form, &$form_state) {
$form_state['redirect'] = 'media-gallery/detail/' . $form_state['media_gallery']['gallery']->nid . '/' . $form_state['values']['fid'];
}
diff --git a/media_gallery.pages.inc b/media_gallery.pages.inc
index 7c22c7e..a56928f 100644
--- a/media_gallery.pages.inc
+++ b/media_gallery.pages.inc
@@ -370,12 +370,13 @@ function media_gallery_media_page_edit($gallery, $file) {
l($gallery->title, $node_url_arguments['path'], $node_url_arguments['options']),
));
- // We'll be reusing Media module's 'media_edit' form, so we need to load its
- // include file. In addition to loading it here, we also set the include file
- // info within $form_state in case there are AJAX enabled widgets that will
- // submit to system/ajax, bypassing this menu callback.
- module_load_include('inc', 'media', 'includes/media.pages');
- $form_state['build_info']['files']['menu'] = array('type' => 'inc', 'module' => 'media', 'name' => 'media.pages');
+ // We'll be reusing File entity (fieldable files) module's 'file_entity_edit'
+ // form, so we need to load its include file. In addition to loading it here,
+ // we also set the include file info within $form_state in case there are
+ // AJAX enabled widgets that will submit to system/ajax, bypassing this menu
+ // callback.
+ module_load_include('inc', 'file_entity', 'file_entity.pages');
+ $form_state['build_info']['files']['menu'] = array('type' => 'inc', 'module' => 'file_entity', 'name' => 'file_entity.pages');
// Provide context information for form building and processing functions.
$form_state['media_gallery']['gallery'] = $gallery;
@@ -383,7 +384,7 @@ function media_gallery_media_page_edit($gallery, $file) {
// Since we have a $form_state, we can't call drupal_get_form(), so pass the
// expected arguments to drupal_build_form().
$form_state['build_info']['args'] = array($file);
- return drupal_build_form('media_edit', $form_state);
+ return drupal_build_form('file_entity_edit', $form_state);
}
/**
@@ -409,9 +410,9 @@ function media_gallery_media_page_multiedit($node) {
module_load_include('inc', 'media', 'includes/media.pages');
// Build and process the form.
- $form = media_page_multiedit($files);
+ $form = media_file_page_edit_multiple($files);
- // Override the page title set by media_page_multiedit() and return the form.
+ // Override the page title set by media_file_page_edit_multiple() and return the form.
drupal_set_title(t('<em>Edit media for</em> @title', array('@type' => $node->type, '@title' => $node->title)), PASS_THROUGH);
return $form;
}