You are here

function twitter_block_custom_block_form in Twitter Block 7

Same name and namespace in other branches
  1. 7.2 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 141
A module to provide simple Twitter blocks using the Twitter Search API.

Code

function twitter_block_custom_block_form($edit = array()) {
  $edit += array(
    'info' => '',
    'search_type' => array(),
    'search_string' => '',
    'include_rts' => TRUE,
    'lang' => '',
    'results_per_page' => 10,
  );
  $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['configuration'] = array(
    '#type' => 'fieldset',
    '#title' => t('Twitter Block configuration'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['configuration']['search_type'] = array(
    '#type' => 'radios',
    '#title' => t('Search type'),
    '#options' => array(
      'searchHashtag' => t('Tweets mentioning a hashtag or search string'),
      'getTweetsFrom' => t('Tweets sent from a specific user'),
      'getReplies' => t('Replies to the a specific user'),
      'getMentions' => t('Tweets mentioning a specific user'),
    ),
    '#default_value' => $edit['search_type'],
    '#description' => t('Choose the method to use when searching tweets.'),
    '#required' => TRUE,
  );
  $form['configuration']['search_string'] = array(
    '#type' => 'textfield',
    '#title' => t('Search query'),
    '#default_value' => $edit['search_string'],
    '#description' => t('Enter a username, hashtag or search string depending on the currently selected search type.'),
    '#maxlength' => 140,
  );
  $form['configuration']['include_rts'] = array(
    '#type' => 'checkbox',
    '#title' => t('Include retweets'),
    '#default_value' => $edit['include_rts'],
  );
  $form['configuration']['lang'] = array(
    '#type' => 'textfield',
    '#title' => t('Language'),
    '#description' => t('Enter an <a href="@language-codes">ISO 639-1 language code</a>. Only tweets written in the specified language will be displayed. Note that Twitter only supports a limited number of languages (see the Twitter <a href="@search-page">advanced search page</a> for a list of currently supported languages). Leave blank to display tweets from all languages.', array(
      '@language-codes' => 'http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes',
      '@search-page' => 'http://twitter.com/search-advanced',
    )),
    '#default_value' => $edit['lang'],
    '#size' => 2,
    '#maxlength' => 2,
  );
  $form['configuration']['results_per_page'] = array(
    '#type' => 'select',
    '#title' => t('Tweets'),
    '#options' => drupal_map_assoc(array(
      1,
      2,
      3,
      4,
      5,
      6,
      7,
      8,
      9,
      10,
      20,
      30,
      40,
      50,
      60,
      70,
      80,
      90,
      100,
    )),
    '#default_value' => $edit['results_per_page'],
    '#description' => t('Select the number of tweets to display.'),
  );
  return $form;
}