Skip to content

Commit 81359bd

Browse files
committed
Modify README syntax
1 parent cb4be99 commit 81359bd

File tree

2 files changed

+97
-105
lines changed

2 files changed

+97
-105
lines changed

README.md

Lines changed: 89 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Yii2 Multi format uploader module
22
==============
33

4-
1 Introduction
5-
----------------------------
4+
## Introduction
65

76
[![Latest Stable Version](https://poser.pugx.org/itstructure/yii2-multi-format-uploader/v/stable)](https://packagist.org/packages/itstructure/yii2-multi-format-uploader)
87
[![Latest Unstable Version](https://poser.pugx.org/itstructure/yii2-multi-format-uploader/v/unstable)](https://packagist.org/packages/itstructure/yii2-multi-format-uploader)
@@ -26,36 +25,36 @@ To work with Amazon it uses [AWS SDK](https://github.com/aws/aws-sdk-php).
2625

2726
Addition module description you can see in my [Personal site](https://pack-develop.info/en/product/yii2-multi-format-uploader).
2827

29-
2 Dependencies
30-
----------------------------
28+
## Dependencies
3129

3230
- php >= 7.1
3331
- composer
3432

35-
3 Installation
36-
----------------------------
33+
## Installation
3734

38-
### 3.1 Base install
35+
### Base install
3936

4037
Via composer:
4138

42-
```composer require itstructure/yii2-multi-format-uploader ~2.2.1```
39+
`composer require itstructure/yii2-multi-format-uploader ~2.2.2`
4340

4441
or in section **require** of composer.json file set the following:
45-
```
42+
43+
```json
4644
"require": {
47-
"itstructure/yii2-multi-format-uploader": "~2.2.1"
45+
"itstructure/yii2-multi-format-uploader": "~2.2.2"
4846
}
4947
```
50-
and command ```composer install```, if you install yii2 project extensions first,
5148

52-
or command ```composer update```, if all yii2 project extensions are already installed.
49+
and command `composer install`, if you install yii2 project extensions first,
5350

54-
### 3.2 If you are testing this package from local server directory
51+
or command `composer update`, if all yii2 project extensions are already installed.
5552

56-
In application ```composer.json``` file set the repository, like in example:
53+
### If you are testing this package from local server directory
5754

58-
```
55+
In application `composer.json` file set the repository, like in example:
56+
57+
```json
5958
"repositories": [
6059
{
6160
"type": "path",
@@ -73,9 +72,9 @@ Here,
7372

7473
Then run command:
7574

76-
```composer require itstructure/yii2-multi-format-uploader:dev-master --prefer-source```
75+
`composer require itstructure/yii2-multi-format-uploader:dev-master --prefer-source`
7776

78-
### 3.3 Apply module migrations
77+
### Apply module migrations
7978

8079
For that make next, **if not already done**:
8180

@@ -84,6 +83,7 @@ For that make next, **if not already done**:
8483
```php
8584
use Itstructure\MFUploader\Module as MFUModule;
8685
```
86+
8787
```php
8888
'modules' => [
8989
'mfuploader' => [
@@ -118,26 +118,23 @@ For that make next, **if not already done**:
118118

119119
- Run command in console:
120120

121-
```
122-
yii migrate --migrationPath=@mfuploader/migrations
123-
```
121+
`yii migrate --migrationPath=@mfuploader/migrations`
124122

125123
The data base structure:
126124

127-
![Data base structure](db_structure.jpg)
125+
![Data base structure](https://github.com/itstructure/yii2-multi-format-uploader/blob/master/db_structure.jpg)
128126

129-
4 Usage
130-
----------------------------
127+
## Usage
131128

132-
### 4.1 Main properties
129+
### Main properties
133130

134-
The **name** of module: ```mfuploader```
131+
The **name** of module: `mfuploader`
135132

136-
The **namespace** for used classes: ```Itstructure\MFUploader```.
133+
The **namespace** for used classes: `Itstructure\MFUploader`.
137134

138-
The **alias** to access in to module root directory: ```@mfuploader```.
135+
The **alias** to access in to module root directory: `@mfuploader`.
139136

140-
### 4.2 Application config
137+
### Application config
141138

142139
Base application config must be like in example below:
143140

@@ -200,18 +197,18 @@ use Itstructure\MFUploader\components\{
200197
],
201198
```
202199

203-
Here ```publicBaseUrl``` for example can be a project domain (```http://your-site-address.com```).
204-
If we have ```url``` in ```mediafiles``` table ```\uploads\images\imagealbum\0d\3890\a947f268d6f9fd02d8a0d7e147da922c.jpg```, and we use **getViewUrl()** function from a ```mediafile``` model for local files,
205-
then for example a result link to image for ```src``` attribute of ```<img>``` tag will be:
200+
Here `publicBaseUrl` for example can be a project domain (`http://your-site-address.com`).
201+
If we have `url` in `mediafiles` table `\uploads\images\imagealbum\0d\3890\a947f268d6f9fd02d8a0d7e147da922c.jpg`, and we use **getViewUrl()** function from a `mediafile` model for local files,
202+
then for example a result link to image for `src` attribute of `<img>` tag will be:
206203

207-
```http://your-site-address.com/uploads/images/imagealbum/0d/3890/a947f268d6f9fd02d8a0d7e147da922c.jpg```
204+
`http://your-site-address.com/uploads/images/imagealbum/0d/3890/a947f268d6f9fd02d8a0d7e147da922c.jpg`
208205

209-
**Note:** It is not necessary to configure two components: ```local-upload-component``` and ```s3-upload-component```.
210-
You must configure minimum one component, according with the ```defaultStorageType```.
206+
**Note:** It is not necessary to configure two components: `local-upload-component` and `s3-upload-component`.
207+
You must configure minimum one component, according with the `defaultStorageType`.
211208

212-
### 4.3 File field for the view template
209+
### File field for the view template
213210

214-
**File field** must be rendered by ```FileSetter``` widget.
211+
**File field** must be rendered by `FileSetter` widget.
215212

216213
It is necessary to send an ID or URL of uploaded mediafile to you application controller and set in
217214
model.
@@ -224,6 +221,7 @@ use Itstructure\MFUploader\widgets\FileSetter;
224221
use Itstructure\MFUploader\Module as MFUModule;
225222
use Itstructure\MFUploader\interfaces\UploadModelInterface;
226223
```
224+
227225
```html
228226
Container to display selected image.
229227
<div class="media">
@@ -235,6 +233,7 @@ Container to display selected image.
235233
</div>
236234
</div>
237235
```
236+
238237
```php
239238
echo FileSetter::widget([
240239
'model' => $model,
@@ -254,32 +253,32 @@ echo FileSetter::widget([
254253
]);
255254
```
256255

257-
### 4.4 Configure upload components
256+
### Configure upload components
258257

259-
#### 4.4.1 Base attributes in BaseUploadComponent
258+
#### Base attributes in BaseUploadComponent
260259

261260
**Note:** BaseUploadComponent - the base class, which LocalUploadComponent and S3UploadComponent extend.
262261

263-
To understand the principles of configure the base attributes, see public attributes in ```components\BaseUploadComponent``` class.
264-
But it may be difficult to configure ```thumbsConfig``` and ```thumbFilenameTemplate```.
265-
Attribute ```thumbsConfig``` takes the values according with the next chain:
266-
1. From the default config file ```config/thumbs-config.php``` in module **init()** function.
267-
2. Can be rewrited by custom during module ```thumbsConfig``` attribute.
268-
3. Previous config result inserted in to the ```LocalUploadComponent``` and ```S3UploadComponent``` module components.
269-
4. Configuration ```thumbsConfig``` in module components can be rewrited by custom during component ```thumbsConfig``` attribute.
262+
To understand the principles of configure the base attributes, see public attributes in `components\BaseUploadComponent` class.
263+
But it may be difficult to configure `thumbsConfig` and `thumbFilenameTemplate`.
264+
Attribute `thumbsConfig` takes the values according with the next chain:
265+
1. From the default config file `config/thumbs-config.php` in module **init()** function.
266+
2. Can be rewrited by custom during module `thumbsConfig` attribute.
267+
3. Previous config result inserted in to the `LocalUploadComponent` and `S3UploadComponent` module components.
268+
4. Configuration `thumbsConfig` in module components can be rewrited by custom during component `thumbsConfig` attribute.
270269

271-
#### 4.4.2 Attributes in LocalUploadComponent
270+
#### Attributes in LocalUploadComponent
272271

273-
That is very simple. See public attributes in ```components\LocalUploadComponent``` class.
272+
That is very simple. See public attributes in `components\LocalUploadComponent` class.
274273

275-
#### 4.4.3 Attributes in S3UploadComponent
274+
#### Attributes in S3UploadComponent
276275

277-
See public attributes in ```components\S3UploadComponent``` class.
276+
See public attributes in `components\S3UploadComponent` class.
278277
But there are important attributes:
279-
- ```credentials```. Attribute to access in to Amazon web services account.
278+
- `credentials`. Attribute to access in to Amazon web services account.
280279
Can be: array, callable, and other. See https://docs.aws.amazon.com/aws-sdk-php/v3/guide/guide/credentials.html.
281-
- ```s3DefaultBucket``` - bucket, which you use to upload files as default.
282-
- ```s3Buckets``` - buckets to upload files depending on the owner. Not required.
280+
- `s3DefaultBucket` - bucket, which you use to upload files as default.
281+
- `s3Buckets` - buckets to upload files depending on the owner. Not required.
283282

284283
config example:
285284
```php
@@ -296,23 +295,24 @@ For more information of S3 configuration, see the next links:
296295
- https://docs.aws.amazon.com/aws-sdk-php/v3/api
297296
- https://github.com/aws/aws-sdk-php
298297

299-
### 4.5 Link entities with owners
298+
### Link entities with owners
300299

301-
To link entities (mediafiles and albums) with owners (pages, articles, posts e.t.c...) there is the abstract class ```behaviors\Behavior```.
300+
To link entities (mediafiles and albums) with owners (pages, articles, posts e.t.c...) there is the abstract class `behaviors\Behavior`.
302301

303-
You must use child classes: ```behaviors\BehaviorMediafile``` and ```behaviors\BehaviorAlbum```.
302+
You must use child classes: `behaviors\BehaviorMediafile` and `behaviors\BehaviorAlbum`.
304303

305304
Explanation by example.
306305

307-
You have a ```catalog``` model which extends an ActiveRecord yii2 class.
306+
You have a `catalog` model which extends an ActiveRecord yii2 class.
308307

309-
Use a ```behaviors\BehaviorMediafile``` and ```behaviors\BehaviorAlbum``` in **behaviors** of your ```catalog``` model to link mediafiles and albums with catalog after: **insert active record**, **update active record**, **delete active record**:
308+
Use a `behaviors\BehaviorMediafile` and `behaviors\BehaviorAlbum` in **behaviors** of your `catalog` model to link mediafiles and albums with catalog after: **insert active record**, **update active record**, **delete active record**:
310309

311310
```php
312311
use Itstructure\MFUploader\behaviors\{BehaviorMediafile, BehaviorAlbum};
313312
use Itstructure\MFUploader\interfaces\UploadModelInterface;
314313
use Itstructure\MFUploader\models\album\Album;
315314
```
315+
316316
```php
317317
public $thumbnail;
318318

@@ -339,73 +339,62 @@ public function behaviors()
339339
}
340340
```
341341

342-
**Note:** This block should be used in conjunction with the ```FileSetter``` widget inside the view form template!
342+
**Note:** This block should be used in conjunction with the `FileSetter` widget inside the view form template!
343343

344344
Here the following happens:
345345

346-
- If you use a "thumbnail" name of ```attribute``` param in FileSetter widget, the uploaded mediafile (thumbnail) will be linked with ```catalog``` after insert new catalog data to the data base.
347-
- If you use an "imageAlbum" (by Album::ALBUM_TYPE_IMAGE) name of the ```name``` attribute of dropdown or checkbox html field, the last created image album will be linked with ```catalog``` after insert new catalog data to the data base.
346+
- If you use a "thumbnail" name of `attribute` param in FileSetter widget, the uploaded mediafile (thumbnail) will be linked with `catalog` after insert new catalog data to the data base.
347+
- If you use an "imageAlbum" (by Album::ALBUM_TYPE_IMAGE) name of the `name` attribute of dropdown or checkbox html field, the last created image album will be linked with `catalog` after insert new catalog data to the data base.
348348

349349
That works according with the next data base example structure:
350350

351-
```Table "mediafiles"``` - record with id=20 now inserted.
351+
`Table "mediafiles"` - record with id=20 now inserted.
352352

353-
```php
354-
| id | ... | created_at | updated_at |
355-
|-----|-----|---------------------|---------------------|
356-
| ... | ... | ... | ... |
357-
| 20 | ... | 2018-05-06 21:35:04 | 2018-05-06 21:35:10 |
358-
```
353+
| id | ... | created_at | updated_at |
354+
|-----|-----|---------------------|---------------------|
355+
| ... | ... | ... | ... |
356+
| 20 | ... | 2018-05-06 21:35:04 | 2018-05-06 21:35:10 |
359357

360-
```Table "catalog"``` - record with id=10 inserted after create mediafile (id=20).
358+
`Table "catalog"` - record with id=10 inserted after create mediafile (id=20).
361359

362-
```php
363-
| id | ... | created_at | updated_at |
364-
|-----|-----|---------------------|---------------------|
365-
| ... | ... | ... | ... |
366-
| 10 | ... | 2018-05-06 21:35:20 | 2018-05-06 21:35:25 |
367-
```
360+
| id | ... | created_at | updated_at |
361+
|-----|-----|---------------------|---------------------|
362+
| ... | ... | ... | ... |
363+
| 10 | ... | 2018-05-06 21:35:20 | 2018-05-06 21:35:25 |
368364

369-
```Table "owners_mediafiles"```
365+
`Table "owners_mediafiles"`
370366

371-
```php
372-
| mediafileId | ownerId | owner | ownerAttribute |
373-
|-------------|---------|-----------|------------------|
374-
| ... | ... | ... | ... |
375-
| 20 | 10 | catalog | thumbnail |
376-
```
367+
| mediafileId | ownerId | owner | ownerAttribute |
368+
|-------------|---------|-----------|------------------|
369+
| ... | ... | ... | ... |
370+
| 20 | 10 | catalog | thumbnail |
377371

378-
```Table "albums"```
372+
`Table "albums"`
379373

380-
```php
381-
| id | type | ... | created_at | updated_at |
382-
|-----|-------------|-----|---------------------|---------------------|
383-
| ... | ... | ... | ... | ... |
384-
| 5 | imageAlbum | ... | 2018-05-06 21:30:00 | 2018-05-06 21:30:05 |
385-
```
374+
| id | type | ... | created_at | updated_at |
375+
|-----|-------------|-----|---------------------|---------------------|
376+
| ... | ... | ... | ... | ... |
377+
| 5 | imageAlbum | ... | 2018-05-06 21:30:00 | 2018-05-06 21:30:05 |
386378

387-
```Table "owners_albums"```
379+
`Table "owners_albums"`
388380

389-
```php
390-
| albumId | ownerId | owner | ownerAttribute |
391-
|---------|---------|-----------|------------------|
392-
| ... | ... | ... | ... |
393-
| 5 | 10 | catalog | imageAlbum |
394-
```
381+
| albumId | ownerId | owner | ownerAttribute |
382+
|---------|---------|-----------|------------------|
383+
| ... | ... | ... | ... |
384+
| 5 | 10 | catalog | imageAlbum |
395385

396-
**Note:** If you set in ```FileSetter``` widget the attributes: ```owner```, ```ownerId```, ```ownerAttribute``` - linking entity with owner will be done automatically during ajax request in **uploadmanager**.
386+
**Note:** If you set in `FileSetter` widget the attributes: `owner`, `ownerId`, `ownerAttribute` - linking entity with owner will be done automatically during ajax request in **uploadmanager**.
397387

398-
### 4.6 Integrated album controllers
388+
### Integrated album controllers
399389

400-
There are already integrated album controllers in the namespace: ```Itstructure\MFUploader\controllers\album```.
390+
There are already integrated album controllers in the namespace: `Itstructure\MFUploader\controllers\album`.
401391
Controllers provide the work with the next types of albums: **imageAlbum**, **audioAlbum**, **videoAlbum**, **applicationAlbum**, **textAlbum**, **otherAlbum**.
402392

403393
For that controllers there are already the models and view templates.
404394

405395
To work with that, you must set just the routes in application configuration.
406396

407-
License
408-
----------------------------
397+
## License
409398

410399
Copyright © 2018-2020 Andrey Girnik girnikandrey@gmail.com.
411400

changelog.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
### CHANGE LOG:
22

3+
**2.2.2 June 23, 2020:**
4+
- Modify README syntax.
5+
36
**2.2.1 June 20, 2020:**
4-
- Bug fix for **getThumbUrl()** method in ```Mediafile``` model.
7+
- Bug fix for **getThumbUrl()** method in `Mediafile` model.
58

69
**2.2.0 June 15, 2020:**
710
- Change saving local file **url** to DB.
@@ -15,7 +18,7 @@
1518
- Upgrade of the copyright time and add a personal site link.
1619

1720
**2.1.3 August 19, 2019:**
18-
- Bug fix for set an unique name of uploading file. Used **microtime()** in ```LocalUpload``` and ```S3Upload``` models.
21+
- Bug fix for set an unique name of uploading file. Used **microtime()** in `LocalUpload` and `S3Upload` models.
1922

2023
**2.1.2 June 12, 2019:**
2124
- Optimize getting module object from a mediafile in **getModule()** function.
@@ -25,8 +28,8 @@
2528
Used in **getPreviewOptions()** module method if **is_callable($previewOptions[$location])**.
2629

2730
**2.1.0 May 18, 2019:**
28-
- Add **urlPrefix parameter** in to ```AlbumController``` for redirect and view links.
29-
- Add **urlPrefixNeighbor** parameter in to ```AlbumController``` for view links of neighbor entity.
31+
- Add **urlPrefix parameter** in to `AlbumController` for redirect and view links.
32+
- Add **urlPrefixNeighbor** parameter in to `AlbumController` for view links of neighbor entity.
3033

3134
**2.0.1 August 9, 2018:**
3235
- Delete duplicates and optimize code.
@@ -38,7 +41,7 @@
3841
- Renaming controllers and models to a single entity name.
3942
- Renaming module constants.
4043
- Some simple code fixes.
41-
- Add **file_exists()** check function in to **sendFile()** of the ```LocalUpload``` model.
44+
- Add **file_exists()** check function in to **sendFile()** of the `LocalUpload` model.
4245
- Fixes for README.
4346

4447
**1.0.0 May 15, 2018:**

0 commit comments

Comments
 (0)