Update v1.0.6

This commit is contained in:
Bhanu Slathia
2016-02-16 23:24:52 +05:30
parent c710c20b9e
commit b1f62846ab
7662 changed files with 1361647 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
<?php namespace Unisharp\Laravelfilemanager;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Config;
/**
* Class LaravelFilemanagerServiceProvider
* @package Unisharp\Laravelfilemanager
*/
class LaravelFilemanagerServiceProvider extends ServiceProvider {
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
if (Config::get('lfm.use_package_routes'))
include __DIR__ . '/routes.php';
$this->loadTranslationsFrom(__DIR__.'/lang', 'laravel-filemanager');
$this->loadViewsFrom(__DIR__.'/views', 'laravel-filemanager');
$this->publishes([
__DIR__ . '/config/lfm.php' => base_path('config/lfm.php'),
], 'lfm_config');
$this->publishes([
__DIR__.'/../public' => public_path('vendor/laravel-filemanager'),
], 'lfm_public');
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app['laravel-filemanager'] = $this->app->share(function ()
{
return true;
});
}
}

View File

@@ -0,0 +1,52 @@
<?php
return [
'rename_file' => true,
'use_package_routes' => true,
'middlewares' => ['auth'],
'allow_multi_user' => true,
'user_field' => 'id',
'shared_folder_name' => 'shares',
'thumb_folder_name' => 'thumbs',
'images_dir' => 'public/photos/',
'images_url' => '/photos/',
'files_dir' => 'public/files/',
'files_url' => '/files/',
'file_type_array' => [
'pdf' => 'Adobe Acrobat',
'docx' => 'Microsoft Word',
'docx' => 'Microsoft Word',
'xls' => 'Microsoft Excel',
'xls' => 'Microsoft Excel',
'zip' => 'Archive',
'gif' => 'GIF Image',
'jpg' => 'JPEG Image',
'jpeg' => 'JPEG Image',
'png' => 'PNG Image',
'ppt' => 'Microsoft PowerPoint',
'pptx' => 'Microsoft PowerPoint',
],
'file_icon_array' => [
'pdf' => 'fa-file-pdf-o',
'docx' => 'fa-file-word-o',
'docx' => 'fa-file-word-o',
'xls' => 'fa-file-excel-o',
'xls' => 'fa-file-excel-o',
'zip' => 'fa-file-archive-o',
'gif' => 'fa-file-image-o',
'jpg' => 'fa-file-image-o',
'jpeg' => 'fa-file-image-o',
'png' => 'fa-file-image-o',
'ppt' => 'fa-file-powerpoint-o',
'pptx' => 'fa-file-powerpoint-o',
],
];

View File

@@ -0,0 +1,52 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\View;
use Intervention\Image\Facades\Image;
/**
* Class CropController
* @package Unisharp\Laravelfilemanager\controllers
*/
class CropController extends LfmController {
/**
* Show crop page
*
* @return mixed
*/
public function getCrop()
{
$working_dir = Input::get('working_dir');
$img = parent::getUrl() . Input::get('img');
return View::make('laravel-filemanager::crop')
->with(compact('working_dir', 'img'));
}
/**
* Crop the image (called via ajax)
*/
public function getCropimage()
{
$image = Input::get('img');
$dataX = Input::get('dataX');
$dataY = Input::get('dataY');
$dataHeight = Input::get('dataHeight');
$dataWidth = Input::get('dataWidth');
// crop image
$tmp_img = Image::make(public_path() . $image);
$tmp_img->crop($dataWidth, $dataHeight, $dataX, $dataY)
->save(public_path() . $image);
// make new thumbnail
$thumb_img = Image::make(public_path() . $image);
$thumb_img->fit(200, 200)
->save(parent::getPath('thumb') . parent::getFileName($image));
}
}

View File

@@ -0,0 +1,53 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use Lang;
/**
* Class CropController
* @package Unisharp\Laravelfilemanager\controllers
*/
class DeleteController extends LfmController {
/**
* Delete image and associated thumbnail
*
* @return mixed
*/
public function getDelete()
{
$name_to_delete = Input::get('items');
$file_path = parent::getPath();
$file_to_delete = $file_path . $name_to_delete;
$thumb_to_delete = parent::getPath('thumb') . $name_to_delete;
if (!File::exists($file_to_delete)) {
return $file_to_delete . ' not found!';
}
if (File::isDirectory($file_to_delete)) {
if (sizeof(File::files($file_to_delete)) != 0) {
return Lang::get('laravel-filemanager::lfm.error-delete');
}
File::deleteDirectory($file_to_delete);
return 'OK';
}
File::delete($file_to_delete);
if (Session::get('lfm_type') == 'Images') {
File::delete($thumb_to_delete);
}
return 'OK';
}
}

View File

@@ -0,0 +1,25 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Session;
/**
* Class DownloadController
* @package Unisharp\Laravelfilemanager\controllers
*/
class DownloadController extends LfmController {
/**
* Download a file
*
* @return mixed
*/
public function getDownload()
{
return Response::download(parent::getPath() . Input::get('file'));
}
}

View File

@@ -0,0 +1,58 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Str;
use Lang;
/**
* Class FolderController
* @package Unisharp\Laravelfilemanager\controllers
*/
class FolderController extends LfmController {
/**
* Get list of folders as json to populate treeview
*
* @return mixed
*/
public function getFolders()
{
$dir_path = parent::getPath();
$directories = parent::getDirectories($dir_path);
$share_path = parent::getPath('share');
$shared_folders = parent::getDirectories($share_path);
return View::make('laravel-filemanager::tree')
->with('dirs', $directories)
->with('shares', $shared_folders);
}
/**
* Add a new folder
*
* @return mixed
*/
public function getAddfolder()
{
$folder_name = Input::get('name');
$path = parent::getPath() . $folder_name;
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
return 'OK';
} else if (empty($folder_name)) {
return Lang::get('laravel-filemanager::lfm.error-folder-name');
} else {
return Lang::get('laravel-filemanager::lfm.error-folder-exist');
}
}
}

View File

@@ -0,0 +1,101 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Redirect;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Intervention\Image\Facades\Image;
/**
* Class ItemsController
* @package Unisharp\Laravelfilemanager\controllers
*/
class ItemsController extends LfmController {
/**
* Get the images to load for a selected folder
*
* @return mixed
*/
public function getItems()
{
$type = Input::get('type');
$view = $this->getView($type);
$path = parent::getPath();
$files = File::files($path);
$file_info = $this->getFileInfos($files, $type);
$directories = parent::getDirectories($path);
$thumb_url = parent::getUrl('thumb');
return View::make($view)
->with(compact('files', 'file_info', 'directories', 'thumb_url'));
}
private function getFileInfos($files, $type = 'Images')
{
$file_info = [];
foreach ($files as $key => $file) {
$file_name = parent::getFileName($file);
$file_created = filemtime($file);
$file_size = number_format((File::size($file) / 1024), 2, ".", "");
if ($file_size > 1024) {
$file_size = number_format(($file_size / 1024), 2, ".", "") . " Mb";
} else {
$file_size = $file_size . " Kb";
}
if ($type === 'Images') {
$file_type = File::mimeType($file);
$icon = '';
} else {
$extension = strtolower(File::extension($file_name));
$icon_array = Config::get('lfm.file_icon_array');
$type_array = Config::get('lfm.file_type_array');
if (array_key_exists($extension, $icon_array)) {
$icon = $icon_array[$extension];
$file_type = $type_array[$extension];
} else {
$icon = "fa-file";
$file_type = "File";
}
}
$file_info[$key] = [
'name' => $file_name,
'size' => $file_size,
'created' => $file_created,
'type' => $file_type,
'icon' => $icon,
];
}
return $file_info;
}
private function getView($type = 'Images')
{
$view = 'laravel-filemanager::images';
if ($type !== 'Images') {
$view = 'laravel-filemanager::files';
}
if (Input::get('show_list') == 1) {
$view .= '-list';
}
return $view;
}
}

View File

@@ -0,0 +1,170 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Facades\View;
use Intervention\Image\Facades\Image;
/**
* Class LfmController
* @package Unisharp\Laravelfilemanager\controllers
*/
class LfmController extends Controller {
/**
* @var
*/
public $file_location;
public $dir_location;
/**
* Constructor
*/
public function __construct()
{
$this->setPathAndType();
$this->checkMyFolderExists();
$this->checkSharedFolderExists();
}
/**
* Show the filemanager
*
* @return mixed
*/
public function show()
{
if (Input::has('working_dir')) {
$working_dir = Input::get('working_dir');
} else {
$working_dir = '/';
}
return View::make('laravel-filemanager::index')
->with('working_dir', $working_dir);
}
/*****************************
*** Private Functions ***
*****************************/
private function setPathAndType()
{
// dd('type:'.Input::get('type'));
if (Input::has('type') && Input::get('type') === 'Files') {
Session::put('lfm_type', 'Files');
Session::put('lfm.file_location', Config::get('lfm.files_dir'));
Session::put('lfm.dir_location', Config::get('lfm.files_url'));
} else if (Input::has('type') && Input::get('type') === 'Images') {
Session::put('lfm_type', 'Images');
Session::put('lfm.file_location', Config::get('lfm.images_dir'));
Session::put('lfm.dir_location', Config::get('lfm.images_url'));
}
}
private function checkMyFolderExists()
{
if (\Config::get('lfm.allow_multi_user') === true) {
$path = $this->getPath();
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
}
}
}
private function checkSharedFolderExists()
{
$path = $this->getPath('share');
if (!File::exists($path)) {
File::makeDirectory($path, $mode = 0777, true, true);
}
}
private function formatLocation($location, $type = null)
{
if ($type === 'share') {
return $location . Config::get('lfm.shared_folder_name') . '/';
}
$working_dir = Input::get('working_dir');
if ($working_dir !== '/') {
$location .= $working_dir . '/';
}
if ($type === 'thumb') {
$location = $location . Config::get('lfm.thumb_folder_name') . '/';
}
return $location;
}
/****************************
*** Shared Functions ***
****************************/
public function getPath($type = null)
{
$path = base_path() . '/' . Session::get('lfm.file_location');
$path = $this->formatLocation($path, $type);
return $path;
}
public function getUrl($type = null)
{
$url = Session::get('lfm.dir_location');
$url = $this->formatLocation($url, $type);
return $url;
}
public function getDirectories($path)
{
$thumb_folder_name = Config::get('lfm.thumb_folder_name');
$all_directories = File::directories($path);
$arr_dir = [];
foreach ($all_directories as $directory) {
$dir_name = $this->getFileName($directory);
if ($dir_name !== $thumb_folder_name) {
$arr_dir[] = $dir_name;
}
}
return $arr_dir;
}
public function getFileName($file)
{
$path_parts = explode('/', $file);
$filename = end($path_parts);
return $filename;
}
}

View File

@@ -0,0 +1,54 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
use Lang;
/**
* Class RenameController
* @package Unisharp\Laravelfilemanager\controllers
*/
class RenameController extends LfmController {
/**
* @return string
*/
public function getRename()
{
$old_name = Input::get('file');
$new_name = Input::get('new_name');
$file_path = parent::getPath();
$thumb_path = parent::getPath('thumb');
$old_file = $file_path . $old_name;
if (!File::isDirectory($old_file)) {
$extension = File::extension($old_file);
$new_name = str_replace('.' . $extension, '', $new_name) . '.' . $extension;
}
$new_file = $file_path . $new_name;
if (File::exists($new_file)) {
return Lang::get('laravel-filemanager::lfm.error-rename');
}
if (File::isDirectory($old_file)) {
File::move($old_file, $new_file);
return 'OK';
}
File::move($old_file, $new_file);
if (Session::get('lfm_type') == 'Images') {
File::move($thumb_path . $old_name, $thumb_path . $new_name);
}
return 'OK';
}
}

View File

@@ -0,0 +1,77 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\View;
use Intervention\Image\Facades\Image;
/**
* Class ResizeController
* @package Unisharp\Laravelfilemanager\controllers
*/
class ResizeController extends LfmController {
/**
* Dipsplay image for resizing
*
* @return mixed
*/
public function getResize()
{
$ratio = 1.0;
$image = Input::get('img');
$path_to_image = parent::getPath() . $image;
$original_width = Image::make($path_to_image)->width();
$original_height = Image::make($path_to_image)->height();
$scaled = false;
if ($original_width > 600) {
$ratio = 600 / $original_width;
$width = $original_width * $ratio;
$height = $original_height * $ratio;
$scaled = true;
} else {
$width = $original_width;
$height = $original_height;
}
if ($height > 400) {
$ratio = 400 / $original_height;
$width = $original_width * $ratio;
$height = $original_height * $ratio;
$scaled = true;
}
return View::make('laravel-filemanager::resize')
->with('img', parent::getUrl() . $image)
->with('height', number_format($height, 0))
->with('width', $width)
->with('original_height', $original_height)
->with('original_width', $original_width)
->with('scaled', $scaled)
->with('ratio', $ratio);
}
public function performResize()
{
$img = Input::get('img');
$dataX = Input::get('dataX');
$dataY = Input::get('dataY');
$height = Input::get('dataHeight');
$width = Input::get('dataWidth');
try {
Image::make(public_path() . $img)->resize($width, $height)->save();
return "OK";
} catch (Exception $e) {
return "width : " . $width . " height: " . $height;
return $e;
}
}
}

View File

@@ -0,0 +1,102 @@
<?php namespace Unisharp\Laravelfilemanager\controllers;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
use Lang;
use Intervention\Image\Facades\Image;
/**
* Class UploadController
* @package Unisharp\Laravelfilemanager\controllers
*/
class UploadController extends LfmController {
/**
* Upload an image/file and (for images) create thumbnail
*
* @param UploadRequest $request
* @return string
*/
public function upload()
{
if (!Input::hasFile('upload')) {
return Lang::get('laravel-filemanager::lfm.error-file-empty');
}
$file = Input::file('upload');
$new_filename = $this->getNewName($file);
$dest_path = parent::getPath();
if (File::exists($dest_path . $new_filename)) {
return Lang::get('laravel-filemanager::lfm.error-file-exist');
}
$file->move($dest_path, $new_filename);
if (Session::get('lfm_type') == 'Images') {
$this->makeThumb($dest_path, $new_filename);
}
// upload via ckeditor 'Upload' tab
if (!Input::has('show_list')) {
return $this->useFile($new_filename);
}
return 'OK';
}
private function getNewName($file)
{
$new_filename = $file->getClientOriginalName();
if (Config::get('lfm.rename_file') === true) {
$new_filename = uniqid() . '.' . $file->getClientOriginalExtension();
}
return $new_filename;
}
private function makeThumb($dest_path, $new_filename)
{
$thumb_folder_name = Config::get('lfm.thumb_folder_name');
if (!File::exists($dest_path . $thumb_folder_name)) {
File::makeDirectory($dest_path . $thumb_folder_name);
}
$thumb_img = Image::make($dest_path . $new_filename);
$thumb_img->fit(200, 200)
->save($dest_path . $thumb_folder_name . '/' . $new_filename);
unset($thumb_img);
}
private function useFile($new_filename)
{
$file = parent::getUrl() . $new_filename;
return "<script type='text/javascript'>
function getUrlParam(paramName) {
var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i');
var match = window.location.search.match(reParam);
return ( match && match.length > 1 ) ? match[1] : null;
}
var funcNum = getUrlParam('CKEditorFuncNum');
var par = window.parent,
op = window.opener,
o = (par && par.CKEDITOR) ? par : ((op && op.CKEDITOR) ? op : false);
if (op) window.close();
if (o !== false) o.CKEDITOR.tools.callFunction(funcNum, '$file');
</script>";
}
}

View File

@@ -0,0 +1,60 @@
<?php
return [
'nav-upload' => 'Upload',
'nav-thumbnails' => 'Thumbnails',
'nav-list' => 'List',
'menu-new' => 'New Folder',
'menu-rename' => 'Rename',
'menu-delete' => 'Delete',
'menu-view' => 'View',
'menu-download' => 'Download',
'menu-resize' => 'Resize',
'menu-crop' => 'Crop',
'title-page' => 'File Manager',
'title-panel' => 'Laravel FileManager',
'title-upload' => 'Upload File',
'title-view' => 'View File',
'title-root' => 'Files',
'title-shares' => 'Shared Files',
'title-item' => 'Item',
'title-size' => 'Size',
'title-type' => 'Type',
'title-modified' => 'Modified',
'title-action' => 'Action',
'type-folder' => 'Folder',
'message-empty' => 'Folder is empty.',
'message-choose' => 'Choose File',
'message-delete' => 'Are you sure you want to delete this item?',
'message-name' => 'Folder name:',
'message-rename' => 'Rename to:',
'error-rename' => 'File name already in use!',
'error-file-empty' => 'You must choose a file!',
'error-file-exist' => 'A file with this name already exists!',
'error-delete' => 'You cannot delete this folder because it is not empty!',
'error-folder-name' => 'Folder name cannot be empty!',
'error-folder-exist'=> 'A folder with this name already exists!',
'btn-upload' => 'Upload File',
'btn-close' => 'Close',
'btn-uploading' => 'Uploading...',
'btn-crop' => 'Crop',
'btn-cancel' => 'Cancel',
'btn-resize' => 'Resize',
'resize-ratio' => 'Ratio:',
'resize-scaled' => 'Image scaled:',
'resize-true' => 'Yes',
'resize-old-height' => 'Original Height:',
'resize-old-width' => 'Original Width:',
'resize-new-height' => 'Height:',
'resize-new-width' => 'Width:',
'locale-bootbox' => 'en',
];

View File

@@ -0,0 +1,60 @@
<?php
return [
'nav-upload' => 'Charger',
'nav-thumbnails' => 'Vignettes',
'nav-list' => 'Liste',
'menu-new' => 'Nouveau dossier',
'menu-rename' => 'Renommez',
'menu-delete' => 'Effacer',
'menu-view' => 'Voir le',
'menu-download' => 'Télécharger',
'menu-resize' => 'Redimensionner',
'menu-crop' => 'Récolte',
'title-page' => 'Gestionnaire de fichiers',
'title-panel' => 'Laravel FileManager',
'title-upload' => 'Envoyer un fichier',
'title-view' => 'Voir le fichier',
'title-root' => 'Fichiers',
'title-shares' => 'Shared Files',
'title-item' => 'Article',
'title-size' => 'Taille du fichier',
'title-type' => 'Type de fichier',
'title-modified' => 'Date modifiée',
'title-action' => 'Exécuter laction',
'type-folder' => 'Dossier',
'message-empty' => 'Dossier est vide',
'message-choose' => 'Choisir un fichier',
'message-delete' => 'Êtes-vous sûr de vouloir supprimer ce fichier ?',
'message-name' => 'Nom du dossier:',
'message-rename' => 'Renommer le dossier:',
'error-rename' => 'Ce nom est déjà pris !',
'error-file-empty' => 'Veuillez choisir un fichier',
'error-file-exist' => 'Un fichier avec ce nom existe déjà !',
'error-delete' => "Vous ne pouvez pas supprimer ce dossier car il n'est pas vide",
'error-folder-name' => 'Le nom du dossier ne peut pas être vide',
'error-folder-exist'=> 'Un dossier avec ce nom existe déjà !',
'btn-upload' => 'Envoyer le fichier',
'btn-close' => 'Fermer',
'btn-uploading' => 'Envoi...',
'btn-crop' => 'Rogner',
'btn-cancel' => 'Annuler',
'btn-resize' => 'Redimensionner',
'resize-ratio' => 'Ratio:',
'resize-scaled' => "Image à l'échelle:",
'resize-true' => 'Oui',
'resize-old-height' => 'Hauteur originale:',
'resize-old-width' => 'Largeur originale:',
'resize-new-height' => 'Hauteur',
'resize-new-width' => 'Largeur',
'locale-bootbox' => 'fr',
];

View File

@@ -0,0 +1,59 @@
<?php
return [
'nav-upload' => 'Enviar',
'nav-thumbnails' => 'Miniatura',
'nav-list' => 'Lista',
'menu-new' => 'Nova Pasta',
'menu-rename' => 'Renomear',
'menu-delete' => 'Deletar',
'menu-view' => 'Ver',
'menu-download' => 'Download',
'menu-resize' => 'Redimensionar',
'menu-crop' => 'Cortar',
'title-page' => 'Gerenciador de Arquivos',
'title-panel' => 'Gerenciador de Arquivos',
'title-upload' => 'Envio de Arquivo',
'title-view' => 'Ver Arquivo',
'title-root' => 'Arquivos',
'title-shares' => 'Arquivos Compartilhados',
'title-item' => 'Item',
'title-size' => 'Tamanho',
'title-type' => 'Tipo',
'title-modified' => 'Modificado',
'title-action' => 'Ação',
'type-folder' => 'Pasta',
'message-empty' => 'A pasta está vazia.',
'message-choose' => 'Escolha um arquivo',
'message-delete' => 'Você está certo que quer deletar este arquivo?',
'message-name' => 'Nome da pasta:',
'message-rename' => 'Renomear para:',
'error-rename' => 'Nome de arquivo já está em uso!',
'error-file-empty' => 'Você deve escolher um arquivo!',
'error-file-exist' => 'Um arquivo com este nome já existe!',
'error-delete' => 'Você não pode deletar esta pasta, pois ela não está vazia!',
'error-folder-name' => 'Nome da pasta não pode ser vazio!',
'error-folder-exist'=> 'Uma pasta com este nome já existe!',
'btn-upload' => 'Enviar Arquivo',
'btn-close' => 'Fechar',
'btn-uploading' => 'Enviando...',
'btn-crop' => 'Cortar',
'btn-cancel' => 'Cancelar',
'btn-resize' => 'Redimensionar',
'resize-ratio' => 'Proporção:',
'resize-scaled' => 'Imagem dimensionada:',
'resize-true' => 'Sim',
'resize-old-height' => 'Altura Original:',
'resize-old-width' => 'Largura Original:',
'resize-new-height' => 'Altura:',
'resize-new-width' => 'Largura:',
'locale-bootbox' => 'pt_BR',
];

View File

@@ -0,0 +1,60 @@
<?php
return [
'nav-upload' => '上传档案',
'nav-thumbnails' => '缩略图显示',
'nav-list' => '列表显示',
'menu-new' => '添加文件夹',
'menu-rename' => '重命名',
'menu-delete' => '删除',
'menu-view' => '预览',
'menu-download' => '下载',
'menu-resize' => '缩放',
'menu-crop' => '裁剪',
'title-page' => '档案管理',
'title-panel' => '档案管理',
'title-upload' => '上传档案',
'title-view' => '预览档案',
'title-root' => '我的档案',
'title-shares' => '共享的文件',
'title-item' => '项目名称',
'title-size' => '档案大小',
'title-type' => '档案类型',
'title-modified' => '上次修改',
'title-action' => '操作',
'type-folder' => '文件夹',
'message-empty' => '空的文件夹',
'message-choose' => '选择档案',
'message-delete' => '确定要删除此项目吗?',
'message-name' => '文件夹名称:',
'message-rename' => '重命名为:',
'error-rename' => '名稱重複,請重新輸入!',
'error-file-empty' => '請選擇檔案!',
'error-file-exist' => '相同檔名的檔案已存在!',
'error-delete' => '資料夾未清空,無法刪除!',
'error-folder-name' => '請輸入資料夾名稱!',
'error-folder-exist'=> '相同名稱的資料夾已存在!',
'btn-upload' => '上传',
'btn-close' => '关闭',
'btn-uploading' => '上传中...',
'btn-crop' => '裁剪',
'btn-cancel' => '取消',
'btn-resize' => '缩放',
'resize-ratio' => '比例:',
'resize-scaled' => '是否已缩放:',
'resize-true' => '是',
'resize-old-height' => '原始高度:',
'resize-old-width' => '原始宽度:',
'resize-new-height' => '目前高度:',
'resize-new-width' => '目前宽度:',
'locale-bootbox' => 'zh_CN',
];

View File

@@ -0,0 +1,60 @@
<?php
return [
'nav-upload' => '上傳檔案',
'nav-thumbnails' => '縮圖顯示',
'nav-list' => '列表顯示',
'menu-new' => '新增資料夾',
'menu-rename' => '重新命名',
'menu-delete' => '刪除',
'menu-view' => '預覽',
'menu-download' => '下載',
'menu-resize' => '縮放',
'menu-crop' => '裁剪',
'title-page' => '檔案管理',
'title-panel' => '檔案管理',
'title-upload' => '上傳檔案',
'title-view' => '預覽檔案',
'title-root' => '我的檔案',
'title-shares' => '共享的檔案',
'title-item' => '項目名稱',
'title-size' => '檔案大小',
'title-type' => '檔案類型',
'title-modified' => '上次修改',
'title-action' => '操作',
'type-folder' => '資料夾',
'message-empty' => '空的資料夾',
'message-choose' => '選擇檔案',
'message-delete' => '確定要刪除此項目嗎?',
'message-name' => '資料夾名稱:',
'message-rename' => '重新命名為:',
'error-rename' => '名稱重複,請重新輸入!',
'error-file-empty' => '請選擇檔案!',
'error-file-exist' => '相同檔名的檔案已存在!',
'error-delete' => '資料夾未清空,無法刪除!',
'error-folder-name' => '請輸入資料夾名稱!',
'error-folder-exist'=> '相同名稱的資料夾已存在!',
'btn-upload' => '上傳',
'btn-close' => '關閉',
'btn-uploading' => '上傳中...',
'btn-crop' => '裁剪',
'btn-cancel' => '取消',
'btn-resize' => '縮放',
'resize-ratio' => '比例:',
'resize-scaled' => '是否已縮放:',
'resize-true' => '是',
'resize-old-height' => '原始高度:',
'resize-old-width' => '原始寬度:',
'resize-new-height' => '目前高度:',
'resize-new-width' => '目前寬度:',
'locale-bootbox' => 'zh_TW',
];

View File

@@ -0,0 +1,44 @@
<?php
namespace Unisharp\Laravelfilemanager\middleware;
use Closure;
class MultiUser
{
public function handle($request, Closure $next)
{
if (\Config::get('lfm.allow_multi_user') === true) {
$slug = \Config::get('lfm.user_field');
\Auth::user()->user_field = \Auth::user()->$slug;
$base = $request->input('working_dir');
if ($base == null) {
$request->merge(['working_dir' => \Auth::user()->user_field]);
} elseif ($this->wrongDir($base)) {
$request->replace(['working_dir' => \Auth::user()->user_field]);
}
}
return $next($request);
}
private function wrongDir($base)
{
if (strpos($base, \Config::get('lfm.shared_folder_name')) !== false) {
return false;
}
if (strpos($base, (string)\Auth::user()->user_field) !== false) {
return false;
}
if (strpos($base, (string)\Auth::user()->user_field) === false) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,38 @@
<?php
$middlewares = \Config::get('lfm.middlewares');
array_push($middlewares, '\Unisharp\Laravelfilemanager\middleware\MultiUser');
// make sure authenticated
Route::group(array('middleware' => $middlewares, 'prefix' => 'laravel-filemanager'), function ()
{
// Show LFM
Route::get('/', 'Unisharp\Laravelfilemanager\controllers\LfmController@show');
// upload
Route::any('/upload', 'Unisharp\Laravelfilemanager\controllers\UploadController@upload');
// list images & files
Route::get('/jsonitems', 'Unisharp\Laravelfilemanager\controllers\ItemsController@getItems');
// folders
Route::get('/newfolder', 'Unisharp\Laravelfilemanager\controllers\FolderController@getAddfolder');
Route::get('/deletefolder', 'Unisharp\Laravelfilemanager\controllers\FolderController@getDeletefolder');
Route::get('/folders', 'Unisharp\Laravelfilemanager\controllers\FolderController@getFolders');
// crop
Route::get('/crop', 'Unisharp\Laravelfilemanager\controllers\CropController@getCrop');
Route::get('/cropimage', 'Unisharp\Laravelfilemanager\controllers\CropController@getCropimage');
// rename
Route::get('/rename', 'Unisharp\Laravelfilemanager\controllers\RenameController@getRename');
// scale/resize
Route::get('/resize', 'Unisharp\Laravelfilemanager\controllers\ResizeController@getResize');
Route::get('/doresize', 'Unisharp\Laravelfilemanager\controllers\ResizeController@performResize');
// download
Route::get('/download', 'Unisharp\Laravelfilemanager\controllers\DownloadController@getDownload');
// delete
Route::get('/delete', 'Unisharp\Laravelfilemanager\controllers\DeleteController@getDelete');
});

View File

View File

@@ -0,0 +1,67 @@
<div class="row fill">
<div class="col-md-8 fill">
<div class="crop-container">
<img src="{{ $img }}" class="img img-responsive">
</div>
</div>
<div class="col-md-4 fill">
<div class="text-center">
<div class="img-preview center-block"></div>
<br>
<button class="btn btn-primary" onclick="performCrop()">{{ Lang::get('laravel-filemanager::lfm.btn-crop') }}</button>
<button class="btn btn-info" onclick="loadItems()">{{ Lang::get('laravel-filemanager::lfm.btn-cancel') }}</button>
<form action="{{url('/laravel-filemanager/crop')}}" role='form' name='cropForm' id='cropForm' mathod='post'>
<input type="hidden" id="img" name="img" value="{{ $img }}">
<input type="hidden" id="working_dir" name="working_dir" value="{{ $working_dir }}">
<input type="hidden" id="dataX" name="dataX">
<input type="hidden" id="dataY" name="dataY">
<input type="hidden" id="dataWidth" name="dataWidth">
<input type="hidden" id="dataHeight" name="dataHeight">
<input type='hidden' name='_token' value='{{csrf_token()}}'>
</form>
</div>
</div>
</div>
<script>
$(document).ready(function () {
var $dataX = $('#dataX'),
$dataY = $('#dataY'),
$dataHeight = $('#dataHeight'),
$dataWidth = $('#dataWidth');
$('.crop-container > img').cropper({
//aspectRatio: 16 / 9,
preview: ".img-preview",
strict: false,
crop: function (data) {
// Output the result data for cropping image.
$dataX.val(Math.round(data.x));
$dataY.val(Math.round(data.y));
$dataHeight.val(Math.round(data.height));
$dataWidth.val(Math.round(data.width));
}
});
});
function performCrop() {
$.ajax({
type: "GET",
dataType: "text",
url: "/laravel-filemanager/cropimage",
data: {
img: $("#img").val(),
working_dir: $("#working_dir").val(),
dataX: $("#dataX").val(),
dataY: $("#dataY").val(),
dataHeight: $("#dataHeight").val(),
dataWidth: $("#dataWidth").val()
},
cache: false
}).done(function (data) {
loadItems();
});
}
</script>

View File

@@ -0,0 +1,68 @@
<div class="container">
@if((sizeof($file_info) > 0) || (sizeof($directories) > 0))
<table class="table table-condensed table-striped">
<thead>
<th style='width:50%;'>{{ Lang::get('laravel-filemanager::lfm.title-item') }}</th>
<th>{{ Lang::get('laravel-filemanager::lfm.title-size') }}</th>
<th>{{ Lang::get('laravel-filemanager::lfm.title-type') }}</th>
<th>{{ Lang::get('laravel-filemanager::lfm.title-modified') }}</th>
<th>{{ Lang::get('laravel-filemanager::lfm.title-action') }}</th>
</thead>
<tbody>
@foreach($directories as $key => $dir_name)
<tr>
<td>
<i class="fa fa-folder-o"></i>
<a id="large_folder_{{ $key }}" data-id="{{ $dir_name }}" href="javascript:clickFolder('large_folder_{{ $key }}',1)">
{{ $dir_name }}
</a>
</td>
<td></td>
<td>{{ Lang::get('laravel-filemanager::lfm.type-folder') }}</td>
<td></td>
<td></td>
</tr>
@endforeach
@foreach($file_info as $file)
<tr>
<td>
<i class="fa <?= $file['icon']; ?>"></i>
<?php $file_name = $file['name'];?>
<a href="javascript:useFile('{{ $file_name }}')">
{{ $file_name }}
</a>
&nbsp;&nbsp;
<a href="javascript:rename('{{ $file_name }}')">
<i class="fa fa-edit"></i>
</a>
</td>
<td>
{{ $file['size'] }}
</td>
<td>
{{ $file['type'] }}
</td>
<td>
{{ date("Y-m-d h:m", $file['created']) }}
</td>
<td>
<a href="javascript:trash('{{ $file_name }}')">
<i class="fa fa-trash fa-fw"></i>
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<div class="row">
<div class="col-md-12">
<p>{{ Lang::get('laravel-filemanager::lfm.message-empty') }}</p>
</div>
</div>
@endif
</div>

View File

@@ -0,0 +1,75 @@
<div class="container">
<div class="row">
@if((sizeof($files) > 0) || (sizeof($directories) > 0))
@foreach($directories as $key => $dir_name)
<div class="col-sm-6 col-md-2">
<div class="thumbnail text-center" data-id="{{ $dir_name }}">
<a id="folder_{{ $key }}" data-id="{{ $dir_name }}" onclick="clickFolder('folder_{{ $key }}',0)" class="folder-icon pointer">
<img src="/vendor/laravel-filemanager/img/folder.jpg">
</a>
</div>
<div class="caption text-center">
<div class="btn-group">
<button type="button" onclick="clickFolder('folder_{{ $key }}',0)" class="btn btn-default btn-xs">
{{ str_limit($dir_name, $limit = 10, $end = '...') }}
</button>
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="javascript:rename('{{ $dir_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-rename') }}</a></li>
<li><a href="javascript:trash('{{ $dir_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-delete') }}</a></li>
</ul>
</div>
</div>
</div>
@endforeach
@foreach($file_info as $key => $file)
<?php $file_name = $file_info[$key]['name'];?>
<div class="col-sm-6 col-md-2 img-row">
<div class="thumbnail thumbnail-img text-center" data-id="{{ $file_name }}" id="img_thumbnail_{{ $key }}">
<i class="fa {{ $file['icon'] }} fa-5x" style="height:200px;cursor:pointer;padding-top:60px;" onclick="useFile('{{ $file_name }}')"></i>
</div>
<div class="caption text-center">
<div class="btn-group ">
<button type="button" onclick="useFile('{{ $file_name }}')" class="btn btn-default btn-xs">
{{ str_limit($file_name, $limit = 10, $end = '...') }}
</button>
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="javascript:rename('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-rename') }}</a></li>
<li><a href="javascript:fileView('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-view') }}</a></li>
<li><a href="javascript:download('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-download') }}</a></li>
<li class="divider"></li>
{{--<li><a href="javascript:notImp()">Rotate</a></li>--}}
<li><a href="javascript:resizeImage('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-resize') }}</a></li>
<li><a href="javascript:cropImage('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-crop') }}</a></li>
<li class="divider"></li>
<li><a href="javascript:trash('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-delete') }}</a></li>
</ul>
</div>
</div>
</div>
@endforeach
@else
<div class="col-md-12">
<p>{{ Lang::get('laravel-filemanager::lfm.message-empty') }}</p>
</div>
@endif
</div>
</div>

View File

@@ -0,0 +1,77 @@
<div class="container">
@if((sizeof($file_info) > 0) || (sizeof($directories) > 0))
<table class="table table-condensed table-striped">
<thead>
<th style='width:50%;'>{{ Lang::get('laravel-filemanager::lfm.title-item') }}</th>
<th>{{ Lang::get('laravel-filemanager::lfm.title-size') }}</th>
<th>{{ Lang::get('laravel-filemanager::lfm.title-type') }}</th>
<th>{{ Lang::get('laravel-filemanager::lfm.title-modified') }}</th>
<th>{{ Lang::get('laravel-filemanager::lfm.title-action') }}</th>
</thead>
<tbody>
@foreach($directories as $key => $dir_name)
<tr>
<td>
<i class="fa fa-folder-o"></i>
<a id="large_folder_{{ $key }}" data-id="{{ $dir_name }}" href="javascript:clickFolder('large_folder_{{ $key }}',1)">
{{ $dir_name }}
</a>
</td>
<td></td>
<td>{{ Lang::get('laravel-filemanager::lfm.type-folder') }}</td>
<td></td>
<td></td>
</tr>
@endforeach
@foreach($file_info as $file)
<tr>
<td>
<i class="fa fa-image"></i>
<?php $file_name = $file['name'];?>
<a href="javascript:useFile('{{ $file_name }}')">
{{ $file_name }}
</a>
&nbsp;&nbsp;
<a href="javascript:rename('{{ $file_name }}')">
<i class="fa fa-edit"></i>
</a>
</td>
<td>
{{ $file['size'] }}
</td>
<td>
{{ $file['type'] }}
</td>
<td>
{{ date("Y-m-d h:m", $file['created']) }}
</td>
<td>
<a href="javascript:trash('{{ $file_name }}')">
<i class="fa fa-trash fa-fw"></i>
</a>
<a href="javascript:cropImage('{{ $file_name }}')">
<i class="fa fa-crop fa-fw"></i>
</a>
<a href="javascript:resizeImage('{{ $file_name }}')">
<i class="fa fa-arrows fa-fw"></i>
</a>
{{--<a href="javascript:notImp()">--}}
{{--<i class="fa fa-rotate-left fa-fw"></i>--}}
{{--</a>--}}
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<div class="row">
<div class="col-md-12">
<p>{{ Lang::get('laravel-filemanager::lfm.message-empty') }}</p>
</div>
</div>
@endif
</div>

View File

@@ -0,0 +1,77 @@
<div class="container">
<div class="row">
@if((sizeof($files) > 0) || (sizeof($directories) > 0))
@foreach($directories as $key => $dir_name)
<div class="col-sm-6 col-md-2">
<div class="thumbnail text-center" data-id="{{ $dir_name }}">
<a id="folder_{{ $key }}" data-id="{{ $dir_name }}" onclick="clickFolder('folder_{{ $key }}',0)" class="folder-icon pointer">
{{--<i class="fa fa-folder-o fa-5x"></i>--}}
<img src="/vendor/laravel-filemanager/img/folder.jpg">
</a>
</div>
<div class="caption text-center">
<div class="btn-group">
<button type="button" onclick="clickFolder('folder_{{ $key }}',0)" class="btn btn-default btn-xs">
{{ str_limit($dir_name, $limit = 10, $end = '...') }}
</button>
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="javascript:rename('{{ $dir_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-rename') }}</a></li>
<li><a href="javascript:trash('{{ $dir_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-delete') }}</a></li>
</ul>
</div>
</div>
</div>
@endforeach
@foreach($files as $key => $file)
<?php $file_name = $file_info[$key]['name'];?>
<?php $thumb_src = $thumb_url . $file_name;?>
<div class="col-sm-6 col-md-2 img-row">
<div class="thumbnail thumbnail-img" data-id="{{ $file_name }}" id="img_thumbnail_{{ $key }}">
<img id="{{ $file }}" src="{{ $thumb_src }}" alt="" style="cursor:pointer;" onclick="useFile('{{ $file_name }}')">
</div>
<div class="caption text-center">
<div class="btn-group ">
<button type="button" onclick="useFile('{{ $file_name }}')" class="btn btn-default btn-xs">
{{ str_limit($file_name, $limit = 10, $end = '...') }}
</button>
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-expanded="false">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="javascript:rename('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-rename') }}</a></li>
<li><a href="javascript:fileView('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-view') }}</a></li>
<li><a href="javascript:download('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-download') }}</a></li>
<li class="divider"></li>
{{--<li><a href="javascript:notImp()">Rotate</a></li>--}}
<li><a href="javascript:resizeImage('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-resize') }}</a></li>
<li><a href="javascript:cropImage('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-crop') }}</a></li>
<li class="divider"></li>
<li><a href="javascript:trash('{{ $file_name }}')">{{ Lang::get('laravel-filemanager::lfm.menu-delete') }}</a></li>
</ul>
</div>
</div>
</div>
@endforeach
@else
<div class="col-md-12">
<p>{{ Lang::get('laravel-filemanager::lfm.message-empty') }}</p>
</div>
@endif
</div>
</div>

View File

@@ -0,0 +1,522 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ Lang::get('laravel-filemanager::lfm.title-page') }}</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="/vendor/laravel-filemanager/css/cropper.min.css">
<link rel="stylesheet" href="/vendor/laravel-filemanager/css/lfm.css">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.css">
</head>
<body>
<div class="container">
<div class="row fill">
<div class="panel panel-primary fill">
<div class="panel-heading">
<h3 class="panel-title">{{ Lang::get('laravel-filemanager::lfm.title-panel') }}</h3>
</div>
<div class="panel-body fill">
<div class="row fill">
<div class="wrapper fill">
<div class="col-md-2 col-lg-2 col-sm-2 col-xs-2 left-nav fill" id="lfm-leftcol">
<div id="tree1">
</div>
</div>
<div class="col-md-10 col-lg-10 col-sm-10 col-xs-10 right-nav" id="right-nav">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav" id="nav-buttons">
<li>
<a href="#!" id="upload" data-toggle="modal" data-target="#uploadModal"><i class="fa fa-upload"></i> {{ Lang::get('laravel-filemanager::lfm.nav-upload') }}</a>
</li>
<li>
<a href="#!" class="thumbnail-display" id="thumbnail-display"><i class="fa fa-picture-o"></i> {{ Lang::get('laravel-filemanager::lfm.nav-thumbnails') }}</a>
</li>
<li>
<a href="#!" class="list-display" id="list-display"><i class="fa fa-list"></i> {{ Lang::get('laravel-filemanager::lfm.nav-list') }}</a>
</li>
</ul>
</div>
</div>
</nav>
@if ($errors->any())
<div class="row">
<div class="col-md-12">
<div class="alert alert-danger" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<ul>
@foreach($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
</div>
</div>
@endif
<div id="content" class="row fill">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aia-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">{{ Lang::get('laravel-filemanager::lfm.title-upload') }}</h4>
</div>
<div class="modal-body">
<form action="{{url('/laravel-filemanager/upload')}}" role='form' id='uploadForm' name='uploadForm' method='post' enctype='multipart/form-data'>
<div class="form-group" id="attachment">
<label for='upload' class='control-label'>{{ Lang::get('laravel-filemanager::lfm.message-choose') }}</label>
<div class="controls">
<div class="input-group" style="width: 100%">
<input type="file" id="upload" name="upload">
</div>
</div>
</div>
<input type='hidden' name='working_dir' id='working_dir' value='{{$working_dir}}'>
<input type='hidden' name='show_list' id='show_list' value='0'>
<input type='hidden' name='_token' value='{{csrf_token()}}'>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ Lang::get('laravel-filemanager::lfm.btn-close') }}</button>
<button type="button" class="btn btn-primary" id="upload-btn">{{ Lang::get('laravel-filemanager::lfm.btn-upload') }}</button>
</div>
</div>
</div>
</div>
<div class="modal fade" id="fileViewModal" tabindex="-1" role="dialog" aria-labelledby="fileLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="fileLabel">{{ Lang::get('laravel-filemanager::lfm.title-view') }}</h4>
</div>
<div class="modal-body" id="fileview_body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ Lang::get('laravel-filemanager::lfm.btn-close') }}</button>
</div>
</div>
</div>
</div>
<script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
<script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.3.0/bootbox.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="/vendor/laravel-filemanager/js/cropper.min.js"></script>
<script src="/vendor/laravel-filemanager/js/jquery.form.min.js"></script>
<script>
var shared_folder = "{{ Config::get('lfm.shared_folder_name') }}";
var image_url = "{{ Config::get('lfm.images_url') }}";
var file_url = "{{ Config::get('lfm.files_url') }}";
$(document).ready(function () {
bootbox.setDefaults({locale:"{{ Lang::get('laravel-filemanager::lfm.locale-bootbox') }}"});
// load folders
$.ajax({
type: 'GET',
dataType: 'text',
url: '/laravel-filemanager/folders',
data: 'working_dir={{ $working_dir }}',
cache: false
}).done(function (data) {
$('#tree1').html(data);
});
loadItems();
refreshFolders();
});
$('#upload-btn').click(function () {
var options = {
beforeSubmit: showRequest,
success: showResponse
};
function showRequest(formData, jqForm, options) {
$('#upload-btn').html('<i class="fa fa-refresh fa-spin"></i> {{ Lang::get("laravel-filemanager::lfm.btn-uploading") }}');
return true;
}
function showResponse(responseText, statusText, xhr, $form) {
$('#uploadModal').modal('hide');
$('#upload-btn').html('{{ Lang::get("laravel-filemanager::lfm.btn-upload") }}');
if (responseText != 'OK'){
notify(responseText);
}
$('#upload').val('');
loadItems();
}
$('#uploadForm').ajaxSubmit(options);
return false;
});
function clickRoot() {
$('.folder-item').removeClass('fa-folder-open').addClass('fa-folder');
$('#folder_shared > i').removeClass('fa-folder-open').addClass('fa-folder');
$('#folder_root > i').addClass('fa-folder-open').removeClass('fa-folder');
$('#working_dir').val("{{ (Config::get('lfm.allow_multi_user')) ? Auth::user()->user_field : '/'}}");
loadItems();
}
function clickShared() {
$('.folder-item').removeClass('fa-folder-open').addClass('fa-folder');
$('#folder_root > i').removeClass('fa-folder-open').addClass('fa-folder');
$('#folder_shared > i').addClass('fa-folder-open').removeClass('fa-folder');
$('#working_dir').val(shared_folder);
loadItems();
}
function clickFolder(x, y) {
$('.folder-item').addClass('fa-folder');
$('#folder_shared > i').removeClass('fa-folder-open').addClass('fa-folder');
$('#folder_root > i').addClass('fa-folder-open').removeClass('fa-folder');
$('.folder-item').not('#folder_root > i').removeClass('fa-folder-open');
if (y == 0) {
if ($('#' + x + ' > i').hasClass('fa-folder')) {
$('#' + x + ' > i').not('#folder_root > i').removeClass('fa-folder');
$('#' + x + ' > i').not('#folder_root > i').addClass('fa-folder-open');
} else {
$('#' + x + ' > i').removeClass('fa-folder-open');
$('#' + x + ' > i').addClass('fa-folder');
}
}
$('#working_dir').val("{{ (Config::get('lfm.allow_multi_user')) ? Auth::user()->user_field.'/' : '' }}" + $('#' + x).data('id'));
loadItems();
}
function clickSharedFolder(x, y) {
$('.folder-item').addClass('fa-folder');
$('#folder_root > i').removeClass('fa-folder-open').addClass('fa-folder');
$('#folder_shared > i').addClass('fa-folder-open').removeClass('fa-folder');
$('.folder-item').not('#folder_shared > i').removeClass('fa-folder-open');
if (y == 0) {
if ($('#' + x + ' > i').hasClass('fa-folder')) {
$('#' + x + ' > i').not('#folder_shared > i').removeClass('fa-folder');
$('#' + x + ' > i').not('#folder_shared > i').addClass('fa-folder-open');
} else {
$('#' + x + ' > i').removeClass('fa-folder-open');
$('#' + x + ' > i').addClass('fa-folder');
}
}
$('#working_dir').val(shared_folder + '/' + $('#' + x).data('id'));
loadItems();
}
function download(x) {
location.href = '/laravel-filemanager/download?'
+ 'working_dir='
+ $('#working_dir').val()
+ '&file='
+ x;
}
function loadItems() {
var type = 'Images';
@if ((Session::has('lfm_type')) && (Session::get('lfm_type') == 'Files'))
type = 'Files';
@endif
$.ajax({
type: 'GET',
dataType: 'html',
url: '/laravel-filemanager/jsonitems',
data: {
working_dir: $('#working_dir').val(),
show_list: $('#show_list').val(),
type: type
},
cache: false
}).done(function (data) {
$('#content').html(data);
$('#nav-buttons').removeClass('hidden');
$('.dropdown-toggle').dropdown();
refreshFolders();
});
}
function trash(x) {
bootbox.confirm("{{ Lang::get('laravel-filemanager::lfm.message-delete') }}", function (result) {
if (result == true) {
$.ajax({
type: 'GET',
dataType: 'text',
url: '/laravel-filemanager/delete',
data: {
working_dir: $('#working_dir').val(),
items: x
},
cache: false
}).done(function (data) {
if (data != 'OK') {
notify(data);
} else {
if ($('#working_dir').val() == '{{ Auth::user()->user_field }}') {
loadFolders();
}
loadItems();
}
});
}
});
}
function loadFolders() {
$.ajax({
type: 'GET',
dataType: 'html',
url: '/laravel-filemanager/folders',
data: {
working_dir: $('#working_dir').val(),
show_list: $('#show_list').val()
},
cache: false
}).done(function (data) {
$('#tree1').html(data);
});
}
function refreshFolders() {
var wd = $('#working_dir').val();
if (wd != '/') {
try {
$('#' + wd + '-folder').removeClass('fa-folder');
$('#' + wd + '-folder').addClass('fa-folder-open');
} catch (e) {}
}
}
function cropImage(x) {
$.ajax({
type: 'GET',
dataType: 'text',
url: '/laravel-filemanager/crop',
data: {
img: x,
working_dir: $('#working_dir').val()
},
cache: false
}).done(function (data) {
$('#nav-buttons').addClass('hidden');
$('#content').html(data);
});
}
function notImp() {
bootbox.alert('Not yet implemented!');;
}
$('body').on('click', '#add-folder', function () {
bootbox.prompt("{{ Lang::get('laravel-filemanager::lfm.message-name') }}", function (result) {
if (result === null) {
} else {
$.ajax({
type: 'GET',
dataType: 'text',
url: '/laravel-filemanager/newfolder',
data: {
name: result,
working_dir: $('#working_dir').val()
},
cache: false
}).done(function (data) {
if (data == 'OK') {
loadFolders();
loadItems();
refreshFolders();
} else {
notify(data);
}
});
}
});
});
function useFile(file) {
var path = $('#working_dir').val();
var item_url = image_url;
@if ((Session::has('lfm_type')) && (Session::get('lfm_type') != "Images"))
item_url = file_url;
@endif
if (path != '/') {
item_url = item_url + path + '/';
}
function getUrlParam(paramName) {
var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i');
var match = window.location.search.match(reParam);
return ( match && match.length > 1 ) ? match[1] : null;
}
var field_name = getUrlParam('field_name');
var url = item_url + file;
if(window.opener || window.tinyMCEPopup || field_name || getUrlParam('CKEditorCleanUpFuncNum') || getUrlParam('CKEditor')) {
if(window.tinyMCEPopup){
// use TinyMCE > 3.0 integration method
var win = tinyMCEPopup.getWindowArg("window");
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = url;
if (typeof(win.ImageDialog) != "undefined") {
// Update image dimensions
if (win.ImageDialog.getImageData)
win.ImageDialog.getImageData();
// Preview if necessary
if (win.ImageDialog.showPreviewImage)
win.ImageDialog.showPreviewImage(url);
}
tinyMCEPopup.close();
return;
}
// tinymce 4 and colorbox
if (field_name) {
parent.document.getElementById(field_name).value = url;
if(typeof parent.tinyMCE !== "undefined") {
parent.tinyMCE.activeEditor.windowManager.close();
}
if(typeof parent.$.fn.colorbox !== "undefined") {
parent.$.fn.colorbox.close();
}
} else if(getUrlParam('CKEditor')) {
// use CKEditor 3.0 + integration method
if (window.opener) {
// Popup
window.opener.CKEDITOR.tools.callFunction(getUrlParam('CKEditorFuncNum'), url);
} else {
// Modal (in iframe)
parent.CKEDITOR.tools.callFunction(getUrlParam('CKEditorFuncNum'), url);
parent.CKEDITOR.tools.callFunction(getUrlParam('CKEditorCleanUpFuncNum'));
}
} else {
// use FCKEditor 2.0 integration method
if (data['Properties']['Width'] != '') {
var p = url;
var w = data['Properties']['Width'];
var h = data['Properties']['Height'];
window.opener.SetUrl(p,w,h);
} else {
window.opener.SetUrl(url);
}
}
if (window.opener) {
window.close();
}
} else {
$.prompt(lg.fck_select_integration);
}
window.close();
}
function rename(x) {
bootbox.prompt({
title: "{{ Lang::get('laravel-filemanager::lfm.message-rename') }}",
value: x,
callback: function (result) {
if (result !== null) {
$.ajax({
type: 'GET',
dataType: 'text',
url: '/laravel-filemanager/rename',
data: {
file: x,
working_dir: $('#working_dir').val(),
new_name: result
},
cache: false
}).done(function (data) {
if (data == 'OK') {
loadItems();
loadFolders();
} else {
notify(data);
}
});
}
}
});
}
function notify(x) {
bootbox.alert(x);
}
function resizeImage(x) {
$.ajax({
type: 'GET',
dataType: 'text',
url: '/laravel-filemanager/resize',
data: {
img: x,
working_dir: $('#working_dir').val()
},
cache: false
}).done(function (data) {
$('#nav-buttons').addClass('hidden');
$('#content').html(data);
});
}
$('#thumbnail-display').click(function () {
$('#show_list').val(0);
loadItems();
});
$('#list-display').click(function () {
$('#show_list').val(1);
loadItems();
});
function fileView(x) {
var rnd = makeRandom();
var img_src = image_url + $('#working_dir').val() + '/' + x;
var img = "<img class='img img-responsive center-block' src='" + img_src + "'>";
$('#fileview_body').html(img);
$('#fileViewModal').modal();
}
function makeRandom() {
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for( var i=0; i < 20; i++ )
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
}
</script>
</body>
</html>

View File

@@ -0,0 +1,96 @@
<div class="container">
<div class="row fill">
<div class="col-md-8 fill" id="containment">
<img id="resize" src="{{ $img }}" height="{{ $height }}" width="{{ $width }}">
</div>
<div class="col-md-4 fill">
<table class="table table-compact table-striped">
<thead></thead>
<tbody>
@if ($scaled)
<tr>
<td>{{ Lang::get('laravel-filemanager::lfm.resize-ratio') }}</td>
<td>{{ number_format($ratio, 2) }}</td>
</tr>
<tr>
<td>{{ Lang::get('laravel-filemanager::lfm.resize-scaled') }}</td>
<td>
{{ Lang::get('laravel-filemanager::lfm.resize-true') }}
</td>
</tr>
@endif
<tr>
<td>{{ Lang::get('laravel-filemanager::lfm.resize-old-height') }}</td>
<td>{{ $original_height }}px</td>
</tr>
<tr>
<td>{{ Lang::get('laravel-filemanager::lfm.resize-old-width') }}</td>
<td>{{ $original_width }}px</td>
</tr>
<tr>
<td>{{ Lang::get('laravel-filemanager::lfm.resize-new-height') }}</td>
<td><span id="height_display"></span></td>
</tr>
<tr>
<td>{{ Lang::get('laravel-filemanager::lfm.resize-new-width') }}</td>
<td><span id="width_display"></span></td>
</tr>
</tbody>
</table>
<button class="btn btn-primary" onclick="doResize()">{{ Lang::get('laravel-filemanager::lfm.btn-resize') }}</button>
<button class="btn btn-info" onclick="loadItems()">{{ Lang::get('laravel-filemanager::lfm.btn-cancel') }}</button>
<input type="hidden" name="ratio" value="{{ $ratio }}"><br>
<input type="hidden" name="scaled" value="{{ $scaled }}"><br>
<input type="hidden" id="original_height" name="original_height" value="{{ $original_height }}"><br>
<input type="hidden" id="original_width" name="original_width" value="{{ $original_width }}"><br>
<input type="hidden" id="height" name="height" value=""><br>
<input type="hidden" id="width" name="width">
</div>
</div>
</div>
<script>
$(document).ready(function () {
$("#height_display").html($("#resize").height() + "px");
$("#width_display").html($("#resize").width() + "px");
$("#resize").resizable({
aspectRatio: true,
containment: "#containment",
handles: "n, e, s, w, se, sw, ne, nw",
resize: function (event, ui) {
$("#width").val($("#resize").width());
$("#height").val($("#resize").height());
$("#height_display").html($("#resize").height() + "px");
$("#width_display").html($("#resize").width() + "px");
}
});
});
function doResize() {
$.ajax({
type: "GET",
dataType: "text",
url: "/laravel-filemanager/doresize",
data: {
img: '{{ $img }}',
working_dir: $("#working_dir").val(),
dataX: $("#dataX").val(),
dataY: $("#dataY").val(),
dataHeight: $("#height").val(),
dataWidth: $("#width").val()
},
cache: false
}).done(function (data) {
if (data == "OK") {
loadItems();
} else {
notify(data);
}
});
}
</script>

View File

@@ -0,0 +1,32 @@
<ul class="list-unstyled">
@if(Config::get('lfm.allow_multi_user'))
<li style="margin-left: -10px;">
<a class="pointer" id="folder_root" data-id="/" onclick="clickRoot()">
<i class="fa fa-folder-open" data-id="/"></i> {{ Lang::get('laravel-filemanager::lfm.title-root') }}
</a>
</li>
@foreach($dirs as $key => $dir_name)
<li>
<a class="pointer" id="folder_{{ $key }}" data-id="{{ $dir_name }}" onclick="clickFolder('folder_{{ $key }}', 0)">
<i class="fa fa-folder folder-item" data-id="{{ $dir_name }}" id="{{ $dir_name }}-folder"></i> {{ $dir_name }}
</a>
</li>
@endforeach
<a id="add-folder" class="add-folder btn btn-default btn-xs" style='margin-top:15px;'>
<i class="fa fa-plus"></i> {{ Lang::get('laravel-filemanager::lfm.menu-new') }}
</a>
<hr>
@endif
<li style="margin-left: -10px;">
<a class="pointer" id="folder_shared" data-id="/" onclick="clickShared()">
<i class="fa fa-folder" data-id="/"></i> {{ Lang::get('laravel-filemanager::lfm.title-shares') }}
</a>
</li>
@foreach($shares as $key => $dir_name)
<li>
<a class="pointer" id="shared_{{ $key }}" data-id="{{ $dir_name }}" onclick="clickSharedFolder('shared_{{ $key }}', 0)">
<i class="fa fa-folder folder-item" data-id="{{ $dir_name }}" id="{{ $dir_name }}-folder-shared"></i> {{ $dir_name }}
</a>
</li>
@endforeach
</ul>