You are here

fb_likebox_patterns.module in Facebook Page Plugin 7.2

Same filename and directory in other branches
  1. 7 fb_likebox_patterns/fb_likebox_patterns.module

Submodule to enable compatibility of Facebook Likebox with patterns module. The current version makes use of the system pattern component, therefore it does not really call drupal_form_submit() for the block_admin_configure $form_id, and the values will not be refreshed in that form (although the changes will be applied since they are taken from get/set variables).

File

fb_likebox_patterns/fb_likebox_patterns.module
View source
<?php

/**
 * @file
 * Submodule to enable compatibility of Facebook Likebox with patterns module.
 * The current version makes use of the system pattern component, therefore it
 * does not really call drupal_form_submit() for the block_admin_configure $form_id,
 * and the values will not be refreshed in that form (although the changes will be
 * applied since they are taken from get/set variables).
 */

/**
 * Implements hook_patterns().
 */
function fb_likebox_patterns($data = NULL) {
  $actions['fb_likebox'] = array(
    PATTERNS_INFO => t('Settings for Facebook Likebox module'),
    PATTERNS_MODIFY => array(
      'variables_execute',
    ),
    PATTERNS_EXPORT => array(
      PATTERNS_EXPORT_ALL => 'fb_likebox_patterns_export_all_settings',
    ),
  );
  return $actions;
}

/**
 * Implements function to export the values of the block configuration form.
 * In this case we do not use the patterns_api_extract_actions()
 * function, and we return directly the array with the action values
 * ready to be fetched.
 * @param $args
 * @param $result
 */
function fb_likebox_patterns_export_all_settings($args = NULL, &$result = NULL) {
  $result = array();

  //Prepare a modify action with all the fb_likebox variables
  $variables_action = array(
    'tag' => 'variables',
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_url',
    'value' => variable_get('fb_likebox_url', 'https://www.facebook.com/FacebookDevelopers'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_app_id',
    'value' => variable_get('fb_likebox_app_id', ''),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_stream',
    'value' => variable_get('fb_likebox_stream', '1'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_events',
    'value' => variable_get('fb_likebox_events', '0'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_messages',
    'value' => variable_get('fb_likebox_messages', '0'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_hide_header',
    'value' => variable_get('fb_likebox_hide_header', '0'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_show_faces',
    'value' => variable_get('fb_likebox_show_faces', '1'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_hide_cta',
    'value' => variable_get('fb_likebox_hide_cta', '0'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_small_header',
    'value' => variable_get('fb_likebox_small_header', '0'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_adapt_container_width',
    'value' => variable_get('fb_likebox_adapt_container_width', '1'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_title',
    'value' => variable_get('fb_likebox_title', 'Like us on Facebook'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_width',
    'value' => variable_get('fb_likebox_width', '340'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_height',
    'value' => variable_get('fb_likebox_height', '500'),
  );
  $variables_action[] = array(
    'name' => 'fb_likebox_language',
    'value' => variable_get('fb_likebox_language', 'en_EN'),
  );
  $result[] = array(
    PATTERNS_MODIFY => $variables_action,
  );
  return $result;
}

/**
 * Implements hook_patterns_directory().
 */
function fb_likebox_patterns_directory() {
  return drupal_get_path('module', 'fb_likebox_patterns') . '/patterns/';
}

Functions

Namesort descending Description
fb_likebox_patterns Implements hook_patterns().
fb_likebox_patterns_directory Implements hook_patterns_directory().
fb_likebox_patterns_export_all_settings Implements function to export the values of the block configuration form. In this case we do not use the patterns_api_extract_actions() function, and we return directly the array with the action values ready to be fetched.