[Mapbender-commits] r10123 - trunk/mapbender/http/php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue May 14 03:28:13 PDT 2019
Author: armin11
Date: 2019-05-14 03:28:13 -0700 (Tue, 14 May 2019)
New Revision: 10123
Modified:
trunk/mapbender/http/php/mod_showOrganizationList.php
trunk/mapbender/http/php/tagCloud.php
Log:
Option for sorting organization list - rank (number of resources), id, title. More info in INSPIRE thematic information.
Modified: trunk/mapbender/http/php/mod_showOrganizationList.php
===================================================================
--- trunk/mapbender/http/php/mod_showOrganizationList.php 2019-05-14 09:51:37 UTC (rev 10122)
+++ trunk/mapbender/http/php/mod_showOrganizationList.php 2019-05-14 10:28:13 UTC (rev 10123)
@@ -1,9 +1,19 @@
<?php
//server component to pull statistics FROM geoportal catalogue
require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-
+$orderBy = 'rank';
+if (isset($_REQUEST["orderBy"]) & $_REQUEST["orderBy"] != "") {
+ $testMatch = $_REQUEST["orderBy"];
+ if (!($testMatch == 'rank' or $testMatch == 'title' or $testMatch == 'id' or $testMatch == 'date')){
+ //echo 'orderBy: <b>'.$testMatch.'</b> is not valid.<br/>';
+ echo 'Parameter <b>orderBy</b> is not valid (rank,title,id,date).<br/>';
+ die();
+ }
+ $orderBy = $testMatch;
+ $testMatch = NULL;
+}
$sql = <<<SQL
-SELECT published_resources.*, mb_group_name, mb_group_description, mb_group_logo_path, mb_group_title, uuid FROM (
+SELECT published_resources.*, datasets+featuretypes+layers+wmcs as all_resources, mb_group_name, mb_group_description, mb_group_logo_path, mb_group_title, mb_group_homepage, uuid FROM (
SELECT SUM(dataset_count) AS datasets, SUM(featuretype_count) AS featuretypes, SUM(layer_count) AS layers, SUM(wmc_count) AS wmcs, mb_group_id FROM (
SELECT 0 AS dataset_count, 0 AS featuretype_count, resource_count AS layer_count, 0 AS wmc_count, mb_group_id FROM (
@@ -47,10 +57,23 @@
) AS owner_wmc INNER JOIN mb_user_mb_group on owner_wmc.fkey_user_id = mb_user_mb_group.fkey_mb_user_id WHERE mb_user_mb_group_type = 2 ) AS published_wmc GROUP BY fkey_mb_group_id
) AS resources GROUP BY mb_group_id ) AS published_resources INNER JOIN mb_group on published_resources.mb_group_id = mb_group.mb_group_id
-ORDER BY mb_group_name DESC
SQL;
-//order by - group_id, group_name, group_title
+switch ($orderBy) {
+ case "rank":
+ $sql .= " ORDER BY all_resources DESC";
+ break;
+ case "id":
+ $sql .= " ORDER BY mb_group_id ASC";
+ break;
+ case "title":
+ $sql .= " ORDER BY mb_group_name ASC";
+ break;
+ default:
+ $sql .= " ORDER BY mb_group_name ASC";
+ break;
+}
+
//...
$v = array();
$t = array();
@@ -66,10 +89,12 @@
$jsonOutput->organizations[$numberOfOrgas]->{'title_long'} = $row['mb_group_title'];
$jsonOutput->organizations[$numberOfOrgas]->{'image_display_url'} = $row['mb_group_logo_path'];
$jsonOutput->organizations[$numberOfOrgas]->{'detail_url'} = '../mod_showOrganizationInfo.php?id='.$row['mb_group_id'].'&outputFormat=ckan';
+ $jsonOutput->organizations[$numberOfOrgas]->{'homepage'} = $row['mb_group_homepage'];
$jsonOutput->organizations[$numberOfOrgas]->{'datasets'} = $row['datasets'];
$jsonOutput->organizations[$numberOfOrgas]->{'layers'} = $row['layers'];
$jsonOutput->organizations[$numberOfOrgas]->{'featuretypes'} = $row['featuretypes'];
$jsonOutput->organizations[$numberOfOrgas]->{'wmcs'} = $row['wmcs'];
+ $jsonOutput->organizations[$numberOfOrgas]->{'all_resources'} = $row['all_resources'];
$numberOfOrgas++;
}
$json = json_encode($jsonOutput);
Modified: trunk/mapbender/http/php/tagCloud.php
===================================================================
--- trunk/mapbender/http/php/tagCloud.php 2019-05-14 09:51:37 UTC (rev 10122)
+++ trunk/mapbender/http/php/tagCloud.php 2019-05-14 10:28:13 UTC (rev 10123)
@@ -176,7 +176,7 @@
$tags[$i] = array('weight' =>$row['sum'], 'tagname' =>$row[$showName], 'url'=>'http://'.$hostName.$pathToSearchScript.urlencode('searchText=*&resultTarget=file&outputFormat=json&isoCategories='.$row['md_topic_category_id'].'&languageCode='.$languageCode));
}
if ($type == 'inspireCategories') {
- $tags[$i] = array('weight' =>$row['sum'], 'tagname' =>$row[$showName], 'url'=>'http://'.$hostName.$pathToSearchScript.urlencode('searchText=*&resultTarget=file&outputFormat=json&inspireCategories='.$row[$categoryFilter.'_id'].'&languageCode='.$languageCode), 'description'=>$row[$categoryFilter.'_description_'.$languageCode], 'info'=>$row[$categoryFilter.'_uri']);
+ $tags[$i] = array('weight' =>$row['sum'], 'tagname' =>$row[$showName], 'url'=>'http://'.$hostName.$pathToSearchScript.urlencode('searchText=*&resultTarget=file&outputFormat=json&inspireCategories='.$row[$categoryFilter.'_id'].'&languageCode='.$languageCode), 'description'=>$row[$categoryFilter.'_description_'.$languageCode], 'info'=>$row[$categoryFilter.'_uri'], 'mbId'=>$row[$categoryFilter.'_id']);
}
if ($type == 'keywords') {
@@ -242,11 +242,14 @@
$tagCloudJSON->tagCloud->tags[$i]->title = $tags[$i]['tagname'];
$tagCloudJSON->tagCloud->tags[$i]->url = $tags[$i]['url'];
$tagCloudJSON->tagCloud->tags[$i]->weight = $tags[$i]['weight'];
+ $tagCloudJSON->tagCloud->tags[$i]->id = $tags[$i]['mbId'];
+
if ($type == 'inspireCategories') {
- $tagCloudJSON->tagCloud->tags[$i]->info = $tags[$i]['info'];
+ $tagCloudJSON->tagCloud->tags[$i]->info = $tags[$i]['info'];
+ $tagCloudJSON->tagCloud->tags[$i]->inspireThemeId = end(explode('/', $tagCloudJSON->tagCloud->tags[$i]->info));
$tagCloudJSON->tagCloud->tags[$i]->description = $tags[$i]['description'];
//symbol
- $tagCloudJSON->tagCloud->tags[$i]->symbolUrl = MAPBENDER_PATH."/img/INSPIRE-themes-icons-master/svg/".end(explode('/', $tagCloudJSON->tagCloud->tags[$i]->info)).".svg";
+ $tagCloudJSON->tagCloud->tags[$i]->symbolUrl = MAPBENDER_PATH."/img/INSPIRE-themes-icons-master/svg/".$tagCloudJSON->tagCloud->tags[$i]->inspireThemeId.".svg";
}
}
#echo "json";
More information about the Mapbender_commits
mailing list