mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Merge remote-tracking branch 'origin/basetheme' into basetheme
This commit is contained in:
commit
f452477792
@ -1,7 +1,6 @@
|
||||
<div class="description-info">
|
||||
<div class="row">
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<nav>
|
||||
<div class="nav nav-tabs nav-fill ad-detail-tabs" id="nav-tab" role="tablist">
|
||||
@ -12,7 +11,7 @@
|
||||
aria-selected="true">{{ trans('visiosoft.module.advs::field.description.name') }}</a>
|
||||
|
||||
<!-- Content Tab With Block -->
|
||||
{{ addBlock('ad-detail/content-tab')|raw }}
|
||||
{{ addBlock('ad-detail/content-tab',{'features':features})|raw }}
|
||||
<!-- Content Tab With Block -->
|
||||
</div>
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<div class="row">
|
||||
<div id="filter" class="w-100 mb-3">
|
||||
|
||||
{{ addBlock('ads-list/partials/list-filter',{'mainCats':mainCats,'subCats':subCats})|raw }}
|
||||
{{ addBlock('ads-list/partials/list-filter',{'mainCats':mainCats,'subCats':subCats,'ranges':ranges,'checkboxes':checkboxes,'radio':radio})|raw }}
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header breadcrumb mb-0" id="priceHeading">
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
<th scope="col"
|
||||
class="text-center align-middle">{{ trans('visiosoft.module.advs::field.advs_list_table_thead.location_city') }}
|
||||
/ {{ trans('visiosoft.module.advs::field.advs_list_table_thead.location_country') }}</th>
|
||||
{{ addBlock('ads-list/table-column',{'seenList':seenList})|raw }}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -43,6 +44,7 @@
|
||||
<small>{{ adv.city_name }} / {{ adv.country_name }}</small>
|
||||
</td>
|
||||
{% endif %}
|
||||
{{ addBlock('ads-list/table-row',{'seenList':seenList,'adv':adv})|raw }}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@ -80,7 +80,11 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
}
|
||||
if (!empty($param['cat'])) {
|
||||
$cat = new CategoryModel();
|
||||
$catLevel = $cat->getCatLevel($param['cat']);
|
||||
$cat_d = $cat->find($param['cat']);
|
||||
if ($cat_d->parent_category_id == null)
|
||||
$catLevel = 1;
|
||||
else
|
||||
$catLevel = $cat->getCatLevel($param['cat']);
|
||||
$catLevel = "cat" . $catLevel;
|
||||
$query = $query->where($catLevel, $param['cat']);
|
||||
}
|
||||
|
||||
@ -194,6 +194,7 @@ class AdvsController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($param['cat']) and $param['cat'] != "") {
|
||||
$cat = $param['cat'];
|
||||
$seo_keywords = $this->category_model->getMeta_keywords($param['cat']);
|
||||
@ -214,9 +215,9 @@ class AdvsController extends PublicController
|
||||
if ($isActiveCustomFields) {
|
||||
$returnvalues = app('Visiosoft\CustomfieldsModule\Http\Controller\cfController')->index($mainCats, $subCats);
|
||||
$checkboxes = $returnvalues['checkboxes'];
|
||||
$textfields = $returnvalues['textfields'];
|
||||
$topfields = $returnvalues['topfields'];
|
||||
$ranges = $returnvalues['ranges'];
|
||||
$radio = $returnvalues['radio'];
|
||||
}
|
||||
|
||||
if (!empty($param['user'])) {
|
||||
@ -224,8 +225,8 @@ class AdvsController extends PublicController
|
||||
$userProfile = $this->profile_repository->getProfile($user->id);
|
||||
}
|
||||
|
||||
$compact = compact('advs', 'countries', 'mainCats', 'subCats', 'textfields', 'checkboxes', 'request',
|
||||
'user', 'userProfile', 'featured_advs', 'type', 'topfields', 'ranges', 'seenList', 'searchedCountry');
|
||||
$compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'request',
|
||||
'user', 'userProfile', 'featured_advs', 'type', 'topfields', 'ranges', 'seenList', 'searchedCountry', 'radio');
|
||||
|
||||
Cookie::queue(Cookie::make('last_search', $this->requestHttp->getRequestUri(), 84000));
|
||||
|
||||
|
||||
@ -5,6 +5,6 @@ return [
|
||||
'title' => 'Category',
|
||||
],
|
||||
'placeholderforsearch' => [
|
||||
'title' => 'Placeholderforsearch',
|
||||
'title' => 'Placeholder',
|
||||
],
|
||||
];
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'clean_subcategories' => 'Clean Subcategories',
|
||||
];
|
||||
@ -9,7 +9,10 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
|
||||
|
||||
public function getCat($id)
|
||||
{
|
||||
return CategoryModel::query()->where('cats_category.id', $id)->first();
|
||||
return CategoryModel::query()
|
||||
->where('cats_category.id', $id)
|
||||
->whereRaw('deleted_at IS NULL')
|
||||
->first();
|
||||
}
|
||||
|
||||
public function getParentCats($id, $type = null)
|
||||
@ -34,7 +37,11 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
|
||||
}
|
||||
}
|
||||
if ($type == 'category_ids') {
|
||||
return CategoryModel::query()->whereIn('cats_category.id', $cat_ids)->orderBy('cats_category.id', 'asc')->get();
|
||||
return CategoryModel::query()
|
||||
->whereIn('cats_category.id', $cat_ids)
|
||||
->whereRaw('deleted_at IS NULL')
|
||||
->orderBy('cats_category.id', 'asc')
|
||||
->get();
|
||||
}
|
||||
if ($type == "parent_id") {
|
||||
$cat_ids = array_reverse($cat_ids);
|
||||
@ -92,11 +99,12 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
|
||||
$cats = $cats->where('cats_category.id', '!=', $selected);
|
||||
}
|
||||
}
|
||||
$cats = $cats->where('name', 'like', $keyword . '%');
|
||||
$cats = $cats->where('name', 'like', $keyword . '%')
|
||||
->whereRaw('deleted_at IS NULL');
|
||||
|
||||
$cats = $cats->leftJoin('cats_category_translations', function ($join) {
|
||||
$join->on('cats_category.id', '=', 'cats_category_translations.entry_id');
|
||||
$join->where('cats_category_translations.locale', '=', Request()->session()->get('_locale'));
|
||||
$join->where('cats_category_translations.locale', '=', Request()->session()->get('_locale', setting_value('streams::default_locale')));
|
||||
});
|
||||
$cats = $cats->select('cats_category.*', 'cats_category_translations.name as name');
|
||||
$cats = $cats->orderBy('id', 'DESC')
|
||||
@ -140,4 +148,24 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface
|
||||
{
|
||||
return $this->find($cat_id)->name;
|
||||
}
|
||||
|
||||
public function getMains($id)
|
||||
{
|
||||
$categories = array();
|
||||
$z = 1;
|
||||
for ($i = 1; $i <= $z; $i++) {
|
||||
$main = $this->find($id);
|
||||
$new = array();
|
||||
$new['id'] = $main->id;
|
||||
$new['val'] = $main->name;
|
||||
$categories[] = $new;
|
||||
if ($main->parent_category_id != null) {
|
||||
$id = $main->parent_category_id;
|
||||
$z++;
|
||||
}
|
||||
}
|
||||
$categories = array_reverse($categories);
|
||||
unset($categories[count($categories) - 1]);
|
||||
return $categories;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,9 @@ use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel;
|
||||
|
||||
class CategoryPresenter extends EntryPresenter
|
||||
{
|
||||
public function getAdvsListUrl($attributes) {
|
||||
return \route('visiosoft.module.advs::list', "cat=".$attributes);
|
||||
public function getAdvsListUrl($attributes)
|
||||
{
|
||||
return \route('visiosoft.module.advs::list', "cat=" . $attributes);
|
||||
}
|
||||
|
||||
public function getCategoryName($id)
|
||||
@ -23,23 +24,7 @@ class CategoryPresenter extends EntryPresenter
|
||||
|
||||
public function getMains($id)
|
||||
{
|
||||
$categories = array();
|
||||
$z = 1;
|
||||
for($i = 1; $i <= $z; $i++)
|
||||
{
|
||||
$main = $this->find($id);
|
||||
$new = array();
|
||||
$new['id'] = $main->id;
|
||||
$new['val'] = $this->getname($main->id);
|
||||
$categories[] = $new;
|
||||
if($main->parent_category_id != null)
|
||||
{
|
||||
$id = $main->parent_category_id;
|
||||
$z++;
|
||||
}
|
||||
}
|
||||
$categories = array_reverse($categories);
|
||||
unset($categories[count($categories)-1]);
|
||||
return $categories;
|
||||
$category_model = new CategoryModel();
|
||||
return $category_model->getMains($id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,7 +10,13 @@ class CategoryTableBuilder extends TableBuilder
|
||||
*
|
||||
* @var array|string
|
||||
*/
|
||||
protected $views = [];
|
||||
protected $views = [
|
||||
'all',
|
||||
'trash',
|
||||
'clean_subcategories' => [
|
||||
'href' => '/admin/cats/clean_subcats',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The table filters.
|
||||
|
||||
@ -50,6 +50,7 @@ class CatsModuleServiceProvider extends AddonServiceProvider
|
||||
* @type array|null
|
||||
*/
|
||||
protected $routes = [
|
||||
'admin/cats/clean_subcats' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@cleanSubcats',
|
||||
'admin/cats/placeholderforsearch' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@index',
|
||||
'admin/cats/placeholderforsearch/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@create',
|
||||
'admin/cats/placeholderforsearch/edit/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@edit',
|
||||
|
||||
@ -1,10 +1,8 @@
|
||||
<?php namespace Visiosoft\CatsModule\Http\Controller\Admin;
|
||||
|
||||
use Anomaly\Streams\Platform\Image\Command\MakeImageInstance;
|
||||
use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel;
|
||||
use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryTranslationsModel;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Str;
|
||||
use Sunra\PhpSimple\HtmlDomParser;
|
||||
use Visiosoft\CatsModule\Category\CategoryModel;
|
||||
@ -25,10 +23,10 @@ class CategoryController extends AdminController
|
||||
Str $str
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->categoryRepository = $categoryRepository;
|
||||
$this->categoryEntryTranslationsModel = $categoryEntryTranslationsModel;
|
||||
$this->str = $str;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(CategoryTableBuilder $table, Request $request)
|
||||
@ -73,20 +71,21 @@ class CategoryController extends AdminController
|
||||
return $this->redirect->back();
|
||||
}
|
||||
|
||||
$locale = DB::table('cats_category_translations')->select('locale')->distinct()->get()->toArray();
|
||||
$locale = $this->getRequestLang($all);
|
||||
|
||||
$translatable = array();
|
||||
foreach ($all as $key => $value) {
|
||||
foreach ($locale as $lang) {
|
||||
if ($this->endsWith($key, "_$lang->locale") && !in_array(substr($key, 0, -3), $translatable)) {
|
||||
if ($this->endsWith($key, "_$lang") && !in_array(substr($key, 0, -3), $translatable)) {
|
||||
$translatable[] = substr($key, 0, -3);
|
||||
}
|
||||
}
|
||||
}
|
||||
$translatableEntries = array();
|
||||
foreach ($locale as $lang) {
|
||||
$translatableEntries[$lang->locale] = array();
|
||||
$translatableEntries[$lang] = array();
|
||||
foreach ($translatable as $translatableEntry) {
|
||||
$translatableEntries[$lang->locale][$translatableEntry] = $all[$translatableEntry . '_' . $lang->locale];
|
||||
$translatableEntries[$lang][$translatableEntry] = $all[$translatableEntry . '_' . $lang];
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ class CategoryController extends AdminController
|
||||
foreach ($multiCat as $cat) {
|
||||
$secondArray = array();
|
||||
foreach ($locale as $lang) {
|
||||
if ($key === $lang->locale) {
|
||||
if ($key === $lang) {
|
||||
$secondArray[$key]['name'] = trim($cat);
|
||||
}
|
||||
}
|
||||
@ -109,7 +108,7 @@ class CategoryController extends AdminController
|
||||
}
|
||||
}
|
||||
if (empty($isMultiCat)) {
|
||||
$this->categoryRepository->create(array_merge($translatableEntries, [
|
||||
$this->categoryRepository->create(array_merge($translatableEntries, [
|
||||
'slug' => $all['slug'],
|
||||
'parent_category' => $all['parent_category'] === "" ? null : $all['parent_category'],
|
||||
'icon' => $all['icon'],
|
||||
@ -172,6 +171,30 @@ class CategoryController extends AdminController
|
||||
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
|
||||
}
|
||||
|
||||
public function getRequestLang($request) {
|
||||
$locale = array();
|
||||
foreach ($request as $key => $field) {
|
||||
$locale[] = substr($key, 0, -2);
|
||||
}
|
||||
$notTrans = array();
|
||||
$trans = array();
|
||||
foreach ($locale as $translatable) {
|
||||
if (!in_array($translatable, $notTrans)) {
|
||||
$notTrans[] = $translatable;
|
||||
} else {
|
||||
$trans[] = $translatable;
|
||||
}
|
||||
}
|
||||
$locale = array();
|
||||
foreach ($request as $key => $field) {
|
||||
foreach (array_unique($trans) as $entry) {
|
||||
if (strpos($key, $entry) === 0) {
|
||||
$locale[] = substr($key, -2);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $locale;
|
||||
}
|
||||
|
||||
public function edit(CategoryFormBuilder $form, Request $request, $id)
|
||||
{
|
||||
@ -220,5 +243,21 @@ class CategoryController extends AdminController
|
||||
return redirect('admin/cats?cat=' . $request->parent)->with('success', ['Category and related sub-categories deleted successfully.']);
|
||||
}
|
||||
|
||||
public function cleanSubcats()
|
||||
{
|
||||
$cats = $this->categoryRepository->all();
|
||||
$deletedCatsCount = 0;
|
||||
foreach ($cats as $cat) {
|
||||
$parentCatId = $cat->parent_category_id;
|
||||
$parentCat = $this->categoryRepository->find($parentCatId);
|
||||
if (is_null($parentCat) && !is_null($parentCatId)) {
|
||||
$this->categoryEntryTranslationsModel->where('entry_id', $cat->id)->delete();
|
||||
$this->categoryRepository->DeleteCategories($cat->id);
|
||||
$deletedCatsCount++;
|
||||
}
|
||||
}
|
||||
return redirect('admin/cats')->with('success', [$deletedCatsCount . ' categories has been deleted.']);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user