Remove remnants of Timezonelist library
This commit is contained in:
parent
4ac781a20d
commit
0c89d36a16
@ -12,9 +12,9 @@ use App\Repositories\AirportRepository;
|
||||
use App\Repositories\Criteria\WhereCriteria;
|
||||
use App\Services\ExportService;
|
||||
use App\Services\ImportService;
|
||||
use App\Support\Timezonelist;
|
||||
use Flash;
|
||||
use Illuminate\Http\Request;
|
||||
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||
use Log;
|
||||
use Response;
|
||||
use Storage;
|
||||
|
@ -14,11 +14,11 @@ use App\Repositories\AirportRepository;
|
||||
use App\Repositories\PirepRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Services\UserService;
|
||||
use App\Support\Timezonelist;
|
||||
use DB;
|
||||
use Flash;
|
||||
use Hash;
|
||||
use Illuminate\Http\Request;
|
||||
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||
use Log;
|
||||
use Prettus\Repository\Exceptions\RepositoryException;
|
||||
use Response;
|
||||
|
@ -10,12 +10,12 @@ use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Services\UserService;
|
||||
use App\Support\Countries;
|
||||
use App\Support\Timezonelist;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||
|
||||
/**
|
||||
* Class RegisterController
|
||||
@ -56,6 +56,8 @@ class RegisterController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function showRegistrationForm()
|
||||
|
@ -9,15 +9,15 @@ use App\Repositories\AirlineRepository;
|
||||
use App\Repositories\AirportRepository;
|
||||
use App\Repositories\UserRepository;
|
||||
use App\Support\Countries;
|
||||
use Flash;
|
||||
use Hash;
|
||||
use App\Support\Timezonelist;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Intervention\Image\Facades\Image;
|
||||
use Jackiedo\Timezonelist\Facades\Timezonelist;
|
||||
use Log;
|
||||
use Validator;
|
||||
use Laracasts\Flash\Flash;
|
||||
|
||||
/**
|
||||
* Class ProfileController
|
||||
@ -86,9 +86,10 @@ class ProfileController extends Controller
|
||||
|
||||
/**
|
||||
* Show the edit for form the user's profile
|
||||
*
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|\Illuminate\View\View
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Support\Timezonelist;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class TimezonelistProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Register services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('timezonelist', function ($app) {
|
||||
return new Timezonelist();
|
||||
});
|
||||
}
|
||||
}
|
@ -22,12 +22,14 @@
|
||||
namespace App\Support;
|
||||
|
||||
use DateTimeZone;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
/**
|
||||
* This library is from:
|
||||
* https://github.com/JackieDo/Timezone-List
|
||||
*
|
||||
* With some changes to suite the formatting, etc that we need
|
||||
* With some changes to suite the formatting, etc that we need.
|
||||
* Also changed it to provide all static methods instead of through a facade
|
||||
*/
|
||||
class Timezonelist
|
||||
{
|
||||
@ -40,7 +42,7 @@ class Timezonelist
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $popularTimezones = [
|
||||
protected static $popularTimezones = [
|
||||
'GMT' => 'GMT timezone',
|
||||
'UTC' => 'UTC timezone',
|
||||
];
|
||||
@ -49,7 +51,7 @@ class Timezonelist
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $continents = [
|
||||
protected static $continents = [
|
||||
'Africa' => DateTimeZone::AFRICA,
|
||||
'America' => DateTimeZone::AMERICA,
|
||||
'Antarctica' => DateTimeZone::ANTARCTICA,
|
||||
@ -69,14 +71,17 @@ class Timezonelist
|
||||
* @param string $continent
|
||||
* @param bool $htmlencode
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function formatTimezone($timezone, $continent, $htmlencode = true)
|
||||
public static function formatTimezone($timezone, $continent, $htmlencode = true)
|
||||
{
|
||||
try {
|
||||
$time = new \DateTimeImmutable(null, new DateTimeZone($timezone));
|
||||
} catch (\Exception $e) {
|
||||
Log::error($e->getMessage());
|
||||
return '';
|
||||
}
|
||||
|
||||
$offset = $time->format('P');
|
||||
if ($htmlencode) {
|
||||
$offset = str_replace(['-', '+'], [' − ', ' + '], $offset);
|
||||
@ -95,9 +100,11 @@ class Timezonelist
|
||||
* @param mixed $attr
|
||||
* @param bool $htmlencode
|
||||
*
|
||||
* @throws \Exception
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function create($name, $selected = '', $attr = '', $htmlencode = true)
|
||||
public static function create($name, $selected = '', $attr = '', $htmlencode = true)
|
||||
{
|
||||
// Attributes for select element
|
||||
$attrSet = '';
|
||||
@ -114,13 +121,13 @@ class Timezonelist
|
||||
$listbox = '<select name="'.$name.'"'.$attrSet.'>';
|
||||
// Add popular timezones
|
||||
$listbox .= '<optgroup label="General">';
|
||||
foreach ($this->popularTimezones as $key => $value) {
|
||||
foreach (self::$popularTimezones as $key => $value) {
|
||||
$selected_attr = ($selected === $key) ? ' selected="selected"' : '';
|
||||
$listbox .= '<option value="'.$key.'"'.$selected_attr.'>'.$value.'</option>';
|
||||
$listbox .= '<option value="'.$key.'" '.$selected_attr.'>'.$value.'</option>';
|
||||
}
|
||||
$listbox .= '</optgroup>';
|
||||
// Add all timezone of continents
|
||||
foreach ($this->continents as $continent => $mask) {
|
||||
foreach (self::$continents as $continent => $mask) {
|
||||
$timezones = DateTimeZone::listIdentifiers($mask);
|
||||
// start optgroup tag
|
||||
$listbox .= '<optgroup label="'.$continent.'">';
|
||||
@ -128,7 +135,7 @@ class Timezonelist
|
||||
foreach ($timezones as $timezone) {
|
||||
$selected_attr = ($selected === $timezone) ? ' selected="selected"' : '';
|
||||
$listbox .= '<option value="'.$timezone.'"'.$selected_attr.'>';
|
||||
$listbox .= $this->formatTimezone($timezone, $continent, $htmlencode);
|
||||
$listbox .= static::formatTimezone($timezone, $continent, $htmlencode);
|
||||
$listbox .= '</option>';
|
||||
}
|
||||
// end optgroup tag
|
||||
@ -146,18 +153,18 @@ class Timezonelist
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function toArray($htmlencode = false)
|
||||
public static function toArray($htmlencode = false)
|
||||
{
|
||||
$list = [];
|
||||
// Add popular timezones to list
|
||||
foreach ($this->popularTimezones as $key => $value) {
|
||||
foreach (self::$popularTimezones as $key => $value) {
|
||||
$list['General'][$key] = $value;
|
||||
}
|
||||
// Add all timezone of continents to list
|
||||
foreach ($this->continents as $continent => $mask) {
|
||||
foreach (self::$continents as $continent => $mask) {
|
||||
$timezones = DateTimeZone::listIdentifiers($mask);
|
||||
foreach ($timezones as $timezone) {
|
||||
$list[$continent][$timezone] = $this->formatTimezone($timezone, $continent, $htmlencode);
|
||||
$list[$continent][$timezone] = self::formatTimezone($timezone, $continent, $htmlencode);
|
||||
}
|
||||
}
|
||||
return $list;
|
||||
|
@ -82,7 +82,6 @@ return [
|
||||
App\Providers\AuthServiceProvider::class,
|
||||
App\Providers\EventServiceProvider::class,
|
||||
App\Providers\RouteServiceProvider::class,
|
||||
App\Providers\TimezonelistProvider::class,
|
||||
App\Providers\MeasurementsProvider::class,
|
||||
App\Providers\BindServiceProviders::class,
|
||||
],
|
||||
|
Loading…
Reference in New Issue
Block a user