Projet

Général

Profil

Paste
Télécharger (1,75 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / plugins / content_types / form / form.inc @ 1e39edcb

1
<?php
2

    
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
  // only provides a single content type
9
  'single' => TRUE,
10
  'render last' => TRUE,
11
  'title' => t('General form'),
12
  'icon' => 'icon_form.png',
13
  'description' => t('Everything in the form that is not displayed by other content.'),
14
  'required context' => new ctools_context_required(t('Form'), 'form'),
15
  'category' => t('Form'),
16
);
17

    
18
/**
19
 * Output function for the 'node' content type. Outputs a node
20
 * based on the module and delta supplied in the configuration.
21
 */
22
function ctools_form_content_type_render($subtype, $conf, $panel_args, &$context) {
23
  $block = new stdClass();
24
  $block->module = 'form';
25

    
26
  if (isset($context->form)) {
27
    if (isset($context->form['#pre_render'])) {
28
      foreach ($context->form['#pre_render'] as $function) {
29
        if (function_exists($function)) {
30
          $context->form = $function($context->form);
31
        }
32
      }
33
      unset($context->form['#pre_render']);
34
    }
35

    
36
    $block->title = $context->form_title;
37
    $block->content = array();
38
    foreach (element_children($context->form) as $element) {
39
      $block->content[$element] = $context->form[$element];
40
      unset($context->form[$element]);
41
    }
42

    
43
    $block->delta = $context->form_id;
44
  }
45
  else {
46
    $block->title = t('Form');
47
    $block->content = t('Form goes here.');
48
    $block->delta   = 'unknown';
49
  }
50

    
51
  return $block;
52
}
53

    
54
function ctools_form_content_type_admin_title($subtype, $conf, $context) {
55
  return t('"@s" base form', array('@s' => $context->identifier));
56
}
57

    
58
function ctools_form_content_type_edit_form($form, &$form_state) {
59
  // provide a blank form so we have a place to override title
60
  // and stuff.
61
  return $form;
62
}