node_form_attachments.inc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @file
  4. */
  5. if (module_exists('upload')) {
  6. /**
  7. * Plugins are described by creating a $plugin array which will be used
  8. * by the system that includes this file.
  9. */
  10. $plugin = array(
  11. 'single' => TRUE,
  12. 'icon' => 'icon_node_form.png',
  13. 'title' => t('Node form file attachments'),
  14. 'description' => t('File attachments on the Node form.'),
  15. 'required context' => new ctools_context_required(t('Form'), 'node_form'),
  16. 'category' => t('Form'),
  17. );
  18. }
  19. function ctools_node_form_attachments_content_type_render($subtype, $conf, $panel_args, &$context) {
  20. $block = new stdClass();
  21. $block->module = 'node_form';
  22. $block->title = t('Attach files');
  23. $block->delta = 'url-path-options';
  24. if (isset($context->form)) {
  25. if (isset($context->form['attachments'])) {
  26. $block->content = $context->form['attachments'];
  27. if (isset($block->content['attachments']['#group'])) {
  28. unset($block->content['attachments']['#pre_render']);
  29. unset($block->content['attachments']['#theme_wrappers']);
  30. $block->content['attachments']['#type'] = '';
  31. }
  32. // Set access to false on the original rather than removing so that
  33. // vertical tabs doesn't clone it. I think this is due to references.
  34. $context->form['attachments']['#access'] = FALSE;
  35. }
  36. }
  37. else {
  38. $block->content = t('Attach files.');
  39. }
  40. return $block;
  41. }
  42. function ctools_node_form_attachments_content_type_admin_title($subtype, $conf, $context) {
  43. return t('"@s" node form attach files', array('@s' => $context->identifier));
  44. }
  45. function ctools_node_form_attachments_content_type_edit_form($form, &$form_state) {
  46. // Provide a blank form so we have a place to have context setting.
  47. return $form;
  48. }