function facebook_wall_settings_form in Facebook Wall 7
Admin configure form for Facebook login & token access.
1 string reference to 'facebook_wall_settings_form'
- facebook_wall_menu in ./
facebook_wall.module - Implements hook_menu().
File
- ./
facebook_wall.admin.inc, line 11 - Contains the administrative functions of the Facebook Wall fetcher module.
Code
function facebook_wall_settings_form() {
$form['fbw'] = array(
'#type' => 'fieldset',
'#title' => t('APP Setting'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#description' => t('In order to get facebook wall post, you had to first enter your APP Key and App Secret Key to get a valid a Access token of FB API. Create a new') . ' ' . l(t('Facebook Apps'), 'https://developers.facebook.com/apps') . t(", if you don't have it. Facebook Access token are used for accessing FB Graph API. Take note as it will expire in 60 days. (FB no longer offering unlimited offline access token."),
);
// FB App settings.
$form['fbw']['facebook_wall_app_id'] = array(
'#type' => 'textfield',
'#title' => t('App ID/ API Key'),
'#default_value' => variable_get('facebook_wall_app_id'),
'#description' => t('Your facebook unique App ID/ API Key. Also called OAuth client_id value on FB App settings pages.'),
'#required' => TRUE,
);
$form['fbw']['facebook_wall_app_secret'] = array(
'#type' => 'textfield',
'#title' => t('App Secret Key'),
'#default_value' => variable_get('facebook_wall_app_secret'),
'#description' => t('Your facebook unique App Secret Key. Also called OAuth client_secret value on FB App settings pages.'),
'#required' => TRUE,
);
// FB Access Token settings.
if (variable_get('facebook_wall_app_id') != '' && variable_get('facebook_wall_app_secret') != '') {
$form['token'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#title' => t('Access token'),
);
$threedays = 60 * 60 * 24 * 3;
// View token option, if it expires with in 3 days.
if (variable_get('facebook_wall_access_token_expiry') == '' || (int) variable_get('facebook_wall_access_token_expiry') < $threedays) {
$url = l(t('Facebook Graph Explorer'), 'https://developers.facebook.com/tools/explorer/' . variable_get('facebook_wall_app_id'), array(
'attributes' => array(
'target' => '_blank',
),
));
$form['token']['#description'] = t('Obtaining an access token is a two-stage process:<ol><li>Go to the !url, copy the long string from the "Access Token" field, paste it into the field below and save this settings page. This token will expires within 1 hour.</li><li>Click the <strong>"@button"</strong> button below to generate an access token that will be valid for sixty days.</li></ol>', array(
'!url' => $url,
'@button' => t('Obtain long term access token'),
));
$form['token']['facebook_wall_access_token_temp'] = array(
'#type' => 'textfield',
'#title' => t('Access token obtained from Facebook Graph Explorer (temporary)'),
'#size' => 160,
'#maxlength' => 255,
'#default_value' => variable_get('facebook_wall_access_token_temp'),
);
}
if (variable_get('facebook_wall_access_token') != '') {
$form['token']['#description'] = t('Note: Long term access tokens are only valid for a maximum of 60 days; Facebook no longer offers access tokens that do not expire.');
$form['token']['facebook_wall_access_token'] = array(
'#type' => 'textfield',
'#title' => t('Access token (long term)'),
'#maxlength' => 255,
'#size' => 120,
'#default_value' => variable_get('facebook_wall_access_token'),
'#disabled' => TRUE,
);
if (variable_get('facebook_wall_access_token_expiry') != '') {
$expiry = facebook_wall_get_expiry();
if ((int) variable_get('facebook_wall_access_token_expiry') < $threedays) {
$message = t('The access token will expires with in !expire_time !expire_suffix . Please click on <strong>""</strong> button to get access for another 60 days.', array(
'!expire_time' => $expiry['time'],
'!expire_suffix' => $expiry['suffix'],
'@button' => t('Obtain long term access token'),
));
watchdog('facebook wall', $message, array(), WATCHDOG_DEBUG);
if (variable_get('facebook_wall_message_show', 1)) {
drupal_set_message($message, 'warning');
}
}
$form['token']['facebook_wall_access_token_expiry'] = array(
'#markup' => t('<strong>This access token expires in @time @units.</strong>', array(
'@time' => $expiry['time'],
'@units' => $expiry['suffix'],
)),
'#prefix' => '<div style="margin-bottom:20px;" id="div_get_access_token">',
'#suffix' => '</div>',
);
$form['token']['facebook_wall_reset_button'] = array(
'#type' => 'submit',
'#value' => t('Reset tokens'),
'#submit' => array(
'_facebook_wall_reset_token',
),
);
}
}
// View token option, if it expires with in 3 days.
if ((variable_get('facebook_wall_access_token_expiry') == '' || (int) variable_get('facebook_wall_access_token_expiry') < 259200) && variable_get('facebook_wall_access_token_temp') != '') {
$form['token']['facebook_wall_access_button'] = array(
'#type' => 'submit',
'#value' => t('Obtain long term access token'),
'#submit' => array(
'_facebook_wall_get_access_token',
),
);
}
}
// FB user page id/name setting.
$form['page'] = array(
'#type' => 'fieldset',
'#title' => t('Page or User Profile'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#description' => t('In order to get facebook wall post, you had to first need to have a Access token.'),
);
$form['page']['facebook_wall_page_url'] = array(
'#type' => 'textfield',
'#title' => t('Facebook Page URL'),
'#field_prefix' => 'https://www.facebook.com/',
'#default_value' => variable_get('facebook_wall_page_url', 'me'),
'#description' => t('Enter your facebook page user name. Example: username: "OSSCube" or id: "322122293265" or "me" for logged in user profile.'),
'#required' => TRUE,
);
// FB user wall post setting.
$page_url = variable_get('facebook_wall_page_url', 'me');
if (!empty($page_url)) {
$form['page']['facebook_wall_test_url'] = array(
'#markup' => t('Test this Facebook page URL.') . ' ' . l(t('https://www.facebook.com/') . $page_url, 'https://www.facebook.com/' . $page_url, array(
'attributes' => array(
'target' => '_blank',
),
)) . '<br /><br />',
);
$form['wall_setting'] = array(
'#type' => 'fieldset',
'#title' => t('Wall Content settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('In order to get facebook wall post, you had to first need to have a Access token.'),
);
$form['wall_setting']['facebook_wall_menu_name'] = array(
'#type' => 'textfield',
'#title' => t('Name of wall page'),
'#size' => 20,
'#default_value' => variable_get('facebook_wall_menu_name'),
'#required' => TRUE,
'#description' => t('Enter the facebook wall page name. Please clear the cache in order to view new page name for') . ' ' . l('facebook_wall', 'facebook_wall'),
);
// FB wall post type.
$post_type = array(
'link' => t('Link'),
'photo' => t('Photo'),
'status' => t('Status'),
'video' => t('Video'),
);
$form['wall_setting']['checkbox_msg'] = array(
'#markup' => '<strong>' . t('FB wall post type') . '</strong>',
);
foreach ($post_type as $key => $value) {
$form['wall_setting']['facebook_wall_post_type_' . $key] = array(
'#type' => 'checkbox',
'#title' => $value,
'#default_value' => variable_get('facebook_wall_post_type_' . $key, 1),
);
}
$form['wall_setting']['facebook_wall_post_limit'] = array(
'#type' => 'textfield',
'#title' => t('Wall Page Limit'),
'#size' => 3,
'#default_value' => (int) variable_get('facebook_wall_post_limit', 10),
'#required' => TRUE,
'#description' => t('Enter the wall post limit (in numeric). Note: Higher the limit, takes more time to fetch post form Facebook API.'),
);
$form['wall_setting']['facebook_wall_width_option'] = array(
'#type' => 'radios',
'#title' => 'Wall Page Width Setting',
'#default_value' => variable_get('facebook_wall_width_option', 'no-style'),
'#options' => array(
'no-style' => t('No Extra Width Style'),
'relative-width' => t('Relative Width Style'),
'pixel-width' => t('Pixel Width Style'),
),
'#description' => t('Choose how the module should set the width of the wall.'),
'#required' => TRUE,
);
$form['wall_setting']['facebook_wall_width_size_relative'] = array(
'#type' => 'textfield',
'#title' => t('Wall Page Width Size (Relative)'),
'#size' => 2,
'#field_suffix' => t('%'),
'#default_value' => (int) variable_get('facebook_wall_width_size_relative', 100),
'#required' => TRUE,
'#description' => t('Enter the wall width size as a percentage (omit % sign).'),
'#states' => array(
'visible' => array(
':input[name="facebook_wall_width_option"]' => array(
'value' => 'relative-width',
),
),
),
);
$form['wall_setting']['facebook_wall_width_size'] = array(
'#type' => 'textfield',
'#title' => t('Wall Page Width Size'),
'#size' => 2,
'#field_suffix' => t('px'),
'#default_value' => (int) variable_get('facebook_wall_width_size', 500),
'#required' => TRUE,
'#description' => t('Enter the wall width size in numeric & between 400px to 800px.'),
'#states' => array(
'visible' => array(
':input[name="facebook_wall_width_option"]' => array(
'value' => 'pixel-width',
),
),
),
);
$form['wall_setting']['button_visible_msg'] = array(
'#markup' => '<strong>' . t('Enable Form Control') . '</strong>',
);
$form['wall_setting']['facebook_wall_older_post_button'] = array(
'#type' => 'checkbox',
'#title' => t('"Get Older Post" Button'),
'#default_value' => variable_get('facebook_wall_older_post_button', 1),
);
$form['wall_setting']['facebook_wall_post_view'] = array(
'#type' => 'checkbox',
'#title' => t('"View Post" Link'),
'#default_value' => variable_get('facebook_wall_post_view', 1),
);
$form['wall_setting']['facebook_wall_autoplay_video'] = array(
'#type' => 'checkbox',
'#title' => t('Auto Play video'),
'#default_value' => variable_get('facebook_wall_autoplay_video', 0),
);
$form['wall_setting']['facebook_message_control'] = array(
'#markup' => '<strong>' . t('Facebook authentication messages Control') . '</strong>',
);
$form['wall_setting']['facebook_wall_message_show'] = array(
'#type' => 'checkbox',
'#title' => t('Display all facebook authentication messages'),
'#default_value' => variable_get('facebook_wall_message_show', 1),
'#description' => t('Facebook error message display while api authentication.'),
);
}
return system_settings_form($form);
}