mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-10-22 14:05:56 +02:00
DOCS Split readme documentation into docs/en files, add related documents information
This commit is contained in:
parent
9c0ec616d1
commit
cef27febf6
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1,3 +1,4 @@
|
|||||||
|
/docs export-ignore
|
||||||
/tests export-ignore
|
/tests export-ignore
|
||||||
/.gitignore export-ignore
|
/.gitignore export-ignore
|
||||||
/.travis.yml export-ignore
|
/.travis.yml export-ignore
|
||||||
|
113
README.md
113
README.md
@ -3,25 +3,20 @@
|
|||||||
[![Build status](https://travis-ci.org/silverstripe/silverstripe-dms.png?branch=master)](https://travis-ci.org/silverstripe/silverstripe-dms)
|
[![Build status](https://travis-ci.org/silverstripe/silverstripe-dms.png?branch=master)](https://travis-ci.org/silverstripe/silverstripe-dms)
|
||||||
[![Code quality](https://scrutinizer-ci.com/g/silverstripe/silverstripe-dms/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-dms/?branch=master)
|
[![Code quality](https://scrutinizer-ci.com/g/silverstripe/silverstripe-dms/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/silverstripe/silverstripe-dms/?branch=master)
|
||||||
[![Code coverage](https://codecov.io/gh/silverstripe/silverstripe-dms/branch/master/graph/badge.svg)](https://codecov.io/gh/silverstripe/silverstripe-dms)
|
[![Code coverage](https://codecov.io/gh/silverstripe/silverstripe-dms/branch/master/graph/badge.svg)](https://codecov.io/gh/silverstripe/silverstripe-dms)
|
||||||
|
![Helpful Robot](https://img.shields.io/badge/helpfulrobot-52-yellow.svg?style=flat)
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
The module adds a new `DMSDocument` model which allows management
|
The module adds a new `DMSDocument` model which allows management of large amounts of files, and their relations to
|
||||||
of large amounts of files, and their relations to pages.
|
pages. In contrast to the `File` model built into SilverStripe core, it aims to wrap storage and access concerns in
|
||||||
In contrast to the `File` model built into SilverStripe core,
|
a generic API. This allows more fine-grained control over how the documents are managed and exposed through the website.
|
||||||
it aims to wrap storage and access concerns in a generic API,
|
|
||||||
which allows more fine-grained control over how the documents are
|
|
||||||
managed and exposed through the website.
|
|
||||||
|
|
||||||
Additionally, documents are stored and managed as part of a page instead of
|
Additionally, documents are stored and managed as part of a page instead of away in a separate assets store.
|
||||||
away in a separate assets store.
|
|
||||||
|
|
||||||
Read more about the DMS module in this [blog post on silverstripe.org](http://www.silverstripe.org/document-management-system-module)
|
## Features
|
||||||
|
|
||||||
Features:
|
|
||||||
|
|
||||||
* Relation of documents to pages
|
* Relation of documents to pages
|
||||||
|
* Relation of documents to other documents
|
||||||
* Management and upload of documents within a page context in the CMS
|
* Management and upload of documents within a page context in the CMS
|
||||||
* Metadata management through the powerful `GridField` and `UploadField` core APIs
|
* Metadata management through the powerful `GridField` and `UploadField` core APIs
|
||||||
* Configurable tags for documents
|
* Configurable tags for documents
|
||||||
@ -29,30 +24,11 @@ Features:
|
|||||||
* Access control based on PHP logic, and page relations
|
* Access control based on PHP logic, and page relations
|
||||||
* Replacement of existing files
|
* Replacement of existing files
|
||||||
|
|
||||||
## Documents on the Filesystem
|
## Documentation
|
||||||
|
|
||||||
While the DMS architecture allows for remote storage of files,
|
For information on configuring and using this module, please see [the documentation section](docs/en/index.md).
|
||||||
the default implementation (the `DMS` class) stores them locally.
|
|
||||||
Relations to pages and tags are persisted as many-many relationships
|
|
||||||
through the SilverStripe ORM.
|
|
||||||
|
|
||||||
File locations in this implementation are structured into
|
## Requirements
|
||||||
subfolders, in order to avoid exceeding filesystem limits.
|
|
||||||
The file name is a composite based on its database ID
|
|
||||||
and the original file name. The exact location shouldn't
|
|
||||||
be relied on by custom logic, but rather retrieved through
|
|
||||||
the API (`DMSDocument->getLink()`).
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
dms-assets/
|
|
||||||
0/
|
|
||||||
1234~myfile.pdf
|
|
||||||
1/
|
|
||||||
2345~myotherfile.pdf
|
|
||||||
|
|
||||||
|
|
||||||
### Requirements
|
|
||||||
|
|
||||||
* PHP 5.3 with the "fileinfo" module (or alternatively the "whereis" and "file" Unix commands)
|
* PHP 5.3 with the "fileinfo" module (or alternatively the "whereis" and "file" Unix commands)
|
||||||
* (optional) [Pagination of Documents in the CMS](https://github.com/silverstripe-big-o/gridfieldpaginatorwithshowall)
|
* (optional) [Pagination of Documents in the CMS](https://github.com/silverstripe-big-o/gridfieldpaginatorwithshowall)
|
||||||
@ -61,75 +37,6 @@ Example:
|
|||||||
* (optional) [Text extraction for Document full-text search](https://github.com/silverstripe-big-o/silverstripe-textextraction)
|
* (optional) [Text extraction for Document full-text search](https://github.com/silverstripe-big-o/silverstripe-textextraction)
|
||||||
* (optional) [Tags](https://github.com/tubbs/silverstripe-dms-simple-tags)
|
* (optional) [Tags](https://github.com/tubbs/silverstripe-dms-simple-tags)
|
||||||
|
|
||||||
### Configuration
|
|
||||||
|
|
||||||
The file location is set via the `DMS::$dmsFolder` static, and points to a location in the webroot.
|
|
||||||
|
|
||||||
### Usage
|
|
||||||
|
|
||||||
Add a simple include to any of your .ss templates to display the DMSDocuments associated with
|
|
||||||
the current page on the front-end.
|
|
||||||
|
|
||||||
<% include Documents %>
|
|
||||||
|
|
||||||
#### Create Documents
|
|
||||||
|
|
||||||
Create by relative path:
|
|
||||||
|
|
||||||
$dms = DMS::getDMSInstance();
|
|
||||||
$doc = $dms->storeDocument('assets/myfile.pdf');
|
|
||||||
|
|
||||||
Create from an existing `File` record:
|
|
||||||
|
|
||||||
$dms = DMS::getDMSInstance();
|
|
||||||
$file = File::get()->byID(99);
|
|
||||||
$doc = $dms->storeDocument($file);
|
|
||||||
|
|
||||||
Note: Both operations copy the existing file.
|
|
||||||
|
|
||||||
#### Download Documents
|
|
||||||
|
|
||||||
$dms = DMS::getDMSInstance();
|
|
||||||
$docs = $dms->getByTag('priority', 'important')->First();
|
|
||||||
$link = $doc->getLink();
|
|
||||||
|
|
||||||
// Set default download behavior ('open' or 'download'). 'download' is the system default
|
|
||||||
// Attempt to open the file in the browser
|
|
||||||
Config::inst()->update('DMSDocument', 'default_download_behaviour', 'open');
|
|
||||||
|
|
||||||
Or in you config.yml:
|
|
||||||
|
|
||||||
DMSDocument:
|
|
||||||
default_download_behaviour: open
|
|
||||||
|
|
||||||
#### Manage Page Relations
|
|
||||||
|
|
||||||
// Find documents by page
|
|
||||||
$dms = DMS::getDMSInstance();
|
|
||||||
$page = SiteTree::get()->filter('URLSegment', 'home')->First();
|
|
||||||
$docs = $dms->getByPage($page);
|
|
||||||
|
|
||||||
// Add documents to page
|
|
||||||
|
|
||||||
#### Manage Tags
|
|
||||||
|
|
||||||
// Find documents by tag
|
|
||||||
$dms = DMS::getDMSInstance();
|
|
||||||
$docs = $dms->getByTag('priority', 'important');
|
|
||||||
|
|
||||||
// Add tag to existing document
|
|
||||||
$doc = Document::get()->byID(99);
|
|
||||||
$doc->addTag('priority', 'low');
|
|
||||||
|
|
||||||
// Supports multiple values for tags
|
|
||||||
$doc->addTag('category', 'keyboard');
|
|
||||||
$doc->addTag('category', 'input device');
|
|
||||||
|
|
||||||
// Removing tags is abstracted as well
|
|
||||||
$doc->removeTag('category', 'keyboard');
|
|
||||||
$doc->removeTag('category', 'input device');
|
|
||||||
$doc->removeAllTags();
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
### Translations
|
### Translations
|
||||||
|
0
docs/en/_manifest_exclude
Normal file
0
docs/en/_manifest_exclude
Normal file
3
docs/en/configuration.md
Normal file
3
docs/en/configuration.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Configuration
|
||||||
|
|
||||||
|
The file location is set via the `DMS::$dmsFolder` static, and points to a location in the webroot.
|
18
docs/en/creating-documents.md
Normal file
18
docs/en/creating-documents.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Creating documents
|
||||||
|
|
||||||
|
Create by relative path:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$dms = DMS::getDMSInstance();
|
||||||
|
$doc = $dms->storeDocument('assets/myfile.pdf');
|
||||||
|
```
|
||||||
|
|
||||||
|
Create from an existing `File` record:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$dms = DMS::getDMSInstance();
|
||||||
|
$file = File::get()->byID(99);
|
||||||
|
$doc = $dms->storeDocument($file);
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: Both operations copy the existing file.
|
18
docs/en/documents-on-the-filesystem.md
Normal file
18
docs/en/documents-on-the-filesystem.md
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Documents on the Filesystem
|
||||||
|
|
||||||
|
While the DMS architecture allows for remote storage of files, the default implementation (the `DMS` class)
|
||||||
|
stores them locally. Relations to pages and tags are persisted as many-many relationships through the SilverStripe ORM.
|
||||||
|
|
||||||
|
File locations in this implementation are structured into subfolders, in order to avoid exceeding filesystem limits.
|
||||||
|
The file name is a composite based on its database ID and the original file name. The exact location shouldn't be
|
||||||
|
relied on by custom logic, but rather retrieved through the API method `DMSDocument::getLink`.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
dms-assets/
|
||||||
|
0/
|
||||||
|
1234~myfile.pdf
|
||||||
|
1/
|
||||||
|
2345~myotherfile.pdf
|
||||||
|
```
|
28
docs/en/download-documents.md
Normal file
28
docs/en/download-documents.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Download documents
|
||||||
|
|
||||||
|
## Get the download link
|
||||||
|
|
||||||
|
You can use `DMSDocument::getLink` to retrieve the secure route to download a DMS document:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$dms = DMS::getDMSInstance();
|
||||||
|
$docs = $dms->getByTag('priority', 'important')->First();
|
||||||
|
$link = $doc->getLink();
|
||||||
|
```
|
||||||
|
|
||||||
|
## Default download behaviour
|
||||||
|
|
||||||
|
The default download behaviour is "download" which will force the browser to download the document. You
|
||||||
|
can select "open" as an option in the document's settings in the CMS individually, or you can change the global
|
||||||
|
default value with configuration:
|
||||||
|
|
||||||
|
```php
|
||||||
|
Config::inst()->update('DMSDocument', 'default_download_behaviour', 'open');
|
||||||
|
```
|
||||||
|
|
||||||
|
Or in YAML:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
DMSDocument:
|
||||||
|
default_download_behaviour: open
|
||||||
|
```
|
16
docs/en/index.md
Normal file
16
docs/en/index.md
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# DMS documentation
|
||||||
|
|
||||||
|
## Development
|
||||||
|
|
||||||
|
* [Configuration](configuration.md)
|
||||||
|
* [Documents on the filesystem](documents-on-the-filesystem.md)
|
||||||
|
* [Use in templates](use-in-templates.md)
|
||||||
|
* [Creating documents](creating-documents.md)
|
||||||
|
* [Download documents](download-documents.md)
|
||||||
|
* [Manage page relations](manage-page-relations.md)
|
||||||
|
* [Manage tags](manage-tags.md)
|
||||||
|
* [Manage related documents](manage-related-documents.md)
|
||||||
|
|
||||||
|
## CMS user help
|
||||||
|
|
||||||
|
* TBC
|
10
docs/en/manage-page-relations.md
Normal file
10
docs/en/manage-page-relations.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Manage page relations
|
||||||
|
|
||||||
|
To find documents by a Page:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$dms = DMS::getDMSInstance();
|
||||||
|
$page = SiteTree::get()->filter('URLSegment', 'home')->first();
|
||||||
|
/** @var DataList $docs */
|
||||||
|
$docs = $dms->getByPage($page);
|
||||||
|
```
|
50
docs/en/manage-related-documents.md
Normal file
50
docs/en/manage-related-documents.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# Manage related documents
|
||||||
|
|
||||||
|
You can relate documents to each other using the GridField under "Related Documents" in the CMS.
|
||||||
|
|
||||||
|
## Add related documents
|
||||||
|
|
||||||
|
You can use the model relationship `DMSDocument::RelatedDocuments` to modify the DataList and save as required:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$parentDocument = DMSDocument::get()->byId(123);
|
||||||
|
|
||||||
|
$relatedDocument = DMSDocument::get()->byId(234);
|
||||||
|
|
||||||
|
$parentDocument->RelatedDocuments()->add($relatedDocument);
|
||||||
|
```
|
||||||
|
|
||||||
|
Using the relationship method directly will skip the extension hook available in `getRelatedDocuments` (see below).
|
||||||
|
|
||||||
|
## Modifying the related documents list
|
||||||
|
|
||||||
|
If you need to modify the related documents DataList returned by the ORM, use the `updateRelatedDocuments` extension
|
||||||
|
hook provided by `DMSDocument::getRelatedDocuments`:
|
||||||
|
|
||||||
|
```php
|
||||||
|
# MyExtension is an extension applied to DMSDocument
|
||||||
|
class MyExtension extends DataExtension
|
||||||
|
{
|
||||||
|
public function updateRelatedDocuments($relatedDocuments)
|
||||||
|
{
|
||||||
|
foreach ($relatedDocuments as $document) {
|
||||||
|
// Add square brackets around the description
|
||||||
|
$document->Description = '[' . $document->Description . ']';
|
||||||
|
}
|
||||||
|
return $relatedDocuments;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Retrieving related documents
|
||||||
|
|
||||||
|
To retrieve a DataList of related documents you can either use `getRelatedDocuments` or the ORM relationship method
|
||||||
|
`RelatedDocuments` directly. The former will allow extensions to modify the list, whereas the latter will not.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$relatedDocuments = $document->getRelatedDocuments();
|
||||||
|
|
||||||
|
foreach ($relatedDocuments as $relatedDocument) {
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
```
|
32
docs/en/manage-tags.md
Normal file
32
docs/en/manage-tags.md
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# Manage Tags
|
||||||
|
|
||||||
|
## Find documents by tag
|
||||||
|
|
||||||
|
```php
|
||||||
|
$dms = DMS::getDMSInstance();
|
||||||
|
$docs = $dms->getByTag('priority', 'important');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Add tag to existing document
|
||||||
|
|
||||||
|
```php
|
||||||
|
$doc = DMSDocument::get()->byID(99);
|
||||||
|
$doc->addTag('priority', 'low');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Supports multiple values for tags
|
||||||
|
|
||||||
|
```php
|
||||||
|
$doc->addTag('category', 'keyboard');
|
||||||
|
$doc->addTag('category', 'input device');
|
||||||
|
```
|
||||||
|
|
||||||
|
## Removing tags
|
||||||
|
|
||||||
|
Removing tags is abstracted as well.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$doc->removeTag('category', 'keyboard');
|
||||||
|
$doc->removeTag('category', 'input device');
|
||||||
|
$doc->removeAllTags();
|
||||||
|
```
|
11
docs/en/use-in-templates.md
Normal file
11
docs/en/use-in-templates.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Use in templates
|
||||||
|
|
||||||
|
Add a simple include to any of your `.ss` templates to display the DMSDocuments associated with
|
||||||
|
the current page on the front-end.
|
||||||
|
|
||||||
|
```
|
||||||
|
<% include Documents %>
|
||||||
|
```
|
||||||
|
|
||||||
|
You can fine tune the HTML markup or display behaviour of any of the templates in `/dms/templates/Includes` to change
|
||||||
|
the way documents will be displayed in your project.
|
@ -11,7 +11,7 @@
|
|||||||
<p>$DescriptionWithLineBreak</p>
|
<p>$DescriptionWithLineBreak</p>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
|
|
||||||
<% if $RelatedDocuments %>
|
<% if $getRelatedDocuments %>
|
||||||
<% include RelatedDocuments %>
|
<% include RelatedDocuments %>
|
||||||
<% end_if %>
|
<% end_if %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<% if PageDocuments %>
|
<% if $PageDocuments %>
|
||||||
<div class="documents">
|
<div class="documents">
|
||||||
<h3><%t DMSDocument.PLURALNAME "Documents" %></h3>
|
<h3><%t DMSDocument.PLURALNAME "Documents" %></h3>
|
||||||
<% loop PageDocuments %>
|
<% loop $PageDocuments %>
|
||||||
<% include Document %>
|
<% include Document %>
|
||||||
<% end_loop %>
|
<% end_loop %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<h5><%t DMSDocument.RELATED_DOCUMENTS "Related documents" %></h5>
|
<h5><%t DMSDocument.RELATED_DOCUMENTS "Related documents" %></h5>
|
||||||
|
|
||||||
<ul class="documents-relateddocuments">
|
<ul class="documents-relateddocuments">
|
||||||
<% loop $RelatedDocuments %>
|
<% loop $getRelatedDocuments %>
|
||||||
<li>
|
<li>
|
||||||
<% if $Title %>
|
<% if $Title %>
|
||||||
<a href="$Link" title="<%t DMSDocument.DOWNLOAD "Download {title}" title=$Title %>">$Title</a>
|
<a href="$Link" title="<%t DMSDocument.DOWNLOAD "Download {title}" title=$Title %>">$Title</a>
|
||||||
|
Loading…
Reference in New Issue
Block a user