You are here

function zenophile_create in Zenophile 6

Same name and namespace in other branches
  1. 6.2 zenophile.module \zenophile_create()
  2. 7 zenophile.module \zenophile_create()

Form to create the subtheme. drupal_get_form() callback.

2 string references to 'zenophile_create'
zenophile_callback in ./zenophile.drush.inc
Drush command callback.
zenophile_menu in ./zenophile.module
Implementation of hook_menu().

File

./zenophile.module, line 32

Code

function zenophile_create() {

  // Check for Zen
  if (drupal_get_path('theme', 'STARTERKIT') === '') {
    drupal_set_message(t('The STARTERKIT theme could not be found. Please check that the <a href="!zen">Zen theme</a> is properly installed.'), array(
      '!zen' => 'http://drupal.org/project/zen',
    ), 'error');
  }
  else {

    // Create a list of Zen-based themes. This is… good enough.
    $zen_based = array();
    foreach (list_themes(TRUE) as $theme) {

      // Check for zen.css in the theme's stylesheet list
      if (in_array('zen.css', array_keys($theme->info['stylesheets']['all']))) {
        $zen_based[$theme->name] = t('@tname (@tsname)', array(
          '@tname' => $theme->info['name'],
          '@tsname' => $theme->name,
        ));
      }
    }
    return array(
      'parent' => array(
        '#title' => t('Starter theme'),
        '#type' => 'select',
        '#options' => $zen_based,
        '#default_value' => 'STARTERKIT',
        '#required' => TRUE,
      ),
      'sysname' => array(
        '#title' => t('System name'),
        '#description' => t('The machine-compatible name of your subtheme. This name should consist of only lowercase letters plus the underscore character.'),
        '#type' => 'textfield',
        '#required' => TRUE,
      ),
      'friendly' => array(
        '#title' => t('Human name'),
        '#description' => t('A human-friendly name for your subtheme. This name may contain uppercase letters, spaces, punctuation, etc. If left blank, the system name will also be used here.'),
        '#type' => 'textfield',
      ),
      'description' => array(
        '#title' => t('Description'),
        '#description' => t('A short description of this theme.'),
        '#type' => 'textfield',
        '#required' => TRUE,
      ),
      'layout' => array(
        '#title' => t('Layout type'),
        '#description' => t('A fixed layout will stay the same width, regardless of the user&rsquo;s browser window width. Any space beyond the width of the layout will be filled with blank space on either side of the layout, so that the layout is always centered in the browser window. A liquid layout will adjust its width depending on the width of the user&rsquo;s browser window width, so that the edges of the layout are always the same distance from the edges of the browser window (though this breaks when the browser window is made to be extremely narrow). If in doubt, you probably want to use a fixed layout.'),
        '#type' => 'radios',
        '#options' => array(
          'fixed' => t('Fixed'),
          'liquid' => t('Liquid'),
        ),
        '#default_value' => 'fixed',
        '#required' => TRUE,
      ),
      'site' => array(
        '#title' => t('Site directory'),
        '#description' => t('Which site directory would you like your new subtheme to be placed in? If in doubt, select <em>all</em>.'),
        '#type' => 'select',
        '#options' => _zenophile_find_sites(),
        '#default_value' => array(
          'all',
        ),
        '#required' => TRUE,
      ),
      'fresh' => array(
        '#title' => t('Create fresh CSS file'),
        '#description' => t('If checked, Zenophile will create a new empty CSS file and add it to the theme via its .info file. Some themers may prefer to start with a fresh empty CSS file rather than adapting the pre-created CSS file which will be copied over from the STARTERKIT directory.'),
        '#type' => 'checkbox',
        '#default_value' => TRUE,
      ),
      'submit' => array(
        '#type' => 'submit',
        '#value' => t('Submit'),
      ),
    );
  }
}