You are here

ckeditor_accordion.module in CKEditor Accordion 7

Same filename and directory in other branches
  1. 8 ckeditor_accordion.module

Adds accordion plugin to CKEditor.

File

ckeditor_accordion.module
View source
<?php

/**
 * @file
 * Adds accordion plugin to CKEditor.
 */

/**
 * Implements hook_ckeditor_plugin().
 * Hook to register the CKEditor plugin - it would appear in the plugins list on the profile setting page.
 */
function ckeditor_accordion_ckeditor_plugin() {
  return array(
    'accordion' => array(
      // Name of the plugin used to write it.
      'name' => 'accordion',
      // Description of the plugin - it would be displayed in
      // the plugins management section of profile settings.
      'desc' => t('CKEditor Accordion - A plugin to easily create accordions'),
      // The full URL to the CKEditor plugins directory,
      // with the trailing slash.
      'path' => ckeditor_base_path('local') . '/' . drupal_get_path('module', 'ckeditor_accordion') . '/plugins/accordion/',
      'buttons' => array(
        'Accordion' => array(
          // Path to an icon relative to the plugins folder.
          'icon' => 'icons/accordion.png',
          'label' => 'Accordion',
        ),
      ),
    ),
  );
}

/**
 * Implements hook_editor_ckeditor_plugins().
 */
function ckeditor_accordion_editor_ckeditor_plugins() {
  return array(
    'accordion' => array(
      'path' => drupal_get_path('module', 'ckeditor_accordion') . '/plugins/accordion',
      'file' => 'plugin.js',
      'css' => array(
        drupal_get_path('module', 'ckeditor_accordion') . '/plugins/accordion/accordion.css',
      ),
      'buttons' => array(
        'Accordion' => array(
          'label' => t('Accordion'),
          'image' => drupal_get_path('module', 'ckeditor_accordion') . '/plugins/accordion/icons/accordion.png',
        ),
      ),
    ),
  );
}

/**
 * Implements hook_menu().
 */
function ckeditor_accordion_menu() {
  $items = array();
  $items['admin/config/content/ckeditor_accordion'] = array(
    'title' => 'Administer CKEditor Accordion',
    'description' => 'Adminster CKEditor Accordion configuration',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'ckeditor_accordion_admin',
    ),
    'access arguments' => array(
      'administer ckeditor',
    ),
    'type' => MENU_NORMAL_ITEM,
  );
  return $items;
}

/**
 * Create settings page for the module.
 */
function ckeditor_accordion_admin() {
  $form = array();
  $form['ckeditor_accordion_collapsed'] = array(
    '#type' => 'checkbox',
    '#title' => t('Collapse all tabs by default'),
    '#default_value' => variable_get('ckeditor_accordion_collapsed', 0),
    '#description' => t("The maximum number of links to display in the block."),
  );
  return system_settings_form($form);
}

/**
 * Implements hook_page_build().
 */
function ckeditor_accordion_page_build(&$page) {
  $config = variable_get('ckeditor_accordion_collapsed', 0);
  if ($config) {
    drupal_add_js(array(
      'ckeditor_accordion' => array(
        'collapseAll' => 1,
      ),
    ), array(
      'type' => 'setting',
    ));
  }
}

Functions

Namesort descending Description
ckeditor_accordion_admin Create settings page for the module.
ckeditor_accordion_ckeditor_plugin Implements hook_ckeditor_plugin(). Hook to register the CKEditor plugin - it would appear in the plugins list on the profile setting page.
ckeditor_accordion_editor_ckeditor_plugins Implements hook_editor_ckeditor_plugins().
ckeditor_accordion_menu Implements hook_menu().
ckeditor_accordion_page_build Implements hook_page_build().