eads@1: 'Drag and Drop Library', eads@1: 'page callback' => 'dnd_admin', eads@1: 'description' => 'Configure drag-and-drop enabled textareas.', eads@1: 'access arguments' => array('administer dnd'), eads@1: 'file' => 'dnd.admin.inc', eads@1: ); eads@1: return $items; eads@1: } eads@1: eads@1: /** eads@1: * Implementation of hook_perm(). eads@1: */ eads@1: function dnd_perm() { eads@1: return array('administer dnd'); eads@1: } eads@2: eads@2: /** eads@2: * Implementation of hook_theme(). eads@2: */ eads@2: function dnd_theme() { eads@2: return array( eads@28: 'dnd_library' => array('arguments' => array('library' => NULL, 'library_id' => NULL), 'template' => 'dnd-library'), eads@2: ); eads@2: } eads@2: eads@2: eads@2: /** eads@2: * Implementation of hook_elements(). eads@2: * eads@2: * Overload textareas. eads@2: */ eads@2: function dnd_elements() { eads@2: $type = array(); eads@2: $type['textarea'] = array( eads@2: '#input' => TRUE, eads@2: '#cols' => 60, eads@2: '#rows' => 5, eads@2: '#resizable' => TRUE, eads@2: '#dnd-enabled' => FALSE, eads@2: '#dnd-settings' => NULL, eads@2: '#process' => array('form_expand_ahah', 'dnd_process_textarea'), eads@2: ); eads@2: return $type; eads@2: } eads@2: eads@2: /** eads@2: * Settings array: eads@21: * What should it take, if anything? Probably a source * maybe editor specific configuration shit? eads@2: * eads@2: * - source for library json/ajax shit eads@2: * - target selector eads@2: * - item selector eads@2: * eads@2: * perhaps like so: eads@2: * eads@2: * global => eads@2: * droppable targets eads@2: * library source for textarea eads@2: * eads@2: * tinymce/othereditor => eads@2: * target selector logic eads@2: * configuration options eads@2: * callback should be smart about attachment and detachment eads@2: */ eads@21: function dnd_process_textarea($element, $edit, $form_state, $form) { eads@2: if ($element['#dnd-enabled']) { eads@20: eads@2: $settings = array(); eads@2: eads@18: // We take a string or an object or an array eads@2: if (is_string($element['#dnd-settings'])) { eads@2: // @TODO load settings eads@2: } eads@2: else if (is_object($element['#dnd-settings'])) { eads@2: $settings = (array) $element['#dnd-settings']; eads@2: } eads@2: else if (is_array($element['#dnd-settings'])) { eads@2: $settings = $element['#dnd-settings']; eads@2: } eads@2: eads@2: // Set some important defaults eads@28: if (function_exists($settings['callback']) && ($library = $settings['callback']($element))) { eads@28: $settings = array('library_id' => $element['#id'] . DND_ID_SUFFIX) + $settings; eads@28: unset($settings['callback']); eads@2: eads@28: // BeautyTips eads@28: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/bt/other_libs/excanvas_0002/excanvas-compressed.js'); eads@28: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/bt/other_libs/jquery.hoverIntent.minified.js'); eads@28: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/bt/jquery.bt.js'); eads@2: eads@28: // Dependencies eads@28: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/jquery.url.packed.js'); eads@28: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/jquery.fieldselection.js'); eads@28: drupal_add_js('misc/jquery.form.js'); eads@28: eads@28: // Drag and drop eads@28: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/jquery.draganddrop.js'); eads@28: drupal_add_js(drupal_get_path('module', 'dnd') .'/js/dnd-library.js'); eads@28: eads@28: drupal_add_js(array( eads@28: 'dndEnabledLibraries' => array($element['#id'] => $settings), eads@28: ), 'setting'); eads@28: eads@28: // Store editor representations in Drupal setting eads@28: drupal_add_js(array( eads@28: 'dndEditorRepresentations' => $library['editor_representations'], eads@28: 'dndLibraryPreviews' => $library['library_previews'], eads@28: ), 'setting'); eads@28: eads@28: $element['#suffix'] = theme('dnd_library', $library['library'], $settings['library_id']) . $element['#suffix']; eads@28: } eads@28: eads@2: } eads@2: return $element; eads@2: } eads@2: eads@28: function template_preprocess_dnd_library($library) {}