public static function calculate_relative_path($file, $returnDir = false)
    {
        // We find the document root of the webserver
        $doc_root = $_SERVER['DOCUMENT_ROOT'];

        // Remove the document root, from the FULL absolute path of the
        // file we're looking for
        $ret = "/" . str_replace($doc_root, "", $file, $ok);
        if (!$ok) {
            return false;
        }

        // If they want the path to the dir, only return the dir part
        if ($returnDir) {
            $ret = dirname($ret) . "/";
        }

        $ret = preg_replace("|//|", "/", $ret);

        return $ret;
    }