Project

General

Profile

« Previous | Next » 

Revision 72f6c7ee

Added by Francisco Revilla about 13 years ago

adding function absolute_path_to_drupal

View differences:

modules/cdm_dataportal/theme/cdm_dataportal.common.theme
12 12

  
13 13
define(FOOTNOTE_ANNOTATIONS, 'annotations');
14 14

  
15
/**
16
* Get the true path to the root of the Drupal site.
17
* Better than using DOCUMENT_ROOT and base_path().
18
*/
19
function absolute_path_to_drupal() {
20
    static $absolute_path_to_drupal = NULL;
21
    
22
    if ($absolute_path_to_drupal === NULL) {
23
        // Get the absolute path to this file:
24
        $dir = rtrim(str_replace('\\', '/', dirname(__FILE__)), '/');
25
        $parts = explode('/', $dir);
26
        // Iterate up the directory hierarchy until we find the website root:
27
        $done = FALSE;
28
        do{
29
            // Check a couple of obvious things:
30
            $done = is_dir("$dir/sites") && is_dir("$dir/includes") && is_file("$dir/index.php");
31
            if (!$done) {
32
                // If there's no more path to examine, we didn't find the site root:
33
                if (empty($parts)) {
34
                    $absolute_path_to_drupal = FALSE;
35
                    break;
36
                }
37
            // Go up one level and look again:
38
            array_pop($parts);
39
            $dir = implode('/', $parts);
40
            }
41
        }while (!$done);
42

  
43
        $absolute_path_to_drupal = $dir;
44
    }
45
    return $absolute_path_to_drupal;
46
}
47

  
15 48
function taxon_in_current_tree ($taxon_uuid) {
16 49
	$taxon_nodes = cdm_ws_get(CDM_WS_PORTAL_TAXON_TAXONNODES, $taxon_uuid);
17 50
	$taxon_in_current_tree = false;

Also available in: Unified diff