From 05edae9a09b52f4e0aad5c1a6bdfa17eae4426cb Mon Sep 17 00:00:00 2001 From: ben Date: Mon, 16 Jun 2008 23:10:19 +0000 Subject: More intelligent context detection. Refs #32 git-svn-id: https://code.elgg.org/elgg/trunk@939 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/plugins.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'engine') diff --git a/engine/lib/plugins.php b/engine/lib/plugins.php index 036a2d5b9..f12ed3cac 100644 --- a/engine/lib/plugins.php +++ b/engine/lib/plugins.php @@ -51,16 +51,25 @@ * * @return string|false Plugin name, or false if no plugin name was called */ - function get_plugin_name() { - if ($backtrace = debug_backtrace()) { - foreach($backtrace as $step) { - $file = $step['file']; - $file = str_replace("\\","/",$file); - $file = str_replace("//","/",$file); - if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/",$file,$matches)) { - return $matches[1]; + function get_plugin_name($mainfilename = false) { + if (!$mainfilename) { + if ($backtrace = debug_backtrace()) { + foreach($backtrace as $step) { + $file = $step['file']; + $file = str_replace("\\","/",$file); + $file = str_replace("//","/",$file); + if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\/start\.php$/",$file,$matches)) { + return $matches[1]; + } } } + } else { + $file = $_SERVER["SCRIPT_NAME"]; + $file = str_replace("\\","/",$file); + $file = str_replace("//","/",$file); + if (preg_match("/mod\/([a-zA-Z0-9\-\_]*)\//",$file,$matches)) { + return $matches[1]; + } } return false; } -- cgit v1.2.3