@@ -6,14 +6,14 @@ File uploads and management, for CodeIgniter 4
661 . Install with Composer: ` > composer require tatter/files `
772 . Migrate the database: ` > php spark migrate -all `
882 . Seed the database: ` > php spark db:seed "Tatter\Files\Database\Seeds\FileSeeder" `
9- 3 . Start managing files: https://[ yourdomain .com] /files
9+ 3 . Start managing files: https://example .com/files
1010
1111## Features
1212
1313The Files module is a self-contained set of routes and functions that adds uploading and
1414CRUD controls to any project. It uses [ DropzoneJS] ( https://www.dropzonejs.com ) for
15- drag-and-drop uploads, and supports a number of extensions for directing files to other
16- locations (WIP) .
15+ drag-and-drop uploads, and supports a number of extensions for generating file thumbnails
16+ and exporting files to various destinations .
1717
1818## Installation
1919
@@ -41,14 +41,21 @@ writable/files/*
4141## Configuration (optional)
4242
4343The library's default behavior can be altered by extending its config file. Copy
44- ** bin /Files.php** to ** app/Config/** and follow the instructions
44+ ** examples /Files.php** to ** app/Config/** and follow the instructions
4545in the comments. If no config file is found in ** app/Config** the library will use its own.
4646
4747## Usage
4848
4949Default routes:
5050* ** files/index** - If user is allowed ` mayList() ` then shows all files, otherwise tries to fall back to the current logged in user
51- * ** files/user** - Shows files for a single user; if no user ID is supplied it defaults to the current logged in user
51+ * ** files/user/{userId}** - Shows files for a single user; if no user ID is supplied it defaults to the current logged in user
52+ * ** files/thumbnail/{fileId}** - Displays the thumbnail for a file
53+
54+ CRUD:
55+ * ** files/new** - Basic Dropzone form
56+ * ** files/upload** - Accepts AJAX upload requests from Dropzone
57+ * ** files/delete/{fileId}** - Removes a file
58+ * ** files/rename/{fileId}** - Accepts POST data to rename a file
5259
5360Available formats:
5461* ** ?format=cards** - Default view with thumbnail on responsive layout
@@ -63,3 +70,51 @@ group for global file access.
6370
6471By default the ** files/** routes are available as soon as the module is installed. In most
6572cases you will want to use Route Filters to restrict some or all of the routes.
73+
74+ ## Extending
75+
76+ ** Controllers/Files.php** is the heart of the module, using cascading options to choose
77+ which files to display when. This controller has a ` setData() ` method to allow you to
78+ intercept this process to provide your own settings at any point. Simply extend the
79+ controller to your own and then provide whatever changes you would like, followed
80+ by the ` display() ` method. E.g.:
81+
82+ ```
83+ <?php namespace App\Controller;
84+
85+ class WidgetFiles
86+ {
87+ public function index($widgetId)
88+ {
89+ $this->setData([
90+ 'format' => 'cards',
91+ 'files' => model(WidgetModel::class)->getFiles($widgetId),
92+ 'layout' => 'manage',
93+ ]);
94+
95+ return $this->display();
96+ }
97+ }
98+
99+ ```
100+
101+ These are the default options for ` setData() ` , but you may also supply anything else you
102+ need in your view:
103+
104+ * ` source ` - The name of the controller method making the call
105+ * ` layout ` - The view layout to use (see ** Config/Files.php** )
106+ * ` files ` - An array of Files to display
107+ * ` selected ` - Files to pre-select (for the ` select ` format)
108+ * ` userId ` - ID of a user to filter for Files`
109+ * ` username ` - Display name of the user for the default layout title
110+ * ` ajax ` - Whether to process the request as an AJAX call (skips layout wrapping)
111+ * ` search ` - Search term to filter Files
112+ * ` sort ` - File sort field
113+ * ` order ` - File sort order
114+ * ` format ` - Display format for files (cards, list, select, or your own!)
115+ * ` perPage ` - Number of items to display per page
116+ * ` page ` - Page number (leave ` null ` for default Pager handling)
117+ * ` pager ` - ` Pager ` instance to handle pagination
118+ * ` access ` - Whether the files can be modified, "manage" or "display"
119+ * ` exports ` - Destinations a File may be sent to (see ` Tatter\Exports ` )
120+ * ` bulks ` - Bulk destinations for a group of Files (see ` Tatter\Exports ` )
0 commit comments