diff --git a/lib/Drupal/twitter/Form/TwitterSettingsForm.php b/lib/Drupal/twitter/Form/TwitterSettingsForm.php new file mode 100644 index 0000000000000000000000000000000000000000..1c25f89cfee478fe35ef7bd384674696b822ab00 --- /dev/null +++ b/lib/Drupal/twitter/Form/TwitterSettingsForm.php @@ -0,0 +1,103 @@ + 'checkbox', + '#title' => t('Import and display the Twitter statuses of site users who have entered their Twitter account information.'), + '#default_value' => variable_get('twitter_import', 1), + ); + $form['twitter_expire'] = array( + '#type' => 'select', + '#title' => t('Delete old statuses'), + '#default_value' => variable_get('twitter_expire', 0), + '#options' => array(0 => t('Never')) + drupal_map_assoc(array(604800, 2592000, 7776000, 31536000), 'format_interval'), + '#states' => array( + 'visible' => array( + ':input[name=twitter_import]' => array('checked' => TRUE), + ), + ), + ); + $form['oauth'] = array( + '#type' => 'fieldset', + '#title' => t('OAuth Settings'), + '#access' => module_exists('oauth_common'), + '#description' => t('To enable OAuth based access for twitter, you must register your application with Twitter and add the provided keys here.', array('@url' => 'https://dev.twitter.com/apps/new')), + ); + $form['oauth']['callback_url'] = array( + '#type' => 'item', + '#title' => t('Callback URL'), + '#markup' => url('twitter/oauth', array('absolute' => TRUE)), + ); + $form['oauth']['twitter_consumer_key'] = array( + '#type' => 'textfield', + '#title' => t('OAuth Consumer key'), + '#default_value' => variable_get('twitter_consumer_key', NULL), + ); + $form['oauth']['twitter_consumer_secret'] = array( + '#type' => 'textfield', + '#title' => t('OAuth Consumer secret'), + '#default_value' => variable_get('twitter_consumer_secret', NULL), + ); + // Twitter external APIs settings. + $form['twitter'] = array( + '#type' => 'fieldset', + '#title' => t('Twitter Settings'), + '#description' => t('The following settings connect Twitter module with external APIs. ' . + 'Change them if, for example, you want to use Identi.ca.'), + ); + $form['twitter']['twitter_host'] = array( + '#type' => 'textfield', + '#title' => t('Twitter host'), + '#default_value' => variable_get('twitter_host', TWITTER_HOST), + ); + $form['twitter']['twitter_api'] = array( + '#type' => 'textfield', + '#title' => t('Twitter API'), + '#default_value' => variable_get('twitter_api', TWITTER_API), + ); + $form['twitter']['twitter_search'] = array( + '#type' => 'textfield', + '#title' => t('Twitter search'), + '#default_value' => variable_get('twitter_search', TWITTER_SEARCH), + ); + $form['twitter']['twitter_tinyurl'] = array( + '#type' => 'textfield', + '#title' => t('TinyURL'), + '#default_value' => variable_get('twitter_tinyurl', TWITTER_TINYURL), + ); + + return parent::buildForm($form, $form_state); + } + + /** + * Implements \Drupal\Core\Form\FormInterface::submitForm(). + */ + public function submitForm(array &$form, array &$form_state) { + + parent::submitForm($form, $form_state); + } + +} diff --git a/twitter.module b/twitter.module index 894930dceb264f47e0e0fda48a56060b735c9e22..b4eae4dbac4219388f69bb1960d1f53403ea7aee 100644 --- a/twitter.module +++ b/twitter.module @@ -70,10 +70,7 @@ function twitter_menu() { $items['admin/config/services/twitter/settings'] = array( 'title' => 'Settings', 'description' => 'Twitter settings.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('twitter_admin_form'), - 'access arguments' => array('administer site configuration'), - 'file' => 'twitter.pages.inc', + 'route_name' => 'twitter_settings_form', 'type' => MENU_LOCAL_TASK, ); diff --git a/twitter.routing.yml b/twitter.routing.yml new file mode 100644 index 0000000000000000000000000000000000000000..24445d65dc8fd8aa349c5c6b2286c9e55085c7b2 --- /dev/null +++ b/twitter.routing.yml @@ -0,0 +1,6 @@ +twitter_settings_form: + pattern: '/admin/config/services/twitter/settings' + defaults: + _form: '\Drupal\twitter\Form\TwitterSettingsForm' + requirements: + _permission: 'administer site configuration'