You are here

function nd_buildmodes_matrix_form in Node displays 6

Build modes matrix form.

1 string reference to 'nd_buildmodes_matrix_form'
nd_build_modes in includes/nd.buildmodes.inc
Build modes overview.

File

includes/nd.buildmodes.inc, line 61
Manage build modes.

Code

function nd_buildmodes_matrix_form() {
  drupal_add_js(drupal_get_path('module', 'nd') . '/js/nd_buildmodes.js');

  // Exclude build mode matrix.
  $exclude_build_modes = variable_get('nd_buildmodes_exclude', array());
  $build_modes = array(
    'nd_block_all' => array(
      'title' => t('Toggle all'),
    ),
  ) + nd_get_build_modes();
  $content_types = node_get_types();
  $form['#build_modes'] = $build_modes;
  $form['#content_types'] = $content_types;
  foreach ($content_types as $ckey => $type) {
    $row_exluded = variable_get('nd_contenttype_' . $ckey, FALSE);
    foreach ($build_modes as $bkey => $mode) {

      // We create 2 form keys here. The first one is the checkbox,
      // the second is a hidden value to store the default value in.
      $form['exclude'][$ckey][$ckey . '-' . $bkey] = array(
        '#type' => 'checkbox',
        '#attributes' => array(
          'class' => 'checkbox-instance',
        ),
      );
      $form['exclude'][$ckey][$ckey . '-' . $bkey . '-disabled'] = array(
        '#type' => 'value',
        '#value' => $exclude_build_modes[$ckey][$bkey],
      );
      if ($bkey == 'nd_block_all') {
        $form['exclude'][$ckey][$ckey . '-' . $bkey]['#attributes']['class'] .= ' block-all';
        $form['exclude'][$ckey][$ckey . '-' . $bkey]['#default_value'] = $row_exluded;
      }
      else {
        $form['exclude'][$ckey][$ckey . '-' . $bkey]['#default_value'] = $exclude_build_modes[$ckey][$bkey];
        if ($row_exluded) {
          $form['exclude'][$ckey][$ckey . '-' . $bkey]['#disabled'] = 'disabled';
        }
      }
    }
  }
  $form['exclude']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
    '#submit' => array(
      'nd_build_modes_matrix_submit',
    ),
  );
  return $form;
}