nodeformcols.inc 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. /**
  3. * @file
  4. * Renders the nodeformcols form in a panel pane. The entire panel is inside the
  5. * <form> tag. Most of the code is from the CTools form.inc content type.
  6. */
  7. /**
  8. * Callback function to supply a list of content types.
  9. */
  10. function nodeformcols_nodeformcols_ctools_content_types() {
  11. return array(
  12. // only provides a single content type
  13. 'single' => TRUE,
  14. 'render last' => TRUE,
  15. 'title' => t('Nodeformcols form'),
  16. 'icon' => 'icon_form.png',
  17. 'description' => t('A complete nodeformcols node form.'),
  18. 'required context' => new ctools_context_required(t('Form'), 'form'),
  19. 'category' => t('Form'),
  20. );
  21. }
  22. /**
  23. * Output function for the 'nodeformcols' content type. Outputs a node form
  24. * as displayed by the nodeformcols module.
  25. */
  26. function nodeformcols_nodeformcols_content_type_render($subtype, $conf, $panel_args, &$context) {
  27. $block = new stdClass();
  28. $block->module = 'nodeformcols';
  29. $context->form['#theme'] = 'node_form';
  30. unset($context->form['#theme_used']);
  31. if (isset($context->form)) {
  32. $block->title = $context->form_title;
  33. if (!empty($context->form_id)) {
  34. // If this is a form, drupal_render it.
  35. $block->content = drupal_render($context->form);
  36. }
  37. else {
  38. // Otherwise just spit back what we were given. This is probably an
  39. // error message or something.
  40. $block->content = $context->form;
  41. }
  42. $block->delta = $context->form_id;
  43. }
  44. else {
  45. $block->title = t('Form');
  46. $block->content = t('Form goes here.');
  47. $block->delta = 'unknown';
  48. }
  49. return $block;
  50. }
  51. /**
  52. * Callback to provide the administrative title of the custom content.
  53. */
  54. function nodeformcols_nodeformcols_content_type_admin_title($subtype, $conf, $context) {
  55. return t('Nodeformcols node form');
  56. }
  57. /**
  58. * Callback to provide administrative info.
  59. */
  60. function nodeformcols_nodeformcols_content_type_admin_info($subtype, $conf) {
  61. $block = new stdClass();
  62. $block->title = t('Affected forms');
  63. $types = node_type_get_types();
  64. $forms = array();
  65. foreach ($types as $type => $description) {
  66. if (variable_get('nodeformscols_field_placements_' . $type . '_default', FALSE)) {
  67. $forms[] = $description->name;
  68. }
  69. }
  70. if (!empty($forms)) {
  71. $block->content = theme('item_list', array('items' => $forms));
  72. }
  73. else {
  74. $block->content = '<p>' . t('No forms are using customized nodeformcols settings.') . '</p>';
  75. }
  76. return $block;
  77. }
  78. function nodeformcols_nodeformcols_content_type_edit_form(&$form, &$form_state) {
  79. // provide a blank form so we have a place to add settings widgets
  80. }