function fb_likebox_block in Facebook Page Plugin 6.2
Same name and namespace in other branches
- 6 fb_likebox.module \fb_likebox_block()
Implements hook_block().
File
- ./
fb_likebox.module, line 11 - Simple module that provides a configurable block with Facebook Likebox's plugin.
Code
function fb_likebox_block($op = 'list', $delta = 0, $edit = array()) {
drupal_add_js(drupal_get_path('module', 'fb_likebox') . '/fb_likebox.js');
switch ($op) {
case 'list':
$blocks[0]['info'] = t('@site_name on Facebook', array(
'@site_name' => variable_get('site_name', 'Default site name'),
));
$blocks[0]['cache'] = BLOCK_NO_CACHE;
return $blocks;
case 'view':
switch ($delta) {
case 0:
$fb_likebox_url = variable_get('fb_likebox_url', 'https://www.facebook.com/FacebookDevelopers');
$fb_likebox_hide_header = variable_get('fb_likebox_hide_header', '0');
$fb_likebox_stream = variable_get('fb_likebox_stream', '0');
$fb_likebox_show_faces = variable_get('fb_likebox_show_faces', '1');
$fb_likebox_title = variable_get('fb_likebox_title', 'Like us on Facebook');
$fb_likebox_width = variable_get('fb_likebox_width', '340');
$fb_likebox_height = variable_get('fb_likebox_height', '500');
$block['subject'] = t('@site_name on Facebook', array(
'@site_name' => variable_get('site_name', 'Default site name'),
));
$block['content'] = theme('fb_likebox_facebook', $fb_likebox_url, $fb_likebox_hide_header, $fb_likebox_stream, $fb_likebox_show_faces, $fb_likebox_width, $fb_likebox_height, $fb_likebox_title);
return $block;
}
break;
case 'configure':
switch ($delta) {
case 0:
$form['fb_likebox_display_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Display options'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['fb_likebox_display_settings']['fb_likebox_url'] = array(
'#type' => 'textfield',
'#title' => t('Facebook Page URL'),
'#default_value' => variable_get('fb_likebox_url', 'https://www.facebook.com/FacebookDevelopers'),
'#description' => t('Enter the Facebook Page URL. I.e.: https://www.facebook.com/FacebookDevelopers'),
'#required' => TRUE,
);
$form['fb_likebox_display_settings']['fb_likebox_hide_header'] = array(
'#type' => 'checkbox',
'#title' => t('Hide cover photo in the header'),
'#default_value' => variable_get('fb_likebox_hide_header', '0'),
);
$form['fb_likebox_display_settings']['fb_likebox_stream'] = array(
'#type' => 'checkbox',
'#title' => t('Show posts from the Page\'s timeline'),
'#default_value' => variable_get('fb_likebox_stream', '0'),
);
$form['fb_likebox_display_settings']['fb_likebox_show_faces'] = array(
'#type' => 'checkbox',
'#title' => t('Show profile photos when friends like this'),
'#default_value' => variable_get('fb_likebox_show_faces', '1'),
);
$form['fb_likebox_display_settings']['fb_likebox_title'] = array(
'#type' => 'textfield',
'#title' => t('iFrame title attribute'),
'#default_value' => variable_get('fb_likebox_title', 'Like us on Facebook'),
'#description' => t('The value of the title attribute.'),
'#required' => TRUE,
);
$form['fb_likebox_display_settings']['fb_likebox_width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => variable_get('fb_likebox_width', '340'),
'#description' => t('The width of the Facebook likebox. Must be a number between 280 and 500, limits included.'),
'#required' => TRUE,
);
$form['fb_likebox_display_settings']['fb_likebox_height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => variable_get('fb_likebox_height', '500'),
'#description' => t('The height of the plugin in pixels. Must be a number bigger than 130.'),
'#required' => TRUE,
);
return $form;
}
break;
case 'save':
switch ($delta) {
case 0:
variable_set('fb_likebox_url', check_url($edit['fb_likebox_url']));
variable_set('fb_likebox_hide_header', check_plain($edit['fb_likebox_hide_header']));
variable_set('fb_likebox_stream', check_plain($edit['fb_likebox_stream']));
variable_set('fb_likebox_show_faces', check_plain($edit['fb_likebox_show_faces']));
variable_set('fb_likebox_width', check_plain($edit['fb_likebox_width']));
variable_set('fb_likebox_height', check_plain($edit['fb_likebox_height']));
variable_set('fb_likebox_title', check_plain($edit['fb_likebox_title']));
}
break;
}
}