node_form_attachments.inc 1.7 KB

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