You are here

panels_bootstrap_layout_builder.module in Panels Bootstrap Layout Builder 7.3

Same filename and directory in other branches
  1. 7 panels_bootstrap_layout_builder.module

File

panels_bootstrap_layout_builder.module
View source
<?php

/**
 * Implements hook_requirements().
 */
function panels_bootstrap_layout_builder_requirements($phase) {
  $requirements = array();

  // Ensure translations do not break at install time
  $t = get_t();
  $requirements['panels_bootstrap_layout_builder'] = array(
    'title' => $t('Panels Bootstrap CSS'),
  );
  $path = libraries_get_path('bootstrap');
  $css_path = $path . '/css/bootstrap.min.css';
  if ($path && file_exists($css_path)) {
    $requirements['panels_bootstrap_layout_builder']['value'] = $t('Exists');
    $requirements['panels_bootstrap_layout_builder']['severity'] = REQUIREMENT_OK;
  }
  else {
    $requirements['panels_bootstrap_layout_builder']['value'] = $t('Not Found');
    $requirements['panels_bootstrap_layout_builder']['severity'] = REQUIREMENT_INFO;
    $requirements['panels_bootstrap_layout_builder']['description'] = $t('The %css file does not exist. Either your admin theme is bootstrap or you will need to <a href="@tb">download bootstrap</a> to /sites/all/libraries/bootstrap.', array(
      '%css' => $css_path,
      '@tb' => url('http://getbootstrap.com/'),
    ));
  }
  return $requirements;
}

/**
 * Implements hook_permission().
 */
function panels_bootstrap_layout_builder_permission() {
  return array(
    'administer layouts' => array(
      'title' => t('Administer bootstrap layouts'),
      'description' => t('Administer backend settings for bootstrap layouts.'),
    ),
  );
}

/**
 * Implements hook_ctools_plugin_directory().
 */
function panels_bootstrap_layout_builder_ctools_plugin_directory($owner, $plugin_type) {
  if ($owner == 'panels' && $plugin_type == 'layouts') {
    return "plugins/{$plugin_type}";
  }
}

/**
 * Implementation of hook_ctools_plugin_api().
 *
 * Tell CTools that we support the default_panels_bootstrap_layout_breakpoint and
 * default_panels_layout APIs.
 */
function panels_bootstrap_layout_builder_ctools_plugin_api($owner, $api) {
  if ($owner == 'panels' && $api == 'layouts') {
    return array(
      'version' => 1,
    );
  }
}

/**
 * Implementation of hook_menu
 */
function panels_bootstrap_layout_builder_menu() {
  $items = array();
  $items['admin/structure/panels/settings/bootstrap'] = array(
    'title' => 'Bootstrap',
    'description' => 'Panels Bootstrap Layout Builder settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'panels_bootstrap_layout_builder_admin_settings_page',
    ),
    'type' => MENU_LOCAL_TASK,
    'access arguments' => array(
      'use panels dashboard',
    ),
  );
  return $items;
}

/**
 * A central administrative page for Panels Bootstrap Layout Builder.
 */
function panels_bootstrap_layout_builder_admin_settings_page() {
  $form = array();
  $form['panels_bootstrap_grid_size'] = array(
    '#type' => 'textfield',
    '#title' => t('Grid Size'),
    '#description' => t('By default this is 12.  Changing this value does not update your css.'),
    '#default_value' => variable_get('panels_bootstrap_grid_size', 12),
    '#size' => 2,
    '#maxlength' => 2,
    '#required' => TRUE,
  );
  return system_settings_form($form);
}