]> git.openstreetmap.org Git - nominatim.git/blobdiff - utils/specialphrases.php
Black/whitelisting for special phrases
[nominatim.git] / utils / specialphrases.php
index 1c3eff5b497be3dd02c10478259829fe2d6885b0..b2f336c7626b93596d471cf095783c04cf766641 100755 (executable)
         );
         getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
 
-       $aLanguageIn = array(
-                       'af',
-                       'ar',
-                       'br',
-                       'ca',
-                       'cs',
-                       'de',
-                       'en',
-                       'es',
-                       'et',
-                       'eu',
-                       'fa',
-                       'fi',
-                       'fr',
-                       'gl',
-                       'hr',
-                       'hu',
-                       'ia',
-                       'is',
-                       'it',
-                       'ja',
-                       'mk',
-                       'nl',
-                       'no',
-                       'pl',
-                       'ps',
-                       'pt',
-                       'ru',
-                       'sk',
-                       'sv',
-                       'uk',
-                       'vi',
-               );
 
     if ($aCMDResult['countries']) {
         echo "select getorcreate_country(make_standard_name('uk'), 'gb');\n";
@@ -63,6 +30,7 @@
 
        if ($aCMDResult['wiki-import'])
        {
+               include(CONST_BasePath.'/settings/phrase_settings.php');
                $aPairs = array();
 
                foreach($aLanguageIn as $sLanguage)
                                                preg_match('/^\\w+$/', $sType) < 1) {
                                                trigger_error("Bad class/type for language $sLanguage: $sClass=$sType");
                                                exit;
-                                       }       
+                                       }
+                                       # blacklisting: disallow certain class/type combinations
+                                       if (isset($aTagsBlacklist[$sClass]) && in_array($sType, $aTagsBlacklist[$sClass])) {
+                                               # fwrite(STDERR, "Blacklisted: ".$sClass."/".$sType."\n");
+                                               continue;
+                                       }
+                                       # whitelisting: if class is in whitelist, allow only tags in the list
+                                       if (isset($aTagsWhitelist[$sClass])     && !in_array($sType, $aTagsWhitelist[$sClass])) {
+                                               # fwrite(STDERR, "Non-Whitelisted: ".$sClass."/".$sType."\n");
+                                               continue;
+                                       }
                                        $aPairs[$sClass.'|'.$sType] = array($sClass, $sType);
 
                                        switch(trim($aMatch[4]))