function twitter_block_custom_block_form in Twitter Block 7.2
Same name and namespace in other branches
- 7 twitter_block.module \twitter_block_custom_block_form()
Form constructor for the Twitter block form.
Parameters
$edit: (optional) An associative array of information retrieved by twitter_block_block_get() if an existing block is being edited, or an empty array otherwise. Defaults to array().
1 call to twitter_block_custom_block_form()
- twitter_block_block_configure in ./
twitter_block.module - Implements hook_block_configure().
File
- ./
twitter_block.module, line 196 - A module to provide simple Twitter blocks using the Twitter Search API.
Code
function twitter_block_custom_block_form($edit = array()) {
$edit += array(
'info' => '',
'widget_id' => '',
'username' => '',
'theme' => '',
'link_color' => '',
'width' => '',
'height' => '',
'chrome' => array(),
'border_color' => '',
'language' => '',
'tweet_limit' => '',
'related' => '',
'polite' => array(),
);
$form['info'] = array(
'#type' => 'textfield',
'#title' => t('Block description'),
'#default_value' => $edit['info'],
'#maxlength' => 64,
'#description' => t('A brief description of your block. Used on the <a href="@overview">Blocks administration page</a>.', array(
'@overview' => url('admin/structure/block'),
)),
'#required' => TRUE,
);
$form['widget_id'] = array(
'#type' => 'textfield',
'#title' => t('Widget ID'),
'#default_value' => $edit['widget_id'],
'#required' => TRUE,
'#description' => t('Each Twitter Block block requires a unique widget ID which determines, among other things, the source (user timeline, favourites, list or search) of the tweets to display. You can view a list of your existing embedded timeline widgets (and their widget IDs) or create new embedded timeline widgets by visiting the <a href="@widgets_section">widgets section of your settings page</a> (make sure that you\'re logged in). You can determine a widget\'s ID by editing it and inspecting the URL (which should be in the form of twitter.com/settings/widgets/WIDGET_ID/edit) or by looking at the widget\'s embed code (look for data-widget-id="WIDGET_ID").', array(
'@widgets_section' => 'https://twitter.com/settings/widgets',
)),
);
$form['username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#default_value' => $edit['username'],
'#required' => TRUE,
'#description' => t('A Twitter account username. This is used to generate a fallback link to the Twitter account associated with the widget when JavaScript is not available. You can find your account username by visting the <a href="@account_section">account section of your settings page</a> or on your profile page in the URL or prefixed with @ under your display name.', array(
'@account_section' => 'https://twitter.com/settings/account',
)),
);
$form['appearance'] = array(
'#type' => 'fieldset',
'#title' => t('Appearance'),
);
$form['appearance']['theme'] = array(
'#type' => 'select',
'#title' => t('Theme'),
'#default_value' => $edit['theme'],
'#options' => array(
'' => t('Default'),
'dark' => t('Dark'),
),
'#description' => t('Select a theme for the widget.'),
);
$form['appearance']['link_color'] = array(
'#type' => 'textfield',
'#title' => t('Link color'),
'#default_value' => $edit['link_color'],
'#maxlength' => 6,
'#size' => 6,
'#field_prefix' => '#',
'#description' => t('Change the link color used by the widget. Takes an %format hex format color. Note that some icons in the widget will also appear this color.', array(
'%format' => 'abc123',
)),
);
$form['appearance']['border_color'] = array(
'#type' => 'textfield',
'#title' => t('Border color'),
'#default_value' => $edit['border_color'],
'#maxlength' => 6,
'#size' => 6,
'#field_prefix' => '#',
'#description' => t('Change the border color used by the widget. Takes an %format hex format color.', array(
'%format' => 'abc123',
)),
);
$form['appearance']['chrome'] = array(
'#type' => 'checkboxes',
'#title' => t('Chrome'),
'#default_value' => $edit['chrome'],
'#options' => array(
'noheader' => t('No header'),
'nofooter' => t('No footer'),
'noborders' => t('No borders'),
'noscrollbar' => t('No scrollbar'),
'transparent' => t('Transparent'),
),
'#description' => t('Control the widget layout and chrome.'),
);
$form['functionality'] = array(
'#type' => 'fieldset',
'#title' => t('Functionality'),
);
$form['functionality']['related'] = array(
'#type' => 'textfield',
'#title' => t('Related users'),
'#default_value' => $edit['related'],
'#description' => t('As per the Tweet and follow buttons, you may provide a comma-separated list of user screen names as suggested followers to a user after they reply, Retweet, or favorite a Tweet in the timeline.'),
);
$form['functionality']['tweet_limit'] = array(
'#type' => 'select',
'#title' => t('Tweet limit'),
'#default_value' => $edit['tweet_limit'],
'#options' => array(
'' => t('Auto'),
) + drupal_map_assoc(range(1, 20)),
'#description' => t('Fix the size of a timeline to a preset number of Tweets between 1 and 20. The timeline will render the specified number of Tweets from the timeline, expanding the height of the widget to display all Tweets without scrolling. Since the widget is of a fixed size, it will not poll for updates when using this option.'),
);
$form['size'] = array(
'#type' => 'fieldset',
'#title' => t('Size'),
'#description' => t('Embedded timelines are flexible and adaptive, functioning at a variety of dimensions ranging from wide to narrow, and short to tall. The default dimensions for a timeline are 520×600px, which can be overridden to fit the dimension requirements of your page. Setting a width is not required, and by default the widget will shrink to the width of its parent element in the page.'),
);
$form['size']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width'),
'#default_value' => $edit['width'],
'#size' => 6,
'#field_suffix' => 'px',
'#description' => t('Change the width of the widget.'),
);
$form['size']['height'] = array(
'#type' => 'textfield',
'#title' => t('Height'),
'#default_value' => $edit['height'],
'#size' => 6,
'#field_suffix' => 'px',
'#description' => t('Change the height of the widget.'),
);
$form['size']['note'] = array(
'#type' => 'markup',
'#markup' => '<p>' . t('The minimum width of a timeline is 180px and the maximum is 520px. The minimum height is 200px.') . '</p>',
);
$form['accessibility'] = array(
'#type' => 'fieldset',
'#title' => t('Accessibility'),
);
$form['accessibility']['language'] = array(
'#type' => 'textfield',
'#title' => t('Language'),
'#default_value' => $edit['language'],
'#maxlength' => 5,
'#size' => 5,
'#description' => t('The widget language is detected from the page, based on the language of your content. Enter a <a href="@website">language code</a> to manually override the language.', array(
'@website' => 'http://www.w3.org/TR/html401/struct/dirlang.html#h-8.1.1',
)),
);
$form['accessibility']['polite'] = array(
'#type' => 'select',
'#title' => t('ARIA politeness'),
'#options' => array(
'polite' => t('Polite'),
'assertive' => t('Assertive'),
),
'#default_value' => $edit['polite'],
'#description' => t('ARIA is an accessibility system that aids people using assistive technology interacting with dynamic web content. <a href="@website">Read more about ARIA on W3C\'s website</a>. By default, the embedded timeline uses the least obtrusive setting: "polite". If you\'re using an embedded timeline as a primary source of content on your page, you may wish to override this to the assertive setting, using "assertive".', array(
'@website' => 'http://www.w3.org/WAI/intro/aria.php',
)),
);
return $form;
}