Browse Source
Merge pull request #69 from PietroCarrara/json-flags
Enable flags on the JSON api
pull/40/head
towards-a-new-leftypol
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
4 additions and
4 deletions
-
inc/api.php
-
inc/instance-config.php
|
@ -111,10 +111,10 @@ class Api { |
|
|
if ($threadsPage) return $apiPost; |
|
|
if ($threadsPage) return $apiPost; |
|
|
|
|
|
|
|
|
// Handle country field |
|
|
// Handle country field |
|
|
if (isset($post->body_nomarkup) && $this->config['country_flags']) { |
|
|
if (isset($post->body_nomarkup) && ($this->config['country_flags'] || $this->config['user_flag'])) { |
|
|
$modifiers = extract_modifiers($post->body_nomarkup); |
|
|
$modifiers = extract_modifiers($post->body_nomarkup); |
|
|
if (isset($modifiers['flag']) && isset($modifiers['flag alt']) && preg_match('/^[a-z]{2}$/', $modifiers['flag'])) { |
|
|
if (isset($modifiers['flag']) && isset($modifiers['flag alt']) && preg_match('/^[1-9a-z_-]{2,}$/', $modifiers['flag'])) { |
|
|
$country = strtoupper($modifiers['flag']); |
|
|
$country = strtolower($modifiers['flag']); |
|
|
if ($country) { |
|
|
if ($country) { |
|
|
$apiPost['country'] = $country; |
|
|
$apiPost['country'] = $country; |
|
|
$apiPost['country_name'] = $modifiers['flag alt']; |
|
|
$apiPost['country_name'] = $modifiers['flag alt']; |
|
|