Commit a17d961e authored by aaronwinborn's avatar aaronwinborn

remove media_upload

parent ea19cfb0
; $Id$
name = Drupal Upload Module Bridge
description = Integrated Drupal's Upload module with Media.
package = Media
core = 7.x
php = 5.2
dependencies[] = media
dependencies[] = upload
files[] = media_upload.module
\ No newline at end of file
<?php
// $Id$
/**
* @file
* This module provides integration for Drupal's upload module
* with the Media module
*/
/**
* Implementation of hook_media_register
*
* @return array
* Form array items
*/
function media_upload_media_register() {
$items = array();
// Register User files display
$items['media_upload_user_files'] = array(
'name' => t('User files'),
'uri' => 'file',
'kind' => 'resource',
'types' => '*',
'description' => t("Displays all of current user's files."),
'callbacks' => array(
'resource' => 'media_upload_user_files_select',
),
'fields' => array('attachments', 'filefield'),
);
// Register Add/Upload file functionality
$items['media_upload_resource_add_file'] = array(
'name' => 'Media Upload add file',
'description' => t("Add new file using Drupal's Upload module"),
'kind' => 'resource',
'callbacks' => array(
'resource' => 'media_upload_resource_add_file',
),
'fields' => array('attachments', 'filefield'),
);
// Register Embed file functionality
$items['media_upload_resource_embed_file'] = array(
'name' => 'Media Upload embed file',
'description' => t("Embed file URI using Drupal's Upload module"),
'uri' => 'file',
'kind' => 'resource',
'types' => '*',
'callbacks' => array(
'resource' => 'media_upload_resource_embed_file',
),
'fields' => array('attachments', 'filefield'),
);
// Register form formatter functionality
$items['media_upload_formatter_form'] = array(
'name' => 'Media Upload form formatter',
'description' => "Media upload form formatter",
'kind' => 'formatter',
'callbacks' => array(
'formatter' => 'media_upload_formatter_form',
),
'fields' => array('attachments', 'filefield'),
);
// Register action functionality
// TODO: This may not be needed depending on our implementation of hook_media_action [see #480166]
$items['media_upload_action'] = array(
'name' => 'Media Upload action handler',
'description' => t("Called to perform various actions such as attaching a file to a node"),
'kind' => 'action',
'types' => '*',
'callbacks' => array(
'action' => 'media_upload_action',
),
'fields' => array('attachments', 'filefield'),
);
return $items;
}
/**
* Implementation of callback media_upload_media_user_files_select().
*
* TODO: We'll need to investigate performance mechanisms (lazy loading etc.)
* rather than dumping ALL files in a single go.
*
* @param string $node_type
* @param string $field
* @param int $uid
*/
function media_upload_user_files_select($node_type, $field, $uid) {
$files = array();
$results = db_query('SELECT filepath, filename FROM {files} WHERE uid = %d', $uid);
while ($file = db_fetch_array($results)) {
$files[] = array(
'uri' => $file['filepath'],
'filename' => $file['filename'],
'meta' => '',
);
}
$return = array(
t('My files') => array(
t('Local') => media_resource_display_user_files_form($files, t('Your files')),
)
);
return $return;
}
/**
* Format Media Upload form
*
* @param string $node_type
* @param string $field
* @param string $file_extension
* @param string $uri
* @return array
* Return a form array.
*/
function media_upload_formatter_form($node_type, $field, $file_extension, $uri) {
if ($uri) {
$form['display'] = array(
'#type' => 'item',
'#value' => l($uri, $uri),
);
$form['list'] = array(
'#type' => 'checkbox',
'#title' => 'List file',
'#default_value' => TRUE,
);
}
return $form;
}
/**
* Implementation of registration media_upload_resource_add_file
*
* @param string $node_type
* drupal node type
* @param string $field
* field name that is being overridden
* @param int $uid
* user id
*/
function media_upload_resource_add_file($node_type, $field, $uid) {
return array(
t('Add files') => array(
t('New file') => media_resource_display_upload_form(),
)
);
}
/**
* Implementation of registration media_upload_resource_embed_file
*
* @param string $node_type
* @param string $field
* @param int $uid
*/
function media_upload_resource_embed_file($node_type, $field, $uid) {
return array(
t('Add files') => array(
t('Embeded file') => _media_upload_display_embed_form(),
)
);
}
/**
* Display the upload form for the tab
*
* @return array
* Form array containing a textarea
*/
function _media_upload_display_embed_form() {
$form['media_upload']['upload'] = array(
'#type' => 'textarea',
'#title' => t('Upload your file'),
);
return $form;
}
/**
* Implementation of hook_media_action
*
* TODO: Implement and document
*/
function media_upload_media_action(&$form, $form_state, $op = '') {
dsm("In the Media Upload action handler. Implement switch and carry out tasks.");
dsm($op);
dsm($form_state);
dsm($form);
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment