You are here

public function sweaver_plugin_styles::sweaver_menu_callback in Sweaver 7

Same name and namespace in other branches
  1. 6 plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc \sweaver_plugin_styles::sweaver_menu_callback()

Menu callback

Overrides sweaver_plugin::sweaver_menu_callback

File

plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc, line 544
Styles plugin.

Class

sweaver_plugin_styles

Code

public function sweaver_menu_callback() {
  $form = array();

  // Settings.
  $form['sweaver_styles_delete_tab'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show delete tab'),
    '#description' => t('Show the delete tab in the frontend editor.'),
    '#default_value' => variable_get('sweaver_styles_delete_tab', FALSE),
  );
  $form['sweaver_styles_autosave'] = array(
    '#title' => t('Autosave'),
    '#type' => 'select',
    '#options' => array(
      0 => t('Never'),
      5 => t('Every 5 seconds'),
      10 => t('Every 10 seconds'),
      15 => t('Every 15 seconds'),
      30 => t('Every 30 seconds'),
      45 => t('Every 45 seconds'),
      60 => t('Every minute'),
      120 => t('Every two minutes'),
    ),
    '#default_value' => variable_get('sweaver_styles_autosave', 0),
    '#description' => t('Check for changes on your style and custom CSS every x seconds. If a change has been identified, sweaver will save those settings in a temporary cache table with AJAX. So leaving a page - or even worse, a browser crash - will make sure you keep your current configuration.'),
  );
  $form = system_settings_form($form);
  $form['table_explenation'] = array(
    '#markup' => 'The following table list all styles defined in Sweaver. You have the possibility to enable multiple styles, it is very usefull if you want to use different styles for different pages (see tab context in the advanced plugin. The style set as default is the last one modified and will be load next time you try you launch sweaver editor.',
  );

  // Styles list.
  $rows = array();
  $styles = db_query("SELECT ssd.*, ss.active FROM {sweaver_style_draft} ssd LEFT JOIN {sweaver_style} ss on ss.style_id = ssd.style_id ORDER BY ssd.style ASC, ssd.theme ASC, ss.active DESC")
    ->fetchAll();
  foreach ($styles as $style) {
    $row = array();
    $row[] = check_plain($style->style);
    $row[] = str_replace('_', ' ', check_plain($style->theme));
    switch ($style->active) {
      case 0:
        $row[] = t('Inactive');
        break;
      case 1:
        $row[] = t('Default');
        break;
      case 2:
        $row[] = t('Active');
        break;
    }
    $operations = '';
    if ($style->active != 1) {
      $operations .= l(t('Set to default'), 'admin/config/user-interface/sweaver/styles/default/' . $style->style_id) . ' - ';
    }
    if (!$style->active) {
      $operations .= l(t('Enable'), 'admin/config/user-interface/sweaver/styles/enable/' . $style->style_id) . ' - ';
    }
    else {
      $operations .= l(t('Disable'), 'admin/config/user-interface/sweaver/styles/disable/' . $style->style_id) . ' - ';
    }
    $operations .= l(t('Delete'), 'admin/config/user-interface/sweaver/styles/delete/' . $style->style_id) . ' - ';
    $operations .= l(t('Export'), 'admin/config/user-interface/sweaver/styles/export/' . $style->style_id);
    $row[] = $operations;
    $rows[] = $row;
  }
  if (empty($rows)) {
    $output = '<p>' . t('No styles found.') . '</p>';
  }
  else {
    $header = array(
      t('Style'),
      t('Theme'),
      t('Status'),
      t('Operations'),
    );
    $variables = array(
      'header' => $header,
      'rows' => $rows,
    );

    // Styles list.
    $output = theme('table', $variables);
  }
  $form['item'] = array(
    '#markup' => $output,
  );
  return $form;
}