You are here

function sweaver_frontend in Sweaver 6

Same name and namespace in other branches
  1. 7 sweaver.module \sweaver_frontend()

Rock 'n' roll: the sweaver editor.

1 string reference to 'sweaver_frontend'
sweaver_footer in ./sweaver.module
Implementation of hook_footer().

File

./sweaver.module, line 495
Sweaver functions.

Code

function sweaver_frontend(&$form_state) {
  $form = array();
  $weight = 1;
  $form['#plugins'] = array();
  $form['#theme'] = 'sweaver_plugin';
  $form['#attributes'] = array(
    'enctype' => 'multipart/form-data',
  );
  $plugins_order = variable_get('sweaver_plugins_weight', array());
  $sweaver = Sweaver::get_instance();
  foreach ($sweaver
    ->get_plugins_registry(TRUE) as $plugin_name => $plugin) {
    $sweaver_plugin = $sweaver
      ->get_plugin($plugin_name);

    // Calculate weight.
    $default_weight = isset($plugins_order[$plugin_name]) ? $plugins_order[$plugin_name] : $weight++;
    if ($plugin_name == 'sweaver_plugin') {
      $default_weight = -100;
    }
    $form['#plugins_order'][$plugin_name] = $default_weight;
    $form['#plugins_full'][$plugin_name] = $plugin;

    // Form.
    $plugin_form = $sweaver_plugin
      ->sweaver_form();
    if (!empty($plugin_form)) {
      $form[$plugin['name']]['form'] = $plugin_form;
      if (isset($plugin['handler']['tab'])) {
        $form[$plugin['name']]['#tab_name'] = isset($plugin['handler']['tab']) ? $plugin['handler']['tab'] : drupal_ucfirst($plugin_name);
        $form[$plugin['name']]['#tab_description'] = isset($plugin['handler']['tab_description']) ? $plugin['handler']['tab_description'] : '';
      }
    }
  }

  // Editor messages.
  $messages = sweaver_session();
  sweaver_session(NULL, 'sweaver_editor_messages', TRUE);
  $form['sweaver-editor-messages'] = array(
    '#type' => 'hidden',
    '#value' => trim($messages),
  );
  $form['#current_theme'] = $sweaver
    ->get_theme_key();
  $form['destination'] = array(
    '#type' => 'hidden',
    '#value' => $_GET['q'],
  );
  return $form;
}