You are here

class sweaver_plugin_customcss in Sweaver 6

@file Custom CSS plugin.

Hierarchy

Expanded class hierarchy of sweaver_plugin_customcss

3 string references to 'sweaver_plugin_customcss'
sweaver_drush_edit_style in drush/sweaver.drush.inc
Edit a style.
sweaver_plugin_customcss::sweaver_form_css_js in plugins/sweaver_plugin_customcss/sweaver_plugin_customcss.inc
Frontend css and js.
_sweaver_sweaver_plugins in ./sweaver.registry.inc
Sweaver plugins.

File

plugins/sweaver_plugin_customcss/sweaver_plugin_customcss.inc, line 7
Custom CSS plugin.

View source
class sweaver_plugin_customcss extends sweaver_plugin {

  /**
   * Frontend form.
   */
  public function sweaver_form() {
    $current_style = Sweaver::get_instance()
      ->get_current_style();
    $form = array();
    $attributes = array();
    $form['sweaver_plugin_custom_css'] = array(
      '#type' => 'textarea',
      '#rows' => 10,
      '#cols' => 80,
      '#resizable' => FALSE,
      '#wysiwyg' => FALSE,
      '#attributes' => array(
        'class' => 'sweaver-400',
      ),
      '#default_value' => isset($current_style->customcss) ? $current_style->customcss : '',
      '#prefix' => '<div class="form-floater">',
    );
    $form['sweaver_plugin_custom_css_button'] = array(
      '#type' => 'button',
      '#value' => t('Apply'),
      '#suffix' => '</div>',
    );
    return $form;
  }

  /**
   * Frontend form submit handler.
   */
  function sweaver_form_submit($form, &$form_state) {
    $clicked_button = $form_state['clicked_button']['#value'];
    if (($clicked_button == t('Save and continue') || $clicked_button == t('Save and publish') || $clicked_button == t('Publish style')) && isset($form_state['style_id'])) {
      db_query("UPDATE {sweaver_style_draft} set customcss = '%s' WHERE style_id = %d", $form_state['values']['sweaver_plugin_custom_css'], $form_state['style_id']);
      if ($form_state['publish']) {
        db_query("UPDATE {sweaver_style} set customcss = '%s' WHERE style_id = %d", $form_state['values']['sweaver_plugin_custom_css'], $form_state['style_id']);
      }
    }
  }

  /**
   * Frontend css and js.
   */
  public function sweaver_form_css_js(&$inline_settings) {
    drupal_add_js(drupal_get_path('module', 'sweaver') . '/plugins/sweaver_plugin_customcss/sweaver_plugin_customcss.js', 'module');
    $inline_settings['sweaver']['invokes'][] = 'sweaver_plugin_customcss';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
sweaver_plugin::sweaver_dependencies public function Sweaver dependencies. 2
sweaver_plugin::sweaver_form_render public function Sweaver form render. 2
sweaver_plugin::sweaver_images_handler public function Images handler. 1
sweaver_plugin::sweaver_init public function Init function. 2
sweaver_plugin::sweaver_menu public function Menu registry. 6
sweaver_plugin::sweaver_menu_callback public function Menu callback. 5
sweaver_plugin::sweaver_menu_callback_submit public function Menu callback submit. 2
sweaver_plugin::sweaver_menu_callback_validate public function Menu callback validate.
sweaver_plugin::sweaver_objects_alter public function Sweaver objects alter. 1
sweaver_plugin::sweaver_popups_render protected function Helper function render the popups.
sweaver_plugin::sweaver_preprocess_page public function Preprocess page function. 1
sweaver_plugin::sweaver_theme public function Theme registry. 1
sweaver_plugin_customcss::sweaver_form public function Frontend form. Overrides sweaver_plugin::sweaver_form
sweaver_plugin_customcss::sweaver_form_css_js public function Frontend css and js. Overrides sweaver_plugin::sweaver_form_css_js
sweaver_plugin_customcss::sweaver_form_submit function Frontend form submit handler. Overrides sweaver_plugin::sweaver_form_submit