You are here

function cleantalk_page_build in Anti Spam by CleanTalk 8

Same name and namespace in other branches
  1. 7 cleantalk.module \cleantalk_page_build()
  2. 7.2 cleantalk.module \cleantalk_page_build()

File

./cleantalk.module, line 183
Main CleanTalk integration module functions.

Code

function cleantalk_page_build(&$page) {
  drupal_session_initialize();
  drupal_save_session(true);
  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    $_SESSION['ct_submit_comment_time'] = REQUEST_TIME;
    $_SESSION['ct_submit_register_time'] = REQUEST_TIME;
  }
  $ct_check_def = '0';
  $ct_check_value = _cleantalk_get_checkjs_value();
  $js_template = 'function ctSetCookie(c_name, value, def_value) {
  document.cookie = c_name + "=" + escape(value.replace(/^def_value$/, value)) + "; path=/";
}
setTimeout("ctSetCookie(\\"%s\\", \\"%s\\", \\"%s\\");",1000);';
  $js_addon_body = sprintf($js_template, 'ct_checkjs', $ct_check_value, $ct_check_def);

  // @FIXME
  // The Assets API has totally changed. CSS, JavaScript, and libraries are now
  // attached directly to render arrays using the #attached property.
  //
  //
  // @see https://www.drupal.org/node/2169605
  // @see https://www.drupal.org/node/2408597
  // drupal_add_js($js_addon_body,
  //     array(
  //       'type' => 'inline',
  //       'scope' => 'footer',
  //       'weight' => 5,
  //       'cache' => FALSE,
  //       'every_page' => TRUE,
  //     )
  //   );
}