Skip to content

Commit

Permalink
New CACHE TYPES
Browse files Browse the repository at this point in the history
Stage 2: code additions and changes
Reference: opencaching#860
Reference: opencaching#2024

- modified lib/cache.php definitions (old, but still used)
- modified GeoCacheCommons.php model
- modified translations (en first)
- new types are forbidden by default lib/settingsDefault.inc.php
- partial modification src/Views/mainMap/mainMapFilters.tpl.php
  • Loading branch information
andrixnet committed Jul 3, 2019
1 parent 9c5f0c5 commit 821d08d
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 51 deletions.
63 changes: 44 additions & 19 deletions lib/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,20 @@
final class cache
{

const TYPE_OTHERTYPE = 1;
const TYPE_TRADITIONAL = 2;
const TYPE_MULTICACHE = 3;
const TYPE_VIRTUAL = 4;
const TYPE_WEBCAM = 5;
const TYPE_EVENT = 6;
const TYPE_QUIZ = 7;
const TYPE_MOVING = 8;
const TYPE_GEOPATHFINAL = 9;
const TYPE_OWNCACHE = 10;
const TYPE_OTHERTYPE = 1;
const TYPE_TRADITIONAL = 2;
const TYPE_MULTICACHE = 3;
const TYPE_VIRTUAL = 4;
const TYPE_WEBCAM = 5;
const TYPE_EVENT = 6;
const TYPE_QUIZ = 7;
const TYPE_MOVING = 20;
const TYPE_GEOPATHFINAL = 21;
const TYPE_OWNCACHE = 22;
const TYPE_GUESTBOOK = 23;
const TYPE_BITCACHE = 24;
const TYPE_BENCHMARK = 25;
const TYPE_CHALLENGE = 26;

const SIZE_MICRO = 2;
const SIZE_SMALL = 3;
Expand Down Expand Up @@ -59,27 +63,27 @@ final class cache
self::TYPE_OTHERTYPE => array(
'name' => 'other',
'icon' => 'unknown.png',
'translation' => 'cacheType_5'
'translation' => 'cacheType_1'
),
self::TYPE_TRADITIONAL => array(
'name' => 'traditional',
'icon' => 'traditional.png',
'translation' => 'cacheType_1'
'translation' => 'cacheType_2'
),
self::TYPE_MULTICACHE => array(
'name' => 'multicache',
'icon' => 'multi.png',
'translation' => 'cacheType_2',
'translation' => 'cacheType_3',
),
self::TYPE_VIRTUAL => array(
'name' => 'virtual',
'icon' => 'virtual.png',
'translation' => 'cacheType_8'
'translation' => 'cacheType_4'
),
self::TYPE_WEBCAM => array(
'name' => 'webcam',
'icon' => 'webcam.png',
'translation' => 'cacheType_7'
'translation' => 'cacheType_5'
),
self::TYPE_EVENT => array(
'name' => 'event',
Expand All @@ -89,22 +93,43 @@ final class cache
self::TYPE_QUIZ => array(
'name' => 'quiz',
'icon' => 'quiz.png',
'translation' => 'cacheType_3'
'translation' => 'cacheType_7'
),
self::TYPE_MOVING => array(
'name' => 'moving',
'icon' => 'moving.png',
'translation' => 'cacheType_4'
'translation' => 'cacheType_20'
),
self::TYPE_GEOPATHFINAL => array(
'name' => 'podcast',
'icon' => 'podcache.png',
'translation' => 'cacheType_9'
'translation' => 'cacheType_21'
),
self::TYPE_OWNCACHE => array(
'name' => 'own-cache',
'icon' => 'owncache.png',
'translation' => 'cacheType_10',
'translation' => 'cacheType_22',
),

self::TYPE_GUESTBOOK => array(
'name' => 'guestbook',
'icon' => 'guestbook.png',
'translation' => 'cacheType_23',
),
self::TYPE_BITCACHE => array(
'name' => 'bit-cache',
'icon' => 'bitcache.png',
'translation' => 'cacheType_24',
),
self::TYPE_BENCHMARK => array(
'name' => 'benchmark',
'icon' => 'benchmark.png',
'translation' => 'cacheType_25',
),
self::TYPE_CHALLENGE => array(
'name' => 'challenge',
'icon' => 'challenge.png',
'translation' => 'cacheType_26',
),
);
private static $iconPath = 'images/cache/';
Expand Down
30 changes: 21 additions & 9 deletions lib/languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'map_excludeOwned' => 'Owned',
'sort_by' => 'Sort by',
'map_excludeCachesByType' => 'Hide caches by type',

'unknown_type' => 'Other type',
'traditional' => 'Traditional',
'multicache' => 'Multicache',
Expand All @@ -64,6 +65,7 @@
'map_exWithoutRecomendation' => 'Without recommendation',
'map_biggerSizeThan' => 'only bigger than',
'map_sizeAny' => 'any size',

'map_otherType' => 'Other type',
'map_traditionalType' => 'Traditional',
'map_multicacheType' => 'Multicache',
Expand All @@ -73,6 +75,11 @@
'map_quizType' => 'Puzzle',
'map_movingType' => 'Moving',
'map_owncacheType' => 'Owncache',
'map_guestbookType' => 'Guestbook',
'map_bitcacheType' => 'BIT cache',
'map_benchmarkType' => 'Benchmark',
'map_challengeType' => 'Challenge',

'map_incorectMapParams' => 'Incorrect map params - default map is presented!',
'map_circle150mMode' => 'Circle with radius 150m for given location',
'map_searchResultsMode' => 'Map presents only the results of geocaches search query',
Expand Down Expand Up @@ -1868,16 +1875,21 @@
'region_04' => 'Region found by Google Maps',
'region_mapQuest' => 'Region found by MapQuest API',

'cacheType_1' => 'Traditional',
'cacheType_2' => 'Multicache',
'cacheType_3' => 'Puzzle',
'cacheType_4' => 'Moving',
'cacheType_5' => 'Other type',
'cacheType_1' => 'Other type',
'cacheType_2' => 'Traditional',
'cacheType_3' => 'Multicache',
'cacheType_4' => 'Virtual',
'cacheType_5' => 'Webcam',
'cacheType_6' => 'Event',
'cacheType_7' => 'Webcam',
'cacheType_8' => 'Virtual',
'cacheType_9' => 'Podcast cache',
'cacheType_10' => 'Own cache',
'cacheType_7' => 'Quiz',
'cacheType_20' => 'Moving',
'cacheType_21' => 'GeoPath FINAL',
'cacheType_22' => 'Own cache',
'cacheType_23' => 'Guestbook',
'cacheType_24' => 'BIT cache',
'cacheType_25' => 'Benchmark',
'cacheType_26' => 'Challenge',

'cacheSize_nano' => 'Nano',
'cacheSize_micro' => 'Micro',
'cacheSize_small' => 'Small',
Expand Down
6 changes: 5 additions & 1 deletion lib/settingsDefault.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@
'forbidenCacheTypes' => array(
cache::TYPE_VIRTUAL,
cache::TYPE_WEBCAM,
cache::TYPE_GEOPATHFINAL
cache::TYPE_GEOPATHFINAL,
cache::TYPE_GUESTBOOK,
cache::TYPE_BITCACHE,
cache::TYPE_BENCHMARK,
cache::TYPE_CHALLENGE
),
/**
* cache limits for user. If user is allowed to place limited nomber of specified cache type,
Expand Down
84 changes: 62 additions & 22 deletions src/Models/GeoCache/GeoCacheCommons.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,20 @@

class GeoCacheCommons extends BaseObject {

const TYPE_OTHERTYPE = 1;
const TYPE_TRADITIONAL = 2;
const TYPE_MULTICACHE = 3;
const TYPE_VIRTUAL = 4;
const TYPE_WEBCAM = 5;
const TYPE_EVENT = 6;
const TYPE_QUIZ = 7;
const TYPE_MOVING = 8;
const TYPE_GEOPATHFINAL = 9; //TODO: old -podcast- type?
const TYPE_OWNCACHE = 10;
const TYPE_OTHERTYPE = 1;
const TYPE_TRADITIONAL = 2;
const TYPE_MULTICACHE = 3;
const TYPE_VIRTUAL = 4;
const TYPE_WEBCAM = 5;
const TYPE_EVENT = 6;
const TYPE_QUIZ = 7;
const TYPE_MOVING = 20;
const TYPE_GEOPATHFINAL = 21; //TODO: old -podcast- type?
const TYPE_OWNCACHE = 22;
const TYPE_GUESTBOOK = 23;
const TYPE_BITCACHE = 24;
const TYPE_BENCHMARK = 25;
const TYPE_CHALLENGE = 26;

const STATUS_READY = 1;
const STATUS_UNAVAILABLE = 2;
Expand All @@ -47,16 +51,21 @@ class GeoCacheCommons extends BaseObject {

const ICON_PATH = '/images/cache/'; //path to the dir with cache icons

const TYPE_TRADITIONAL_TR_KEY = 'cacheType_1';
const TYPE_OTHERTYPE_TR_KEY = 'cacheType_5';
const TYPE_MULTICACHE_TR_KEY = 'cacheType_2';
const TYPE_VIRTUAL_TR_KEY = 'cacheType_8';
const TYPE_WEBCAM_TR_KEY = 'cacheType_7';
const TYPE_OTHERTYPE_TR_KEY = 'cacheType_1';
const TYPE_TRADITIONAL_TR_KEY = 'cacheType_2';
const TYPE_MULTICACHE_TR_KEY = 'cacheType_3';
const TYPE_VIRTUAL_TR_KEY = 'cacheType_4';
const TYPE_WEBCAM_TR_KEY = 'cacheType_5';
const TYPE_EVENT_TR_KEY = 'cacheType_6';
const TYPE_QUIZ_TR_KEY = 'cacheType_3';
const TYPE_MOVING_TR_KEY = 'cacheType_4';
const TYPE_GEOPATHFINAL_TR_KEY = 'cacheType_9';
const TYPE_OWNCACHE_TR_KEY = 'cacheType_10';
const TYPE_QUIZ_TR_KEY = 'cacheType_7';
const TYPE_MOVING_TR_KEY = 'cacheType_20';
const TYPE_GEOPATHFINAL_TR_KEY = 'cacheType_21';
const TYPE_OWNCACHE_TR_KEY = 'cacheType_22';

const TYPE_GUESTBOOK_TR_KEY = 'cacheType_23';
const TYPE_BITCACHE_TR_KEY = 'cacheType_24';
const TYPE_BENCHMARK_TR_KEY = 'cacheType_25';
const TYPE_CHALLENGE_TR_KEY = 'cacheType_26';

const STATUS_READY_TR_KEY = 'cacheStatus_1';
const STATUS_UNAVAILABLE_TR_KEY = 'cacheStatus_2';
Expand All @@ -83,8 +92,8 @@ public static function CacheTypeTranslationKey($type)
{

switch ($type) {
case self::TYPE_TRADITIONAL: return self::TYPE_TRADITIONAL_TR_KEY;
case self::TYPE_OTHERTYPE: return self::TYPE_OTHERTYPE_TR_KEY;
case self::TYPE_TRADITIONAL: return self::TYPE_TRADITIONAL_TR_KEY;
case self::TYPE_MULTICACHE: return self::TYPE_MULTICACHE_TR_KEY;
case self::TYPE_VIRTUAL: return self::TYPE_VIRTUAL_TR_KEY;
case self::TYPE_WEBCAM: return self::TYPE_WEBCAM_TR_KEY;
Expand All @@ -93,6 +102,10 @@ public static function CacheTypeTranslationKey($type)
case self::TYPE_MOVING: return self::TYPE_MOVING_TR_KEY;
case self::TYPE_GEOPATHFINAL: return self::TYPE_GEOPATHFINAL_TR_KEY;
case self::TYPE_OWNCACHE: return self::TYPE_OWNCACHE_TR_KEY;
case self::TYPE_GUESTBOOK: return self::TYPE_GUESTBOOK_TR_KEY;
case self::TYPE_BITCACHE: return self::TYPE_BITCACHE_TR_KEY;
case self::TYPE_BENCHMARK: return self::TYPE_BENCHMARK_TR_KEY;
case self::TYPE_CHALLENGE: return self::TYPE_CHALLENGE_TR_KEY;
}
}

Expand Down Expand Up @@ -177,6 +190,8 @@ public static function CacheStatusArray()
public static function CacheTypeIdFromOkapi($okapiType)
{
switch ($okapiType) {
case 'Other':
return self::TYPE_OTHERTYPE;
case 'Traditional':
return self::TYPE_TRADITIONAL;
case 'Multi':
Expand All @@ -191,10 +206,18 @@ public static function CacheTypeIdFromOkapi($okapiType)
return self::TYPE_QUIZ;
case 'Moving':
return self::TYPE_MOVING;
case 'GeoPath FINAL':
return self::TYPE_GEOPATHFINAL;
case 'Own':
return self::TYPE_OWNCACHE;
case 'Other':
return self::TYPE_OTHERTYPE;
case 'Guestbook':
return self::TYPE_GUESTBOOK;
case 'BIT Cache':
return self::TYPE_BITCACHE;
case 'Benchmark':
return self::TYPE_BENCHMARK;
case 'Challenge':
return self::TYPE_CHALLENGE;
default:
Debug::errorLog('Unknown cache type from OKAPI: ' . $okapiType);
return self::TYPE_TRADITIONAL;
Expand Down Expand Up @@ -340,6 +363,23 @@ public static function CacheIconByType(
case self::TYPE_OWNCACHE:
$typePart = 'owncache';
break;

case self::TYPE_GUESTBOOK:
$typePart = 'guestbook';
break;

case self::TYPE_BITCACHE:
$typePart = 'bitcache';
break;

case self::TYPE_BENCHMARK:
$typePart = 'benchmark';
break;

case self::TYPE_CHALLENGE:
$typePart = 'challenge';
break;

}

if ($fileNameOnly) {
Expand Down
32 changes: 32 additions & 0 deletions src/Views/mainMap/mainMapFilters.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@
alt="<?=tr('map_quizType')?>">
</label>
</div>
<div>
<input id="exTypeGuestbook" type="checkbox" class="filterParam">
<label for="exTypeGuestbook">
<?=tr('map_guestbokType')?>
<img src="/okapi/static/tilemap/legend_guestbook.png"
alt="<?=tr('map_guestbookType')?>">
</label>
</div>
<div>
<input id="exTypeChallenge" type="checkbox" class="filterParam">
<label for="exTypeChallenge">
<?=tr('map_challengeType')?>
<img src="/okapi/static/tilemap/legend_challenge.png"
alt="<?=tr('map_challengeType')?>">
</label>
</div>
</div>
<div class="col">
<div>
Expand All @@ -56,6 +72,14 @@
alt="<?=tr('map_otherType')?>">
</label>
</div>
<div>
<input id="exTypeBitcache" type="checkbox" class="filterParam">
<label for="exTypeBitcache">
<?=tr('map_bitcacheType')?>
<img src="/okapi/static/tilemap/legend_bitcache.png"
alt="<?=tr('map_bitcacheType')?>">
</label>
</div>
</div>
<div class="col">
<div>
Expand All @@ -74,6 +98,14 @@
alt="<?=tr('map_movingType')?>">
</label>
</div>
<div>
<input id="exTypeBenchmark" type="checkbox" class="filterParam">
<label for="exTypeBenchmark">
<?=tr('map_benchmarkType')?>
<img src="/okapi/static/tilemap/legend_benchmark.png"
alt="<?=tr('map_benchmarkType')?>">
</label>
</div>
<div>
<input id="exTypeOwn" type="checkbox" class="filterParam">
<label for="exTypeOwn">
Expand Down

0 comments on commit 821d08d

Please sign in to comment.