Skip to content

Commit

Permalink
fix: json file path
Browse files Browse the repository at this point in the history
  • Loading branch information
dr5hn committed Oct 5, 2024
1 parent 8d8d766 commit 31a7eb0
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 66 deletions.
12 changes: 6 additions & 6 deletions bin/Commands/ExportCsv.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ protected function execute(InputInterface $input, OutputInterface $output)

$files = array(
'countries' => array(
'from' => '/countries.json',
'from' => '/json/countries.json',
'to' => '/csv/countries.csv',
),
'states' => array(
'from' => '/states.json',
'from' => '/json/states.json',
'to' => '/csv/states.csv',
),
'cities' => array(
'from' => '/cities.json',
'from' => '/json/cities.json',
'to' => '/csv/cities.csv',
),
'regions' => array(
'from' => '/regions.json',
'from' => '/json/regions.json',
'to' => '/csv/regions.csv',
),
'subregions' => array(
'from' => '/subregions.json',
'from' => '/json/subregions.json',
'to' => '/csv/subregions.csv',
),
);
Expand Down Expand Up @@ -78,4 +78,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 1;
}

}
}
24 changes: 12 additions & 12 deletions bin/Commands/ExportJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$db = Config::getConfig()->getDB();

$rootDir = PATH_BASE . '../..';
$rootDir = PATH_BASE . '../../json';

$r = 0; // regions
$s = 0; // suberegions
Expand Down Expand Up @@ -277,7 +277,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('Total Countries Count : '.count($countriesArray));
$output->writeln('Total States Count : '.count($statesArray));
$output->writeln('Total Cities Count : '.count($citiesArray));

$exportTo = $rootDir . '/countries.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($countriesArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
Expand All @@ -290,55 +290,55 @@ protected function execute(InputInterface $input, OutputInterface $output)
fwrite($fp, json_encode($statesArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/cities.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($citiesArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/states+cities.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($stateCityArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/countries+states.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($countryStateArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/countries+cities.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($countryCityArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/countries+states+cities.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($countryStateCityArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/regions.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($regionsArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);

$exportTo = $rootDir . '/subregions.json';
$fp = fopen($exportTo, 'w'); // Putting Array to JSON
fwrite($fp, json_encode($subregionsArray, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT).PHP_EOL);
$output->writeln( 'JSON Exported to ' .$exportTo );
fclose($fp);


$db->close();


return 1;
}


}
}
20 changes: 10 additions & 10 deletions bin/Commands/ExportXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,47 +18,47 @@ protected function execute(InputInterface $input, OutputInterface $output)
$rootDir = PATH_BASE . '../..';
$files = array(
'regions' => array(
'from' => '/regions.json',
'from' => '/json/regions.json',
'to' => '/xml/regions.xml',
'singular' => 'region',
),
'subregions' => array(
'from' => '/subregions.json',
'from' => '/json/subregions.json',
'to' => '/xml/subregions.xml',
'singular' => 'subregion',
),
'countries' => array(
'from' => '/countries.json',
'from' => '/json/countries.json',
'to' => '/xml/countries.xml',
'singular' => 'country',
),
'states' => array(
'from' => '/states.json',
'from' => '/json/states.json',
'to' => '/xml/states.xml',
'singular' => 'state',
),
'cities' => array(
'from' => '/cities.json',
'from' => '/json/cities.json',
'to' => '/xml/cities.xml',
'singular' => 'city',
),
'states_cities' => array(
'from' => '/states+cities.json',
'from' => '/json/states+cities.json',
'to' => '/xml/states+cities.xml',
'singular' => 'state_city',
),
'countries_states' => array(
'from' => '/countries+states.json',
'from' => '/json/countries+states.json',
'to' => '/xml/countries+states.xml',
'singular' => 'country_state',
),
'countries_cities' => array(
'from' => '/countries+cities.json',
'from' => '/json/countries+cities.json',
'to' => '/xml/countries+cities.xml',
'singular' => 'country_city',
),
'countries_states_cities' => array(
'from' => '/countries+states+cities.json',
'from' => '/json/countries+states+cities.json',
'to' => '/xml/countries+states+cities.xml',
'singular' => 'country_state_city',
),
Expand Down Expand Up @@ -92,4 +92,4 @@ protected function execute(InputInterface $input, OutputInterface $output)
}


}
}
20 changes: 10 additions & 10 deletions bin/Commands/ExportYaml.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,47 +19,47 @@ protected function execute(InputInterface $input, OutputInterface $output)

$files = array(
'regions' => array(
'from' => '/regions.json',
'from' => '/json/regions.json',
'to' => '/yml/regions.yml',
'singular' => 'region',
),
'subregions' => array(
'from' => '/subregions.json',
'from' => '/json/subregions.json',
'to' => '/yml/subregions.yml',
'singular' => 'subregion',
),
'countries' => array(
'from' => '/countries.json',
'from' => '/json/countries.json',
'to' => '/yml/countries.yml',
'singular' => 'country',
),
'states' => array(
'from' => '/states.json',
'from' => '/json/states.json',
'to' => '/yml/states.yml',
'singular' => 'state',
),
'cities' => array(
'from' => '/cities.json',
'from' => '/json/cities.json',
'to' => '/yml/cities.yml',
'singular' => 'city',
),
'states_cities' => array(
'from' => '/states+cities.json',
'from' => '/json/states+cities.json',
'to' => '/yml/states+cities.yml',
'singular' => 'state_city',
),
'countries_states' => array(
'from' => '/countries+states.json',
'from' => '/json/countries+states.json',
'to' => '/yml/countries+states.yml',
'singular' => 'country_state',
),
'countries_cities' => array(
'from' => '/countries+cities.json',
'from' => '/json/countries+cities.json',
'to' => '/yml/countries+cities.yml',
'singular' => 'country_city',
),
'countries_states_cities' => array(
'from' => '/countries+states+cities.json',
'from' => '/json/countries+states+cities.json',
'to' => '/yml/countries+states+cities.yml',
'singular' => 'country_state_city',
),
Expand All @@ -82,4 +82,4 @@ protected function execute(InputInterface $input, OutputInterface $output)

return 1;
}
}
}
6 changes: 3 additions & 3 deletions docs/sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ self.addEventListener('install', (e) => {
'./vendor/dynatable/css/jquery.dynatable.css',
'./vendor/dynatable/js/jquery.dynatable.js',
'./vendor/jquery/jquery.min.js',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/countries.json',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/states.json',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/cities.json'
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/json/countries.json',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/json/states.json',
'https://raw.githubusercontent.com/dr5hn/countries-states-cities-database/master/json/cities.json'
]);
})
);
Expand Down
12 changes: 6 additions & 6 deletions scripts/export_csv.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
// Require Array2XML class which takes a PHP array and changes it to XML
require_once 'vendor/base.php';

$rootDir = dirname(dirname(__FILE__));
$rootDir = dirname(dirname(__FILE__)).'/json';
$files = array(
'countries' => array(
'from' => '/countries.json',
'from' => '/json/countries.json',
'to' => '/csv/countries.csv',
),
'states' => array(
'from' => '/states.json',
'from' => '/json/states.json',
'to' => '/csv/states.csv',
),
'cities' => array(
'from' => '/cities.json',
'from' => '/json/cities.json',
'to' => '/csv/cities.csv',
),
'regions' => array(
'from' => '/regions.json',
'from' => '/json/regions.json',
'to' => '/csv/regions.csv',
),
'subregions' => array(
'from' => '/subregions.json',
'from' => '/json/subregions.json',
'to' => '/csv/subregions.csv',
),
);
Expand Down
18 changes: 9 additions & 9 deletions scripts/export_xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,47 @@
$rootDir = dirname(dirname(__FILE__));
$files = array(
'regions' => array(
'from' => '/regions.json',
'from' => '/json/regions.json',
'to' => '/xml/regions.xml',
'singular' => 'region',
),
'subregions' => array(
'from' => '/subregions.json',
'from' => '/json/subregions.json',
'to' => '/xml/subregions.xml',
'singular' => 'subregion',
),
'countries' => array(
'from' => '/countries.json',
'from' => '/json/countries.json',
'to' => '/xml/countries.xml',
'singular' => 'country',
),
'states' => array(
'from' => '/states.json',
'from' => '/json/states.json',
'to' => '/xml/states.xml',
'singular' => 'state',
),
'cities' => array(
'from' => '/cities.json',
'from' => '/json/cities.json',
'to' => '/xml/cities.xml',
'singular' => 'city',
),
'states_cities' => array(
'from' => '/states+cities.json',
'from' => '/json/states+cities.json',
'to' => '/xml/states+cities.xml',
'singular' => 'state_city',
),
'countries_states' => array(
'from' => '/countries+states.json',
'from' => '/json/countries+states.json',
'to' => '/xml/countries+states.xml',
'singular' => 'country_state',
),
'countries_cities' => array(
'from' => '/countries+cities.json',
'from' => '/json/countries+cities.json',
'to' => '/xml/countries+cities.xml',
'singular' => 'country_city',
),
'countries_states_cities' => array(
'from' => '/countries+states+cities.json',
'from' => '/json/countries+states+cities.json',
'to' => '/xml/countries+states+cities.xml',
'singular' => 'country_state_city',
),
Expand Down
Loading

0 comments on commit 31a7eb0

Please sign in to comment.