Merge pull request #668 from openclassify/vedatakdgn

add popular ads limit && added Theme Settings Link For Settings
This commit is contained in:
Dia Shalabi 2020-09-17 17:30:47 +03:00 committed by GitHub
commit 239689e5de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 78 additions and 12 deletions

View File

@ -21,6 +21,7 @@ return [
'title' => 'visiosoft.module.advs::section.ads', 'title' => 'visiosoft.module.advs::section.ads',
'fields' => [ 'fields' => [
'latest-limit', 'latest-limit',
'popular_ads_limit',
'default_view_type', 'default_view_type',
'hide_zero_price', 'hide_zero_price',
'auto_approve', 'auto_approve',

View File

@ -248,4 +248,11 @@ return [
'default_value' => false, 'default_value' => false,
] ]
], ],
'popular_ads_limit' => [
'type' => 'anomaly.field_type.integer',
'config' => [
'default_value' => 15,
],
],
]; ];

View File

@ -155,4 +155,7 @@ return [
'tcmb_exchange_url' => [ 'tcmb_exchange_url' => [
'name' => 'TCMB Exchange URL', 'name' => 'TCMB Exchange URL',
], ],
'popular_ads_limit' => [
'name' => 'Popular Ads Limit',
],
]; ];

View File

@ -477,4 +477,14 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
->where('advs_advs.status', 'approved') ->where('advs_advs.status', 'approved')
->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s')); ->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s'));
} }
public function getPopular()
{
return $this->newQuery()
->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
->where('status', '=', 'approved')
->where('slug', '!=', '')
->orderBy('count_show_ad', 'desc')
->paginate(setting_value('visiosoft.module.advs::popular_ads_limit', setting_value('streams::per_page')));
}
} }

View File

@ -0,0 +1,20 @@
<?php namespace Visiosoft\AdvsModule\Adv\Command;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
class getPopular
{
public function handle(AdvRepositoryInterface $repository)
{
$ads = $repository->getPopular();
$ads = $repository->getModel()->getLocationNames($ads);
foreach ($ads as $index => $ad) {
$ads[$index]->detail_url = $repository->getModel()->getAdvDetailLinkByModel($ad, 'list');
$ads[$index] = $repository->getModel()->AddAdsDefaultCoverImage($ad);
}
return $ads;
}
}

View File

@ -39,4 +39,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function extendAds($allAds, $isAdmin = false); public function extendAds($allAds, $isAdmin = false);
public function getByUsersIDs($usersIDs); public function getByUsersIDs($usersIDs);
public function getPopular();
} }

View File

@ -6,8 +6,10 @@ 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\getExchange;
use Visiosoft\AdvsModule\Adv\Command\getPopular;
use Visiosoft\AdvsModule\Adv\Command\isActive; use Visiosoft\AdvsModule\Adv\Command\isActive;
use Visiosoft\AdvsModule\Adv\Command\LatestAds; use Visiosoft\AdvsModule\Adv\Command\LatestAds;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Visiosoft\AdvsModule\Currency\Currency; use Visiosoft\AdvsModule\Currency\Currency;
use Visiosoft\AdvsModule\Currency\CurrencyFormat; use Visiosoft\AdvsModule\Currency\CurrencyFormat;
@ -109,7 +111,15 @@ class AdvsModulePlugin extends Plugin
} }
return $exchange; return $exchange;
} }
) ), new \Twig_SimpleFunction(
'getPopular',
function () {
if (!$popular = $this->dispatch(new getPopular())) {
return null;
}
return $popular;
}
),
]; ];
} }
} }

View File

@ -365,18 +365,24 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
{ {
// Run extra post-boot registration logic here. // Run extra post-boot registration logic here.
// Use method injection or commands to bring in services. // Use method injection or commands to bring in services.
$slug = 'general_settings'; $settings_url = [
$section = [ 'general_settings' => [
'title' => 'visiosoft.module.advs::button.general_settings', 'title' => 'visiosoft.module.advs::button.general_settings',
'href' => '/admin/settings/modules/visiosoft.module.advs', 'href' => '/admin/settings/modules/visiosoft.module.advs',
],
'theme_settings' => [
'title' => 'visiosoft.theme.defaultadmin::section.theme_settings.name',
'href' => url('admin/settings/themes/' . setting_value('streams::standard_theme')),
],
'assets_clear' => [
'title' => 'visiosoft.module.advs::section.assets_clear.name',
'href' => route('assets_clear'),
],
]; ];
$slug2 = 'assets_clear';
$section2 = [ foreach ($settings_url as $key => $value) {
'title' => 'visiosoft.module.advs::section.assets_clear.name', $addonCollection->get('anomaly.module.settings')->addSection($key, $value);
'href' => '/admin/assets/clear', }
];
$addonCollection->get('anomaly.module.settings')->addSection($slug, $section);
$addonCollection->get('anomaly.module.settings')->addSection($slug2, $section2);
// Disable file versioning // Disable file versioning
$fileModel->disableVersioning(); $fileModel->disableVersioning();

View File

@ -0,0 +1,7 @@
<?php
return [
'theme_settings' => [
'name' => 'Theme Settings'
],
];