diff --git a/.styleci.yml b/.styleci.yml index 837286d..6400542 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,4 +1,4 @@ -# Styleci for WebDevEtc. +# Styleci for binshops. preset: laravel diff --git a/LICENSE.txt b/LICENSE.txt index 00f04a7..bac0ded 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 Hessam. +Copyright (c) 2020 Binshops. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 0f4ff7c..009eaf6 100644 --- a/README.md +++ b/README.md @@ -1,43 +1,122 @@ -<p align="center"><a href="cms.binshops.com/" target="_blank"><img src="https://cms.binshops.com/img/hessam-cms.png"></a></p> + <h1 align="center">Laravel Blog Package</h1> <p align="center"> - <a href="https://packagist.org/packages/hessam/laravel-blogger"> - <img src="https://poser.pugx.org/hessam/laravel-blogger/v/stable.png" alt="Latest Stable Version"> - </a> - - <a href="https://packagist.org/packages/hessam/laravel-blogger"> - <img src="https://poser.pugx.org/hessam/laravel-blogger/license.png" alt="License"> - </a> + <img src="https://user-images.githubusercontent.com/20775532/215362765-c2a3360e-c165-4cba-809b-4f04316c8d5e.png" width="80%" /> </p> -# Complete Laravel CMS Package -- ### Multi-level Categories -- ### Full text search -- ### Multi-language support (coming soon) - - See the progress for multi-lang in `multi-lang` branch +### Lightweight and Easy to Install + +Incredible features with a lightweight laravel blog package. +- Quick installation (<3 minutes) +- It's very easy to extend +- Included great features out-of-box +- Its simplicity allows to be easily made compatible with latest laravel +- No additional concept except laravel knowledge +- Compatible with other Laravel platforms like Bagisto + +## Outstanding Features +- Fulltext Search - search throughout all blog posts +- Multi Level Category - nested sets using Baum +- Multi Language Support + +### Quick and easy installation (Multi-lang version) +1- Install via composer + +`composer require binshops/laravel-blog` + +For a fresh Laravel installation run the following too: + +``` +composer require laravel/ui +php artisan ui vue --auth +``` + +2- Scaffold + +``` +npm install && npm run build +``` + +3- Run the following two commands to copy config file, migration files, and view files + +`php artisan vendor:publish --provider="BinshopsBlog\BinshopsBlogServiceProvider"` + +4- Execute migrations to create tables + +`php artisan migrate;` + +5- You must add one method to your \App\User (in laravel 8 \App\Models\User) model. As the name of this method shows it determines which user can manage posts. Place your logic there + +``` + /** + * Enter your own logic (e.g. if ($this->id === 1) to + * enable this user to be able to add/edit blog posts + * + * @return bool - true = they can edit / manage blog posts, + * false = they have no access to the blog admin panel + */ + public function canManageBinshopsBlogPosts() + { + // Enter the logic needed for your app. + // Maybe you can just hardcode in a user id that you + // know is always an admin ID? + + if ( $this->id === 1 + && $this->email === "your_admin_user@your_site.com" + ){ + + // return true so this user CAN edit/post/delete + // blog posts (and post any HTML/JS) + + return true; + } + + // otherwise return false, so they have no access + // to the admin panel (but can still view posts) + + return false; + } +``` + +6- Create a directory in `public/` named `blog_images` -## [Let's try it - Online Demo](https://cms.binshops.com/login) -You can try Hessam CMS online: [https://cms.binshops.com](https://cms.binshops.com/login) +7- Start the server -### Quick and easy installation +``` +php artisan serve +``` -Install with following command and follow the instructions. +8- Login as admin and setup your package: `/blog_admin/setup` - composer require hessam/laravel-blogger +Congrats! Your blog is ready to use. (URLs are customizable in the config file) -### For Complete Setup Instructions (with video guide), please Visit [The Install Guide](https://hessam.binshops.com/laravel-blog-package#setup) + Admin panel URI: `/blog_admin` + Front URI: `/en/blog` -To see package on Packagist click this [Link](https://packagist.org/packages/hessam/laravel-blogger) +To see package on Packagist click this [Link](https://packagist.org/packages/binshops/laravel-blog) + +### Single Language Version +To install the single language version of the package use version v8.1x: + +1- `composer require binshops/laravel-blog:v8.2.0` + +2- `php artisan vendor:publish --provider="BinshopsBlog\BinshopsBlogServiceProvider"` + +3- `php artisan vendor:publish --tag=laravel-fulltext` + +4- `php artisan migrate;` + +You can see the single version in "single-lang" branch. The major difference with multi-language version is the database structure. ## Important Notes -- For laravel 8.x's default auth User model, change user model in `blogetc.php` to: `\App\Models\User::class` +- For laravel 8.x's default auth User model, change user model in `binshopsblog.php` to: `\App\Models\User::class` ## Features - Compatible with latest laravel version (laravel 8.x) - Backward-compatibility with previous laravel versions - Full text search - searching throughout the blog posts - Multi-level category support -- fully configurable via its `config/blogetc.php` config file +- fully configurable via its `config/binshopsblog.php` config file - Ready to use admin panel - Full customizability of admin views and front views - Paginated views @@ -46,56 +125,34 @@ To see package on Packagist click this [Link](https://packagist.org/packages/hes - Managing comments and comment approval - Other options include using Disqus comments or disabling comments -## Recent Changes -- **8.0.x** Compatibility with Laravel 8.x - -## Screen Shots - - <p align="center"> - <img src="https://hessam.binshops.com/wp-content/uploads/2020/08/Screen-Shot-2020-08-08-at-6.23.35-PM-1024x560.png" width="500px" title="Add post"> - </p> - <p align="center"> - Add post - </p> - - <p align="center"> - <img src="https://hessam.binshops.com/wp-content/uploads/2020/08/Screen-Shot-2020-08-08-at-6.19.42-PM-1024x558.png" width="500px" title="All posts"> - </p> - <p align="center"> - All posts - </p> - - <p align="center"> - <img src="https://hessam.binshops.com/wp-content/uploads/2020/08/Screen-Shot-2020-08-08-at-6.03.39-PM-1-1024x560.png" width="500px" title="Add category"> - </p> - <p align="center"> - Add category - </p> - +## Recent Changes +- **9.1.x** Multi language support +- 8.0.x Compatibility with Laravel 8.x + ## What/who this package is for: - For websites running Laravel - - Who wants to have a site blog, and have an easy to use interface to write blog posts/assign categories/manage existing posts + - Anyone, who wants to have a site blog. This laravel blog gives an easy to use interface to write blog posts/assign categories/manage existing posts - Where only admin users can edit/manage the blog (this is not suitable for every user on your site to be able to manage posts) - - For anyone who likes to add a wordpress-like CMS to her/his web app + - For anyone who likes to add a wordpress-like laravel blog to laravel website ## How to customise the blog views/templates -After doing the correct `vendor:publish`, all of the default template files will be found in /resources/views/vendor/blogetc/ and are easy to edit to match your needs. +After doing the correct `vendor:publish`, all of the default template files will be found in /resources/views/vendor/binshopsblog/ and are easy to edit to match your needs. ### Customizing admin views If you need to customize the admin view, just copy the files from -`vendor/webdevetc/blogetc/src/Views/blogetc_admin` +`vendor/binshopsblog/src/Views/binshopsblog_admin` to -`resources/views/vendor/blogetc_admin` +`resources/views/vendor/binshopsblog_admin` Then you can modify them just like any other view file. ## Routes -It will auto set all required routes (both public facing, and admin backend). There are some config options (such as changing the /blog/ url to something else), which can be done in the blogetc.php file. +It will auto set all required routes (both public facing, and admin backend). There are some config options (such as changing the /blog/ url to something else), which can be done in the binshopsblog.php file. ## Config options -All config options have comments which describe what they do. Please just refer to the `blogetc.php` file in your /config/ dir. +All config options have comments which describe what they do. Please just refer to the `binshopsblog.php` file in your /config/ dir. ### Custom User Model You can change the default user model through the config file. @@ -108,9 +165,31 @@ Add these (and an Event Listener) to your `EventServiceProvider.php` file to mak ## Built in CAPTCHA / anti spam -There is a built in captcha (anti spam comment) system built in, which will be easy for you to replace with your own implementation. +There is a built-in captcha (anti-spam comment) system built in, which will be easy for you to replace with your own implementation. + +There is a basic anti-spam captcha function built-in. + +See the config/binshops.php captcha section. There is a built in system (basic!) that will prevent most automated spam attempts. +Writing your own captcha system: + +I wrote the captcha system simple on purpose, so you can add your own captcha options. It should be easy to add any other captcha system to this. - Please see [this Captcha docs](https://hessam.binshops.com/laravel-blog-package#captcha) for more details. +If you want to write your own implementation then create your own class that implements \BinshopsBlog\Interfaces\CaptchaInterface, then update the config/binshopsblog.php file (change the captcha_type option). + +There are three methods you need to implement: +public function captcha_field_name() : string + +Return a string such as "captcha". It is used for the form validation and <input name=???>. +public function view() : string + +What view file should the binshops::partials.add_comment_form view include? You can set this to whatever you need, and then create your own view file. The default included basic captcha class will return "binshops::captcha.basic". +public function rules() : array + +Return an array for the rules (which are just the standard Laravel validation rules. This is where you can check if the captcha was successful or not. +Optional: +public function runCaptchaBeforeShowingPosts() : null + +This isn't part of the interface, it isn't required. By default it does nothing. But you can put some code in this method and it'll be run in the BinshopsReaderController::viewSinglePost method. ## Image upload errors @@ -123,41 +202,13 @@ Try adding this to config/app.php: - You might need to set a higher memory limit, or upload smaller image files. This will depend on your server. I've used it to upload huge (10mb+) jpg images without problem, once the server was set up correctly to handle larger file uploads. ## Version History -- **8.0.x** Compatibility with Laravel 8 -- 7.3.2 Some bug fixes +- **9.3.x** Stable version of package +- 9.0.x Multi-language support beta release +- 8.0.x Compatibility with Laravel 8 - 7.3.0 New Admin UI -- 7.2.2 - - bug fix: do not show search bar when it's disabled - - feature: configure to show full text post or preview -- 7.2.1 - adds logout button at admin panel -- 7.2.0 - - adds sub-category functionality to blog - - adds reading progress bar feature (if you upgrade, re-publish config file and view files) -- 7.1.8 - ability to remove images from posts (this feature does not work for old posts) -- 7.1.7 - updates CKEditor -- 7.1.5 - minor fix for recent posts -- 7.1.4 - updates fulltext search package which solves the search issue -- 7.1.2 - shows categories on blog home page - minor fix (if you upgrade try to re-publish view files) -- 7.1.1 - minor fix and some admin panel text changes -- 7.1.0 - Adds support for custom user model (if you upgrade, try to publish new config) -- 7.0.2 - Bug fix for listing posts and search page -- 7.0.1 - made compatible with Laravel 6.x & 7.x -- 3.1 - minor fixes -- 3.0.3 - fixed RSS feed cache issue -- 3.0.2 - fixed default medium image size (changed to 600x400) - 3.0.1 - replaced all short tags (<?) with full opening ones (<?php) -- 3.0 - Added separate functionality for uploading images (and save some meta data in db) -- 2.1 - added 'short_description' to db + form, and BlogEtcPost::generate_introduction() method will try and use this to generate intro text. - 2.0 - added full text search (enable it via the config file - it is disabled by default). -- 1.2 - added WYSIWYG, few smaller changes - 1.1.1 - added basic captcha - 1.0.5 - composer.json changes. - 1.0 - First release -- 0.3 - Small changes, packagist settings. - 0.1 - Initial release - -Contact: hessam.modaberi@gmail.com - - - - diff --git a/composer.json b/composer.json index a15e648..661a430 100755 --- a/composer.json +++ b/composer.json @@ -1,61 +1,61 @@ -{ - "name": "hessam/laravel-blogger", - "keywords": [ - "laravel", - "blog", - "package", - "admin", - "panel", - "rss", - "feed", - "write", - "posts", - "news", - "update", - "hessam-blog" - ], - "description": "Simple blog package (with admin panel) for Laravel (6.x and 7.x). Includes all views, controllers, routes and can add a blog to any existing Laravel app. Fully customisable blog (view, urls, and many other options). Includes image uploads and a pretty admin interface to manage your blog. Defaults to /blog but you can change it to anything.", - "license": "MIT", - "support": { - "docs": "https://hessam.binshops.com/laravel-blog-package/" - }, - "authors": [ - { - "name": "Hessam", - "homepage": "http://hessam.binshops.com", - "role": "developer", - "email": "hessam.modaberi@gmail.com" - } - ], - "require": { - "cviebrock/eloquent-sluggable": "~8.0|~7.0|~6.0|~4.8|~4.7|~4.6|~4.5", - "laravelium/feed": "~2.12.0|~3.0.0|3.1.*|v6.0.*|v7.0.*|v8.0.*", - "intervention/image": "2.*", - "swisnl/laravel-fulltext": "^0.20.0", - "laravel/helpers": "^1.3" - }, - "require-dev": { - "phpunit/phpunit": "*", - "orchestra/testbench": "4.0.*", - "php-coveralls/php-coveralls": "*" - }, - "autoload": { - "psr-4": { - "WebDevEtc\\BlogEtc\\": "src" - } - }, - "autoload-dev": { - "psr-4": { - "WebDevEtc\\BlogEtc\\Tests\\": "tests" - } - }, - "extra": { - "laravel": { - "providers": [ - "WebDevEtc\\BlogEtc\\BlogEtcServiceProvider" - ], - "aliases": { - } - } - } -} +{ + "name": "binshops/laravel-blog", + "keywords": [ + "laravel", + "blog", + "package", + "admin", + "panel", + "rss", + "feed", + "write", + "posts", + "news", + "update", + "laravel blog", + "binshops" + ], + "description": "Simple blog package (with admin panel) for Laravel (6.x and 7.x). Includes all views, controllers, routes and can add a blog to any existing Laravel app. Fully customisable blog (view, urls, and many other options). Includes image uploads and a pretty admin interface to manage your blog. Defaults to /blog but you can change it to anything.", + "license": "MIT", + "support": { + "docs": "https://github.com/binshops/laravel-blog" + }, + "authors": [ + { + "name": "Binshops", + "homepage": "https://github.com/binshops/laravel-blog", + "role": "owner", + "email": "contact@binshops.com" + } + ], + "require": { + "cviebrock/eloquent-sluggable": "^10.0|^9.0|~8.0|~7.0|~6.0|~4.8|~4.7|~4.6|~4.5", + "intervention/image": "2.*", + "laravel/helpers": "^1.3" + }, + "require-dev": { + "phpunit/phpunit": "*", + "orchestra/testbench": "4.0.*", + "php-coveralls/php-coveralls": "*" + }, + "autoload": { + "psr-4": { + "BinshopsBlog\\": "src", + "BinshopsBlog\\Laravel\\Fulltext\\": "src/FulltextSearch/src/" + } + }, + "autoload-dev": { + "psr-4": { + "BinshopsBlog\\Tests\\": "tests" + } + }, + "extra": { + "laravel": { + "providers": [ + "BinshopsBlog\\BinshopsBlogServiceProvider" + ], + "aliases": { + } + } + } +} diff --git a/migrations/2016_11_04_152913_create_laravel_fulltext_table.php b/migrations/2016_11_04_152913_create_laravel_fulltext_table.php new file mode 100644 index 0000000..4ce7812 --- /dev/null +++ b/migrations/2016_11_04_152913_create_laravel_fulltext_table.php @@ -0,0 +1,40 @@ +<?php + +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; + +class CreateLaravelFulltextTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::connection(config('laravel-fulltext.db_connection'))->create('laravel_fulltext', function (Blueprint $table) { + $table->increments('id'); + $table->integer('indexable_id'); + $table->string('indexable_type'); + $table->text('indexed_title'); + $table->text('indexed_content'); + + $table->unique(['indexable_type', 'indexable_id']); + + $table->timestamps(); + }); + + DB::connection(config('laravel-fulltext.db_connection'))->statement('ALTER TABLE laravel_fulltext ADD FULLTEXT fulltext_title(indexed_title)'); + DB::connection(config('laravel-fulltext.db_connection'))->statement('ALTER TABLE laravel_fulltext ADD FULLTEXT fulltext_title_content(indexed_title, indexed_content)'); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::connection(config('laravel-fulltext.db_connection'))->drop('laravel_fulltext'); + } +} diff --git a/migrations/2018_05_28_224023_create_blog_etc_posts_table.php b/migrations/2018_05_28_224023_create_blog_etc_posts_table.php deleted file mode 100755 index 683a076..0000000 --- a/migrations/2018_05_28_224023_create_blog_etc_posts_table.php +++ /dev/null @@ -1,92 +0,0 @@ -<?php - -use Illuminate\Support\Facades\Schema; -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Database\Migrations\Migration; - -class CreateBlogEtcPostsTable extends Migration -{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::create('blog_etc_posts', function (Blueprint $table) { - $table->increments('id'); - $table->unsignedInteger("user_id")->index()->nullable(); - $table->string("slug")->unique(); - - $table->string("title")->nullable()->default("New blog post"); - $table->string("subtitle")->nullable()->default(""); - $table->text("meta_desc")->nullable(); - $table->mediumText("post_body")->nullable(); - - $table->string("use_view_file")->nullable()->comment("should refer to a blade file in /views/"); - - $table->dateTime("posted_at")->index()->nullable()->comment("Public posted at time, if this is in future then it wont appear yet"); - $table->boolean("is_published")->default(true); - - $table->string('image_large')->nullable(); - $table->string('image_medium')->nullable(); - $table->string('image_thumbnail')->nullable(); - - $table->timestamps(); - }); - - Schema::create('blog_etc_categories', function (Blueprint $table) { - $table->increments('id'); - - $table->string("category_name")->nullable(); - $table->string("slug")->unique(); - $table->mediumText("category_description")->nullable(); - - $table->unsignedInteger("created_by")->nullable()->index()->comment("user id"); - - $table->timestamps(); - }); - - Schema::create('blog_etc_post_categories', function (Blueprint $table) { - $table->increments('id'); - - $table->unsignedInteger("blog_etc_post_id")->index(); - $table->foreign('blog_etc_post_id')->references('id')->on('blog_etc_posts')->onDelete("cascade"); - - $table->unsignedInteger("blog_etc_category_id")->index(); - $table->foreign('blog_etc_category_id')->references('id')->on('blog_etc_categories')->onDelete("cascade"); - }); - - - Schema::create('blog_etc_comments', function (Blueprint $table) { - $table->increments('id'); - - $table->unsignedInteger("blog_etc_post_id")->index(); - $table->foreign('blog_etc_post_id')->references('id')->on('blog_etc_posts')->onDelete("cascade"); - $table->unsignedInteger("user_id")->nullable()->index()->comment("if user was logged in"); - - $table->string("ip")->nullable()->comment("if enabled in the config file"); - $table->string("author_name")->nullable()->comment("if not logged in"); - - $table->text("comment")->comment("the comment body"); - - $table->boolean("approved")->default(true); - - $table->timestamps(); - }); - - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('blog_etc_post_categories'); - Schema::dropIfExists('blog_etc_categories'); - Schema::dropIfExists('blog_etc_posts'); - } -} diff --git a/migrations/2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php b/migrations/2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php deleted file mode 100644 index 67cec73..0000000 --- a/migrations/2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - -use Illuminate\Support\Facades\Schema; -use Illuminate\Database\Schema\Blueprint; -use Illuminate\Database\Migrations\Migration; - -class AddAuthorAndUrlBlogEtcPostsTable extends Migration -{ - /** - * Run the migrations. - * - * @return void - */ - public function up() - { - Schema::table('blog_etc_comments', function (Blueprint $table) { - $table->string("author_email")->nullable(); - $table->string("author_website")->nullable(); - }); - - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - - Schema::table('blog_etc_comments', function (Blueprint $table) { - $table->dropColumn("author_email"); - $table->dropColumn("author_website"); - }); - } -} - diff --git a/migrations/2020_10_16_004241_create_binshops_languages_table.php b/migrations/2020_10_16_004241_create_binshops_languages_table.php new file mode 100644 index 0000000..cbf41a9 --- /dev/null +++ b/migrations/2020_10_16_004241_create_binshops_languages_table.php @@ -0,0 +1,39 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateBinshopsLanguagesTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('binshops_languages', function (Blueprint $table) { + $table->increments('id'); + + $table->string("name")->unique(); + $table->string("locale")->unique(); + $table->string("iso_code")->unique(); + $table->string("date_format"); + $table->boolean("active")->default(true); + $table->boolean("rtl")->default(false); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('binshops_languages'); + } +} diff --git a/migrations/2020_05_27_104123_add_parameters_blog_etc_categories_table.php b/migrations/2020_10_16_005400_create_binshops_categories_table.php similarity index 52% rename from migrations/2020_05_27_104123_add_parameters_blog_etc_categories_table.php rename to migrations/2020_10_16_005400_create_binshops_categories_table.php index 1fc8255..1e1c566 100644 --- a/migrations/2020_05_27_104123_add_parameters_blog_etc_categories_table.php +++ b/migrations/2020_10_16_005400_create_binshops_categories_table.php @@ -4,7 +4,7 @@ use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; -class AddParametersBlogEtcCategoriesTable extends Migration +class CreateBinshopsCategoriesTable extends Migration { /** * Run the migrations. @@ -13,12 +13,20 @@ class AddParametersBlogEtcCategoriesTable extends Migration */ public function up() { - Schema::table('blog_etc_categories', function (Blueprint $table) { - $table->integer('parent_id')->nullable()->default(0); + Schema::create('binshops_categories', function (Blueprint $table) { + $table->increments('id'); + + $table->unsignedInteger("created_by")->nullable()->index()->comment("user id"); + + //columns related to multi-level categories + $table->integer('parent_id')->nullable(); $table->integer('lft')->nullable(); $table->integer('rgt')->nullable(); $table->integer('depth')->nullable(); + + $table->timestamps(); }); + } /** @@ -28,8 +36,6 @@ public function up() */ public function down() { - Schema::table('blog_etc_categories', function (Blueprint $table) { - // - }); + Schema::dropIfExists('binshops_categories'); } } diff --git a/migrations/2020_10_16_005425_create_binshops_category_translations_table.php b/migrations/2020_10_16_005425_create_binshops_category_translations_table.php new file mode 100644 index 0000000..713197b --- /dev/null +++ b/migrations/2020_10_16_005425_create_binshops_category_translations_table.php @@ -0,0 +1,41 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateBinshopsCategoryTranslationsTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('binshops_category_translations', function (Blueprint $table) { + $table->increments('id'); + + $table->unsignedInteger('category_id')->nullable(); + + $table->string("category_name")->nullable(); + $table->string("slug")->unique(); + $table->mediumText("category_description")->nullable(); + + $table->unsignedInteger("lang_id")->index(); + $table->foreign('lang_id')->references('id')->on('binshops_languages'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('binshops_category_translations'); + } +} diff --git a/migrations/2020_10_16_010039_create_binshops_posts_table.php b/migrations/2020_10_16_010039_create_binshops_posts_table.php new file mode 100644 index 0000000..398b44e --- /dev/null +++ b/migrations/2020_10_16_010039_create_binshops_posts_table.php @@ -0,0 +1,46 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateBinshopsPostsTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('binshops_posts', function (Blueprint $table) { + $table->increments('id'); + $table->unsignedInteger("user_id")->index()->nullable(); + + $table->dateTime("posted_at")->index()->nullable()->comment("Public posted at time, if this is in future then it wont appear yet"); + $table->boolean("is_published")->default(true); + + $table->timestamps(); + }); + + Schema::create('binshops_post_categories', function (Blueprint $table) { + $table->increments('id'); + + $table->unsignedInteger("post_id")->index(); + $table->foreign('post_id')->references('id')->on('binshops_posts')->onDelete("cascade"); + + $table->unsignedInteger("category_id")->index(); + $table->foreign('category_id')->references('id')->on('binshops_categories')->onDelete("cascade"); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('binshops_posts'); + } +} diff --git a/migrations/2020_10_16_010049_create_binshops_post_translations_table.php b/migrations/2020_10_16_010049_create_binshops_post_translations_table.php new file mode 100644 index 0000000..3c52d9f --- /dev/null +++ b/migrations/2020_10_16_010049_create_binshops_post_translations_table.php @@ -0,0 +1,51 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateBinshopsPostTranslationsTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('binshops_post_translations', function (Blueprint $table) { + $table->increments('id'); + + $table->unsignedInteger('post_id')->nullable(); + + $table->string("slug"); + $table->string("title")->nullable()->default("New blog post"); + $table->string("subtitle")->nullable()->default(""); + $table->text("meta_desc")->nullable(); + $table->string("seo_title")->nullable(); + $table->mediumText("post_body")->nullable(); + $table->text("short_description")->nullable(); + + $table->string("use_view_file")->nullable()->comment("should refer to a blade file in /views/"); + + $table->string('image_large')->nullable(); + $table->string('image_medium')->nullable(); + $table->string('image_thumbnail')->nullable(); + + $table->unsignedInteger("lang_id")->index(); + $table->foreign('lang_id')->references('id')->on('binshops_languages'); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('binshops_post_translations'); + } +} diff --git a/migrations/2020_10_16_121230_create_binshops_comments_table.php b/migrations/2020_10_16_121230_create_binshops_comments_table.php new file mode 100644 index 0000000..91091d8 --- /dev/null +++ b/migrations/2020_10_16_121230_create_binshops_comments_table.php @@ -0,0 +1,45 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateBinshopsCommentsTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create('binshops_comments', function (Blueprint $table) { + $table->increments('id'); + + $table->unsignedInteger("post_id")->index(); + $table->unsignedInteger("user_id")->nullable()->index()->comment("if user was logged in"); + + $table->string("ip")->nullable()->comment("if enabled in the config file"); + $table->string("author_name")->nullable()->comment("if not logged in"); + + $table->text("comment")->comment("the comment body"); + + $table->boolean("approved")->default(true); + + $table->string("author_email")->nullable(); + $table->string("author_website")->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('binshops_comments'); + } +} diff --git a/migrations/2018_09_27_122627_create_blog_etc_uploaded_photos_table.php b/migrations/2020_10_16_121728_create_binshops_uploaded_photos_table.php similarity index 61% rename from migrations/2018_09_27_122627_create_blog_etc_uploaded_photos_table.php rename to migrations/2020_10_16_121728_create_binshops_uploaded_photos_table.php index 5098b13..9485997 100644 --- a/migrations/2018_09_27_122627_create_blog_etc_uploaded_photos_table.php +++ b/migrations/2020_10_16_121728_create_binshops_uploaded_photos_table.php @@ -1,10 +1,10 @@ <?php -use Illuminate\Support\Facades\Schema; -use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; -class CreateBlogEtcUploadedPhotosTable extends Migration +class CreateBinshopsUploadedPhotosTable extends Migration { /** * Run the migrations. @@ -13,7 +13,7 @@ class CreateBlogEtcUploadedPhotosTable extends Migration */ public function up() { - Schema::create('blog_etc_uploaded_photos', function (Blueprint $table) { + Schema::create('binshops_uploaded_photos', function (Blueprint $table) { $table->increments('id'); $table->text("uploaded_images")->nullable(); $table->string("image_title")->nullable(); @@ -21,9 +21,6 @@ public function up() $table->unsignedInteger("uploader_id")->nullable()->index(); $table->timestamps(); }); - Schema::table("blog_etc_posts",function(Blueprint $table) { - $table->string("seo_title")->nullable(); - }); } /** @@ -33,10 +30,6 @@ public function up() */ public function down() { - Schema::dropIfExists('blog_etc_uploaded_photos'); - - Schema::table("blog_etc_posts",function(Blueprint $table) { - $table->dropColumn("seo_title"); - }); + Schema::dropIfExists('binshops_uploaded_photos'); } } diff --git a/migrations/2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php b/migrations/2020_10_22_132005_create_binshops_configurations_table.php similarity index 53% rename from migrations/2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php rename to migrations/2020_10_22_132005_create_binshops_configurations_table.php index e24feed..b62c443 100644 --- a/migrations/2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php +++ b/migrations/2020_10_22_132005_create_binshops_configurations_table.php @@ -1,10 +1,10 @@ <?php -use Illuminate\Support\Facades\Schema; -use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; -class AddShortDescTextreaToBlogEtc extends Migration +class CreateBinshopsConfigurationsTable extends Migration { /** * Run the migrations. @@ -13,10 +13,11 @@ class AddShortDescTextreaToBlogEtc extends Migration */ public function up() { - Schema::table('blog_etc_posts', function (Blueprint $table) { - $table->text("short_description")->nullable(); + Schema::create('binshops_configurations', function (Blueprint $table) { + $table->string("key")->primary(); + $table->string("value"); + $table->timestamps(); }); - } /** @@ -26,9 +27,6 @@ public function up() */ public function down() { - - Schema::table('blog_etc_posts', function (Blueprint $table) { - $table->dropColumn("short_description"); - }); + Schema::dropIfExists('binshops_configurations'); } } diff --git a/src/Baum/Extensions/Eloquent/Collection.php b/src/Baum/Extensions/Eloquent/Collection.php index 41884af..5fb8a4a 100644 --- a/src/Baum/Extensions/Eloquent/Collection.php +++ b/src/Baum/Extensions/Eloquent/Collection.php @@ -1,5 +1,5 @@ <?php -namespace WebDevEtc\BlogEtc\Baum\Extensions\Eloquent; +namespace BinshopsBlog\Baum\Extensions\Eloquent; use Illuminate\Database\Eloquent\Collection as BaseCollection; @@ -8,7 +8,7 @@ class Collection extends BaseCollection { public function toHierarchy() { $dict = $this->getDictionary(); - // Enforce sorting by $orderColumn setting in WebDevEtc\BlogEtc\Baum\Node instance + // Enforce sorting by $orderColumn setting in BinshopsBlog\Baum\Node instance uasort($dict, function($a, $b){ return ($a->getOrder() >= $b->getOrder()) ? 1 : -1; }); diff --git a/src/Baum/Extensions/Eloquent/Model.php b/src/Baum/Extensions/Eloquent/Model.php index 66fb0c5..2a2cb2b 100644 --- a/src/Baum/Extensions/Eloquent/Model.php +++ b/src/Baum/Extensions/Eloquent/Model.php @@ -1,10 +1,10 @@ <?php -namespace WebDevEtc\BlogEtc\Baum\Extensions\Eloquent; +namespace BinshopsBlog\Baum\Extensions\Eloquent; use Illuminate\Database\Eloquent\Model as BaseModel; use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\SoftDeletingScope; -use WebDevEtc\BlogEtc\Baum\Extensions\Query\Builder as QueryBuilder; +use BinshopsBlog\Baum\Extensions\Query\Builder as QueryBuilder; abstract class Model extends BaseModel { diff --git a/src/Baum/Extensions/Query/Builder.php b/src/Baum/Extensions/Query/Builder.php index 3c21afe..ac74915 100644 --- a/src/Baum/Extensions/Query/Builder.php +++ b/src/Baum/Extensions/Query/Builder.php @@ -1,6 +1,6 @@ <?php -namespace WebDevEtc\BlogEtc\Baum\Extensions\Query; +namespace BinshopsBlog\Baum\Extensions\Query; use Illuminate\Database\Query\Builder as BaseBuilder; diff --git a/src/Baum/Move.php b/src/Baum/Move.php index 63beaf8..1cd3b5f 100644 --- a/src/Baum/Move.php +++ b/src/Baum/Move.php @@ -1,5 +1,5 @@ <?php -namespace WebDevEtc\BlogEtc\Baum; +namespace BinshopsBlog\Baum; use \Illuminate\Events\Dispatcher; @@ -11,14 +11,14 @@ class Move { /** * Node on which the move operation will be performed * - * @var \WebDevEtc\BlogEtc\Baum\Node + * @var \BinshopsBlog\Baum\Node */ protected $node = NULL; /** * Destination node * - * @var \WebDevEtc\BlogEtc\Baum\Node | int + * @var \BinshopsBlog\Baum\Node | int */ protected $target = NULL; @@ -60,8 +60,8 @@ class Move { /** * Create a new Move class instance. * - * @param \WebDevEtc\BlogEtc\Baum\Node $node - * @param \WebDevEtc\BlogEtc\Baum\Node|int $target + * @param \BinshopsBlog\Baum\Node $node + * @param \BinshopsBlog\Baum\Node|int $target * @param string $position * @return void */ @@ -76,10 +76,10 @@ public function __construct($node, $target, $position) { /** * Easy static accessor for performing a move operation. * - * @param \WebDevEtc\BlogEtc\Baum\Node $node - * @param \WebDevEtc\BlogEtc\Baum\Node|int $target + * @param \BinshopsBlog\Baum\Node $node + * @param \BinshopsBlog\Baum\Node|int $target * @param string $position - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public static function to($node, $target, $position) { $instance = new static($node, $target, $position); @@ -90,7 +90,7 @@ public static function to($node, $target, $position) { /** * Perform the move operation. * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function perform() { $this->guardAgainstImpossibleMove(); @@ -176,14 +176,14 @@ public function updateStructure() { /** * Resolves suplied node. Basically returns the node unchanged if - * supplied parameter is an instance of \WebDevEtc\BlogEtc\Baum\Node. Otherwise it will try + * supplied parameter is an instance of \BinshopsBlog\Baum\Node. Otherwise it will try * to find the node in the database. * - * @param \WebDevEtc\BlogEtc\Baum\node|int - * @return \WebDevEtc\BlogEtc\Baum\Node + * @param \BinshopsBlog\Baum\node|int + * @return \BinshopsBlog\Baum\Node */ protected function resolveNode($node) { - if ( $node instanceof \WebDevEtc\BlogEtc\Baum\Node ) return $node->reload(); + if ( $node instanceof \BinshopsBlog\Baum\Node ) return $node->reload(); return $this->node->newNestedSetQuery()->find($node); } diff --git a/src/Baum/MoveNotPossibleException.php b/src/Baum/MoveNotPossibleException.php index a05c4b2..8056c90 100644 --- a/src/Baum/MoveNotPossibleException.php +++ b/src/Baum/MoveNotPossibleException.php @@ -1,4 +1,4 @@ <?php -namespace WebDevEtc\BlogEtc\Baum; +namespace BinshopsBlog\Baum; class MoveNotPossibleException extends \RuntimeException {} diff --git a/src/Baum/Node.php b/src/Baum/Node.php index 9629c2c..07758f6 100644 --- a/src/Baum/Node.php +++ b/src/Baum/Node.php @@ -1,8 +1,8 @@ <?php -namespace WebDevEtc\BlogEtc\Baum; +namespace BinshopsBlog\Baum; -use WebDevEtc\BlogEtc\Baum\Extensions\Eloquent\Collection; -use WebDevEtc\BlogEtc\Baum\Extensions\Eloquent\Model; +use BinshopsBlog\Baum\Extensions\Eloquent\Collection; +use BinshopsBlog\Baum\Extensions\Eloquent\Model; /** * Node @@ -347,7 +347,7 @@ public function newNestedSetQuery($excludeDeleted = true) { * Overload new Collection * * @param array $models - * @return \WebDevEtc\BlogEtc\Baum\Extensions\Eloquent\Collection + * @return \BinshopsBlog\Baum\Extensions\Eloquent\Collection */ public function newCollection(array $models = array()) { return new Collection($models); @@ -887,7 +887,7 @@ public function getRightSibling() { /** * Find the left sibling and move to left of it. * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function moveLeft() { return $this->moveToLeftOf($this->getLeftSibling()); @@ -896,7 +896,7 @@ public function moveLeft() { /** * Find the right sibling and move to the right of it. * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function moveRight() { return $this->moveToRightOf($this->getRightSibling()); @@ -905,7 +905,7 @@ public function moveRight() { /** * Move to the node to the left of ... * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function moveToLeftOf($node) { return $this->moveTo($node, 'left'); @@ -914,7 +914,7 @@ public function moveToLeftOf($node) { /** * Move to the node to the right of ... * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function moveToRightOf($node) { return $this->moveTo($node, 'right'); @@ -923,7 +923,7 @@ public function moveToRightOf($node) { /** * Alias for moveToRightOf * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function makeNextSiblingOf($node) { return $this->moveToRightOf($node); @@ -932,7 +932,7 @@ public function makeNextSiblingOf($node) { /** * Alias for moveToRightOf * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function makeSiblingOf($node) { return $this->moveToRightOf($node); @@ -941,7 +941,7 @@ public function makeSiblingOf($node) { /** * Alias for moveToLeftOf * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function makePreviousSiblingOf($node) { return $this->moveToLeftOf($node); @@ -950,7 +950,7 @@ public function makePreviousSiblingOf($node) { /** * Make the node a child of ... * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function makeChildOf($node) { return $this->moveTo($node, 'child'); @@ -959,7 +959,7 @@ public function makeChildOf($node) { /** * Make the node the first child of ... * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function makeFirstChildOf($node) { if ( $node->children()->count() == 0 ) @@ -971,7 +971,7 @@ public function makeFirstChildOf($node) { /** * Make the node the last child of ... * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function makeLastChildOf($node) { return $this->makeChildOf($node); @@ -980,7 +980,7 @@ public function makeLastChildOf($node) { /** * Make current node a root node. * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function makeRoot() { return $this->moveTo($this, 'root'); @@ -989,7 +989,7 @@ public function makeRoot() { /** * Equals? * - * @param \WebDevEtc\BlogEtc\Baum\Node + * @param \BinshopsBlog\Baum\Node * @return boolean */ public function equals($node) { @@ -999,7 +999,7 @@ public function equals($node) { /** * Checkes if the given node is in the same scope as the current one. * - * @param \WebDevEtc\BlogEtc\Baum\Node + * @param \BinshopsBlog\Baum\Node * @return boolean */ public function inSameScope($other) { @@ -1014,7 +1014,7 @@ public function inSameScope($other) { * Checks wether the given node is a descendant of itself. Basically, whether * its in the subtree defined by the left and right indices. * - * @param \WebDevEtc\BlogEtc\Baum\Node + * @param \BinshopsBlog\Baum\Node * @return boolean */ public function insideSubtree($node) { @@ -1071,7 +1071,7 @@ public function moveToNewParent() { /** * Sets the depth attribute * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function setDepth() { $self = $this; @@ -1091,7 +1091,7 @@ public function setDepth() { /** * Sets the depth attribute for the current node and all of its descendants. * - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ public function setDepthWithSubtree() { $self = $this; @@ -1232,9 +1232,9 @@ public function makeTree($nodeList) { * Main move method. Here we handle all node movements with the corresponding * lft/rgt index updates. * - * @param WebDevEtc\BlogEtc\Baum\Node|int $target + * @param BinshopsBlog\Baum\Node|int $target * @param string $position - * @return \WebDevEtc\BlogEtc\Baum\Node + * @return \BinshopsBlog\Baum\Node */ protected function moveTo($target, $position) { return Move::to($this, $target, $position); @@ -1259,7 +1259,7 @@ protected function computeLevel() { /** * Return an array with the last node we could reach and its nesting level * - * @param WebDevEtc\BlogEtc\Baum\Node $node + * @param BinshopsBlog\Baum\Node $node * @param integer $nesting * @return array */ diff --git a/src/Baum/SetBuilder.php b/src/Baum/SetBuilder.php index e3b57bb..0374ddc 100644 --- a/src/Baum/SetBuilder.php +++ b/src/Baum/SetBuilder.php @@ -1,15 +1,15 @@ <?php -namespace WebDevEtc\BlogEtc\Baum; +namespace BinshopsBlog\Baum; -use WebDevEtc\BlogEtc\Baum\Helpers\DatabaseHelper as DB; -use WebDevEtc\BlogEtc\Baum\Node; +use BinshopsBlog\Baum\Helpers\DatabaseHelper as DB; +use BinshopsBlog\Baum\Node; class SetBuilder { /** * Node instance for reference * - * @var \WebDevEtc\BlogEtc\Baum\Node + * @var \BinshopsBlog\Baum\Node */ protected $node = NULL; @@ -21,9 +21,9 @@ class SetBuilder { protected $bounds = array(); /** - * Create a new \WebDevEtc\BlogEtc\Baum\SetBuilder class instance. + * Create a new \BinshopsBlog\Baum\SetBuilder class instance. * - * @param \WebDevEtc\BlogEtc\Baum\Node $node + * @param \BinshopsBlog\Baum\Node $node * @return void */ public function __construct($node) { @@ -91,7 +91,7 @@ public function rebuildBounds($node, $depth = 0) { /** * Return all children for the specified node. * - * @param WebDevEtc\BlogEtc\Baum\Node $node + * @param BinshopsBlog\Baum\Node $node * @return Illuminate\Database\Eloquent\Collection */ public function children($node) { @@ -114,7 +114,7 @@ public function children($node) { /** * Return an array of the scoped attributes of the supplied node. * - * @param WebDevEtc\BlogEtc\Baum\Node $node + * @param BinshopsBlog\Baum\Node $node * @return array */ protected function scopedAttributes($node) { @@ -133,7 +133,7 @@ protected function scopedAttributes($node) { * Return a string-key for the current scoped attributes. Used for index * computing when a scope is defined (acsts as an scope identifier). * - * @param WebDevEtc\BlogEtc\Baum\Node $node + * @param BinshopsBlog\Baum\Node $node * @return string */ protected function scopedKey($node) { diff --git a/src/Baum/SetMapper.php b/src/Baum/SetMapper.php index 52f14aa..9a68833 100644 --- a/src/Baum/SetMapper.php +++ b/src/Baum/SetMapper.php @@ -1,16 +1,16 @@ <?php -namespace WebDevEtc\BlogEtc\Baum; +namespace BinshopsBlog\Baum; use \Closure; use Illuminate\Support\Contracts\ArrayableInterface; -use WebDevEtc\BlogEtc\Baum\Node; +use BinshopsBlog\Baum\Node; class SetMapper { /** * Node instance for reference * - * @var \WebDevEtc\BlogEtc\Baum\Node + * @var \BinshopsBlog\Baum\Node */ protected $node = NULL; @@ -22,9 +22,9 @@ class SetMapper { protected $childrenKeyName = 'children'; /** - * Create a new \WebDevEtc\BlogEtc\Baum\SetBuilder class instance. + * Create a new \BinshopsBlog\Baum\SetBuilder class instance. * - * @param \WebDevEtc\BlogEtc\Baum\Node $node + * @param \BinshopsBlog\Baum\Node $node * @return void */ public function __construct($node, $childrenKeyName = 'children') { diff --git a/src/Baum/SetValidator.php b/src/Baum/SetValidator.php index e6a29e3..c6bd03d 100644 --- a/src/Baum/SetValidator.php +++ b/src/Baum/SetValidator.php @@ -1,5 +1,5 @@ <?php -namespace WebDevEtc\BlogEtc\Baum; +namespace BinshopsBlog\Baum; use Illuminate\Database\Capsule\Manager as Capsule; @@ -8,14 +8,14 @@ class SetValidator { /** * Node instance for reference * - * @var \WebDevEtc\BlogEtc\Baum\Node + * @var \BinshopsBlog\Baum\Node */ protected $node = NULL; /** - * Create a new \WebDevEtc\BlogEtc\Baum\SetValidator class instance. + * Create a new \BinshopsBlog\Baum\SetValidator class instance. * - * @param \WebDevEtc\BlogEtc\Baum\Node $node + * @param \BinshopsBlog\Baum\Node $node * @return void */ public function __construct($node) { @@ -207,7 +207,7 @@ protected function groupRootsByScope($roots) { * Builds a single string for the given scope columns values. Useful for * making array keys for grouping. * - * @param WebDevEtc\BlogEtc\Baum\Node $node + * @param BinshopsBlog\Baum\Node $node * @return string */ protected function keyForScope($node) { diff --git a/src/BinshopsBlogServiceProvider.php b/src/BinshopsBlogServiceProvider.php new file mode 100755 index 0000000..a1fa100 --- /dev/null +++ b/src/BinshopsBlogServiceProvider.php @@ -0,0 +1,90 @@ +<?php + +namespace BinshopsBlog; + +use BinshopsBlog\Models\BinshopsPostTranslation; +use Illuminate\Support\ServiceProvider; +use BinshopsBlog\Models\BinshopsPost; +use BinshopsBlog\Laravel\Fulltext\Commands\Index; +use BinshopsBlog\Laravel\Fulltext\Commands\IndexOne; +use BinshopsBlog\Laravel\Fulltext\Commands\UnindexOne; +use BinshopsBlog\Laravel\Fulltext\ModelObserver; +use BinshopsBlog\Laravel\Fulltext\Search; +use BinshopsBlog\Laravel\Fulltext\SearchInterface; + +class BinshopsBlogServiceProvider extends ServiceProvider +{ + + protected $commands = [ + Index::class, + IndexOne::class, + UnindexOne::class, + ]; + /** + * Bootstrap services. + * + * @return void + */ + public function boot() + { + + if (config("binshopsblog.search.search_enabled") == false) { + // if search is disabled, don't allow it to sync. + ModelObserver::disableSyncingFor(BinshopsPostTranslation::class); + } + + if (config("binshopsblog.include_default_routes", true)) { + include(__DIR__ . "/routes.php"); + } + + foreach ([ + '2020_10_16_005400_create_binshops_categories_table.php', + '2020_10_16_005425_create_binshops_category_translations_table.php', + '2020_10_16_010039_create_binshops_posts_table.php', + '2020_10_16_010049_create_binshops_post_translations_table.php', + '2020_10_16_121230_create_binshops_comments_table.php', + '2020_10_16_121728_create_binshops_uploaded_photos_table.php', + '2020_10_16_004241_create_binshops_languages_table.php', + '2020_10_22_132005_create_binshops_configurations_table.php', + '2016_11_04_152913_create_laravel_fulltext_table.php' + ] as $file) { + + $this->publishes([ + __DIR__ . '/../migrations/' . $file => database_path('migrations/' . $file) + ]); + + } + + $this->publishes([ + __DIR__ . '/Views/binshopsblog' => base_path('resources/views/vendor/binshopsblog'), + __DIR__ . '/Config/binshopsblog.php' => config_path('binshopsblog.php'), + __DIR__ . '/css/binshopsblog_admin_css.css' => public_path('binshopsblog_admin_css.css'), + __DIR__ . '/css/binshops-blog.css' => public_path('binshops-blog.css'), + __DIR__ . '/css/admin-setup.css' => public_path('admin-setup.css'), + __DIR__ . '/js/binshops-blog.js' => public_path('binshops-blog.js'), + ]); + + + } + + /** + * Register services. + * + * @return void + */ + public function register() + { + $this->app->bind( + SearchInterface::class, + Search::class + ); + + // for the admin backend views ( view("binshopsblog_admin::BLADEFILE") ) + $this->loadViewsFrom(__DIR__ . "/Views/binshopsblog_admin", 'binshopsblog_admin'); + + // for public facing views (view("binshopsblog::BLADEFILE")): + // if you do the vendor:publish, these will be copied to /resources/views/vendor/binshopsblog anyway + $this->loadViewsFrom(__DIR__ . "/Views/binshopsblog", 'binshopsblog'); + } + +} diff --git a/src/BlogEtcServiceProvider.php b/src/BlogEtcServiceProvider.php deleted file mode 100755 index a8ed524..0000000 --- a/src/BlogEtcServiceProvider.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc; - -use Illuminate\Support\ServiceProvider; -use Swis\Laravel\Fulltext\ModelObserver; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; - -class BlogEtcServiceProvider extends ServiceProvider -{ - /** - * Bootstrap services. - * - * @return void - */ - public function boot() - { - - if (config("blogetc.search.search_enabled") == false) { - // if search is disabled, don't allow it to sync. - ModelObserver::disableSyncingFor(BlogEtcPost::class); - } - - if (config("blogetc.include_default_routes", true)) { - include(__DIR__ . "/routes.php"); - } - - - foreach ([ - '2018_05_28_224023_create_blog_etc_posts_table.php', - '2018_09_16_224023_add_author_and_url_blog_etc_posts_table.php', - '2018_09_26_085711_add_short_desc_textrea_to_blog_etc.php', - '2018_09_27_122627_create_blog_etc_uploaded_photos_table.php', - '2020_05_27_104123_add_parameters_blog_etc_categories_table.php' - ] as $file) { - - $this->publishes([ - __DIR__ . '/../migrations/' . $file => database_path('migrations/' . $file) - ]); - - } - - $this->publishes([ - __DIR__ . '/Views/blogetc' => base_path('resources/views/vendor/blogetc'), - __DIR__ . '/Config/blogetc.php' => config_path('blogetc.php'), - __DIR__ . '/css/blogetc_admin_css.css' => public_path('blogetc_admin_css.css'), - __DIR__ . '/css/hessam-blog.css' => public_path('hessam-blog.css'), - __DIR__ . '/js/hessam-blog.js' => public_path('hessam-blog.js'), - ]); - - - } - - /** - * Register services. - * - * @return void - */ - public function register() - { - - // for the admin backend views ( view("blogetc_admin::BLADEFILE") ) - $this->loadViewsFrom(__DIR__ . "/Views/blogetc_admin", 'blogetc_admin'); - - // for public facing views (view("blogetc::BLADEFILE")): - // if you do the vendor:publish, these will be copied to /resources/views/vendor/blogetc anyway - $this->loadViewsFrom(__DIR__ . "/Views/blogetc", 'blogetc'); - } - -} diff --git a/src/Captcha/Basic.php b/src/Captcha/Basic.php index c98c380..f65694e 100644 --- a/src/Captcha/Basic.php +++ b/src/Captcha/Basic.php @@ -1,15 +1,15 @@ -<?php namespace WebDevEtc\BlogEtc\Captcha; +<?php namespace BinshopsBlog\Captcha; /** * Class Basic - * @package WebDevEtc\BlogEtc\Captcha + * @package BinshopsBlog\Captcha */ class Basic extends CaptchaAbstract { public function __construct() { - if (!config("blogetc.captcha.basic_question") || !config("blogetc.captcha.basic_answers")) { + if (!config("binshopsblog.captcha.basic_question") || !config("binshopsblog.captcha.basic_answers")) { throw new \DomainException("Invalid question or answers for captcha"); } } @@ -31,7 +31,7 @@ public function captcha_field_name() */ public function view() { - return 'blogetc::captcha.basic'; + return 'binshopsblog::captcha.basic'; } /** @@ -44,7 +44,7 @@ public function view() public function rules() { $check_func = function ($attribute, $value, $fail) { - $answers = config("blogetc.captcha.basic_answers"); + $answers = config("binshopsblog.captcha.basic_answers"); // strtolower everything $value = strtolower(trim($value)); $answers = strtolower($answers); diff --git a/src/Captcha/CaptchaAbstract.php b/src/Captcha/CaptchaAbstract.php index c11dcf1..ec7b828 100644 --- a/src/Captcha/CaptchaAbstract.php +++ b/src/Captcha/CaptchaAbstract.php @@ -1,8 +1,9 @@ -<?php namespace WebDevEtc\BlogEtc\Captcha; +<?php namespace BinshopsBlog\Captcha; use Illuminate\Http\Request; -use WebDevEtc\BlogEtc\Interfaces\CaptchaInterface; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use BinshopsBlog\Interfaces\CaptchaInterface; +use BinshopsBlog\Models\BinshopsPost; +use BinshopsBlog\Models\BinshopsPostTranslation; abstract class CaptchaAbstract implements CaptchaInterface { @@ -12,11 +13,11 @@ abstract class CaptchaAbstract implements CaptchaInterface * executed when viewing single post * * @param Request $request - * @param BlogEtcPost $blogEtcPost + * @param BinshopsPostTranslation $binshopsBlogPost * * @return void */ - public function runCaptchaBeforeShowingPosts(Request $request, BlogEtcPost $blogEtcPost) + public function runCaptchaBeforeShowingPosts(Request $request, BinshopsPostTranslation $binshopsBlogPost) { // no code here to run! Maybe in your subclass you can make use of this? /* @@ -37,13 +38,13 @@ public function runCaptchaBeforeShowingPosts(Request $request, BlogEtcPost $blog * executed when posting new comment * * @param Request $request - * @param BlogEtcPost $blogEtcPost + * @param BinshopsPost $binshopsBlogPost * * @return void */ - public function runCaptchaBeforeAddingComment(Request $request, BlogEtcPost $blogEtcPost) + public function runCaptchaBeforeAddingComment(Request $request, BinshopsPost $binshopsBlogPost) { // no code here to run! Maybe in your subclass you can make use of this? } -} \ No newline at end of file +} diff --git a/src/Captcha/UsesCaptcha.php b/src/Captcha/UsesCaptcha.php index 9b3f85d..3076ab2 100644 --- a/src/Captcha/UsesCaptcha.php +++ b/src/Captcha/UsesCaptcha.php @@ -1,11 +1,11 @@ -<?php namespace WebDevEtc\BlogEtc\Captcha; +<?php namespace BinshopsBlog\Captcha; /** * Trait UsesCaptcha * - * For instantiating the config("blogetc.captcha.captcha_type") object. + * For instantiating the config("binshopsblog.captcha.captcha_type") object. * - * @package WebDevEtc\BlogEtc\Captcha + * @package BinshopsBlog\Captcha */ trait UsesCaptcha { @@ -15,13 +15,13 @@ trait UsesCaptcha */ private function getCaptchaObject() { - if (!config("blogetc.captcha.captcha_enabled")) { + if (!config("binshopsblog.captcha.captcha_enabled")) { return null; } // else: captcha is enabled /** @var string $captcha_class */ - $captcha_class = config("blogetc.captcha.captcha_type"); + $captcha_class = config("binshopsblog.captcha.captcha_type"); return new $captcha_class; } diff --git a/src/Config/blogetc.php b/src/Config/binshopsblog.php similarity index 86% rename from src/Config/blogetc.php rename to src/Config/binshopsblog.php index b774dec..50a0757 100755 --- a/src/Config/blogetc.php +++ b/src/Config/binshopsblog.php @@ -1,17 +1,16 @@ <?php -//config for hessam/laravel-blogger +//config for binshops/laravel-blogger return [ - //Your custom User model - //Change it to \App\Models\User::class for laravel 8.x's default auth User model - 'user_model'=>\App\User::class, + //Change it to \App\User::class for previous laravel versions + 'user_model'=>\App\Models\User::class, // reading progress bar is the bar which shows on top of your post when you are scrolling down the page. You can disable this feature if you want 'reading_progress_bar' => true, - 'include_default_routes' => true, // set to false to not include routes.php for BlogEtcReaderController and admin related routes. Default: true. If you disable this, you will have to manually copy over the data from routes.php and add it to your web.php. + 'include_default_routes' => true, // set to false to not include routes.php for BinshopsReaderController and admin related routes. Default: true. If you disable this, you will have to manually copy over the data from routes.php and add it to your web.php. 'blog_prefix' => "blog", // used in routes.php. If you want to your http://yoursite.com/latest-news (or anything else), then enter that here. Default: blog 'admin_prefix' => "blog_admin", // similar to above, but used for the admin panel for the blog. Default: blog_admin @@ -26,7 +25,7 @@ 'memory_limit' => '2048M', // This is used when uploading images : - // @ini_set('memory_limit', config("blogetc.memory_limit")); + // @ini_set('memory_limit', config("binshopsblog.memory_limit")); // See PHP.net for detailso // Set to false to not set any value. @@ -89,7 +88,7 @@ ], // you can add more fields here, but make sure that you create the relevant database columns too! - // They must be in the same format as the default ones - image_xxxxx (and this db column must exist on the blog_etc_posts table) + // They must be in the same format as the default ones - image_xxxxx (and this db column must exist on the binshops_posts table) /* 'image_custom_example_size' => [ // << MAKE A DB COLUM WITH THIS NAME. @@ -103,7 +102,7 @@ ], */ // Create the custom db table by doing - // php artisan make:migration --table=blog_etc_posts AddCustomBlogImageSize + // php artisan make:migration --table=binshops_posts AddCustomBlogImageSize // then adding in the up() method: // $table->string("image_custom_example_size")->nullable(); // and in the down() method: @@ -115,23 +114,11 @@ 'captcha' => [ 'captcha_enabled' => true, // true = we should use a captcha, false = turn it off. If comments are disabled this makes no difference. - 'captcha_type' => \WebDevEtc\BlogEtc\Captcha\Basic::class, // this should be a class that implements the \WebDevEtc\BlogEtc\Interfaces\CaptchaInterface interface + 'captcha_type' => \BinshopsBlog\Captcha\Basic::class, // this should be a class that implements the \BinshopsBlog\Interfaces\CaptchaInterface interface 'basic_question' => "What is the opposite of white?", // a simple captcha question to always ask (if captcha_type is set to 'basic' 'basic_answers' => "black,dark", // comma separated list of possible answers. Don't worry about case. ], - ////////// RSS FEED - - 'rssfeed' => [ - - 'should_shorten_text' => true, // boolean. Default: true. Should we shorten the text in rss feed? - 'text_limit' => 100, // max length of description text in the rss feed - 'posts_to_show_in_rss_feed' => 10, // how many posts should we show in the rss feed - 'cache_in_minutes' => 60, // how long (in minutes) to cache the RSS blog feed for. - 'description' => "Our blog post RSS feed", //description for the RSS feed - 'language' => "en", // see https://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes - ], - ////////// comments: 'comments' => [ @@ -141,7 +128,7 @@ // options: // 'built_in' (default, uses own database for comments), // 'disqus' (uses https://disqus.com/, please enter further config options below), - // 'custom' (will load blogetc::partials.custom_comments, which you can copy to your vendor view dir to customise + // 'custom' (will load binshopsblog::partials.custom_comments, which you can copy to your vendor view dir to customise // 'disabled' (turn comments off) 'type_of_comments_to_show' => 'built_in', // default: built_in @@ -177,6 +164,13 @@ 'search' => [ 'search_enabled' => true, //you can easily turn off search functionality + + 'limit-results'=> 50, + 'enable_wildcards' => true, + 'weight' => [ + 'title' => 1.5, + 'content' => 1, + ], ], //Shows full text of post in listing pages like search result page or category page. Now it shows a preview diff --git a/src/Controllers/BinshopsAdminController.php b/src/Controllers/BinshopsAdminController.php new file mode 100755 index 0000000..34c3ef1 --- /dev/null +++ b/src/Controllers/BinshopsAdminController.php @@ -0,0 +1,503 @@ +<?php + +namespace BinshopsBlog\Controllers; + +use App\Http\Controllers\Controller; +use BinshopsBlog\Laravel\Fulltext\Search; +use BinshopsBlog\Models\BinshopsCategory; +use Carbon\Carbon; +use Illuminate\Http\Request; +use BinshopsBlog\Interfaces\BaseRequestInterface; +use BinshopsBlog\Events\BlogPostAdded; +use BinshopsBlog\Events\BlogPostEdited; +use BinshopsBlog\Events\BlogPostWillBeDeleted; +use BinshopsBlog\Helpers; +use BinshopsBlog\Middleware\LoadLanguage; +use BinshopsBlog\Middleware\PackageSetup; +use BinshopsBlog\Middleware\UserCanManageBlogPosts; +use BinshopsBlog\Models\BinshopsCategoryTranslation; +use BinshopsBlog\Models\BinshopsLanguage; +use BinshopsBlog\Models\BinshopsPost; +use BinshopsBlog\Models\BinshopsPostTranslation; +use BinshopsBlog\Models\BinshopsUploadedPhoto; +use BinshopsBlog\Requests\CreateBinshopsBlogPostRequest; +use BinshopsBlog\Requests\CreateBinshopsPostToggleRequest; +use BinshopsBlog\Requests\DeleteBinshopsBlogPostRequest; +use BinshopsBlog\Requests\UpdateBinshopsBlogPostRequest; +use BinshopsBlog\Traits\UploadFileTrait; + +/** + * Class BinshopsAdminController + * @package BinshopsBlog\Controllers + */ +class BinshopsAdminController extends Controller +{ + use UploadFileTrait; + + /** + * BinshopsAdminController constructor. + */ + public function __construct() + { + $this->middleware(UserCanManageBlogPosts::class); + $this->middleware(LoadLanguage::class); + $this->middleware(PackageSetup::class); + + if (!is_array(config("binshopsblog"))) { + throw new \RuntimeException('The config/binshopsblog.php does not exist. Publish the vendor files for the BinshopsBlog package by running the php artisan publish:vendor command'); + } + } + + /** + * View all posts + * + * @return mixed + */ + public function index(Request $request) + { + $language_id = $request->get('language_id'); + $posts = BinshopsPostTranslation::orderBy("post_id", "desc")->where('lang_id', $language_id) + ->paginate(10); + + return view("binshopsblog_admin::index", [ + 'post_translations'=>$posts, + 'language_id' => $language_id + ]); + } + + /** + * Show form for creating new post + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function create_post(Request $request) + { + $language_id = $request->get('language_id'); + $language_list = BinshopsLanguage::where('active',true)->get(); + $ts = BinshopsCategoryTranslation::where("lang_id",$language_id)->limit(1000)->get(); + + $new_post = new BinshopsPost(); + $new_post->is_published = true; + + return view("binshopsblog_admin::posts.add_post", [ + 'cat_ts' => $ts, + 'language_list' => $language_list, + 'selected_lang' => $language_id, + 'post' => $new_post, + 'post_translation' => new \BinshopsBlog\Models\BinshopsPostTranslation(), + 'post_id' => -1 + ]); + } + + /** + * Save a new post - this method is called whenever add post button is clicked + * + * @param CreateBinshopsBlogPostRequest $request + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @throws \Exception + */ + public function store_post(CreateBinshopsBlogPostRequest $request) + { + $new_blog_post = null; + $translation = BinshopsPostTranslation::where( + [ + ['post_id','=',$request['post_id']], + ['lang_id', '=', $request['lang_id']] + ] + )->first(); + + if (!$translation){ + $translation = new BinshopsPostTranslation(); + } + + if ($request['post_id'] == -1 || $request['post_id'] == null){ + //cretes new post + $new_blog_post = new BinshopsPost(); + $translation = new BinshopsPostTranslation(); + + $new_blog_post->posted_at = Carbon::now(); + }else{ + //edits post + $new_blog_post = BinshopsPost::findOrFail($request['post_id']); + } + + $post_exists = $this->check_if_same_post_exists($request['slug'] , $request['lang_id'], $request['post_id']); + if ($post_exists){ + Helpers::flash_message("Post already exists - try to change the slug for this language"); + }else { + $new_blog_post->is_published = $request['is_published']; + $new_blog_post->user_id = \Auth::user()->id; + $new_blog_post->save(); + + $translation->title = $request['title']; + $translation->subtitle = $request['subtitle']; + $translation->short_description = $request['short_description']; + $translation->post_body = $request['post_body']; + $translation->seo_title = $request['seo_title']; + $translation->meta_desc = $request['meta_desc']; + $translation->slug = $request['slug']; + $translation->use_view_file = $request['use_view_file']; + + $translation->lang_id = $request['lang_id']; + $translation->post_id = $new_blog_post->id; + + $this->processUploadedImages($request, $translation); + $translation->save(); + + $new_blog_post->categories()->sync($request->categories()); + Helpers::flash_message("Added post"); + event(new BlogPostAdded($new_blog_post)); + } + + return redirect( route('binshopsblog.admin.index') ); + } + + /** + * This method is called whenever a language is selected + */ + public function store_post_toggle(CreateBinshopsPostToggleRequest $request){ + $new_blog_post = null; + $translation = BinshopsPostTranslation::where( + [ + ['post_id','=',$request['post_id']], + ['lang_id', '=', $request['lang_id']] + ] + )->first(); + + if (!$translation){ + $translation = new BinshopsPostTranslation(); + } + + if ($request['post_id'] == -1 || $request['post_id'] == null){ + //cretes new post + $new_blog_post = new BinshopsPost(); + $new_blog_post->is_published = true; + $new_blog_post->posted_at = Carbon::now(); + }else{ + //edits post + $new_blog_post = BinshopsPost::findOrFail($request['post_id']); + } + + if ($request['slug']){ + $post_exists = $this->check_if_same_post_exists($request['slug'] , $request['lang_id'], $new_blog_post->id); + if ($post_exists){ + Helpers::flash_message("Post already exists - try to change the slug for this language"); + }else{ + $new_blog_post->is_published = $request['is_published']; + $new_blog_post->user_id = \Auth::user()->id; + $new_blog_post->save(); + + $translation->title = $request['title']; + $translation->subtitle = $request['subtitle']; + $translation->short_description = $request['short_description']; + $translation->post_body = $request['post_body']; + $translation->seo_title = $request['seo_title']; + $translation->meta_desc = $request['meta_desc']; + $translation->slug = $request['slug']; + $translation->use_view_file = $request['use_view_file']; + + $translation->lang_id = $request['lang_id']; + $translation->post_id = $new_blog_post->id; + + $this->processUploadedImages($request, $translation); + $translation->save(); + + $new_blog_post->categories()->sync($request->categories()); + + event(new BlogPostAdded($new_blog_post)); + } + } + + //todo: generate event + + $language_id = $request->get('language_id'); + $language_list = BinshopsLanguage::where('active',true)->get(); + $ts = BinshopsCategoryTranslation::where("lang_id",$language_id)->limit(1000)->get(); + + $translation = BinshopsPostTranslation::where( + [ + ['post_id','=',$request['post_id']], + ['lang_id', '=', $request['selected_lang']] + ] + )->first(); + if (!$translation){ + $translation = new BinshopsPostTranslation(); + } + + return view("binshopsblog_admin::posts.add_post", [ + 'cat_ts' => $ts, + 'language_list' => $language_list, + 'selected_lang' => $request['selected_lang'], + 'post_translation' => $translation, + 'post' => $new_blog_post, + 'post_id' => $new_blog_post->id + ]); + } + + /** + * Show form to edit post + * + * @param $blogPostId + * @return mixed + */ + public function edit_post( $blogPostId , Request $request) + { + $language_id = $request->get('language_id'); + + $post_translation = BinshopsPostTranslation::where( + [ + ['lang_id', '=', $language_id], + ['post_id', '=', $blogPostId] + ] + )->first(); + + $post = BinshopsPost::findOrFail($blogPostId); + $language_list = BinshopsLanguage::where('active',true)->get(); + $ts = BinshopsCategoryTranslation::where("lang_id",$language_id)->limit(1000)->get(); + + return view("binshopsblog_admin::posts.edit_post", [ + 'cat_ts' => $ts, + 'language_list' => $language_list, + 'selected_lang' => $language_id, + 'selected_locale' => BinshopsLanguage::where('id', $language_id)->first()->locale, + 'post' => $post, + 'post_translation' => $post_translation + ]); + } + + /** + * Show form to edit post + * + * @param $blogPostId + * @return mixed + */ + public function edit_post_toggle( $blogPostId , Request $request) + { + $post_translation = BinshopsPostTranslation::where( + [ + ['lang_id', '=', $request['selected_lang']], + ['post_id', '=', $blogPostId] + ] + )->first(); + if (!$post_translation){ + $post_translation = new BinshopsPostTranslation(); + } + + $post = BinshopsPost::findOrFail($blogPostId); + $language_list = BinshopsLanguage::where('active',true)->get(); + $ts = BinshopsCategoryTranslation::where("lang_id", $request['selected_lang'])->limit(1000)->get(); + + return view("binshopsblog_admin::posts.edit_post", [ + 'cat_ts' => $ts, + 'language_list' => $language_list, + 'selected_lang' => $request['selected_lang'], + 'selected_locale' => BinshopsLanguage::where('id', $request['selected_lang'])->first()->locale, + 'post' => $post, + 'post_translation' => $post_translation + ]); + } + + /** + * Save changes to a post + * + * @param UpdateBinshopsBlogPostRequest $request + * @param $blogPostId + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * @throws \Exception + */ + public function update_post(UpdateBinshopsBlogPostRequest $request, $blogPostId) + { + $new_blog_post = BinshopsPost::findOrFail($blogPostId); + $translation = BinshopsPostTranslation::where( + [ + ['post_id','=', $new_blog_post->id], + ['lang_id', '=', $request['lang_id']] + ] + )->first(); + + if (!$translation){ + $translation = new BinshopsPostTranslation(); + $new_blog_post->posted_at = Carbon::now(); + } + + $post_exists = $this->check_if_same_post_exists($request['slug'] , $request['lang_id'], $blogPostId); + if ($post_exists){ + Helpers::flash_message("Post already exists - try to change the slug for this language"); + }else { + $new_blog_post->is_published = $request['is_published']; + $new_blog_post->user_id = \Auth::user()->id; + $new_blog_post->save(); + + $translation->title = $request['title']; + $translation->subtitle = $request['subtitle']; + $translation->short_description = $request['short_description']; + $translation->post_body = $request['post_body']; + $translation->seo_title = $request['seo_title']; + $translation->meta_desc = $request['meta_desc']; + $translation->slug = $request['slug']; + $translation->use_view_file = $request['use_view_file']; + + $translation->lang_id = $request['lang_id']; + $translation->post_id = $new_blog_post->id; + + $this->processUploadedImages($request, $translation); + $translation->save(); + + $new_blog_post->categories()->sync($request->categories()); + Helpers::flash_message("Post Updated"); + event(new BlogPostAdded($new_blog_post)); + } + + return redirect( route('binshopsblog.admin.index') ); + } + + public function remove_photo($postSlug, $lang_id) + { + $post = BinshopsPostTranslation::where([ + ["slug", '=', $postSlug], + ['lang_id', '=', $lang_id] + ])->firstOrFail(); + + $path = public_path('/' . config("binshopsblog.blog_upload_dir")); + if (!$this->checked_blog_image_dir_is_writable) { + if (!is_writable($path)) { + throw new \RuntimeException("Image destination path is not writable ($path)"); + } + } + + $destinationPath = $this->image_destination_path(); + + if (file_exists($destinationPath.'/'.$post->image_large)) { + unlink($destinationPath.'/'.$post->image_large); + } + + if (file_exists($destinationPath.'/'.$post->image_medium)) { + unlink($destinationPath.'/'.$post->image_medium); + } + + if (file_exists($destinationPath.'/'.$post->image_thumbnail)) { + unlink($destinationPath.'/'.$post->image_thumbnail); + } + + $post->image_large = null; + $post->image_medium = null; + $post->image_thumbnail = null; + $post->save(); + + Helpers::flash_message("Photo removed"); + + return redirect($post->edit_url()); + } + + /** + * Delete a post + * + * @param DeleteBinshopsBlogPostRequest $request + * @param $blogPostId + * @return mixed + */ + public function destroy_post(DeleteBinshopsBlogPostRequest $request, $blogPostId) + { + $post = BinshopsPost::findOrFail($blogPostId); + //archive deleted post + + $post->delete(); + event(new BlogPostWillBeDeleted($post)); + + // todo - delete the featured images? + // At the moment it just issues a warning saying the images are still on the server. + + Helpers::flash_message("Post successfully deleted!"); + + return redirect( route('binshopsblog.admin.index') ); + } + + /** + * Process any uploaded images (for featured image) + * + * @param BaseRequestInterface $request + * @param $new_blog_post + * @throws \Exception + * @todo - next full release, tidy this up! + */ + protected function processUploadedImages(BaseRequestInterface $request, BinshopsPostTranslation $new_blog_post) + { + if (!config("binshopsblog.image_upload_enabled")) { + // image upload was disabled + return; + } + + $this->increaseMemoryLimit(); + + // to save in db later + $uploaded_image_details = []; + + + foreach ((array)config('binshopsblog.image_sizes') as $size => $image_size_details) { + + if ($image_size_details['enabled'] && $photo = $request->get_image_file($size)) { + // this image size is enabled, and + // we have an uploaded image that we can use + + $uploaded_image = $this->UploadAndResize($new_blog_post, $new_blog_post->slug, $image_size_details, $photo); + + $new_blog_post->$size = $uploaded_image['filename']; + $uploaded_image_details[$size] = $uploaded_image; + } + } + + // store the image upload. + // todo: link this to the binshopsblog_post row. + if (count(array_filter($uploaded_image_details))>0) { + BinshopsUploadedPhoto::create([ + 'source' => "BlogFeaturedImage", + 'uploaded_images' => $uploaded_image_details, + ]); + } + } + + //translations for the same psots are ignored + protected function check_if_same_post_exists($slug, $lang_id, $post_id){ + $slg = BinshopsPostTranslation::where( + [ + ['slug','=', $slug], + ['lang_id', '=', $lang_id], + ['post_id', '<>', $post_id] + ] + )->first(); + if ($slg){ + return true; + }else{ + return false; + } + } + + /** + * Show the search results for $_GET['s'] + * + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * @throws \Exception + */ + public function searchBlog(Request $request) + { + if (!config("binshopsblog.search.search_enabled")) { + throw new \Exception("Search is disabled"); + } + $query = $request->get("s"); + $search = new Search(); + $search_results = $search->run($query); + + \View::share("title", "Search results for " . e($query)); + + $rootList = BinshopsCategory::roots()->get(); + BinshopsCategory::loadSiblingsWithList($rootList); + + $language_id = $request->get('language_id'); + + return view("binshopsblog_admin::index", [ + 'search' => true, + 'post_translations'=>$search_results, + 'language_id' => $language_id + ]); + } +} diff --git a/src/Controllers/BinshopsAdminSetupController.php b/src/Controllers/BinshopsAdminSetupController.php new file mode 100644 index 0000000..8612907 --- /dev/null +++ b/src/Controllers/BinshopsAdminSetupController.php @@ -0,0 +1,59 @@ +<?php + +namespace BinshopsBlog\Controllers; + +use App\Http\Controllers\Controller; +use Illuminate\Http\Request; +use BinshopsBlog\Helpers; +use BinshopsBlog\Middleware\UserCanManageBlogPosts; +use BinshopsBlog\Models\BinshopsConfiguration; +use BinshopsBlog\Models\BinshopsLanguage; + +/** + * Class BinshopsAdminSetupController + * Handles initial setup for Binshops Blog + */ +class BinshopsAdminSetupController extends Controller +{ + /** + * BinshopsAdminSetupController constructor. + */ + public function __construct() + { + $this->middleware(UserCanManageBlogPosts::class); + + if (!is_array(config("binshopsblog"))) { + throw new \RuntimeException('The config/binshopsblog.php does not exist. Publish the vendor files for the BinshopsBlog package by running the php artisan publish:vendor command'); + } + } + + /** + * View all posts + * + * @return mixed + */ + public function setup(Request $request) + { + return view("binshopsblog_admin::setup.setup"); + } + + public function setup_submit(Request $request){ + if ($request['locale'] == null){ + return redirect( route('binshopsblog.admin.setup_submit') ); + } + $language = new BinshopsLanguage(); + $language->active = $request['active']; + $language->iso_code = $request['iso_code']; + $language->locale = $request['locale']; + $language->name = $request['name']; + $language->date_format = $request['date_format']; + + $language->save(); + if (!BinshopsConfiguration::get('INITIAL_SETUP')){ + BinshopsConfiguration::set('INITIAL_SETUP', true); + BinshopsConfiguration::set('DEFAULT_LANGUAGE_LOCALE', $request['locale']); + } + + return redirect( route('binshopsblog.admin.index') ); + } +} diff --git a/src/Controllers/BinshopsCategoryAdminController.php b/src/Controllers/BinshopsCategoryAdminController.php new file mode 100755 index 0000000..6fb33c0 --- /dev/null +++ b/src/Controllers/BinshopsCategoryAdminController.php @@ -0,0 +1,210 @@ +<?php + +namespace BinshopsBlog\Controllers; + +use App\Http\Controllers\Controller; +use Illuminate\Http\Request; +use BinshopsBlog\Events\CategoryAdded; +use BinshopsBlog\Events\CategoryEdited; +use BinshopsBlog\Events\CategoryWillBeDeleted; +use BinshopsBlog\Helpers; +use BinshopsBlog\Middleware\LoadLanguage; +use BinshopsBlog\Middleware\UserCanManageBlogPosts; +use BinshopsBlog\Models\BinshopsCategory; +use BinshopsBlog\Models\BinshopsCategoryTranslation; +use BinshopsBlog\Models\BinshopsLanguage; +use BinshopsBlog\Requests\DeleteBinshopsBlogCategoryRequest; +use BinshopsBlog\Requests\StoreBinshopsBlogCategoryRequest; +use BinshopsBlog\Requests\UpdateBinshopsBlogCategoryRequest; + +/** + * Class BinshopsCategoryAdminController + * @package BinshopsBlog\Controllers + */ +class BinshopsCategoryAdminController extends Controller +{ + /** + * BinshopsCategoryAdminController constructor. + */ + public function __construct() + { + $this->middleware(UserCanManageBlogPosts::class); + $this->middleware(LoadLanguage::class); + + } + + /** + * Show list of categories + * + * @return mixed + */ + public function index(Request $request){ + $language_id = $request->get('language_id'); + $categories = BinshopsCategoryTranslation::orderBy("category_id")->where('lang_id', $language_id)->paginate(25); + return view("binshopsblog_admin::categories.index",[ + 'categories' => $categories, + 'language_id' => $language_id + ]); + } + + /** + * Show the form for creating new category + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function create_category(Request $request){ + $language_id = $request->get('language_id'); + $language_list = BinshopsLanguage::where('active',true)->get(); + + $cat_list = BinshopsCategory::whereHas('categoryTranslations', function ($query) use ($language_id) { + return $query->where('lang_id', '=', $language_id); + })->get(); + + $rootList = BinshopsCategory::roots()->get(); + BinshopsCategory::loadSiblingsWithList($rootList); + + + return view("binshopsblog_admin::categories.add_category",[ + 'category' => new \BinshopsBlog\Models\BinshopsCategory(), + 'category_translation' => new \BinshopsBlog\Models\BinshopsCategoryTranslation(), + 'category_tree' => $cat_list, + 'cat_roots' => $rootList, + 'language_id' => $language_id, + 'language_list' => $language_list + ]); + } + + /** + * Store a new category + * + * @param StoreBinshopsBlogCategoryRequest $request + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + * + * This controller is totally REST controller + */ + public function store_category(Request $request){ + $language_id = $request->get('language_id'); + $language_list = $request['data']; + + if ($request['parent_id']== 0){ + $request['parent_id'] = null; + } + $new_category = BinshopsCategory::create([ + 'parent_id' => $request['parent_id'] + ]); + + foreach ($language_list as $key => $value) { + if ($value['lang_id'] != -1 && $value['category_name'] !== null){ + //check for slug availability + $obj = BinshopsCategoryTranslation::where('slug',$value['slug'])->first(); + if ($obj){ + BinshopsCategory::destroy($new_category->id); + return response()->json([ + 'code' => 403, + 'message' => "slug is already taken", + 'data' => $value['lang_id'] + ]); + } + $new_category_translation = $new_category->categoryTranslations()->create([ + 'category_name' => $value['category_name'], + 'slug' => $value['slug'], + 'category_description' => $value['category_description'], + 'lang_id' => $value['lang_id'], + 'category_id' => $new_category->id + ]); + } + } + + event(new CategoryAdded($new_category, $new_category_translation)); + Helpers::flash_message("Saved new category"); + return response()->json([ + 'code' => 200, + 'message' => "category successfully aaded" + ]); + } + + /** + * Show the edit form for category + * @param $categoryId + * @return mixed + */ + public function edit_category($categoryId, Request $request){ + $language_id = $request->get('language_id'); + $language_list = BinshopsLanguage::where('active',true)->get(); + + $category = BinshopsCategory::findOrFail($categoryId); + $cat_trans = BinshopsCategoryTranslation::where( + [ + ['lang_id', '=', $language_id], + ['category_id', '=', $categoryId] + ] + )->first(); + + return view("binshopsblog_admin::categories.edit_category",[ + 'category' => $category, + 'category_translation' => $cat_trans, + 'categories_list' => BinshopsCategoryTranslation::orderBy("category_id")->where('lang_id', $language_id)->get(), + 'language_id' => $language_id, + 'language_list' => $language_list + ]); + } + + /** + * Save submitted changes + * + * @param UpdateBinshopsBlogCategoryRequest $request + * @param $categoryId + * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector + */ + public function update_category(UpdateBinshopsBlogCategoryRequest $request, $categoryId){ + /** @var BinshopsCategory $category */ + $category = BinshopsCategory::findOrFail($categoryId); + $language_id = $request->get('language_id'); + $translation = BinshopsCategoryTranslation::where( + [ + ['lang_id', '=', $language_id], + ['category_id', '=', $categoryId] + ] + )->first(); + $category->fill($request->all()); + $translation->fill($request->all()); + + // if the parent_id is passed in as 0 it will create an error + if ($category->parent_id <= 0) { + $category->parent_id = null; + } + + $category->save(); + $translation->save(); + + Helpers::flash_message("Saved category changes"); + event(new CategoryEdited($category)); + return redirect($translation->edit_url()); + } + + /** + * Delete the category + * + * @param DeleteBinshopsBlogCategoryRequest $request + * @param $categoryId + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + */ + public function destroy_category(DeleteBinshopsBlogCategoryRequest $request, $categoryId){ + + /* Please keep this in, so code inspectiwons don't say $request was unused. Of course it might now get marked as left/right parts are equal */ + $request=$request; + + $category = BinshopsCategory::findOrFail($categoryId); + $children = $category->children()->get(); + if (sizeof($children) > 0) { + Helpers::flash_message("This category could not be deleted it has some sub-categories. First try to change parent category of subs."); + return redirect(route('binshopsblog.admin.categories.index')); + } + + event(new CategoryWillBeDeleted($category)); + $category->delete(); + + Helpers::flash_message("Category successfully deleted!"); + return redirect( route('binshopsblog.admin.categories.index') ); + } + +} diff --git a/src/Controllers/BinshopsCommentWriterController.php b/src/Controllers/BinshopsCommentWriterController.php new file mode 100755 index 0000000..5cf3fad --- /dev/null +++ b/src/Controllers/BinshopsCommentWriterController.php @@ -0,0 +1,100 @@ +<?php + +namespace BinshopsBlog\Controllers; + +use App\Http\Controllers\Controller; +use Auth; +use BinshopsBlog\Captcha\CaptchaAbstract; +use BinshopsBlog\Captcha\UsesCaptcha; +use BinshopsBlog\Events\CommentAdded; +use BinshopsBlog\Middleware\LoadLanguage; +use BinshopsBlog\Middleware\UserCanManageBlogPosts; +use BinshopsBlog\Models\BinshopsComment; +use BinshopsBlog\Models\BinshopsPost; +use BinshopsBlog\Models\BinshopsPostTranslation; +use BinshopsBlog\Requests\AddNewCommentRequest; + +/** + * Class BinshopsCommentWriterController + * @package BinshopsBlog\Controllers + */ +class BinshopsCommentWriterController extends Controller +{ + + use UsesCaptcha; + + public function __construct() + { + $this->middleware(UserCanManageBlogPosts::class); + $this->middleware(LoadLanguage::class); + + } + + /** + * Let a guest (or logged in user) submit a new comment for a blog post + * + * @param AddNewCommentRequest $request + * @param $blog_post_slug + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * @throws \Exception + */ + public function addNewComment(AddNewCommentRequest $request, $locale, $blog_post_slug) + { + + if (config("binshopsblog.comments.type_of_comments_to_show", "built_in") !== 'built_in') { + throw new \RuntimeException("Built in comments are disabled"); + } + + $post_translation = BinshopsPostTranslation::where("slug", $blog_post_slug) + ->with('post') + ->firstOrFail(); + $blog_post = $post_translation->post; + + /** @var CaptchaAbstract $captcha */ + $captcha = $this->getCaptchaObject(); + if ($captcha) { + $captcha->runCaptchaBeforeAddingComment($request, $blog_post); + } + + $new_comment = $this->createNewComment($request, $blog_post); + + return view("binshopsblog::saved_comment", [ + 'captcha' => $captcha, + 'blog_post' => $post_translation, + 'new_comment' => $new_comment + ]); + + } + + /** + * @param AddNewCommentRequest $request + * @param $blog_post + * @return BinshopsComment + */ + protected function createNewComment(AddNewCommentRequest $request, $blog_post) + { + $new_comment = new BinshopsComment($request->all()); + + if (config("binshopsblog.comments.save_ip_address")) { + $new_comment->ip = $request->ip(); + } + if (config("binshopsblog.comments.ask_for_author_website")) { + $new_comment->author_website = $request->get('author_website'); + } + if (config("binshopsblog.comments.ask_for_author_email")) { + $new_comment->author_email = $request->get('author_email'); + } + if (config("binshopsblog.comments.save_user_id_if_logged_in", true) && Auth::check()) { + $new_comment->user_id = Auth::user()->id; + } + + $new_comment->approved = config("binshopsblog.comments.auto_approve_comments", true) ? true : false; + + $blog_post->comments()->save($new_comment); + + event(new CommentAdded($blog_post, $new_comment)); + + return $new_comment; + } + +} diff --git a/src/Controllers/BlogEtcCommentsAdminController.php b/src/Controllers/BinshopsCommentsAdminController.php similarity index 61% rename from src/Controllers/BlogEtcCommentsAdminController.php rename to src/Controllers/BinshopsCommentsAdminController.php index 3557aed..6574900 100755 --- a/src/Controllers/BlogEtcCommentsAdminController.php +++ b/src/Controllers/BinshopsCommentsAdminController.php @@ -1,27 +1,30 @@ <?php -namespace WebDevEtc\BlogEtc\Controllers; +namespace BinshopsBlog\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; -use WebDevEtc\BlogEtc\Events\CommentApproved; -use WebDevEtc\BlogEtc\Events\CommentWillBeDeleted; -use WebDevEtc\BlogEtc\Helpers; -use WebDevEtc\BlogEtc\Middleware\UserCanManageBlogPosts; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; +use BinshopsBlog\Events\CommentApproved; +use BinshopsBlog\Events\CommentWillBeDeleted; +use BinshopsBlog\Helpers; +use BinshopsBlog\Middleware\LoadLanguage; +use BinshopsBlog\Middleware\UserCanManageBlogPosts; +use BinshopsBlog\Models\BinshopsComment; /** - * Class BlogEtcCommentsAdminController - * @package WebDevEtc\BlogEtc\Controllers + * Class BinshopsCommentsAdminController + * @package BinshopsBlog\Controllers */ -class BlogEtcCommentsAdminController extends Controller +class BinshopsCommentsAdminController extends Controller { /** - * BlogEtcCommentsAdminController constructor. + * BinshopsCommentsAdminController constructor. */ public function __construct() { $this->middleware(UserCanManageBlogPosts::class); + $this->middleware(LoadLanguage::class); + } /** @@ -32,7 +35,7 @@ public function __construct() */ public function index(Request $request) { - $comments = BlogEtcComment::withoutGlobalScopes()->orderBy("created_at", "desc") + $comments = BinshopsComment::withoutGlobalScopes()->orderBy("created_at", "desc") ->with("post"); if ($request->get("waiting_for_approval")) { @@ -40,7 +43,7 @@ public function index(Request $request) } $comments = $comments->paginate(100); - return view("blogetc_admin::comments.index") + return view("binshopsblog_admin::comments.index") ->withComments($comments ); } @@ -54,7 +57,7 @@ public function index(Request $request) */ public function approve($blogCommentId) { - $comment = BlogEtcComment::withoutGlobalScopes()->findOrFail($blogCommentId); + $comment = BinshopsComment::withoutGlobalScopes()->findOrFail($blogCommentId); $comment->approved = true; $comment->save(); @@ -73,7 +76,7 @@ public function approve($blogCommentId) */ public function destroy($blogCommentId) { - $comment = BlogEtcComment::withoutGlobalScopes()->findOrFail($blogCommentId); + $comment = BinshopsComment::withoutGlobalScopes()->findOrFail($blogCommentId); event(new CommentWillBeDeleted($comment)); $comment->delete(); diff --git a/src/Controllers/BlogEtcImageUploadController.php b/src/Controllers/BinshopsImageUploadController.php similarity index 59% rename from src/Controllers/BlogEtcImageUploadController.php rename to src/Controllers/BinshopsImageUploadController.php index de80e75..eaa4b2d 100755 --- a/src/Controllers/BlogEtcImageUploadController.php +++ b/src/Controllers/BinshopsImageUploadController.php @@ -1,38 +1,40 @@ <?php -namespace WebDevEtc\BlogEtc\Controllers; +namespace BinshopsBlog\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\Request; -use WebDevEtc\BlogEtc\Middleware\UserCanManageBlogPosts; -use WebDevEtc\BlogEtc\Models\BlogEtcUploadedPhoto; +use BinshopsBlog\Middleware\LoadLanguage; +use BinshopsBlog\Middleware\UserCanManageBlogPosts; +use BinshopsBlog\Models\BinshopsUploadedPhoto; use File; -use WebDevEtc\BlogEtc\Requests\UploadImageRequest; -use WebDevEtc\BlogEtc\Traits\UploadFileTrait; +use BinshopsBlog\Requests\UploadImageRequest; +use BinshopsBlog\Traits\UploadFileTrait; /** - * Class BlogEtcAdminController - * @package WebDevEtc\BlogEtc\Controllers + * Class BinshopsAdminController + * @package BinshopsBlog\Controllers */ -class BlogEtcImageUploadController extends Controller +class BinshopsImageUploadController extends Controller { use UploadFileTrait; /** - * BlogEtcAdminController constructor. + * BinshopsAdminController constructor. */ public function __construct() { $this->middleware(UserCanManageBlogPosts::class); + $this->middleware(LoadLanguage::class); - if (!is_array(config("blogetc"))) { - throw new \RuntimeException('The config/blogetc.php does not exist. Publish the vendor files for the BlogEtc package by running the php artisan publish:vendor command'); + if (!is_array(config("binshopsblog"))) { + throw new \RuntimeException('The config/binshopsblog.php does not exist. Publish the vendor files for the BinshopsBlog package by running the php artisan publish:vendor command'); } - if (!config("blogetc.image_upload_enabled")) { - throw new \RuntimeException("The blogetc.php config option has not enabled image uploading"); + if (!config("binshopsblog.image_upload_enabled")) { + throw new \RuntimeException("The binshopsblog.php config option has not enabled image uploading"); } @@ -46,7 +48,7 @@ public function __construct() public function index() { - return view("blogetc_admin::imageupload.index", ['uploaded_photos' => BlogEtcUploadedPhoto::orderBy("id", "desc")->paginate(10)]); + return view("binshopsblog_admin::imageupload.index", ['uploaded_photos' => BinshopsUploadedPhoto::orderBy("id", "desc")->paginate(10)]); } /** @@ -56,7 +58,7 @@ public function index() */ public function create() { - return view("blogetc_admin::imageupload.create", []); + return view("binshopsblog_admin::imageupload.create", []); } /** @@ -70,7 +72,7 @@ public function store(UploadImageRequest $request) { $processed_images = $this->processUploadedImages($request); - return view("blogetc_admin::imageupload.uploaded", ['images' => $processed_images]); + return view("binshopsblog_admin::imageupload.uploaded", ['images' => $processed_images]); } /** @@ -80,7 +82,7 @@ public function store(UploadImageRequest $request) * * @return array returns an array of details about each file resized. * @throws \Exception - * @todo - This class was added after the other main features, so this duplicates some code from the main blog post admin controller (BlogEtcAdminController). For next full release this should be tided up. + * @todo - This class was added after the other main features, so this duplicates some code from the main blog post admin controller (BinshopsAdminController). For next full release this should be tided up. */ protected function processUploadedImages(UploadImageRequest $request) { @@ -93,13 +95,13 @@ protected function processUploadedImages(UploadImageRequest $request) $sizes_to_upload = $request->get("sizes_to_upload"); // now upload a full size - this is a special case, not in the config file. We only store full size images in this class, not as part of the featured blog image uploads. - if (isset($sizes_to_upload['blogetc_full_size']) && $sizes_to_upload['blogetc_full_size'] === 'true') { + if (isset($sizes_to_upload['binshopsblog_full_size']) && $sizes_to_upload['binshopsblog_full_size'] === 'true') { - $uploaded_image_details['blogetc_full_size'] = $this->UploadAndResize(null, $request->get("image_title"), 'fullsize', $photo); + $uploaded_image_details['binshopsblog_full_size'] = $this->UploadAndResize(null, $request->get("image_title"), 'fullsize', $photo); } - foreach ((array)config('blogetc.image_sizes') as $size => $image_size_details) { + foreach ((array)config('binshopsblog.image_sizes') as $size => $image_size_details) { if (!isset($sizes_to_upload[$size]) || !$sizes_to_upload[$size] || !$image_size_details['enabled']) { continue; @@ -112,7 +114,7 @@ protected function processUploadedImages(UploadImageRequest $request) // store the image upload. - BlogEtcUploadedPhoto::create([ + BinshopsUploadedPhoto::create([ 'image_title' => $request->get("image_title"), 'source' => "ImageUpload", 'uploader_id' => optional(\Auth::user())->id, diff --git a/src/Controllers/BinshopsLanguageAdminController.php b/src/Controllers/BinshopsLanguageAdminController.php new file mode 100644 index 0000000..6f6addc --- /dev/null +++ b/src/Controllers/BinshopsLanguageAdminController.php @@ -0,0 +1,91 @@ +<?php + + +namespace BinshopsBlog\Controllers; + +use App\Http\Controllers\Controller; +use BinshopsBlog\Models\BinshopsConfiguration; +use Illuminate\Http\Request; +use BinshopsBlog\Helpers; +use BinshopsBlog\Middleware\LoadLanguage; +use BinshopsBlog\Middleware\UserCanManageBlogPosts; +use BinshopsBlog\Models\BinshopsLanguage; + +class BinshopsLanguageAdminController extends Controller +{ + /** + * BinshopsLanguageAdminController constructor. + */ + public function __construct() + { + $this->middleware(UserCanManageBlogPosts::class); + $this->middleware(LoadLanguage::class); + + } + + public function index(){ + $language_list = BinshopsLanguage::all(); + return view("binshopsblog_admin::languages.index",[ + 'language_list' => $language_list + ]); + } + + public function create_language(){ + return view("binshopsblog_admin::languages.add_language"); + } + + public function store_language(Request $request){ + if ($request['locale'] == null){ + Helpers::flash_message("Select a language!"); + return view("binshopsblog_admin::languages.add_language"); + } + $language = new BinshopsLanguage(); + $language->active = $request['active']; + $language->iso_code = $request['iso_code']; + $language->locale = $request['locale']; + $language->name = $request['name']; + $language->date_format = $request['date_format']; + $language->rtl = $request['rtl']; + + $language->save(); + + Helpers::flash_message("Language: " . $language->name . " has been added."); + return redirect( route('binshopsblog.admin.languages.index') ); + } + + public function destroy_language(Request $request, $languageId){ + $lang = BinshopsLanguage::where('locale', BinshopsConfiguration::get('DEFAULT_LANGUAGE_LOCALE'))->first(); + if ($languageId == $lang->id){ + Helpers::flash_message("The default language can not be deleted!"); + return redirect( route('binshopsblog.admin.languages.index') ); + } + + try { + $language = BinshopsLanguage::findOrFail($languageId); + //todo +// event(new CategoryWillBeDeleted($category)); + $language->delete(); + Helpers::flash_message("The language is successfully deleted!"); + return redirect( route('binshopsblog.admin.languages.index') ); + } catch (\Illuminate\Database\QueryException $e) { + Helpers::flash_message("You can not delete this language, because it's used in posts or categoies."); + return redirect( route('binshopsblog.admin.languages.index') ); + } + } + + public function toggle_language(Request $request, $languageId){ + $language = BinshopsLanguage::findOrFail($languageId); + if ($language->active == 1){ + $language->active = 0; + }else if ($language->active == 0){ + $language->active = 1; + } + + $language->save(); + //todo + //event + + Helpers::flash_message("Language: " . $language->name . " has been disabled."); + return redirect( route('binshopsblog.admin.languages.index') ); + } +} diff --git a/src/Controllers/BinshopsReaderController.php b/src/Controllers/BinshopsReaderController.php new file mode 100755 index 0000000..3386ca2 --- /dev/null +++ b/src/Controllers/BinshopsReaderController.php @@ -0,0 +1,176 @@ +<?php + +namespace BinshopsBlog\Controllers; + +use App\Http\Controllers\Controller; +use Carbon\Carbon; +use BinshopsBlog\Laravel\Fulltext\Search; +use BinshopsBlog\Models\BinshopsCategoryTranslation; +use Illuminate\Http\Request; +use BinshopsBlog\Captcha\UsesCaptcha; +use BinshopsBlog\Middleware\DetectLanguage; +use BinshopsBlog\Models\BinshopsCategory; +use BinshopsBlog\Models\BinshopsLanguage; +use BinshopsBlog\Models\BinshopsPost; +use BinshopsBlog\Models\BinshopsPostTranslation; + +/** + * Class BinshopsReaderController + * All of the main public facing methods for viewing blog content (index, single posts) + * @package BinshopsBlog\Controllers + */ +class BinshopsReaderController extends Controller +{ + use UsesCaptcha; + + public function __construct() + { + $this->middleware(DetectLanguage::class); + } + + /** + * Show blog posts + * If category_slug is set, then only show from that category + * + * @param null $category_slug + * @return mixed + */ + public function index($locale = null, Request $request, $category_slug = null) + { + // the published_at + is_published are handled by BinshopsBlogPublishedScope, and don't take effect if the logged in user can manageb log posts + + //todo + $title = 'Blog Page'; // default title... + + $categoryChain = null; + $posts = array(); + if ($category_slug) { + $category = BinshopsCategoryTranslation::where("slug", $category_slug)->with('category')->firstOrFail()->category; + $categoryChain = $category->getAncestorsAndSelf(); + $posts = $category->posts()->where("binshops_post_categories.category_id", $category->id)->with([ 'postTranslations' => function($query) use ($request){ + $query->where("lang_id" , '=' , $request->get("lang_id")); + } + ])->get(); + + $posts = BinshopsPostTranslation::join('binshops_posts', 'binshops_post_translations.post_id', '=', 'binshops_posts.id') + ->where('lang_id', $request->get("lang_id")) + ->where("is_published" , '=' , true) + ->where('posted_at', '<', Carbon::now()->format('Y-m-d H:i:s')) + ->orderBy("posted_at", "desc") + ->whereIn('binshops_posts.id', $posts->pluck('id')) + ->paginate(config("binshopsblog.per_page", 10)); + + // at the moment we handle this special case (viewing a category) by hard coding in the following two lines. + // You can easily override this in the view files. + \View::share('binshopsblog_category', $category); // so the view can say "You are viewing $CATEGORYNAME category posts" + $title = 'Posts in ' . $category->category_name . " category"; // hardcode title here... + } else { + $posts = BinshopsPostTranslation::join('binshops_posts', 'binshops_post_translations.post_id', '=', 'binshops_posts.id') + ->where('lang_id', $request->get("lang_id")) + ->where("is_published" , '=' , true) + ->where('posted_at', '<', Carbon::now()->format('Y-m-d H:i:s')) + ->orderBy("posted_at", "desc") + ->paginate(config("binshopsblog.per_page", 10)); + } + + //load category hierarchy + $rootList = BinshopsCategory::roots()->get(); + BinshopsCategory::loadSiblingsWithList($rootList); + + return view("binshopsblog::index", [ + 'lang_list' => BinshopsLanguage::all('locale','name'), + 'locale' => $request->get("locale"), + 'lang_id' => $request->get('lang_id'), + 'category_chain' => $categoryChain, + 'categories' => $rootList, + 'posts' => $posts, + 'title' => $title, + 'routeWithoutLocale' => $request->get("routeWithoutLocale") + ]); + } + + /** + * Show the search results for $_GET['s'] + * + * @param Request $request + * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View + * @throws \Exception + */ + public function search(Request $request) + { + if (!config("binshopsblog.search.search_enabled")) { + throw new \Exception("Search is disabled"); + } + $query = $request->get("s"); + $search = new Search(); + $search_results = $search->run($query); + + \View::share("title", "Search results for " . e($query)); + + $rootList = BinshopsCategory::roots()->get(); + BinshopsCategory::loadSiblingsWithList($rootList); + + return view("binshopsblog::search", [ + 'lang_id' => $request->get('lang_id'), + 'locale' => $request->get("locale"), + 'categories' => $rootList, + 'query' => $query, + 'search_results' => $search_results, + 'routeWithoutLocale' => $request->get("routeWithoutLocale") + ] + ); + } + + /** + * View all posts in $category_slug category + * + * @param Request $request + * @param $category_slug + * @return mixed + */ + public function view_category(Request $request) + { + $hierarchy = $request->route('subcategories'); + + $categories = explode('/', $hierarchy); + return $this->index($request->get('locale'), $request, end($categories)); + } + + /** + * View a single post and (if enabled) it's comments + * + * @param Request $request + * @param $blogPostSlug + * @return mixed + */ + public function viewSinglePost(Request $request) + { + $blogPostSlug = $request->route('blogPostSlug'); + + // the published_at + is_published are handled by BinshopsBlogPublishedScope, and don't take effect if the logged in user can manage log posts + $blog_post = BinshopsPostTranslation::where([ + ["slug", "=", $blogPostSlug], + ['lang_id', "=" , $request->get("lang_id")] + ])->firstOrFail(); + + if ($captcha = $this->getCaptchaObject()) { + $captcha->runCaptchaBeforeShowingPosts($request, $blog_post); + } + + $categories = $blog_post->post->categories()->with([ 'categoryTranslations' => function($query) use ($request){ + $query->where("lang_id" , '=' , $request->get("lang_id")); + } + ])->get(); + return view("binshopsblog::single_post", [ + 'post' => $blog_post, + // the default scope only selects approved comments, ordered by id + 'comments' => $blog_post->post->comments() + ->with("user") + ->get(), + 'captcha' => $captcha, + 'categories' => $categories, + 'locale' => $request->get("locale"), + 'routeWithoutLocale' => $request->get("routeWithoutLocale") + ]); + } +} diff --git a/src/Controllers/BlogEtcAdminController.php b/src/Controllers/BlogEtcAdminController.php deleted file mode 100755 index 9f93a30..0000000 --- a/src/Controllers/BlogEtcAdminController.php +++ /dev/null @@ -1,230 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Controllers; - -use App\Http\Controllers\Controller; -use Carbon\Carbon; -use Illuminate\Http\Request; -use WebDevEtc\BlogEtc\Interfaces\BaseRequestInterface; -use WebDevEtc\BlogEtc\Events\BlogPostAdded; -use WebDevEtc\BlogEtc\Events\BlogPostEdited; -use WebDevEtc\BlogEtc\Events\BlogPostWillBeDeleted; -use WebDevEtc\BlogEtc\Helpers; -use WebDevEtc\BlogEtc\Middleware\UserCanManageBlogPosts; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; -use WebDevEtc\BlogEtc\Models\BlogEtcUploadedPhoto; -use WebDevEtc\BlogEtc\Requests\CreateBlogEtcPostRequest; -use WebDevEtc\BlogEtc\Requests\DeleteBlogEtcPostRequest; -use WebDevEtc\BlogEtc\Requests\UpdateBlogEtcPostRequest; -use WebDevEtc\BlogEtc\Traits\UploadFileTrait; - -/** - * Class BlogEtcAdminController - * @package WebDevEtc\BlogEtc\Controllers - */ -class BlogEtcAdminController extends Controller -{ - use UploadFileTrait; - - /** - * BlogEtcAdminController constructor. - */ - public function __construct() - { - $this->middleware(UserCanManageBlogPosts::class); - - if (!is_array(config("blogetc"))) { - throw new \RuntimeException('The config/blogetc.php does not exist. Publish the vendor files for the BlogEtc package by running the php artisan publish:vendor command'); - } - } - - - /** - * View all posts - * - * @return mixed - */ - public function index() - { - $posts = BlogEtcPost::orderBy("posted_at", "desc") - ->paginate(10); - - return view("blogetc_admin::index", ['posts'=>$posts]); - } - - /** - * Show form for creating new post - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ - public function create_post() - { - return view("blogetc_admin::posts.add_post"); - } - - /** - * Save a new post - * - * @param CreateBlogEtcPostRequest $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector - * @throws \Exception - */ - public function store_post(CreateBlogEtcPostRequest $request) - { - $new_blog_post = new BlogEtcPost($request->all()); - - $this->processUploadedImages($request, $new_blog_post); - - if (!$new_blog_post->posted_at) { - $new_blog_post->posted_at = Carbon::now(); - } - - $new_blog_post->user_id = \Auth::user()->id; - $new_blog_post->save(); - - $new_blog_post->categories()->sync($request->categories()); - - Helpers::flash_message("Added post"); - event(new BlogPostAdded($new_blog_post)); - return redirect($new_blog_post->edit_url()); - } - - /** - * Show form to edit post - * - * @param $blogPostId - * @return mixed - */ - public function edit_post( $blogPostId) - { - $post = BlogEtcPost::findOrFail($blogPostId); - return view("blogetc_admin::posts.edit_post")->withPost($post); - } - - /** - * Save changes to a post - * - * @param UpdateBlogEtcPostRequest $request - * @param $blogPostId - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector - * @throws \Exception - */ - public function update_post(UpdateBlogEtcPostRequest $request, $blogPostId) - { - /** @var BlogEtcPost $post */ - $post = BlogEtcPost::findOrFail($blogPostId); - $post->fill($request->all()); - - $this->processUploadedImages($request, $post); - - $post->save(); - $post->categories()->sync($request->categories()); - - Helpers::flash_message("Updated post"); - event(new BlogPostEdited($post)); - - return redirect($post->edit_url()); - - } - - public function remove_photo($postSlug) - { - $post = BlogEtcPost::where("slug", $postSlug)->firstOrFail(); - - $path = public_path('/' . config("blogetc.blog_upload_dir")); - if (!$this->checked_blog_image_dir_is_writable) { - if (!is_writable($path)) { - throw new \RuntimeException("Image destination path is not writable ($path)"); - } - } - - $destinationPath = $this->image_destination_path(); - - if (file_exists($destinationPath.'/'.$post->image_large)) { - unlink($destinationPath.'/'.$post->image_large); - } - - if (file_exists($destinationPath.'/'.$post->image_medium)) { - unlink($destinationPath.'/'.$post->image_medium); - } - - if (file_exists($destinationPath.'/'.$post->image_thumbnail)) { - unlink($destinationPath.'/'.$post->image_thumbnail); - } - - $post->image_large = null; - $post->image_medium = null; - $post->image_thumbnail = null; - $post->save(); - - Helpers::flash_message("Photo removed"); - - return redirect($post->edit_url()); - } - - /** - * Delete a post - * - * @param DeleteBlogEtcPostRequest $request - * @param $blogPostId - * @return mixed - */ - public function destroy_post(DeleteBlogEtcPostRequest $request, $blogPostId) - { - - $post = BlogEtcPost::findOrFail($blogPostId); - event(new BlogPostWillBeDeleted($post)); - - $post->delete(); - - // todo - delete the featured images? - // At the moment it just issues a warning saying the images are still on the server. - - return view("blogetc_admin::posts.deleted_post") - ->withDeletedPost($post); - - } - - /** - * Process any uploaded images (for featured image) - * - * @param BaseRequestInterface $request - * @param $new_blog_post - * @throws \Exception - * @todo - next full release, tidy this up! - */ - protected function processUploadedImages(BaseRequestInterface $request, BlogEtcPost $new_blog_post) - { - if (!config("blogetc.image_upload_enabled")) { - // image upload was disabled - return; - } - - $this->increaseMemoryLimit(); - - // to save in db later - $uploaded_image_details = []; - - - foreach ((array)config('blogetc.image_sizes') as $size => $image_size_details) { - - if ($image_size_details['enabled'] && $photo = $request->get_image_file($size)) { - // this image size is enabled, and - // we have an uploaded image that we can use - - $uploaded_image = $this->UploadAndResize($new_blog_post, $new_blog_post->slug, $image_size_details, $photo); - - $new_blog_post->$size = $uploaded_image['filename']; - $uploaded_image_details[$size] = $uploaded_image; - } - } - - // store the image upload. - // todo: link this to the blogetc_post row. - if (count(array_filter($uploaded_image_details))>0) { - BlogEtcUploadedPhoto::create([ - 'source' => "BlogFeaturedImage", - 'uploaded_images' => $uploaded_image_details, - ]); - } - } -} diff --git a/src/Controllers/BlogEtcCategoryAdminController.php b/src/Controllers/BlogEtcCategoryAdminController.php deleted file mode 100755 index 827222c..0000000 --- a/src/Controllers/BlogEtcCategoryAdminController.php +++ /dev/null @@ -1,122 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Controllers; - -use App\Http\Controllers\Controller; -use WebDevEtc\BlogEtc\Events\CategoryAdded; -use WebDevEtc\BlogEtc\Events\CategoryEdited; -use WebDevEtc\BlogEtc\Events\CategoryWillBeDeleted; -use WebDevEtc\BlogEtc\Helpers; -use WebDevEtc\BlogEtc\Middleware\UserCanManageBlogPosts; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; -use WebDevEtc\BlogEtc\Requests\DeleteBlogEtcCategoryRequest; -use WebDevEtc\BlogEtc\Requests\StoreBlogEtcCategoryRequest; -use WebDevEtc\BlogEtc\Requests\UpdateBlogEtcCategoryRequest; - -/** - * Class BlogEtcCategoryAdminController - * @package WebDevEtc\BlogEtc\Controllers - */ -class BlogEtcCategoryAdminController extends Controller -{ - /** - * BlogEtcCategoryAdminController constructor. - */ - public function __construct() - { - $this->middleware(UserCanManageBlogPosts::class); - } - - /** - * Show list of categories - * - * @return mixed - */ - public function index(){ - - $categories = BlogEtcCategory::orderBy("category_name")->paginate(25); - return view("blogetc_admin::categories.index")->withCategories($categories); - } - - /** - * Show the form for creating new category - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ - public function create_category(){ - - return view("blogetc_admin::categories.add_category",[ - 'category' => new \WebDevEtc\BlogEtc\Models\BlogEtcCategory(), - 'categories_list' => BlogEtcCategory::orderBy("category_name")->get() - ]); - - } - - /** - * Store a new category - * - * @param StoreBlogEtcCategoryRequest $request - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector - */ - public function store_category(StoreBlogEtcCategoryRequest $request){ - if ($request['parent_id']== 0){ - $request['parent_id'] = null; - } - $new_category = BlogEtcCategory::create($request->all()); - - Helpers::flash_message("Saved new category"); - - event(new CategoryAdded($new_category)); - return redirect( route('blogetc.admin.categories.index') ); - } - - /** - * Show the edit form for category - * @param $categoryId - * @return mixed - */ - public function edit_category($categoryId){ - $category = BlogEtcCategory::findOrFail($categoryId); - return view("blogetc_admin::categories.edit_category",[ - 'categories_list' => BlogEtcCategory::orderBy("category_name")->get() - ])->withCategory($category); - } - - /** - * Save submitted changes - * - * @param UpdateBlogEtcCategoryRequest $request - * @param $categoryId - * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector - */ - public function update_category(UpdateBlogEtcCategoryRequest $request, $categoryId){ - /** @var BlogEtcCategory $category */ - $category = BlogEtcCategory::findOrFail($categoryId); - $category->fill($request->all()); - $category->save(); - - Helpers::flash_message("Saved category changes"); - event(new CategoryEdited($category)); - return redirect($category->edit_url()); - } - - /** - * Delete the category - * - * @param DeleteBlogEtcCategoryRequest $request - * @param $categoryId - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - */ - public function destroy_category(DeleteBlogEtcCategoryRequest $request, $categoryId){ - - /* Please keep this in, so code inspections don't say $request was unused. Of course it might now get marked as left/right parts are equal */ - $request=$request; - - $category = BlogEtcCategory::findOrFail($categoryId); - event(new CategoryWillBeDeleted($category)); - $category->delete(); - - return view ("blogetc_admin::categories.deleted_category"); - - } - -} diff --git a/src/Controllers/BlogEtcCommentWriterController.php b/src/Controllers/BlogEtcCommentWriterController.php deleted file mode 100755 index d033439..0000000 --- a/src/Controllers/BlogEtcCommentWriterController.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Controllers; - -use App\Http\Controllers\Controller; -use Auth; -use WebDevEtc\BlogEtc\Captcha\CaptchaAbstract; -use WebDevEtc\BlogEtc\Captcha\UsesCaptcha; -use WebDevEtc\BlogEtc\Events\CommentAdded; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; -use WebDevEtc\BlogEtc\Requests\AddNewCommentRequest; - -/** - * Class BlogEtcCommentWriterController - * @package WebDevEtc\BlogEtc\Controllers - */ -class BlogEtcCommentWriterController extends Controller -{ - - use UsesCaptcha; - - /** - * Let a guest (or logged in user) submit a new comment for a blog post - * - * @param AddNewCommentRequest $request - * @param $blog_post_slug - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - * @throws \Exception - */ - public function addNewComment(AddNewCommentRequest $request, $blog_post_slug) - { - - if (config("blogetc.comments.type_of_comments_to_show", "built_in") !== 'built_in') { - throw new \RuntimeException("Built in comments are disabled"); - } - - $blog_post = BlogEtcPost::where("slug", $blog_post_slug) - ->firstOrFail(); - - /** @var CaptchaAbstract $captcha */ - $captcha = $this->getCaptchaObject(); - if ($captcha) { - $captcha->runCaptchaBeforeAddingComment($request, $blog_post); - } - - $new_comment = $this->createNewComment($request, $blog_post); - - return view("blogetc::saved_comment", [ - 'captcha' => $captcha, - 'blog_post' => $blog_post, - 'new_comment' => $new_comment - ]); - - } - - /** - * @param AddNewCommentRequest $request - * @param $blog_post - * @return BlogEtcComment - */ - protected function createNewComment(AddNewCommentRequest $request, $blog_post) - { - $new_comment = new BlogEtcComment($request->all()); - - if (config("blogetc.comments.save_ip_address")) { - $new_comment->ip = $request->ip(); - } - if (config("blogetc.comments.ask_for_author_website")) { - $new_comment->author_website = $request->get('author_website'); - } - if (config("blogetc.comments.ask_for_author_website")) { - $new_comment->author_email = $request->get('author_email'); - } - if (config("blogetc.comments.save_user_id_if_logged_in", true) && Auth::check()) { - $new_comment->user_id = Auth::user()->id; - } - - $new_comment->approved = config("blogetc.comments.auto_approve_comments", true) ? true : false; - - $blog_post->comments()->save($new_comment); - - event(new CommentAdded($blog_post, $new_comment)); - - return $new_comment; - } - -} diff --git a/src/Controllers/BlogEtcReaderController.php b/src/Controllers/BlogEtcReaderController.php deleted file mode 100755 index 242a437..0000000 --- a/src/Controllers/BlogEtcReaderController.php +++ /dev/null @@ -1,135 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Controllers; - -use App\Http\Controllers\Controller; -use Carbon\Carbon; -use Illuminate\Http\Request; -use Swis\Laravel\Fulltext\Search; -use WebDevEtc\BlogEtc\Captcha\UsesCaptcha; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; - -/** - * Class BlogEtcReaderController - * All of the main public facing methods for viewing blog content (index, single posts) - * @package WebDevEtc\BlogEtc\Controllers - */ -class BlogEtcReaderController extends Controller -{ - use UsesCaptcha; - - /** - * Show blog posts - * If category_slug is set, then only show from that category - * - * @param null $category_slug - * @return mixed - */ - public function index($category_slug = null) - { - // the published_at + is_published are handled by BlogEtcPublishedScope, and don't take effect if the logged in user can manageb log posts - $title = 'Blog Page'; // default title... - - $categoryChain = null; - if ($category_slug) { - $category = BlogEtcCategory::where("slug", $category_slug)->firstOrFail(); - $categoryChain = $category->getAncestorsAndSelf(); - $posts = $category->posts()->where("blog_etc_post_categories.blog_etc_category_id", $category->id); - - // at the moment we handle this special case (viewing a category) by hard coding in the following two lines. - // You can easily override this in the view files. - \View::share('blogetc_category', $category); // so the view can say "You are viewing $CATEGORYNAME category posts" - $title = 'Posts in ' . $category->category_name . " category"; // hardcode title here... - } else { - $posts = BlogEtcPost::query(); - } - - $posts = $posts->where('is_published', '=', 1)->where('posted_at', '<', Carbon::now()->format('Y-m-d H:i:s'))->orderBy("posted_at", "desc")->paginate(config("blogetc.per_page", 10)); - - //load categories in 3 levels - $rootList = BlogEtcCategory::where('parent_id' ,'=' , null)->get(); - for($i = 0 ; sizeof($rootList) > $i ; $i++){ - $rootList[$i]->loadSiblings(); - for ($j = 0 ; sizeof($rootList[$i]->siblings) > $j; $j++){ - $rootList[$i]->siblings[$j]->loadSiblings(); - } - } - - return view("blogetc::index", [ - 'category_chain' => $categoryChain, - 'categories' => $rootList, - 'posts' => $posts, - 'title' => $title, - ]); - } - - /** - * Show the search results for $_GET['s'] - * - * @param Request $request - * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View - * @throws \Exception - */ - public function search(Request $request) - { - if (!config("blogetc.search.search_enabled")) { - throw new \Exception("Search is disabled"); - } - $query = $request->get("s"); - $search = new Search(); - $search_results = $search->run($query); - - \View::share("title", "Search results for " . e($query)); - - $categories = BlogEtcCategory::all(); - - return view("blogetc::search", [ - 'categories' => $categories, - 'query' => $query, - 'search_results' => $search_results] - ); - - } - - /** - * View all posts in $category_slug category - * - * @param Request $request - * @param $category_slug - * @return mixed - */ - public function view_category($hierarchy) - { - $categories = explode('/', $hierarchy); - return $this->index(end($categories)); - } - - /** - * View a single post and (if enabled) it's comments - * - * @param Request $request - * @param $blogPostSlug - * @return mixed - */ - public function viewSinglePost(Request $request, $blogPostSlug) - { - // the published_at + is_published are handled by BlogEtcPublishedScope, and don't take effect if the logged in user can manage log posts - $blog_post = BlogEtcPost::where("slug", $blogPostSlug) - ->firstOrFail(); - - if ($captcha = $this->getCaptchaObject()) { - $captcha->runCaptchaBeforeShowingPosts($request, $blog_post); - } - - return view("blogetc::single_post", [ - 'post' => $blog_post, - // the default scope only selects approved comments, ordered by id - 'comments' => $blog_post->comments() - ->with("user") - ->get(), - 'captcha' => $captcha, - ]); - } - -} diff --git a/src/Controllers/BlogEtcRssFeedController.php b/src/Controllers/BlogEtcRssFeedController.php deleted file mode 100755 index 2b0ada9..0000000 --- a/src/Controllers/BlogEtcRssFeedController.php +++ /dev/null @@ -1,88 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Controllers; - -use App\Http\Controllers\Controller; -use Carbon\Carbon; -use Laravelium\Feed\Feed; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; -use WebDevEtc\BlogEtc\Requests\FeedRequest; - -/** - * Class BlogEtcRssFeedController.php - * All RSS feed viewing methods - * @package WebDevEtc\BlogEtc\Controllers - */ -class BlogEtcRssFeedController extends Controller -{ - /** - * @param Feed $feed - * @param $posts - * @return mixed - */ - protected function setupFeed(Feed $feed, $posts) - { - $feed->title = config("app.name") . ' Blog'; - $feed->description = config("blogetc.rssfeed.description", "Our blog RSS feed"); - $feed->link = route('blogetc.index'); - $feed->setDateFormat('carbon'); - $feed->pubdate = isset($posts[0]) ? $posts[0]->posted_at : Carbon::now()->subYear(10); - $feed->lang = config("blogetc.rssfeed.language", "en"); - $feed->setShortening(config("blogetc.rssfeed.should_shorten_text", true)); // true or false - $feed->setTextLimit(config("blogetc.rssfeed.text_limit", 100)); - } - - - /** - * @param $feed - */ - protected function makeFreshFeed(Feed $feed) - { - $posts = BlogEtcPost::orderBy("posted_at", "desc") - ->limit(config("blogetc.rssfeed.posts_to_show_in_rss_feed", 10)) - ->with("author") - ->get(); - - $this->setupFeed($feed, $posts); - - /** @var BlogEtcPost $post */ - foreach ($posts as $post) { - $feed->add($post->title, - $post->author_string(), - $post->url(), - $post->posted_at, - $post->short_description, - $post->generate_introduction() - ); - } - } - - /** - * RSS Feed - * This is a long (but quite simple) method to show an RSS feed - * It makes use of Laravelium\Feed\Feed. - * - * @param FeedRequest $request - * @param Feed $feed - * @return mixed - */ - public function feed(FeedRequest $request, Feed $feed) - { - - // if a logged in user views the RSS feed it will get cached, and if they are an admin user then it'll show all posts (even if it is not set as published) - $user_or_guest = \Auth::check() ? \Auth::user()->id : 'guest'; - - $feed->setCache( - config("blogetc.rssfeed.cache_in_minutes", 60), - "blogetc-" . $request->getFeedType() . $user_or_guest - ); - - if (!$feed->isCached()) { - $this->makeFreshFeed($feed); - } - - return $feed->render($request->getFeedType()); - } - - -} diff --git a/src/Events/BlogPostAdded.php b/src/Events/BlogPostAdded.php index d0bfb21..4aef3b5 100644 --- a/src/Events/BlogPostAdded.php +++ b/src/Events/BlogPostAdded.php @@ -1,30 +1,30 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use BinshopsBlog\Models\BinshopsPost; /** * Class BlogPostAdded - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class BlogPostAdded { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost */ - public $blogEtcPost; + /** @var BinshopsPost */ + public $binshopsBlogPost; /** * BlogPostAdded constructor. - * @param BlogEtcPost $blogEtcPost + * @param BinshopsPost $binshopsBlogPost */ - public function __construct(BlogEtcPost $blogEtcPost) + public function __construct(BinshopsPost $binshopsBlogPost) { - $this->blogEtcPost=$blogEtcPost; + $this->binshopsBlogPost=$binshopsBlogPost; } } diff --git a/src/Events/BlogPostEdited.php b/src/Events/BlogPostEdited.php index 3bade22..94d4b13 100644 --- a/src/Events/BlogPostEdited.php +++ b/src/Events/BlogPostEdited.php @@ -1,30 +1,30 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use BinshopsBlog\Models\BinshopsPost; /** * Class BlogPostEdited - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class BlogPostEdited { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost */ - public $blogEtcPost; + /** @var BinshopsPost */ + public $binshopsBlogPost; /** * BlogPostEdited constructor. - * @param BlogEtcPost $blogEtcPost + * @param BinshopsPost $binshopsBlogPost */ - public function __construct(BlogEtcPost $blogEtcPost) + public function __construct(BinshopsPost $binshopsBlogPost) { - $this->blogEtcPost=$blogEtcPost; + $this->binshopsBlogPost=$binshopsBlogPost; } } diff --git a/src/Events/BlogPostWillBeDeleted.php b/src/Events/BlogPostWillBeDeleted.php index 3e1f332..07c473e 100644 --- a/src/Events/BlogPostWillBeDeleted.php +++ b/src/Events/BlogPostWillBeDeleted.php @@ -1,30 +1,30 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use BinshopsBlog\Models\BinshopsPost; /** * Class BlogPostWillBeDeleted - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class BlogPostWillBeDeleted { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost */ - public $blogEtcPost; + /** @var BinshopsPost */ + public $binshopsBlogPost; /** * BlogPostWillBeDeleted constructor. - * @param BlogEtcPost $blogEtcPost + * @param BinshopsPost $binshopsBlogPost */ - public function __construct(BlogEtcPost $blogEtcPost) + public function __construct(BinshopsPost $binshopsBlogPost) { - $this->blogEtcPost=$blogEtcPost; + $this->binshopsBlogPost=$binshopsBlogPost; } } diff --git a/src/Events/CategoryAdded.php b/src/Events/CategoryAdded.php index 825339e..a090f31 100644 --- a/src/Events/CategoryAdded.php +++ b/src/Events/CategoryAdded.php @@ -1,30 +1,33 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use BinshopsBlog\Models\BinshopsCategory; +use BinshopsBlog\Models\BinshopsCategoryTranslation; /** * Class CategoryAdded - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class CategoryAdded { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcCategory */ - public $blogEtcCategory; + /** @var BinshopsCategory */ + public $binshopsCategory; + public $binshopsCategoryTranslation; /** * CategoryAdded constructor. - * @param BlogEtcCategory $blogEtcCategory + * @param BinshopsCategory $binshopsCategory */ - public function __construct(BlogEtcCategory $blogEtcCategory) + public function __construct(BinshopsCategory $binshopsCategory, BinshopsCategoryTranslation $binshopsCategoryTranslation) { - $this->blogEtcCategory=$blogEtcCategory; + $this->binshopsCategory=$binshopsCategory; + $this->binshopsCategoryTranslation = $binshopsCategoryTranslation; } } diff --git a/src/Events/CategoryEdited.php b/src/Events/CategoryEdited.php index 9fe3ef6..f8cbf19 100644 --- a/src/Events/CategoryEdited.php +++ b/src/Events/CategoryEdited.php @@ -1,30 +1,30 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use BinshopsBlog\Models\BinshopsCategory; /** * Class CategoryEdited - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class CategoryEdited { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcCategory */ - public $blogEtcCategory; + /** @var BinshopsCategory */ + public $binshopsBlogCategory; /** * CategoryEdited constructor. - * @param BlogEtcCategory $blogEtcCategory + * @param BinshopsCategory $binshopsBlogCategory */ - public function __construct(BlogEtcCategory $blogEtcCategory) + public function __construct(BinshopsCategory $binshopsBlogCategory) { - $this->blogEtcCategory=$blogEtcCategory; + $this->binshopsBlogCategory=$binshopsBlogCategory; } } diff --git a/src/Events/CategoryWillBeDeleted.php b/src/Events/CategoryWillBeDeleted.php index 980d233..f831fa7 100644 --- a/src/Events/CategoryWillBeDeleted.php +++ b/src/Events/CategoryWillBeDeleted.php @@ -1,30 +1,30 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use BinshopsBlog\Models\BinshopsCategory; /** * Class CategoryWillBeDeleted - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class CategoryWillBeDeleted { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcCategory */ - public $blogEtcCategory; + /** @var BinshopsCategory */ + public $binshopsBlogCategory; /** * CategoryWillBeDeleted constructor. - * @param BlogEtcCategory $blogEtcCategory + * @param BinshopsCategory $binshopsBlogCategory */ - public function __construct(BlogEtcCategory $blogEtcCategory) + public function __construct(BinshopsCategory $binshopsBlogCategory) { - $this->blogEtcCategory=$blogEtcCategory; + $this->binshopsBlogCategory=$binshopsBlogCategory; } } diff --git a/src/Events/CommentAdded.php b/src/Events/CommentAdded.php index dcb383c..e0332f3 100644 --- a/src/Events/CommentAdded.php +++ b/src/Events/CommentAdded.php @@ -1,34 +1,34 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use BinshopsBlog\Models\BinshopsComment; +use BinshopsBlog\Models\BinshopsPost; /** * Class CommentAdded - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class CommentAdded { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost */ - public $blogEtcPost; - /** @var BlogEtcComment */ + /** @var BinshopsPost */ + public $binshopsBlogPost; + /** @var BinshopsComment */ public $newComment; /** * CommentAdded constructor. - * @param BlogEtcPost $blogEtcPost - * @param BlogEtcComment $newComment + * @param BinshopsPost $binshopsBlogPost + * @param BinshopsComment $newComment */ - public function __construct(BlogEtcPost $blogEtcPost, BlogEtcComment $newComment) + public function __construct(BinshopsPost $binshopsBlogPost, BinshopsComment $newComment) { - $this->blogEtcPost=$blogEtcPost; + $this->binshopsBlogPost=$binshopsBlogPost; $this->newComment=$newComment; } diff --git a/src/Events/CommentApproved.php b/src/Events/CommentApproved.php index 43c9351..8c4555e 100644 --- a/src/Events/CommentApproved.php +++ b/src/Events/CommentApproved.php @@ -1,28 +1,28 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; +use BinshopsBlog\Models\BinshopsComment; /** * Class CommentApproved - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class CommentApproved { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcComment */ + /** @var BinshopsComment */ public $comment; /** * CommentApproved constructor. - * @param BlogEtcComment $comment + * @param BinshopsComment $comment */ - public function __construct(BlogEtcComment $comment) + public function __construct(BinshopsComment $comment) { $this->comment=$comment; // you can get the blog post via $comment->post diff --git a/src/Events/CommentWillBeDeleted.php b/src/Events/CommentWillBeDeleted.php index 7947eb5..25ba513 100644 --- a/src/Events/CommentWillBeDeleted.php +++ b/src/Events/CommentWillBeDeleted.php @@ -1,28 +1,28 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcComment; +use BinshopsBlog\Models\BinshopsComment; /** * Class CommentWillBeDeleted - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class CommentWillBeDeleted { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcComment */ + /** @var BinshopsComment */ public $comment; /** * CommentWillBeDeleted constructor. - * @param BlogEtcComment $comment + * @param BinshopsComment $comment */ - public function __construct(BlogEtcComment $comment) + public function __construct(BinshopsComment $comment) { $this->comment=$comment; } diff --git a/src/Events/UploadedImage.php b/src/Events/UploadedImage.php index 1feb61d..cb3ac03 100644 --- a/src/Events/UploadedImage.php +++ b/src/Events/UploadedImage.php @@ -1,22 +1,23 @@ <?php -namespace WebDevEtc\BlogEtc\Events; +namespace BinshopsBlog\Events; use Illuminate\Queue\SerializesModels; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Broadcasting\InteractsWithSockets; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use BinshopsBlog\Models\BinshopsPost; +use BinshopsBlog\Models\BinshopsPostTranslation; /** * Class UploadedImage - * @package WebDevEtc\BlogEtc\Events + * @package BinshopsBlog\Events */ class UploadedImage { use Dispatchable, InteractsWithSockets, SerializesModels; - /** @var BlogEtcPost|null */ - public $blogEtcPost; + /** @var BinshopsPost|null */ + public $binshopsBlogPost; /** * @var */ @@ -29,14 +30,14 @@ class UploadedImage * UploadedImage constructor. * * @param $image_filename - the new filename - * @param BlogEtcPost $blogEtcPost + * @param BinshopsPost $binshopsBlogPost * @param $image * @param $source string|null the __METHOD__ firing this event (or other string) */ - public function __construct(string $image_filename, $image,BlogEtcPost $blogEtcPost=null,string $source='other') + public function __construct(string $image_filename, $image, BinshopsPostTranslation $binshopsBlogPost=null, string $source='other') { $this->image_filename = $image_filename; - $this->blogEtcPost=$blogEtcPost; + $this->binshopsBlogPost=$binshopsBlogPost; $this->image=$image; $this->source=$source; } diff --git a/src/FulltextSearch/src/Commands/Index.php b/src/FulltextSearch/src/Commands/Index.php new file mode 100644 index 0000000..def85d8 --- /dev/null +++ b/src/FulltextSearch/src/Commands/Index.php @@ -0,0 +1,29 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext\Commands; + +use Illuminate\Console\Command; +use BinshopsBlog\Laravel\Fulltext\Indexer; + +class Index extends Command +{ + protected $signature = 'laravel-fulltext:all {model_class}'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Build the searchindex'; + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $indexer = new Indexer(); + $indexer->indexAllByClass($this->argument('model_class')); + } +} diff --git a/src/FulltextSearch/src/Commands/IndexOne.php b/src/FulltextSearch/src/Commands/IndexOne.php new file mode 100644 index 0000000..564bbe6 --- /dev/null +++ b/src/FulltextSearch/src/Commands/IndexOne.php @@ -0,0 +1,29 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext\Commands; + +use Illuminate\Console\Command; +use BinshopsBlog\Laravel\Fulltext\Indexer; + +class IndexOne extends Command +{ + protected $signature = 'laravel-fulltext:one {model_class} {id}'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Update the searchindex for a single record'; + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $indexer = new Indexer(); + $indexer->indexOneByClass($this->argument('model_class'), $this->argument('id')); + } +} diff --git a/src/FulltextSearch/src/Commands/UnindexOne.php b/src/FulltextSearch/src/Commands/UnindexOne.php new file mode 100644 index 0000000..a8b69fe --- /dev/null +++ b/src/FulltextSearch/src/Commands/UnindexOne.php @@ -0,0 +1,29 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext\Commands; + +use Illuminate\Console\Command; +use BinshopsBlog\Laravel\Fulltext\Indexer; + +class UnindexOne extends Command +{ + protected $signature = 'laravel-fulltext:unindex {model_class} {id}'; + + /** + * The console command description. + * + * @var string + */ + protected $description = 'Remove a single record from the searchindex'; + + /** + * Execute the console command. + * + * @return mixed + */ + public function handle() + { + $indexer = new Indexer(); + $indexer->unIndexOneByClass($this->argument('model_class'), $this->argument('id')); + } +} diff --git a/src/FulltextSearch/src/Indexable.php b/src/FulltextSearch/src/Indexable.php new file mode 100644 index 0000000..438a451 --- /dev/null +++ b/src/FulltextSearch/src/Indexable.php @@ -0,0 +1,95 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext; + +use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasOne; + +/** + * @property \BinshopsBlog\Laravel\Fulltext\IndexedRecord|null $indexedRecord + */ +trait Indexable +{ + /** + * Boot the trait. + */ + public static function bootIndexable() + { + static::observe(new ModelObserver()); + } + + public function getIndexContent() + { + return $this->getIndexDataFromColumns($this->indexContentColumns); + } + + public function getIndexTitle() + { + return $this->getIndexDataFromColumns($this->indexTitleColumns); + } + + public function indexedRecord() + { + return $this->morphOne(IndexedRecord::class, 'indexable'); + } + + public function indexRecord() + { + if (null === $this->indexedRecord) { + $this->indexedRecord = new IndexedRecord(); + $this->indexedRecord->indexable()->associate($this); + } + $this->indexedRecord->updateIndex(); + } + + public function unIndexRecord() + { + if (null !== $this->indexedRecord) { + $this->indexedRecord->delete(); + } + } + + protected function getIndexDataFromColumns($columns) + { + $indexData = []; + foreach ($columns as $column) { + if ($this->indexDataIsRelation($column)) { + $indexData[] = $this->getIndexValueFromRelation($column); + } else { + $indexData[] = trim($this->{$column}); + } + } + + return implode(' ', array_filter($indexData)); + } + + /** + * @param $column + * + * @return bool + */ + protected function indexDataIsRelation($column) + { + return (int) strpos($column, '.') > 0; + } + + /** + * @param $column + * + * @return string + */ + protected function getIndexValueFromRelation($column) + { + list($relation, $column) = explode('.', $column); + if (is_null($this->{$relation})) { + return ''; + } + + $relationship = $this->{$relation}(); + if ($relationship instanceof BelongsTo || $relationship instanceof HasOne) { + return $this->{$relation}->{$column}; + } + + return $this->{$relation}->pluck($column)->implode(', '); + } +} diff --git a/src/FulltextSearch/src/IndexedRecord.php b/src/FulltextSearch/src/IndexedRecord.php new file mode 100644 index 0000000..4c572ab --- /dev/null +++ b/src/FulltextSearch/src/IndexedRecord.php @@ -0,0 +1,29 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext; + +use Illuminate\Database\Eloquent\Model; + +class IndexedRecord extends Model +{ + protected $table = 'laravel_fulltext'; + + public function __construct(array $attributes = []) + { + $this->connection = config('binshopsblog.search.db_connection'); + + parent::__construct($attributes); + } + + public function indexable() + { + return $this->morphTo(); + } + + public function updateIndex() + { + $this->setAttribute('indexed_title', $this->indexable->getIndexTitle()); + $this->setAttribute('indexed_content', $this->indexable->getIndexContent()); + $this->save(); + } +} diff --git a/src/FulltextSearch/src/Indexer.php b/src/FulltextSearch/src/Indexer.php new file mode 100644 index 0000000..394c493 --- /dev/null +++ b/src/FulltextSearch/src/Indexer.php @@ -0,0 +1,42 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext; + +use Illuminate\Database\Eloquent\Model; + +class Indexer +{ + public function indexModel(Model $model) + { + $model->indexRecord(); + } + + public function unIndexOneByClass($class, $id) + { + $record = IndexedRecord::where('indexable_id', $id)->where('indexable_type', $class); + if ($record->exists) { + $record->delete(); + } + } + + public function indexOneByClass($class, $id) + { + $model = call_user_func([$class, 'find'], $id); + if (in_array(Indexable::class, class_uses($model), true)) { + $this->indexModel($model); + } + } + + public function indexAllByClass($class) + { + $model = new $class(); + $self = $this; + if (in_array(Indexable::class, class_uses($model), true)) { + $model->chunk(100, function ($chunk) use ($self) { + foreach ($chunk as $modelRecord) { + $self->indexModel($modelRecord); + } + }); + } + } +} diff --git a/src/FulltextSearch/src/ModelObserver.php b/src/FulltextSearch/src/ModelObserver.php new file mode 100644 index 0000000..8cc3d88 --- /dev/null +++ b/src/FulltextSearch/src/ModelObserver.php @@ -0,0 +1,95 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext; + +class ModelObserver +{ + /** + * The class names that syncing is disabled for. + * + * @var array + */ + protected static $syncingDisabledFor = []; + + /** + * Enable syncing for the given class. + * + * @param string $class + */ + public static function enableSyncingFor($class) + { + unset(static::$syncingDisabledFor[$class]); + } + + /** + * Disable syncing for the given class. + * + * @param string $class + */ + public static function disableSyncingFor($class) + { + static::$syncingDisabledFor[$class] = true; + } + + /** + * Determine if syncing is disabled for the given class or model. + * + * @param object|string $class + * + * @return bool + */ + public static function syncingDisabledFor($class) + { + $class = is_object($class) ? get_class($class) : $class; + + return isset(static::$syncingDisabledFor[$class]); + } + + /** + * Handle the created event for the model. + * + * @param \Illuminate\Database\Eloquent\Model $model + */ + public function created($model) + { + if (static::syncingDisabledFor($model)) { + return; + } + + $model->indexRecord(); + } + + /** + * Handle the updated event for the model. + * + * @param \Illuminate\Database\Eloquent\Model $model + */ + public function updated($model) + { + $this->created($model); + } + + /** + * Handle the deleted event for the model. + * + * @param \Illuminate\Database\Eloquent\Model $model + */ + public function deleted($model) + { + if (static::syncingDisabledFor($model)) { + return; + } + + $model->unIndexRecord(); + } + + /** + * Handle the restored event for the model. + * + * @param \Illuminate\Database\Eloquent\Model $model + */ + public function restored($model) + { + $this->created($model); + } +} diff --git a/src/FulltextSearch/src/Search.php b/src/FulltextSearch/src/Search.php new file mode 100644 index 0000000..01a95d0 --- /dev/null +++ b/src/FulltextSearch/src/Search.php @@ -0,0 +1,72 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext; + +class Search implements SearchInterface +{ + /** + * @param string $search + * + * @return \Illuminate\Database\Eloquent\Collection|\BinshopsBlog\Laravel\Fulltext\IndexedRecord[] + */ + public function run($search) + { + $query = $this->searchQuery($search); + + return $query->get(); + } + + /** + * @param $search + * @param $class + * + * @return \Illuminate\Database\Eloquent\Collection|\BinshopsBlog\Laravel\Fulltext\IndexedRecord[] + */ + public function runForClass($search, $class) + { + $query = $this->searchQuery($search); + $query->where('indexable_type', $class); + + return $query->get(); + } + + /** + * @param string $search + * + * This search query is designed for post queries - todo: + * + * @return \Illuminate\Database\Eloquent\Builder + */ + public function searchQuery($search) + { + $termsBool = ''; + $termsMatch = ''; + + if ($search) { + $terms = TermBuilder::terms($search); + + $termsBool = '+'.$terms->implode(' +'); + $termsMatch = ''.$terms->implode(' '); + } + + $titleWeight = str_replace(',', '.', (float) config('binshopsblog.search.weight.title', 1.5)); + $contentWeight = str_replace(',', '.', (float) config('binshopsblog.search.weight.content', 1.0)); + + $query = IndexedRecord::query() + ->whereRaw('MATCH (indexed_title, indexed_content) AGAINST (? IN BOOLEAN MODE)', [$termsBool]) + ->orderByRaw( + '('.$titleWeight.' * (MATCH (indexed_title) AGAINST (?)) + + '.$contentWeight.' * (MATCH (indexed_title, indexed_content) AGAINST (?)) + ) DESC', + [$termsMatch, $termsMatch]) + ->limit(config('binshopsblog.search.limit-results')); + + $query->with(['indexable' => function ($query) { + $query->with(['post' => function($query){ + $query->where('is_published', '=', true); + }]); + }]); + + return $query; + } +} diff --git a/src/FulltextSearch/src/SearchInterface.php b/src/FulltextSearch/src/SearchInterface.php new file mode 100644 index 0000000..22e0ae2 --- /dev/null +++ b/src/FulltextSearch/src/SearchInterface.php @@ -0,0 +1,12 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext; + +interface SearchInterface +{ + public function run($search); + + public function runForClass($search, $class); + + public function searchQuery($search); +} diff --git a/src/FulltextSearch/src/TermBuilder.php b/src/FulltextSearch/src/TermBuilder.php new file mode 100644 index 0000000..a07ba6c --- /dev/null +++ b/src/FulltextSearch/src/TermBuilder.php @@ -0,0 +1,25 @@ +<?php + +namespace BinshopsBlog\Laravel\Fulltext; + +class TermBuilder +{ + public static function terms($search) + { + $wildcards = config('binshopsblog.search.enable_wildcards'); + + // Remove every boolean operator (+, -, > <, ( ), ~, *, ", @distance) from the search query + // else we will break the MySQL query. + $search = trim(preg_replace('/[+\-><\(\)~*\"@]+/', ' ', $search)); + + $terms = collect(preg_split('/[\s,]+/', $search)); + + if ($wildcards === true) { + $terms->transform(function ($term) { + return $term.'*'; + }); + } + + return $terms; + } +} diff --git a/src/Helpers.php b/src/Helpers.php index 3fd7c47..6ff1435 100755 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -1,18 +1,18 @@ <?php -namespace WebDevEtc\BlogEtc; +namespace BinshopsBlog; use \Session; /** * Class Helpers - * @package WebDevEtc\BlogEtc + * @package BinshopsBlog */ class Helpers { /** * What key to use for the session::flash / pull / has */ - const FLASH_MESSAGE_SESSION_KEY = "WEBDEVETC_FLASH"; + const FLASH_MESSAGE_SESSION_KEY = "BINSHOPSBLOG_FLASH"; /** * Set a new message @@ -43,29 +43,13 @@ public static function pull_flashed_message() return Session::pull(self::FLASH_MESSAGE_SESSION_KEY); } - /** - * Use this (Helpers::rss_html_tag()) in your blade/template files, within <head> - * to auto insert the links to rss feed - * @return string - */ - public static function rss_html_tag() - { - - - return '<link rel="alternate" type="application/atom+xml" title="Atom RSS Feed" href="' . e(route("blogetc.feed")) . '?type=atom" /> - <link rel="alternate" type="application/rss+xml" title="XML RSS Feed" href="' . e(route("blogetc.feed")) . '?type=rss" /> - '; - - - } - /** * This method is depreciated. Just use the config() directly. * @return array * @deprecated */ public static function image_sizes(){ - return config("blogetc.image_sizes"); + return config("binshopsblog.image_sizes"); } } diff --git a/src/Interfaces/BaseRequestInterface.php b/src/Interfaces/BaseRequestInterface.php index 6ddd97d..c45580a 100755 --- a/src/Interfaces/BaseRequestInterface.php +++ b/src/Interfaces/BaseRequestInterface.php @@ -1,4 +1,4 @@ -<?php namespace WebDevEtc\BlogEtc\Interfaces; +<?php namespace BinshopsBlog\Interfaces; interface BaseRequestInterface { diff --git a/src/Interfaces/CaptchaInterface.php b/src/Interfaces/CaptchaInterface.php index a5bc736..0ecdd20 100644 --- a/src/Interfaces/CaptchaInterface.php +++ b/src/Interfaces/CaptchaInterface.php @@ -1,4 +1,4 @@ -<?php namespace WebDevEtc\BlogEtc\Interfaces; +<?php namespace BinshopsBlog\Interfaces; interface CaptchaInterface { diff --git a/src/Interfaces/SearchResultInterface.php b/src/Interfaces/SearchResultInterface.php index 92c97fa..f15b892 100644 --- a/src/Interfaces/SearchResultInterface.php +++ b/src/Interfaces/SearchResultInterface.php @@ -1,4 +1,4 @@ -<?php namespace WebDevEtc\BlogEtc\Interfaces; +<?php namespace BinshopsBlog\Interfaces; interface SearchResultInterface { diff --git a/src/Middleware/DetectLanguage.php b/src/Middleware/DetectLanguage.php new file mode 100644 index 0000000..f25d1a8 --- /dev/null +++ b/src/Middleware/DetectLanguage.php @@ -0,0 +1,37 @@ +<?php + +namespace BinshopsBlog\Middleware; + +use BinshopsBlog\Models\BinshopsConfiguration; +use Closure; +use BinshopsBlog\Models\BinshopsLanguage; + +class DetectLanguage +{ + public function handle($request, Closure $next) + { + $locale = $request->route('locale'); + $routeWithoutLocale = false; + + if (!$request->route('locale')){ + $routeWithoutLocale = true; + $locale = BinshopsConfiguration::get('DEFAULT_LANGUAGE_LOCALE'); + } + + $lang = BinshopsLanguage::where('locale', $locale) + ->where('active', true) + ->first(); + + if (!$lang){ + return abort(404); + } + + $request->attributes->add([ + 'lang_id' => $lang->id, + 'locale' => $lang->locale, + 'routeWithoutLocale' => $routeWithoutLocale + ]); + + return $next($request); + } +} diff --git a/src/Middleware/LoadLanguage.php b/src/Middleware/LoadLanguage.php new file mode 100644 index 0000000..08c7479 --- /dev/null +++ b/src/Middleware/LoadLanguage.php @@ -0,0 +1,25 @@ +<?php + + +namespace BinshopsBlog\Middleware; +use Closure; +use BinshopsBlog\Models\BinshopsConfiguration; +use BinshopsBlog\Models\BinshopsLanguage; + +class LoadLanguage +{ + + public function handle($request, Closure $next) + { + $default_locale = BinshopsConfiguration::get('DEFAULT_LANGUAGE_LOCALE'); + $lang = BinshopsLanguage::where('locale', $default_locale) + ->first(); + + $request->attributes->add([ + 'locale' => $lang->locale, + 'language_id' => $lang->id + ]); + + return $next($request); + } +} diff --git a/src/Middleware/PackageSetup.php b/src/Middleware/PackageSetup.php new file mode 100644 index 0000000..fe71282 --- /dev/null +++ b/src/Middleware/PackageSetup.php @@ -0,0 +1,20 @@ +<?php + + +namespace BinshopsBlog\Middleware; + +use Closure; +use BinshopsBlog\Models\BinshopsConfiguration; + +class PackageSetup +{ + public function handle($request, Closure $next) + { + $initial_setup = BinshopsConfiguration::get('INITIAL_SETUP'); + if (!$initial_setup){ + return redirect( route('binshopsblog.admin.setup') ); + } + + return $next($request); + } +} diff --git a/src/Middleware/UserCanManageBlogPosts.php b/src/Middleware/UserCanManageBlogPosts.php index ad387b5..d26fb54 100755 --- a/src/Middleware/UserCanManageBlogPosts.php +++ b/src/Middleware/UserCanManageBlogPosts.php @@ -1,18 +1,18 @@ <?php -namespace WebDevEtc\BlogEtc\Middleware; +namespace BinshopsBlog\Middleware; use Closure; /** * Class UserCanManageBlogPosts - * @package WebDevEtc\BlogEtc\Middleware + * @package BinshopsBlog\Middleware */ class UserCanManageBlogPosts { /** - * Show 401 error if \Auth::user()->canManageBlogEtcPosts() == false + * Show 401 error if \Auth::user()->canManageBinshopsBlogPosts() == false * @param $request * @param Closure $next * @return mixed @@ -21,8 +21,9 @@ public function handle($request, Closure $next) { if (!\Auth::check()) { abort(401,"User not authorised to manage blog posts: You are not logged in"); + return redirect('/login'); } - if (!\Auth::user()->canManageBlogEtcPosts()) { + if (!\Auth::user()->canManageBinshopsBlogPosts()) { abort(401,"User not authorised to manage blog posts: Your account is not authorised to edit blog posts"); } return $next($request); diff --git a/src/Models/BinshopsCategory.php b/src/Models/BinshopsCategory.php new file mode 100755 index 0000000..e7d400a --- /dev/null +++ b/src/Models/BinshopsCategory.php @@ -0,0 +1,79 @@ +<?php + +namespace BinshopsBlog\Models; + +use BinshopsBlog\Baum\Node; + +class BinshopsCategory extends Node +{ + protected $parentColumn = 'parent_id'; + public $siblings = array(); + + public $fillable = [ + 'parent_id' + ]; + + public static function boot() { + parent::boot(); + + static::deleting(function($category) { // before delete() method call this + $category->categoryTranslations()->delete(); + }); + } + + /** + * The associated category translations + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function categoryTranslations() + { + return $this->hasMany(BinshopsCategoryTranslation::class,"category_id"); + } + + /** + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function posts() + { + return $this->belongsToMany(BinshopsPost::class, 'binshops_post_categories','category_id', 'post_id'); + } + + public function loadSiblings(){ + $this->siblings = $this->children()->get(); + } + + public static function loadSiblingsWithList($node_list){ + for($i = 0 ; sizeof($node_list) > $i ; $i++){ + $node_list[$i]->loadSiblings(); + if (sizeof($node_list[$i]->siblings) > 0){ + self::loadSiblingsWithList($node_list[$i]->siblings); + } + } + } + +// public function parent() +// { +// return $this->belongsTo('BinshopsBlog\Models\BinshopsCategory', 'parent_id'); +// } +// +// public function children() +// { +// return $this->hasMany('BinshopsBlog\Models\BinshopsCategory', 'parent_id'); +// } +// +// // recursive, loads all descendants +// private function childrenRecursive() +// { +// return $this->children()->with('children')->get(); +// } +// +// public function loadChildren(){ +// $this->childrenCat = $this->childrenRecursive(); +// } + +// public function scopeApproved($query) +// { +// dd("A"); +// return $query->where("approved", true); +// } +} diff --git a/src/Models/BinshopsCategoryTranslation.php b/src/Models/BinshopsCategoryTranslation.php new file mode 100644 index 0000000..f4450d5 --- /dev/null +++ b/src/Models/BinshopsCategoryTranslation.php @@ -0,0 +1,58 @@ +<?php + +namespace BinshopsBlog\Models; + +use Illuminate\Database\Eloquent\Model; + +class BinshopsCategoryTranslation extends Model +{ + public $fillable = [ + 'category_id', + 'category_name', + 'slug', + 'category_description', + 'lang_id' + ]; + + /** + * Get the category that owns the phone. + */ + public function category() + { + return $this->belongsTo(BinshopsCategory::class, 'category_id'); + } + + /** + * The associated Language + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function language() + { + return $this->hasOne(BinshopsLanguage::class,"lang_id"); + } + + /** + * Returns the public facing URL of showing blog posts in this category + * @return string + */ + public function url($locale, $routeWithoutLocale = false) + { + $theChainString = ""; + $cat = $this->category()->get(); + $chain = $cat[0]->getAncestorsAndSelf(); + foreach ($chain as $category){ + $theChainString .= "/" . $category->categoryTranslations()->where('lang_id' , $this->lang_id)->first()->slug; + } + + return $routeWithoutLocale ? route("binshopsblog.view_category",["", $theChainString]) : route("binshopsblog.view_category",[$locale, $theChainString]); + } + + /** + * Returns the URL for an admin user to edit this category + * @return string + */ + public function edit_url() + { + return route("binshopsblog.admin.categories.edit_category", $this->category_id); + } +} diff --git a/src/Models/BlogEtcComment.php b/src/Models/BinshopsComment.php similarity index 70% rename from src/Models/BlogEtcComment.php rename to src/Models/BinshopsComment.php index 680bb1c..b621d0e 100755 --- a/src/Models/BlogEtcComment.php +++ b/src/Models/BinshopsComment.php @@ -1,12 +1,12 @@ <?php -namespace WebDevEtc\BlogEtc\Models; +namespace BinshopsBlog\Models; use App\User; use Illuminate\Database\Eloquent\Model; -use WebDevEtc\BlogEtc\Scopes\BlogCommentApprovedAndDefaultOrderScope; +use BinshopsBlog\Scopes\BlogCommentApprovedAndDefaultOrderScope; -class BlogEtcComment extends Model +class BinshopsComment extends Model { public $casts = [ 'approved' => 'boolean', @@ -28,7 +28,7 @@ protected static function boot() { parent::boot(); - /* If user is logged in and \Auth::user()->canManageBlogEtcPosts() == true, show any/all posts. + /* If user is logged in and \Auth::user()->canManageBinshopsBlogPosts() == true, show any/all posts. otherwise (which will be for most users) it should only show published posts that have a posted_at time <= Carbon::now(). This sets it up: */ static::addGlobalScope(new BlogCommentApprovedAndDefaultOrderScope()); @@ -37,12 +37,12 @@ protected static function boot() /** - * The associated BlogEtcPost + * The associated BinshopsPost * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function post() { - return $this->belongsTo(BlogEtcPost::class,"blog_etc_post_id"); + return $this->belongsTo(BinshopsPost::class,"post_id"); } /** @@ -51,7 +51,7 @@ public function post() */ public function user() { - return $this->belongsTo(config("blogetc.user_model"), 'user_id'); + return $this->belongsTo(config("binshopsblog.user_model"), 'user_id'); } /** @@ -62,7 +62,7 @@ public function user() public function author() { if ($this->user_id) { - $field = config("blogetc.comments.user_field_for_author_name","name"); + $field = config("binshopsblog.comments.user_field_for_author_name","name"); return optional($this->user)->$field; } diff --git a/src/Models/BinshopsConfiguration.php b/src/Models/BinshopsConfiguration.php new file mode 100644 index 0000000..59a583e --- /dev/null +++ b/src/Models/BinshopsConfiguration.php @@ -0,0 +1,37 @@ +<?php + + +namespace BinshopsBlog\Models; + +use Illuminate\Database\Eloquent\Model; + + +/** + * + */ +class BinshopsConfiguration extends Model +{ + protected $primaryKey = 'key'; + + public $fillable = [ + 'key', + 'value' + ]; + + public static function get($key){ + $obj = BinshopsConfiguration::where('key', $key)->first(); + if ($obj){ + return $obj->value; + } + else{ + return null; + } + } + + public static function set($key, $value){ + $config = new BinshopsConfiguration(); + $config->key = $key; + $config->value = $value; + $config->save(); + } +} diff --git a/src/Models/BinshopsLanguage.php b/src/Models/BinshopsLanguage.php new file mode 100644 index 0000000..1ba7a87 --- /dev/null +++ b/src/Models/BinshopsLanguage.php @@ -0,0 +1,37 @@ +<?php + + +namespace BinshopsBlog\Models; + +use Illuminate\Database\Eloquent\Model; + +class BinshopsLanguage extends Model +{ + public $fillable = [ + 'name', + 'locale', + 'iso_code', + 'date_format', + 'active' + ]; + + + /** + * The associated post (if post_id) is set + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function post() + { + return $this->belongsTo(BinshopsPost::class, 'post_id'); + } + + /** + * The associated author (if category_id) is set + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function category() + { + return $this->belongsTo(BinshopsCategory::class, 'category_id'); + } + +} \ No newline at end of file diff --git a/src/Models/BinshopsPost.php b/src/Models/BinshopsPost.php new file mode 100755 index 0000000..ebebb77 --- /dev/null +++ b/src/Models/BinshopsPost.php @@ -0,0 +1,107 @@ +<?php + +namespace BinshopsBlog\Models; + +use Illuminate\Database\Eloquent\Model; +use BinshopsBlog\Scopes\BinshopsBlogPublishedScope; + +/** + * Class BinshopsPost + * @package BinshopsBlog\Models + */ +class BinshopsPost extends Model +{ + /** + * @var array + */ + public $casts = [ + 'is_published' => 'boolean', + 'posted_at' => 'date' + ]; + + /** + * @var array + */ + public $dates = [ + 'posted_at' + ]; + + /** + * @var array + */ + public $fillable = [ + 'is_published', + 'posted_at', + ]; + + /** + * The associated post translations + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function postTranslations() + { + return $this->hasMany(BinshopsPostTranslation::class,"post_id"); + } + + /** + * The "booting" method of the model. + * + * @return void + */ + protected static function boot() + { + parent::boot(); + + /* If user is logged in and \Auth::user()->canManageBinshopsBlogPosts() == true, show any/all posts. + otherwise (which will be for most users) it should only show published posts that have a posted_at + time <= Carbon::now(). This sets it up: */ + static::addGlobalScope(new BinshopsBlogPublishedScope()); + + static::deleting(function($post) { // before delete() method call this + $post->postTranslations()->delete(); + }); + } + + /** + * The associated author (if user_id) is set + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function author() + { + return $this->belongsTo(config("binshopsblog.user_model"), 'user_id'); + } + + /** + * Return author string (either from the User (via ->user_id), or the submitted author_name value + * @return string + */ + public function author_string() + { + if ($this->author) { + return optional($this->author)->name; + } else { + return 'Unknown Author'; + } + } + + /** + * The associated categories for this blog post + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function categories() + { + return $this->belongsToMany(BinshopsCategory::class, 'binshops_post_categories','post_id','category_id'); + } + + /** + * Comments for this post + * + * @return \Illuminate\Database\Eloquent\Relations\HasMany + */ + public function comments() + { + return $this->hasMany(BinshopsComment::class, 'post_id'); + } + +} diff --git a/src/Models/BlogEtcPost.php b/src/Models/BinshopsPostTranslation.php old mode 100755 new mode 100644 similarity index 60% rename from src/Models/BlogEtcPost.php rename to src/Models/BinshopsPostTranslation.php index 12d97f5..856de2f --- a/src/Models/BlogEtcPost.php +++ b/src/Models/BinshopsPostTranslation.php @@ -1,45 +1,21 @@ <?php -namespace WebDevEtc\BlogEtc\Models; +namespace BinshopsBlog\Models; use Cviebrock\EloquentSluggable\Sluggable; +use BinshopsBlog\Laravel\Fulltext\Indexable; use Illuminate\Database\Eloquent\Model; -use Swis\Laravel\Fulltext\Indexable; -use WebDevEtc\BlogEtc\Interfaces\SearchResultInterface; -use WebDevEtc\BlogEtc\Scopes\BlogEtcPublishedScope; - -/** - * Class BlogEtcPost - * @package WebDevEtc\BlogEtc\Models - */ -class BlogEtcPost extends Model implements SearchResultInterface -{ +use BinshopsBlog\Interfaces\SearchResultInterface; +class BinshopsPostTranslation extends Model implements SearchResultInterface +{ use Sluggable; use Indexable; protected $indexContentColumns = ['post_body', 'short_description', 'meta_desc',]; protected $indexTitleColumns = ['title', 'subtitle', 'seo_title',]; - /** - * @var array - */ - public $casts = [ - 'is_published' => 'boolean', - ]; - - /** - * @var array - */ - public $dates = [ - 'posted_at' - ]; - - /** - * @var array - */ public $fillable = [ - 'title', 'subtitle', 'short_description', @@ -48,17 +24,31 @@ class BlogEtcPost extends Model implements SearchResultInterface 'meta_desc', 'slug', 'use_view_file', - - 'is_published', - 'posted_at', ]; + /** + * Get the user that owns the phone. + */ + public function post() + { + return $this->belongsTo(BinshopsPost::class, 'post_id'); + } + + /** + * The associated Language + * @return \Illuminate\Database\Eloquent\Relations\HasOne + */ + public function language() + { + return $this->hasOne(BinshopsLanguage::class,"lang_id"); + } + /** * Return the sluggable configuration array for this model. * * @return array */ - public function sluggable() + public function sluggable(): array { return [ 'slug' => [ @@ -77,82 +67,6 @@ public function search_result_page_title() return $this->title; } - /** - * The "booting" method of the model. - * - * @return void - */ - protected static function boot() - { - parent::boot(); - - /* If user is logged in and \Auth::user()->canManageBlogEtcPosts() == true, show any/all posts. - otherwise (which will be for most users) it should only show published posts that have a posted_at - time <= Carbon::now(). This sets it up: */ - static::addGlobalScope(new BlogEtcPublishedScope()); - } - - /** - * The associated author (if user_id) is set - * @return \Illuminate\Database\Eloquent\Relations\BelongsTo - */ - public function author() - { - return $this->belongsTo(config("blogetc.user_model"), 'user_id'); - } - - /** - * Return author string (either from the User (via ->user_id), or the submitted author_name value - * @return string - */ - public function author_string() - { - if ($this->author) { - return optional($this->author)->name; - } else { - return 'Unknown Author'; - } - } - - /** - * The associated categories for this blog post - * - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function categories() - { - return $this->belongsToMany(BlogEtcCategory::class, 'blog_etc_post_categories'); - } - - /** - * Comments for this post - * - * @return \Illuminate\Database\Eloquent\Relations\HasMany - */ - public function comments() - { - return $this->hasMany(BlogEtcComment::class); - } - - /** - * Returns the public facing URL to view this blog post - * - * @return string - */ - public function url() - { - return route("blogetc.single", $this->slug); - } - - /** - * Return the URL for editing the post (used for admin users) - * @return string - */ - public function edit_url() - { - return route("blogetc.admin.edit_post", $this->id); - } - /** * If $this->user_view_file is not empty, then it'll return the dot syntax location of the blade file it should look for * @return string @@ -190,7 +104,7 @@ public function image_url($size = 'medium') { $this->check_valid_image_size($size); $filename = $this->{"image_" . $size}; - return asset(config("blogetc.blog_upload_dir", "blog_images") . "/" . $filename); + return asset(config("binshopsblog.blog_upload_dir", "blog_images") . "/" . $filename); } /** @@ -211,7 +125,7 @@ public function image_tag($size = 'medium', $auto_link = true, $img_class = null $url = e($this->image_url($size)); $alt = e($this->title); $img = "<img src='$url' alt='$alt' class='" . e($img_class) . "' >"; - return $auto_link ? "<a class='" . e($anchor_class) . "' href='" . e($this->url()) . "'>$img</a>" : $img; + return $auto_link ? "<a class='" . e($anchor_class) . "' href='" . e($this->url( app()->getLocale() )) . "'>$img</a>" : $img; } @@ -229,23 +143,23 @@ public function generate_introduction($max_len = 500) public function post_body_output() { - if (config("blogetc.use_custom_view_files") && $this->use_view_file) { + if (config("binshopsblog.use_custom_view_files") && $this->use_view_file) { // using custom view files is enabled, and this post has a use_view_file set, so render it: - $return = view("blogetc::partials.use_view_file", ['post' => $this])->render(); + $return = view("binshopsblog::partials.use_view_file", ['post' => $this])->render(); } else { // just use the plain ->post_body $return = $this->post_body; } - if (!config("blogetc.echo_html")) { + if (!config("binshopsblog.echo_html")) { // if this is not true, then we should escape the output - if (config("blogetc.strip_html")) { + if (config("binshopsblog.strip_html")) { $return = strip_tags($return); } $return = e($return); - if (config("blogetc.auto_nl2br")) { + if (config("binshopsblog.auto_nl2br")) { $return = nl2br($return); } } @@ -265,7 +179,7 @@ protected function check_valid_image_size(string $size = 'medium') { - if (array_key_exists("image_" . $size, config("blogetc.image_sizes"))) { + if (array_key_exists("image_" . $size, config("binshopsblog.image_sizes"))) { return true; } @@ -273,22 +187,20 @@ protected function check_valid_image_size(string $size = 'medium') if (starts_with($size, "image_")) { // $size starts with image_, which is an error - /* the config/blogetc.php and the DB columns SHOULD have keys that start with image_$size + /* the config/binshopsblog.php and the DB columns SHOULD have keys that start with image_$size however when using methods such as image_url() or has_image() it SHOULD NOT start with 'image_' To put another way: : - in the config/blogetc.php : config("blogetc.image_sizes.image_medium") - in the database table: : blogetc_posts.image_medium + in the config/binshopsblog.php : config("binshopsblog.image_sizes.image_medium") + in the database table: : binshopsblog_posts.image_medium when calling image_url() : image_url("medium") */ - throw new \InvalidArgumentException("Invalid image size ($size). BlogEtcPost image size should not begin with 'image_'. Remove this from the start of $size. It *should* be in the blogetc.image_sizes config though!"); + throw new \InvalidArgumentException("Invalid image size ($size). BinshopsPost image size should not begin with 'image_'. Remove this from the start of $size. It *should* be in the binshopsblog.image_sizes config though!"); } - - throw new \InvalidArgumentException("BlogEtcPost image size should be 'large','medium','thumbnail' or another field as defined in config/blogetc.php. Provided size ($size) is not valid"); + throw new \InvalidArgumentException("BinshopsPost image size should be 'large','medium','thumbnail' or another field as defined in config/binshopsblog.php. Provided size ($size) is not valid"); } - /** * * If $this->seo_title was set, return that. @@ -304,4 +216,23 @@ public function gen_seo_title() } return $this->title; } + + /** + * Returns the public facing URL to view this blog post + * + * @return string + */ + public function url($loacle, $routeWithoutLocale = false) + { + return $routeWithoutLocale ? route("binshopsblog.single", ["", $this->slug]) : route("binshopsblog.single", [$loacle, $this->slug]); + } + + /** + * Return the URL for editing the post (used for admin users) + * @return string + */ + public function edit_url() + { + return route("binshopsblog.admin.edit_post", $this->post_id); + } } diff --git a/src/Models/BlogEtcUploadedPhoto.php b/src/Models/BinshopsUploadedPhoto.php similarity index 65% rename from src/Models/BlogEtcUploadedPhoto.php rename to src/Models/BinshopsUploadedPhoto.php index 50aa787..dfe1916 100644 --- a/src/Models/BlogEtcUploadedPhoto.php +++ b/src/Models/BinshopsUploadedPhoto.php @@ -1,12 +1,12 @@ <?php -namespace WebDevEtc\BlogEtc\Models; +namespace BinshopsBlog\Models; use Illuminate\Database\Eloquent\Model; -class BlogEtcUploadedPhoto extends Model +class BinshopsUploadedPhoto extends Model { - public $table = 'blog_etc_uploaded_photos'; + public $table = 'binshops_uploaded_photos'; public $casts = [ 'uploaded_images' => 'array', ]; diff --git a/src/Models/BlogEtcCategory.php b/src/Models/BlogEtcCategory.php deleted file mode 100755 index af32277..0000000 --- a/src/Models/BlogEtcCategory.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Models; - -use Illuminate\Database\Eloquent\Model; -use WebDevEtc\BlogEtc\Baum\Node; - -class BlogEtcCategory extends Node -{ - protected $parentColumn = 'parent_id'; - public $siblings = array(); - - public $fillable = [ - 'category_name', - 'slug', - 'category_description', - 'parent_id' - ]; - - /** - * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany - */ - public function posts() - { - return $this->belongsToMany(BlogEtcPost::class, 'blog_etc_post_categories'); - } - - /** - * Returns the public facing URL of showing blog posts in this category - * @return string - */ - public function url() - { - $theChainString = ""; - $chain = $this->getAncestorsAndSelf(); - foreach ($chain as $category){ - $theChainString .= "/" . $category->slug; - } - return route("blogetc.view_category", $theChainString); - } - - /** - * Returns the URL for an admin user to edit this category - * @return string - */ - public function edit_url() - { - return route("blogetc.admin.categories.edit_category", $this->id); - } - - public function loadSiblings(){ - $this->siblings = $this->children()->get(); - } - -// public function parent() -// { -// return $this->belongsTo('WebDevEtc\BlogEtc\Models\BlogEtcCategory', 'parent_id'); -// } -// -// public function children() -// { -// return $this->hasMany('WebDevEtc\BlogEtc\Models\BlogEtcCategory', 'parent_id'); -// } -// -// // recursive, loads all descendants -// private function childrenRecursive() -// { -// return $this->children()->with('children')->get(); -// } -// -// public function loadChildren(){ -// $this->childrenCat = $this->childrenRecursive(); -// } - -// public function scopeApproved($query) -// { -// dd("A"); -// return $query->where("approved", true); -// } -} diff --git a/src/Requests/AddNewCommentRequest.php b/src/Requests/AddNewCommentRequest.php index 35587de..bc46526 100755 --- a/src/Requests/AddNewCommentRequest.php +++ b/src/Requests/AddNewCommentRequest.php @@ -1,6 +1,6 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -9,7 +9,7 @@ class AddNewCommentRequest extends FormRequest public function authorize() { - if (config("blogetc.comments.type_of_comments_to_show") === 'built_in') { + if (config("binshopsblog.comments.type_of_comments_to_show") === 'built_in') { // anyone is allowed to submit a comment, to return true always. return true; } @@ -34,7 +34,7 @@ public function rules() ]; // do we need author name? - if (\Auth::check() && config("blogetc.comments.save_user_id_if_logged_in", true)) { + if (\Auth::check() && config("binshopsblog.comments.save_user_id_if_logged_in", true)) { // is logged in, so we don't need an author name (it won't get used) $return['author_name'][] = 'nullable'; } else { @@ -43,24 +43,24 @@ public function rules() } // is captcha enabled? If so, get the rules from its class. - if (config("blogetc.captcha.captcha_enabled")) { + if (config("binshopsblog.captcha.captcha_enabled")) { /** @var string $captcha_class */ - $captcha_class = config("blogetc.captcha.captcha_type"); + $captcha_class = config("binshopsblog.captcha.captcha_type"); - /** @var \WebDevEtc\BlogEtc\Interfaces\CaptchaInterface $captcha */ + /** @var \BinshopsBlog\Interfaces\CaptchaInterface $captcha */ $captcha = new $captcha_class; $return[$captcha->captcha_field_name()] = $captcha->rules(); } // in case you need to implement something custom, you can use this... - if (config("blogetc.comments.rules") && is_callable(config("blogetc.comments.rules"))) { + if (config("binshopsblog.comments.rules") && is_callable(config("binshopsblog.comments.rules"))) { /** @var callable $func */ - $func = config('blogetc.comments.rules'); + $func = config('binshopsblog.comments.rules'); $return = $func($return); } - if (config("blogetc.comments.require_author_email")) { + if (config("binshopsblog.comments.require_author_email")) { $return['author_email'][] = 'required'; } diff --git a/src/Requests/BaseBlogEtcCategoryRequest.php b/src/Requests/BaseBinshopsBlogCategoryRequest.php similarity index 82% rename from src/Requests/BaseBlogEtcCategoryRequest.php rename to src/Requests/BaseBinshopsBlogCategoryRequest.php index 26e441e..4e5f8e8 100755 --- a/src/Requests/BaseBlogEtcCategoryRequest.php +++ b/src/Requests/BaseBinshopsBlogCategoryRequest.php @@ -1,8 +1,8 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; -abstract class BaseBlogEtcCategoryRequest extends BaseRequest +abstract class BaseBinshopsBlogCategoryRequest extends BaseRequest { /** * Shared rules for categories diff --git a/src/Requests/BaseBlogEtcPostRequest.php b/src/Requests/BaseBinshopsBlogPostRequest.php similarity index 89% rename from src/Requests/BaseBlogEtcPostRequest.php rename to src/Requests/BaseBinshopsBlogPostRequest.php index db3e5f7..3c26770 100755 --- a/src/Requests/BaseBlogEtcPostRequest.php +++ b/src/Requests/BaseBinshopsBlogPostRequest.php @@ -1,10 +1,10 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; use Carbon\Carbon; -abstract class BaseBlogEtcPostRequest extends BaseRequest +abstract class BaseBinshopsBlogPostRequest extends BaseRequest { /** @@ -57,7 +57,7 @@ protected function baseBlogPostRules() // is use_custom_view_files true? - if (config('blogetc.use_custom_view_files')) { + if (config('binshopsblog.use_custom_view_files')) { $return['use_view_file'] = ['nullable', 'string', 'alpha_num', 'min:1', 'max:75',]; } else { // use_view_file is disabled, so give an empty if anything is submitted via this function: @@ -65,8 +65,8 @@ protected function baseBlogPostRules() } // some additional rules for uploaded images - foreach ((array)config('blogetc.image_sizes') as $size => $image_detail) { - if ($image_detail['enabled'] && config("blogetc.image_upload_enabled")) { + foreach ((array)config('binshopsblog.image_sizes') as $size => $image_detail) { + if ($image_detail['enabled'] && config("binshopsblog.image_upload_enabled")) { $return[$size] = ['nullable', 'image',]; } else { // was not enabled (or all images are disabled), so show an error if it was submitted: diff --git a/src/Requests/BaseRequest.php b/src/Requests/BaseRequest.php index 4412332..5d3b9b4 100755 --- a/src/Requests/BaseRequest.php +++ b/src/Requests/BaseRequest.php @@ -1,13 +1,13 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; use Illuminate\Foundation\Http\FormRequest; -use WebDevEtc\BlogEtc\Interfaces\BaseRequestInterface; +use BinshopsBlog\Interfaces\BaseRequestInterface; /** * Class BaseRequest - * @package WebDevEtc\BlogEtc\Requests + * @package BinshopsBlog\Requests */ abstract class BaseRequest extends FormRequest implements BaseRequestInterface { @@ -18,6 +18,6 @@ abstract class BaseRequest extends FormRequest implements BaseRequestInterface */ public function authorize() { - return \Auth::check() && \Auth::user()->canManageBlogEtcPosts(); + return \Auth::check() && \Auth::user()->canManageBinshopsBlogPosts(); } } diff --git a/src/Requests/CreateBlogEtcPostRequest.php b/src/Requests/CreateBinshopsBlogPostRequest.php similarity index 52% rename from src/Requests/CreateBlogEtcPostRequest.php rename to src/Requests/CreateBinshopsBlogPostRequest.php index 0a012ff..f874d6a 100755 --- a/src/Requests/CreateBlogEtcPostRequest.php +++ b/src/Requests/CreateBinshopsBlogPostRequest.php @@ -1,13 +1,13 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; use Illuminate\Validation\Rule; -use WebDevEtc\BlogEtc\Requests\Traits\HasCategoriesTrait; -use WebDevEtc\BlogEtc\Requests\Traits\HasImageUploadTrait; +use BinshopsBlog\Requests\Traits\HasCategoriesTrait; +use BinshopsBlog\Requests\Traits\HasImageUploadTrait; -class CreateBlogEtcPostRequest extends BaseBlogEtcPostRequest +class CreateBinshopsBlogPostRequest extends BaseBinshopsBlogPostRequest { use HasCategoriesTrait; use HasImageUploadTrait; @@ -20,7 +20,6 @@ class CreateBlogEtcPostRequest extends BaseBlogEtcPostRequest public function rules() { $return = $this->baseBlogPostRules(); - $return['slug'] [] = Rule::unique("blog_etc_posts", "slug"); return $return; } diff --git a/src/Requests/CreateBinshopsPostToggleRequest.php b/src/Requests/CreateBinshopsPostToggleRequest.php new file mode 100755 index 0000000..f5cc5ba --- /dev/null +++ b/src/Requests/CreateBinshopsPostToggleRequest.php @@ -0,0 +1,25 @@ +<?php + +namespace BinshopsBlog\Requests; + + +use Illuminate\Validation\Rule; +use BinshopsBlog\Requests\Traits\HasCategoriesTrait; +use BinshopsBlog\Requests\Traits\HasImageUploadTrait; + +class CreateBinshopsPostToggleRequest extends BaseBinshopsBlogPostRequest +{ + use HasCategoriesTrait; + use HasImageUploadTrait; + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + //no rules + return []; + } +} diff --git a/src/Requests/DeleteBlogEtcCategoryRequest.php b/src/Requests/DeleteBinshopsBlogCategoryRequest.php similarity index 70% rename from src/Requests/DeleteBlogEtcCategoryRequest.php rename to src/Requests/DeleteBinshopsBlogCategoryRequest.php index 57a3fde..35ae88a 100755 --- a/src/Requests/DeleteBlogEtcCategoryRequest.php +++ b/src/Requests/DeleteBinshopsBlogCategoryRequest.php @@ -1,9 +1,9 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; -class DeleteBlogEtcCategoryRequest extends BaseRequest { +class DeleteBinshopsBlogCategoryRequest extends BaseRequest { /** diff --git a/src/Requests/DeleteBlogEtcPostRequest.php b/src/Requests/DeleteBinshopsBlogPostRequest.php similarity index 73% rename from src/Requests/DeleteBlogEtcPostRequest.php rename to src/Requests/DeleteBinshopsBlogPostRequest.php index 05955b1..aa3ad64 100755 --- a/src/Requests/DeleteBlogEtcPostRequest.php +++ b/src/Requests/DeleteBinshopsBlogPostRequest.php @@ -1,9 +1,9 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; -class DeleteBlogEtcPostRequest extends BaseRequest { +class DeleteBinshopsBlogPostRequest extends BaseRequest { /** diff --git a/src/Requests/FeedRequest.php b/src/Requests/FeedRequest.php deleted file mode 100755 index 18f87ee..0000000 --- a/src/Requests/FeedRequest.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Requests; - -use Illuminate\Foundation\Http\FormRequest; -use Illuminate\Validation\Rule; - -class FeedRequest extends FormRequest -{ - - /** - * Always return true, as this is just to view the rss feed - * - * @return bool - */ - public function authorize() - { - return true; - } - - /** - * - * - * @return array - */ - public function rules() - { - return [ - 'type' => [Rule::in(['rss','atom'])], - ]; - } - - /** - * Is this request for an RSS feed or Atom feed? defaults to atom. - * @return string - */ - public function getFeedType() - { - return $this->get("type") === 'rss' ? 'rss' : 'atom'; - } -} diff --git a/src/Requests/SearchRequest.php b/src/Requests/SearchRequest.php index 5b0c046..8bbd716 100755 --- a/src/Requests/SearchRequest.php +++ b/src/Requests/SearchRequest.php @@ -1,6 +1,6 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -8,7 +8,7 @@ class SearchRequest extends FormRequest { public function authorize() { - if (config("blogetc.search.search_enabled")) { + if (config("binshopsblog.search.search_enabled")) { // anyone is allowed to submit a comment, to return true always. return true; } diff --git a/src/Requests/Traits/HasCategoriesTrait.php b/src/Requests/Traits/HasCategoriesTrait.php index 40e280d..ec560aa 100755 --- a/src/Requests/Traits/HasCategoriesTrait.php +++ b/src/Requests/Traits/HasCategoriesTrait.php @@ -1,10 +1,10 @@ -<?php namespace WebDevEtc\BlogEtc\Requests\Traits; +<?php namespace BinshopsBlog\Requests\Traits; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; +use BinshopsBlog\Models\BinshopsCategory; /** * Class HasCategoriesTrait - * @package WebDevEtc\BlogEtc\Requests\Traits + * @package BinshopsBlog\Requests\Traits */ trait HasCategoriesTrait { @@ -25,7 +25,7 @@ public function categories() // check they are valid, return the IDs // limit to 1000 ... just in case someone submits with too many for the web server. No error is given if they submit more than 1k. - $vals = BlogEtcCategory::whereIn("id", array_keys($this->get("category")))->select("id")->limit(1000)->get(); + $vals = BinshopsCategory::whereIn("id", array_keys($this->get("category")))->select("id")->limit(1000)->get(); $vals = array_values($vals->pluck("id")->toArray()); return $vals; diff --git a/src/Requests/Traits/HasImageUploadTrait.php b/src/Requests/Traits/HasImageUploadTrait.php index b561ca5..e25f12a 100755 --- a/src/Requests/Traits/HasImageUploadTrait.php +++ b/src/Requests/Traits/HasImageUploadTrait.php @@ -1,4 +1,4 @@ -<?php namespace WebDevEtc\BlogEtc\Requests\Traits; +<?php namespace BinshopsBlog\Requests\Traits; @@ -16,7 +16,7 @@ public function get_image_file($size) } // not found? lets cycle through all the images and see if anything was submitted, and use that instead - foreach (config("blogetc.image_sizes") as $image_size_name => $image_size_info) { + foreach (config("binshopsblog.image_sizes") as $image_size_name => $image_size_info) { if ($this->file($image_size_name)) { return $this->file($image_size_name); } diff --git a/src/Requests/StoreBlogEtcCategoryRequest.php b/src/Requests/UpdateBinshopsBlogCategoryRequest.php similarity index 58% rename from src/Requests/StoreBlogEtcCategoryRequest.php rename to src/Requests/UpdateBinshopsBlogCategoryRequest.php index d274275..8674045 100755 --- a/src/Requests/StoreBlogEtcCategoryRequest.php +++ b/src/Requests/UpdateBinshopsBlogCategoryRequest.php @@ -1,12 +1,15 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; + +namespace BinshopsBlog\Requests; use Illuminate\Validation\Rule; +use BinshopsBlog\Models\BinshopsCategory; -class StoreBlogEtcCategoryRequest extends BaseBlogEtcCategoryRequest +class UpdateBinshopsBlogCategoryRequest extends BaseBinshopsBlogCategoryRequest { + /** * Get the validation rules that apply to the request. * @@ -15,7 +18,7 @@ class StoreBlogEtcCategoryRequest extends BaseBlogEtcCategoryRequest public function rules() { $return = $this->baseCategoryRules(); - $return['slug'] [] = Rule::unique("blog_etc_categories", "slug"); return $return; + } } diff --git a/src/Requests/UpdateBinshopsBlogPostRequest.php b/src/Requests/UpdateBinshopsBlogPostRequest.php new file mode 100755 index 0000000..4f30db2 --- /dev/null +++ b/src/Requests/UpdateBinshopsBlogPostRequest.php @@ -0,0 +1,27 @@ +<?php + +namespace BinshopsBlog\Requests; + + +use Illuminate\Validation\Rule; +use BinshopsBlog\Models\BinshopsPost; +use BinshopsBlog\Requests\Traits\HasCategoriesTrait; +use BinshopsBlog\Requests\Traits\HasImageUploadTrait; + +class UpdateBinshopsBlogPostRequest extends BaseBinshopsBlogPostRequest { + + use HasCategoriesTrait; + use HasImageUploadTrait; + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + $return = $this->baseBlogPostRules(); +// $return['slug'] [] = Rule::unique("binshops_post_translations", "slug")->ignore($this->route()->parameter("blogPostId")); + return $return; + } +} diff --git a/src/Requests/UpdateBlogEtcCategoryRequest.php b/src/Requests/UpdateBlogEtcCategoryRequest.php deleted file mode 100755 index 45af4d0..0000000 --- a/src/Requests/UpdateBlogEtcCategoryRequest.php +++ /dev/null @@ -1,25 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Requests; - - -use Illuminate\Validation\Rule; -use WebDevEtc\BlogEtc\Models\BlogEtcCategory; - -class UpdateBlogEtcCategoryRequest extends BaseBlogEtcCategoryRequest -{ - - - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - $return = $this->baseCategoryRules(); - $return['slug'] [] = Rule::unique("blog_etc_categories", "slug")->ignore($this->route()->parameter("categoryId")); - return $return; - - } -} diff --git a/src/Requests/UpdateBlogEtcPostRequest.php b/src/Requests/UpdateBlogEtcPostRequest.php deleted file mode 100755 index d59ed70..0000000 --- a/src/Requests/UpdateBlogEtcPostRequest.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -namespace WebDevEtc\BlogEtc\Requests; - - -use Illuminate\Validation\Rule; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; -use WebDevEtc\BlogEtc\Requests\Traits\HasCategoriesTrait; -use WebDevEtc\BlogEtc\Requests\Traits\HasImageUploadTrait; - -class UpdateBlogEtcPostRequest extends BaseBlogEtcPostRequest { - - use HasCategoriesTrait; - use HasImageUploadTrait; - - /** - * Get the validation rules that apply to the request. - * - * @return array - */ - public function rules() - { - $return = $this->baseBlogPostRules(); - $return['slug'] [] = Rule::unique("blog_etc_posts", "slug")->ignore($this->route()->parameter("blogPostId")); - return $return; - } -} diff --git a/src/Requests/UploadImageRequest.php b/src/Requests/UploadImageRequest.php index 422e9aa..6128b4e 100755 --- a/src/Requests/UploadImageRequest.php +++ b/src/Requests/UploadImageRequest.php @@ -1,13 +1,13 @@ <?php -namespace WebDevEtc\BlogEtc\Requests; +namespace BinshopsBlog\Requests; use Illuminate\Foundation\Http\FormRequest; -use WebDevEtc\BlogEtc\Interfaces\BaseRequestInterface; +use BinshopsBlog\Interfaces\BaseRequestInterface; /** * Class BaseRequest - * @package WebDevEtc\BlogEtc\Requests + * @package BinshopsBlog\Requests */ class UploadImageRequest extends BaseRequest { diff --git a/src/Scopes/BlogEtcPublishedScope.php b/src/Scopes/BinshopsBlogPublishedScope.php similarity index 72% rename from src/Scopes/BlogEtcPublishedScope.php rename to src/Scopes/BinshopsBlogPublishedScope.php index 2d8c831..c3a0c59 100755 --- a/src/Scopes/BlogEtcPublishedScope.php +++ b/src/Scopes/BinshopsBlogPublishedScope.php @@ -1,16 +1,16 @@ <?php -namespace WebDevEtc\BlogEtc\Scopes; +namespace BinshopsBlog\Scopes; use Carbon\Carbon; use Illuminate\Database\Eloquent\Scope; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Builder; -class BlogEtcPublishedScope implements Scope +class BinshopsBlogPublishedScope implements Scope { /** - * If user is logged in and canManageBlogEtcPosts() == true, then don't add any scope + * If user is logged in and canManageBinshopsBlogPosts() == true, then don't add any scope * But for everyone else then it should only show PUBLISHED posts with a POSTED_AT < NOW() * * @param \Illuminate\Database\Eloquent\Builder $builder @@ -19,7 +19,7 @@ class BlogEtcPublishedScope implements Scope */ public function apply(Builder $builder, Model $model) { - if (!\Auth::check() || ! \Auth::user()->canManageBlogEtcPosts()) { + if (!\Auth::check() || ! \Auth::user()->canManageBinshopsBlogPosts()) { // user is a guest, or if logged in they can't manage blog posts $builder->where("is_published", true); $builder->where("posted_at", "<=", Carbon::now()); diff --git a/src/Scopes/BlogCommentApprovedAndDefaultOrderScope.php b/src/Scopes/BlogCommentApprovedAndDefaultOrderScope.php index 77f16e2..70615f4 100755 --- a/src/Scopes/BlogCommentApprovedAndDefaultOrderScope.php +++ b/src/Scopes/BlogCommentApprovedAndDefaultOrderScope.php @@ -1,6 +1,6 @@ <?php -namespace WebDevEtc\BlogEtc\Scopes; +namespace BinshopsBlog\Scopes; use Illuminate\Database\Eloquent\Scope; use Illuminate\Database\Eloquent\Model; @@ -23,7 +23,7 @@ public function apply(Builder $builder, Model $model) { $builder->orderBy("id", 'asc'); // set a sane limit on num of comments. No pagination. Maybe a feature in the future. - $builder->limit(config("blogetc.comments.max_num_of_comments_to_show", 500)); + $builder->limit(config("binshopsblog.comments.max_num_of_comments_to_show", 500)); $builder->where("approved", true); } } \ No newline at end of file diff --git a/src/Traits/UploadFileTrait.php b/src/Traits/UploadFileTrait.php index 1b11f28..a1c793c 100644 --- a/src/Traits/UploadFileTrait.php +++ b/src/Traits/UploadFileTrait.php @@ -1,11 +1,12 @@ <?php -namespace WebDevEtc\BlogEtc\Traits; +namespace BinshopsBlog\Traits; use Illuminate\Http\UploadedFile; -use WebDevEtc\BlogEtc\Events\UploadedImage; -use WebDevEtc\BlogEtc\Models\BlogEtcPost; +use BinshopsBlog\Events\UploadedImage; +use BinshopsBlog\Models\BinshopsPost; use File; +use BinshopsBlog\Models\BinshopsPostTranslation; trait UploadFileTrait { @@ -20,14 +21,14 @@ trait UploadFileTrait /** * Small method to increase memory limit. - * This can be defined in the config file. If blogetc.memory_limit is false/null then it won't do anything. + * This can be defined in the config file. If binshopsblog.memory_limit is false/null then it won't do anything. * This is needed though because if you upload a large image it'll not work */ protected function increaseMemoryLimit() { // increase memory - change this setting in config file - if (config("blogetc.memory_limit")) { - @ini_set('memory_limit', config("blogetc.memory_limit")); + if (config("binshopsblog.memory_limit")) { + @ini_set('memory_limit', config("binshopsblog.memory_limit")); } } @@ -76,21 +77,21 @@ protected function getImageFilename(string $suggested_title, $image_size_details */ protected function image_destination_path() { - $path = public_path('/' . config("blogetc.blog_upload_dir")); + $path = public_path('/' . config("binshopsblog.blog_upload_dir")); $this->check_image_destination_path_is_writable($path); return $path; } /** - * @param BlogEtcPost $new_blog_post + * @param BinshopsPost $new_blog_post * @param $suggested_title - used to help generate the filename * @param $image_size_details - either an array (with 'w' and 'h') or a string (and it'll be uploaded at full size, no size reduction, but will use this string to generate the filename) * @param $photo * @return array * @throws \Exception */ - protected function UploadAndResize(BlogEtcPost $new_blog_post = null, $suggested_title, $image_size_details, $photo) + protected function UploadAndResize(BinshopsPostTranslation $new_blog_post = null, $suggested_title, $image_size_details, $photo) { // get the filename/filepath $image_filename = $this->getImageFilename($suggested_title, $image_size_details, $photo); @@ -122,7 +123,7 @@ protected function UploadAndResize(BlogEtcPost $new_blog_post = null, $suggested } // save image - $resizedImage->save($destinationPath . '/' . $image_filename, config("blogetc.image_quality", 80)); + $resizedImage->save($destinationPath . '/' . $image_filename, config("binshopsblog.image_quality", 80)); // fireevent event(new UploadedImage($image_filename, $resizedImage, $new_blog_post, __METHOD__)); diff --git a/src/Views/blogetc/captcha/basic.blade.php b/src/Views/binshopsblog/captcha/basic.blade.php similarity index 59% rename from src/Views/blogetc/captcha/basic.blade.php rename to src/Views/binshopsblog/captcha/basic.blade.php index 976ebe4..e3b9f79 100644 --- a/src/Views/blogetc/captcha/basic.blade.php +++ b/src/Views/binshopsblog/captcha/basic.blade.php @@ -1,6 +1,6 @@ <div class="form-group "> <label id="captcha_label" - for="captcha">Captcha: {{ config("blogetc.captcha.basic_question", "[error - undefined captcha question]" )}} </label> + for="captcha">Captcha: {{ config("binshopsblog.captcha.basic_question", "[error - undefined captcha question]" )}} </label> <input type='text' required class="form-control" name='captcha' id="captcha" placeholder="" value="{{old("captcha")}}"> </div> \ No newline at end of file diff --git a/src/Views/blogetc/index.blade.php b/src/Views/binshopsblog/index.blade.php similarity index 50% rename from src/Views/blogetc/index.blade.php rename to src/Views/binshopsblog/index.blade.php index 75a254c..0483be3 100755 --- a/src/Views/blogetc/index.blade.php +++ b/src/Views/binshopsblog/index.blade.php @@ -1,17 +1,17 @@ @extends("layouts.app",['title'=>$title]) @section('blog-custom-css') - <link type="text/css" href="{{ asset('hessam-blog.css') }}" rel="stylesheet"> + <link type="text/css" href="{{ asset('binshops-blog.css') }}" rel="stylesheet"> @endsection @section("content") - <div class='col-sm-12 blogetc_container'> - @if(\Auth::check() && \Auth::user()->canManageBlogEtcPosts()) + <div class='col-sm-12 binshopsblog_container'> + @if(\Auth::check() && \Auth::user()->canManageBinshopsBlogPosts()) <div class="text-center"> <p class='mb-1'>You are logged in as a blog admin user. <br> - <a href='{{route("blogetc.admin.index")}}' + <a href='{{route("binshopsblog.admin.index")}}' class='btn border btn-outline-primary btn-sm '> <i class="fa fa-cogs" aria-hidden="true"></i> Go To Blog Admin Panel</a> @@ -27,8 +27,8 @@ class='btn border btn-outline-primary btn-sm '> <div class="row"> <div class="col-md-12"> @forelse($category_chain as $cat) - / <a href="{{$cat->url()}}"> - <span class="cat1">{{$cat->category_name}}</span> + / <a href="{{$cat->categoryTranslations[0]->url($locale)}}"> + <span class="cat1">{{$cat->categoryTranslations[0]['category_name']}}</span> </a> @empty @endforelse </div> @@ -36,11 +36,11 @@ class='btn border btn-outline-primary btn-sm '> </div> @endif - @if(isset($blogetc_category) && $blogetc_category) - <h2 class='text-center'> {{$blogetc_category->category_name}}</h2> + @if(isset($binshopsblog_category) && $binshopsblog_category) + <h2 class='text-center'> {{$binshopsblog_category->category_name}}</h2> - @if($blogetc_category->category_description) - <p class='text-center'>{{$blogetc_category->category_description}}</p> + @if($binshopsblog_category->category_description) + <p class='text-center'>{{$binshopsblog_category->category_description}}</p> @endif @endif @@ -48,7 +48,7 @@ class='btn border btn-outline-primary btn-sm '> <div class="container"> <div class="row"> @forelse($posts as $post) - @include("blogetc::partials.index_loop") + @include("binshopsblog::partials.index_loop") @empty <div class="col-md-12"> <div class='alert alert-danger'>No posts!</div> @@ -59,24 +59,32 @@ class='btn border btn-outline-primary btn-sm '> </div> <div class="col-md-3"> <h6>Blog Categories</h6> - @forelse($categories as $category) - <a href="{{$category->url()}}"> - <h6>{{$category->category_name}}</h6> - </a> - @empty - <a href="#"> - <h6>No Categories</h6> - </a> - @endforelse + <ul class="binshops-cat-hierarchy"> + @if($categories) + @include("binshopsblog::partials._category_partial", [ + 'category_tree' => $categories, + 'name_chain' => $nameChain = "", + 'routeWithoutLocale' => $routeWithoutLocale + ]) + @else + <span>No Categories</span> + @endif + </ul> </div> </div> - <div class='text-center col-sm-4 mx-auto'> - {{$posts->appends( [] )->links()}} - </div> - @if (config('blogetc.search.search_enabled') ) - @include('blogetc::sitewide.search_form') + @if (config('binshopsblog.search.search_enabled') ) + @include('binshopsblog::sitewide.search_form') @endif + <div class="row"> + <div class="col-md-12 text-center"> + @foreach($lang_list as $lang) + <a href="{{route("binshopsblog.index" , $lang->locale)}}"> + <span>{{$lang->name}}</span> + </a> + @endforeach + </div> + </div> </div> @endsection diff --git a/src/Views/binshopsblog/partials/_category_partial.blade.php b/src/Views/binshopsblog/partials/_category_partial.blade.php new file mode 100644 index 0000000..7cb577f --- /dev/null +++ b/src/Views/binshopsblog/partials/_category_partial.blade.php @@ -0,0 +1,24 @@ +@foreach($category_tree as $category) + @php $trans = $category->categoryTranslations->where('lang_id',$lang_id)->first();@endphp + @if($trans != null) + <li class="category-item-wrapper"> + @php $nameChain = $nameChain .'/'. $trans->slug @endphp + + <a href="{{ $routeWithoutLocale ? route("binshopsblog.view_category",["", $nameChain]) : route("binshopsblog.view_category",[$locale, $nameChain])}}"> + <span class="category-item" value='{{$category->category_id}}'> + {{$trans->category_name}} + + @if( count($category->siblings) > 0) + <ul> + @include("binshopsblog::partials._category_partial", [ + 'category_tree' => $category->siblings, + 'name_chain' => $nameChain, + 'routeWithoutLocale' => $routeWithoutLocale + ]) + </ul> + @endif + </span> + </a> + </li> + @endif +@endforeach diff --git a/src/Views/blogetc/partials/add_comment_form.blade.php b/src/Views/binshopsblog/partials/add_comment_form.blade.php similarity index 89% rename from src/Views/blogetc/partials/add_comment_form.blade.php rename to src/Views/binshopsblog/partials/add_comment_form.blade.php index 7b045b0..97a49f2 100644 --- a/src/Views/blogetc/partials/add_comment_form.blade.php +++ b/src/Views/binshopsblog/partials/add_comment_form.blade.php @@ -1,6 +1,6 @@ <div class='add_comment_area'> <h5 class='text-center'>Add a comment</h5> - <form method='post' action='{{route("blogetc.comments.add_new_comment", $post->slug)}}'> + <form method='post' action='{{route("binshopsblog.comments.add_new_comment",[app('request')->get('locale'),$post->slug])}}'> @csrf @@ -21,7 +21,7 @@ class="form-control" <div class='container-fluid'> <div class='row'> - @if(config("blogetc.comments.save_user_id_if_logged_in", true) == false || !\Auth::check()) + @if(config("binshopsblog.comments.save_user_id_if_logged_in", true) == false || !\Auth::check()) <div class='col'> <div class="form-group "> @@ -37,7 +37,7 @@ class="form-control" </div> </div> - @if(config("blogetc.comments.ask_for_author_email")) + @if(config("binshopsblog.comments.ask_for_author_email")) <div class='col'> <div class="form-group"> <label id="author_email_label" for="author_email">Your Email @@ -57,7 +57,7 @@ class="form-control" @endif - @if(config("blogetc.comments.ask_for_author_website")) + @if(config("binshopsblog.comments.ask_for_author_website")) <div class='col'> <div class="form-group"> <label id="author_website_label" for="author_website">Your Website diff --git a/src/Views/blogetc/partials/author.blade.php b/src/Views/binshopsblog/partials/author.blade.php similarity index 100% rename from src/Views/blogetc/partials/author.blade.php rename to src/Views/binshopsblog/partials/author.blade.php diff --git a/src/Views/blogetc/partials/built_in_comments.blade.php b/src/Views/binshopsblog/partials/built_in_comments.blade.php similarity index 70% rename from src/Views/blogetc/partials/built_in_comments.blade.php rename to src/Views/binshopsblog/partials/built_in_comments.blade.php index e0c2785..89b5244 100644 --- a/src/Views/blogetc/partials/built_in_comments.blade.php +++ b/src/Views/binshopsblog/partials/built_in_comments.blade.php @@ -6,7 +6,7 @@ <div class="card-header"> {{$comment->author()}} - @if(config("blogetc.comments.ask_for_author_website") && $comment->author_website) + @if(config("binshopsblog.comments.ask_for_author_website") && $comment->author_website) (<a href='{{$comment->author_website}}' target='_blank' rel='noopener'>website</a>) @endif @@ -25,8 +25,8 @@ <div class='alert alert-info'>No comments yet! Why don't you be the first?</div> @endforelse -@if(count($comments)> config("blogetc.comments.max_num_of_comments_to_show",500) - 1) - <p><em>Only the first {{config("blogetc.comments.max_num_of_comments_to_show",500)}} comments are +@if(count($comments)> config("binshopsblog.comments.max_num_of_comments_to_show",500) - 1) + <p><em>Only the first {{config("binshopsblog.comments.max_num_of_comments_to_show",500)}} comments are shown.</em> </p> @endif diff --git a/src/Views/blogetc/partials/cat_snippet.blade.php b/src/Views/binshopsblog/partials/cat_snippet.blade.php similarity index 100% rename from src/Views/blogetc/partials/cat_snippet.blade.php rename to src/Views/binshopsblog/partials/cat_snippet.blade.php diff --git a/src/Views/binshopsblog/partials/categories.blade.php b/src/Views/binshopsblog/partials/categories.blade.php new file mode 100644 index 0000000..285bcf6 --- /dev/null +++ b/src/Views/binshopsblog/partials/categories.blade.php @@ -0,0 +1,7 @@ +<div class=''> + @foreach($categories as $category) + <a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->categoryTranslations[0]->url($locale, $routeWithoutLocale)}}'> + {{$category->categoryTranslations[0]->category_name}} + </a> + @endforeach +</div> diff --git a/src/Views/blogetc/partials/custom_comments.blade.php b/src/Views/binshopsblog/partials/custom_comments.blade.php similarity index 60% rename from src/Views/blogetc/partials/custom_comments.blade.php rename to src/Views/binshopsblog/partials/custom_comments.blade.php index d15684c..9c586c0 100644 --- a/src/Views/blogetc/partials/custom_comments.blade.php +++ b/src/Views/binshopsblog/partials/custom_comments.blade.php @@ -1,5 +1,5 @@ <div class='alert alert-danger'> error! custom_comments: You must customise this by creating a file in - /resources/views/vendor/blogetc/partials/custom_comments.blade.php + /resources/views/vendor/binshopsblog/partials/custom_comments.blade.php </div> diff --git a/src/Views/blogetc/partials/disqus_comments.blade.php b/src/Views/binshopsblog/partials/disqus_comments.blade.php similarity index 82% rename from src/Views/blogetc/partials/disqus_comments.blade.php rename to src/Views/binshopsblog/partials/disqus_comments.blade.php index ab965b5..f8332ec 100644 --- a/src/Views/blogetc/partials/disqus_comments.blade.php +++ b/src/Views/binshopsblog/partials/disqus_comments.blade.php @@ -2,7 +2,7 @@ <script> /** - * RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS. + * RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR Blog. * LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/ var disqus_config = function () { this.page.url = "{{$post->url()}}"; // Replace PAGE_URL with your page's canonical URL variable @@ -10,9 +10,9 @@ }; (function() { // DON'T EDIT BELOW THIS LINE var d = document, s = d.createElement('script'); - s.src = '{{config("blogetc.comments.disqus.src_url","ENTER YOUR URL HERE!!!")}}'; + s.src = '{{config("binshopsblog.comments.disqus.src_url","ENTER YOUR URL HERE!!!")}}'; s.setAttribute('data-timestamp', +new Date()); (d.head || d.body).appendChild(s); })(); </script> -<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus</a>, and run by <a href='https://webdevetc.com/'>WebDevEtc's BlogEtc Laravel Blog package</a></noscript> \ No newline at end of file +<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus</a>, and run by <a href='https://binshops.com/'>BinshopsBlog Laravel Blog package</a></noscript> diff --git a/src/Views/blogetc/partials/full_post_details.blade.php b/src/Views/binshopsblog/partials/full_post_details.blade.php similarity index 58% rename from src/Views/blogetc/partials/full_post_details.blade.php rename to src/Views/binshopsblog/partials/full_post_details.blade.php index 81d97e5..cada8aa 100644 --- a/src/Views/blogetc/partials/full_post_details.blade.php +++ b/src/Views/binshopsblog/partials/full_post_details.blade.php @@ -1,4 +1,4 @@ -@if(\Auth::check() && \Auth::user()->canManageBlogEtcPosts()) +@if(\Auth::check() && \Auth::user()->canManageBinshopsBlogPosts()) <a href="{{$post->edit_url()}}" class="btn btn-outline-secondary btn-sm pull-right float-right">Edit Post</a> @endif @@ -12,9 +12,9 @@ <p class="blog_body_content"> {!! $post->post_body_output() !!} - {{--@if(config("blogetc.use_custom_view_files") && $post->use_view_file)--}} + {{--@if(config("binshopsblog.use_custom_view_files") && $post->use_view_file)--}} {{-- // use a custom blade file for the output of those blog post--}} - {{-- @include("blogetc::partials.use_view_file")--}} + {{-- @include("binshopsblog::partials.use_view_file")--}} {{--@else--}} {{-- {!! $post->post_body !!} // unsafe, echoing the plain html/js--}} {{-- {{ $post->post_body }} // for safe escaping --}} @@ -23,7 +23,7 @@ <hr/> -Posted <strong>{{$post->posted_at->diffForHumans()}}</strong> +Posted <strong>{{$post->post->posted_at->diffForHumans()}}</strong> -@includeWhen($post->author,"blogetc::partials.author",['post'=>$post]) -@includeWhen($post->categories,"blogetc::partials.categories",['post'=>$post]) +@includeWhen($post->post->author,"binshopsblog::partials.author",['post'=>$post->post]) +@includeWhen($categories,"binshopsblog::partials.categories",['categories'=>$categories]) diff --git a/src/Views/blogetc/partials/index_loop.blade.php b/src/Views/binshopsblog/partials/index_loop.blade.php similarity index 54% rename from src/Views/blogetc/partials/index_loop.blade.php rename to src/Views/binshopsblog/partials/index_loop.blade.php index 1dcd6aa..4e4c44b 100644 --- a/src/Views/blogetc/partials/index_loop.blade.php +++ b/src/Views/binshopsblog/partials/index_loop.blade.php @@ -1,6 +1,5 @@ {{--Used on the index page (so shows a small summary--}} -{{--See the guide on webdevetc.com for how to copy these files to your /resources/views/ directory--}} -{{--https://webdevetc.com/laravel/packages/blogetc-blog-system-for-your-laravel-app/help-documentation/laravel-blog-package-blogetc#guide_to_views--}} +{{--See the guide on binshops.com for how to copy these files to your /resources/views/ directory--}} <div class="col-md-6"> <div class="blog-item"> @@ -9,22 +8,22 @@ <?=$post->image_tag("medium", true, ''); ?> </div> <div class="blog-inner-item"> - <h3 class=''><a href='{{$post->url()}}'>{{$post->title}}</a></h3> + <h3 class=''><a href='{{$post->url($locale, $routeWithoutLocale)}}'>{{$post->title}}</a></h3> <h5 class=''>{{$post->subtitle}}</h5> - @if (config('blogetc.show_full_text_at_list')) + @if (config('binshopsblog.show_full_text_at_list')) <p>{!! $post->post_body_output() !!}</p> @else <p>{!! mb_strimwidth($post->post_body_output(), 0, 400, "...") !!}</p> @endif <div class="post-details-bottom"> - <span class="light-text">Authored by: </span> {{$post->author->name}} <span class="light-text">Posted at: </span> {{date('d M Y ', strtotime($post->posted_at))}} + <span class="light-text">Authored by: </span> {{$post->post->author->name}} <span class="light-text">Posted at: </span> {{date('d M Y ', strtotime($post->post->posted_at))}} </div> <div class='text-center'> - <a href="{{$post->url()}}" class="btn btn-primary">View Post</a> + <a href="{{$post->url($locale, $routeWithoutLocale)}}" class="btn btn-primary">View Post</a> </div> </div> </div> -</div> \ No newline at end of file +</div> diff --git a/src/Views/blogetc/partials/search_form.blade.php b/src/Views/binshopsblog/partials/search_form.blade.php similarity index 50% rename from src/Views/blogetc/partials/search_form.blade.php rename to src/Views/binshopsblog/partials/search_form.blade.php index f5579e0..5d671f5 100644 --- a/src/Views/blogetc/partials/search_form.blade.php +++ b/src/Views/binshopsblog/partials/search_form.blade.php @@ -1,4 +1,4 @@ {{--This is only included for backwards compatibility. It will be removed at a future stage.--}} -@if (config('blogetc.search.search_enabled') ) - @include('blogetc::sitewide.search_form') +@if (config('binshopsblog.search.search_enabled') ) + @include('binshopsblog::sitewide.search_form') @endif \ No newline at end of file diff --git a/src/Views/blogetc/partials/show_comments.blade.php b/src/Views/binshopsblog/partials/show_comments.blade.php similarity index 64% rename from src/Views/blogetc/partials/show_comments.blade.php rename to src/Views/binshopsblog/partials/show_comments.blade.php index 2ea555f..313bb9e 100644 --- a/src/Views/blogetc/partials/show_comments.blade.php +++ b/src/Views/binshopsblog/partials/show_comments.blade.php @@ -1,20 +1,20 @@ -@switch(config("blogetc.comments.type_of_comments_to_show","built_in")) +@switch(config("binshopsblog.comments.type_of_comments_to_show","built_in")) @case("built_in") {{-- default - show our own comments--}} -@include("blogetc::partials.built_in_comments") -@include("blogetc::partials.add_comment_form") +@include("binshopsblog::partials.built_in_comments") +@include("binshopsblog::partials.add_comment_form") @break @case("disqus") {{--use disqus--}} -@include("blogetc::partials.disqus_comments") +@include("binshopsblog::partials.disqus_comments") @break @case("custom") {{--use custom - you should create the custom_comments in your vendor view dir and customise it--}} -@include("blogetc::partials.custom_comments") +@include("binshopsblog::partials.custom_comments") @break @case("disabled") diff --git a/src/Views/blogetc/partials/show_errors.blade.php b/src/Views/binshopsblog/partials/show_errors.blade.php similarity index 100% rename from src/Views/blogetc/partials/show_errors.blade.php rename to src/Views/binshopsblog/partials/show_errors.blade.php diff --git a/src/Views/blogetc/partials/use_view_file.blade.php b/src/Views/binshopsblog/partials/use_view_file.blade.php similarity index 73% rename from src/Views/blogetc/partials/use_view_file.blade.php rename to src/Views/binshopsblog/partials/use_view_file.blade.php index 420c850..6f89734 100644 --- a/src/Views/blogetc/partials/use_view_file.blade.php +++ b/src/Views/binshopsblog/partials/use_view_file.blade.php @@ -8,16 +8,16 @@ {{--uh oh! the view file wasn't there. Show a detailed error if user is logged in and can manage the blog, otherwise show generic error.--}} - @if(\Auth::check() && \Auth::user()->canManageBlogEtcPosts()) - {{--is logged in + canManageBlogEtcPosts() == true, so show a detailed error--}} + @if(\Auth::check() && \Auth::user()->canManageBinshopsBlogPosts()) + {{--is logged in + canManageBinshopsBlogPosts() == true, so show a detailed error--}} <div class='alert alert-danger'>Custom blog post blade view file (<code>{{$post->full_view_file_path()}}</code>) not found. <a - href='https://webdevetc.com/laravel/packages/help-documentation/laravel-blog-package-blogetc' + href='https://github.com/binshops/laravel-blog' target='_blank'>See Laravel Blog Package help here</a>. </div> @else - {{--is not logged in, or User::canManageBlogEtcPosts() for current user == false--}} + {{--is not logged in, or User::canManageBinshopsBlogPosts() for current user == false--}} {{--show basic error message--}} <div class='alert alert-danger'>Sorry, but there is an error showing that blog post. Please come back later.</div> @endif diff --git a/src/Views/blogetc/saved_comment.blade.php b/src/Views/binshopsblog/saved_comment.blade.php similarity index 59% rename from src/Views/blogetc/saved_comment.blade.php rename to src/Views/binshopsblog/saved_comment.blade.php index dd72136..59cc977 100755 --- a/src/Views/blogetc/saved_comment.blade.php +++ b/src/Views/binshopsblog/saved_comment.blade.php @@ -4,11 +4,11 @@ <div class='text-center'> <h3>Thanks! Your comment has been saved!</h3> - @if(!config("blogetc.comments.auto_approve_comments",false) ) + @if(!config("binshopsblog.comments.auto_approve_comments",false) ) <p>After an admin user approves the comment, it'll appear on the site!</p> @endif - <a href='{{$blog_post->url()}}' class='btn btn-primary'>Back to blog post</a> + <a href='{{$blog_post->url(app('request')->get('locale'))}}' class='btn btn-primary'>Back to blog post</a> </div> @endsection \ No newline at end of file diff --git a/src/Views/blogetc/search.blade.php b/src/Views/binshopsblog/search.blade.php similarity index 62% rename from src/Views/blogetc/search.blade.php rename to src/Views/binshopsblog/search.blade.php index 98abe55..6bb266e 100755 --- a/src/Views/blogetc/search.blade.php +++ b/src/Views/binshopsblog/search.blade.php @@ -12,9 +12,9 @@ @if(isset($result->indexable)) @php $search_count += $search_count + 1; @endphp <?php $post = $result->indexable; ?> - @if($post && is_a($post,\WebDevEtc\BlogEtc\Models\BlogEtcPost::class)) + @if($post && is_a($post,\BinshopsBlog\Models\BinshopsPostTranslation::class)) <h2>Search result #{{$search_count}}</h2> - @include("blogetc::partials.index_loop") + @include("binshopsblog::partials.index_loop") @else <div class='alert alert-danger'>Unable to show this search result - unknown type</div> @@ -26,24 +26,25 @@ </div> <div class="col-md-3"> <h6>Blog Categories</h6> - @forelse($categories as $category) - <a href="{{$category->url()}}"> - <h6>{{$category->category_name}}</h6> - </a> - @empty - <a href="#"> - <h6>No Categories</h6> - </a> - @endforelse + <ul class="binshops-cat-hierarchy"> + @if($categories) + @include("binshopsblog::partials._category_partial", [ + 'category_tree' => $categories, + 'name_chain' => $nameChain = "" + ]) + @else + <span>No Categories</span> + @endif + </ul> </div> </div> - @if (config('blogetc.search.search_enabled') ) - @include('blogetc::sitewide.search_form') + @if (config('binshopsblog.search.search_enabled') ) + @include('binshopsblog::sitewide.search_form') @endif </div> </div> -@endsection \ No newline at end of file +@endsection diff --git a/src/Views/binshopsblog/single_post.blade.php b/src/Views/binshopsblog/single_post.blade.php new file mode 100755 index 0000000..2e3f5a1 --- /dev/null +++ b/src/Views/binshopsblog/single_post.blade.php @@ -0,0 +1,43 @@ +@extends("layouts.app",['title'=>$post->gen_seo_title()]) + +@section('blog-custom-css') + <link type="text/css" href="{{ asset('binshops-blog.css') }}" rel="stylesheet"> +@endsection + +@section("content") + + @if(config("binshopsblog.reading_progress_bar")) + <div id="scrollbar"> + <div id="scrollbar-bg"></div> + </div> + @endif + + {{--https://github.com/binshops/laravel-blog--}} + + <div class='container'> + <div class='row'> + <div class='col-sm-12 col-md-12 col-lg-12'> + + @include("binshopsblog::partials.show_errors") + @include("binshopsblog::partials.full_post_details") + + + @if(config("binshopsblog.comments.type_of_comments_to_show","built_in") !== 'disabled') + <div class="" id='maincommentscontainer'> + <h2 class='text-center' id='binshopsblogcomments'>Comments</h2> + @include("binshopsblog::partials.show_comments") + </div> + @else + {{--Comments are disabled--}} + @endif + + + </div> + </div> + </div> + +@endsection + +@section('blog-custom-js') + <script src="{{asset('binshops-blog.js')}}"></script> +@endsection diff --git a/src/Views/blogetc/sitewide/random_posts.blade.php b/src/Views/binshopsblog/sitewide/random_posts.blade.php similarity index 65% rename from src/Views/blogetc/sitewide/random_posts.blade.php rename to src/Views/binshopsblog/sitewide/random_posts.blade.php index 505781b..cd5a0c2 100644 --- a/src/Views/blogetc/sitewide/random_posts.blade.php +++ b/src/Views/binshopsblog/sitewide/random_posts.blade.php @@ -1,6 +1,6 @@ <h5>Random Posts</h5> <ul class="nav"> - @foreach(\WebDevEtc\BlogEtc\Models\BlogEtcPost::inRandomOrder()->limit(5)->get() as $post) + @foreach(\BinshopsBlog\Models\BinshopsPost::inRandomOrder()->limit(5)->get() as $post) <li class="nav-item"> <a class='nav-link' href='{{$post->url()}}'>{{$post->title}}</a> </li> diff --git a/src/Views/blogetc/sitewide/recent_posts.blade.php b/src/Views/binshopsblog/sitewide/recent_posts.blade.php similarity index 62% rename from src/Views/blogetc/sitewide/recent_posts.blade.php rename to src/Views/binshopsblog/sitewide/recent_posts.blade.php index cd3935f..4f1e54b 100644 --- a/src/Views/blogetc/sitewide/recent_posts.blade.php +++ b/src/Views/binshopsblog/sitewide/recent_posts.blade.php @@ -1,6 +1,6 @@ <h5>Recent Posts</h5> <ul class="nav"> - @foreach(\WebDevEtc\BlogEtc\Models\BlogEtcPost::orderBy("posted_at","desc")->limit(5)->get() as $post) + @foreach(\BinshopsBlog\Models\BinshopsPost::orderBy("posted_at","desc")->limit(5)->get() as $post) <li class="nav-item"> <a class='nav-link' href='{{$post->url()}}'>{{$post->title}}</a> </li> diff --git a/src/Views/blogetc/sitewide/search_form.blade.php b/src/Views/binshopsblog/sitewide/search_form.blade.php similarity index 73% rename from src/Views/blogetc/sitewide/search_form.blade.php rename to src/Views/binshopsblog/sitewide/search_form.blade.php index a7c865d..d845cc9 100644 --- a/src/Views/blogetc/sitewide/search_form.blade.php +++ b/src/Views/binshopsblog/sitewide/search_form.blade.php @@ -1,5 +1,5 @@ <div style='max-width:500px;margin:50px auto;' class='search-form-outer'> - <form method='get' action='{{route("blogetc.search")}}' class='text-center'> + <form method='get' action='{{route("binshopsblog.search", app('request')->get('locale'))}}' class='text-center'> <h4>Search for something in our blog:</h4> <input type='text' name='s' placeholder='Search...' class='form-control' value='{{\Request::get("s")}}'> <input type='submit' value='Search' class='btn btn-primary m-2'> diff --git a/src/Views/blogetc/sitewide/show_all_categories.blade.php b/src/Views/binshopsblog/sitewide/show_all_categories.blade.php similarity index 63% rename from src/Views/blogetc/sitewide/show_all_categories.blade.php rename to src/Views/binshopsblog/sitewide/show_all_categories.blade.php index a4e2286..0cb3a22 100644 --- a/src/Views/blogetc/sitewide/show_all_categories.blade.php +++ b/src/Views/binshopsblog/sitewide/show_all_categories.blade.php @@ -1,6 +1,6 @@ <h5>Post Categories</h5> <ul class="nav"> - @foreach(\WebDevEtc\BlogEtc\Models\BlogEtcCategory::orderBy("category_name")->limit(200)->get() as $category) + @foreach(\BinshopsBlog\Models\BinshopsCategory::orderBy("category_name")->limit(200)->get() as $category) <li class="nav-item"> <a class='nav-link' href='{{$category->url()}}'>{{$category->category_name}}</a> </li> diff --git a/src/Views/binshopsblog_admin/categories/_category_partial.blade.php b/src/Views/binshopsblog_admin/categories/_category_partial.blade.php new file mode 100644 index 0000000..d65a1da --- /dev/null +++ b/src/Views/binshopsblog_admin/categories/_category_partial.blade.php @@ -0,0 +1,17 @@ +@foreach($category_tree as $category) + @php + $ct = $category->categoryTranslations->where('lang_id', $language_id)->first(); + @endphp + @if(isset($ct)) + <li> + <span value='{{$category->category_id}}'> + {{$category->categoryTranslations->where('lang_id', $language_id)->first()->category_name}} + </span> + @if( count($category->siblings) > 0) + <ul> + @include("binshopsblog_admin::categories._category_partial", ['category_tree' => $category->siblings]) + </ul> + @endif + </li> + @endif +@endforeach diff --git a/src/Views/binshopsblog_admin/categories/add_category.blade.php b/src/Views/binshopsblog_admin/categories/add_category.blade.php new file mode 100755 index 0000000..60098f2 --- /dev/null +++ b/src/Views/binshopsblog_admin/categories/add_category.blade.php @@ -0,0 +1,191 @@ +@extends("binshopsblog_admin::layouts.admin_layout") +@section("content") + + <h5>Admin - Add Category</h5> + <form method='post' action='{{route("binshopsblog.admin.categories.create_category")}}' enctype="multipart/form-data" > + + @csrf + + <div class="form-group"> + <label for="language_list">Select Language</label> + <select id="language_list" name='lang_id' class='form-control'> + @foreach($language_list as $language) + <option value='{{$language->id}}' @if($language->id == $language_id)selected="selected" @endif> + {{$language->name}} + </option> + @endforeach + </select> + </div> + + <div class="form-group"> + <label for="category_category_name">Category Name</label> + + <input type="text" + class="form-control" + id="category_name" + oninput="populate_slug_field();" + required + aria-describedby="category_category_name_help" + name='category_name' + value="{{old("category_name",$category_translation->category_name)}}" + > + + <small id="category_category_name_help" class="form-text text-muted">The name of the category</small> + </div> + + + <div class="form-group"> + <label for="category_slug">Category slug</label> + <input + maxlength='100' + pattern="[a-zA-Z0-9-]+" + type="text" + required + class="form-control" + id="category_slug" + oninput="SHOULD_AUTO_GEN_SLUG=false;" + aria-describedby="category_slug_help" + name='slug' + value="{{old("slug",$category_translation->slug)}}" + > + + <small id="category_slug_help" class="form-text text-muted"> + Letters, numbers, dash only. The slug + i.e. {{route("binshopsblog.view_category",[app('request')->get('locale'),""])}}/<u><em>this_part</em></u>. This must be unique (two categories can't + share the same slug). + + </small> + </div> + + <div class="form-group"> + <label for="category_slug">Category Tree</label> + <ul class="wtree"> + @include("binshopsblog_admin::categories._category_partial", ['category_tree' => $cat_roots]) + </ul> + </div> + + <div class="form-group"> + <label for="category_slug">Parent Category</label> + <select id="parent_id" name='parent_id' class='form-control'> + <option selected='selected' value='0'> + Root + </option> + @foreach($category_tree as $category) + <option value='{{$category->categoryTranslations[0]['category_id']}}'> + {{$category->categoryTranslations[0]['category_name']}} + </option> + @endforeach + </select> + </div> + + <div class="form-group"> + <label for="category_description">Category Description (optional)</label> + <textarea name='category_description' + class='form-control' + id='category_description'>{{old("category_description",$category_translation->category_description)}}</textarea> + + </div> + + <button type="button" class='btn btn-primary' id="submit-btn">Add new category</button> + + <script> + SHOULD_AUTO_GEN_SLUG = false; + + /* Generate the slug field, if it was not touched by the user (or if it was an empty string) */ + function populate_slug_field() { + +// alert("A"); + var cat_slug = document.getElementById('category_slug'); + + if (cat_slug.value.length < 1) { + // if the slug field is empty, make sure it auto generates + SHOULD_AUTO_GEN_SLUG = true; + } + + if (SHOULD_AUTO_GEN_SLUG) { + // the slug hasn't been manually changed (or it was set above), so we should generate the slug + // This is done in two stages - one to remove non words/spaces etc, the another to replace white space (and underscore) with a - + cat_slug.value =document.getElementById("category_name").value.toLowerCase() + .replace(/[^\w-_ ]+/g, '') // replace with nothing + .replace(/[_ ]+/g, '-') // replace _ and spaces with - + .substring(0,99); // limit str length + + } + + } + + if (document.getElementById("category_slug").value.length < 1) { + SHOULD_AUTO_GEN_SLUG = true; + } else { + SHOULD_AUTO_GEN_SLUG = false; // there is already a value in #category_slug, so lets pretend it was changed already. + } + + + //multi-language data + var defalutLangId = {{$language_id}}; + var preLangId = defalutLangId; + var languageList = {}; + $("#language_list > option").each(function() { + languageList[this.value] = { + lang_id: -1, + category_name: "", + slug: "", + category_description: "", + lang_name: this.text + } + }); + + $('#language_list').on('change', function() { + fillLanguageList(this.value); + preLangId = this.value; + }); + + function fillLanguageList(langId){ + languageList[preLangId].lang_id = preLangId; + languageList[preLangId].category_name = $('#category_name').val(); + languageList[preLangId].slug = $('#category_slug').val(); + languageList[preLangId].category_description = $('#category_description').val(); + + $('#category_name').val(languageList[langId].category_name); + $('#category_slug').val(languageList[langId].slug); + $('#category_description').val(languageList[langId].category_description); + } + + $.ajaxSetup({ + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + } + }); + + $('#submit-btn').click(function (){ + if (languageList[$('#language_list').val()].lang_id == -1){ + if (!$('#category_name').val()){ + alert("Category name must not be empty"); + return ; + }else if (!$('#category_slug').val()){ + alert("Category slug must not be empty"); + return ; + } + languageList[preLangId].lang_id = $('#language_list').val(); + languageList[preLangId].category_name = $('#category_name').val(); + languageList[preLangId].slug = $('#category_slug').val(); + languageList[preLangId].category_description = $('#category_description').val(); + } + $.post('{{route("binshopsblog.admin.categories.store_category")}}' , + { + data: languageList, + parent_id: parseInt($('#parent_id').val()) + }, + function(data, status){ + if (data.code === 403){ + alert("Slug is already taken: " + languageList[data.data].lang_name); + }else if (data.code === 200) { + } + window.location.replace("{{route('binshopsblog.admin.categories.index')}}"); + }); + }); + + </script> + </form> + +@endsection diff --git a/src/Views/blogetc_admin/categories/edit_category.blade.php b/src/Views/binshopsblog_admin/categories/edit_category.blade.php similarity index 83% rename from src/Views/blogetc_admin/categories/edit_category.blade.php rename to src/Views/binshopsblog_admin/categories/edit_category.blade.php index d80658b..76174f7 100755 --- a/src/Views/blogetc_admin/categories/edit_category.blade.php +++ b/src/Views/binshopsblog_admin/categories/edit_category.blade.php @@ -1,10 +1,10 @@ -@extends("blogetc_admin::layouts.admin_layout") +@extends("binshopsblog_admin::layouts.admin_layout") @section("content") <h5>Admin - Edit Category</h5> - <form method='post' action='{{route("blogetc.admin.categories.edit_category",$category->id)}}' enctype="multipart/form-data" > + <form method='post' action='{{route("binshopsblog.admin.categories.edit_category",$category->id)}}' enctype="multipart/form-data" > @csrf @method("patch") @@ -45,7 +45,7 @@ class="form-control" required aria-describedby="category_category_name_help" name='category_name' - value="{{old("category_name",$category->category_name)}}" + value="{{old("category_name",$category_translation->category_name)}}" > <small id="category_category_name_help" class="form-text text-muted">The name of the category</small> @@ -64,12 +64,12 @@ class="form-control" oninput="SHOULD_AUTO_GEN_SLUG=false;" aria-describedby="category_slug_help" name='slug' - value="{{old("slug",$category->slug)}}" + value="{{old("slug",$category_translation->slug)}}" > <small id="category_slug_help" class="form-text text-muted"> Letters, numbers, dash only. The slug - i.e. {{route("blogetc.view_category","")}}/<u><em>this_part</em></u>. This must be unique (two categories can't + i.e. {{route("binshopsblog.view_category",[app('request')->get('locale'),""])}}/<u><em>this_part</em></u>. This must be unique (two categories can't share the same slug). </small> @@ -82,8 +82,8 @@ class="form-control" Root </option> @foreach($categories_list as $category2) - @if($category->id != $category2->id) - <option @if($category->parent_id == $category2->id) selected='selected' @endif value='{{$category2->id}}'> + @if($category->id != $category2->category_id) + <option @if($category->parent_id == $category2->category_id) selected='selected' @endif value='{{$category2->category_id}}'> {{$category2->category_name}} </option> @endif @@ -96,7 +96,7 @@ class="form-control" <label for="category_description">Category Description (optional)</label> <textarea name='category_description' class='form-control' - id='category_description'>{{old("category_description",$category->category_description)}}</textarea> + id='category_description'>{{old("category_description",$category_translation->category_description)}}</textarea> </div> diff --git a/src/Views/blogetc_admin/categories/form.blade.php b/src/Views/binshopsblog_admin/categories/form.blade.php similarity index 95% rename from src/Views/blogetc_admin/categories/form.blade.php rename to src/Views/binshopsblog_admin/categories/form.blade.php index 1bbc152..c4f4823 100755 --- a/src/Views/blogetc_admin/categories/form.blade.php +++ b/src/Views/binshopsblog_admin/categories/form.blade.php @@ -58,7 +58,7 @@ class="form-control" <small id="category_slug_help" class="form-text text-muted"> Letters, numbers, dash only. The slug - i.e. {{route("blogetc.view_category","")}}/<u><em>this_part</em></u>. This must be unique (two categories can't + i.e. {{route("binshopsblog.view_category",[app('request')->get('locale'),""])}}/<u><em>this_part</em></u>. This must be unique (two categories can't share the same slug). </small> diff --git a/src/Views/blogetc_admin/categories/index.blade.php b/src/Views/binshopsblog_admin/categories/index.blade.php similarity index 64% rename from src/Views/blogetc_admin/categories/index.blade.php rename to src/Views/binshopsblog_admin/categories/index.blade.php index 448a723..7410836 100755 --- a/src/Views/blogetc_admin/categories/index.blade.php +++ b/src/Views/binshopsblog_admin/categories/index.blade.php @@ -1,20 +1,20 @@ -@extends("blogetc_admin::layouts.admin_layout") +@extends("binshopsblog_admin::layouts.admin_layout") @section("content") @forelse ($categories as $category) <div class="card m-4"> <div class="card-body"> - <h5 class='card-title'><a class="a-link-cart-color" href='{{$category->url()}}'>{{$category->category_name}}</a></h5> + <h5 class='card-title'><a class="a-link-cart-color" href='{{$category->url(app('request')->get('locale'))}}'>{{$category->category_name}}</a></h5> - <a href="{{$category->url()}}" class="card-link btn btn-outline-secondary">View Posts in this category</a> + <a href="{{$category->url(app('request')->get('locale'))}}" class="card-link btn btn-outline-secondary">View Posts in this category</a> <a href="{{$category->edit_url()}}" class="card-link btn btn-primary">Edit Category</a> <form onsubmit="return confirm('Are you sure you want to delete this blog post category?\n You cannot undo this action!');" - method='post' action='{{route("blogetc.admin.categories.destroy_category", $category->id)}}' class='float-right'> + method='post' action='{{route("binshopsblog.admin.categories.destroy_category", $category->category_id)}}' class='float-right'> @csrf @method("DELETE") <input type='submit' class='btn btn-danger btn-sm' value='Delete'/> @@ -32,4 +32,4 @@ {{$categories->appends( [] )->links()}} </div> - @endsection \ No newline at end of file + @endsection diff --git a/src/Views/blogetc_admin/comments/index.blade.php b/src/Views/binshopsblog_admin/comments/index.blade.php similarity index 62% rename from src/Views/blogetc_admin/comments/index.blade.php rename to src/Views/binshopsblog_admin/comments/index.blade.php index ead49a6..7ed1462 100755 --- a/src/Views/blogetc_admin/comments/index.blade.php +++ b/src/Views/binshopsblog_admin/comments/index.blade.php @@ -1,49 +1,35 @@ -@extends("blogetc_admin::layouts.admin_layout") +@extends("binshopsblog_admin::layouts.admin_layout") @section("content") @forelse ($comments as $comment) <div class="card m-4" > <div class="card-body"> - <h5 class='card-title'> - - {{$comment->author()}} commented on: @if($comment->post) - <a class="a-link-cart-color" href='{{$comment->post->url()}}'>{{$comment->post->title}}</a> - @else + <a class="a-link-cart-color" href='{{$comment->post->postTranslations()->get()[0]->url(app('request')->get('locale'))}}'>{{$comment->post->title}}</a> + @else Unknown blog post - - @endif + @endif on {{$comment->created_at}} </h5> - - <p class='m-3 p-2'>{{$comment->comment}}</p> - - - @if($comment->post) - {{--VIEW + EDIT POST LINKS--}} - <a href="{{$comment->post->url()}}" class="card-link btn btn-outline-secondary"><i class="fa fa-file-text-o" - aria-hidden="true"></i> + <a href='{{$comment->post->postTranslations()->get()[0]->url(app('request')->get('locale'))}}' class="card-link btn btn-outline-secondary"><i class="fa fa-file-text-o" + aria-hidden="true"></i> View Post</a> - <a href="{{$comment->post->edit_url()}}" class="card-link btn btn-primary"> + <a href='{{$comment->post->postTranslations()->get()[0]->edit_url()}}' class="card-link btn btn-primary"> <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit Post</a> - - @endif - - @if(!$comment->approved) {{--APPROVE BUTTON--}} - <form method='post' action='{{route("blogetc.admin.comments.approve", $comment->id)}}' class='float-right'> + <form method='post' action='{{route("binshopsblog.admin.comments.approve", $comment->id)}}' class='float-right'> @csrf @method("PATCH") <input type='submit' class='btn btn-success btn-sm' value='Approve'/> @@ -53,7 +39,7 @@ {{--DELETE BUTTON--}} <form onsubmit="return confirm('Are you sure you want to delete this blog post comment?\n You cannot undo this action!');" - method='post' action='{{route("blogetc.admin.comments.delete", $comment->id)}}' class='float-right'> + method='post' action='{{route("binshopsblog.admin.comments.delete", $comment->id)}}' class='float-right'> @csrf @method("DELETE") <input type='submit' class='btn btn-danger btn-sm' value='Delete'/> @@ -61,14 +47,12 @@ </div> </div> - @empty <div class='alert alert-danger'>None found</div> @endforelse - <div class='text-center'> {{$comments->appends( [] )->links()}} </div> -@endsection \ No newline at end of file +@endsection diff --git a/src/Views/blogetc_admin/imageupload/create.blade.php b/src/Views/binshopsblog_admin/imageupload/create.blade.php similarity index 75% rename from src/Views/blogetc_admin/imageupload/create.blade.php rename to src/Views/binshopsblog_admin/imageupload/create.blade.php index b2803fc..3d1f80f 100644 --- a/src/Views/blogetc_admin/imageupload/create.blade.php +++ b/src/Views/binshopsblog_admin/imageupload/create.blade.php @@ -1,4 +1,4 @@ -@extends("blogetc_admin::layouts.admin_layout") +@extends("binshopsblog_admin::layouts.admin_layout") @section("content") @@ -7,7 +7,7 @@ <p>You can use this to upload images.</p> - <form method='post' action='{{route("blogetc.admin.images.store")}}' enctype="multipart/form-data"> + <form method='post' action='{{route("binshopsblog.admin.images.store")}}' enctype="multipart/form-data"> @csrf @@ -37,12 +37,12 @@ <label >Sizes to convert to</label> <div> - <input type='checkbox' name='sizes_to_upload[blogetc_full_size]' value='true' checked id='size_blogetc_full_size'> - <label for='size_blogetc_full_size'>Full size (no resizing)</label> + <input type='checkbox' name='sizes_to_upload[binshopsblog_full_size]' value='true' checked id='size_binshopsblog_full_size'> + <label for='size_binshopsblog_full_size'>Full size (no resizing)</label> </div> - @foreach((array)config('blogetc.image_sizes') as $size => $image_size_details) + @foreach((array)config('binshopsblog.image_sizes') as $size => $image_size_details) <div> <input type='checkbox' name='sizes_to_upload[{{$size}}]' value='true' checked id='size_{{$size}}'> <label for='size_{{$size}}'>{{$image_size_details['name']}} - {{$image_size_details['w']}} x {{$image_size_details['h']}}px</label> diff --git a/src/Views/blogetc_admin/imageupload/index.blade.php b/src/Views/binshopsblog_admin/imageupload/index.blade.php similarity index 88% rename from src/Views/blogetc_admin/imageupload/index.blade.php rename to src/Views/binshopsblog_admin/imageupload/index.blade.php index fc516a0..d7ef5a6 100644 --- a/src/Views/blogetc_admin/imageupload/index.blade.php +++ b/src/Views/binshopsblog_admin/imageupload/index.blade.php @@ -1,4 +1,4 @@ -@extends("blogetc_admin::layouts.admin_layout") +@extends("binshopsblog_admin::layouts.admin_layout") @section("content") @@ -46,11 +46,11 @@ function show_uploaded_file_row(id, img) { <h6 class='text-center mt-3'><strong>{{$file_key}}</strong> - {{$file['w']}} x {{$file['h']}}:</h6> <p class='text-center'><a - href='{{asset( config("blogetc.blog_upload_dir") . "/". $file['filename'])}}' + href='{{asset( config("binshopsblog.blog_upload_dir") . "/". $file['filename'])}}' target='_blank'>[link]</a> / <span class='btn btn-sm btn-primary' style='cursor: zoom-in;' - onclick='show_uploaded_file_row("{{$id}}","{{asset( config("blogetc.blog_upload_dir") . "/". $file['filename'])}}")'>show</span> + onclick='show_uploaded_file_row("{{$id}}","{{asset( config("binshopsblog.blog_upload_dir") . "/". $file['filename'])}}")'>show</span> </p> <div id="{{$id}}"></div> @@ -59,7 +59,7 @@ class='btn btn-sm btn-primary' <div style=''> <small class='text-muted'>Image URL</small> <input type='text' readonly='readonly' class='form-control' - value='{{asset( config("blogetc.blog_upload_dir") . "/". $file['filename'])}}'> + value='{{asset( config("binshopsblog.blog_upload_dir") . "/". $file['filename'])}}'> </div> </div> <div class='col-md-6 {{$id}}' style='display:none;'> @@ -67,7 +67,7 @@ class='btn btn-sm btn-primary' <div style=''> <small class='text-muted'>img tag</small> <input type='text' readonly='readonly' class='form-control' - value='{{"<img src='".asset( config("blogetc.blog_upload_dir") . "/". $file['filename'])."' alt='" . e($uploadedPhoto->image_title) . "' >"}}'> + value='{{"<img src='".asset( config("binshopsblog.blog_upload_dir") . "/". $file['filename'])."' alt='" . e($uploadedPhoto->image_title) . "' >"}}'> </div> </div> @@ -89,9 +89,9 @@ class='btn btn-sm btn-primary' <div style='text-align:center;'> - <a style='cursor: zoom-in;' href='{{asset( config("blogetc.blog_upload_dir") . "/". $smallest['filename'])}}' + <a style='cursor: zoom-in;' href='{{asset( config("binshopsblog.blog_upload_dir") . "/". $smallest['filename'])}}' target='_blank'> - <img src='{{asset( config("blogetc.blog_upload_dir") . "/". $smallest['filename'])}}' + <img src='{{asset( config("binshopsblog.blog_upload_dir") . "/". $smallest['filename'])}}' style='max-width:100%; height: auto;'> </a> </div> diff --git a/src/Views/blogetc_admin/imageupload/uploaded.blade.php b/src/Views/binshopsblog_admin/imageupload/uploaded.blade.php similarity index 55% rename from src/Views/blogetc_admin/imageupload/uploaded.blade.php rename to src/Views/binshopsblog_admin/imageupload/uploaded.blade.php index 8456868..97b46e7 100644 --- a/src/Views/blogetc_admin/imageupload/uploaded.blade.php +++ b/src/Views/binshopsblog_admin/imageupload/uploaded.blade.php @@ -1,4 +1,4 @@ -@extends("blogetc_admin::layouts.admin_layout") +@extends("binshopsblog_admin::layouts.admin_layout") @section("content") @@ -15,12 +15,12 @@ <small>{{$image['w'] . "x" . $image['h']}}</small> </h6> - <a href='{{asset( config("blogetc.blog_upload_dir") . "/". $image['filename'])}}' target='_blank'> - <img src='{{asset( config("blogetc.blog_upload_dir") . "/". $image['filename'])}}' + <a href='{{asset( config("binshopsblog.blog_upload_dir") . "/". $image['filename'])}}' target='_blank'> + <img src='{{asset( config("binshopsblog.blog_upload_dir") . "/". $image['filename'])}}' style='max-width:400px; height: auto;'> </a> - <input type='text' readonly='readonly' class='form-control' value='{{asset( config("blogetc.blog_upload_dir") . "/". $image['filename'])}}'> - <input type='text' readonly='readonly' class='form-control' value='{{"<img src='".asset( config("blogetc.blog_upload_dir") . "/". $image['filename'])."' alt='' >"}}'> + <input type='text' readonly='readonly' class='form-control' value='{{asset( config("binshopsblog.blog_upload_dir") . "/". $image['filename'])}}'> + <input type='text' readonly='readonly' class='form-control' value='{{"<img src='".asset( config("binshopsblog.blog_upload_dir") . "/". $image['filename'])."' alt='' >"}}'> </div> diff --git a/src/Views/blogetc_admin/index.blade.php b/src/Views/binshopsblog_admin/index.blade.php similarity index 57% rename from src/Views/blogetc_admin/index.blade.php rename to src/Views/binshopsblog_admin/index.blade.php index a5f117c..3ac0b45 100755 --- a/src/Views/blogetc_admin/index.blade.php +++ b/src/Views/binshopsblog_admin/index.blade.php @@ -1,13 +1,25 @@ -@extends("blogetc_admin::layouts.admin_layout") +@extends("binshopsblog_admin::layouts.admin_layout") @section("content") + @if($post_translations) + <div class='search-form-outer mb-3'> + <form method='get' action='{{route("binshopsblog.admin.searchblog", app('request')->get('locale'))}}' class='text-center'> + <input style="display: inline-block; width: 50%" type='text' name='s' placeholder='Search...' class='form-control' value='{{\Request::get("s")}}'> + <input style="display: inline-block" type='submit' value='Search' class='btn btn-primary m-2'> + </form> + </div> + + <h5>Manage Blog Posts</h5> + @endif - <h5>Admin - Manage Blog Posts</h5> + @forelse($post_translations as $post) + @if(isset($post->indexable)) + <?php $post = $post->indexable; ?> + @endif - @forelse($posts as $post) <div class="card m-4" style=""> <div class="card-body"> - <h5 class='card-title'><a class="a-link-cart-color" href='{{$post->url()}}'>{{$post->title}}</a></h5> + <h5 class='card-title'><a class="a-link-cart-color" href='{{$post->url(app('request')->get('locale'))}}'>{{$post->title}}</a></h5> <h5 class='card-subtitle mb-2 text-muted'>{{$post->subtitle}}</h5> <p class="card-text">{{$post->html}}</p> @@ -15,26 +27,26 @@ <dl class=""> <dt class="">Author</dt> - <dd class="">{{$post->author_string()}}</dd> + <dd class="">{{$post->post->author_string()}}</dd> <dt class="">Posted at</dt> - <dd class="">{{$post->posted_at}}</dd> + <dd class="">{{$post->post->posted_at}}</dd> <dt class="">Is published?</dt> <dd class=""> - {!!($post->is_published ? "Yes" : '<span class="border border-danger rounded p-1">No</span>')!!} + {!!($post->post->is_published ? "Yes" : '<span class="border border-danger rounded p-1">No</span>')!!} </dd> <dt class="">Categories</dt> <dd class=""> - @if(count($post->categories)) - @foreach($post->categories as $category) - <a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->edit_url()}}'> + @if(count($post->post->categories)) + @foreach($post->post->categories as $category) + <a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->categoryTranslations->where('lang_id' , $language_id)->first()->edit_url()}}'> <i class="fa fa-pencil-square-o" aria-hidden="true"></i> - {{$category->category_name}} + {{$category->categoryTranslations->where('lang_id' , $language_id)->first()->category_name}} </a> @endforeach @else No Categories @@ -73,14 +85,14 @@ @endif - <a href="{{$post->url()}}" class="card-link btn btn-outline-secondary"><i class="fa fa-file-text-o" - aria-hidden="true"></i> + <a href="{{$post->url(app('request')->get('locale'))}}" class="card-link btn btn-outline-secondary"><i class="fa fa-file-text-o" + aria-hidden="true"></i> View Post</a> <a href="{{$post->edit_url()}}" class="card-link btn btn-primary"> <i class="fa fa-pencil-square-o" aria-hidden="true"></i> Edit Post</a> <form onsubmit="return confirm('Are you sure you want to delete this blog post?\n You cannot undo this action!');" - method='post' action='{{route("blogetc.admin.destroy_post", $post->id)}}' class='float-right'> + method='post' action='{{route("binshopsblog.admin.destroy_post", $post->post_id)}}' class='float-right'> @csrf <input name="_method" type="hidden" value="DELETE"/> <button type='submit' class='btn btn-danger btn-sm'> @@ -91,14 +103,12 @@ </div> </div> @empty - <div class='alert alert-warning'>No posts to show you. Why don't you add one?</div> - @endforelse - + @if(empty($search)) + <h5>Manage Blog Posts</h5> - - <div class='text-center'> - {{$posts->appends( [] )->links()}} - </div> - - -@endsection \ No newline at end of file + <div class='alert alert-warning'>No posts to show you. Why don't you add one?</div> + @else + <div class='alert alert-warning'>There were no results for this search!</div> + @endif + @endforelse +@endsection diff --git a/src/Views/binshopsblog_admin/languages/add_language.blade.php b/src/Views/binshopsblog_admin/languages/add_language.blade.php new file mode 100755 index 0000000..9faeb52 --- /dev/null +++ b/src/Views/binshopsblog_admin/languages/add_language.blade.php @@ -0,0 +1,151 @@ +@extends("binshopsblog_admin::layouts.admin_layout") +@section("content") + + + <h5>Add new Language</h5> + + <form method='post' action='{{route("binshopsblog.admin.languages.store_language")}}' enctype="multipart/form-data" > + @csrf + + <div class="form-group"> + <select id="lang-name" data-placeholder="Choose a Language..."> + <option value="AF">Afrikaans</option> + <option value="SQ">Albanian</option> + <option value="AR">Arabic</option> + <option value="HY">Armenian</option> + <option value="EU">Basque</option> + <option value="BN">Bengali</option> + <option value="BG">Bulgarian</option> + <option value="CA">Catalan</option> + <option value="KM">Cambodian</option> + <option value="ZH">Chinese (Mandarin)</option> + <option value="HR">Croatian</option> + <option value="CS">Czech</option> + <option value="DA">Danish</option> + <option value="NL">Dutch</option> + <option value="EN">English</option> + <option value="ET">Estonian</option> + <option value="FJ">Fiji</option> + <option value="FI">Finnish</option> + <option value="FR">French</option> + <option value="KA">Georgian</option> + <option value="DE">German</option> + <option value="EL">Greek</option> + <option value="GU">Gujarati</option> + <option value="HE">Hebrew</option> + <option value="HI">Hindi</option> + <option value="HU">Hungarian</option> + <option value="IS">Icelandic</option> + <option value="ID">Indonesian</option> + <option value="GA">Irish</option> + <option value="IT">Italian</option> + <option value="JA">Japanese</option> + <option value="JW">Javanese</option> + <option value="KO">Korean</option> + <option value="LA">Latin</option> + <option value="LV">Latvian</option> + <option value="LT">Lithuanian</option> + <option value="MK">Macedonian</option> + <option value="MS">Malay</option> + <option value="ML">Malayalam</option> + <option value="MT">Maltese</option> + <option value="MI">Maori</option> + <option value="MR">Marathi</option> + <option value="MN">Mongolian</option> + <option value="NE">Nepali</option> + <option value="NO">Norwegian</option> + <option value="FA">Persian</option> + <option value="PL">Polish</option> + <option value="PT">Portuguese</option> + <option value="PA">Punjabi</option> + <option value="QU">Quechua</option> + <option value="RO">Romanian</option> + <option value="RU">Russian</option> + <option value="SM">Samoan</option> + <option value="SR">Serbian</option> + <option value="SK">Slovak</option> + <option value="SL">Slovenian</option> + <option value="ES">Spanish</option> + <option value="SW">Swahili</option> + <option value="SV">Swedish </option> + <option value="TA">Tamil</option> + <option value="TT">Tatar</option> + <option value="TE">Telugu</option> + <option value="TH">Thai</option> + <option value="BO">Tibetan</option> + <option value="TO">Tonga</option> + <option value="TR">Turkish</option> + <option value="UK">Ukrainian</option> + <option value="UR">Urdu</option> + <option value="UZ">Uzbek</option> + <option value="VI">Vietnamese</option> + <option value="CY">Welsh</option> + <option value="XH">Xhosa</option> + </select> + </div> + + <div class="form-group"> + <label for="active"> Active</label> + <input checked type="radio" id="active" name="active" value="1"> + <label for="deactive"> Deactive</label> + <input type="radio" id="deactive" name="active" value="0"> + <br> + + </div> + + <div class="form-group"> + <span>RTL: </span> + + <label for="no">No</label> + <input checked type="radio" id="no" name="rtl" value="0"> + <label for="yes">Yes</label> + <input type="radio" id="yes" name="rtl" value="1"> + <br> + </div> + + <script> + $('#lang-name').change(function(){ + var value = $(this).val().toLowerCase(); + $('#language_name').val($("#lang-name option:selected").text()); + $('#language_locale').val(value); + $('#iso_code').val(value); + console.log(value) + }); + </script> + + <div class="form-group"> + <label for="language_name">Language Name</label> + + <input type="text" + class="form-control" + id="language_name" + required + name='name' + readonly + > + + <small id="language_name" class="form-text text-muted">The name of the language</small> + + </div> + <div class="form-group"> + <label for="category_category_name">Locale</label> + + <input type="text" + class="form-control" + id="language_locale" + required + name='locale' + readonly + > + + <small id="language_name" class="form-text text-muted">The locale of the language</small> + + </div> + + <input name="iso_code" value="" id="iso_code" style="display: none"> + <input name="date_format" value="YYYY/MM/DD" style="display: none"> + + <input type='submit' class='btn btn-primary' value='Add New Language' > + </form> + +@endsection diff --git a/src/Views/binshopsblog_admin/languages/deleted_language.blade.php b/src/Views/binshopsblog_admin/languages/deleted_language.blade.php new file mode 100755 index 0000000..e69de29 diff --git a/src/Views/binshopsblog_admin/languages/edit_language.blade.php b/src/Views/binshopsblog_admin/languages/edit_language.blade.php new file mode 100755 index 0000000..e69de29 diff --git a/src/Views/binshopsblog_admin/languages/index.blade.php b/src/Views/binshopsblog_admin/languages/index.blade.php new file mode 100755 index 0000000..af509cd --- /dev/null +++ b/src/Views/binshopsblog_admin/languages/index.blade.php @@ -0,0 +1,49 @@ +@extends("binshopsblog_admin::layouts.admin_layout") +@section("content") + + @forelse ($language_list as $language) + + <div class="card m-4"> + <div class="card-body"> + <h5 class='card-title'>{{$language->name}}</h5> + <p><span><b>Locale: </b> {{$language->locale}}</span></p> + <p><span><b>Date format: </b> {{$language->date_format}}</span></p> + <p><span><b>Active: </b> + @if($language->active == 1) + Yes + @else + No + @endif + </span></p> + + <form + onsubmit="return confirm('Are you sure you want to do this action?');" + + method='post' action='{{route("binshopsblog.admin.languages.toggle_language", $language->id)}}' class='float-left'> + @csrf + + @if($language->active == 1) + <input type='submit' class='card-link btn btn-outline-secondary' value='Disable'/> + + @else + <input type='submit' class='card-link btn btn-primary' value='Enable'/> + @endif + </form> + + + <form + onsubmit="return confirm('Are you sure you want to delete this language?\n You cannot undo this action!');" + + method='post' action='{{route("binshopsblog.admin.languages.destroy_language", $language->id)}}' class='float-right'> + @csrf + @method("DELETE") + <input type='submit' class='btn btn-danger btn-sm' value='Delete'/> + </form> + + </div> + </div> + + @empty + <div class='alert alert-danger'>None found, why don't you add one?</div> + @endforelse +@endsection diff --git a/src/Views/blogetc_admin/layouts/admin_layout.blade.php b/src/Views/binshopsblog_admin/layouts/admin_layout.blade.php similarity index 70% rename from src/Views/blogetc_admin/layouts/admin_layout.blade.php rename to src/Views/binshopsblog_admin/layouts/admin_layout.blade.php index 4b2ac86..49e275c 100755 --- a/src/Views/blogetc_admin/layouts/admin_layout.blade.php +++ b/src/Views/binshopsblog_admin/layouts/admin_layout.blade.php @@ -26,14 +26,14 @@ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito" crossorigin="anonymous"> <!-- Styles --> -{{-- @if(file_exists(public_path("blogetc_admin_css.css")))--}} - <link href="{{ asset('blogetc_admin_css.css') }}" rel="stylesheet"> -{{-- @else--}} -{{-- <link href="{{ asset('css/app.css') }}" rel="stylesheet">--}} - {{--Edited your css/app.css file? Uncomment these lines to use plain bootstrap:--}} - {{--<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">--}} - {{--<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">--}} -{{-- @endif--}} + {{-- @if(file_exists(public_path("binshopsblog_admin_css.css")))--}} + <link href="{{ asset('binshopsblog_admin_css.css') }}" rel="stylesheet"> + {{-- @else--}} + {{-- <link href="{{ asset('css/app.css') }}" rel="stylesheet">--}} + {{--Edited your css/app.css file? Uncomment these lines to use plain bootstrap:--}} + {{--<link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">--}} + {{--<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">--}} + {{-- @endif--}} </head> @@ -41,7 +41,7 @@ <div id="app"> <nav class="navbar navbar-expand-md navbar-light navbar-laravel"> <div class="container"> - <a class="navbar-brand hessam-blog-title" href="{{ route('blogetc.admin.index') }}"> + <a class="navbar-brand binshops-blog-title" href="{{ route('binshopsblog.admin.index') }}"> {{ config('app.name', 'Laravel') }} Blog Dashboard </a> <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" @@ -60,9 +60,7 @@ <ul class="navbar-nav ml-auto"> <!-- Authentication Links --> - - <li class='nav-item px-2'><a class='nav-link' href='{{route("blogetc.index")}}'>Blog home</a></li> - + <li class='nav-item px-2'><a class='nav-link' href='{{route("binshopsblog.index" , app('request')->get('locale'))}}' target="_blank">Blog home</a></li> <li class="nav-item "> <a id="" class="nav-link " href="#" role="button" @@ -72,9 +70,9 @@ </li> <li class="nav-item "> <a class="nav-link" href="{{ route('logout') }}" - onclick="event.preventDefault(); + onclick="event.preventDefault(); document.getElementById('logout-form').submit();"> - {{ __('Logout') }} + {{ __('Logout') }} </a> <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;"> @csrf @@ -89,12 +87,12 @@ <div class="container"> <div class='row full-width-div nav-bar-full'> <div class='list-group-color'> - @include("blogetc_admin::layouts.sidebar") - <div class=' list-group-color text-center mt-5 mb-3 text-muted hessam-version'> - <small><a href='https://github.com/vhessam/laravel-blogger'>Hessam CMS</a></small> + @include("binshopsblog_admin::layouts.sidebar") + <div class=' list-group-color text-center mt-5 mb-3 text-muted binshops-version'> + <small><a href='https://github.com/binshops/laravel-blog'>Binshops Blog</a></small> <small> - Version 8.0.x + Version 9.2.x </small> </div> </div> @@ -114,9 +112,9 @@ {{--REPLACING THIS FILE WITH YOUR OWN LAYOUT FILE? Don't forget to include the following section!--}} - @if(\WebDevEtc\BlogEtc\Helpers::has_flashed_message()) + @if(\BinshopsBlog\Helpers::has_flashed_message()) <div class='alert alert-info'> - <h3>{{\WebDevEtc\BlogEtc\Helpers::pull_flashed_message() }}</h3> + <h3>{{\BinshopsBlog\Helpers::pull_flashed_message() }}</h3> </div> @endif @@ -127,16 +125,5 @@ </main> </div> - -@if( config("blogetc.use_wysiwyg") && config("blogetc.echo_html") && (in_array( \Request::route()->getName() ,[ 'blogetc.admin.create_post' , 'blogetc.admin.edit_post' ]))) - <script src="//cdn.ckeditor.com/4.14.1/full/ckeditor.js"></script> - <script> - if( typeof(CKEDITOR) !== "undefined" ) { - CKEDITOR.replace('post_body'); - } - </script> -@endif - - </body> </html> diff --git a/src/Views/blogetc_admin/layouts/sidebar.blade.php b/src/Views/binshopsblog_admin/layouts/sidebar.blade.php similarity index 52% rename from src/Views/blogetc_admin/layouts/sidebar.blade.php rename to src/Views/binshopsblog_admin/layouts/sidebar.blade.php index 5ed6a08..f26192b 100755 --- a/src/Views/blogetc_admin/layouts/sidebar.blade.php +++ b/src/Views/binshopsblog_admin/layouts/sidebar.blade.php @@ -1,9 +1,9 @@ <ul class="list-group"> <li class="list-group-item list-group-color justify-content-between lh-condensed"> <div> - <h6 class="my-0"><a href="{{ route('blogetc.admin.index') }}">Dashboard</a> + <h6 class="my-0"><a href="{{ route('binshopsblog.admin.index') }}">Dashboard</a> <span class="text-muted">(<?php - $categoryCount = \WebDevEtc\BlogEtc\Models\BlogEtcPost::count(); + $categoryCount = \BinshopsBlog\Models\BinshopsPost::count(); echo $categoryCount . " " . str_plural("Post", $categoryCount); @@ -13,13 +13,13 @@ <div class="list-group "> - <a href='{{ route('blogetc.admin.index') }}' - class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'blogetc.admin.index') active @endif '><i + <a href='{{ route('binshopsblog.admin.index') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.index') active @endif '><i class="fa fa-th fa-fw" aria-hidden="true"></i> All Posts</a> - <a href='{{ route('blogetc.admin.create_post') }}' - class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'blogetc.admin.create_post') active @endif '><i + <a href='{{ route('binshopsblog.admin.create_post') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.create_post') active @endif '><i class="fa fa-plus fa-fw" aria-hidden="true"></i> Add Post</a> </div> @@ -29,10 +29,10 @@ class="fa fa-plus fa-fw" aria-hidden="true"></i> <li class="list-group-item list-group-color justify-content-between lh-condensed"> <div> - <h6 class="my-0"><a href="{{ route('blogetc.admin.comments.index') }}">Comments</a> + <h6 class="my-0"><a href="{{ route('binshopsblog.admin.comments.index') }}">Comments</a> <span class="text-muted">(<?php - $commentCount = \WebDevEtc\BlogEtc\Models\BlogEtcComment::withoutGlobalScopes()->count(); + $commentCount = \BinshopsBlog\Models\BinshopsComment::withoutGlobalScopes()->count(); echo $commentCount . " " . str_plural("Comment", $commentCount); @@ -41,16 +41,16 @@ class="fa fa-plus fa-fw" aria-hidden="true"></i> <small class="text-muted">Manage your comments</small> <div class="list-group "> - <a href='{{ route('blogetc.admin.comments.index') }}' - class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'blogetc.admin.comments.index' && !\Request::get("waiting_for_approval")) active @endif '><i + <a href='{{ route('binshopsblog.admin.comments.index') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.comments.index' && !\Request::get("waiting_for_approval")) active @endif '><i class="fa fa-fw fa-comments" aria-hidden="true"></i> All Comments</a> - <?php $comment_approval_count = \WebDevEtc\BlogEtc\Models\BlogEtcComment::withoutGlobalScopes()->where("approved", false)->count(); ?> + <?php $comment_approval_count = \BinshopsBlog\Models\BinshopsComment::withoutGlobalScopes()->where("approved", false)->count(); ?> - <a href='{{ route('blogetc.admin.comments.index') }}?waiting_for_approval=true' - class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'blogetc.admin.comments.index' && \Request::get("waiting_for_approval")) active @elseif($comment_approval_count>0) list-group-item list-group-color-warning @endif '><i + <a href='{{ route('binshopsblog.admin.comments.index') }}?waiting_for_approval=true' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.comments.index' && \Request::get("waiting_for_approval")) active @elseif($comment_approval_count>0) list-group-item list-group-color-warning @endif '><i class="fa fa-fw fa-comments" aria-hidden="true"></i> {{ $comment_approval_count }} Waiting for approval </a> @@ -62,9 +62,9 @@ class="fa fa-fw fa-comments" aria-hidden="true"></i> <li class="list-group-item list-group-color justify-content-between lh-condensed"> <div> - <h6 class="my-0"><a href="{{ route('blogetc.admin.categories.index') }}">Categories</a> + <h6 class="my-0"><a href="{{ route('binshopsblog.admin.categories.index') }}">Categories</a> <span class="text-muted">(<?php - $postCount = \WebDevEtc\BlogEtc\Models\BlogEtcCategory::count(); + $postCount = \BinshopsBlog\Models\BinshopsCategory::count(); echo $postCount . " " . str_plural("Category", $postCount); ?>)</span> </h6> @@ -73,12 +73,12 @@ class="fa fa-fw fa-comments" aria-hidden="true"></i> <small class="text-muted">Blog post categories</small> <div class="list-group "> - <a href='{{ route('blogetc.admin.categories.index') }}' - class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'blogetc.admin.categories.index') active @endif '><i + <a href='{{ route('binshopsblog.admin.categories.index') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.categories.index') active @endif '><i class="fa fa-object-group fa-fw" aria-hidden="true"></i> All Categories</a> - <a href='{{ route('blogetc.admin.categories.create_category') }}' - class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'blogetc.admin.categories.create_category') active @endif '><i + <a href='{{ route('binshopsblog.admin.categories.create_category') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.categories.create_category') active @endif '><i class="fa fa-plus fa-fw" aria-hidden="true"></i> Add Category</a> </div> @@ -86,24 +86,45 @@ class="fa fa-plus fa-fw" aria-hidden="true"></i> </li> - @if(config("blogetc.image_upload_enabled")) + + <li class="list-group-item list-group-color justify-content-between lh-condensed"> + <div> + <h6 class="my-0"><a href="{{ route('binshopsblog.admin.images.upload') }}">Languages</a></h6> + + <div class="list-group "> + + <a href='{{ route('binshopsblog.admin.languages.index') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.languages.index') active @endif '><i + class="fa fa-language fa-fw" aria-hidden="true"></i> + All Languages</a> + + <a href='{{ route('binshopsblog.admin.languages.create_language') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.languages.create_language') active @endif '><i + class="fa fa-plus fa-fw" aria-hidden="true"></i> + Add new Language</a> + </div> + </div> + </li> + + + @if(config("binshopsblog.image_upload_enabled")) <li class="list-group-item list-group-color justify-content-between lh-condensed"> <div> - <h6 class="my-0"><a href="{{ route('blogetc.admin.images.upload') }}">Upload images</a></h6> + <h6 class="my-0"><a href="{{ route('binshopsblog.admin.images.upload') }}">Upload images</a></h6> <div class="list-group "> - <a href='{{ route('blogetc.admin.images.all') }}' - class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'blogetc.admin.images.all') active @endif '><i + <a href='{{ route('binshopsblog.admin.images.all') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.images.all') active @endif '><i class="fa fa-picture-o fa-fw" aria-hidden="true"></i> View All</a> - <a href='{{ route('blogetc.admin.images.upload') }}' - class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'blogetc.admin.images.upload') active @endif '><i + <a href='{{ route('binshopsblog.admin.images.upload') }}' + class='list-group-item list-group-color list-group-item list-group-color-action @if(\Request::route()->getName() === 'binshopsblog.admin.images.upload') active @endif '><i class="fa fa-upload fa-fw" aria-hidden="true"></i> Upload</a> </div> </div> </li> @endif -</ul> \ No newline at end of file +</ul> diff --git a/src/Views/binshopsblog_admin/posts/add_post.blade.php b/src/Views/binshopsblog_admin/posts/add_post.blade.php new file mode 100755 index 0000000..ed805d9 --- /dev/null +++ b/src/Views/binshopsblog_admin/posts/add_post.blade.php @@ -0,0 +1,32 @@ +@extends("binshopsblog_admin::layouts.admin_layout") +@section("content") + + + <h5>Admin - Add post</h5> + <p>Change language option to translate your post in different language</p> + <form id="add-post-form" method='post' action='{{route("binshopsblog.admin.store_post")}}' enctype="multipart/form-data" > + + @csrf + @include("binshopsblog_admin::posts.form", [ + 'post' => $post, + 'post_translation' => $post_translation + ]) + <input id="post_id" name="post_id" type="number" value="{{$post_id}}" hidden> + <input type='submit' name="submit_btn" class='btn btn-primary' value='Add new post' > + + </form> + + <script> + //multi language + var store_toggle_url = '{{route("binshopsblog.admin.store_post_toggle")}}'; + var preLang = $('#language_list').val(); + $('#language_list').change(function (){ + $('#add-post-form').attr('action', store_toggle_url); + + $('#selected_lang').val($('#language_list').val()); + $('#language_list').val(preLang); + console.log($('#language_list').val()) + $('#add-post-form').trigger('submit'); + }); + </script> +@endsection diff --git a/src/Views/blogetc_admin/posts/deleted_post.blade.php b/src/Views/binshopsblog_admin/posts/deleted_post.blade.php similarity index 65% rename from src/Views/blogetc_admin/posts/deleted_post.blade.php rename to src/Views/binshopsblog_admin/posts/deleted_post.blade.php index 7010d9a..ce7ce24 100755 --- a/src/Views/blogetc_admin/posts/deleted_post.blade.php +++ b/src/Views/binshopsblog_admin/posts/deleted_post.blade.php @@ -1,13 +1,13 @@ -@extends("blogetc_admin::layouts.admin_layout") +@extends("binshopsblog_admin::layouts.admin_layout") @section("content") <div class='alert alert-success'><b>Deleted that post</b> - <br/><a href='{{ route('blogetc.admin.index') }}' class='btn btn-primary '>Back to posts overview</a></div> + <br/><a href='{{ route('binshopsblog.admin.index') }}' class='btn btn-primary '>Back to posts overview</a></div> <?php $images_to_delete = []; - foreach ((array) config("blogetc.image_sizes") as $image_size => $image_size_info) { + foreach ((array) config("binshopsblog.image_sizes") as $image_size => $image_size_info) { if (!$deletedPost->$image_size) { continue; } @@ -32,25 +32,25 @@ <td class='text-center'><a - href='{{asset(config("blogetc.blog_upload_dir","blog_images")."/".$deletedPost->$image_size) }}' + href='{{asset(config("binshopsblog.blog_upload_dir","blog_images")."/".$deletedPost->$image_size) }}' target='_blank' class='btn btn-primary m-1'>view</a> - <img src='{{asset(config("blogetc.blog_upload_dir","blog_images")."/".$deletedPost->$image_size) }}' + <img src='{{asset(config("binshopsblog.blog_upload_dir","blog_images")."/".$deletedPost->$image_size) }}' width=100> </td> <td><code>{{$deletedPost->$image_size}}</code> {{--check filesize returns something, so we don't divide by 0--}} - @if(filesize(public_path(config("blogetc.blog_upload_dir","blog_images")."/".$deletedPost->$image_size))) + @if(filesize(public_path(config("binshopsblog.blog_upload_dir","blog_images")."/".$deletedPost->$image_size))) - ({{ (round(filesize(public_path(config("blogetc.blog_upload_dir","blog_images")."/".$deletedPost->$image_size)) / 1000 ,1)). " kb"}}) + ({{ (round(filesize(public_path(config("binshopsblog.blog_upload_dir","blog_images")."/".$deletedPost->$image_size)) / 1000 ,1)). " kb"}}) @endif </td> <td><code> - <small>{{ public_path(config("blogetc.blog_upload_dir","blog_images")."/".$deletedPost->$image_size) }}</small> + <small>{{ public_path(config("binshopsblog.blog_upload_dir","blog_images")."/".$deletedPost->$image_size) }}</small> </code></td> </tr> diff --git a/src/Views/binshopsblog_admin/posts/edit_post.blade.php b/src/Views/binshopsblog_admin/posts/edit_post.blade.php new file mode 100755 index 0000000..f9a4572 --- /dev/null +++ b/src/Views/binshopsblog_admin/posts/edit_post.blade.php @@ -0,0 +1,42 @@ +@extends("binshopsblog_admin::layouts.admin_layout") +@section("content") + + + <h5>Admin - Editing post + @if($post_translation->slug) + <a target='_blank' href='{{$post_translation->url($selected_locale)}}' class='float-right btn btn-primary'>View post</a> + @endif + </h5> + + <form id="edit-post-form" method='post' action='{{route("binshopsblog.admin.update_post",$post->id)}}' enctype="multipart/form-data" > + + <p> + To apply changes, click save changes for each language. + </p> + + @csrf + @include("binshopsblog_admin::posts.form", [ + 'post' => $post, + 'post_translation' => $post_translation + ]) + + <input type='submit' name="submit_btn" class='btn btn-primary' value='Save Changes' > + + </form> + + <script> + //multi language + var edit_toggle_url = '{{route("binshopsblog.admin.edit_post_toggle",$post->id)}}'; + var preLang = $('#language_list').val(); + $('#language_list').change(function (){ + $("#edit-post-form").attr("method", "post"); + $('#edit-post-form').attr('action', edit_toggle_url); + + $('#selected_lang').val($('#language_list').val()); + $('#language_list').val(preLang); + console.log($('#language_list').val()) + $('#edit-post-form').trigger('submit'); + }); + </script> + +@endsection diff --git a/src/Views/blogetc_admin/posts/form.blade.php b/src/Views/binshopsblog_admin/posts/form.blade.php similarity index 62% rename from src/Views/blogetc_admin/posts/form.blade.php rename to src/Views/binshopsblog_admin/posts/form.blade.php index 0179dfe..a37ff4f 100755 --- a/src/Views/blogetc_admin/posts/form.blade.php +++ b/src/Views/binshopsblog_admin/posts/form.blade.php @@ -1,14 +1,26 @@ +<div class="form-group"> + <label for="language_list">Select Language</label> + <select id="language_list" name='lang_id' class='form-control'> + @foreach($language_list as $language) + <option value='{{$language->id}}' @if($language->id == $selected_lang)selected="selected" @endif> + {{$language->name}} + </option> + @endforeach + </select> +</div> + <div class="form-group"> <label for="blog_title">Blog Post Title</label> <input type="text" class="form-control" required id="blog_title" aria-describedby="blog_title_help" name='title' - value="{{old("title",$post->title)}}"> + value="{{old("title",$post_translation->title)}}" oninput="populate_slug_field();" + > <small id="blog_title_help" class="form-text text-muted">The title of the blog post</small> </div> <div class="form-group"> <label for="blog_subtitle">Subtitle</label> <input type="text" class="form-control" id="blog_subtitle" aria-describedby="blog_subtitle_help" name='subtitle' - value='{{old("subtitle",$post->subtitle)}}'> + value='{{old("subtitle",$post_translation->subtitle)}}'> <small id="blog_subtitle_help" class="form-text text-muted">The subtitle of the blog post (optional)</small> </div> @@ -22,9 +34,8 @@ <div class="form-group"> <label for="blog_slug">Blog Post Slug</label> <input type="text" class="form-control" id="blog_slug" aria-describedby="blog_slug_help" name='slug' - value="{{old("slug",$post->slug)}}"> - <small id="blog_slug_help" class="form-text text-muted">The slug (leave blank to auto generate) - - i.e. {{route("blogetc.single","")}}/<u><em>this_part</em></u></small> + value="{{old("slug",$post_translation->slug)}}"> + <small id="blog_slug_help" class="form-text text-muted">The slug (leave blank to auto generate) - i.e.{{route("binshopsblog.single", [app('request')->get('locale'), "your-slug"])}}</small> </div> </div> @@ -73,7 +84,7 @@ <div class="form-group"> <label for="blog_post_body">Post Body - @if(config("blogetc.echo_html")) + @if(config("binshopsblog.echo_html")) (HTML) @else (Html will be escaped) @@ -81,7 +92,7 @@ </label> <textarea style='min-height:600px;' class="form-control" id="blog_post_body" aria-describedby="blog_post_body_help" - name='post_body'>{{old("post_body",$post->post_body)}}</textarea> + name='post_body'>{{old("post_body",$post_translation->post_body)}}</textarea> <div class='alert alert-warning'> @@ -90,12 +101,12 @@ </div> -@if(config("blogetc.use_custom_view_files",true)) +@if(config("binshopsblog.use_custom_view_files",true)) <div class="form-group"> <label for="blog_use_view_file">Custom View File</label> <input type="text" class="form-control" id="blog_use_view_file" aria-describedby="blog_use_view_file_help" name='use_view_file' - value='{{old("use_view_file",$post->use_view_file)}}'> + value='{{old("use_view_file",$post_translation->use_view_file)}}'> <small id="blog_use_view_file_help" class="form-text text-muted">Optional - if anything is entered here, then it will attempt to load <code>view("custom_blog_posts." . $use_view_file)</code>. You must create the file in /resources/views/custom_blog_posts/FILENAME.blade.php. @@ -108,25 +119,25 @@ <div class="form-group"> <label for="blog_seo_title">SEO: {{"<title>"}} tag (optional)</label> <input class="form-control" id="blog_seo_title" aria-describedby="blog_seo_title_help" - name='seo_title' tyoe='text' value='{{old("seo_title",$post->seo_title)}}' > + name='seo_title' tyoe='text' value='{{old("seo_title",$post_translation->seo_title)}}' > <small id="blog_seo_title_help" class="form-text text-muted">Enter a value for the {{"<title>"}} tag. If nothing is provided here we will just use the normal post title from above (optional)</small> </div> <div class="form-group"> <label for="blog_meta_desc">Meta Desc (optional)</label> <textarea class="form-control" id="blog_meta_desc" aria-describedby="blog_meta_desc_help" - name='meta_desc'>{{old("meta_desc",$post->meta_desc)}}</textarea> + name='meta_desc'>{{old("meta_desc",$post_translation->meta_desc)}}</textarea> <small id="blog_meta_desc_help" class="form-text text-muted">Meta description (optional)</small> </div> <div class="form-group"> <label for="blog_short_description">Short Desc (optional)</label> <textarea class="form-control" id="blog_short_description" aria-describedby="blog_short_description_help" - name='short_description'>{{old("short_description",$post->short_description)}}</textarea> + name='short_description'>{{old("short_description",$post_translation->short_description)}}</textarea> <small id="blog_short_description_help" class="form-text text-muted">Short description (optional - only useful if you use in your template views)</small> </div> -@if(config("blogetc.image_upload_enabled",true)) +@if(config("binshopsblog.image_upload_enabled",true)) <div class='bg-white pt-4 px-4 pb-0 my-2 mb-4 rounded border'> <style> @@ -137,16 +148,16 @@ <h4>Featured Images</h4> - @foreach(config("blogetc.image_sizes") as $size_key =>$size_info) + @foreach(config("binshopsblog.image_sizes") as $size_key =>$size_info) <div class="form-group mb-4 p-2 @if($loop->iteration>1) image_upload_other_sizes @endif "> - @if($post->has_image($size_info['basic_key'])) + @if($post_translation->has_image($size_info['basic_key'])) <div style='max-width:55px; ' class='float-right m-2'> - <a style='cursor: zoom-in;' target='_blank' href='{{$post->image_url($size_info['basic_key'])}}'> - <?=$post->image_tag($size_info['basic_key'], false, 'd-block mx-auto img-fluid '); ?> + <a style='cursor: zoom-in;' target='_blank' href='{{$post_translation->image_url($size_info['basic_key'])}}'> + <?=$post_translation->image_tag($size_info['basic_key'], false, 'd-block mx-auto img-fluid '); ?> </a> </div> @endif @@ -159,8 +170,12 @@ <input class="form-control" type="file" name="{{$size_key}}" id="blog_{{$size_key}}" aria-describedby="blog_{{$size_key}}_help"> - @if($post->has_image($size_info['basic_key'])) - <a style="color: darkred" href="{{route("blogetc.admin.remove_photo", $post->slug)}}">Remove Image</a> + @if($post_translation->has_image($size_info['basic_key'])) + <a style="color: darkred" href="{{route("binshopsblog.admin.remove_photo",[ + $post_translation->slug, + $selected_lang + ] + )}}">Remove Image</a> @endif </div> @endforeach @@ -173,7 +188,7 @@ class='btn btn-light btn-sm'>Show other sizes</span> </div> @else - <div class='alert alert-warning'>Image uploads were disabled in blogetc.php config</div> + <div class='alert alert-warning'>Image uploads were disabled in binshopsblog.php config</div> @endif @@ -181,13 +196,13 @@ class='btn btn-light btn-sm'>Show other sizes</span> <h4>Categories:</h4> <div class='row'> - @forelse(\WebDevEtc\BlogEtc\Models\BlogEtcCategory::orderBy("category_name","asc")->limit(1000)->get() as $category) + @forelse($cat_ts as $translation) <div class="form-check col-sm-6"> <input class="" type="checkbox" value="1" - @if(old("category.".$category->id, $post->categories->contains($category->id))) checked='checked' - @endif name='category[{{$category->id}}]' id="category_check{{$category->id}}"> - <label class="form-check-label" for="category_check{{$category->id}}"> - {{$category->category_name}} + @if(old("category.".$translation->category_id, $post->categories->contains($translation->category_id))) checked='checked' + @endif name='category[{{$translation->category_id}}]' id="category_check{{$translation->category_id}}"> + <label class="form-check-label" for="category_check{{$translation->category_id}}"> + {{$translation->category_name}} </label> </div> @empty @@ -198,9 +213,55 @@ class='btn btn-light btn-sm'>Show other sizes</span> <div class='col-md-12 my-3 text-center'> - <em><a class="a-link-cart-color" target='_blank' href='{{route("blogetc.admin.categories.create_category")}}'><i class="fa fa-external-link" aria-hidden="true"></i> - Add new categories + <em><a class="a-link-cart-color" target='_blank' href='{{route("binshopsblog.admin.categories.create_category")}}'><i class="fa fa-external-link" aria-hidden="true"></i> + Add new categories here</a></em> </div> </div> </div> + +<input id="selected_lang" name="selected_lang" type="number" value="-1" hidden> + +<script> + SHOULD_AUTO_GEN_SLUG = false; + + /* Generate the slug field, if it was not touched by the user (or if it was an empty string) */ + function populate_slug_field() { + +// alert("A"); + var cat_slug = document.getElementById('blog_slug'); + + if (cat_slug.value.length < 1) { + // if the slug field is empty, make sure it auto generates + SHOULD_AUTO_GEN_SLUG = true; + } + + if (SHOULD_AUTO_GEN_SLUG) { + // the slug hasn't been manually changed (or it was set above), so we should generate the slug + // This is done in two stages - one to remove non words/spaces etc, the another to replace white space (and underscore) with a - + cat_slug.value =document.getElementById("blog_title").value.toLowerCase() + .replace(/[^\w-_ ]+/g, '') // replace with nothing + .replace(/[_ ]+/g, '-') // replace _ and spaces with - + .substring(0,99); // limit str length + + } + + } + + if (document.getElementById("blog_slug").value.length < 1) { + SHOULD_AUTO_GEN_SLUG = true; + } else { + SHOULD_AUTO_GEN_SLUG = false; // there is already a value in #category_slug, so lets pretend it was changed already. + } + +</script> + +@if( config("binshopsblog.use_wysiwyg") && config("binshopsblog.echo_html")) + <script src="//cdn.ckeditor.com/4.15.0/full/ckeditor.js"></script> + + <script> + if( typeof(CKEDITOR) !== "undefined" ) { + CKEDITOR.replace('post_body'); + } + </script> +@endif diff --git a/src/Views/binshopsblog_admin/setup/setup.blade.php b/src/Views/binshopsblog_admin/setup/setup.blade.php new file mode 100644 index 0000000..ab0bd55 --- /dev/null +++ b/src/Views/binshopsblog_admin/setup/setup.blade.php @@ -0,0 +1,325 @@ +<!doctype html> +<html lang="en"> +<head> + <meta charset="utf-8" /> + <link rel="apple-touch-icon" sizes="76x76" href="assets/img/apple-icon.png"> + <link rel="icon" type="image/png" href="assets/img/favicon.png"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> + <title>Binshops Blog package setup</title> + + <meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' /> + <meta name="viewport" content="width=device-width" /> + + <!-- Fonts and icons --> + <link href="http://netdna.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.css" rel="stylesheet"> + + <!-- CSS Files --> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> + + <link href="{{ asset('admin-setup.css') }}" rel="stylesheet"> +</head> + +<body style="background-color: #e2e8f0"> +<div style="background-color: #e2e8f0"> + + <div class="container"> + <div class="row"> + <div class="col-sm-8 col-sm-offset-2"> + + <div class="wizard-container"> + <div class="card wizard-card" data-color="green" id="wizard"> + <form action="{{route("binshopsblog.admin.setup_submit")}}" method="post"> + @csrf + + <div class="wizard-header" style="padding: 10px; text-align: center"> + </div> + <div class="wizard-navigation"> + <ul> + <li><a href="#language" data-toggle="tab">Language</a></li> + </ul> + </div> + + <div class="tab-content"> + <div class="tab-pane" id="language"> + <div class="row"> + <div class="col-sm-12"> + <h4 class="info-text">Your default language will be set to English. You can add more language through the admin panel.</h4> + + <h6 class="info-text"> + Version v9.3.x + </h6> + </div> + + <input type="text" + class="form-control" + id="language_name" + required + name='name' + value="English" + style="display: none"> + + <input type="text" + class="form-control" + id="language_locale" + required + name='locale' + value="en" + style="display: none"> + + <input name="iso_code" value="en" id="iso_code" style="display: none"> + <input name="date_format" value="YYYY/MM/DD" style="display: none"> + <input checked style="display: none" name="active" value="1"> + + + {{-- </div>--}} + {{-- </div>--}} + + + + </div> + </div> + </div> + + <div class="row"> + <div class="col-md-12" style="text-align: center"> + <input type='submit' class='btn btn-fill btn-success btn-wd btn-sm' value='Setup Package' /> + + </div> + </div> + {{-- FOOTER--}} + {{-- <div class="wizard-footer ">--}} + {{-- <div class="pull-right">--}} + {{-- <input type='button' class='btn btn-next btn-fill btn-success btn-wd btn-sm' name='next' value='Next' />--}} + {{-- <input type='submit' class='btn btn-finish btn-fill btn-success btn-wd btn-sm' name='finish' value='Finish' />--}} + + {{-- </div>--}} + {{-- <div class="pull-left">--}} + {{-- <input type='button' class='btn btn-previous btn-fill btn-default btn-wd btn-sm' name='previous' value='Previous' />--}} + {{-- </div>--}} + {{-- <div class="clearfix"></div>--}} + {{-- </div>--}} + + </form> + </div> + </div> + </div> + </div> + </div> + + <div class="footer"> + <div class="container"> + Created by BINSHOPS + </div> + </div> +</div> + +</body> + +<!-- Core JS Files --> +<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap-wizard/1.2/jquery.bootstrap.wizard.js"></script> + +<!-- Plugin for the Wizard --> +<script> + searchVisible = 0; + transparent = true; + + $(document).ready(function(){ + + /* Activate the tooltips */ + $('[rel="tooltip"]').tooltip(); + + // Code for the Validator + var $validator = $('.wizard-card form').validate({ + rules: { + firstname: { + required: true, + minlength: 3 + }, + lastname: { + required: true, + minlength: 3 + }, + email: { + required: true, + minlength: 3, + } + } + }); + + // Wizard Initialization + $('.wizard-card').bootstrapWizard({ + 'tabClass': 'nav nav-pills', + 'nextSelector': '.btn-next', + 'previousSelector': '.btn-previous', + + onNext: function(tab, navigation, index) { + var $valid = $('.wizard-card form').valid(); + if(!$valid) { + $validator.focusInvalid(); + return false; + } + }, + + onInit : function(tab, navigation, index){ + + //check number of tabs and fill the entire row + var $total = navigation.find('li').length; + $width = 100/$total; + var $wizard = navigation.closest('.wizard-card'); + + $display_width = $(document).width(); + + if($display_width < 600 && $total > 3){ + $width = 50; + } + + navigation.find('li').css('width',$width + '%'); + $first_li = navigation.find('li:first-child a').html(); + $moving_div = $('<div class="moving-tab">' + $first_li + '</div>'); + $('.wizard-card .wizard-navigation').append($moving_div); + refreshAnimation($wizard, index); + $('.moving-tab').css('transition','transform 0s'); + }, + + onTabClick : function(tab, navigation, index){ + + var $valid = $('.wizard-card form').valid(); + + if(!$valid){ + return false; + } else { + return true; + } + }, + + onTabShow: function(tab, navigation, index) { + var $total = navigation.find('li').length; + var $current = index+1; + + var $wizard = navigation.closest('.wizard-card'); + + // If it's the last tab then hide the last button and show the finish instead + if($current >= $total) { + $($wizard).find('.btn-next').hide(); + $($wizard).find('.btn-finish').show(); + } else { + $($wizard).find('.btn-next').show(); + $($wizard).find('.btn-finish').hide(); + } + + button_text = navigation.find('li:nth-child(' + $current + ') a').html(); + + setTimeout(function(){ + $('.moving-tab').text(button_text); + }, 150); + + var checkbox = $('.footer-checkbox'); + + if( !index == 0 ){ + $(checkbox).css({ + 'opacity':'0', + 'visibility':'hidden', + 'position':'absolute' + }); + } else { + $(checkbox).css({ + 'opacity':'1', + 'visibility':'visible' + }); + } + + refreshAnimation($wizard, index); + } + }); + + + // Prepare the preview for profile picture + $("#wizard-picture").change(function(){ + readURL(this); + }); + + $('[data-toggle="wizard-radio"]').click(function(){ + wizard = $(this).closest('.wizard-card'); + wizard.find('[data-toggle="wizard-radio"]').removeClass('active'); + $(this).addClass('active'); + $(wizard).find('[type="radio"]').removeAttr('checked'); + $(this).find('[type="radio"]').attr('checked','true'); + }); + + $('[data-toggle="wizard-checkbox"]').click(function(){ + if( $(this).hasClass('active')){ + $(this).removeClass('active'); + $(this).find('[type="checkbox"]').removeAttr('checked'); + } else { + $(this).addClass('active'); + $(this).find('[type="checkbox"]').attr('checked','true'); + } + }); + + $('.set-full-height').css('height', 'auto'); + + }); + + + + //Function to show image before upload + + function readURL(input) { + if (input.files && input.files[0]) { + var reader = new FileReader(); + + reader.onload = function (e) { + $('#wizardPicturePreview').attr('src', e.target.result).fadeIn('slow'); + } + reader.readAsDataURL(input.files[0]); + } + } + + $(window).resize(function(){ + $('.wizard-card').each(function(){ + $wizard = $(this); + index = $wizard.bootstrapWizard('currentIndex'); + refreshAnimation($wizard, index); + + $('.moving-tab').css({ + 'transition': 'transform 0s' + }); + }); + }); + + function refreshAnimation($wizard, index){ + total_steps = $wizard.find('li').length; + move_distance = $wizard.width() / total_steps; + step_width = move_distance; + move_distance *= index; + + $wizard.find('.moving-tab').css('width', step_width); + $('.moving-tab').css({ + 'transform':'translate3d(' + move_distance + 'px, 0, 0)', + 'transition': 'all 0.3s ease-out' + + }); + } + + function debounce(func, wait, immediate) { + var timeout; + return function() { + var context = this, args = arguments; + clearTimeout(timeout); + timeout = setTimeout(function() { + timeout = null; + if (!immediate) func.apply(context, args); + }, wait); + if (immediate && !timeout) func.apply(context, args); + }; + }; + +</script> + +<!-- More information about jquery.validate here: http://jqueryvalidation.org/ --> +<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.14.0/jquery.validate.min.js"></script> + +</html> diff --git a/src/Views/blogetc/partials/categories.blade.php b/src/Views/blogetc/partials/categories.blade.php deleted file mode 100644 index c001136..0000000 --- a/src/Views/blogetc/partials/categories.blade.php +++ /dev/null @@ -1,7 +0,0 @@ -<div class=''> - @foreach($post->categories as $category) - <a class='btn btn-outline-secondary btn-sm m-1' href='{{$category->url()}}'> - {{$category->category_name}} - </a> - @endforeach -</div> \ No newline at end of file diff --git a/src/Views/blogetc/single_post.blade.php b/src/Views/blogetc/single_post.blade.php deleted file mode 100755 index 856f364..0000000 --- a/src/Views/blogetc/single_post.blade.php +++ /dev/null @@ -1,43 +0,0 @@ -@extends("layouts.app",['title'=>$post->gen_seo_title()]) - -@section('blog-custom-css') - <link type="text/css" href="{{ asset('hessam-blog.css') }}" rel="stylesheet"> -@endsection - -@section("content") - - @if(config("blogetc.reading_progress_bar")) - <div id="scrollbar"> - <div id="scrollbar-bg"></div> - </div> - @endif - - {{--https://webdevetc.com/laravel/packages/blogetc-blog-system-for-your-laravel-app/help-documentation/laravel-blog-package-blogetc#guide_to_views--}} - - <div class='container'> - <div class='row'> - <div class='col-sm-12 col-md-12 col-lg-12'> - - @include("blogetc::partials.show_errors") - @include("blogetc::partials.full_post_details") - - - @if(config("blogetc.comments.type_of_comments_to_show","built_in") !== 'disabled') - <div class="" id='maincommentscontainer'> - <h2 class='text-center' id='blogetccomments'>Comments</h2> - @include("blogetc::partials.show_comments") - </div> - @else - {{--Comments are disabled--}} - @endif - - - </div> - </div> - </div> - -@endsection - -@section('blog-custom-js') - <script src="{{asset('hessam-blog.js')}}"></script> -@endsection \ No newline at end of file diff --git a/src/Views/blogetc_admin/categories/add_category.blade.php b/src/Views/blogetc_admin/categories/add_category.blade.php deleted file mode 100755 index 2ecdc64..0000000 --- a/src/Views/blogetc_admin/categories/add_category.blade.php +++ /dev/null @@ -1,113 +0,0 @@ -@extends("blogetc_admin::layouts.admin_layout") -@section("content") - - - <h5>Admin - Add Category</h5> - - <form method='post' action='{{route("blogetc.admin.categories.create_category")}}' enctype="multipart/form-data" > - - @csrf - - <script> - SHOULD_AUTO_GEN_SLUG = false; - - /* Generate the slug field, if it was not touched by the user (or if it was an empty string) */ - function populate_slug_field() { - -// alert("A"); - var cat_slug = document.getElementById('category_slug'); - - if (cat_slug.value.length < 1) { - // if the slug field is empty, make sure it auto generates - SHOULD_AUTO_GEN_SLUG = true; - } - - if (SHOULD_AUTO_GEN_SLUG) { - // the slug hasn't been manually changed (or it was set above), so we should generate the slug - // This is done in two stages - one to remove non words/spaces etc, the another to replace white space (and underscore) with a - - cat_slug.value =document.getElementById("category_category_name").value.toLowerCase() - .replace(/[^\w-_ ]+/g, '') // replace with nothing - .replace(/[_ ]+/g, '-') // replace _ and spaces with - - .substring(0,99); // limit str length - - } - - } - </script> - <div class="form-group"> - <label for="category_category_name">Category Name</label> - - <input type="text" - class="form-control" - id="category_category_name" - oninput="populate_slug_field();" - required - aria-describedby="category_category_name_help" - name='category_name' - value="{{old("category_name",$category->category_name)}}" - > - - <small id="category_category_name_help" class="form-text text-muted">The name of the category</small> - </div> - - - <div class="form-group"> - <label for="category_slug">Category slug</label> - <input - maxlength='100' - pattern="[a-zA-Z0-9-]+" - type="text" - required - class="form-control" - id="category_slug" - oninput="SHOULD_AUTO_GEN_SLUG=false;" - aria-describedby="category_slug_help" - name='slug' - value="{{old("slug",$category->slug)}}" - > - - <small id="category_slug_help" class="form-text text-muted"> - Letters, numbers, dash only. The slug - i.e. {{route("blogetc.view_category","")}}/<u><em>this_part</em></u>. This must be unique (two categories can't - share the same slug). - - </small> - </div> - - <div class="form-group"> - <label for="category_slug">Parent Category</label> - <select name='parent_id' class='form-control'> - <option selected='selected' value='0'> - Root - </option> - @foreach($categories_list as $category) - <option value='{{$category->id}}'> - {{$category->category_name}} - </option> - @endforeach - </select> - </div> - - - <div class="form-group"> - <label for="category_description">Category Description (optional)</label> - <textarea name='category_description' - class='form-control' - id='category_description'>{{old("category_description",$category->category_description)}}</textarea> - - </div> - - <script> - if (document.getElementById("category_slug").value.length < 1) { - SHOULD_AUTO_GEN_SLUG = true; - } else { - SHOULD_AUTO_GEN_SLUG = false; // there is already a value in #category_slug, so lets pretend it was changed already. - } - </script> - - - <input type='submit' class='btn btn-primary' value='Add new category' > - - </form> - -@endsection diff --git a/src/Views/blogetc_admin/categories/deleted_category.blade.php b/src/Views/blogetc_admin/categories/deleted_category.blade.php deleted file mode 100755 index 64030de..0000000 --- a/src/Views/blogetc_admin/categories/deleted_category.blade.php +++ /dev/null @@ -1,7 +0,0 @@ -@extends("blogetc_admin::layouts.admin_layout") -@section("content") - - -<div class='alert alert-success'><b>Deleted that category</b></div> - -@endsection \ No newline at end of file diff --git a/src/Views/blogetc_admin/posts/add_post.blade.php b/src/Views/blogetc_admin/posts/add_post.blade.php deleted file mode 100755 index 9bf2090..0000000 --- a/src/Views/blogetc_admin/posts/add_post.blade.php +++ /dev/null @@ -1,16 +0,0 @@ -@extends("blogetc_admin::layouts.admin_layout") -@section("content") - - - <h5>Admin - Add post</h5> - - <form method='post' action='{{route("blogetc.admin.store_post")}}' enctype="multipart/form-data" > - - @csrf - @include("blogetc_admin::posts.form", ['post' => new \WebDevEtc\BlogEtc\Models\BlogEtcPost()]) - - <input type='submit' class='btn btn-primary' value='Add new post' > - - </form> - -@endsection diff --git a/src/Views/blogetc_admin/posts/edit_post.blade.php b/src/Views/blogetc_admin/posts/edit_post.blade.php deleted file mode 100755 index e3e337c..0000000 --- a/src/Views/blogetc_admin/posts/edit_post.blade.php +++ /dev/null @@ -1,19 +0,0 @@ -@extends("blogetc_admin::layouts.admin_layout") -@section("content") - - - <h5>Admin - Editing post - <a target='_blank' href='{{$post->url()}}' class='float-right btn btn-primary'>View post</a> - </h5> - - <form method='post' action='{{route("blogetc.admin.update_post",$post->id)}}' enctype="multipart/form-data" > - - @csrf - @method("patch") - @include("blogetc_admin::posts.form", ['post' => $post]) - - <input type='submit' class='btn btn-primary' value='Save Changes' > - - </form> - -@endsection \ No newline at end of file diff --git a/src/css/admin-setup.css b/src/css/admin-setup.css new file mode 100644 index 0000000..4f34ba9 --- /dev/null +++ b/src/css/admin-setup.css @@ -0,0 +1,954 @@ +a { + color: #2CA8FF; +} + +a:hover, a:focus { + color: #109CFF; +} + +a:focus, a:active, +button::-moz-focus-inner, +input[type="reset"]::-moz-focus-inner, +input[type="button"]::-moz-focus-inner, +input[type="submit"]::-moz-focus-inner, +select::-moz-focus-inner, +input[type="file"] > input[type="button"]::-moz-focus-inner, +input[type="button"]:focus { + outline: 0 !important; +} + +.btn:focus, +.btn:hover, +.btn:active { + outline: 0; +} + +/* Animations */ +.form-control, .input-group-addon { + -webkit-transition: all 300ms linear; + -moz-transition: all 300ms linear; + -o-transition: all 300ms linear; + -ms-transition: all 300ms linear; + transition: all 300ms linear; +} + +.image-container { + min-height: 100vh; + background-position: center center; + background-size: cover; +} + +.wizard-container { + padding-top: 100px; + z-index: 3; +} + +.wizard-navigation { + position: relative; +} + +.made-with-mk { + width: 50px; + height: 50px; + display: block; + position: fixed; + z-index: 555; + bottom: 40px; + right: 40px; + border-radius: 30px; + background-color: rgba(16, 16, 16, 0.35); + border: 1px solid rgba(255, 255, 255, 0.15); + color: #FFFFFF; + cursor: pointer; + padding: 10px 12px; + white-space: nowrap; + overflow: hidden; + -webkit-transition: 0.55s cubic-bezier(0.6, 0, 0.4, 1); + -moz-transition: 0.55s cubic-bezier(0.6, 0, 0.4, 1); + -o-transition: 0.55s cubic-bezier(0.6, 0, 0.4, 1); + transition: 0.55s cubic-bezier(0.6, 0, 0.4, 1); +} +.made-with-mk:hover, .made-with-mk:active, .made-with-mk:focus { + width: 218px; + color: #FFFFFF; + transition-duration: .55s; + padding: 10px 30px; +} +.made-with-mk:hover .made-with, .made-with-mk:active .made-with, .made-with-mk:focus .made-with { + opacity: 1; +} +.made-with-mk:hover .brand, .made-with-mk:active .brand, .made-with-mk:focus .brand { + left: 0; +} +.made-with-mk .brand, +.made-with-mk .made-with { + float: left; +} +.made-with-mk .brand { + position: relative; + top: 3px; + left: -1px; + letter-spacing: 1px; + vertical-align: middle; + font-size: 16px; + font-weight: 600; +} +.made-with-mk .made-with { + color: rgba(255, 255, 255, 0.6); + position: absolute; + left: 75px; + top: 15px; + opacity: 0; + margin: 0; + -webkit-transition: 0.55s cubic-bezier(0.6, 0, 0.4, 1); + -moz-transition: 0.55s cubic-bezier(0.6, 0, 0.4, 1); + -o-transition: 0.55s cubic-bezier(0.6, 0, 0.4, 1); + transition: 0.55s cubic-bezier(0.6, 0, 0.4, 1); +} +.made-with-mk .made-with strong { + font-weight: 400; + color: rgba(255, 255, 255, 0.9); + letter-spacing: 1px; +} + +/* Font Smoothing */ +h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6, p, .navbar, .brand, .btn-simple { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; +} + +/* Typography */ +h1, .h1, h2, .h2, h3, .h3, h4, .h4 { + font-weight: 400; + margin: 30px 0 15px; +} + +h1, .h1 { + font-size: 52px; +} + +h2, .h2 { + font-size: 36px; +} + +h3, .h3 { + font-size: 28px; + margin: 20px 0 10px; +} + +h4, .h4 { + font-size: 22px; +} + +h5, .h5 { + font-size: 16px; +} + +h6, .h6 { + font-size: 14px; + font-weight: bold; + text-transform: uppercase; +} + +p { + font-size: 16px; + line-height: 1.6180em; +} + +h1 small, h2 small, h3 small, h4 small, h5 small, h6 small, .h1 small, .h2 small, .h3 small, .h4 small, .h5 small, .h6 small, h1 .small, h2 .small, h3 .small, h4 .small, h5 .small, h6 .small, .h1 .small, .h2 .small, .h3 .small, .h4 .small, .h5 .small, .h6 .small { + color: #999999; + font-weight: 300; + line-height: 1; +} + +h1 small, h2 small, h3 small, h1 .small, h2 .small, h3 .small { + font-size: 60%; +} + +h1 .subtitle { + display: block; + font-family: 'Grand Hotel',cursive; + line-height: 40px; + margin: 15px 0 30px; +} + +.card { + background-color: #FFFFFF; + padding: 10px 0 20px; + width: 100%; +} + +.wizard-card { + min-height: 410px; + background-color: #FFFFFF; + box-shadow: 0 0 15px rgba(0, 0, 0, 0.15), 0 0 1px 1px rgba(0, 0, 0, 0.1); + border-radius: 10px; + padding: 10px 0; +} +.wizard-card .picture-container { + position: relative; + cursor: pointer; + text-align: center; +} +.wizard-card .picture { + width: 106px; + height: 106px; + background-color: #999999; + border: 4px solid #CCCCCC; + color: #FFFFFF; + border-radius: 50%; + margin: 5px auto; + overflow: hidden; + transition: all 0.2s; + -webkit-transition: all 0.2s; +} +.wizard-card .picture:hover { + border-color: #2ca8ff; +} +.wizard-card .picture input[type="file"] { + cursor: pointer; + display: block; + height: 100%; + left: 0; + opacity: 0 !important; + position: absolute; + top: 0; + width: 100%; +} +.wizard-card .picture-src { + width: 100%; +} +.wizard-card .tab-content { + min-height: 340px; + padding: 20px 10px; +} +.wizard-card .wizard-footer { + padding: 0 10px; +} +.wizard-card .disabled { + display: none; +} +.wizard-card .wizard-header h3 { + font-weight: 200; + text-align: center; +} +.wizard-card[data-color="green"] .choice:hover .icon, .wizard-card[data-color="green"] .choice.active .icon { + border-color: #2787AC; +} +.wizard-card[data-color="green"] .picture:hover { + border-color: #2787AC; +} +.wizard-card[data-color="green"] .moving-tab { + position: absolute; + text-align: center; + padding: 10px; + font-size: 12px; + text-transform: uppercase; + -webkit-font-smoothing: subpixel-antialiased; + background-color: #2787AC; + top: 0px; + left: 0px; + color: #FFFFFF; + cursor: pointer; + font-weight: 500; +} +.wizard-card[data-color="azzure"] .choice:hover .icon, .wizard-card[data-color="azzure"] .choice.active .icon { + border-color: #2CA8FF; +} +.wizard-card[data-color="azzure"] .picture:hover { + border-color: #2CA8FF; +} +.wizard-card[data-color="azzure"] .moving-tab { + position: absolute; + text-align: center; + padding: 10px; + font-size: 12px; + text-transform: uppercase; + -webkit-font-smoothing: subpixel-antialiased; + background-color: #2CA8FF; + top: 0px; + left: 0px; + color: #FFFFFF; + cursor: pointer; + font-weight: 500; +} +.wizard-card[data-color="blue"] .choice:hover .icon, .wizard-card[data-color="blue"] .choice.active .icon { + border-color: #3472F7; +} +.wizard-card[data-color="blue"] .picture:hover { + border-color: #3472F7; +} +.wizard-card[data-color="blue"] .moving-tab { + position: absolute; + text-align: center; + padding: 10px; + font-size: 12px; + text-transform: uppercase; + -webkit-font-smoothing: subpixel-antialiased; + background-color: #3472F7; + top: 0px; + left: 0px; + color: #FFFFFF; + cursor: pointer; + font-weight: 500; +} +.wizard-card[data-color="orange"] .choice:hover .icon, .wizard-card[data-color="orange"] .choice.active .icon { + border-color: #FF9500; +} +.wizard-card[data-color="orange"] .picture:hover { + border-color: #FF9500; +} +.wizard-card[data-color="orange"] .moving-tab { + position: absolute; + text-align: center; + padding: 10px; + font-size: 12px; + text-transform: uppercase; + -webkit-font-smoothing: subpixel-antialiased; + background-color: #FF9500; + top: 0px; + left: 0px; + color: #FFFFFF; + cursor: pointer; + font-weight: 500; +} +.wizard-card[data-color="red"] .choice:hover .icon, .wizard-card[data-color="red"] .choice.active .icon { + border-color: #FF3B30; +} +.wizard-card[data-color="red"] .picture:hover { + border-color: #FF3B30; +} +.wizard-card[data-color="red"] .moving-tab { + position: absolute; + text-align: center; + padding: 10px; + font-size: 12px; + text-transform: uppercase; + -webkit-font-smoothing: subpixel-antialiased; + background-color: #FF3B30; + top: 0px; + left: 0px; + color: #FFFFFF; + cursor: pointer; + font-weight: 500; +} +.wizard-card .btn { + text-transform: uppercase; +} +.wizard-card .info-text { + text-align: center; + font-weight: 300; + margin: 10px 0 30px; +} +.wizard-card .choice { + text-align: center; + cursor: pointer; + margin-top: 20px; +} +.wizard-card .choice .icon { + text-align: center; + vertical-align: middle; + height: 116px; + width: 116px; + border-radius: 50%; + background-color: #999999; + color: #FFFFFF; + margin: 0 auto 20px; + border: 4px solid #CCCCCC; + transition: all 0.2s; + -webkit-transition: all 0.2s; +} +.wizard-card .choice i { + font-size: 30px; + line-height: 111px; +} +.wizard-card .choice:hover .icon, .wizard-card .choice.active .icon { + border-color: #2ca8ff; +} +.wizard-card .choice input[type="radio"], +.wizard-card .choice input[type="checkbox"] { + position: absolute; + left: -10000px; + z-index: -1; +} +.wizard-card .btn-finish { + display: none; +} +.wizard-card .description { + color: #999999; + font-size: 14px; +} + +/* Inputs */ +.form-control { + background-color: #FFFFFF; + border: 1px solid #E3E3E3; + border-radius: 4px; + box-shadow: none; + color: #444444; + height: 38px; + padding: 6px 16px; +} +.form-control:focus { + background-color: #FFFFFF; + border: 1px solid #9A9A9A; + box-shadow: none; + outline: 0 none; +} +.form-control + .form-control-feedback { + border-radius: 6px; + font-size: 14px; + padding: 0 12px 0 0; + position: absolute; + right: 25px; + top: 13px; + vertical-align: middle; +} +.has-success .form-control, .has-error .form-control, .has-success .form-control:focus, .has-error .form-control:focus { + border-color: #E3E3E3; + box-shadow: none; +} +.has-success .form-control, +.form-control .has-success .form-control-feedback, .form-control.valid:focus { + border-color: #2787AC; + color: #2787AC; +} +.has-error .form-control, +.form-control .has-error .form-control-feedback, .form-control.error { + color: #FF3B30; + border-color: #FF3B30; +} +.form-control:focus + .input-group-addon, .form-control:focus ~ .input-group-addon { + background-color: #FFFFFF; + border-color: #9A9A9A; +} +.form-control ::-moz-placeholder { + color: #DDDDDD; + opacity: 1; +} +.form-control ::-moz-placeholder { + color: #DDDDDD; + opacity: 1; +} +.form-control ::-webkit-input-placeholder { + color: #DDDDDD; + opacity: 1; +} +.form-control ::-ms-input-placeholder { + color: #DDDDDD; + opacity: 1; +} +.form-control[disabled], .form-control[readonly], fieldset[disabled] .form-control { + background-color: #EEEEEE; + color: #999999; + cursor: not-allowed; +} + +.input-lg { + height: 56px; + padding: 10px 16px; +} + +.input-group-addon { + background-color: #FFFFFF; + border: 1px solid #E3E3E3; + border-radius: 4px; +} + +.input-group .form-control:first-child, .input-group-addon:first-child, .input-group-btn:first-child > .btn, .input-group-btn:first-child > .dropdown-toggle, .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle) { + border-right: 0 none; +} + +.input-group .form-control:last-child, .input-group-addon:last-child, .input-group-btn:last-child > .btn, .input-group-btn:last-child > .dropdown-toggle, .input-group-btn:first-child > .btn:not(:first-child) { + border-left: 0 none; +} + +.btn { + border-width: 2px; + background-color: transparent; + font-weight: 400; + opacity: 0.8; + padding: 8px 16px; +} +.btn:active, .btn.active { + background-image: none; + box-shadow: none; +} +.btn.disabled, .btn[disabled], fieldset[disabled] .btn { + opacity: 0.45; +} + +.btn-round { + border-width: 1px; + border-radius: 30px !important; + opacity: 0.79; + padding: 9px 18px; +} + +.btn-sm, .btn-xs { + border-radius: 3px; + font-size: 12px; + padding: 5px 10px; +} + +.btn-xs { + padding: 1px 5px; +} + +.btn-lg { + border-radius: 6px; + font-size: 18px; + font-weight: 400; + padding: 14px 30px; +} + +.btn-wd { + min-width: 100px; +} + +.btn-default { + color: #777777; + border-color: #999999; +} + +.btn-primary { + color: #3472F7; + border-color: #3472F7; +} + +.btn-info { + color: #2CA8FF; + border-color: #2CA8FF; +} + +.btn-success { + color: #2787AC; + border-color: #2787AC; +} + +.btn-warning { + color: #FF9500; + border-color: #FF9500; +} + +.btn-danger { + color: #FF3B30; + border-color: #FF3B30; +} + +.btn:hover { + background-color: transparent; + opacity: 1; +} + +.btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open .dropdown-toggle .btn-primary { + color: #1D62F0; + border-color: #1D62F0; + background-color: transparent; +} + +.btn-info:hover, .btn-info:focus, .btn-info:active, .btn-info.active, .open .dropdown-toggle .btn-info { + color: #109CFF; + border-color: #109CFF; + background-color: transparent; +} + +.btn-success:hover, .btn-success:focus, .btn-success:active, .btn-success.active, .open .dropdown-toggle .btn-success { + color: #049F0C; + border-color: #049F0C; + background-color: transparent; +} + +.btn-warning:hover, .btn-warning:focus, .btn-warning:active, .btn-warning.active, .open .dropdown-toggle .btn-warning { + color: #ED8D00; + border-color: #ED8D00; + background-color: transparent; +} + +.btn-danger:hover, .btn-danger:focus, .btn-danger:active, .btn-danger.active, .open .dropdown-toggle .btn-danger { + color: #EE2D20; + border-color: #EE2D20; + background-color: transparent; +} + +.btn-default:hover, .btn-default:focus, .btn-default.active, .open .dropdown-toggle .btn-default { + color: #666666; + border-color: #888888; + background-color: transparent; +} + +.btn-primary.disabled, .btn-primary[disabled], fieldset[disabled] .btn-primary, .btn-primary.disabled:hover, .btn-primary[disabled]:hover, fieldset[disabled] .btn-primary:hover, .btn-primary.disabled:focus, .btn-primary[disabled]:focus, fieldset[disabled] .btn-primary:focus, .btn-primary.disabled:active, .btn-primary[disabled]:active, fieldset[disabled] .btn-primary:active, .btn-primary.disabled.active, .btn-primary.active[disabled], fieldset[disabled] .btn-primary.active { + background-color: transparent; + border-color: #3472F7; +} + +.btn-info.disabled, .btn-info[disabled], fieldset[disabled] .btn-info, .btn-info.disabled:hover, .btn-info[disabled]:hover, fieldset[disabled] .btn-info:hover, .btn-info.disabled:focus, .btn-info[disabled]:focus, fieldset[disabled] .btn-info:focus, .btn-info.disabled:active, .btn-info[disabled]:active, fieldset[disabled] .btn-info:active, .btn-info.disabled.active, .btn-info.active[disabled], fieldset[disabled] .btn-info.active { + background-color: transparent; + border-color: #2CA8FF; +} + +.btn-success.disabled, .btn-success[disabled], fieldset[disabled] .btn-success, .btn-success.disabled:hover, .btn-success[disabled]:hover, fieldset[disabled] .btn-success:hover, .btn-success.disabled:focus, .btn-success[disabled]:focus, fieldset[disabled] .btn-success:focus, .btn-success.disabled:active, .btn-success[disabled]:active, fieldset[disabled] .btn-success:active, .btn-success.disabled.active, .btn-success.active[disabled], fieldset[disabled] .btn-success.active { + background-color: transparent; + border-color: #2787AC; +} + +.btn-danger.disabled, .btn-danger[disabled], fieldset[disabled] .btn-danger, .btn-danger.disabled:hover, .btn-danger[disabled]:hover, fieldset[disabled] .btn-danger:hover, .btn-danger.disabled:focus, .btn-danger[disabled]:focus, fieldset[disabled] .btn-danger:focus, .btn-danger.disabled:active, .btn-danger[disabled]:active, fieldset[disabled] .btn-danger:active, .btn-danger.disabled.active, .btn-danger.active[disabled], fieldset[disabled] .btn-danger.active { + background-color: transparent; + border-color: #FF3B30; +} + +.btn-warning.disabled, .btn-warning[disabled], fieldset[disabled] .btn-warning, .btn-warning.disabled:hover, .btn-warning[disabled]:hover, fieldset[disabled] .btn-warning:hover, .btn-warning.disabled:focus, .btn-warning[disabled]:focus, fieldset[disabled] .btn-warning:focus, .btn-warning.disabled:active, .btn-warning[disabled]:active, fieldset[disabled] .btn-warning:active, .btn-warning.disabled.active, .btn-warning.active[disabled], fieldset[disabled] .btn-warning.active { + background-color: transparent; + border-color: #FF9500; +} + +/* Buttons fill .btn-fill */ +.btn-fill { + color: #FFFFFF; + opacity: 1; +} +.btn-fill:hover, .btn-fill:active, .btn-fill:focus { + color: #FFFFFF; +} +.btn-fill.btn-default { + background-color: #999999; + border-color: #999999; +} +.btn-fill.btn-default:hover, .btn-fill.btn-default:focus, .btn-fill.btn-default:active, .btn-fill.btn-default.active, .open .dropdown-toggle .btn-fill.btn-default { + background-color: #888888; + border-color: #888888; +} +.btn-fill.btn-primary { + background-color: #3472F7; + border-color: #3472F7; +} +.btn-fill.btn-primary:hover, .btn-fill.btn-primary:focus, .btn-fill.btn-primary:active, .btn-fill.btn-primary.active, .open .dropdown-toggle .btn-fill.btn-primary { + border-color: #1D62F0; + background-color: #1D62F0; +} +.btn-fill.btn-info { + background-color: #2CA8FF; + border-color: #2CA8FF; +} +.btn-fill.btn-info:hover, .btn-fill.btn-info:focus, .btn-fill.btn-info:active, .btn-fill.btn-info.active, .open .dropdown-toggle .btn-fill.btn-info { + background-color: #109CFF; + border-color: #109CFF; +} +.btn-fill.btn-success { + background-color: #2787AC; + border-color: #2787AC; +} +.btn-fill.btn-warning { + background-color: #FF9500; + border-color: #FF9500; +} +.btn-fill.btn-warning:hover, .btn-fill.btn-warning:focus, .btn-fill.btn-warning:active, .btn-fill.btn-warning.active, .open .dropdown-toggle .btn-fill.btn-warning { + background-color: #ED8D00; + border-color: #ED8D00; +} +.btn-fill.btn-danger { + background-color: #FF3B30; + border-color: #FF3B30; +} +.btn-fill.btn-danger:hover, .btn-fill.btn-danger:focus, .btn-fill.btn-danger:active, .btn-fill.btn-danger.active, .open .dropdown-toggle .btn-fill.btn-danger { + background-color: #EE2D20; + border-color: #EE2D20; +} + +/* End Buttons fill */ +.btn-simple { + font-weight: 600; + border: 0; + padding: 10px 18px; +} +.btn-simple.btn-xs { + padding: 3px 5px; +} +.btn-simple.btn-sm { + padding: 7px 10px; +} +.btn-simple.btn-lg { + padding: 16px 60px; +} + +.btn-round.btn-xs { + padding: 2px 5px; +} +.btn-round.btn-sm { + padding: 6px 10px; +} +.btn-round.btn-lg { + padding: 15px 30px; +} + +/* Navigation menu */ +.nav-pills { + background-color: #999999; +} +.nav-pills > li + li { + margin-left: 0; +} +.nav-pills > li > a { + border: 1px solid #2CA8FF; + border-radius: 0; + color: #2CA8FF; + border: 0 !important; + text-transform: uppercase; + background-color: #999999; + text-align: center; + color: #FFFFFF !important; + font-size: 12px; + cursor: pointer; +} +.nav-pills > li > a:focus, .nav-pills > li > a:hover { + background-color: #999999; +} +.nav-pills > li.active > a, +.nav-pills > li.active > a:focus, +.nav-pills > li.active > a:hover { + background-color: inherit; +} + +.text-primary, .text-primary:hover { + color: #3472F7; +} + +.text-info, .text-info:hover { + color: #2CA8FF; +} + +.text-success, .text-success:hover { + color: #2787AC; +} + +.text-warning, .text-warning:hover { + color: #FF9500; +} + +.text-danger, .text-danger:hover { + color: #FF3B30; +} + +/* Labels & Progress-bar */ +.label { + padding: 0.2em 0.6em 0.2em; + border: 1px solid #999999; + border-radius: 3px; + color: #999999; + background-color: #FFFFFF; + font-weight: 500; + font-size: 11px; + text-transform: uppercase; +} +.label.label-fill { + color: #FFFFFF; +} + +.label-primary { + border-color: #3472F7; + color: #3472F7; +} + +.label-info { + border-color: #2CA8FF; + color: #2CA8FF; +} + +.label-success { + border-color: #2787AC; + color: #2787AC; +} + +.label-warning { + border-color: #FF9500; + color: #FF9500; +} + +.label-danger { + border-color: #FF3B30; + color: #FF3B30; +} + +label { + font-weight: 400; +} + +label.error { + color: #FF3B30; + margin-top: 5px; + margin-bottom: 0; +} + +label small { + color: #999999; +} + +.label-primary.label-fill, .progress-bar, .progress-bar-primary { + background-color: #3472F7; +} + +.label-info.label-fill, .progress-bar-info { + background-color: #2CA8FF; +} + +.label-success.label-fill, .progress-bar-success { + background-color: #2787AC; +} + +.label-warning.label-fill, .progress-bar-warning { + background-color: #FF9500; +} + +.label-danger.label-fill, .progress-bar-danger { + background-color: #FF3B30; +} + +.label-default.label-fill { + background-color: #999999; +} + +.tooltip { + font-size: 14px; + font-weight: bold; +} + +.tooltip-arrow { + display: none; + opacity: 0; +} + +.tooltip-inner { + background-color: #FAE6A4; + border-radius: 4px; + box-shadow: 0 1px 13px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(115, 71, 38, 0.23); + color: #734726; + max-width: 200px; + padding: 6px 10px; + text-align: center; + text-decoration: none; +} +.tooltip-inner:after { + content: ""; + display: inline-block; + left: 100%; + margin-left: -56%; + position: absolute; +} +.tooltip-inner:before { + content: ""; + display: inline-block; + left: 100%; + margin-left: -56%; + position: absolute; +} + +.tooltip.top { + margin-top: -11px; + padding: 0; +} +.tooltip.top .tooltip-inner:after { + border-top: 11px solid #FAE6A4; + border-left: 11px solid transparent; + border-right: 11px solid transparent; + bottom: -10px; +} +.tooltip.top .tooltip-inner:before { + border-top: 11px solid rgba(0, 0, 0, 0.2); + border-left: 11px solid transparent; + border-right: 11px solid transparent; + bottom: -11px; +} + +.tooltip.bottom { + margin-top: 11px; + padding: 0; +} +.tooltip.bottom .tooltip-inner:after { + border-bottom: 11px solid #FAE6A4; + border-left: 11px solid transparent; + border-right: 11px solid transparent; + top: -10px; +} +.tooltip.bottom .tooltip-inner:before { + border-bottom: 11px solid rgba(0, 0, 0, 0.2); + border-left: 11px solid transparent; + border-right: 11px solid transparent; + top: -11px; +} + +.tooltip.left { + margin-left: -11px; + padding: 0; +} +.tooltip.left .tooltip-inner:after { + border-left: 11px solid #FAE6A4; + border-top: 11px solid transparent; + border-bottom: 11px solid transparent; + right: -10px; + left: auto; + margin-left: 0; +} +.tooltip.left .tooltip-inner:before { + border-left: 11px solid rgba(0, 0, 0, 0.2); + border-top: 11px solid transparent; + border-bottom: 11px solid transparent; + right: -11px; + left: auto; + margin-left: 0; +} + +.tooltip.right { + margin-left: 11px; + padding: 0; +} +.tooltip.right .tooltip-inner:after { + border-right: 11px solid #FAE6A4; + border-top: 11px solid transparent; + border-bottom: 11px solid transparent; + left: -10px; + top: 0; + margin-left: 0; +} +.tooltip.right .tooltip-inner:before { + border-right: 11px solid rgba(0, 0, 0, 0.2); + border-top: 11px solid transparent; + border-bottom: 11px solid transparent; + left: -11px; + top: 0; + margin-left: 0; +} + +.footer { + position: relative; + bottom: 20px; + right: 0px; + width: 100%; + color: #706f6f; + z-index: 4; + text-align: center; + margin-top: 60px; +} +.footer a { + color: #FFFFFF; +} +.footer .heart { + color: #FF3B30; +} + +@media (max-width: 768px) { + .main .container { + margin-bottom: 50px; + } +} +@media (min-width: 768px) { + .navbar-form { + margin-top: 21px; + margin-bottom: 21px; + padding-left: 5px; + padding-right: 5px; + } + + .btn-wd { + min-width: 140px; + } +} diff --git a/src/css/hessam-blog.css b/src/css/binshops-blog.css similarity index 83% rename from src/css/hessam-blog.css rename to src/css/binshops-blog.css index 585188e..e8edc54 100644 --- a/src/css/hessam-blog.css +++ b/src/css/binshops-blog.css @@ -23,4 +23,8 @@ width: 100%; height: 100%; background-color: #E16036; -} \ No newline at end of file +} + +.binshops-cat-hierarchy { + list-style-type: none !important; +} diff --git a/src/css/blogetc_admin_css.css b/src/css/binshopsblog_admin_css.css similarity index 99% rename from src/css/blogetc_admin_css.css rename to src/css/binshopsblog_admin_css.css index 77dd7da..48562d3 100644 --- a/src/css/blogetc_admin_css.css +++ b/src/css/binshopsblog_admin_css.css @@ -22,7 +22,7 @@ From laravel 5.6 background-color: #212529 !important; } -.hessam-version{ +.binshops-version{ margin: 0px !important; padding: 10px; } @@ -31,7 +31,7 @@ From laravel 5.6 color: #212529 !important; } -.hessam-blog-title{ +.binshops-blog-title{ position: absolute; left: 20px; } @@ -43,3 +43,53 @@ body{ .nav-bar-full{ height: 100% !important; } + +.wtree li { + list-style-type: none; + margin: 10px 0 10px 10px; + position: relative; +} +.wtree li:before { + content: ""; + position: absolute; + top: -10px; + left: -20px; + border-left: 1px solid #ddd; + border-bottom: 1px solid #ddd; + width: 20px; + height: 15px; +} +.wtree li:after { + position: absolute; + content: ""; + top: 5px; + left: -20px; + border-left: 1px solid #ddd; + border-top: 1px solid #ddd; + width: 20px; + height: 100%; +} +.wtree li:last-child:after { + display: none; +} +.wtree li span { + display: block; + border: 1px solid #ddd; + padding: 5px; + color: #888; + text-decoration: none; +} + +.wtree li span:hover, .wtree li span:focus { + background: #eee; + color: #000; + border: 1px solid #aaa; +} +.wtree li span:hover + ul li span, .wtree li span:focus + ul li span { + background: #eee; + color: #000; + border: 1px solid #aaa; +} +.wtree li span:hover + ul li:after, .wtree li span:hover + ul li:before, .wtree li span:focus + ul li:after, .wtree li span:focus + ul li:before { + border-color: #aaa; +} diff --git a/src/js/hessam-blog.js b/src/js/binshops-blog.js similarity index 100% rename from src/js/hessam-blog.js rename to src/js/binshops-blog.js diff --git a/src/routes.php b/src/routes.php index dec1d93..3d78ad5 100755 --- a/src/routes.php +++ b/src/routes.php @@ -1,128 +1,171 @@ <?php -Route::group(['middleware' => ['web'], 'namespace' => '\WebDevEtc\BlogEtc\Controllers'], function () { +Route::group(['middleware' => ['web'], 'namespace' => '\BinshopsBlog\Controllers'], function () { + /** The main public facing blog routes - show all posts, view a category, view a single post, also the add comment route */ + Route::group(['prefix' => "/{locale}/".config('binshopsblog.blog_prefix', 'blog')], function () { - /** The main public facing blog routes - show all posts, view a category, rss feed, view a single post, also the add comment route */ - Route::group(['prefix' => config('blogetc.blog_prefix', 'blog')], function () { + Route::get('/', 'BinshopsReaderController@index') + ->name('binshopsblog.index'); - Route::get('/', 'BlogEtcReaderController@index') - ->name('blogetc.index'); + Route::get('/search', 'BinshopsReaderController@search') + ->name('binshopsblog.search'); - Route::get('/search', 'BlogEtcReaderController@search') - ->name('blogetc.search'); + Route::get('/category{subcategories}', 'BinshopsReaderController@view_category')->where('subcategories', '^[a-zA-Z0-9-_\/]+$')->name('binshopsblog.view_category'); - Route::get('/feed', 'BlogEtcRssFeedController@feed') - ->name('blogetc.feed'); //RSS feed + Route::get('/{blogPostSlug}', + 'BinshopsReaderController@viewSinglePost') + ->name('binshopsblog.single'); - Route::get('/category{subcategories}', 'BlogEtcReaderController@view_category')->where('subcategories', '^[a-zA-Z0-9-_\/]+$')->name('blogetc.view_category'); + // throttle to a max of 10 attempts in 3 minutes: + Route::group(['middleware' => 'throttle:10,3'], function () { + Route::post('save_comment/{blogPostSlug}', + 'BinshopsCommentWriterController@addNewComment') + ->name('binshopsblog.comments.add_new_comment'); + }); + }); -// Route::get('/category/{categorySlug}', -// 'BlogEtcReaderController@view_category') -// ->name('blogetc.view_category'); + Route::group(['prefix' => config('binshopsblog.blog_prefix', 'blog')], function () { - Route::get('/{blogPostSlug}', - 'BlogEtcReaderController@viewSinglePost') - ->name('blogetc.single'); + Route::get('/', 'BinshopsReaderController@index') + ->name('binshopsblognolocale.index'); + Route::get('/search', 'BinshopsReaderController@search') + ->name('binshopsblognolocale.search'); + + Route::get('/category{subcategories}', 'BinshopsReaderController@view_category')->where('subcategories', '^[a-zA-Z0-9-_\/]+$')->name('binshopsblognolocale.view_category'); + + Route::get('/{blogPostSlug}', + 'BinshopsReaderController@viewSinglePost') + ->name('binshopsblognolocale.single'); // throttle to a max of 10 attempts in 3 minutes: Route::group(['middleware' => 'throttle:10,3'], function () { - Route::post('save_comment/{blogPostSlug}', - 'BlogEtcCommentWriterController@addNewComment') - ->name('blogetc.comments.add_new_comment'); - - + 'BinshopsCommentWriterController@addNewComment') + ->name('binshopsblognolocale.comments.add_new_comment'); }); - }); - /* Admin backend routes - CRUD for posts, categories, and approving/deleting submitted comments */ - Route::group(['prefix' => config('blogetc.admin_prefix', 'blog_admin')], function () { + Route::group(['prefix' => config('binshopsblog.admin_prefix', 'blog_admin')], function () { + + Route::get('/search', + 'BinshopsAdminController@searchBlog') + ->name('binshopsblog.admin.searchblog'); - Route::get('/', 'BlogEtcAdminController@index') - ->name('blogetc.admin.index'); + Route::get('/setup', 'BinshopsAdminSetupController@setup') + ->name('binshopsblog.admin.setup'); + + Route::post('/setup-submit', 'BinshopsAdminSetupController@setup_submit') + ->name('binshopsblog.admin.setup_submit'); + + Route::get('/', 'BinshopsAdminController@index') + ->name('binshopsblog.admin.index'); Route::get('/add_post', - 'BlogEtcAdminController@create_post') - ->name('blogetc.admin.create_post'); + 'BinshopsAdminController@create_post') + ->name('binshopsblog.admin.create_post'); Route::post('/add_post', - 'BlogEtcAdminController@store_post') - ->name('blogetc.admin.store_post'); + 'BinshopsAdminController@store_post') + ->name('binshopsblog.admin.store_post'); + Route::post('/add_post_toggle', + 'BinshopsAdminController@store_post_toggle') + ->name('binshopsblog.admin.store_post_toggle'); Route::get('/edit_post/{blogPostId}', - 'BlogEtcAdminController@edit_post') - ->name('blogetc.admin.edit_post'); + 'BinshopsAdminController@edit_post') + ->name('binshopsblog.admin.edit_post'); + + Route::post('/edit_post_toggle/{blogPostId}', + 'BinshopsAdminController@edit_post_toggle') + ->name('binshopsblog.admin.edit_post_toggle'); - Route::patch('/edit_post/{blogPostId}', - 'BlogEtcAdminController@update_post') - ->name('blogetc.admin.update_post'); + Route::post('/edit_post/{blogPostId}', + 'BinshopsAdminController@update_post') + ->name('binshopsblog.admin.update_post'); //Removes post's photo - Route::get('/remove_photo/{slug}', - 'BlogEtcAdminController@remove_photo') - ->name('blogetc.admin.remove_photo'); + Route::get('/remove_photo/{slug}/{lang_id}', + 'BinshopsAdminController@remove_photo') + ->name('binshopsblog.admin.remove_photo'); Route::group(['prefix' => "image_uploads",], function () { - Route::get("/", "BlogEtcImageUploadController@index")->name("blogetc.admin.images.all"); - - Route::get("/upload", "BlogEtcImageUploadController@create")->name("blogetc.admin.images.upload"); - Route::post("/upload", "BlogEtcImageUploadController@store")->name("blogetc.admin.images.store"); + Route::get("/", "BinshopsImageUploadController@index")->name("binshopsblog.admin.images.all"); + Route::get("/upload", "BinshopsImageUploadController@create")->name("binshopsblog.admin.images.upload"); + Route::post("/upload", "BinshopsImageUploadController@store")->name("binshopsblog.admin.images.store"); }); - Route::delete('/delete_post/{blogPostId}', - 'BlogEtcAdminController@destroy_post') - ->name('blogetc.admin.destroy_post'); + 'BinshopsAdminController@destroy_post') + ->name('binshopsblog.admin.destroy_post'); Route::group(['prefix' => 'comments',], function () { Route::get('/', - 'BlogEtcCommentsAdminController@index') - ->name('blogetc.admin.comments.index'); + 'BinshopsCommentsAdminController@index') + ->name('binshopsblog.admin.comments.index'); Route::patch('/{commentId}', - 'BlogEtcCommentsAdminController@approve') - ->name('blogetc.admin.comments.approve'); + 'BinshopsCommentsAdminController@approve') + ->name('binshopsblog.admin.comments.approve'); Route::delete('/{commentId}', - 'BlogEtcCommentsAdminController@destroy') - ->name('blogetc.admin.comments.delete'); + 'BinshopsCommentsAdminController@destroy') + ->name('binshopsblog.admin.comments.delete'); }); Route::group(['prefix' => 'categories'], function () { Route::get('/', - 'BlogEtcCategoryAdminController@index') - ->name('blogetc.admin.categories.index'); + 'BinshopsCategoryAdminController@index') + ->name('binshopsblog.admin.categories.index'); Route::get('/add_category', - 'BlogEtcCategoryAdminController@create_category') - ->name('blogetc.admin.categories.create_category'); - Route::post('/add_category', - 'BlogEtcCategoryAdminController@store_category') - ->name('blogetc.admin.categories.store_category'); + 'BinshopsCategoryAdminController@create_category') + ->name('binshopsblog.admin.categories.create_category'); + Route::post('/store_category', + 'BinshopsCategoryAdminController@store_category') + ->name('binshopsblog.admin.categories.store_category'); Route::get('/edit_category/{categoryId}', - 'BlogEtcCategoryAdminController@edit_category') - ->name('blogetc.admin.categories.edit_category'); + 'BinshopsCategoryAdminController@edit_category') + ->name('binshopsblog.admin.categories.edit_category'); Route::patch('/edit_category/{categoryId}', - 'BlogEtcCategoryAdminController@update_category') - ->name('blogetc.admin.categories.update_category'); + 'BinshopsCategoryAdminController@update_category') + ->name('binshopsblog.admin.categories.update_category'); Route::delete('/delete_category/{categoryId}', - 'BlogEtcCategoryAdminController@destroy_category') - ->name('blogetc.admin.categories.destroy_category'); - + 'BinshopsCategoryAdminController@destroy_category') + ->name('binshopsblog.admin.categories.destroy_category'); }); + Route::group(['prefix' => 'languages'], function () { + + Route::get('/', + 'BinshopsLanguageAdminController@index') + ->name('binshopsblog.admin.languages.index'); + + Route::get('/add_language', + 'BinshopsLanguageAdminController@create_language') + ->name('binshopsblog.admin.languages.create_language'); + Route::post('/add_language', + 'BinshopsLanguageAdminController@store_language') + ->name('binshopsblog.admin.languages.store_language'); + + Route::delete('/delete_language/{languageId}', + 'BinshopsLanguageAdminController@destroy_language') + ->name('binshopsblog.admin.languages.destroy_language'); + + Route::post('/toggle_language/{languageId}', + 'BinshopsLanguageAdminController@toggle_language') + ->name('binshopsblog.admin.languages.toggle_language'); + }); }); }); diff --git a/tests/CaptchaTest.php b/tests/CaptchaTest.php index 649adb3..dfa7f34 100644 --- a/tests/CaptchaTest.php +++ b/tests/CaptchaTest.php @@ -6,7 +6,7 @@ class CaptchaTest extends \Tests\TestCase public function testBasicCaptchaMethodsReturnCorrectType() { - $captcha = new \WebDevEtc\BlogEtc\Captcha\Basic(); + $captcha = new \BinshopsBlog\Captcha\Basic(); $this->assertEquals(gettype($captcha->captcha_field_name()), "string"); $this->assertEquals(gettype($captcha->view()), "string"); $this->assertEquals(gettype($captcha->rules()), "array"); @@ -16,7 +16,7 @@ public function testBasicCaptchaMethodsReturnCorrectType() public function testRuleCustomValidationFunctionReturnsCorrectly() { - $captcha = new \WebDevEtc\BlogEtc\Captcha\Basic(); + $captcha = new \BinshopsBlog\Captcha\Basic(); foreach ($captcha->rules() as $rule) { @@ -31,32 +31,32 @@ public function testRuleCustomValidationFunctionReturnsCorrectly() // testing CORRECT answer (should return null) - \Config::set('blogetc.captcha.basic_answers', "ignoreme,dark,ignoreme2"); + \Config::set('binshopsblog.captcha.basic_answers', "ignoreme,dark,ignoreme2"); $this->assertNull($rule('correct1', 'dark', function () { return "lookingforthis"; })); // testing WRONG answer - \Config::set('blogetc.captcha.basic_answers', "ignoreme,dark,ignoreme2"); + \Config::set('binshopsblog.captcha.basic_answers', "ignoreme,dark,ignoreme2"); $this->assertEquals($rule('wrong1', 'light', function () { return "lookingforthis"; }), "lookingforthis"); // testing CORRECT answer - \Config::set('blogetc.captcha.basic_answers', "bLAcK"); + \Config::set('binshopsblog.captcha.basic_answers', "bLAcK"); $this->assertNull($rule('wrong1', 'black', function () { return "lookingforthis"; })); // testing CORRECT answer - \Config::set('blogetc.captcha.basic_answers', "bLAcK"); + \Config::set('binshopsblog.captcha.basic_answers', "bLAcK"); $this->assertNull($rule('wrong1', ' black', function () { return "lookingforthis"; })); // testing CORRECT answer - \Config::set('blogetc.captcha.basic_answers', "ignoreme, BLACK , jgnoreme2"); + \Config::set('binshopsblog.captcha.basic_answers', "ignoreme, BLACK , jgnoreme2"); $this->assertNull($rule('wrong1', ' black', function () { return "lookingforthis"; })); diff --git a/tests/MainTest.php b/tests/MainTest.php index e436964..9d08a2f 100644 --- a/tests/MainTest.php +++ b/tests/MainTest.php @@ -20,11 +20,10 @@ class MainTest extends \Tests\TestCase Testing the author_email, author_website. /blog/... - blogetc.index YES - blogetc.feed YES - blogetc.view_category no - but this is basically blogetc.index - blogetc.single YES - blogetc.comments.add_new_comment YES - tested multiple times with/without basic captcha on/off/correct/incorrect. + binshopsblog.index YES + binshopsblog.view_category no - but this is basically binshopsblog.index + binshopsblog.single YES + binshopsblog.comments.add_new_comment YES - tested multiple times with/without basic captcha on/off/correct/incorrect. Also tested with diff configs for comment form: disabled built_in @@ -32,27 +31,27 @@ class MainTest extends \Tests\TestCase custom /blog_admin/... - blogetc.admin.index YES - blogetc.admin.create_post no - but is just a form - blogetc.admin.store_post YES - blogetc.admin.edit_post YES - but no extra checks - blogetc.admin.update_post YES - blogetc.admin.destroy_post YES + binshopsblog.admin.index YES + binshopsblog.admin.create_post no - but is just a form + binshopsblog.admin.store_post YES + binshopsblog.admin.edit_post YES - but no extra checks + binshopsblog.admin.update_post YES + binshopsblog.admin.destroy_post YES /blog_admin/comments/... - blogetc.admin.comments.index YES - blogetc.admin.comments.approve YES - blogetc.admin.comments.delete YES + binshopsblog.admin.comments.index YES + binshopsblog.admin.comments.approve YES + binshopsblog.admin.comments.delete YES /blog_admin/categories/... - blogetc.admin.categories.index - blogetc.admin.categories.create_category no - but is just a form - blogetc.admin.categories.store_category YES - blogetc.admin.categories.edit_category no - but is just a form - blogetc.admin.categories.update_category - blogetc.admin.categories.destroy_category YES + binshopsblog.admin.categories.index + binshopsblog.admin.categories.create_category no - but is just a form + binshopsblog.admin.categories.store_category YES + binshopsblog.admin.categories.edit_category no - but is just a form + binshopsblog.admin.categories.update_category + binshopsblog.admin.categories.destroy_category YES @@ -63,16 +62,16 @@ class MainTest extends \Tests\TestCase public function testFilesArePresent() { - $this->assertFileExists(config_path("blogetc.php"), "/config/blogetc.php should exist - currently no file with that filename is found"); - $this->assertTrue(is_array(include(config_path("blogetc.php"))), "/config/blogetc.php should exist - currently no file with that filename is found"); + $this->assertFileExists(config_path("binshopsblog.php"), "/config/binshopsblog.php should exist - currently no file with that filename is found"); + $this->assertTrue(is_array(include(config_path("binshopsblog.php"))), "/config/binshopsblog.php should exist - currently no file with that filename is found"); } public function testImageSizesAreSane() { - $this->assertTrue(count(config("blogetc.image_sizes")) >= 3); + $this->assertTrue(count(config("binshopsblog.image_sizes")) >= 3); - foreach (config("blogetc.image_sizes") as $image_key => $image_info) { + foreach (config("binshopsblog.image_sizes") as $image_key => $image_info) { $this->assertArrayHasKey("w", $image_info); $this->assertArrayHasKey("h", $image_info); @@ -94,13 +93,13 @@ public function testImageSizesAreSane() } - public function testUserHasNanManageBlogEtcPostsMethod() + public function testUserHasNanManageBinshopsBlogPostsMethod() { - $this->assertTrue(method_exists(\App\User::class, "canManageBlogEtcPosts"), "Your User model must have the canManageBlogEtcPosts method"); + $this->assertTrue(method_exists(\App\User::class, "canManageBinshopsBlogPosts"), "Your User model must have the canManageBinshopsBlogPosts method"); $user = new \App\User(); - $this->assertTrue(is_bool($user->canManageBlogEtcPosts())); + $this->assertTrue(is_bool($user->canManageBinshopsBlogPosts())); } @@ -109,7 +108,7 @@ public function testUserHasNanManageBlogEtcPostsMethod() public function testCanSeeAdminPanel() { - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); \Auth::logout(); // without a logged in user, should give error @@ -126,7 +125,7 @@ public function testCanSeeAdminPanel() $response->assertStatus(200); // check user can see admin area: - $this->assertTrue($user->canManageBlogEtcPosts()); + $this->assertTrue($user->canManageBinshopsBlogPosts()); $response = $this->get($admin_panel_url); // check if we can see the admin panel correctly @@ -138,10 +137,10 @@ public function testCanSeeAdminPanel() $response->assertSee("Add Category"); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); // $user=$this->create_admin_user(); - $this->assertTrue($user->canManageBlogEtcPosts()); + $this->assertTrue($user->canManageBinshopsBlogPosts()); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); @@ -155,7 +154,7 @@ public function testCanSeeAdminPanel() $new_object_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_posts', $search_for_obj); + $this->assertDatabaseMissing('binshops_posts', $search_for_obj); $response = $this->post($admin_panel_url . "/add_post", $new_object_vals); $response->assertSessionHasNoErrors(); @@ -163,7 +162,7 @@ public function testCanSeeAdminPanel() $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); } @@ -174,9 +173,9 @@ public function testCanCreatePost() $user = $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); - $this->assertTrue($user->canManageBlogEtcPosts()); + $this->assertTrue($user->canManageBinshopsBlogPosts()); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); @@ -188,13 +187,13 @@ public function testCanCreatePost() $new_object_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_posts', $search_for_obj); + $this->assertDatabaseMissing('binshops_posts', $search_for_obj); $response = $this->post($admin_panel_url . "/add_post", $new_object_vals); $response->assertSessionHasNoErrors(); $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); } @@ -206,9 +205,9 @@ public function testCanCreatePostThenEditIt() $user = $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); - $this->assertTrue($user->canManageBlogEtcPosts()); + $this->assertTrue($user->canManageBinshopsBlogPosts()); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); @@ -221,20 +220,20 @@ public function testCanCreatePostThenEditIt() $new_object_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_posts', $search_for_obj); + $this->assertDatabaseMissing('binshops_posts', $search_for_obj); $response = $this->post($admin_panel_url . "/add_post", $new_object_vals); $response->assertSessionHasNoErrors(); $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); - $justCreatedRow = \WebDevEtc\BlogEtc\Models\BlogEtcPost::where("slug", $new_object_vals['slug'])->firstOrFail(); + $justCreatedRow = \BinshopsBlog\Models\BinshopsPost::where("slug", $new_object_vals['slug'])->firstOrFail(); $new_object_vals['title'] = "New title " . str_random(); - $this->assertDatabaseMissing('blog_etc_posts', ['title' => $new_object_vals['title']]); + $this->assertDatabaseMissing('binshops_posts', ['title' => $new_object_vals['title']]); $response = $this->patch($admin_panel_url . "/edit_post/" . $justCreatedRow->id, $new_object_vals); $response->assertStatus(302); - $this->assertDatabaseHas('blog_etc_posts', ['title' => $new_object_vals['title']]); + $this->assertDatabaseHas('binshops_posts', ['title' => $new_object_vals['title']]); } @@ -246,9 +245,9 @@ public function testCreatePostThenCheckIsViewableToPublic() $user = $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); - $this->assertTrue($user->canManageBlogEtcPosts()); + $this->assertTrue($user->canManageBinshopsBlogPosts()); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); @@ -263,17 +262,16 @@ public function testCreatePostThenCheckIsViewableToPublic() $new_object_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_posts', $search_for_obj); + $this->assertDatabaseMissing('binshops_posts', $search_for_obj); // check we don't see it at moment - $response = $this->get(config("blogetc.blog_prefix", "blog")); + $response = $this->get(config("binshopsblog.blog_prefix", "blog")); $response->assertDontSee($new_object_vals['slug']); - // must clear the cache, as the /feed is cached + // must clear the cache \Artisan::call('cache:clear'); - $response = $this->get(config("blogetc.blog_prefix", "blog") . "/feed"); $response->assertDontSee($new_object_vals['slug']); $response = $this->post($admin_panel_url . "/add_post", $new_object_vals); @@ -281,26 +279,25 @@ public function testCreatePostThenCheckIsViewableToPublic() $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); // logout - so we are guest user \Auth::logout(); - $response = $this->get(config("blogetc.blog_prefix", "blog")); + $response = $this->get(config("binshopsblog.blog_prefix", "blog")); // if we see the slug (which is str_random()) we can safely assume that there was a link to the post, so it is working ok. of course it would depend a bit on your template but this should work. $response->assertSee($new_object_vals['slug']); - // must clear the cache, as the /feed is cached + // must clear the cache \Artisan::call('cache:clear'); - $response = $this->get(config("blogetc.blog_prefix", "blog") . "/feed"); $response->assertSee($new_object_vals['slug']); $response->assertSee($new_object_vals['title']); // now check single post is viewable - $response = $this->get(route("blogetc.single", $new_object_vals['slug'])); + $response = $this->get(route("binshopsblog.single", $new_object_vals['slug'])); $response->assertStatus(200); $response->assertSee($new_object_vals['slug']); $response->assertSee($new_object_vals['title']); @@ -313,7 +310,7 @@ public function testCreatePostWithNotPublishedThenCheckIsNotViewableToPublic() { - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); list($new_object_vals, $search_for_obj) = $this->prepare_post_creation(); $new_object_vals['is_published'] = false; @@ -323,19 +320,19 @@ public function testCreatePostWithNotPublishedThenCheckIsNotViewableToPublic() $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); // must log out, as the admin user can see posts dated in future \Auth::logout(); - $response = $this->get(config("blogetc.blog_prefix", "blog")); + $response = $this->get(config("binshopsblog.blog_prefix", "blog")); // if we see the slug (which is str_random()) we can safely assume that there was a link to the post, so it is working ok. of course it would depend a bit on your template but this should work. $response->assertDontSee($new_object_vals['slug']); // now check single post is viewable - $response = $this->get(config("blogetc.blog_prefix", "blog") . "/" . $new_object_vals['slug']); + $response = $this->get(config("binshopsblog.blog_prefix", "blog") . "/" . $new_object_vals['slug']); $response->assertStatus(404); $response->assertDontSee($new_object_vals['slug']); $response->assertDontSee($new_object_vals['title']); @@ -348,7 +345,7 @@ public function testCreatePostWithFuturePostedAtThenCheckIsNotViewableToPublic() { - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); list($new_object_vals, $search_for_obj) = $this->prepare_post_creation(); $new_object_vals['posted_at'] = \Carbon\Carbon::now()->addMonths(12); @@ -358,19 +355,19 @@ public function testCreatePostWithFuturePostedAtThenCheckIsNotViewableToPublic() $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); // must log out, as the admin user can see posts dated in future \Auth::logout(); - $response = $this->get(config("blogetc.blog_prefix", "blog")); + $response = $this->get(config("binshopsblog.blog_prefix", "blog")); // if we see the slug (which is str_random()) we can safely assume that there was a link to the post, so it is working ok. of course it would depend a bit on your template but this should work. $response->assertDontSee($new_object_vals['slug']); // now check single post is viewable - $response = $this->get(config("blogetc.blog_prefix", "blog") . "/" . $new_object_vals['slug']); + $response = $this->get(config("binshopsblog.blog_prefix", "blog") . "/" . $new_object_vals['slug']); $response->assertStatus(404); $response->assertDontSee($new_object_vals['slug']); $response->assertDontSee($new_object_vals['title']); @@ -383,16 +380,16 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveCommentWithBas { - \Config::set('blogetc.comments.auto_approve_comments', false); - \Config::set('blogetc.captcha.captcha_enabled', true); - \Config::set('blogetc.captcha.captcha_type', \WebDevEtc\BlogEtc\Captcha\Basic::class); - $captcha = new \WebDevEtc\BlogEtc\Captcha\Basic(); - \Config::set('blogetc.captcha.basic_question', "a test question"); - \Config::set('blogetc.captcha.basic_answers', "answer1,answer2"); + \Config::set('binshopsblog.comments.auto_approve_comments', false); + \Config::set('binshopsblog.captcha.captcha_enabled', true); + \Config::set('binshopsblog.captcha.captcha_type', \BinshopsBlog\Captcha\Basic::class); + $captcha = new \BinshopsBlog\Captcha\Basic(); + \Config::set('binshopsblog.captcha.basic_question', "a test question"); + \Config::set('binshopsblog.captcha.basic_answers', "answer1,answer2"); $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); // to verify this was added to database. Use a different variable, so we can add things (like _token) and still be able to assertDatabaseHas later. @@ -409,10 +406,10 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveCommentWithBas $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); - \Config::set('blogetc.comments.type_of_comments_to_show', 'built_in'); + \Config::set('binshopsblog.comments.type_of_comments_to_show', 'built_in'); $comment_detail = [ @@ -421,11 +418,11 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveCommentWithBas 'comment' => str_random(), $captcha->captcha_field_name() => "wronganswer1", // << WRONG CAPTCHA ]; - $this->assertDatabaseMissing('blog_etc_comments', ['author_name' => $comment_detail['author_name']]); - $response = $this->post(config("blogetc.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); + $this->assertDatabaseMissing('binshops_comments', ['author_name' => $comment_detail['author_name']]); + $response = $this->post(config("binshopsblog.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); $response->assertStatus(302); - $this->assertDatabaseMissing('blog_etc_comments', ['author_name' => $comment_detail['author_name']]); + $this->assertDatabaseMissing('binshops_comments', ['author_name' => $comment_detail['author_name']]); $comment_detail = [ @@ -434,11 +431,11 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveCommentWithBas 'comment' => str_random(), // << NO CAPTCHA FIELD ]; - $this->assertDatabaseMissing('blog_etc_comments', ['author_name' => $comment_detail['author_name']]); - $response = $this->post(config("blogetc.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); + $this->assertDatabaseMissing('binshops_comments', ['author_name' => $comment_detail['author_name']]); + $response = $this->post(config("binshopsblog.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); $response->assertStatus(302); - $this->assertDatabaseMissing('blog_etc_comments', ['author_name' => $comment_detail['author_name']]); + $this->assertDatabaseMissing('binshops_comments', ['author_name' => $comment_detail['author_name']]); } @@ -448,14 +445,14 @@ public function testCreatePostThenSetCommentsToDisabledAndCheckNoneShow() { - \Config::set('blogetc.comments.type_of_comments_to_show', "disabled"); + \Config::set('binshopsblog.comments.type_of_comments_to_show', "disabled"); $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); - $newblogpost = new \WebDevEtc\BlogEtc\Models\BlogEtcPost; + $newblogpost = new \BinshopsBlog\Models\BinshopsPost; $newblogpost->title=__METHOD__ . " " . time(); @@ -480,14 +477,14 @@ public function testCreatePostThenSetCommentsToDisabledAndCheckNoneShow() } public function testCreatePostThenSetCommentsToDisqusAndCheckDisqusJSIsShown() { - \Config::set('blogetc.comments.type_of_comments_to_show', "disqus"); + \Config::set('binshopsblog.comments.type_of_comments_to_show', "disqus"); $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); - $newblogpost = new \WebDevEtc\BlogEtc\Models\BlogEtcPost; + $newblogpost = new \BinshopsBlog\Models\BinshopsPost; $newblogpost->title=__METHOD__ . " " . time(); @@ -510,14 +507,14 @@ public function testCreatePostThenSetCommentsToCustomAndCheckCustomErrorShows() { - \Config::set('blogetc.comments.type_of_comments_to_show', "custom"); + \Config::set('binshopsblog.comments.type_of_comments_to_show', "custom"); $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); - $newblogpost = new \WebDevEtc\BlogEtc\Models\BlogEtcPost; + $newblogpost = new \BinshopsBlog\Models\BinshopsPost; $newblogpost->title=__METHOD__ . " " . time(); @@ -541,16 +538,16 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveCommentWithBas { - \Config::set('blogetc.comments.auto_approve_comments', false); - \Config::set('blogetc.captcha.captcha_enabled', true); - \Config::set('blogetc.captcha.captcha_type', \WebDevEtc\BlogEtc\Captcha\Basic::class); - $captcha = new \WebDevEtc\BlogEtc\Captcha\Basic(); - \Config::set('blogetc.captcha.basic_question', "a test question"); - \Config::set('blogetc.captcha.basic_answers', "answer1,answer2"); + \Config::set('binshopsblog.comments.auto_approve_comments', false); + \Config::set('binshopsblog.captcha.captcha_enabled', true); + \Config::set('binshopsblog.captcha.captcha_type', \BinshopsBlog\Captcha\Basic::class); + $captcha = new \BinshopsBlog\Captcha\Basic(); + \Config::set('binshopsblog.captcha.basic_question', "a test question"); + \Config::set('binshopsblog.captcha.basic_answers', "answer1,answer2"); $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); // to verify this was added to database. Use a different variable, so we can add things (like _token) and still be able to assertDatabaseHas later. @@ -566,10 +563,10 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveCommentWithBas $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); - \Config::set('blogetc.comments.type_of_comments_to_show', 'built_in'); + \Config::set('binshopsblog.comments.type_of_comments_to_show', 'built_in'); $comment_detail = [ @@ -578,28 +575,28 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveCommentWithBas 'comment' => str_random(), $captcha->captcha_field_name() => "AnsWer2", ]; - $this->assertDatabaseMissing('blog_etc_comments', ['author_name' => $comment_detail['author_name']]); - $response = $this->post(config("blogetc.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); + $this->assertDatabaseMissing('binshops_comments', ['author_name' => $comment_detail['author_name']]); + $response = $this->post(config("binshopsblog.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); $response->assertStatus(200); - \Config::set('blogetc.captcha.auto_approve_comments', false); + \Config::set('binshopsblog.captcha.auto_approve_comments', false); - $this->assertDatabaseHas('blog_etc_comments', ['approved' => false, 'author_name' => $comment_detail['author_name']]); + $this->assertDatabaseHas('binshops_comments', ['approved' => false, 'author_name' => $comment_detail['author_name']]); - $justAddedRow = \WebDevEtc\BlogEtc\Models\BlogEtcComment::withoutGlobalScopes()->where('author_name', $comment_detail['author_name'])->firstOrFail(); + $justAddedRow = \BinshopsBlog\Models\BinshopsComment::withoutGlobalScopes()->where('author_name', $comment_detail['author_name'])->firstOrFail(); - $response = $this->get(route("blogetc.admin.comments.index")); + $response = $this->get(route("binshopsblog.admin.comments.index")); $response->assertSee($justAddedRow->author_name); // approve it: - $response = $this->patch(route("blogetc.admin.comments.approve", $justAddedRow->id), [ + $response = $this->patch(route("binshopsblog.admin.comments.approve", $justAddedRow->id), [ '_token' => csrf_token(), ]); // check it was approved $response->assertStatus(302); - $this->assertDatabaseHas('blog_etc_comments', ['approved' => 1, 'author_name' => $justAddedRow->author_name]); + $this->assertDatabaseHas('binshops_comments', ['approved' => 1, 'author_name' => $justAddedRow->author_name]); } @@ -607,12 +604,12 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveCommentWithBas public function testCreatePostThenCheckCanCreateCommentThenApproveComment() { - \Config::set('blogetc.comments.auto_approve_comments', false); - \Config::set('blogetc.captcha.captcha_enabled', false); + \Config::set('binshopsblog.comments.auto_approve_comments', false); + \Config::set('binshopsblog.captcha.captcha_enabled', false); $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); // to verify this was added to database. Use a different variable, so we can add things (like _token) and still be able to assertDatabaseHas later. @@ -628,11 +625,11 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveComment() $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); - \Config::set('blogetc.comments.type_of_comments_to_show', 'built_in'); - \Config::set('blogetc.captcha.captcha_enabled', false); + \Config::set('binshopsblog.comments.type_of_comments_to_show', 'built_in'); + \Config::set('binshopsblog.captcha.captcha_enabled', false); $comment_detail = [ @@ -640,29 +637,29 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveComment() 'author_name' => str_random(), 'comment' => str_random(), ]; - $this->assertDatabaseMissing('blog_etc_comments', ['author_name' => $comment_detail['author_name']]); - $response = $this->post(config("blogetc.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); + $this->assertDatabaseMissing('binshops_comments', ['author_name' => $comment_detail['author_name']]); + $response = $this->post(config("binshopsblog.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); $response->assertStatus(200); - \Config::set('blogetc.captcha.auto_approve_comments', false); + \Config::set('binshopsblog.captcha.auto_approve_comments', false); - $this->assertDatabaseHas('blog_etc_comments', ['approved' => false, 'author_name' => $comment_detail['author_name']]); + $this->assertDatabaseHas('binshops_comments', ['approved' => false, 'author_name' => $comment_detail['author_name']]); - $justAddedRow = \WebDevEtc\BlogEtc\Models\BlogEtcComment::withoutGlobalScopes()->where('author_name', $comment_detail['author_name'])->firstOrFail(); + $justAddedRow = \BinshopsBlog\Models\BinshopsComment::withoutGlobalScopes()->where('author_name', $comment_detail['author_name'])->firstOrFail(); - $response = $this->get(route("blogetc.admin.comments.index")); + $response = $this->get(route("binshopsblog.admin.comments.index")); $response->assertSee($justAddedRow->author_name); // approve it: - $response = $this->patch(route("blogetc.admin.comments.approve", $justAddedRow->id), [ + $response = $this->patch(route("binshopsblog.admin.comments.approve", $justAddedRow->id), [ '_token' => csrf_token(), ]); // check it was approved $response->assertStatus(302); - $this->assertDatabaseHas('blog_etc_comments', ['approved' => 1, 'author_name' => $justAddedRow->author_name]); + $this->assertDatabaseHas('binshops_comments', ['approved' => 1, 'author_name' => $justAddedRow->author_name]); } @@ -670,12 +667,12 @@ public function testCreatePostThenCheckCanCreateCommentThenApproveComment() public function testCreatePostThenCheckCanCreateCommentThenDeleteComment() { - \Config::set('blogetc.comments.auto_approve_comments', false); - \Config::set('blogetc.captcha.captcha_enabled', false); + \Config::set('binshopsblog.comments.auto_approve_comments', false); + \Config::set('binshopsblog.captcha.captcha_enabled', false); $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); // to verify this was added to database. Use a different variable, so we can add things (like _token) and still be able to assertDatabaseHas later. @@ -691,43 +688,43 @@ public function testCreatePostThenCheckCanCreateCommentThenDeleteComment() $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); - if (config("blogetc.comments.type_of_comments_to_show") === 'built_in') { + if (config("binshopsblog.comments.type_of_comments_to_show") === 'built_in') { $comment_detail = [ '_token' => csrf_token(), 'author_name' => str_random(), 'comment' => str_random(), ]; - $this->assertDatabaseMissing('blog_etc_comments', ['author_name' => $comment_detail['author_name']]); - $response = $this->post(config("blogetc.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); + $this->assertDatabaseMissing('binshops_comments', ['author_name' => $comment_detail['author_name']]); + $response = $this->post(config("binshopsblog.blog_prefix", "blog") . "/save_comment/" . $new_object_vals['slug'], $comment_detail); $response->assertSessionHasNoErrors(); $response->assertStatus(200); - $this->assertDatabaseHas('blog_etc_comments', ['author_name' => $comment_detail['author_name']]); + $this->assertDatabaseHas('binshops_comments', ['author_name' => $comment_detail['author_name']]); - $justAddedRow = \WebDevEtc\BlogEtc\Models\BlogEtcComment::withoutGlobalScopes()->where('author_name', $comment_detail['author_name'])->firstOrFail(); + $justAddedRow = \BinshopsBlog\Models\BinshopsComment::withoutGlobalScopes()->where('author_name', $comment_detail['author_name'])->firstOrFail(); // check the just added row exists... - $response = $this->get(route("blogetc.admin.comments.index")); + $response = $this->get(route("binshopsblog.admin.comments.index")); $response->assertSee($justAddedRow->author_name); // delete it: - $response = $this->delete(route("blogetc.admin.comments.delete", $justAddedRow->id), [ + $response = $this->delete(route("binshopsblog.admin.comments.delete", $justAddedRow->id), [ '_token' => csrf_token(), ]); // check it was deleted (it will deleted if approved) $response->assertStatus(302); //check it doesnt exist in database - $this->assertDatabaseMissing('blog_etc_comments', ['id' => $justAddedRow->id,]); + $this->assertDatabaseMissing('binshops_comments', ['id' => $justAddedRow->id,]); } else { - dump("NOT TESTING COMMENT FEATURE, as config(\"blogetc.comments.type_of_comments_to_show\") is not set to 'built_in')"); + dump("NOT TESTING COMMENT FEATURE, as config(\"binshopsblog.comments.type_of_comments_to_show\") is not set to 'built_in')"); } } @@ -739,9 +736,9 @@ public function testCanCreateThenDeletePost() $user = $this->create_admin_user(); - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); - $this->assertTrue($user->canManageBlogEtcPosts()); + $this->assertTrue($user->canManageBinshopsBlogPosts()); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); @@ -754,30 +751,30 @@ public function testCanCreateThenDeletePost() $new_object_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_posts', $search_for_obj); + $this->assertDatabaseMissing('binshops_posts', $search_for_obj); $response = $this->post($admin_panel_url . "/add_post", $new_object_vals); $response->assertSessionHasNoErrors(); $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_posts', $search_for_obj); + $this->assertDatabaseHas('binshops_posts', $search_for_obj); - $justCreatedRow = \WebDevEtc\BlogEtc\Models\BlogEtcPost::where("slug", $new_object_vals['slug'])->firstOrFail(); + $justCreatedRow = \BinshopsBlog\Models\BinshopsPost::where("slug", $new_object_vals['slug'])->firstOrFail(); $id = $justCreatedRow->id; $delete_url = $admin_panel_url . "/delete_post/" . $id; $response = $this->delete($delete_url, ['_token' => csrf_token()]); $response->assertStatus(200); - $this->assertDatabaseMissing('blog_etc_posts', $search_for_obj); + $this->assertDatabaseMissing('binshops_posts', $search_for_obj); } public function testCanCreateCategory() { - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $this->create_admin_user(); // now lets create a category $new_cat_vals = [ @@ -786,11 +783,11 @@ public function testCanCreateCategory() ]; $search_for_new_cat = $new_cat_vals; $new_cat_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_categories', $search_for_new_cat); + $this->assertDatabaseMissing('binshops_categories', $search_for_new_cat); $response = $this->post($admin_panel_url . "/categories/add_category", $new_cat_vals); $response->assertSessionHasNoErrors(); $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_categories', $search_for_new_cat); + $this->assertDatabaseHas('binshops_categories', $search_for_new_cat); } @@ -800,7 +797,7 @@ public function testCanCreateCategoryThenEditIt() { - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $this->create_admin_user(); @@ -814,15 +811,15 @@ public function testCanCreateCategoryThenEditIt() // create a post so we can edit it later $search_for_new_cat = $new_cat_vals; $new_cat_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_categories', $search_for_new_cat); + $this->assertDatabaseMissing('binshops_categories', $search_for_new_cat); $response = $this->post($admin_panel_url . "/categories/add_category", $new_cat_vals); $response->assertSessionHasNoErrors(); $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_categories', $search_for_new_cat); + $this->assertDatabaseHas('binshops_categories', $search_for_new_cat); // get the just inserted row - $justCreatedRow = \WebDevEtc\BlogEtc\Models\BlogEtcCategory::where("slug", $new_cat_vals['slug'])->firstOrFail(); + $justCreatedRow = \BinshopsBlog\Models\BinshopsCategory::where("slug", $new_cat_vals['slug'])->firstOrFail(); // get the edit page (form) @@ -837,12 +834,12 @@ public function testCanCreateCategoryThenEditIt() $new_object_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_categories', ['category_name' => $new_object_vals['category_name']]); + $this->assertDatabaseMissing('binshops_categories', ['category_name' => $new_object_vals['category_name']]); // send the request to save the changes $response = $this->patch( - route("blogetc.admin.categories.update_category", $justCreatedRow->id), + route("binshopsblog.admin.categories.update_category", $justCreatedRow->id), $new_object_vals ); @@ -850,7 +847,7 @@ public function testCanCreateCategoryThenEditIt() $response->assertStatus(302); // check it was a redirect // check that the edited category name is in the database. - $this->assertDatabaseHas('blog_etc_categories', ['slug' => $new_object_vals['slug'], 'category_name' => $new_object_vals['category_name']]); + $this->assertDatabaseHas('binshops_categories', ['slug' => $new_object_vals['slug'], 'category_name' => $new_object_vals['category_name']]); } @@ -858,7 +855,7 @@ public function testCanCreateCategoryThenEditIt() public function testCanDeleteCategory() { - $admin_panel_url = config("blogetc.admin_prefix", "blog_admin"); + $admin_panel_url = config("binshopsblog.admin_prefix", "blog_admin"); $this->create_admin_user(); // now lets create a category $new_cat_vals = [ @@ -867,21 +864,21 @@ public function testCanDeleteCategory() ]; $search_for_new_cat = $new_cat_vals; $new_cat_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_categories', $search_for_new_cat); + $this->assertDatabaseMissing('binshops_categories', $search_for_new_cat); $response = $this->post($admin_panel_url . "/categories/add_category", $new_cat_vals); $response->assertSessionHasNoErrors(); $response->assertStatus(302); // redirect - $this->assertDatabaseHas('blog_etc_categories', $search_for_new_cat); + $this->assertDatabaseHas('binshops_categories', $search_for_new_cat); - $justCreatedRow = \WebDevEtc\BlogEtc\Models\BlogEtcCategory::where("slug", $new_cat_vals['slug'])->firstOrFail(); + $justCreatedRow = \BinshopsBlog\Models\BinshopsCategory::where("slug", $new_cat_vals['slug'])->firstOrFail(); $id = $justCreatedRow->id; $delete_url = $admin_panel_url . "/categories/delete_category/$id"; $response = $this->delete($delete_url, ['_token' => csrf_token()]); $response->assertStatus(200); - $this->assertDatabaseMissing('blog_etc_categories', $search_for_new_cat); + $this->assertDatabaseMissing('binshops_categories', $search_for_new_cat); } @@ -914,7 +911,7 @@ protected function create_admin_user() $user = $this->getMockBuilder(\App\User::class) ->getMock(); // make sure the user can see admin panel - $user->method("canManageBlogEtcPosts") + $user->method("canManageBinshopsBlogPosts") ->will($this->returnCallback(function () { return true; })); @@ -942,7 +939,7 @@ protected function prepare_post_creation() { $user = $this->create_admin_user(); - $this->assertTrue($user->canManageBlogEtcPosts()); + $this->assertTrue($user->canManageBinshopsBlogPosts()); $new_object_vals = $this->generate_basic_blog_post_with_random_data(); @@ -955,30 +952,30 @@ protected function prepare_post_creation() $new_object_vals['_token'] = csrf_token(); - $this->assertDatabaseMissing('blog_etc_posts', $search_for_obj); + $this->assertDatabaseMissing('binshops_posts', $search_for_obj); // check we don't see it at moment - $response = $this->get(config("blogetc.blog_prefix", "blog")); + $response = $this->get(config("binshopsblog.blog_prefix", "blog")); $response->assertDontSee($new_object_vals['slug']); return array($new_object_vals, $search_for_obj); } - public function testUserModelHasCanManageBlogEtcPostsMethod() + public function testUserModelHasCanManageBinshopsBlogPostsMethod() { $u = new \App\User(); - $this->assertTrue(method_exists($u,"canManageBlogEtcPosts"),"canManageBlogEtcPosts() must be added to User model. Please see WebDevEtc BlogEtc docs for details. It should return true ONLY for the admin users"); + $this->assertTrue(method_exists($u,"canManageBinshopsBlogPosts"),"canManageBinshopsBlogPosts() must be added to User model. Please see binshops BinshopsBlog docs for details. It should return true ONLY for the admin users"); } - public function testUserModelCanManageBlogEtcPostsMethodDoesntAlwaysReturnTrue() + public function testUserModelCanManageBinshopsBlogPostsMethodDoesntAlwaysReturnTrue() { $u = new \App\User(); - $u->id = 9999999; // in case the logic on canManageBlogEtcPosts() checks for a low ID + $u->id = 9999999; // in case the logic on canManageBinshopsBlogPosts() checks for a low ID $u->email = str_random(); // in case the logic looks for a certain email or something. - $this->assertTrue(method_exists($u,"canManageBlogEtcPosts")); + $this->assertTrue(method_exists($u,"canManageBinshopsBlogPosts")); // because this user is just a randomly made one, it probably should not be allowed to edit blog posts. - $this->assertFalse($u->canManageBlogEtcPosts(), "User::canManageBlogEtcPosts() returns true, but it PROBABLY should return false! Otherwise every single user on your site has access to the blog admin panel! This might not be an error though, if your system doesn't allow public registration. But you should look into this. I know this isn't a good way to handle this test, but it seems to make sense."); + $this->assertFalse($u->canManageBinshopsBlogPosts(), "User::canManageBinshopsBlogPosts() returns true, but it PROBABLY should return false! Otherwise every single user on your site has access to the blog admin panel! This might not be an error though, if your system doesn't allow public registration. But you should look into this. I know this isn't a good way to handle this test, but it seems to make sense."); }