forked from GithubBackups/vichan
api.php: using depedency injection instead of globals
This commit is contained in:
parent
4d8a4db338
commit
4f68166870
10
inc/api.php
10
inc/api.php
@ -45,13 +45,11 @@ class Api {
|
|||||||
'size' => 'fsize'
|
'size' => 'fsize'
|
||||||
];
|
];
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct(bool $show_filename, bool $hide_email, bool $country_flags) {
|
||||||
global $config;
|
|
||||||
|
|
||||||
// Translation from local fields to fields in 4chan-style API
|
// Translation from local fields to fields in 4chan-style API
|
||||||
$this->show_filename = $config['show_filename'];
|
$this->show_filename = $show_filename;
|
||||||
$this->hide_email = $config['hide_email'];
|
$this->hide_email = $hide_email;
|
||||||
$this->country_flags = $config['country_flags'];
|
$this->country_flags = $country_flags;
|
||||||
|
|
||||||
$this->postFields = [
|
$this->postFields = [
|
||||||
'id' => 'no',
|
'id' => 'no',
|
||||||
|
@ -1730,7 +1730,11 @@ function buildIndex($global_api = "yes") {
|
|||||||
$antibot = null;
|
$antibot = null;
|
||||||
|
|
||||||
if ($config['api']['enabled']) {
|
if ($config['api']['enabled']) {
|
||||||
$api = new Api();
|
$api = new Api(
|
||||||
|
$config['show_filename'],
|
||||||
|
$config['hide_email'],
|
||||||
|
$config['country_flags']
|
||||||
|
);
|
||||||
$catalog = array();
|
$catalog = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2388,7 +2392,11 @@ function buildThread($id, $return = false, $mod = false) {
|
|||||||
|
|
||||||
// json api
|
// json api
|
||||||
if ($config['api']['enabled'] && !$mod) {
|
if ($config['api']['enabled'] && !$mod) {
|
||||||
$api = new Api();
|
$api = new Api(
|
||||||
|
$config['show_filename'],
|
||||||
|
$config['hide_email'],
|
||||||
|
$config['country_flags']
|
||||||
|
);
|
||||||
$json = json_encode($api->translateThread($thread));
|
$json = json_encode($api->translateThread($thread));
|
||||||
$jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json';
|
$jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json';
|
||||||
file_write($jsonFilename, $json);
|
file_write($jsonFilename, $json);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user