You are here

function _disclaimer_get_content in Disclaimer 6

Same name and namespace in other branches
  1. 6.2 disclaimer.module \_disclaimer_get_content()

Generate disclaimer content

1 call to _disclaimer_get_content()
disclaimer_admin_settings in ./disclaimer.admin.inc
1 string reference to '_disclaimer_get_content'
disclaimer_menu in ./disclaimer.module
Implementation of hook_menu().

File

./disclaimer.module, line 96
Create and show disclaimer for your site. Visotors need js enabled and accept cookie

Code

function _disclaimer_get_content() {
  $action_type = variable_get('disclaimer_action_type', 'text');
  $exit_url = variable_get('disclaimer_exit_url', 'http://www.google.com');
  $enter_url = variable_get('disclaimer_enter_url', '');
  $nid = variable_get('disclaimer_node', '');
  $nid_footer = variable_get('disclaimer_node_footer', '');
  $age = variable_get('disclaimer_age_form', 0);
  $age_limit = variable_get('disclaimer_age_limit', 18);
  $modal = variable_get('disclaimer_modal', 'thickbox');
  $js = '';
  switch ($action_type) {
    case "image":
      $enter_alt = variable_get('disclaimer_enter_img_alt', t('ENTER'));
      $exit_alt = variable_get('disclaimer_exit_img_alt', t('EXIT'));
      $enter = theme('image', variable_get('disclaimer_enter_img_path', FALSE), $enter_alt, $enter_alt);
      $exit = theme('image', variable_get('disclaimer_exit_img_path', FALSE), $exit_alt, $exit_alt);
      break;
    default:
      $enter = variable_get('disclaimer_enter_txt', t('ENTER'));
      $exit = variable_get('disclaimer_exit_txt', t('EXIT'));
  }
  if ($age == 1) {
    $age_form = drupal_get_form('disclaimer_age_form');
    $rows[] = array(
      array(
        'data' => $age_form,
        'align' => 'center',
        'colspan' => '2',
      ),
    );
    $js = "CheckAge('" . variable_get('disclaimer_cookie_name', 'disclaimerShow') . "', " . $age_limit . ", '" . $exit_url . "', '" . $modal . "');";
  }
  else {
    $js = 'WriteCookie(\'' . variable_get('disclaimer_cookie_name', 'disclaimerShow') . '\', \'1\');';
    switch ($modal) {
      case 'nyroModal':
        $js .= '$.nyroModalRemove();';
        break;
      case 'jqModal':
        $js .= '$(\'#disclaimer\').jqmHide();';
        break;
      case 'thickbox':
        $js .= 'tb_remove();';
        break;
    }
  }
  if ($enter_url) {
    $enter = l($enter, $enter_url, array(
      'attributes' => array(
        'onclick' => $js,
      ),
      'html' => TRUE,
    ));
  }
  else {
    $enter = '<a href="javascript:void(0);" onclick="' . $js . '">' . $enter . '</a>';
  }
  $exit = l($exit, $exit_url, array(
    'html' => TRUE,
  ));
  $rows[] = array(
    array(
      'data' => $enter,
      'align' => 'center',
    ),
    array(
      'data' => $exit,
      'align' => 'center',
    ),
  );
  if ($nid == 0) {
    $output = check_markup(variable_get('disclaimer_content', ''), variable_get('disclaimer_content_format', 1), FALSE);
  }
  else {
    $output = node_view(node_load($nid), FALSE, TRUE);
  }
  $output .= theme('table', array(), $rows);
  if ($nid_footer == 0) {
    $output .= check_markup(variable_get('disclaimer_content_footer', ''), variable_get('disclaimer_content_footer_format', 1), FALSE);
  }
  else {
    $output .= node_view(node_load($nid_footer), FALSE, TRUE);
  }
  return $output;
}