diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index f63d0135d..98efd5a69 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php @@ -154,7 +154,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface public function popularAdvs() { - return $this->getAdv()->where('popular_adv', 1)->paginate(9); + return $this->getAdv()->orderBy('count_show_ad', 'desc')->limit(10)->get(); } public function advsofDay() @@ -230,12 +230,12 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface $id = $object->id; $seo = str_slug($object->name); $seo = str_replace('_', '-', $seo); - return \route('adv_detail_seo', [$id, $seo]); + return \route('adv_detail_seo', [$seo, $id]); } $id = $object->getObject()->id; $seo = str_slug($object->getObject()->name); $seo = str_replace('_', '-', $seo); - return \route('adv_detail_seo', [$id, $seo]); + return \route('adv_detail_seo', [$seo, $id]); } public function getAdvDetailLinkByAdId($id) @@ -245,7 +245,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface $id = $adv->id; $seo = str_slug($adv->name); $seo = str_replace('_', '-', $seo); - return \route('adv_detail_seo', [$id, $seo]); + return \route('adv_detail_seo', [$seo, $id]); } } diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleSeeder.php b/addons/default/visiosoft/advs-module/src/AdvsModuleSeeder.php index c6bb53f1a..eba3670b2 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModuleSeeder.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModuleSeeder.php @@ -1,63 +1,16 @@ disks = $disks; - $this->folders = $folders; - } - /** * Run the seeder. */ public function run() { - //Download demo SQL - $repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/"; - file_put_contents(__DIR__."/demo.sql", fopen($repository."demo.sql", 'r')); - //Download demo Files and Extract to Files - file_put_contents("advs-files.zip", fopen($repository."advs-files.zip", 'r')); - $zipper = new Zipper(); - $zipper->make('advs-files.zip')->folder('advs-files')->extractTo(base_path().'/public/app/default/files-module/local/images/'); - $zipper->close(); - $this->call(BlockSeeder::class); - - /* Demo Start */ - DB::table('files_files')->truncate(); - Model::unguard(); - DB::unprepared(file_get_contents(__DIR__.'/demo.sql')); - Model::reguard(); - /* Demo Stop*/ } } \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php index 3e28f61ca..25e842140 100644 --- a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php +++ b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php @@ -118,12 +118,20 @@ class AdvsModuleServiceProvider extends AddonServiceProvider 'as' => 'adv_detail_seo', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view' ], + 'ad/{id}' => [ + 'as' => 'adv_detail', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view' + ], + 'ad/{seo}/{id}' => [ + 'as' => 'adv_detail_seo', + 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@view' + ], 'advs/map?country={country}&city[]={city}&district={districts}' => [ 'as' => 'visiosoft.module.advs::show_ad_map_location', 'uses' => 'Visiosoft\AdvsModule\Http\Controller\advsController@map' ], 'advs/categories' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@index', - 'advs/categories/{cat}' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@listByCat', + 'advs/c/{cat}' => 'Visiosoft\AdvsModule\Http\Controller\CategoriesController@listByCat', 'advs/module_active' => 'Visiosoft\AdvsModule\Http\Controller\advsController@index', 'advs/create_adv' => [ 'as' => "create_adv", diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php index d9c9ca9d4..946e5e5f5 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php @@ -83,8 +83,14 @@ class AdvsController extends AdminController $table->setColumns([ 'cover_photo' => [ - 'wrapper' => '', - 'value' => ['cover_photo' => 'entry.cover_photo'] + 'wrapper' => function (EntryInterface $entry, Request $request) { + if (strpos($entry->cover_photo, 'http') === 0) { + $wrapper = ''; + } else { + $wrapper = ''; + } + return $wrapper; + }, ], 'entry.id', 'name' => [ @@ -183,6 +189,7 @@ class AdvsController extends AdminController $default_adv_publish = $settings->value('visiosoft.module.advs::default_published_time'); $adv->finish_at = date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s') . ' + ' . $default_adv_publish . ' day')); + $adv->publish_at = date('Y-m-d H:i:s'); //algolia Search Module $isActiveAlgolia = new AdvModel(); diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/CategoriesController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/CategoriesController.php index 3329bb931..05d8fba37 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/CategoriesController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/CategoriesController.php @@ -8,12 +8,24 @@ class CategoriesController extends PublicController { public function listByCat($cat) { $advs = DB::table('advs_advs') - ->where('category_id', $cat) + ->where('cat1', $cat) + ->orwhere('cat2', $cat) + ->orwhere('cat3', $cat) + ->orwhere('cat4', $cat) + ->orwhere('cat5', $cat) + ->orwhere('cat6', $cat) + ->orwhere('cat7', $cat) ->leftJoin('users_users as u1', 'advs_advs.created_by_id', '=', 'u1.id') ->leftJoin('advs_advs_translations as t1', 'advs_advs.id', '=', 't1.id') ->select('advs_advs.*','u1.username as owner', 't1.name as name') ->get(); + foreach ($advs as $adv) { + if (strpos($adv->cover_photo, 'http') !== 0 && strpos($adv->cover_photo, '/') !== 0) { + $adv->cover_photo = "/$adv->cover_photo"; + } + } + return $this->view->make('visiosoft.module.advs::list/list', compact('advs')); } } diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php index 7ca56daf0..b72008eb5 100644 --- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php +++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php @@ -146,6 +146,18 @@ class AdvsController extends PublicController $subCats = array(); $param = $this->requestHttp->toArray(); + if (!isset($param['country'])) { + if (is_null(Cookie::get('country'))) { + $param['country'] = setting_value('visiosoft.module.advs::default_country'); + } else { + $param['country'] = Cookie::get('country'); + } + } else { + if ($param['country'] != setting_value('visiosoft.module.advs::default_country')) { + Cookie::queue(Cookie::make('country', $param['country'], 84000)); + } + } + $searchedCountry = $param['country']; $countries = $this->country_repository->viewAll(); @@ -213,7 +225,7 @@ class AdvsController extends PublicController } $compact = compact('advs', 'countries', 'mainCats', 'subCats', 'textfields', 'checkboxes', 'request', - 'user', 'userProfile', 'featured_advs', 'type', 'topfields', 'ranges', 'seenList'); + 'user', 'userProfile', 'featured_advs', 'type', 'topfields', 'ranges', 'seenList', 'searchedCountry'); Cookie::queue(Cookie::make('last_search', $this->requestHttp->getRequestUri(), 84000)); @@ -233,8 +245,10 @@ class AdvsController extends PublicController return redirect($this->request->headers->get('referer')); } - public function view($id) + public function view($seo, $id = null) { + $id = is_null($id) ? $seo : $id; + $categories = array(); $categories_id = array(); $isActiveComplaints = $this->adv_model->is_enabled('complaints'); diff --git a/addons/default/visiosoft/base-theme/resources/lang/ar/addon.php b/addons/default/visiosoft/base-theme/resources/lang/ar/addon.php new file mode 100644 index 000000000..69a57e357 --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/lang/ar/addon.php @@ -0,0 +1,50 @@ + 'الوصف', + 'post_ad' => 'انشر إعلانك', + 'profile' => 'الملف الشخصي', + 'my_messages' => 'رسائلي', + 'my_ads' => 'إعلاناتي', + 'login' => 'تسجيل الدخول', + 'logout' => 'تسجيل الخروج', + 'chose_language' => 'اختر اللغة', + + 'privacy_and_use' => 'الخصوصية والاستخدام', + 'sell_fast' => 'البيع السريع', + 'cloudsite' => 'موقع السحابة', + 'banner_advertising' => 'راية الإعلان', + 'trade_delivers' => 'أدوات التجارة', + 'promote_your_ad' => 'تعزيز إعلانك', + 'faq' => 'الأسئلة المتكررة', + 'follow_us_on' => 'تابعنا على', + 'newsletter' => 'النشرة الإخبارية', + 'subscribe' => 'اشترك!', + 'your_email' => 'بريدك الإلكتروني', + 'sign_up' => 'التسجيل', + 'copyright' => 'حقوق الطبع والنشر 2019. | طورت بواسطة', + 'cart' => 'سلتي', + 'search' => 'بحث', + 'type_your_keyword' => 'اكتب كلمتك المفتاحية', + 'categories' => 'الفئات', + 'contact_us' => '24/7 دعم العملاء', + 'help_center' => 'مركز المساعدة', + 'find_your_ad' => 'ابحث عن إعلانك', + 'vehicle_type' => 'نوع السيارة', + 'select_makes' => 'اختر الصانع', + 'browse_cars_by_makes'=> 'تصفح السيارات حسب الصانع', + 'featured_car_deals'=> 'عروض السيارات المميزة', + 'learn_more'=> 'تعلم المزيد', + 'advs_default_theme_homepage_mobile_app_title' => 'تنزيل من متجر التطبيقات', + 'advs_default_theme_homepage_mobile_app_available_on' => 'متوفر في', + 'all'=>'الكل', + 'trend_ads'=>'الإعلانات الشائعة', + 'single_cta1'=>'التداول الآمن', + 'single_cta2'=>'احصل على راحة البال مع زيادة الحماية للتداول الآمن.', + 'single_cta3'=>'دعم 24/7', + 'single_cta4'=>'خدمة العملاء 212 555 55 55', + 'single_cta5'=>'التجارة السهلة', + 'single_cta6'=>'مع خدمات الدفع الآمنة ، يمكن تنفيذ معاملاتك بشكل مريح.', + 'welcome'=> 'مرحبًا', +]; + diff --git a/addons/default/visiosoft/base-theme/resources/lang/ar/button.php b/addons/default/visiosoft/base-theme/resources/lang/ar/button.php new file mode 100644 index 000000000..d96ca1b36 --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/lang/ar/button.php @@ -0,0 +1,8 @@ + [ + 'name' => 'إرسال', + ], +]; + diff --git a/addons/default/visiosoft/base-theme/resources/lang/ar/fields.php b/addons/default/visiosoft/base-theme/resources/lang/ar/fields.php new file mode 100644 index 000000000..4723257f6 --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/lang/ar/fields.php @@ -0,0 +1,33 @@ + 'انشر إعلانك', + 'featured_ads' => "الإعلانات المميزة", + 'recent_ads' => "الإعلانات الحديثة", + 'trending_ads' => 'الإعلانات الشائعة', + 'search_map' => 'البحث على الخريطة', + 'search' => 'بحث', + 'categories' => 'الفئات', + 'city' => 'المدينة', + 'last_search' => 'لمواصلة البحث الأخير', + 'join-us' => 'انضم إلينا', + 'sign-in' => 'تسجيل الدخول', + 'new-here' => 'جديد هنا؟', + 'scroll-screen-for-details' => 'مرر الشاشة لعرض الجدول', + 'close' => 'إغلاق', + + + 'login' => 'تسجيل الدخول', + 'email' => [ + 'name' => 'عنوان البريد الإلكتروني', + ], + 'name' => [ + 'name' => 'الاسم', + ], + 'subject' => [ + 'name' => 'العنوان', + ], + 'content' => [ + 'name' => 'المحتوى', + ], +]; \ No newline at end of file diff --git a/addons/default/visiosoft/base-theme/resources/lang/ar/message.php b/addons/default/visiosoft/base-theme/resources/lang/ar/message.php new file mode 100644 index 000000000..c5c23e41e --- /dev/null +++ b/addons/default/visiosoft/base-theme/resources/lang/ar/message.php @@ -0,0 +1,4 @@ + [ + 'name' => 'كلمات ميتا المفتاحية', + ], + 'template' => [ + 'name' => 'القالب', + ], + 's-type-latest-limit' => [ + 'name' => 'الحد الأقصى من نوع-اس', + ], + 's-type-showcase' => [ + 'name' => 'اسم حد عرض S-type', + ], + 's-type-banner-code' => [ + 'name' => 'رمز شعار نوع-اس', + ], + + 's-type-banner-mobile-code' => [ + 'name' => 'رمز الجوال لراية نوع-اس', + ], + + 'show_post_your_add_btn' => [ + 'name' => 'أظهر زر "انشر اعلانك"', + ], + + 'show_home_search_on_map_btn' => [ + 'name' => 'أظهر زر "على الخريطة" في البحث في الصفحة الرئيسية', + ], + + 'show_last_search_btn' => [ + 'name' => 'أظهر زر "آخر عملية بحث"', + ], +]; diff --git a/addons/default/visiosoft/cats-module/resources/lang/en/field.php b/addons/default/visiosoft/cats-module/resources/lang/en/field.php index 05f8d2c61..ab6a13cfe 100644 --- a/addons/default/visiosoft/cats-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/cats-module/resources/lang/en/field.php @@ -20,7 +20,7 @@ return [ 'name' => 'Seo Description' ], 'icon' => [ -' name' => 'ICON' + 'name' => 'Icon' ], 'please_wait' => 'Please wait.Deleting Sub Categories', diff --git a/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php b/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php index e96b19902..671d997f4 100644 --- a/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php +++ b/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php @@ -1,9 +1,6 @@ call(CategorySeeder::class); - - //Download demo SQL - $repository = "https://raw.githubusercontent.com/openclassify/Openclassify-Demo-Data/master/"; - file_put_contents(__DIR__."/categories.sql", fopen($repository."categories.sql", 'r')); - file_put_contents(__DIR__."/categoryTransEn.sql", fopen($repository."categoryTransEn.sql", 'r')); - //Download demo Files and Extract to Files - file_put_contents("category-files.zip", fopen($repository."category-files.zip", 'r')); - $zipper = new Zipper(); - $zipper->make('category-files.zip')->folder('category-files')->extractTo(base_path().'/public/app/default/files-module/local/images/'); - $zipper->close(); - $this->call(PlaceholderforsearchSeeder::class); - Model::unguard(); - DB::unprepared(file_get_contents(__DIR__.'/categories.sql')); - DB::unprepared(file_get_contents(__DIR__.'/categoryTransEn.sql')); - Model::reguard(); } } \ No newline at end of file diff --git a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php index 1096855b8..a0c4ebef5 100644 --- a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php +++ b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php @@ -2,9 +2,11 @@ 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\CategoryCollection; use Visiosoft\CatsModule\Category\CategoryModel; use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface; use Visiosoft\CatsModule\Category\Form\CategoryFormBuilder; @@ -13,6 +15,22 @@ use Anomaly\Streams\Platform\Http\Controller\AdminController; class CategoryController extends AdminController { + private $categoryRepository; + private $categoryEntryTranslationsModel; + private $str; + + public function __construct( + CategoryRepositoryInterface $categoryRepository, + CatsCategoryEntryTranslationsModel $categoryEntryTranslationsModel, + Str $str + ) + { + parent::__construct(); + $this->categoryRepository = $categoryRepository; + $this->categoryEntryTranslationsModel = $categoryEntryTranslationsModel; + $this->str = $str; + } + public function index(CategoryTableBuilder $table, Request $request) { if ($this->request->action == "delete") { @@ -55,10 +73,76 @@ class CategoryController extends AdminController return $this->redirect->back(); } - $form->make(); - if ($form->hasFormErrors()) { - return $this->redirect->to('/admin/cats/create'); + $locale = DB::table('cats_category_translations')->select('locale')->distinct()->get()->toArray(); + $translatable = array(); + foreach ($all as $key => $value) { + foreach ($locale as $lang) { + if ($this->endsWith($key, "_$lang->locale") && !in_array(substr($key, 0, -3), $translatable)) { + $translatable[] = substr($key, 0, -3); + } + } } + $translatableEntries = array(); + foreach ($locale as $lang) { + $translatableEntries[$lang->locale] = array(); + foreach ($translatable as $translatableEntry) { + $translatableEntries[$lang->locale][$translatableEntry] = $all[$translatableEntry . '_' . $lang->locale]; + } + } + + // Check if there is multiple categories in the name filed + $isMultiCat = array(); + foreach ($translatableEntries as $key => $translatableEntry) { + $multiCat = explode(",", $translatableEntry['name']); + if (count($multiCat) > 1) { + $firstArray = array(); + foreach ($multiCat as $cat) { + $secondArray = array(); + foreach ($locale as $lang) { + if ($key === $lang->locale) { + $secondArray[$key]['name'] = trim($cat); + } + } + array_push($firstArray, $secondArray); + } + array_push($isMultiCat, $firstArray); + } + } + if (empty($isMultiCat)) { + $this->categoryRepository->create(array_merge($translatableEntries, [ + 'slug' => $all['slug'], + 'parent_category' => $all['parent_category'] === "" ? null : $all['parent_category'], + 'icon' => $all['icon'], + 'seo_keyword' => $all['seo_keyword'], + 'seo_description' => $all['seo_description'], + ])); + } else { + for ($i = 0; $i < count($isMultiCat[0]); $i++) { + foreach ($isMultiCat as $cat) { + $translatableEntries = array_merge($translatableEntries, $cat[$i]); + } + $this->categoryRepository->create(array_merge($translatableEntries, [ + 'slug' => $this->str->slug(reset($translatableEntries)['name'], '_'), + 'parent_category' => $all['parent_category'] === "" ? null : $all['parent_category'], + 'icon' => $all['icon'], + 'seo_keyword' => $all['seo_keyword'], + 'seo_description' => $all['seo_description'], + ])); + } + }; + +// $this->categoryRepository->create(array_merge($translatableEntries, [ +// 'slug' => $all['slug'], +// 'parent_category' => $all['parent_category'], +// 'icon' => $all['icon'], +// 'seo_keyword' => $all['seo_keyword'], +// 'seo_description' => $all['seo_description'], +// ])); + +// $form->make(); +// if ($form->hasFormErrors()) { +// return $this->redirect->to('/admin/cats/create'); +// } if ($parent_id != "") { return $this->redirect->to('/admin/cats?cat=' . $parent_id); } @@ -81,6 +165,13 @@ class CategoryController extends AdminController return $this->view->make('visiosoft.module.cats::cats/admin-cat', compact('nameField', 'formBuilder')); } + public function endsWith($string, $test) { + $strlen = strlen($string); + $testlen = strlen($test); + if ($testlen > $strlen) return false; + return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0; + } + public function edit(CategoryFormBuilder $form, Request $request, $id) {