You are here

function zenophile_callback in Zenophile 6.2

Same name and namespace in other branches
  1. 6 zenophile.drush.inc \zenophile_callback()

Drush command callback.

1 string reference to 'zenophile_callback'
zenophile_drush_command in ./zenophile.drush.inc
Implementation of hook_drush_command().

File

./zenophile.drush.inc, line 59
Zenophile Drush commands.

Code

function zenophile_callback() {
  $args = func_get_args();
  $fake_form = array(
    'values' => array(
      'sysname' => $args[0],
      'description' => $args[1],
      'parent' => 'STARTERKIT',
      'friendly' => '',
      'layout' => 'fixed',
      'fresh' => TRUE,
      'site' => 'all',
      'sidebars_on' => FALSE,
      'sidebar-left' => '200',
      'sidebar-right' => '200',
      'page' => '960',
      'sidebar-pos' => 'normal',
    ),
  );
  foreach (array_keys($fake_form['values']) as $key) {
    $value = drush_get_option($key);
    if (in_array($key, array(
      'sidebar-left',
      'sidebar-right',
      'page',
      'sidebar-pos',
    ))) {
      $fake_form['values']['sidebars_on'] = TRUE;
    }
    if ($value !== NULL) {
      $fake_form['values'][$key] = stripslashes($value);
    }
  }
  drupal_execute('zenophile_create', $fake_form);

  // _drush_log_drupal_messages() does not log "status" messages, which is how
  // we try to tell the user that we were successful. So we'll log those
  // manually. First, save them in a var, because _drush_log_drupal_messages()'s
  // call to drupal_get_messages() is going to flush them.
  $messages = drupal_get_messages(NULL, FALSE);
  _drush_log_drupal_messages();
  if (isset($messages['status'])) {

    // There will probably never be more than one, but we'll iterate anyway.
    foreach ($messages['status'] as $msg) {
      drush_log(strip_tags($msg), 'success');
    }
  }
}