public static function getThemes($query, $query_args) { $themeTree = $GLOBALS['themeTree']; $layersCheckedThemes = $GLOBALS['layersCheckedThemes']; $arr_theme = array(); $i = 0; $result_theme = db_query($query, $query_args); if(!$result_theme) { //Error occured $errmsgstr = $GLOBALS['errmsgstr']; die('Error fetching themes. ' . $errmsgstr); } else { while($theme_obj = db_fetch_object($result_theme)) { $theme_id = $theme_obj->theme_id; if ($theme_obj->theme_type == 1) { $imgUrl = './'.path_to_theme().'/images/icons/theme-'. $theme_obj->icon .'.png' ; if(file_exists($imgUrl)) { //switch case to add mouse over text for the themes switch($theme_obj->theme_name) { case "Abiotic": $tooltip = "Soil, water, climate"; break; case "Administrative Units": $tooltip = "Administrative units"; break; case "Biogeography": $tooltip = "Biogeographical units"; break; case "Conservation": $tooltip = "Conservation areas"; break; case "Demography": $tooltip = "Census and population distribution"; break; case "Land Use Land Cover": $tooltip = "Land use land cover"; break; case "Species": $tooltip = "Species distribution"; break; case "General": $tooltip = "General sandbox"; break; } $arr_theme[$i]["text"] = '<table cellspacing="0" style="border-collapse:separate;"><tr><td><div class="LayerTreeElem"><img src="'. $imgUrl .'"" alt="'.$theme_obj->theme_name.'" /></div></td><td><div class="LayerTreeElem"><b title="' . $tooltip . '">'. str_replace(" ", " ", $theme_obj->theme_name) .'</b>'; } else { $arr_theme[$i]["text"] = '<table cellspacing="0" style="border-collapse:separate;"><tr><td><div class="LayerTreeElem"><b>'. str_replace(" ", " ", $theme_obj->theme_name) .'</b>'; } } else { $arr_theme[$i]["text"] = '<table cellspacing="0" style="border-collapse:separate;"><tr><td><div class="LayerTreeElem"><b>'. str_replace(" ", " ", $theme_obj->theme_name) .'</b>'; } $arr_theme[$i]["text"] .= " (".$theme_obj->layer_count.")</div></td></tr></table>"; $arr_theme[$i]["id"]= $theme_id; $arr_theme[$i]["title"] = $theme_obj->theme_name; if((isset($themeTree[$theme_id]) && ($themeTree[$theme_id] == 1)) || in_array($theme_id, $layersCheckedThemes) ) { $arr_theme[$i]['expanded'] = true; $arr_theme[$i]["children"] = array_merge(getSubThemes($theme_id), getLayersForTheme($theme_id)); } else { $arr_theme[$i]["hasChildren"] = true; } $i++; } } return $arr_theme; }
function getTheme($theme_type,$themeTree,$source) { $layersCheckedThemes = array(); if(count($layersChecked) > 0) { $query = <<<EOF SELECT DISTINCT theme_id FROM "Theme_Layer_Mapping" WHERE layer_id IN (SELECT layer_id FROM "Meta_Layer" WHERE layer_tablename IN ( EOF; $arr = $layersChecked; array_walk($arr, "quoteString"); $query .= implode(",", $arr); $query .= "))"; $result_theme = db_query($query); if(!$result_theme) { //Error occured $errmsgstr = $GLOBALS['errmsgstr']; die('Error fetching layers. ' . $errmsgstr); } else { while($theme_obj = db_fetch_object($result_theme)) { $layersCheckedThemes[] = $theme_obj->theme_id; } } } $arr_theme = array(); switch ($theme_type) { case 1: case 2: if ($source == "source") { $arr_theme = getSource($theme_type); } else { $theme_id = $source; $arr_theme = array_merge(getSubThemes($theme_id), getLayersForTheme($theme_id)); } break; case 3: $arr_theme = getParticipatoryLayers(); break; case 6: $arr_theme = getInactiveLayers(); break; } $str = json_encode($arr_theme); return $str; }
require_once('metadata_themelayermapping.php'); getThemeMapping($responseDoc, $rootNode, $requestDoc->getElementsByTagName('params')->item(0)); break; case 'saveThemeMapping': require_once('metadata_themelayermapping.php'); saveThemeMapping($responseDoc, $rootNode, $requestDoc->getElementsByTagName('params')->item(0)); break; case 'getLayersForGroupType': $paramsNode = $requestDoc->getElementsByTagName('params')->item(0); $group_type = $paramsNode->getElementsByTagName('group_type')->item(0)->nodeValue; if($group_type == null || $group_type == '') { die(sendErrorResponse("Required parameters are not set.")); } if($group_type == 1 || $group_type == 2) { require_once('metadata_themelayermapping.php'); getLayersForTheme($responseDoc, $rootNode, $paramsNode); } else { require_once('metadata_layer.php'); getLayersOfType($responseDoc, $rootNode, $group_type); } break; case 'getLinkTables': require_once('metadata_link.php'); getLinkTables($responseDoc, $rootNode, $requestDoc->getElementsByTagName('params')->item(0)); break; case 'getMetaLinkTable': require_once('metadata_link.php'); getMetaLinkTable($responseDoc, $rootNode, $requestDoc->getElementsByTagName('params')->item(0)); break; case 'saveMetaLinkTable': require_once('metadata_link.php');