/**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions(array $base_plugin_definition)
 {
     include_once DRUPAL_ROOT . '/core/includes/language.inc';
     $info = language_types_info();
     $configurable_types = language_types_get_configurable();
     foreach ($configurable_types as $type) {
         $this->derivatives[$type] = $base_plugin_definition;
         $this->derivatives[$type]['admin_label'] = t('Language dropdown switcher (!type)', array('!type' => $info[$type]['name']));
         $this->derivatives[$type]['cache'] = DRUPAL_NO_CACHE;
     }
     // If there is just one configurable type then change the title of the
     // block.
     if (count($configurable_types) == 1) {
         $this->derivatives[reset($configurable_types)]['admin_label'] = t('Language dropdown switcher');
     }
     return parent::getDerivativeDefinitions($base_plugin_definition);
 }
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $language_code = check_plain($form_state['values']['lang_dropdown_select']);
     $type = $form_state['values']['lang_dropdown_type'];
     $tohome = $form_state['values']['lang_dropdown_tohome'];
     $language_codes = language_list();
     if (!array_key_exists($language_code, $language_codes)) {
         return;
     }
     $types = language_types_info();
     if (!array_key_exists($type, $types)) {
         return;
     }
     $path = drupal_is_front_page() ? '<front>' : current_path();
     $languages = language_negotiation_get_switch_links($type, $path);
     $language = $languages->links[$language_code];
     $newpath = isset($language['href']) && $tohome == 0 ? $language['href'] : '<front>';
     if (!isset($language['query'])) {
         $language['query'] = drupal_get_query_parameters();
     }
     $form_state['redirect'] = array($newpath, $language);
 }