You are here

function theme_ulogin_widget in uLogin (advanced version) 6

1 theme call to theme_ulogin_widget()
ulogin_elements in ./ulogin.module
Implements hook_elements().

File

./ulogin.module, line 223

Code

function theme_ulogin_widget($element) {
  $output = '';
  static $counter;
  if (!isset($counter)) {
    $counter = 0;

    //adding js only once

    /*if (variable_get('ulogin_load_type', 1)) {
        drupal_add_js(drupal_get_path('module', 'ulogin') . '/js/ulogin.async.js');
      }
      else {
        drupal_add_js('document.write(unescape("%3Cscript src=\'http://ulogin.ru/js/ulogin.js\' type=\'text/javascript\'%3E%3C/script%3E"));', 'inline');
      }*/
    drupal_add_js(drupal_get_path('module', 'ulogin') . '/js/ulogin.async.js');
  }
  $increment = FALSE;
  if ($element['#ulogin_id'] == 'uLogin') {
    $increment = TRUE;
    $counter++;
  }
  if (variable_get('ulogin_redirect', 0)) {
    $callback = 'Drupalulogintoken';
    $redirect = url('sites/all/libraries/ulogin/ulogin_xd.html', array(
      'absolute' => TRUE,
    ));
  }
  else {
    $callback = '';
    $redirect = _ulogin_token_url($element['#ulogin_destination']);
  }
  $id = $element['#ulogin_id'] . ($increment ? '-' . $counter : '');
  if ($element['#ulogin_display'] == 'small' || $element['#ulogin_display'] == 'panel') {
    $output = '<div ' . 'id="' . $id . '" ' . 'data-ulogin="display=' . $element['#ulogin_display'] . ';fields=' . $element['#ulogin_fields'] . ';optional=' . $element['#ulogin_optional'] . ';providers=' . $element['#ulogin_providers'] . ';hidden=' . $element['#ulogin_hidden'] . ';callback=' . $callback . ';redirect_uri=' . $redirect . '"></div>';
  }
  elseif ($element['#ulogin_display'] == 'window') {
    $output = '<a href="#" ' . 'id="' . $id . '" ' . 'data-ulogin="display=' . $element['#ulogin_display'] . ';fields=' . $element['#ulogin_fields'] . ';optional=' . $element['#ulogin_optional'] . ';callback=' . $callback . ';redirect_uri=' . $redirect . '"><img src="//ulogin.ru/img/button.png" width=187 height=30 alt="' . t('MultiAuthentication') . '"/></a>';
  }

  /*if (variable_get('ulogin_load_type', 1)) {
      drupal_add_js(array('ulogin' => array($id)), 'setting');
    }*/
  drupal_add_js(array(
    'ulogin' => array(
      $id,
    ),
  ), 'setting');
  return theme('form_element', $element, $output);
}