Commit 55a3ab29 authored by Jon Stacey's avatar Jon Stacey

Some blind styling cleanup in preparation for work.

parent e31059e9
......@@ -2,9 +2,10 @@
July 2009
---------
* Drupal 7 compatability
* Drupal 7 compatability (jmstacey)
* Update .info files.
* Added necessary files to new registry.
* Removed 'file' keys from hook_menu().
* Global media settings page fixed.
* Code styling cleanup (jmstacey).
* Untested rough sync up with D6 branch (jmstacey).
\ No newline at end of file
<?php
// $Id$
// $Id$
/**
* @file
*
* Install, update and uninstall functions for the Media module.
*/
\ No newline at end of file
/**
* @file
*
* Install, update and uninstall functions for the Media module.
*/
\ No newline at end of file
// $Id$
/**
* @file
* @file
* This file handles the JS for Media Module functions
*/
/**
* This handles the activation of drawers on the media browser form
* @TODO make this a drupal behavior
*/
$(document).ready( function () {
/**
* This handles the activation of drawers on the media browser form
* @TODO make this a drupal behavior
*/
$(document).ready( function () {
// hide the display information on page load
$('.media.browser.display').each(function() {
$(this).hide();
});
// Activate drawers when the page loads
// Activate drawers when the page loads
$('.media.browser .ui-tabs-panel .drawers .item-list li.first').addClass('active');
// Activate displays when the page loads
// Activate displays when the page loads
$('.media.browser .ui-tabs-panel .display.first').addClass('active').show();
// now we need to bind click functionality on drawers to display
$('.media.browser .ui-tabs-panel .drawers .item-list ul li, .drawers li a').bind('click', function () {
// get the href id that we want to display
// is this an a element?
var display_id = $(this).attr('href');
if (display_id == undefined) {
var display_id = $(this).children('a').attr('href');
}
// we need to get the container that this drawer is in
var parent = $(this).parents('.ui-tabs-panel').attr('id');
// hide current active display
$('#'+parent+' .display.active').removeClass('active').hide();
// set any drawers to not active
$('#'+parent+' .drawers li.active').removeClass('active');
// make this drawer active
$(this).addClass('active');
// make the correct display active
$(display_id).addClass('active').show();
});
});
/**
* we need to hide any form elements that were replaced by the media browser form
* activate the add button, and hide the browser
*/
$(document).ready(function () {
$('.media.replace').hide();
$('.media.browser.activation').each(function () {
$(this).next('.media.browser').hide();
$(this).click(function () {
$(this).next('.media.browser').slideDown('slow');
$(this).slideUp();
});
});
});
/**
* This handles passing the current file data from the media browser
* to the formater function and returns the correct form elements
*/
// now we need to bind click functionality on drawers to display
$('.media.browser .ui-tabs-panel .drawers .item-list ul li, .drawers li a').bind('click', function () {
// get the href id that we want to display
// is this an a element?
var display_id = $(this).attr('href');
if (display_id == undefined) {
var display_id = $(this).children('a').attr('href');
}
// we need to get the container that this drawer is in
var parent = $(this).parents('.ui-tabs-panel').attr('id');
// hide current active display
$('#'+parent+' .display.active').removeClass('active').hide();
// set any drawers to not active
$('#'+parent+' .drawers li.active').removeClass('active');
// make this drawer active
$(this).addClass('active');
// make the correct display active
$(display_id).addClass('active').show();
});
});
/**
* we need to hide any form elements that were replaced by the media browser form
* activate the add button, and hide the browser
*/
$(document).ready(function () {
});
\ No newline at end of file
$('.media.replace').hide();
$('.media.browser.activation').each(function () {
$(this).next('.media.browser').hide();
$(this).click(function () {
$(this).next('.media.browser').slideDown('slow');
$(this).slideUp();
});
});
});
/**
* This handles passing the current file data from the media browser
* to the formater function and returns the correct form elements
*/
$(document).ready(function () { });
\ No newline at end of file
This diff is collapsed.
......@@ -27,38 +27,40 @@
function media_ahah_formatter_load() { //$registration_id, $node_type, $field, $uri = NULL, $file_extension = NULL) {
// The form is generated in an include file which we need to include manually.
include_once 'modules/node/node.pages.inc';
// We're starting in step #3, preparing for #4.
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$form_build_id = $_POST['form_build_id'];
// Step #4.
$form = form_get_cache($form_build_id, $form_state);
// Preparing for #5.
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
$form['#programmed'] = $form['#redirect'] = FALSE;
// Step #5.
drupal_process_form($form_id, $form, $form_state);
// Step #6 and #7 and #8.
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
// Do whatever we need here for Step #9.
// ...
drupal_set_message('media_ahah_formatter_load can add anything here (if necessary).');
// Step #10: Output any drupal messages and the new form.
$media_tabs = $form[$field]['media']['media_tabs'];
$output = theme('status_messages') . drupal_render($media_tabs);
$output = theme('status_messages') . drupal_render($media_tabs);
// Ensure any changes to Drupal.settings js are preserved.
$javascript = drupal_add_js(NULL, NULL, 'header');
// Final rendering callback.
drupal_json(array(
'status' => TRUE,
'data' => $output,
'status' => TRUE,
'data' => $output,
'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
));
}
......@@ -69,38 +71,40 @@ function media_ahah_formatter_load() { //$registration_id, $node_type, $field, $
function media_ahah_metadata_ahah() {
// The form is generated in an include file which we need to include manually.
include_once 'modules/node/node.pages.inc';
// We're starting in step #3, preparing for #4.
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$form_state = array('storage' => NULL, 'submitted' => FALSE);
$form_build_id = $_POST['form_build_id'];
// Step #4.
$form = form_get_cache($form_build_id, $form_state);
// Preparing for #5.
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
$args = $form['#parameters'];
$form_id = array_shift($args);
$form_state['post'] = $form['#post'] = $_POST;
$form['#programmed'] = $form['#redirect'] = FALSE;
// Step #5.
drupal_process_form($form_id, $form, $form_state);
// Step #6 and #7 and #8.
$form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
// Do whatever we need here for Step #9.
// ...
drupal_set_message('final submission: media_ahah_metadata_ahah can do something here, maybe display a new add file form?');
// Step #10: Output any drupal messages and the new form.
$media_tabs = $form[$field]['media']['media_tabs'];
$output = theme('status_messages') . drupal_render($media_tabs);
$output = theme('status_messages') . drupal_render($media_tabs);
// Ensure any changes to Drupal.settings js are preserved.
$javascript = drupal_add_js(NULL, NULL, 'header');
// Final rendering callback.
drupal_json(array(
'status' => TRUE,
'data' => $output,
'status' => TRUE,
'data' => $output,
'settings' => call_user_func_array('array_merge_recursive', $javascript['setting']),
));
}
\ No newline at end of file
......@@ -7,10 +7,10 @@
*/
/**
* Returns the metadata keys associated with a file stream mimetype.
* Returns the metadata keys associated with a file stream MIME type.
*
* Defines hook_media_metadata_keys. All implementing modules will be invoked
* with the MIME type abd a list of keys to be collected and saved will be built.
* with the MIME type and a list of keys to be collected and saved will be built.
*
* @param string $mimetype
* The file mimetype to return the keys. If '*' is passed, then only the
......@@ -28,8 +28,8 @@ function media_metadata_keys($mimetype = '*', $exclusive = FALSE, $reset = FALSE
// Build our static cache.
if (is_null($keys)) {
$keys = array();
// Collect all metadata keys for the wildcard/all '*' mimetype.
$keys = array();
$keys['*'] = module_invoke_all('media_metadata_keys', '*');
}
......@@ -60,10 +60,12 @@ function media_metadata_keys($mimetype = '*', $exclusive = FALSE, $reset = FALSE
*/
function media_metadata_form($form_state, $mimetype = '*') {
$form = module_invoke_all('media_metadata_form', $form_state, $mimetype);
$form['mimetype'] = array(
'#type' => 'value',
'#type' => 'value',
'#value' => $mimetype,
);
$form['#submit'] = array('media_metadata_form_submit');
}
......@@ -79,8 +81,9 @@ function media_metadata_form($form_state, $mimetype = '*') {
*/
function media_metadata_form_submit($form, &$form_state) {
$mimetype = $form_state['values']['mimetype'];
$keys = media_metadata_keys($mimetype);
$values = array();
$keys = media_metadata_keys($mimetype);
$values = array();
foreach ($keys as $key) {
$values[$key] = $form_state['values'][$key];
}
......
......@@ -18,35 +18,35 @@
*/
function media_settings_content_type(&$form, $type_name = NULL) {
$form['media'] = array(
'#type' => 'fieldset',
'#title' => t('Media settings'),
'#collapsible' => 'true',
'#collapsed' => 'true',
'#type' => 'fieldset',
'#title' => t('Media settings'),
'#collapsible' => 'true',
'#collapsed' => 'true',
);
$type = _media_content_field_types($type_name);
// Master settings override.
$form['media']['media_'. $type_name .'_override'] = array(
'#title' => t($type["name"] .' overrides default values'),
'#type' => 'checkbox',
'#description' => t('Override the default settings for this content type. The options below will only be used if this box is checked.'),
'#default_value' => variable_get('media_'. $type_name .'_override', NULL),
'#title' => t($type["name"] .' overrides default values'),
'#type' => 'checkbox',
'#description' => t('Override the default settings for this content type. The options below will only be used if this box is checked.'),
'#default_value' => variable_get('media_'. $type_name .'_override', NULL),
);
$form['media']['media_'. $type_name .'_enabled'] = array(
'#title' => t('Enable Media resource browser'),
'#type' => 'checkbox',
'#description' => t('Enable the Media resource browser for this node type.'),
'#default_value' => variable_get('media_'. $type_name .'_enabled', NULL),
'#title' => t('Enable Media resource browser'),
'#type' => 'checkbox',
'#description' => t('Enable the Media resource browser for this node type.'),
'#default_value' => variable_get('media_'. $type_name .'_enabled', NULL),
);
// Extract the fields for this node type
foreach ((array)$type['fields'] as $field_name => $field) {
// Create the field identifier
$form['media'][$field['field_name']] = array(
'#type' => 'fieldset',
'#title' => t('Field name: !name', array('!name' => $field['widget']['label'])),
'#collapsible' => 'true',
'#type' => 'fieldset',
'#title' => t('Field name: !name', array('!name' => $field['widget']['label'])),
'#collapsible' => 'true',
);
// Build a form for each type of module that we have
......@@ -54,15 +54,17 @@ function media_settings_content_type(&$form, $type_name = NULL) {
// Get all the kinds that match this field
if ($registrations = media_get_fields($field['type'], $kind)) {
$options = array();
foreach ($registrations as $id => $registration) {
$options[$field['field_name'] .'--'. $id] = $registration['name'] .': '. $registration['description'];
}
$form['media'][$field['field_name']]['media_'. $type_name .'_'. $field['field_name'] .'_'. $kind] = array(
'#title' => t('Enable !kind options for this field', array('!kind' => $kind)),
'#description' => t('Choose which !kind options you would like to have enabled on this field', array('!kind' => $kind)),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => variable_get('media_'. $type_name .'_'. $field['field_name'] .'_'. $kind, array()),
'#title' => t('Enable !kind options for this field', array('!kind' => $kind)),
'#description' => t('Choose which !kind options you would like to have enabled on this field', array('!kind' => $kind)),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => variable_get('media_'. $type_name .'_'. $field['field_name'] .'_'. $kind, array()),
);
}
}
......@@ -89,10 +91,10 @@ function media_settings_global($form) {
$settings_form = array();
$settings_form['media_global_enabled'] = array(
'#title' => t('Media resource browser'),
'#type' => 'checkbox',
'#description' => t('Enable or Disable the Media resource browser for all types, unless specifically set for a given type.'),
'#default_value' => variable_get('media_global_enabled', 1),
'#title' => t('Media resource browser'),
'#type' => 'checkbox',
'#description' => t('Enable or Disable the Media resource browser for all types, unless specifically set for a given type.'),
'#default_value' => variable_get('media_global_enabled', 1),
);
return system_settings_form($settings_form);
......
......@@ -18,6 +18,7 @@
function theme_media_file_browser($element) {
// Add the CSS for our display.
$output = '<div class="media browser">'. $element .'</div>';
return $output;
}
......@@ -41,7 +42,7 @@ function theme_media_file_list($element) {
* @return string
*/
function theme_media_browser_pane($form) {
$output = array();
$output = array();
// render the drawers
$output[] = '<div'. drupal_attributes($form['#attributes']) .'>';
......
......@@ -25,7 +25,7 @@ function media_upload_media_register() {
'types' => '*',
'description' => t("Displays all of current user's files."),
'callbacks' => array(
'resource' => 'media_upload_user_files_select',
'resource' => 'media_upload_user_files_select',
),
'fields' => array('attachments', 'filefield'),
);
......@@ -98,15 +98,15 @@ function media_upload_user_files_select($node_type, $field, $uid) {
while ($file = db_fetch_array($results)) {
$files[] = array(
'uri' => $file['filepath'],
'uri' => $file['filepath'],
'filename' => $file['filename'],
'meta' => '',
'meta' => '',
);
}
$return = array(
t('My files') => array(
t('Local') => media_resource_display_user_files_form($files, t('Your files')),
t('Local') => media_resource_display_user_files_form($files, t('Your files')),
)
);
......@@ -126,12 +126,12 @@ function media_upload_user_files_select($node_type, $field, $uid) {
function media_upload_formatter_form($node_type, $field, $file_extension, $uri) {
if ($uri) {
$form['display'] = array(
'#type' => 'item',
'#type' => 'item',
'#value' => l($uri, $uri),
);
$form['list'] = array(
'#type' => 'checkbox',
'#title' => 'List file',
'#type' => 'checkbox',
'#title' => 'List file',
'#default_value' => TRUE,
);
}
......@@ -152,7 +152,7 @@ function media_upload_formatter_form($node_type, $field, $file_extension, $uri)
function media_upload_resource_add_file($node_type, $field, $uid) {
return array(
t('Add files') => array(
t('New file') => media_resource_display_upload_form(),
t('New file') => media_resource_display_upload_form(),
)
);
}
......@@ -180,9 +180,10 @@ function media_upload_resource_embed_file($node_type, $field, $uid) {
*/
function _media_upload_display_embed_form() {
$form['media_upload']['upload'] = array(
'#type' => 'textarea',
'#type' => 'textarea',
'#title' => t('Upload your file'),
);
return $form;
}
......@@ -196,5 +197,4 @@ function media_upload_media_action(&$form, $form_state, $op = '') {
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