node_form_metatags.inc 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @file
  4. * Display the node form's Metatag fieldset in a pane.
  5. */
  6. $plugin = array(
  7. 'single' => TRUE,
  8. 'title' => t('Node form meta tags'),
  9. 'icon' => 'icon_node_form.png',
  10. 'description' => t('Meta tags on the node form.'),
  11. 'required context' => new ctools_context_required(t('Form'), 'node_form'),
  12. 'category' => t('Form'),
  13. );
  14. /**
  15. * CTools content type callback to output this pane.
  16. */
  17. function metatag_node_form_metatags_content_type_render($subtype, $conf, $panel_args, &$context) {
  18. $block = new stdClass();
  19. $block->title = t('Meta tags');
  20. $block->module = 'metatag';
  21. $block->delta = 'metatag';
  22. if (isset($context->form)) {
  23. if (isset($context->form['metatags'])) {
  24. $block->content['metatags'] = $context->form['metatags'];
  25. unset($block->content['metatags']['#pre_render']);
  26. unset($block->content['metatags']['#theme_wrappers']);
  27. $block->content['metatags']['#type'] = '';
  28. // Set access to false on the original rather than removing so that
  29. // vertical tabs doesn't clone it. I think this is due to references.
  30. $context->form['metatags']['#access'] = FALSE;
  31. }
  32. }
  33. else {
  34. $block->content = t('Meta tags options.');
  35. }
  36. return $block;
  37. }
  38. /**
  39. * CTools content type callback to get the title of this pane.
  40. */
  41. function metatag_node_form_metatags_content_type_admin_title($subtype, $conf, $context) {
  42. if (isset($context->identifier)) {
  43. $message = t('"@s" node form meta tags', array('@s' => $context->identifier));
  44. }
  45. else {
  46. $message = t('Node form meta tags');
  47. }
  48. return $message;
  49. }
  50. /**
  51. * CTools content type callback to display an edit form for this pane.
  52. */
  53. function metatag_node_form_metatags_content_type_edit_form($form, &$form_state) {
  54. // Provide a blank form so we have a place to have context setting.
  55. return $form;
  56. }
  57. /**
  58. * CTools content type callback to provide extra information about this pane.
  59. */
  60. function metatag_node_form_metatags_content_type_admin_info($type, $subtype, $conf, $context = NULL) {
  61. $output = new stdClass();
  62. $output->title = t('Metatag form');
  63. $output->content = t('Shows the meta tag fields on this node form if the user has the appropriate permissions.');
  64. return $output;
  65. }