You are here

function delta_theme_overrides_form in Delta 6

Same name and namespace in other branches
  1. 7 delta.module \delta_theme_overrides_form()

Generate the override list page.

1 string reference to 'delta_theme_overrides_form'
delta_theme_overrides in ./delta.module
Menu callback for admin/build/delta/%.

File

./delta.module, line 246
The Delta Theme API is an advanced manipulation of the Theme Settings API to allow for customization/configuration of theme settings based on node types, context, or groups of paths.

Code

function delta_theme_overrides_form(&$form_state, $theme, $data) {

  // Build form tree
  $form = array(
    '#action' => url('admin/build/delta/settings/' . $theme),
    '#tree' => TRUE,
  );
  $form['theme'] = array(
    '#type' => 'hidden',
    '#value' => $theme,
  );

  //krumo($data);
  if (count($data) > 0) {
    foreach ($data as $k => $delta) {
      $key = 'delta_id_' . $k;
      $form[$key]['name'] = array(
        '#value' => $delta['name'],
      );

      /**
       * Build out the type of override(s) this is.
       * Possible values are node, context, path
       */
      $override_type = array();
      if (count(array_filter($delta['conditions']['nodes'])) > 0) {
        $override_type[] = 'Node';
      }
      if (count(array_filter($delta['conditions']['contexts'])) > 0) {
        $override_type[] = 'Context';
      }
      if ($delta['conditions']['paths']) {
        $override_type[] = 'Path';
      }
      $override_types = implode(', ', $override_type);

      //krumo($override_types);
      $form[$key]['types'] = array(
        '#value' => $override_types,
      );
      $form[$key]['did'] = array(
        '#type' => 'hidden',
        '#value' => $delta['did'],
      );
      $form[$key]['weight'] = array(
        '#type' => 'weight',
        '#default_value' => $delta['weight'],
        '#delta' => 100,
      );
      $theme_settings_templates = delta_get_theme_settings_templates($theme);
      $form[$key]['theme_settings_template'] = array(
        '#type' => 'select',
        '#options' => count($theme_settings_templates) > 0 ? $theme_settings_templates : array(
          '0' => '<' . t('none') . '>',
        ),
        '#default_value' => $delta['tid'],
      );
      $form[$key]['#info'] = 'delta_override';

      // operations
      $form[$key]['edit'] = array(
        '#value' => l(t('edit'), 'admin/build/delta/override/manage/' . $delta['did'] . '/edit'),
      );
      $form[$key]['delete'] = array(
        '#value' => l(t('delete'), 'admin/build/delta/override/manage/' . $delta['did'] . '/delete'),
      );
      $form[$key]['export'] = array(
        '#value' => l(t('export'), 'admin/build/delta/override/manage/' . $delta['did'] . '/export'),
      );
      $form[$key]['add_template'] = array(
        '#value' => l(t('add new template'), 'admin/build/delta/add-template/' . $theme, array(
          'attributes' => array(
            'class' => 'add-template',
            'id' => $delta['did'],
          ),
        )),
      );
    }
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save Changes'),
    );
  }
  return $form;
}