diff --git a/badge_positions_list.php b/badge_positions_list.php index 9070d5acbf..6dec79464a 100644 --- a/badge_positions_list.php +++ b/badge_positions_list.php @@ -3,6 +3,7 @@ use src\Utils\Text\Formatter; use src\Controllers\MeritBadgeController; use src\Controllers\ViewBadgeHeadController; +use src\Models\GeoCache\GeoCacheCommons; require_once(__DIR__.'/lib/common.inc.php'); @@ -33,7 +34,6 @@ $content = ""; $positionsMeritBadge = $meritBadgeCtrl->buildArrayGainedPositions($userid, $badge_id); -$cacheTypesIcons = cache::getCacheIconsSet(); foreach( $positionsMeritBadge as $onePositionBadge ){ @@ -55,8 +55,7 @@ $typeIcon =''; $typeIcon = str_replace( "{src}", - $cacheTypesIcons[$onePositionBadge->getType()]['iconSet'][1]['iconSmallFound'], - $typeIcon ); + GeoCacheCommons::CacheIconByType($onePositionBadge->getType(), GeoCacheCommons::STATUS_READY), $typeIcon); $date = Formatter::date($onePositionBadge->getGainDate()); $dateSort = date("y.m.d", strtotime($onePositionBadge->getGainDate())); diff --git a/cacheratings.php b/cacheratings.php index 5b89217548..cfce4cd043 100644 --- a/cacheratings.php +++ b/cacheratings.php @@ -4,7 +4,6 @@ //prepare the templates and include all necessary require_once(__DIR__.'/lib/common.inc.php'); -require_once(__DIR__.'/lib/caches.inc.php'); require_once(__DIR__.'/src/Views/lib/icons.inc.php'); global $usr; diff --git a/config/geocache.default.php b/config/geocache.default.php index c1ff3ce536..f00b3bf909 100644 --- a/config/geocache.default.php +++ b/config/geocache.default.php @@ -16,7 +16,7 @@ * * (All other size-related features will automatically adjust to the sizes * which are in use for existing caches.) - * + * * The order does not matter. */ $geocache['enabledSizes'] = [ @@ -27,3 +27,10 @@ GeoCacheCommons::SIZE_XLARGE, GeoCacheCommons::SIZE_NONE, ]; + +/** + * Types of geocache which are forbidden on creation (it is possible thatsuch geocaches are still in DB, + * but no NEW caches of this can be created + */ +$geocache['noNewCachesOfTypes'] = []; + diff --git a/config/geocache.nl.php b/config/geocache.nl.php index a6c78b1781..fc45dddab1 100644 --- a/config/geocache.nl.php +++ b/config/geocache.nl.php @@ -7,3 +7,4 @@ */ $geocache['enabledSizes'][] = GeoCacheCommons::SIZE_NANO; + diff --git a/config/geocache.pl.php b/config/geocache.pl.php new file mode 100644 index 0000000000..0a067def09 --- /dev/null +++ b/config/geocache.pl.php @@ -0,0 +1,13 @@ +dbResultFetch($s)) { if ($cache_record['user_id'] == $usr['userid'] || $usr['admin']) { - require_once(__DIR__.'/lib/caches.inc.php'); // from deleted editcache.inc.php: $submit = 'Zapisz'; @@ -739,23 +739,30 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type //build typeoptions $types = ''; - foreach (get_cache_types_from_database() as $type) { + foreach (GeoCacheCommons::CacheTypesArray() as $type) { // blockforbidden cache types - if (($type['id'] != $cache_type) && in_array($type['id'], $config['forbidenCacheTypes']) && !$usr['admin']) { + if (($type != $cache_type) && in_array($type, OcConfig::getNoNewCacheOfTypesArray()) && !$usr['admin']) { continue; } - if (isset($config['cacheLimitByTypePerUser'][$cache_type]) && $cacheLimitByTypePerUser[$cache_type] >= $config['cacheLimitByTypePerUser'][$cache_type] && !$usr['admin']) { + if (isset($config['cacheLimitByTypePerUser'][$cache_type]) && + $cacheLimitByTypePerUser[$cache_type] >= $config['cacheLimitByTypePerUser'][$cache_type] && + !$usr['admin']) { continue; } - if (isset($cacheLimitByTypePerUser[$type['id']]) && isset($config['cacheLimitByTypePerUser'][$type['id']]) && $cacheLimitByTypePerUser[$type['id']] >= $config['cacheLimitByTypePerUser'][$type['id']] && !$usr['admin']) { + if (isset($cacheLimitByTypePerUser[$type]) && + isset($config['cacheLimitByTypePerUser'][$type]) && + $cacheLimitByTypePerUser[$type] >= $config['cacheLimitByTypePerUser'][$type] && + !$usr['admin']) { continue; } - if ($type['id'] == $cache_type) { - $types .= ''; + if ($type == $cache_type) { + $types .= ''; } else { - $types .= ''; + $types .= ''; } } tpl_set_var('typeoptions', $types); @@ -766,7 +773,7 @@ function build_drop_seq($item_row, $selected_seq, $max_drop, $thisid, $drop_type // blockforbidden cache sizes if ($size != $sel_size - && !in_array($size, OcConfig::instance()->getGeocacheConfig('enabledSizes')) + && !in_array($size, OcConfig::getEnabledCacheSizesArray()) ) { continue; } diff --git a/editlog.php b/editlog.php index 6809a423cf..e074455743 100644 --- a/editlog.php +++ b/editlog.php @@ -12,6 +12,8 @@ use src\Models\GeoCache\MobileCacheMove; use src\Models\OcConfig\OcConfig; use src\Utils\I18n\I18n; +use src\Models\GeoCache\GeoCacheLogCommons; +use src\Models\GeoCache\GeoCache; + //prepare the templates and include all neccessary require_once(__DIR__.'/lib/common.inc.php'); @@ -44,7 +46,6 @@ if ($log_record) { require(__DIR__.'/src/Views/editlog.inc.php'); - require_once(__DIR__.'/lib/caches.inc.php'); require(__DIR__.'/src/Views/rating.inc.php'); if ($log_record['node'] != OcConfig::getSiteNodeId()) { @@ -432,51 +433,93 @@ //build logtypeoptions $logtypeoptions = ''; - foreach (get_log_types_from_database() AS $type) { - // skip if permission=O ???? and not owner or COG - if ($type['permission'] == 'B' && $log_record['user_id'] != $cache_user_id && !($usr['admin'])) + foreach (GeoCacheLogCommons::logTypesArray() as $type) { + + // skip types allowed only for cacheOwner (9,10,11) + $allowedOnlyForOwner = [GeoCacheLogCommons::LOGTYPE_READYTOSEARCH, + GeoCacheLogCommons::LOGTYPE_ARCHIVED, + GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE]; + if (in_array($type,$allowedOnlyForOwner) && + $log_record['user_id'] != $cache_user_id && !($usr['admin'])) { continue; + } + // Only COG can write or edit COG comment - if ($type['id'] == 12 && !($usr['admin'])) { + if ($type == GeoCacheLogCommons::LOGTYPE_ADMINNOTE && !($usr['admin'])) { continue; } - if ($log_record['logtype'] != $type['id'] && $log_record['cachestatus'] != 1) - continue; - if ($log_record['logtype'] != $type['id'] && $log_record['cachestatus'] == 1 && $log_record['user_id'] == $cache_user_id && $type['id'] != 3 && $type['id'] != 6) + + // skip current type of log + if ($log_record['logtype'] != $type && $log_record['cachestatus'] != GeoCacheCommons::STATUS_READY) { continue; + } + + if ($log_record['logtype'] != $type && // not same as current type + $log_record['cachestatus'] == GeoCacheCommons::STATUS_READY && // not ready-to-search + $log_record['user_id'] == $cache_user_id && // is owner + $type != GeoCacheLogCommons::LOGTYPE_COMMENT && + $type != GeoCacheLogCommons::LOGTYPE_MADEMAINTENANCE) { + + continue; + } + if ($already_found_in_other_comment) { - if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) { + if ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT || + $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND || + $type == GeoCacheLogCommons::LOGTYPE_ATTENDED || + $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED || + $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED || + $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE) { continue; } } - if ($cache_type == 6 || $cache_type == 8) { - // Event cache - if ($cache_type == 6) { - if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 || $type['id'] == 5 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) { - continue; - } + + if ($cache_type == GeoCache::TYPE_EVENT) { + if ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT || + $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND || + $type == GeoCacheLogCommons::LOGTYPE_MOVED || + $type == GeoCacheLogCommons::LOGTYPE_NEEDMAINTENANCE || + $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED || + $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE) { + continue; } - // Mobile cache - if ($cache_type == 8) { - if ($type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9) { - continue; - } + } else if ($cache_type == GeoCache::TYPE_MOVING) { + if ($type == GeoCacheLogCommons::LOGTYPE_ATTENDED || + $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED || + $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED) { + continue; } } else { - if ($log_record['user_id'] == $cache_user_id && ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 || $type['id'] == 5 || $type['id'] == 7 || $type['id'] == 8)) { + + if ($log_record['user_id'] == $cache_user_id && // is owner + ($type == GeoCacheLogCommons::LOGTYPE_FOUNDIT || + $type == GeoCacheLogCommons::LOGTYPE_DIDNOTFIND || + $type == GeoCacheLogCommons::LOGTYPE_MOVED || + $type == GeoCacheLogCommons::LOGTYPE_NEEDMAINTENANCE || + $type == GeoCacheLogCommons::LOGTYPE_ATTENDED || + $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED)) { continue; } - if ($log_record['user_id'] != $cache_user_id && ($type['id'] == 4 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11)) { + + if ($log_record['user_id'] != $cache_user_id && + ($type == GeoCacheLogCommons::LOGTYPE_MOVED || + $type == GeoCacheLogCommons::LOGTYPE_ATTENDED || + $type == GeoCacheLogCommons::LOGTYPE_WILLATTENDED || + $type == GeoCacheLogCommons::LOGTYPE_ARCHIVED || + $type == GeoCacheLogCommons::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLogCommons::LOGTYPE_TEMPORARYUNAVAILABLE)) { continue; } } - $lang_db = I18n::getLangForDbTranslations('log_types'); - - if ($type['id'] == $log_type) { - $logtypeoptions .= '' . "\n"; + if ($type == $log_type) { + $logtypeoptions .= '' . "\n"; } else { - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } } diff --git a/editwp.php b/editwp.php index 33dee72250..cf62025057 100644 --- a/editwp.php +++ b/editwp.php @@ -2,6 +2,7 @@ use src\Utils\Database\XDb; use src\Utils\I18n\I18n; +use src\Models\GeoCache\WaypointCommons; //prepare the templates and include all neccessary require_once(__DIR__.'/lib/common.inc.php'); @@ -67,18 +68,19 @@ $tplname = 'editwp'; - require_once(__DIR__.'/lib/caches.inc.php'); require(__DIR__.'/src/Views/newcache.inc.php'); $wp_type = isset($_POST['type']) ? $_POST['type'] : $wp_record['type']; //build typeoptions $types = ''; + $types .= ''; } else { - $types .= ''; + $types .= ''; } } tpl_set_var('typeoptions', $types); diff --git a/getLogEntries.php b/getLogEntries.php index 07a12dbcdd..9995f20059 100644 --- a/getLogEntries.php +++ b/getLogEntries.php @@ -10,6 +10,7 @@ use src\Models\GeoCache\GeoCache; use src\Models\OcConfig\OcConfig; use src\Models\Coordinates\Coordinates; +use src\Utils\DateTime\Year; require_once (__DIR__.'/lib/common.inc.php'); require(__DIR__.'/src/Views/lib/icons.inc.php'); @@ -164,8 +165,8 @@ $dateTimeTmpArray = explode(' ', $record['date']); $tmplog = mb_ereg_replace('{time}', substr($dateTimeTmpArray[1], 0, -3), $tmplog); - // display user activity (by Łza 2012) - if ((date('m') == 4) and ( date('d') == 1)) { + // display user activity + if (Year::isPrimaAprilisToday() && OcConfig::isPAUserStatsRandEnabled()) { $tmplog_username_aktywnosc = ' (user activity' . rand(1, 9) . ') '; } else { $tmplog_username_aktywnosc = ' (user activity' . ($record['ukryte'] + $record['znalezione'] + $record['nieznalezione']) . ') '; diff --git a/images/oc_logo_1A.png b/images/oc_logo_1A.png deleted file mode 100644 index 7b8e1e13cf..0000000000 Binary files a/images/oc_logo_1A.png and /dev/null differ diff --git a/lib/ClassPathDictionary.php b/lib/ClassPathDictionary.php index c6b8f52a33..052e09096c 100644 --- a/lib/ClassPathDictionary.php +++ b/lib/ClassPathDictionary.php @@ -42,7 +42,6 @@ class ClassPathDictionary * !!! please preserve alphabetical order. !!! */ private static $classDictionary = array( - 'cache' => 'lib/cache.php', 'myninc' => 'lib/myn.inc.php', 'powerTrailBase' => 'powerTrail/powerTrailBase.php', 'powerTrailController' => 'powerTrail/powerTrailController.php', diff --git a/lib/cache.php b/lib/cache.php deleted file mode 100644 index ef469891dd..0000000000 --- a/lib/cache.php +++ /dev/null @@ -1,192 +0,0 @@ - array( - 'description' => 'Ready for search', - 'translation' => 'cacheStatus_1', - ), - self::STATUS_UNAVAILABLE => array( - 'description' => 'Temporarily unavailable', - 'translation' => 'cacheStatus_2', - ), - self::STATUS_ARCHIVED => array( - 'description' => 'Archived', - 'translation' => 'cacheStatus_3', - ), - self::STATUS_WAITAPPROVERS => array( - 'description' => 'Hidden by approvers to check', - 'translation' => 'cacheStatus_4', - ), - self::STATUS_NOTYETAVAILABLE => array( - 'description' => 'Not yet available', - 'translation' => 'cacheStatus_5', - ), - self::STATUS_BLOCKED => array( - 'description' => 'Blocked by COG', - 'translation' => 'cacheStatus_6', - ), - ); - private static $type = array( - self::TYPE_OTHERTYPE => array( - 'name' => 'other', - 'icon' => 'unknown.png', - 'translation' => 'cacheType_5' - ), - self::TYPE_TRADITIONAL => array( - 'name' => 'traditional', - 'icon' => 'traditional.png', - 'translation' => 'cacheType_1' - ), - self::TYPE_MULTICACHE => array( - 'name' => 'multicache', - 'icon' => 'multi.png', - 'translation' => 'cacheType_2', - ), - self::TYPE_VIRTUAL => array( - 'name' => 'virtual', - 'icon' => 'virtual.png', - 'translation' => 'cacheType_8' - ), - self::TYPE_WEBCAM => array( - 'name' => 'webcam', - 'icon' => 'webcam.png', - 'translation' => 'cacheType_7' - ), - self::TYPE_EVENT => array( - 'name' => 'event', - 'icon' => 'event.png', - 'translation' => 'cacheType_6' - ), - self::TYPE_QUIZ => array( - 'name' => 'quiz', - 'icon' => 'quiz.png', - 'translation' => 'cacheType_3' - ), - self::TYPE_MOVING => array( - 'name' => 'moving', - 'icon' => 'moving.png', - 'translation' => 'cacheType_4' - ), - self::TYPE_GEOPATHFINAL => array( - 'name' => 'podcast', - 'icon' => 'podcache.png', - 'translation' => 'cacheType_9' - ), - self::TYPE_OWNCACHE => array( - 'name' => 'own-cache', - 'icon' => 'owncache.png', - 'translation' => 'cacheType_10', - ), - ); - private static $iconPath = 'images/cache/'; - private static $iconSmallStr = '16x16-'; - private static $iconFoundStr = '-found'; - private static $iconArchivedStr = '-a'; - private static $iconTmpUnavStr = '-n'; - - private function __construct() - { - $this->cacheTypeIcons = self::getCacheIconsSet(); - } - - public static function instance() - { - static $inst = null; - if ($inst === null) { - $inst = new cache(); - } - return $inst; - } - - /** - * prepare array contain set of icons for diffrent cachetypes - */ - public static function getCacheIconsSet() - { - $cacheTypeIcons = self::$type; - foreach ($cacheTypeIcons as $cacheTypeId => $cacheType) { - $cacheTypeIcons[$cacheTypeId]['iconSet'] = array( - 1 => array(//active, published - 'iconFound' => self::$iconPath . self::getFoundCacheIcon($cacheType['icon']), - 'iconSmall' => self::$iconPath . self::$iconSmallStr . $cacheType['icon'], - 'iconSmallFound' => self::$iconPath . self::getFoundCacheIcon(self::$iconSmallStr . $cacheType['icon']), - 'iconSmallOwner' => self::$iconPath . self::getOwnerCacheIcon(self::$iconSmallStr . $cacheType['icon']), - ), - 2 => array(//tempUnavailable - 'iconFound' => self::$iconPath . self::getFoundCacheIcon($cacheType['icon'], self::$iconTmpUnavStr), - 'iconSmall' => self::$iconPath . self::$iconSmallStr . $cacheType['icon'], - 'iconSmallFound' => self::$iconPath . self::getFoundCacheIcon(self::$iconSmallStr . $cacheType['icon'], self::$iconTmpUnavStr), - 'iconSmallOwner' => self::$iconPath . self::getOwnerCacheIcon(self::$iconSmallStr . $cacheType['icon'], self::$iconTmpUnavStr), - ), - 3 => array(// archived - 'iconFound' => self::$iconPath . self::getFoundCacheIcon($cacheType['icon'], self::$iconArchivedStr), - 'iconSmall' => self::$iconPath . self::$iconSmallStr . $cacheType['icon'], - 'iconSmallFound' => self::$iconPath . self::getFoundCacheIcon(self::$iconSmallStr . $cacheType['icon'], self::$iconArchivedStr), - 'iconSmallOwner' => self::$iconPath . self::getOwnerCacheIcon(self::$iconSmallStr . $cacheType['icon'], self::$iconArchivedStr), - ), - ); - } - return $cacheTypeIcons; - } - - private static function getFoundCacheIcon($cacheIcon, $statusStr = '') - { - $tmp = explode('.', $cacheIcon); - $tmp[0] = $tmp[0] . $statusStr . '-found'; - return implode('.', $tmp); - } - - private static function getOwnerCacheIcon($cacheIcon, $statusStr = '') - { - $tmp = explode('.', $cacheIcon); - $tmp[0] = $tmp[0] . $statusStr . '-s-owner'; - return implode('.', $tmp); - } - - public function getCacheTypeIcons() - { - return $this->cacheTypeIcons; - } - - - - public function getCacheTypes() - { - return self::$type; - } - - public function getCacheStatuses() - { - return $this->status; - } - -} diff --git a/lib/caches.inc.php b/lib/caches.inc.php deleted file mode 100644 index 339fbaf7e9..0000000000 --- a/lib/caches.inc.php +++ /dev/null @@ -1,54 +0,0 @@ - 'New coordinates', 'viewlog_aktywnosc' => 'Total user activity (total of caches found, not found and hidden)', 'viewlog_kordy' => 'Cache coordinates after moving', - 'log_type_temp_unavailable' => 'Temporarily unavailable', - 'log_type_available' => 'Ready to find', 'log_mobile_init' => 'Starting coordinates', 'error_coords_not_ok' => 'Wrong coordinates!', 'error_nofulltext' => 'Invalid entry. Change the name to search.', @@ -1021,11 +1019,7 @@ 'lxg01' => 'Wrong date. Please enter correct date: DD-MM-YYYY', 'lxg02' => 'Rate cache, or select you do not want rate this cache.', 'lxg05' => 'Send log entry', - 'lxg08' => 'Write a note', - 'lxg09' => 'Moved', - 'lxg10' => 'Needs maintenance', 'lxg11' => 'OC Team Comment', - 'made_service' => 'Maintenance performed', 'remove_desc_01' => 'Should the description in', 'remove_desc_02' => 'from the cache', 'remove_desc_03' => 'be removed?', diff --git a/lib/myn.inc.php b/lib/myn.inc.php index 434bd69c54..68a3585dfe 100644 --- a/lib/myn.inc.php +++ b/lib/myn.inc.php @@ -1,6 +1,13 @@ paramQuery($q, $params); - $rec = $db->dbResultFetch($s); - if (isset($rec['user_id'])) { - return true; - } else { - return false; - } - } - +/** + * @deprecated + * + * Don't use this - myn class should be removed soon + */ public static function checkCacheStatusByUser($record, $userId) { - $cacheTypesIcons = cache::getCacheIconsSet(); - if (isset($record['user_id']) && $record['user_id'] == $userId) { - return $cacheTypesIcons[$record['cache_type']]['iconSet'][1]['iconSmallOwner']; - } elseif (isset($record['cache_id']) && self::is_cache_found($record['cache_id'], $userId)) { - return $cacheTypesIcons[$record['cache_type']]['iconSet'][1]['iconSmallFound']; + if (isset($record['user_id']) && $record['user_id'] == $userId) { //for owner + return GeoCacheCommons::CacheIconByType( + $record['cache_type'], GeoCacheCommons::STATUS_READY, null, false, true); + + } else if (isset($record['cache_id']) && self::is_cache_found($record['cache_id'], $userId)){ + return GeoCacheCommons::CacheIconByType( + $record['cache_type'], GeoCacheCommons::STATUS_READY, GeoCacheLog::LOGTYPE_FOUNDIT, false, false); + } else { - return $cacheTypesIcons[$record['cache_type']]['iconSet'][1]['iconSmall']; + + return GeoCacheCommons::CacheIconByType($record['cache_type'], GeoCacheCommons::STATUS_READY); } } } diff --git a/lib/search.html.inc.php b/lib/search.html.inc.php index 48b2560c2b..5c80f7d536 100644 --- a/lib/search.html.inc.php +++ b/lib/search.html.inc.php @@ -7,6 +7,7 @@ use src\Utils\Uri\OcCookie; use src\Models\Coordinates\Coordinates; use src\Utils\I18n\I18n; +use src\Models\GeoCache\GeoCacheCommons; /** * This script is used (can be loaded) by /search.php @@ -405,7 +406,7 @@ function fHideColumn($nr, $set) } } ; - $tmpline = str_replace('{cachetype}', htmlspecialchars(cache_type_from_id($caches_record['cache_type']), ENT_COMPAT, 'UTF-8'), $tmpline); + $tmpline = str_replace('{cachetype}', tr(GeoCacheCommons::CacheTypeTranslationKey($caches_record['cache_type'])), $tmpline); // sp2ong short_desc ermitteln TODO: nicht die erste sondern die richtige wählen $tmpline = str_replace('{wp_oc}', htmlspecialchars($caches_record['wp_oc'], ENT_COMPAT, 'UTF-8'), $tmpline); diff --git a/lib/search.txt.inc.php b/lib/search.txt.inc.php index 452fa64758..6317200db0 100644 --- a/lib/search.txt.inc.php +++ b/lib/search.txt.inc.php @@ -18,11 +18,6 @@ require_once (__DIR__.'/../lib/calculation.inc.php'); - -$cache = cache::instance(); -$cacheTypesArr = $cache->getCacheTypeIcons(); -$cacheStatusArr = $cache->getCacheStatuses(); - $txtLine = chr(239) . chr(187) . chr(191) .tr('search_text_01')." {mod_suffix}{cachename} ".tr('search_text_02')." {owner} ".tr('search_text_03')." {lat} {lon} ".tr('search_text_04')." {status} @@ -253,9 +248,9 @@ } else { $thisline = str_replace('{rr_comment}', html2txt("

--------
".$r['rr_comment']), $thisline); } - $thisline = str_replace('{type}', tr($cacheTypesArr[$r['type_id']]['translation']), $thisline); + $thisline = str_replace('{type}', tr(GeoCacheCommons::CacheTypeTranslationKey($r['type_id']), $thisline); $thisline = str_replace('{container}', tr(GeoCacheCommons::CacheSizeTranslationKey($r['size'])), $thisline); - $thisline = str_replace('{status}', tr($cacheStatusArr[$r['status']]['translation']), $thisline); + $thisline = str_replace('{status}', tr(GeoCacheCommons::CacheStatusTranslationKey($r['status'])), $thisline); $difficulty = sprintf('%01.1f', $r['difficulty'] / 2); $thisline = str_replace('{difficulty}', $difficulty, $thisline); diff --git a/lib/settingsDefault.inc.php b/lib/settingsDefault.inc.php index 6d0c9e8f37..865d8e4273 100644 --- a/lib/settingsDefault.inc.php +++ b/lib/settingsDefault.inc.php @@ -5,7 +5,7 @@ * settings.inc.php file (e.g. $config['debugDB'] = true;). */ -require_once (__DIR__.'/cache.php'); +use src\Models\GeoCache\GeoCacheCommons; // enable detailed cache access logging $enable_cache_access_logs = false; @@ -40,8 +40,6 @@ 'headerLogo' => 'oc_logo.png', /** main logo; winter version, displayed during december and january. */ 'headerLogoWinter' => 'oc_logo_winter.png', - /** main logo; prima aprilis version (april fools), displayed only on april 1st. */ - 'headerLogo1stApril' => 'oc_logo_1A.png', /** qrcode logo: show qrcode image and link the prefered way. */ 'qrCodeLogo' => 'qrcode_bg.jpg', 'qrCodeUrl' => 'https://opencaching.pl/viewcache.php?wp=OP3C90', @@ -65,24 +63,14 @@ * another site. */ 'otherSites_minfinds' => 100, - /** - * not allowed cache types (user cannot create caches of this types). - * - * Cachetypes must be lib/cache.php constant TYPE_* - */ - 'forbidenCacheTypes' => array( - cache::TYPE_VIRTUAL, - cache::TYPE_WEBCAM, - cache::TYPE_GEOPATHFINAL - ), /** * cache limits for user. If user is allowed to place limited nomber of specified cache type, * place cachetype and limit here. * - * Cachetypes must be lib/cache.php constant TYPE_* + * Cachetypes must be GeoCacheCommons constant TYPE_* */ 'cacheLimitByTypePerUser' => array( - cache::TYPE_OWNCACHE => 1, + GeoCacheCommons::TYPE_OWNCACHE => 1, ), /** The filter fragment selecting provinces from nuts_codes table. */ 'provinceNutsCondition' => '`code` like \'PL__\'', diff --git a/log.php b/log.php index 93404de943..4f720a0c44 100644 --- a/log.php +++ b/log.php @@ -37,7 +37,6 @@ $view->loadJquery(); -require_once(__DIR__.'/lib/caches.inc.php'); require(__DIR__.'/src/Views/rating.inc.php'); if(!isset($_REQUEST['cacheid'])){ @@ -661,7 +660,7 @@ tpl_set_var('display', "none"); } - foreach (get_log_types_from_database() AS $type) { + foreach (GeoCacheLogCommons::logTypesArray() AS $type) { // do not allow 'finding' or 'not finding' own or archived cache // (events can be logged) $geoCache->getStatus() == 2 || $geoCache->getStatus() == 3 @@ -674,37 +673,44 @@ //3 = Write a note; if ($user->hasOcTeamRole() && $geoCache->getStatus() == GeoCache::STATUS_WAITAPPROVERS){ - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } else { - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } //4 = Moved if ($geoCache->getCacheType() == GeoCache::TYPE_MOVING || $geoCache->getCacheType() == GeoCache::TYPE_OWNCACHE ) { - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } //5 = Needs maintenace if ($user->getUserId() != $geoCache->getOwnerId()) { - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } - $logtypeoptions .= '' . "\n"; + + $logtypeoptions .= '' . "\n"; //12 = OC Team Comment if ($user->hasOcTeamRole()) { - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } // service log by Łza // if curently logged user is a cache owner and cache status is "avilable" // then add log type option "temp. unavailable"; //11 = Temporarily unavailable - if ($user->getUserId() == $geoCache->getOwnerId() && - $geoCache->getStatus() == GeoCache::STATUS_READY) { + if ($user->getUserId() == $geoCache->getOwnerId() && $geoCache->getStatus() == GeoCache::STATUS_READY) { - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } // if curently logged user is a cache owner and cache status is "temp. unavailable" @@ -713,28 +719,18 @@ if ( $user->getUserId() == $geoCache->getOwnerId() && $geoCache->getStatus() == GeoCache::STATUS_UNAVAILABLE ) { - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } break; } - - - // skip if permission=O and not owner - if ($type['permission'] == 'O' && - $user->getUserId() != $geoCache->getOwnerId() && - $type['permission']){ - - continue; - } - - // if virtual, webcam = archived -> allow only comment log type if (($geoCache->getCacheType() == GeoCache::TYPE_VIRTUAL || $geoCache->getCacheType() == GeoCache::TYPE_WEBCAM ) && $geoCache->getStatus() == GeoCache::STATUS_ARCHIVED) { - if ($type['id'] != 3) { + if ($type != GeoCacheLog::LOGTYPE_COMMENT) { continue; } } @@ -746,7 +742,7 @@ //so zero time here to allow logging WILLATTENDED or ATTENDED in the day of event // if user logged event as willattended before or event it's over, do not display logtype 'attended' - if ($type['id'] == GeoCacheLog::LOGTYPE_WILLATTENDED) { + if ($type == GeoCacheLog::LOGTYPE_WILLATTENDED) { if ($geoCache->hasUserLogByType($user, GeoCacheLog::LOGTYPE_WILLATTENDED) || $now > $geoCache->getDatePlaced()) { continue; @@ -754,60 +750,86 @@ } // if user logged event as attended before or event has not happened yet, //do not display logtype 'attended' - if ($type['id'] == GeoCacheLog::LOGTYPE_ATTENDED) { + if ($type == GeoCacheLog::LOGTYPE_ATTENDED) { if ($geoCache->hasUserLogByType($user, GeoCacheLog::LOGTYPE_ATTENDED) || $now < $geoCache->getDatePlaced()) { continue; } } if ($user->hasOcTeamRole()) { - if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 || - $type['id'] == 5 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) { + if ($type == GeoCacheLog::LOGTYPE_FOUNDIT || + $type == GeoCacheLog::LOGTYPE_DIDNOTFIND || + $type == GeoCacheLog::LOGTYPE_MOVED || + $type == GeoCacheLog::LOGTYPE_NEEDMAINTENANCE || + $type == GeoCacheLog::LOGTYPE_ARCHIVED || + $type == GeoCacheLog::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE) { continue; } } else { - if ($type['id'] == 1 || $type['id'] == 2 || $type['id'] == 4 || - $type['id'] == 5 || $type['id'] == 9 || $type['id'] == 10 || - $type['id'] == 11 || $type['id'] == 12) { + if ($type == GeoCacheLog::LOGTYPE_FOUNDIT || + $type == GeoCacheLog::LOGTYPE_DIDNOTFIND || + $type == GeoCacheLog::LOGTYPE_MOVED || + $type == GeoCacheLog::LOGTYPE_NEEDMAINTENANCE || + $type == GeoCacheLog::LOGTYPE_ARCHIVED || + $type == GeoCacheLog::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE || + $type == GeoCacheLog::LOGTYPE_ADMINNOTE) { continue; } } - } else { + } else { // NOT-EVENT if ($geoCache->getCacheType() == GeoCache::TYPE_MOVING) { if ($user->hasOcTeamRole()) { // skip will attend/attended if the cache no event - if ($type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) { + if ($type == GeoCacheLog::LOGTYPE_ATTENDED || + $type == GeoCacheLog::LOGTYPE_WILLATTENDED || + $type == GeoCacheLog::LOGTYPE_ARCHIVED || + $type == GeoCacheLog::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE) { continue; } } else { - if ($type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11 || $type['id'] == 12) { + if ($type == GeoCacheLog::LOGTYPE_ATTENDED || + $type == GeoCacheLog::LOGTYPE_WILLATTENDED || + $type == GeoCacheLog::LOGTYPE_ARCHIVED || + $type == GeoCacheLog::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE || + $type == GeoCacheLog::LOGTYPE_ADMINNOTE) { continue; } } } else { // skip will attend/attended/Moved if the cache no event and Mobile if ($user->hasOcTeamRole()) { - if ($type['id'] == 4 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11) { + if ($type == GeoCacheLog::LOGTYPE_MOVED || + $type == GeoCacheLog::LOGTYPE_ATTENDED || + $type == GeoCacheLog::LOGTYPE_WILLATTENDED || + $type == GeoCacheLog::LOGTYPE_ARCHIVED || + $type == GeoCacheLog::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE) { continue; } } else { - if ($type['id'] == 4 || $type['id'] == 7 || $type['id'] == 8 || $type['id'] == 9 || $type['id'] == 10 || $type['id'] == 11 || $type['id'] == 12) { + if ($type == GeoCacheLog::LOGTYPE_MOVED || + $type == GeoCacheLog::LOGTYPE_ATTENDED || + $type == GeoCacheLog::LOGTYPE_WILLATTENDED || + $type == GeoCacheLog::LOGTYPE_ARCHIVED || + $type == GeoCacheLog::LOGTYPE_READYTOSEARCH || + $type == GeoCacheLog::LOGTYPE_TEMPORARYUNAVAILABLE || + $type == GeoCacheLog::LOGTYPE_ADMINNOTE) { continue; } } } } - if (isset($type[I18n::getCurrentLang()])){ - $lang_db = I18n::getCurrentLang(); - } else { - $lang_db = "en"; - } - - if ($type['id'] == $log_type) { - $logtypeoptions .= '' . "\n"; + if ($type == $log_type) { + $logtypeoptions .= '' . "\n"; } else { - $logtypeoptions .= '' . "\n"; + $logtypeoptions .= '' . "\n"; } } diff --git a/log_cache_multi.php b/log_cache_multi.php index 7b01b7af8c..8bb7489076 100644 --- a/log_cache_multi.php +++ b/log_cache_multi.php @@ -97,7 +97,6 @@ if ($usr == false || (!isset($_FILES['userfile']) && !isset($_SESSION['log_cache_multi_data']))) { tpl_redirect('log_cache_multi_send.php'); } else { - require_once(__DIR__.'/lib/caches.inc.php'); $tplname = 'log_cache_multi'; $myHtml = ""; diff --git a/log_cache_multi_panel.php b/log_cache_multi_panel.php index 8133c97c49..e9845e16c5 100644 --- a/log_cache_multi_panel.php +++ b/log_cache_multi_panel.php @@ -1,5 +1,7 @@ @@ -99,14 +100,16 @@ } ?> - " . $v['kod_str'] . " " . $v['cache_name'] : " "; ?> + " . + $v['kod_str'] . " " . $v['cache_name'] : " "; ?> ", $v['data']) : " "; echo "      "; - echo isset($v['status']) ? "" : " "; + echo isset($v['status']) ? "" : " "; ?> ", $v['last_date']) . "      " . (isset($v['last_status']) ? "" : " ") : " "; + echo isset($v['got_last_activity']) ? str_replace(" ", "
", $v['last_date']) . "      " . (isset($v['last_status']) ? "" : " ") : " "; ?>   @@ -124,22 +127,3 @@ } } -function get_icon_for_status($status) -{ - $typyStatusow = get_log_types_from_database(); - foreach ($typyStatusow as $k => $v) { - if ($v['id'] == $status) { - return $v['icon_small']; - } - } -} - -function get_icon_for_cache_type($type) -{ - $typySkrzynek = get_cache_types_from_database(); - foreach ($typySkrzynek as $k => $v) { - if ($v['id'] == $type) { - return $v['icon_large']; - } - } -} diff --git a/my_logs.php b/my_logs.php index 27e198dd87..9555842aab 100644 --- a/my_logs.php +++ b/my_logs.php @@ -22,7 +22,7 @@ tpl_set_var('userid', $user_id); } - $logTypes = GeoCacheLog::logTypes(); + $logTypes = GeoCacheLog::logTypesArray(); if (isset($_REQUEST['logtypes'])) { $logTypes = array_intersect($logTypes, explode(',', $_REQUEST['logtypes'])); } @@ -61,7 +61,7 @@ $startat = max(0, floor((($start / $LOGS_PER_PAGE) + 1) / $PAGES_LISTED) * $PAGES_LISTED); $logsPage = 'my_logs.php?userid='.$user_id; - if (array_diff(GeoCacheLog::logTypes(), $logTypes)) { + if (array_diff(GeoCacheLog::logTypesArray(), $logTypes)) { $logsPage .= '&logtypes='.implode(',',$logTypes); } $logsPage .= '&start='; diff --git a/myroutes_search.php b/myroutes_search.php index e22a4793c2..8b0244df16 100644 --- a/myroutes_search.php +++ b/myroutes_search.php @@ -13,7 +13,6 @@ require_once (__DIR__.'/lib/export.inc.php'); require_once (__DIR__.'/lib/format.gpx.inc.php'); require_once (__DIR__.'/lib/calculation.inc.php'); -require_once (__DIR__.'/lib/caches.inc.php'); require_once (__DIR__.'/src/Views/lib/icons.inc.php'); global $content, $bUseZip, $usr, $config; diff --git a/newcache.php b/newcache.php index d67541ac91..3040792d90 100644 --- a/newcache.php +++ b/newcache.php @@ -50,7 +50,6 @@ exit(); } -require_once (__DIR__.'/lib/caches.inc.php'); require_once (__DIR__.'/src/Views/newcache.inc.php'); $errors = false; // set if there was any errors @@ -317,23 +316,25 @@ } // typeoptions - -$cache = cache::instance(); -$cacheTypes = $cache->getCacheTypes(); $types = ''; -foreach ($cacheTypes as $typeId => $type) { +foreach (GeoCacheCommons::CacheTypesArray() as $typeId) { /* block creating forbidden cache types */ - if (in_array($typeId, $config['forbidenCacheTypes'])) { + if (in_array($typeId, OcConfig::getNoNewCacheOfTypesArray())) { continue; } + /* apply cache limit by type per user */ - if (isset($config['cacheLimitByTypePerUser'][$typeId]) && isset($cacheLimitByTypePerUser[$typeId]) && $cacheLimitByTypePerUser[$typeId] >= $config['cacheLimitByTypePerUser'][$typeId]) { + if (isset($config['cacheLimitByTypePerUser'][$typeId]) && + isset($cacheLimitByTypePerUser[$typeId]) && + $cacheLimitByTypePerUser[$typeId] >= $config['cacheLimitByTypePerUser'][$typeId]) { continue; } if ($typeId == $sel_type) { - $types .= ''; + $types .= ''; } else { - $types .= ''; + $types .= ''; } } tpl_set_var('typeoptions', $types); @@ -607,7 +608,7 @@ // cache-type $type_not_ok = false; // block forbiden cache types - if ($sel_type == - 1 || in_array($sel_type, $config['forbidenCacheTypes'])) { + if ($sel_type == - 1 || in_array($sel_type, OcConfig::getNoNewCacheOfTypesArray())) { tpl_set_var('type_message', $type_not_ok_message); $error = true; $type_not_ok = true; @@ -773,7 +774,7 @@ function buildCacheSizeSelector($sel_type, $sel_size) $sizes = ''; foreach (GeoCacheCommons::CacheSizesArray() as $size) { - if (!in_array($size, OcConfig::instance()->getGeoCacheConfig('enabledSizes'))) { + if (!in_array($size, OcConfig::getEnabledCacheSizesArray())) { continue; } diff --git a/newcaches.php b/newcaches.php index a6e9d87dfc..866f952c54 100644 --- a/newcaches.php +++ b/newcaches.php @@ -3,9 +3,9 @@ use src\Utils\Database\XDb; use src\Utils\Text\Formatter; use src\Utils\View\View; +use src\Models\GeoCache\GeoCacheCommons; require_once (__DIR__.'/lib/common.inc.php'); -require_once (__DIR__.'/lib/caches.inc.php'); require_once (__DIR__.'/src/Views/lib/icons.inc.php'); require_once (__DIR__.'/src/Views/newcaches.inc.php'); @@ -110,7 +110,7 @@ $thisline = mb_ereg_replace('{GPicon}', '', $thisline); }; - $thisline = mb_ereg_replace('{cachetype}', htmlspecialchars(cache_type_from_id($r['type']), ENT_COMPAT, 'UTF-8'), $thisline); + $thisline = mb_ereg_replace('{cachetype}', GeoCacheCommons::CacheTypeTranslationKey($r['type']), $thisline); $thisline = mb_ereg_replace('{cachename}', htmlspecialchars($r['cachename'], ENT_COMPAT, 'UTF-8'), $thisline); $thisline = mb_ereg_replace('{username}', htmlspecialchars($r['username'], ENT_COMPAT, 'UTF-8'), $thisline); $thisline = mb_ereg_replace('{region}', htmlspecialchars($r['region'], ENT_COMPAT, 'UTF-8'), $thisline); diff --git a/newwp.php b/newwp.php index d3a5e6650a..22f5d2b1cb 100644 --- a/newwp.php +++ b/newwp.php @@ -1,5 +1,6 @@ ' . tr('choose_waypoint_type') . ''; // if ($cache_record['type'] == '2' || $cache_record['type'] == '6' || $cache_record['type'] == '8' || $cache_record['type'] == '9') @@ -95,22 +94,22 @@ else $pomin = 0; - foreach ( get_wp_types_from_database($cache_record['type']) as $type ) { - if ($type['id'] == $sel_type) { - if (($type['id'] == 3) && ($pomin == 1)) { + foreach ( WaypointCommons::getTypesArray($cache_record['type']) as $type ) { + if ($type == $sel_type) { + if (($type == WaypointCommons::TYPE_FINAL) && ($pomin == 1)) { } // if final waypoint alreday exist for this cache do not allow create new waypoint type "final location" else - $types .= ''; + $types .= ''; } else { if (($type['id'] == 3) && ($pomin == 1)) { } //// if final waypoint alreday exist for this cache do not allow create new waypoint type "final location" else - $types .= ''; + $types .= ''; } } diff --git a/powerTrail.php b/powerTrail.php index 186890ef7f..9fee230e9e 100644 --- a/powerTrail.php +++ b/powerTrail.php @@ -30,8 +30,6 @@ $ocConfig = OcConfig::instance(); $appContainer = ApplicationContainer::Instance(); -require_once(__DIR__.'/lib/cache.php'); - $_SESSION['powerTrail']['userFounds'] = $usr['userFounds']; if ($ocConfig->isPowerTrailModuleSwitchOn() === false) { diff --git a/powerTrail/ajaxGetPowerTrailCaches.php b/powerTrail/ajaxGetPowerTrailCaches.php index c6b28d150e..db23e6782d 100644 --- a/powerTrail/ajaxGetPowerTrailCaches.php +++ b/powerTrail/ajaxGetPowerTrailCaches.php @@ -1,6 +1,7 @@ tr('pt244') ); - $cacheTypesIcons = cache::getCacheIconsSet(); $cacheRows = ''; @@ -95,12 +95,22 @@ function displayAllCachesOfPowerTrail(PowerTrail $powerTrail, $choseFinalCaches) $cacheRows .= ''; //display icon found/not found depend on current user if (isset($geocacheFoundArr[$geocache->getCacheId()])) { - $cacheRows .= ''; + $iconSrc = GeoCacheCommons::CacheIconByType( + $geocache->getCacheType(), + GeoCacheCommons::STATUS_READY, + GeoCacheLog::LOGTYPE_FOUNDIT); + } elseif ($geocache->getOwner()->getUserId() == $userId) { - $cacheRows .= ''; + $iconSrc = GeoCacheCommons::CacheIconByType( + $geocache->getCacheType(), + GeoCacheCommons::STATUS_READY, + null, false, true); } else { - $cacheRows .= ''; + $iconSrc = GeoCacheCommons::CacheIconByType( + $geocache->getCacheType(), GeoCacheCommons::STATUS_READY); } + $cacheRows .= ''; + //cachename, username $cacheRows .= '
' . tr('pt075') . ' ' . tr('pt076') . '
'. ''. @@ -165,7 +175,7 @@ function displayAllCachesOfPowerTrail(PowerTrail $powerTrail, $choseFinalCaches) // count the rest of types $restOfTypes = 0; - foreach (array_diff_key(GeoCache::CacheTypesArray(), $typesToShow) as $type) { + foreach (array_diff(GeoCache::CacheTypesArray(), $typesToShow) as $type) { $restOfTypes += $cachetypes[$type]; } if ($restOfTypes > 0) { diff --git a/search.php b/search.php index de8f6250d4..dd3760bbe2 100644 --- a/search.php +++ b/search.php @@ -50,7 +50,6 @@ function sanitize(&$array) $tplname = 'search'; $view->loadJQueryUI(); require(__DIR__.'/src/Views/search.inc.php'); - require(__DIR__.'/lib/caches.inc.php'); sanitize($_REQUEST); diff --git a/src/Controllers/PageLayout/MainLayoutController.php b/src/Controllers/PageLayout/MainLayoutController.php index f6e6d73b64..c5bf5759b8 100644 --- a/src/Controllers/PageLayout/MainLayoutController.php +++ b/src/Controllers/PageLayout/MainLayoutController.php @@ -112,7 +112,7 @@ private function initMainLayout() '/views/common/mainLayout.css')); } - if (Year::isPrimaAprilisToday()) { + if (Year::isPrimaAprilisToday() && OcConfig::isPADanceEnabled()) { // add rythm JS $this->view->addLocalJs( Uri::getLinkWithModificationTime( @@ -124,15 +124,14 @@ private function initMainLayout() $this->view->addLocalJs(Uri::getLinkWithModificationTime( '/vendor/js-cookie/js-cookie/src/js.cookie.js')); - } - if (Year::isPrimaAprilisToday()) { + if (Year::isPrimaAprilisToday() && OcConfig::isPADanceEnabled()) { $this->view->loadJQuery(); $logo = $config['headerLogo']; $logoTitle = 'discoCaching'; $logoSubtitle = 'The first discoCaching site!'; - } else if (date('m') == 12 || date('m') == 1) { + } else if (Year::isChristmassTime()) { $logo = $config['headerLogoWinter']; $logoTitle = tr('oc_on_all_pages_top_' . $config['ocNode']); $logoSubtitle = tr('oc_subtitle_on_all_pages_' . $config['ocNode']); diff --git a/src/Models/GeoCache/GeoCache.php b/src/Models/GeoCache/GeoCache.php index e548cb857a..fc42a5275d 100644 --- a/src/Models/GeoCache/GeoCache.php +++ b/src/Models/GeoCache/GeoCache.php @@ -81,9 +81,6 @@ class GeoCache extends GeoCacheCommons */ private $distance = -1; - /** @var $dictionary \cache */ - public $dictionary; - private $ownerId; /** @var $owner User */ @@ -182,8 +179,6 @@ public function __construct(array $params = array()) } elseif (isset($params['cacheUUID'])) { $this->loadByUUID($params['cacheUUID']); } - - $this->dictionary = \cache::instance(); } /** diff --git a/src/Models/GeoCache/GeoCacheLogCommons.php b/src/Models/GeoCache/GeoCacheLogCommons.php index 3bef4b6f57..bf5b80837d 100644 --- a/src/Models/GeoCache/GeoCacheLogCommons.php +++ b/src/Models/GeoCache/GeoCacheLogCommons.php @@ -107,7 +107,7 @@ public static function typeTranslationKey($logType) } } - public static function logTypes() + public static function logTypesArray() { return array( self::LOGTYPE_FOUNDIT, diff --git a/src/Models/GeoCache/Waypoint.php b/src/Models/GeoCache/Waypoint.php index 78f5776192..3ed3ea21e5 100644 --- a/src/Models/GeoCache/Waypoint.php +++ b/src/Models/GeoCache/Waypoint.php @@ -8,22 +8,9 @@ /** * Geocache Waypoint (place of interest) * represented in db by waypoints table - * - * @author Łza */ -class Waypoint +class Waypoint extends WaypointCommons { - const TYPE_PHYSICAL = 1; - const TYPE_VIRTUAL = 2; - const TYPE_FINAL = 3; - const TYPE_INTERESTING = 4; - const TYPE_PARKING = 5; - const TYPE_TRAILHEAD = 6; - - const STATUS_VISIBLE = 1; - const STATUS_VISIBLE_HIDDEN_COORDS = 2; - const STATUS_HIDDEN = 3; - const OPENCHECKER_ENABLED = 1; private $id; @@ -40,14 +27,7 @@ class Waypoint private $cacheId; private $openChecker; - private $iconNames = array( - self::TYPE_PHYSICAL => 'images/waypoints/wp_physical.png', - self::TYPE_VIRTUAL => 'images/waypoints/wp_virtual.png', - self::TYPE_FINAL => 'images/waypoints/wp_final.png', - self::TYPE_INTERESTING => 'images/waypoints/wp_reference.png', - self::TYPE_PARKING => 'images/waypoints/wp_parking.png', - self::TYPE_TRAILHEAD => 'images/waypoints/wp_trailhead.png' - ); + diff --git a/src/Models/GeoCache/WaypointCommons.php b/src/Models/GeoCache/WaypointCommons.php new file mode 100644 index 0000000000..e587fbe2a5 --- /dev/null +++ b/src/Models/GeoCache/WaypointCommons.php @@ -0,0 +1,64 @@ + 'images/waypoints/wp_physical.png', + self::TYPE_VIRTUAL => 'images/waypoints/wp_virtual.png', + self::TYPE_FINAL => 'images/waypoints/wp_final.png', + self::TYPE_INTERESTING => 'images/waypoints/wp_reference.png', + self::TYPE_PARKING => 'images/waypoints/wp_parking.png', + self::TYPE_TRAILHEAD => 'images/waypoints/wp_trailhead.png' + ); + + public static function typeTranslationKey($type) + { + return 'wayPointType'.$type; + } + + public static function getTypesArray($forCacheType=null) + { + $cacheTypesWithSimpleWps = [ + GeoCacheCommons::TYPE_TRADITIONAL, GeoCacheCommons::TYPE_VIRTUAL, + GeoCacheCommons::TYPE_WEBCAM, GeoCacheCommons::TYPE_EVENT, + GeoCacheCommons::TYPE_GEOPATHFINAL + ]; + + if ($forCacheType && in_array($forCacheType, $cacheTypesWithSimpleWps) ) { + return [ + self::TYPE_INTERESTING, + self::TYPE_PARKING, + self::TYPE_TRAILHEAD + ]; + } else { + return [ + self::TYPE_PHYSICAL, + self::TYPE_VIRTUAL, + self::TYPE_FINAL, + self::TYPE_INTERESTING, + self::TYPE_PARKING, + self::TYPE_TRAILHEAD + ]; + } + } + + public static function getIcon($type){ + self::ICONS[$type]; + } + +} diff --git a/src/Models/OcConfig/GeocacheConfigTrait.php b/src/Models/OcConfig/GeocacheConfigTrait.php new file mode 100644 index 0000000000..b24ce9084f --- /dev/null +++ b/src/Models/OcConfig/GeocacheConfigTrait.php @@ -0,0 +1,58 @@ +geocacheConfig) { + $this->geocacheConfig = self::getConfig("geocache", "geocache"); + } + return $this->geocacheConfig; + } + + /** + * Get Var from geocache.* files + * + * @param string $varName + * @throws \Exception + * @return string|array + */ + private static function getGeocacheConfigVar($varName) + { + $config = self::instance()->getGeocacheConfig(); + if (!is_array($config)) { + throw new \Exception("Invalid $varName setting: see /config/geocache.*"); + } + return $config[$varName]; + } +} diff --git a/src/Models/OcConfig/OcConfig.php b/src/Models/OcConfig/OcConfig.php index 4efcd3f35d..4c91cb13a7 100644 --- a/src/Models/OcConfig/OcConfig.php +++ b/src/Models/OcConfig/OcConfig.php @@ -5,6 +5,7 @@ final class OcConfig extends ConfigReader { use EmailConfigTrait, SiteConfigTrait, I18nConfigTrait, PicturesConfigTrait, MapConfigTrait; + use PrimaAprilisTrait, GeocacheConfigTrait; /* const OCNODE_GERMANY = 1; // Opencaching Germany http://www.opencaching.de OC @@ -50,9 +51,6 @@ final class OcConfig extends ConfigReader /** @var array the \src\Utils\Lock objects configuration array */ private $lockConfig; - /** @var array the watchlist configuration array */ - private $geoCacheConfig; - /** @var array the watchlist configuration array */ private $watchlistConfig; @@ -288,19 +286,6 @@ public function getLockConfig() return $this->lockConfig; } - - public function getGeoCacheConfig($setting = null) - { - if ($this->geoCacheConfig == null) { - $this->geoCacheConfig = self::getConfig("geocache", "geocache"); - } - if ($setting !== null) { - return $this->geoCacheConfig[$setting]; - } else { - return $this->geoCacheConfig; - } - } - /** * Gives watchlist configuration, tries to initialize it if null * diff --git a/src/Models/OcConfig/PrimaAprilisTrait.php b/src/Models/OcConfig/PrimaAprilisTrait.php new file mode 100644 index 0000000000..e9faa7bafb --- /dev/null +++ b/src/Models/OcConfig/PrimaAprilisTrait.php @@ -0,0 +1,72 @@ +primaAprilisConfig) { + $this->primaAprilisConfig = self::getConfig("primaAprilis", "config"); + } + return $this->primaAprilisConfig; + } + + /** + * Get Var from geocache.* files + * + * @param string $varName + * @throws \Exception + * @return string|array + */ + private static function getPAVar($varName) + { + $config = self::instance()->getPAConfig(); + if (!is_array($config)) { + throw new \Exception("Invalid $varName setting: see /config/primaAprilis.*"); + } + return $config[$varName]; + } +} diff --git a/src/Utils/DateTime/Year.php b/src/Utils/DateTime/Year.php index 5896b8e930..5ccdaedfe4 100644 --- a/src/Utils/DateTime/Year.php +++ b/src/Utils/DateTime/Year.php @@ -23,4 +23,10 @@ public static function current() { return date("Y"); } + + public static function isChristmassTime() + { + $month = date('m'); + return ($month == 12 || $month == 1); + } } diff --git a/src/Views/log_cache_multi.tpl.php b/src/Views/log_cache_multi.tpl.php index f3ba1449d5..9668f2911a 100644 --- a/src/Views/log_cache_multi.tpl.php +++ b/src/Views/log_cache_multi.tpl.php @@ -1,24 +1,8 @@ $v) { - if ($v['id'] == $status) { - return $v['icon_small']; - } - } -} +use src\Models\GeoCache\GeoCacheLogCommons; +use src\Models\GeoCache\GeoCacheCommons; -function get_icon_for_cache_type($type) -{ - $typySkrzynek = get_cache_types_from_database(); - foreach ($typySkrzynek as $k => $v) { - if ($v['id'] == $type) { - return $v['icon_large']; - } - } -} ?>