You are here

bs_shortcodes.module in Bootstrap Theme Shortcodes 7

File

bs_shortcodes.module
View source
<?php

/**
 * Implements hook_help.
 *
 * Displays help and module information.
 *
 * @param path
 *   Which path of the site we're using to display help
 * @param arg
 *   Array that holds the current path as returned from arg() function
 */
function bs_shortcodes_help($path, $arg) {
  switch ($path) {
    case "admin/help#bs_shortcodes":
      return '<p>' . t("Adding Twitter Bootstrap functionality to the Shortcode API") . '</p>';
      break;
  }
}
function bs_shortcodes_preprocess_page(&$variables) {
  $path = drupal_get_path('module', 'bs_shortcodes');
  drupal_add_js($path . '/inc/js/custom.js', 'file');
  drupal_add_css($path . '/inc/css/shortcodes.css', 'file');
}
function bs_shortcodes_shortcode_info() {

  // Tooltips
  $shortcodes['tooltiptop'] = array(
    'title' => t('Tooltip Top'),
    'description' => t('Makes a Tooltip appear above an element.'),
    'process callback' => 'bs_shortcodes_shortcode_tooltiptop',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_tooltiptop_tip',
  );
  $shortcodes['tooltipright'] = array(
    'title' => t('Tooltip Right'),
    'description' => t('Makes a Tooltip appear to the right of an element.'),
    'process callback' => 'bs_shortcodes_shortcode_tooltipright',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_tooltipright_tip',
  );
  $shortcodes['tooltipbottom'] = array(
    'title' => t('Tooltip Bottom'),
    'description' => t('Makes a Tooltip appear under an element.'),
    'process callback' => 'bs_shortcodes_shortcode_tooltipbottom',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_tooltipbottom_tip',
  );
  $shortcodes['tooltipleft'] = array(
    'title' => t('Tooltip Left'),
    'description' => t('Makes a Tooltip appear to the left of an element.'),
    'process callback' => 'bs_shortcodes_shortcode_tooltipleft',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_tooltipleft_tip',
  );

  // Popovers
  $shortcodes['popovertop'] = array(
    'title' => t('popover Top'),
    'description' => t('Makes a Popover appear above an element.'),
    'process callback' => 'bs_shortcodes_shortcode_popovertop',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_popovertop_tip',
  );
  $shortcodes['popoverright'] = array(
    'title' => t('Popover Right'),
    'description' => t('Makes a Popover appear to the right of an element.'),
    'process callback' => 'bs_shortcodes_shortcode_popoverright',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_popoverright_tip',
  );
  $shortcodes['popoverbottom'] = array(
    'title' => t('Popover Bottom'),
    'description' => t('Makes a Popover appear under an element.'),
    'process callback' => 'bs_shortcodes_shortcode_popoverbottom',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_popoverbottom_tip',
  );
  $shortcodes['popoverleft'] = array(
    'title' => t('Popover Left'),
    'description' => t('Makes a Popover appear to the left of an element.'),
    'process callback' => 'bs_shortcodes_shortcode_popoverleft',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_popoverleft_tip',
  );

  // Wells
  $shortcodes['well'] = array(
    'title' => t('Well'),
    'description' => t('Wraps content in a styled well'),
    'process callback' => 'bs_shortcodes_shortcode_well',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_well_tip',
  );
  $shortcodes['well_large'] = array(
    'title' => t('Well Large'),
    'description' => t('Wraps content in a large styled well'),
    'process callback' => 'bs_shortcodes_shortcode_well_large',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_well_large_tip',
  );
  $shortcodes['well_small'] = array(
    'title' => t('Well Small'),
    'description' => t('Wraps content in a small styled well'),
    'process callback' => 'bs_shortcodes_shortcode_well_small',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_well_small_tip',
  );

  // Panels
  $shortcodes['panel'] = array(
    'title' => t('Panel'),
    'description' => t('Wraps content in a styled panel'),
    'process callback' => 'bs_shortcodes_shortcode_panel',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_panel_tip',
  );

  // Glyphicons
  $shortcodes['glyphicons'] = array(
    'title' => t('Glyphicons'),
    'description' => t('Prefixes content with an icon'),
    'process callback' => 'bs_shortcodes_shortcode_glyphicons',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_glyphicons_tip',
  );

  // Jumbotron
  $shortcodes['jumbotron'] = array(
    'title' => t('Jumbotron'),
    'description' => t('Wraps content in a jumbotron'),
    'process callback' => 'bs_shortcodes_shortcode_jumbotron',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_jumbotron_tip',
  );

  // Blockquote
  $shortcodes['blockquote'] = array(
    'title' => t('Blockquote'),
    'description' => t('Wraps content in a blockquote'),
    'process callback' => 'bs_shortcodes_shortcode_blockquote',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_blockquote_tip',
  );

  // Blockquote Reverse
  $shortcodes['blockquote_reverse'] = array(
    'title' => t('Blockquote Reverse'),
    'description' => t('Wraps content in a reverse blockquote'),
    'process callback' => 'bs_shortcodes_shortcode_blockquote_reverse',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_blockquote_reverse_tip',
  );

  // Abbreviations
  $shortcodes['abbr'] = array(
    'title' => t('Abbreviation'),
    'description' => t('Wraps content as a styled abbreviation'),
    'process callback' => 'bs_shortcodes_shortcode_abbreviation',
    //'settings callback' => '_shortcode_settings_form', TODO
    'tips callback' => 'bs_shortcodes_shortcode_abbreviation_tip',
  );
  return $shortcodes;
}

/**
 * Implementation of hook_theme().
 */
function bs_shortcodes_theme() {
  return array(
    // Tooltips
    'shortcode_tooltiptop' => array(
      'variables' => array(
        'text' => '',
        'id' => '',
      ),
    ),
    'shortcode_tooltipright' => array(
      'variables' => array(
        'text' => '',
        'id' => '',
      ),
    ),
    'shortcode_tooltipbottom' => array(
      'variables' => array(
        'text' => '',
        'id' => '',
      ),
    ),
    'shortcode_tooltipleft' => array(
      'variables' => array(
        'text' => '',
        'id' => '',
      ),
    ),
    // Popovers
    'shortcode_popover' => array(
      'variables' => array(
        'text' => '',
        'id' => '',
      ),
    ),
    'shortcode_popoverright' => array(
      'variables' => array(
        'text' => '',
        'id' => '',
      ),
    ),
    'shortcode_popoverbottom' => array(
      'variables' => array(
        'text' => '',
        'id' => '',
      ),
    ),
    'shortcode_popoverleft' => array(
      'variables' => array(
        'text' => '',
        'id' => '',
      ),
    ),
    // Wells
    'shortcode_well' => array(
      'variables' => array(
        'text' => '',
      ),
    ),
    'shortcode_well_large' => array(
      'variables' => array(
        'text' => '',
      ),
    ),
    'shortcode_well_small' => array(
      'variables' => array(
        'text' => '',
      ),
    ),
    //Panels
    'shortcode_panel' => array(
      'variables' => array(
        'text' => '',
        'heading' => '',
        'style' => '',
      ),
    ),
    //Glyphicons
    'shortcode_glyphicons' => array(
      'variables' => array(
        'text' => '',
        'name' => '',
      ),
    ),
    //Glyphicons
    'shortcode_jumbotron' => array(
      'variables' => array(
        'text' => '',
      ),
    ),
    //Blockquote
    'shortcode_blockquote' => array(
      'variables' => array(
        'blockquote' => '',
        'text' => '',
        'source' => '',
      ),
    ),
    //Blockquote Reverse
    'shortcode_blockquote_reverse' => array(
      'variables' => array(
        'blockquoter' => '',
        'text' => '',
        'sourcer' => '',
      ),
    ),
    //Abbreviation
    'shortcode_abbr' => array(
      'variables' => array(
        'abbreviation' => '',
        'title' => '',
        'text' => '',
      ),
    ),
  );
}
include "inc/elements/tooltips.php";
include "inc/elements/popovers.php";
include "inc/elements/wells.php";
include "inc/elements/panels.php";
include "inc/elements/glyphicons.php";
include "inc/elements/jumbotron.php";
include "inc/elements/blockquote.php";
include "inc/elements/abbreviation.php";

Functions