Country flags in API if they are enabled
This commit is contained in:
parent
ecda099dfb
commit
618d979ec4
16
inc/api.php
16
inc/api.php
@ -3,6 +3,7 @@
|
|||||||
* Copyright (c) 2010-2013 Tinyboard Development Group
|
* Copyright (c) 2010-2013 Tinyboard Development Group
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for generating json API compatible with 4chan API
|
* Class for generating json API compatible with 4chan API
|
||||||
*/
|
*/
|
||||||
@ -11,6 +12,8 @@ class Api {
|
|||||||
/**
|
/**
|
||||||
* Translation from local fields to fields in 4chan-style API
|
* Translation from local fields to fields in 4chan-style API
|
||||||
*/
|
*/
|
||||||
|
$this->config = $config;
|
||||||
|
|
||||||
$this->postFields = array(
|
$this->postFields = array(
|
||||||
'id' => 'no',
|
'id' => 'no',
|
||||||
'thread' => 'resto',
|
'thread' => 'resto',
|
||||||
@ -64,6 +67,7 @@ class Api {
|
|||||||
if ($val !== null && $val !== '') {
|
if ($val !== null && $val !== '') {
|
||||||
$apiPost[$translated] = $toInt ? (int) $val : $val;
|
$apiPost[$translated] = $toInt ? (int) $val : $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($post->filename)) {
|
if (isset($post->filename)) {
|
||||||
@ -72,6 +76,18 @@ class Api {
|
|||||||
$apiPost['ext'] = substr($post->filename, $dotPos);
|
$apiPost['ext'] = substr($post->filename, $dotPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle country field
|
||||||
|
if (isset($post->body_nomarkup) && $this->config['country_flags']) {
|
||||||
|
$modifiers = extract_modifiers($post->body_nomarkup);
|
||||||
|
if (isset($modifiers['flag']) && isset($modifiers['flag alt'])) {
|
||||||
|
$country = mb_convert_case($modifiers['flag'], MB_CASE_UPPER);
|
||||||
|
if ($country) {
|
||||||
|
$apiPost['country'] = $country;
|
||||||
|
$apiPost['country_name'] = $modifiers['flag alt'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $apiPost;
|
return $apiPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user