Skip to content

Instantly share code, notes, and snippets.

@Kwaadpepper
Last active September 15, 2019 06:28
Show Gist options
  • Save Kwaadpepper/a4568f1ed718cab1ec3b59d3d7ac3e76 to your computer and use it in GitHub Desktop.
Save Kwaadpepper/a4568f1ed718cab1ec3b59d3d7ac3e76 to your computer and use it in GitHub Desktop.
VScode markdown erratic scroll bug

Maintenance MIT license Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0)  license GitHub version

Laravel-ResponsiveFileManager

This software includes a modified version of Responsive File Manager see official website

Responsive File Manager (RFM) is licenced under CC BY-NC 3.0 which means software can't be redistributed for a commercial use.

CC BY-NC 3.0

If you wan't to use it for comercial purpose take a look on the author (Alberto Peripolli ) website

This repo is under MIT Licence except parts where antoher licence is mentioned in file.

Corrections are made to RFM in order to

  • Prevent collisions
  • Fix small errors
  • Adapt to Laravel

The Laravel plugin code part here is under MIT Licence.

The RFM author delivers a commercial version of his code (a modified include.js). You will need to modify this file if you use CSRF check on your laravel app by adding _token: jQuery('meta[name="csrf-token"]').attr('content') on ajax calls. You can use www.diffchecker.com to check modifications you will have to apply to your include.commercial.js file. I can't deliver myself a licence to use RFM for commercial purpose

If you have some corrections, recommendations or anything else to say please let me know. Don't hesitate to make PR if you done something cool you wan't to share

Read Responsive File Manager Documentation


How to Install ?

#1

Install in your project

composer require kwaadpepper/laravel-responsivefilemanager

php artisan vendor:publish --provider="Kwaadpepper\ResponsiveFileManager\FileManagerServiceProvider"

Now there is a new configuration file rfm.php

Install in config/app.php

'providers' => [
        /*
         * Laravel Framework Service Providers...
         */
        ...
        // Responsive File Manager
        Kwaadpepper\ResponsiveFileManager\FileManagerServiceProvider::class
],

In HTTP/Kernel.php need to use StartSession, can also use and is recommended CSRF Token

protected $middlewareGroups = [
    ...
    'web' => [
        ...
        \Illuminate\Session\Middleware\StartSession::class,
        // Responsive File Manager supports CSRF Token usage
        \App\Http\Middleware\VerifyCsrfToken::class
    ]
    ...
];

Generate private key for url identification

php artisan rfm:generate

All configs included to work out of the box. Files are meant to be stored in public folder.


#2

Use as StandAlone

Use helpers to write filemanager url

<a href="@filemanager_get_resource(dialog.php)?field_id=imgField&lang=en_EN&akey=@filemanager_get_key()" value="Files">Open RFM</a>

see USE AS STAND-ALONE FILE MANAGER in Responsible File Manager Doc

tip: Seems to support Bootstrap Modal


Include in TinyMCE or CKEDITOR

Include JS

For CKEditor

Replace #MYTEXTAREAJS with your textarea input

<script src='{{ asset('/vendor/unisharp/laravel-ckeditor/ckeditor.js') }}'></script>
<script>
    $(document).ready(function() {
        if($("#MYTEXTAREAID").length) {
            CKEDITOR.replace( 'postBody', {
                filebrowserBrowseUrl : '@filemanager_get_resource(dialog.php)?akey=@filemanager_get_key()&type=2&editor=ckeditor&fldr=',
                filebrowserUploadUrl : '@filemanager_get_resource(dialog.php)?akey=@filemanager_get_key()&type=2&editor=ckeditor&fldr=',
                filebrowserImageBrowseUrl : '@filemanager_get_resource(dialog.php)?akey=@filemanager_get_key()&type=1&editor=ckeditor&fldr=',
                language : '<?php App::getLocale() ?>'
            });
        }
    })
</script>

For TinyMCE

$(document).ready(() => {
    $('textarea').first().tinymce({
        script_url : '/tinymce/tinymce.min.js',
        width: 680,height: 300,
        plugins: [
            "advlist autolink link image lists charmap print preview hr anchor pagebreak",
            "searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking",
            "table contextmenu directionality emoticons paste textcolor filemanager code"
    ],
    toolbar1: "undo redo | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | styleselect",
    toolbar2: "| responsivefilemanager | link unlink anchor | image media | forecolor backcolor  | print preview code ",
    image_advtab: true ,
    filemanager_access_key: '@filemanager_get_key()',
    filemanager_sort_by: '',
    filemanager_descending: '',
    filemanager_subfolder: '',
    filemanager_crossdomain: '',
    external_filemanager_path: '@filemanager_get_resource(dialog.php)',
    filemanager_title:"Responsive Filemanager" ,
    external_plugins: { "filemanager" : "/vendor/responsivefilemanager/plugin.min.js"}
    });
});

To make private folder use .htaccess with Deny from all


Configuration

Language

This package has multiple languages support, it is still incomplete. please contribute if you have the language concerned skills.

-1 url get parameter -2 RF.language session var (User selected languages in drop list) -3 config.php (rfm.php) default_language 4 - User prefered language (HTTP headers) 5 - Laravel app default language

TODO :

  • private key setup
  • more corrections on JS side
  • more corrections on languages
  • Test with tinyMCE
  • Include commercial support
  • Test and debug FTP fonctionnality (Alpha Still need debug some functionallities)
  • TODO: cache FTP thumbnails for preview (images only)
  • MultiUser and Auth Support
  • compile assets
  • publish package

** In the Future **

  • Rewrite routes to be cleaner (eg : ajax_calls/{action}/{subaction})
  • separe properly View from logic ( ex: dialog.php OMG <(o_O)>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment