'FB Like settings', 'description' => 'Configure FB Like Button', 'page callback' => 'system_admin_menu_block_page', 'access arguments' => array('administer fblikebutton'), 'position' => 'right', 'weight' => -20, 'type' => MENU_NORMAL_ITEM, 'file' => 'system.admin.inc', 'file path' => drupal_get_path('module', 'system'), ); $items['admin/config/fblikebutton/general'] = array( 'title' => 'FB Like settings', 'description' => 'Configure which the button should appear on.', 'page callback' => 'drupal_get_form', 'page arguments' => array('fblikebutton_admin_settings'), 'access arguments' => array('administer fblikebutton'), 'type' => MENU_NORMAL_ITEM, 'file' => 'fblikebutton.admin.inc', 'weight' => 0, ); $items['admin/config/fblikebutton/block'] = array( 'title' => 'FB Like block settings', 'description' => 'Configure which the block should appear on.', 'page callback' => 'drupal_get_form', 'page arguments' => array('fblikebutton_block_settings'), 'access arguments' => array('administer fblikebutton block'), 'type' => MENU_NORMAL_ITEM, 'file' => 'fblikebutton.admin.inc', 'weight' => 1, ); return $items; } /** * Implementation of hook_permission() */ function fblikebutton_permission() { return array( 'administer fblikebutton' => array( 'title' => t('Administer FB Like button'), 'description' => t('Perform administration tasks for FB Like button') ), 'administer fblikebutton block' => array( 'title' => t('Administer FB Like button block'), 'description' => t('Perform administration tasks for FB Like button block') ), 'access fblikebutton' => array( 'title' => t('Access FB Like button'), ), ); } /** * Implementation of hook_node_view() */ function fblikebutton_node_view($node, $view_mode) { $types = variable_get('fblikebutton_node_types', array()); $full = ($view_mode == 'full') ? TRUE : FALSE; $show = ( ! empty($types[$node->type]) && $full && user_access('access fblikebutton')); if ($show) { $url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $http = ( ! empty($_SERVER['HTTPS'])) ? 'https://' : 'http://'; $addr = $http . $url; $conf = array( 'layout' => variable_get('fblikebutton_layout', "standard"), 'action' => variable_get('fblikebutton_action', "like"), 'color_scheme' => variable_get('fblikebutton_color_scheme', "light"), 'show_faces' => variable_get('fblikebutton_show_faces', "false"), 'font' => variable_get('fblikebutton_font', "arial"), ); $node->content['fblikebutton_field'] = array( '#markup' => _fblikebutton_field($addr, $conf), ); } } /** * Implementation of hook_block_info() */ function fblikebutton_block_info() { $blocks['fblikebutton_block'] = array( 'info' => t('FB Like button'), ); return $blocks; } /** * Implementation of hook_block_configure() */ function fblikebutton_block_configure($delta = '') { global $base_url; $form = array(); if ($delta == 'fblikebutton_block') { $form['fblikebutton_block_url'] = array( '#title' => t('Homepage URL'), '#type' => 'textfield', '#default_value' => variable_get('fblikebutton_block_url', $base_url), '#description' => t('URL of your homepage to like'), ); $form['block'] = array( '#type' => 'fieldset', '#collapsible' => false, '#collapsed' => false, '#title' => t('Options'), '#description' => '', ); $form['block']['fblikebutton_bl_layout'] = array( '#type' => 'select', '#title' => t('Layout style'), '#options' => array('standard' => t('Standard'), 'box_count' => t('Box Count'), 'button_count' => t('Button Count')), '#default_value' => variable_get('fblikebutton_bl_layout', 'standard'), '#description' => t('Determines the size and amount of social context next to the button'), ); $form['block']['fblikebutton_bl_show_faces'] = array( '#type' => 'select', '#title' => t('Display faces in the box'), '#options' => array('show' => t('Show faces'), 'hide' => t('Do not show faces')), '#default_value' => variable_get('fblikebutton_bl_show_faces', 'show'), '#description' => t('Show profile pictures below the button. Only work on Standard layout'), ); $form['block']['fblikebutton_bl_action'] = array( '#type' => 'select', '#title' => t('Verb to display'), '#options' => array('like' => t('Like'), 'recommend' => t('Recommend')), '#default_value' => variable_get('fblikebutton_bl_action', 'like'), '#description' => t('The verb to display in the button.'), ); $form['block']['fblikebutton_bl_font'] = array( '#type' => 'select', '#title' => t('Font'), '#options' => array('arial' => 'Arial', 'lucida+grande' => 'Lucida Grande', 'segoe+ui' => 'Segoe UI', 'tahoma' => 'Tahoma', 'trebuchet+ms' => 'Trebuchet MS', 'verdana' => 'Verdana'), '#default_value' => variable_get('fblikebutton_bl_font', 'arial'), '#description' => t('The font to display in the button'), ); $form['block']['fblikebutton_bl_color_scheme'] = array( '#type' => 'select', '#title' => t('Color scheme'), '#options' => array('light' => t('Light'), 'dark' => t('Dark')), '#default_value' => variable_get('fblikebutton_bl_color_scheme', 'light'), '#description' => t('The color scheme of box environtment'), ); } return $form; } /** * Implementation of hook_block_save() */ function fblikebutton_block_save($delta = '', $edit = array()) { if ($delta == 'fblikebutton_block') { variable_set('fblikebutton_bl_layout', $edit['fblikebutton_bl_layout']); variable_set('fblikebutton_bl_layout', $edit['fblikebutton_bl_layout']); variable_set('fblikebutton_bl_show_faces', $edit['fblikebutton_bl_show_faces']); variable_set('fblikebutton_bl_action', $edit['fblikebutton_bl_action']); variable_set('fblikebutton_bl_font', $edit['fblikebutton_bl_font']); variable_set('fblikebutton_bl_color_scheme', $edit['fblikebutton_bl_color_scheme']); } } /** * Implementation of hook_block_view() */ function fblikebutton_block_view($delta = '') { global $base_url; $block = array(); switch ($delta) { case 'fblikebutton_block': default: $addr = variable_get('fblikebutton_block_url', $base_url); $conf = array( 'layout' => variable_get('fblikebutton_bl_layout', "standard"), 'action' => variable_get('fblikebutton_bl_action', "like"), 'color_scheme' => variable_get('fblikebutton_bl_color_scheme', "light"), 'show_faces' => variable_get('fblikebutton_bl_show_faces', "false"), 'font' => variable_get('fblikebutton_bl_font', "arial"), ); $block['content'] = _fblikebutton_field($addr, $conf); } return $block; } function _fblikebutton_field($addr, $conf) { $addr = urlencode($addr); $width = "100%"; $layout = $conf['layout']; $action = $conf['action']; $colorscheme = $conf['color_scheme']; $show_faces = $conf['show_faces']; $font = $conf['font']; switch ($layout) { case "box_count": $height = 65; case "button_count": $height = 21; case "standard": default: $height = $show_faces == "false" ? 35 : 80; } $height = 60; $params = "href=$addr&layout=$layout&show_faces=false&width&font=$font&height=$height&action=$action&colorscheme=$colorscheme"; $src = htmlentities($params); $output = ""; return $output; }