Skip to content

Commit

Permalink
Rearrange code & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuell1 committed Aug 12, 2023
1 parent e533cf5 commit 7af76a0
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 90 deletions.
14 changes: 7 additions & 7 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class Plugin extends PluginBase
public function pluginDetails()
{
return [
'name' => 'Content Editor',
'name' => 'Content Editor',
'description' => 'Front-end content editor',
'author' => 'Samuell',
'icon' => 'icon-edit'
'author' => 'Samuell',
'icon' => 'icon-edit'
];
}

Expand All @@ -36,11 +36,11 @@ public function registerSettings()
{
return [
'settings' => [
'label' => 'Content Editor Settings',
'label' => 'Content Editor Settings',
'description' => 'Manage main editor settings.',
'icon' => 'icon-cog',
'class' => 'Samuell\ContentEditor\Models\Settings',
'order' => 500,
'icon' => 'icon-cog',
'class' => 'Samuell\ContentEditor\Models\Settings',
'order' => 500,
'permissions' => ['samuell.contenteditor.access_settings']
]
];
Expand Down
27 changes: 13 additions & 14 deletions components/ContentEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Samuell\ContentEditor\Components;

use Cache;
use File;
use BackendAuth;
use Cms\Classes\Content;
use Cache;
use Cms\Classes\ComponentBase;
use Cms\Classes\Content;
use File;
use RainLab\Translate\Classes\Translator;

use Samuell\ContentEditor\Models\Settings;

class ContentEditor extends ComponentBase
Expand All @@ -27,7 +26,7 @@ class ContentEditor extends ComponentBase
public function componentDetails()
{
return [
'name' => 'Content Editor',
'name' => 'Content Editor',
'description' => 'Edit your front-end content in page.'
];
}
Expand All @@ -36,25 +35,25 @@ public function defineProperties()
{
return [
'file' => [
'title' => 'Content file',
'title' => 'Content file',
'description' => 'Content block filename to edit, optional',
'default' => '',
'type' => 'dropdown'
'default' => '',
'type' => 'dropdown'
],
'fixture' => [
'title' => 'Content block tag with disabled toolbox',
'title' => 'Content block tag with disabled toolbox',
'description' => 'Fixed name for content block, useful for inline texts (headers, spans...)',
'default' => ''
'default' => ''
],
'tools' => [
'title' => 'List of enabled tools',
'title' => 'List of enabled tools',
'description' => 'List of enabled tools for selected content (for all use *)',
'default' => ''
'default' => ''
],
'class' => [
'title' => 'CSS classes',
'title' => 'CSS classes',
'description' => 'CSS class or classes that should be applied to the content block when rendered',
'default' => ''
'default' => ''
],
];
}
Expand Down
2 changes: 1 addition & 1 deletion http/controllers/AdditionalStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Samuell\ContentEditor\Http\Controllers;

use Response;
use Illuminate\Routing\Controller;
use Response;
use Samuell\ContentEditor\Models\Settings;

class AdditionalStylesController extends Controller
Expand Down
30 changes: 15 additions & 15 deletions http/controllers/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

namespace Samuell\ContentEditor\Http\Controllers;

use ApplicationException;
use Exception;
use File;
use Lang;
use Illuminate\Routing\Controller;
use Input;
use Response;
use Exception;
use SystemException;
use ApplicationException;
use Lang;
use Media\Classes\MediaLibrary;
use October\Rain\Filesystem\Definitions as FileDefinitions;
use October\Rain\Resize\Resizer;
use Illuminate\Routing\Controller;
use Response;
use Samuell\ContentEditor\Models\Settings;
use October\Rain\Filesystem\Definitions as FileDefinitions;
use SystemException;

/**
* ImageController
Expand Down Expand Up @@ -69,10 +69,10 @@ public function upload()
list($width, $height) = getimagesize($uploadedFile);

return Response::json([
'url' => MediaLibrary::instance()->getPathUrl($path . '/' . $fileName),
'url' => MediaLibrary::instance()->getPathUrl($path . '/' . $fileName),
'filePath' => $path . '/' . $fileName,
'filename' => $fileName,
'size' => [
'size' => [
$width,
$height
]
Expand Down Expand Up @@ -124,12 +124,12 @@ public function save()
}

return Response::json([
'url' => $url,
'filePath' => $relativeFilePath,
'width' => $width,
'crop' => post('crop'),
'alt' => post('alt'),
'size' => [
'url' => $url,
'filePath' => $relativeFilePath,
'width' => $width,
'crop' => post('crop'),
'alt' => post('alt'),
'size' => [
$width,
$height
]
Expand Down
4 changes: 2 additions & 2 deletions http/middleware/EditorPermissionsMiddleware.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php namespace Samuell\ContentEditor\Http\Middleware;

use Closure;
use Backend\Facades\BackendAuth;
use Closure;

/**
* EditorPermissionsMiddleware
*
*
* Allow only backend user with editor permission
*/
class EditorPermissionsMiddleware
Expand Down
26 changes: 13 additions & 13 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

return [
'plugin' => [
'name' => 'Content Editor',
'name' => 'Content Editor',
'description' => 'Front-end content editor'
],
'settings' => [
'main_settings' => 'Main settings',
'style_palettes' => 'Style palettes',
'style_palettes_desc' => 'Set your style palettes and reuse them on any content. In tab Additional styles you can define CSS/LESS for style palettes.',
'buttons' => 'Buttons',
'permissions' => 'Permissions',
'permissions_comment' => 'Show Content Editor only for',
'image_folder' => 'Images folder name',
'image_folder_comment' => 'Upload images in MediaLibrary folder',
'name' => 'Name',
'class' => 'Class',
'allowed_tags' => 'Allowed tags',
'additional_styles' => 'Additional CSS',
'main_settings' => 'Main settings',
'style_palettes' => 'Style palettes',
'style_palettes_desc' => 'Set your style palettes and reuse them on any content. In tab Additional styles you can define CSS/LESS for style palettes.',
'buttons' => 'Buttons',
'permissions' => 'Permissions',
'permissions_comment' => 'Show Content Editor only for',
'image_folder' => 'Images folder name',
'image_folder_comment' => 'Upload images in MediaLibrary folder',
'name' => 'Name',
'class' => 'Class',
'allowed_tags' => 'Allowed tags',
'additional_styles' => 'Additional CSS',
'additional_styles_label' => 'Addional styles that are included in website. Possibility to use CSS or LESS.'
]
];
26 changes: 13 additions & 13 deletions lang/sk/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

return [
'plugin' => [
'name' => 'Content Editor',
'name' => 'Content Editor',
'description' => 'Front-end content editor'
],
'settings' => [
'main_settings' => 'Hlavné nastavenia',
'style_palettes' => 'Palety štýlov',
'style_palettes_desc' => 'Nastavte si palety štýlov a znovu ich použite na ľubovoľný obsah. V záložke Dodatočné štýly môžete definovať CSS/LESS pre palety štýlov.',
'buttons' => 'Tlačidlá',
'permissions' => 'Práva',
'permissions_comment' => 'Zobraziť Content editor iba pre',
'image_folder' => 'Zložka pre obrázky',
'image_folder_comment' => 'Upload obrázkov do priečinku v MediaLibrary',
'name' => 'Názov',
'class' => 'Trieda',
'allowed_tags' => 'Povolené tagy',
'additional_styles' => 'Dodatočné stýly',
'main_settings' => 'Hlavné nastavenia',
'style_palettes' => 'Palety štýlov',
'style_palettes_desc' => 'Nastavte si palety štýlov a znovu ich použite na ľubovoľný obsah. V záložke Dodatočné štýly môžete definovať CSS/LESS pre palety štýlov.',
'buttons' => 'Tlačidlá',
'permissions' => 'Práva',
'permissions_comment' => 'Zobraziť Content editor iba pre',
'image_folder' => 'Zložka pre obrázky',
'image_folder_comment' => 'Upload obrázkov do priečinku v MediaLibrary',
'name' => 'Názov',
'class' => 'Trieda',
'allowed_tags' => 'Povolené tagy',
'additional_styles' => 'Dodatočné stýly',
'additional_styles_label' => 'Dodatočné stýly ktoré bude importnuté na stránku. Možnosť použiť CSS alebo LESS.'
]
];
46 changes: 23 additions & 23 deletions models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Samuell\ContentEditor\Models;

use Cache;
use File;
use Model;
use Less_Parser;
use Cache;
use Model;

class Settings extends Model
{
Expand All @@ -27,34 +27,34 @@ public function initSettingsData()
public function getEnabledButtonsOptions()
{
return [
'bold' => 'Bold (strong)',
'italic' => 'Italic (em)',
'link' => 'Link (a)',
'small' => 'Small (small)',
'bold' => 'Bold (strong)',
'italic' => 'Italic (em)',
'link' => 'Link (a)',
'small' => 'Small (small)',

'align-left' => 'Align left',
'align-center' => 'Align center',
'align-right' => 'Align right',
'align-left' => 'Align left',
'align-center' => 'Align center',
'align-right' => 'Align right',

'heading' => 'Heading (h1)',
'subheading' => 'Subheading (h2)',
'heading' => 'Heading (h1)',
'subheading' => 'Subheading (h2)',

'subheading3' => 'Subheading3 (h3)',
'subheading4' => 'Subheading4 (h4)',
'subheading5' => 'Subheading5 (h5)',
'subheading3' => 'Subheading3 (h3)',
'subheading4' => 'Subheading4 (h4)',
'subheading5' => 'Subheading5 (h5)',

'paragraph' => 'Paragraph (p)',
'paragraph' => 'Paragraph (p)',
'unordered-list' => 'Unordered list (ul)',
'ordered-list' => 'Ordered list (ol)',
'ordered-list' => 'Ordered list (ol)',

'table' => 'Table',
'indent' => 'Indent',
'unindent' => 'Unindent',
'line-break' => 'Line-break (br)',
'table' => 'Table',
'indent' => 'Indent',
'unindent' => 'Unindent',
'line-break' => 'Line-break (br)',

'image' => 'Image upload',
'video' => 'Video',
'preformatted' => 'Preformatted (pre)',
'image' => 'Image upload',
'video' => 'Video',
'preformatted' => 'Preformatted (pre)',
];
}

Expand Down
4 changes: 2 additions & 2 deletions routes.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Samuell\ContentEditor\Http\Middleware\EditorPermissionsMiddleware;
use Samuell\ContentEditor\Http\Controllers\ImageController;
use Samuell\ContentEditor\Http\Controllers\AdditionalStylesController;
use Samuell\ContentEditor\Http\Controllers\ImageController;
use Samuell\ContentEditor\Http\Middleware\EditorPermissionsMiddleware;

Route::group(['prefix' => 'contenteditor'], function () {

Expand Down

0 comments on commit 7af76a0

Please sign in to comment.