You are here

function bueditor_editor_theme in BUEditor 7

Same name and namespace in other branches
  1. 6.2 admin/bueditor.admin.inc \bueditor_editor_theme()
  2. 6 bueditor.admin.inc \bueditor_editor_theme()

Editor form theming.

1 string reference to 'bueditor_editor_theme'
bueditor_theme in ./bueditor.module
Implements hook_theme().

File

admin/bueditor.admin.inc, line 330

Code

function bueditor_editor_theme($variables) {
  $form = $variables['form'];
  $path = drupal_get_path('module', 'bueditor');
  $eid = $form['editor']['eid']['#value'];
  $header = array(
    array(
      'data' => t('Title'),
      'class' => array(
        'th-title',
      ),
    ),
    array(
      'data' => t('Content'),
      'class' => array(
        'th-content',
      ),
    ),
    array(
      'data' => t('Icon'),
      'class' => array(
        'th-icon',
      ),
    ),
    array(
      'data' => t('Key'),
      'class' => array(
        'th-key',
      ),
    ),
    array(
      'data' => t('Weight'),
      'class' => array(
        'th-weight',
      ),
    ),
    array(
      'data' => '',
      'class' => 'select-all',
    ),
  );
  $rows = array();
  foreach (element_children($form['buttons']) as $bid) {
    $new = !is_numeric($bid);
    $cells = array();
    $cells[] = drupal_render($form['buttons'][$bid]['title']);
    $cells[] = drupal_render($form['buttons'][$bid]['content']);
    $cells[] = drupal_render($form['buttons'][$bid]['icon']);
    $cells[] = drupal_render($form['buttons'][$bid]['accesskey']);
    $cells[] = drupal_render($form['buttons'][$bid]['weight']);
    $cells[] = $new ? '<a>new</a>' : drupal_render($form['checks'][$bid]);
    $row = array(
      'data' => $cells,
      'class' => array(
        'draggable',
      ),
    );
    if ($new) {
      $row['class'][] = 'new-button';
    }
    $rows[] = $row;
  }

  //set title
  if ($form['editor']['name']['#value']) {
    drupal_set_title(t('Settings for the editor @name', array(
      '@name' => $form['editor']['name']['#value'],
    )));
  }
  $name = theme('fieldset', array(
    'element' => array(
      '#title' => t('Editor name'),
      '#children' => drupal_render($form['editor']['name']),
      '#attributes' => array(),
    ),
  ));
  $visibility = theme('fieldset', array(
    'element' => array(
      '#title' => t('Visibility settings'),
      '#children' => drupal_render($form['editor']['pages']) . drupal_render($form['editor']['excludes']),
      '#attributes' => array(),
    ),
  ));
  $paths = theme('fieldset', array(
    'element' => array(
      '#title' => t('Editor paths'),
      '#children' => drupal_render($form['editor']['iconpath']) . drupal_render($form['editor']['spriteon']) . drupal_render($form['editor']['librarypath']),
      '#attributes' => array(),
    ),
  ));
  $import = $eid ? theme('fieldset', array(
    'element' => array(
      '#title' => t('Import Buttons'),
      '#children' => t('<em>You can either upload a CSV file exported from BUEditor 6.x-1.x or earlier</em> !csvfield <em>OR paste the editor code containing the buttons</em> !codefield', array(
        '!csvfield' => drupal_render($form['importcsv']),
        '!codefield' => drupal_render($form['importcode']),
      )) . drupal_render($form['import']),
      '#attributes' => array(),
    ),
  )) : '';
  $buttons = theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'attributes' => array(
      'class' => array(
        'button-table',
      ),
      'id' => 'button-table',
    ),
  ));
  $selaction = $eid ? '<div id="sel-action-wrapper">' . drupal_render($form['selaction']) . drupal_render($form['copyto']) . drupal_render($form['go']) . '</div>' : '';
  $timer = timer_read('page');
  $demo = '';
  if ($eid && !isset($_GET['nodemo']) && bueditor_settle($eid)) {
    $set['BUE']['preset']['edit-demo-value'] = "e{$eid}";
    $demo = drupal_render($form['demo']);
    $set['BUE']['demotime'] = round(timer_read('page') - $timer);
  }
  $set['BUE']['iconpath'] = bueditor_path_tr($form['editor']['iconpath']['#value']);
  $set['BUE']['iconlist'] = bueditor_icons($set['BUE']['iconpath']);
  $output = theme('vertical_tabs', array(
    'element' => array(
      '#children' => $name . $visibility . $paths . $import,
    ),
  ));
  $output .= '<h2 class="title">' . t('Buttons') . '</h2>' . $buttons . $selaction . drupal_render($form['submit']);
  $output .= drupal_render_children($form) . $demo;
  drupal_add_js('misc/tableselect.js');
  drupal_add_css($path . '/admin/bueditor.edit.css');
  drupal_add_js($path . '/admin/bueditor.edit.js');
  drupal_add_js($set, 'setting');
  drupal_add_tabledrag('button-table', 'order', 'sibling', 'input-weight');
  return $output;
}