You are here

function _fb_likebox_validate_block_settings in Facebook Page Plugin 7

Same name and namespace in other branches
  1. 6.2 fb_likebox.module \_fb_likebox_validate_block_settings()
  2. 6 fb_likebox.module \_fb_likebox_validate_block_settings()
  3. 7.2 fb_likebox.module \_fb_likebox_validate_block_settings()

Perform the validation of the block settings.

1 string reference to '_fb_likebox_validate_block_settings'
fb_likebox_form_block_admin_configure_alter in ./fb_likebox.module
Implements hook_form_FORM_ID_alter().

File

./fb_likebox.module, line 261
Simple module that provides a configurable block with Facebook Likebox's plugin.

Code

function _fb_likebox_validate_block_settings(&$form, $form_state) {

  // Facebook display settings validation.
  $fb_url = $form_state['values']['fb_likebox_url'];
  if (!valid_url($fb_url, TRUE)) {
    form_set_error('fb_likebox_url', t('Please enter a valid url'));
  }

  // Facebook theming settings validation.
  $fb_width = $form_state['values']['fb_likebox_width'];
  if (!is_numeric($fb_width) || intval($fb_width) <= 0) {
    form_set_error('fb_likebox_width', t('Width should be a number bigger than 0'));
  }
  $fb_width_units = $form_state['values']['fb_likebox_width_units'];
  if ($fb_width_units == '%' && intval($fb_width) > 100) {
    form_set_error('fb_likebox_width', t('When using percentages, width should be 100 or smaller'));
  }
  $fb_height = $form_state['values']['fb_likebox_height'];
  if (!is_numeric($fb_height) || intval($fb_height) <= 0) {
    form_set_error('fb_likebox_height', t('Height should be a number bigger than 0'));
  }
}