/** * Returns the page namespace based on the current URL. * A few examples: * * /login * /publish * /blueprints/datasources * [...] * /extension/$extension_name/$page_name * * This method is especially useful in couple with the translation function. * * @see toolkit#__() * @return string * The page namespace, without any action string (e.g. "new", "saved") or * any value that depends upon the single setup (e.g. the section handle in * /publish/$handle) */ public static function getPageNamespace() { if (self::$namespace !== false) { return self::$namespace; } $page = getCurrentPage(); if (!is_null($page)) { $page = trim($page, '/'); } if (substr($page, 0, 7) == 'publish') { self::$namespace = '/publish'; } else { if (empty($page) && isset($_REQUEST['mode'])) { self::$namespace = '/login'; } else { if (empty($page)) { self::$namespace = null; } else { $bits = explode('/', $page); if ($bits[0] == 'extension') { self::$namespace = sprintf('/%s/%s/%s', $bits[0], $bits[1], $bits[2]); } else { self::$namespace = sprintf('/%s/%s', $bits[0], $bits[1]); } } } } return self::$namespace; }