mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 14:56:13 -06:00
Merge pull request #760 from openclassify/fatihalp
get currency with cron
This commit is contained in:
commit
252260a92c
@ -41,12 +41,6 @@ return [
|
|||||||
'default_value' => 6,
|
'default_value' => 6,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'tcmb_exchange_url' => [
|
|
||||||
'type' => 'anomaly.field_type.url',
|
|
||||||
'config' => [
|
|
||||||
'default_value' => 'http://www.tcmb.gov.tr/kurlar',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'default_published_time' => [
|
'default_published_time' => [
|
||||||
'type' => 'anomaly.field_type.integer',
|
'type' => 'anomaly.field_type.integer',
|
||||||
'bind' => 'adv.default_published_time',
|
'bind' => 'adv.default_published_time',
|
||||||
|
|||||||
@ -128,9 +128,6 @@ return [
|
|||||||
'show_lang_url' => [
|
'show_lang_url' => [
|
||||||
'name' => 'Show Lang Parameter For URL',
|
'name' => 'Show Lang Parameter For URL',
|
||||||
],
|
],
|
||||||
'tcmb_exchange_url' => [
|
|
||||||
'name' => 'TCMB Exchange URL',
|
|
||||||
],
|
|
||||||
'popular_ads_limit' => [
|
'popular_ads_limit' => [
|
||||||
'name' => 'Popular Ads Limit',
|
'name' => 'Popular Ads Limit',
|
||||||
],
|
],
|
||||||
|
|||||||
@ -125,15 +125,11 @@ return [
|
|||||||
'show_lang_url' => [
|
'show_lang_url' => [
|
||||||
'name' => 'URL için Dil Parametresini Göster',
|
'name' => 'URL için Dil Parametresini Göster',
|
||||||
],
|
],
|
||||||
'tcmb_exchange_url' => [
|
|
||||||
'name' => 'TCMB Exchange URL\'si',
|
|
||||||
],
|
|
||||||
'popular_ads_limit' => [
|
'popular_ads_limit' => [
|
||||||
'name' => 'Popüler İlan Limiti',
|
'name' => 'Popüler İlan Limiti',
|
||||||
],
|
],
|
||||||
|
|
||||||
//Image
|
//Image
|
||||||
|
|
||||||
'image_resize_backend' => [
|
'image_resize_backend' => [
|
||||||
'name' => 'Görüntüyü Yeniden Boyutlandır Arka Uç',
|
'name' => 'Görüntüyü Yeniden Boyutlandır Arka Uç',
|
||||||
],
|
],
|
||||||
|
|||||||
@ -1,72 +0,0 @@
|
|||||||
<?php namespace Visiosoft\AdvsModule\Adv\Command;
|
|
||||||
|
|
||||||
class getExchange
|
|
||||||
{
|
|
||||||
public $currency;
|
|
||||||
|
|
||||||
public function __construct($currency = null)
|
|
||||||
{
|
|
||||||
$this->currency = $currency;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function handle()
|
|
||||||
{
|
|
||||||
$exchange_xml = simplexml_load_file(setting_value('visiosoft.module.advs::tcmb_exchange_url') . '/today.xml');
|
|
||||||
$exchange_xml = json_decode(json_encode($exchange_xml), TRUE);
|
|
||||||
$exchange = [
|
|
||||||
'USD' => 0,
|
|
||||||
'EUR' => 3,
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($exchange as $key => $exchange_key) {
|
|
||||||
|
|
||||||
$buy = $exchange_xml['Currency'][$exchange_key]['BanknoteSelling'];
|
|
||||||
$exchange[$key] = [
|
|
||||||
'sell' => $exchange_xml['Currency'][$exchange_key]['BanknoteBuying'],
|
|
||||||
'buy' => $buy,
|
|
||||||
'status' => $this->getStatus($buy, $exchange_key)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->currency) {
|
|
||||||
if (array_key_exists($this->currency, $exchange)) {
|
|
||||||
return $exchange[$this->currency];
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $exchange;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStatus($today_buy, $exchange_key)
|
|
||||||
{
|
|
||||||
$today = now();
|
|
||||||
|
|
||||||
$number_of_days_to_be_reduced = 1;
|
|
||||||
if ($today->format('D') == 'Mon') {
|
|
||||||
$number_of_days_to_be_reduced = 3;
|
|
||||||
} else if ($today->format('D') == 'Sun') {
|
|
||||||
$number_of_days_to_be_reduced = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$date = $today->addDays('-' . $number_of_days_to_be_reduced);
|
|
||||||
|
|
||||||
$year_and_month = $date->format('Ym');
|
|
||||||
$date = $date->format('dmY');
|
|
||||||
|
|
||||||
|
|
||||||
$exchange_xml = simplexml_load_file(setting_value('visiosoft.module.advs::tcmb_exchange_url') . '/' . $year_and_month . '/' . $date . '.xml');
|
|
||||||
$exchange_xml = json_decode(json_encode($exchange_xml), TRUE);
|
|
||||||
|
|
||||||
$old_buy = $exchange_xml['Currency'][$exchange_key]['BanknoteSelling'];
|
|
||||||
|
|
||||||
$difference = ($today_buy * 10000) - ($old_buy * 10000);
|
|
||||||
|
|
||||||
if ($difference > 0) {
|
|
||||||
return 'increased';
|
|
||||||
} elseif ($difference < 0) {
|
|
||||||
return 'decreased';
|
|
||||||
}
|
|
||||||
return 'equal';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -5,7 +5,6 @@ use Twig_Environment;
|
|||||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\appendRequestURL;
|
use Visiosoft\AdvsModule\Adv\Command\appendRequestURL;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\GetAd;
|
use Visiosoft\AdvsModule\Adv\Command\GetAd;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\getExchange;
|
|
||||||
use Visiosoft\AdvsModule\Adv\Command\getPopular;
|
use Visiosoft\AdvsModule\Adv\Command\getPopular;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\GetUserAds;
|
use Visiosoft\AdvsModule\Adv\Command\GetUserAds;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\isActive;
|
use Visiosoft\AdvsModule\Adv\Command\isActive;
|
||||||
@ -107,16 +106,6 @@ class AdvsModulePlugin extends Plugin
|
|||||||
|
|
||||||
return $fn->getCallable()(...$args);
|
return $fn->getCallable()(...$args);
|
||||||
}, ['needs_environment' => true]
|
}, ['needs_environment' => true]
|
||||||
),
|
|
||||||
new \Twig_SimpleFunction(
|
|
||||||
'getExchange',
|
|
||||||
function ($currency = null) {
|
|
||||||
|
|
||||||
if (!$exchange = $this->dispatch(new getExchange($currency))) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $exchange;
|
|
||||||
}
|
|
||||||
), new \Twig_SimpleFunction(
|
), new \Twig_SimpleFunction(
|
||||||
'getPopular',
|
'getPopular',
|
||||||
function () {
|
function () {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user