\n")); // This is needed since the $user object is already destructed in _boost_ob_handler(): define('BOOST_USER_ID', @$GLOBALS['user']->uid); ////////////////////////////////////////////////////////////////////////////// // Core API hooks /** * Implementation of hook_help(). Provides online user help. */ function boost_help($path, $arg) { switch ($path) { case 'admin/help#boost': if (file_exists($file = drupal_get_path('module', 'boost') . '/README.txt')) { return '
' . implode("\n", array_slice(explode("\n", @file_get_contents($file)), 2)) . ''; } break; case 'admin/settings/performance/boost': return '
' . t('') . '
'; // TODO: add help text. } //hack to get drupal_get_messages before they are destroyed. $GLOBALS['_boost_message_count'] = count(drupal_get_messages(NULL, FALSE)); } /** * Implementation of hook_init(). Performs page setup tasks if page not cached. */ function boost_init() { global $user, $base_path; //set variables $GLOBALS['_boost_path'] = $_REQUEST['q']; // Make the proper filename for our query $GLOBALS['_boost_query'] = '_'; foreach ($_GET as $key => $val) { if ($key != 'q') { $GLOBALS['_boost_query'] .= (($GLOBALS['_boost_query'] == '_') ? '' : '&') . $key . '=' . $val; } } // Make sure the page is/should be cached according to our current configuration if ( strpos($_SERVER['SCRIPT_FILENAME'], 'index.php') === FALSE || variable_get('site_offline', 0) || $_SERVER['REQUEST_METHOD'] != 'GET' || $_SERVER['SERVER_SOFTWARE'] === 'PHP CLI' || !BOOST_ENABLED || isset($_GET['nocache']) || !boost_is_cacheable($GLOBALS['_boost_path']) ) { return; } // For authenticated users, set a special cookie to prevent them // inadvertently getting served pages from the static page cache. if (!empty($user->uid)) { boost_set_cookie($user); } // We only generate cached pages for anonymous visitors. else { if (BOOST_ENABLED != CACHE_AGGRESSIVE) { $GLOBALS['conf']['cache'] = CACHE_DISABLED; } ob_start('_boost_ob_handler'); } } /** * Implementation of hook_preprocess_page(). * * Grab references to css/js files. */ function boost_preprocess_page(&$variables) { $GLOBALS['_boost_styles'] = $variables['styles']; $GLOBALS['_boost_scripts'] = $variables['scripts']; } /** * Implementation of hook_footer(). * * Place boost stat counter image into pages footer. * * NOTE HTML code could be added to the $buffer directly, right before