'./top_hat_dynamic/data', 'cache' => false, 'secure' => false, 'central_url' => 'http://oregonstate.edu/osuhomepage', 'central_path' => '/www/virtual/oregonstate.edu/osuhomepage', 'version' => '1.2', 'search_url' => 'http://search.oregonstate.edu', 'site_name' => '', 'site_domain' => 'oregonstate.edu', 'top_hat_border_color' => '#dbd6d0', 'top_hat_wrapper' => 'wrapper4', 'top_hat_search_box'=>true, 'top_hat_campaign_id' => '', 'top_hat_menu_links' => true, 'top_hat_disable_drupal_search' => false ); // Include the library file. We are using the default path for this, not the // central path from custom settings - we can't get settings until we load the library. // So, ALWAYS make sure that the default central path points to the location where // the osu_homepage library that was developed to go with this version of top-hat // lives. /* replaced with local library file include_once(substr(__FILE__, 0, strrpos(__FILE__, "/")) . '/../../../lib/' . $top_hat_default_settings['version'] . '/functions.php'); */ $new_data_path = dirname(__FILE__) . '/data'; $top_hat_default_settings['data_path'] = $new_data_path; $top_hat_default_settings['cache'] = 0; include_once(substr(__FILE__, 0, strrpos(__FILE__, "/")) . '/lib/' . $top_hat_default_settings['version'] . '/functions.php'); // get the settings $top_hat_settings = get_settings($top_hat_default_settings, $osu_home_settings); // set the cache filename $top_hat_cache_filename = 'top-hat-'.md5(serialize($top_hat_settings)); $osu_top_hat_html = ''; // if we are using cache, fetch it if($top_hat_settings['cache']) { $osu_top_hat_html = get_cache($top_hat_settings['data_path'], $top_hat_cache_filename); } // if we didn't get a cache file, render the top hat string if (empty($osu_top_hat_html)) { try { $osu_top_hat_html = generate_top_hat($top_hat_settings); if($top_hat_settings['cache']) { save_cache($top_hat_settings['data_path'], $top_hat_cache_filename, $osu_top_hat_html); } } catch (Exception $e) { // todo: add proper exception handling } } //echo the top hat string echo $osu_top_hat_html; /** * Displays the top hat region * * @param array $top_hat_settings - array of all current settings * @return string - fully rendered top hat html string * */ function generate_top_hat($top_hat_settings) { $border_color = $top_hat_settings['top_hat_border_color']; $wrapper = $top_hat_settings['top_hat_wrapper']; $site_name = $top_hat_settings['site_name']; $site_domain = $top_hat_settings['site_domain']; $drupal_search = !$top_hat_settings['top_hat_disable_drupal_search']; $url = $top_hat_settings['central_url']; $version = $top_hat_settings['version']; $tag_image_src = $url . '/regions/top-hat/' . $version . '/images/osu-tag.gif'; $top_hat_data = $top_hat_settings['data_path'] . '/top-hat-1.xml'; $top_hat_html = ''; // If a drupal site is including this file, ask Drupal for the site path. // and set some drupal specific items if ($drupal_search && is_drupal()) { global $base_url; $top_hat_html .= sprintf('', $base_url ); if (empty($site_domain)) { $site_domain = str_replace('http://', '', $base_url); $top_hat_settings['site_domain'] = $site_domain; } if (empty($top_hat_settings['site_name'])) { $site_name = variable_get('site_name', ''); $top_hat_settings['site_name'] = $site_name; } $search_this_site = true; } $top_hat_html .= sprintf('