url . $location; } // return new forward location or false to stop the forward or empty string to exit $params = array('current_url' => $current_page, 'forward_url' => $location); $location = trigger_plugin_hook('forward', 'system', $params, $location); if ($location) { header("Location: {$location}"); exit; } else if ($location === '') { exit; } } return false; } /** * Return the current page URL. */ function current_page_url() { global $CONFIG; $url = parse_url($CONFIG->wwwroot); $page = $url['scheme'] . "://"; // user/pass if ((isset($url['user'])) && ($url['user'])) { $page .= $url['user']; } if ((isset($url['pass'])) && ($url['pass'])) { $page .= ":".$url['pass']; } if ((isset($url['user']) && $url['user']) || (isset($url['pass']) && $url['pass'])) { $page .="@"; } $page .= $url['host']; if ((isset($url['port'])) && ($url['port'])) { $page .= ":" . $url['port']; } //$page.="/"; $page = trim($page, "/"); $page .= $_SERVER['REQUEST_URI']; return $page; } /** * This is a factory function which produces an ElggCache object suitable for caching file load paths. * * @todo Can this be done in a cleaner way? * @todo Swap to memcache etc? */ function elgg_get_filepath_cache() { global $CONFIG; static $FILE_PATH_CACHE; if (!$FILE_PATH_CACHE) $FILE_PATH_CACHE = new ElggFileCache($CONFIG->dataroot); return $FILE_PATH_CACHE; } /** * Function which resets the file path cache. * */ function elgg_filepath_cache_reset() { $cache = elgg_get_filepath_cache(); return $cache->delete('view_paths'); } /** * Saves a filepath cache. * * @param mixed $data */ function elgg_filepath_cache_save($data) { global $CONFIG; if ($CONFIG->viewpath_cache_enabled) { $cache = elgg_get_filepath_cache(); return $cache->save('view_paths', $data); } return false; } /** * Retrieve the contents of the filepath cache. * */ function elgg_filepath_cache_load() { global $CONFIG; if ($CONFIG->viewpath_cache_enabled) { $cache = elgg_get_filepath_cache(); $cached_view_paths = $cache->load('view_paths'); if ($cached_view_paths) { return $cached_view_paths; } } return NULL; } /** * Enable the filepath cache. * */ function elgg_enable_filepath_cache() { global $CONFIG; datalist_set('viewpath_cache_enabled',1); $CONFIG->viewpath_cache_enabled = 1; elgg_filepath_cache_reset(); } /** * Disable filepath cache. * */ function elgg_disable_filepath_cache() { global $CONFIG; datalist_set('viewpath_cache_enabled',0); $CONFIG->viewpath_cache_enabled = 0; elgg_filepath_cache_reset(); } /** * Deprecated by elgg_add_submenu_item() * * @see elgg_add_submenu_item() * @deprecated 1.8 */ function add_submenu_item($label, $link, $group = 'default', $onclick = false, $selected = NULL) { elgg_deprecated_notice('add_submenu_item was deprecated by elgg_add_submenu_item', 1.8); $item = array( 'text' => $label, 'href' => $link, 'selected' => $selected ); if (!$group) { $group = 'default'; } if ($onclick) { $js = "onclick=\"javascript:return confirm('". elgg_echo('deleteconfirm') . "')\""; $item['vars'] = array('js' => $js); } // submenu items were added in the page setup hook usually by checking // the context. We'll pass in the current context here, which will // emulate that effect. // if context == 'main' (default) it probably means they always wanted // the menu item to show up everywhere. $context = get_context(); if ($context == 'main') { $context = 'all'; } return elgg_add_submenu_item($item, $context, $group); } /** * Add an entry to the submenu. * * @param array $item The item as array( * 'title' => 'Text to display', * 'url' => 'URL of the link', * 'id' => 'entry_unique_id' //used by children items to identify parents * 'parent_id' => 'id_of_parent', * 'selected' => BOOL // Is this item selected? (If NULL or unset will attempt to guess) * 'vars' => array() // Array of vars to pass to the navigation/submenu_item view * ) * * @param string $context Context in which to display this menu item. 'all' will make it show up all the time. Use sparingly. * @param string $group Group for the item. Each submenu group has its own