Go to file
2012-08-07 18:37:10 +12:00
_config ENHANCEMENT: download link functionality 2012-07-27 17:40:17 +12:00
code ENHANCEMENT: adding the ability to extend a DMSDocument's file querying mechanism. 2012-08-07 18:19:58 +12:00
css ENHANCEMENT: hiding the field that filters by last changed, because it is very confusing what to enter into that field to do the filtering 2012-08-07 17:38:57 +12:00
images ENHANCEMENT: Styling for Adding document edit panel. Duplicate file type icons and rename with osx extensions 2012-08-07 12:23:03 +12:00
javascript MINOR: refactoring from JSLint 2012-08-07 18:37:10 +12:00
resources ENHANCEMENT: protecting the "dms-assets" folder from web access 2012-08-07 11:16:10 +12:00
scss ENHANCEMENT: hiding the field that filters by last changed, because it is very confusing what to enter into that field to do the filtering 2012-08-07 17:38:57 +12:00
templates FEATURE: Autocomplete for add document 2012-08-07 13:45:01 +12:00
tests ENHANCEMENT: warning when deleting a page with documents that exist only on this page. Also, when actually deleting the page, delete the associated documents that only exist on that page 2012-08-07 14:39:07 +12:00
_config.php FEATURE: Upload button for documents (WIP) 2012-07-31 14:12:20 +12:00
.gitignore ENHANCEMENT: adding scss stlying 2012-08-01 16:12:11 +12:00
config.rb ENHANCEMENT: adding scss stlying 2012-08-01 16:12:11 +12:00
README.md Added README 2012-08-06 16:20:33 +02:00
testfile MINOR: adding test file 2012-07-18 17:58:00 +12:00

Document Management Module (DMS)

Overview

The module adds a new DMSDocument model which allows management of large amounts of files, and their relations to pages. In contrast to the File model built into SilverStripe core, 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.

Features:

  • Relation of documents to pages
  • Management and upload of documents within a page context in the CMS
  • Metadata management through the powerful GridField and UploadField core APIs
  • Configurable tags for documents
  • Download via SilverStripe controller (rather than filesystem URLs)
  • Access control based on PHP logic, and page relations
  • Replacement of existing files

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 (DMSDocument->getDownloadLink()).

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)

Configuration

The file location is set via the DMS::$dmsFolder static, and points to a location in the webroot.

Usage

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->getDownloadLink();

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();