mirror of
https://github.com/silverstripe/silverstripe-dms
synced 2024-06-16 17:51:30 +02:00
API-CHANGE: adding ability to show/hide the Document tab on specific pages
This commit is contained in:
parent
18c2081be7
commit
a9f9e7111a
13
_config.php
13
_config.php
|
@ -1,5 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
DMSDocument_versions::$enable_versions = true;
|
||||||
|
|
||||||
|
DMSSiteTreeExtension::show_documents_tab(); //show the Documents tab on all pages
|
||||||
|
DMSSiteTreeExtension::no_documents_tab(); //and don't exclude it from any pages
|
||||||
|
|
||||||
define('DMS_DIR', 'dms');
|
define('DMS_DIR', 'dms');
|
||||||
|
|
||||||
|
|
||||||
if (!file_exists(BASE_PATH . DIRECTORY_SEPARATOR . DMS_DIR)) user_error("DMS directory named incorrectly. Please install the DMS module into a folder named: ".DMS_DIR);
|
if (!file_exists(BASE_PATH . DIRECTORY_SEPARATOR . DMS_DIR)) user_error("DMS directory named incorrectly. Please install the DMS module into a folder named: ".DMS_DIR);
|
||||||
|
|
||||||
Object::add_extension('SiteTree','DMSSiteTreeExtension');
|
Object::add_extension('SiteTree','DMSSiteTreeExtension');
|
||||||
|
@ -8,10 +16,7 @@ CMSMenu::remove_menu_item('DMSDocumentAddController');
|
||||||
|
|
||||||
ShortcodeParser::get('default')->register('dms_document_link', array('DMSDocument_Controller', 'dms_link_shortcode_handler'));
|
ShortcodeParser::get('default')->register('dms_document_link', array('DMSDocument_Controller', 'dms_link_shortcode_handler'));
|
||||||
|
|
||||||
DMSDocument_versions::$enable_versions = true;
|
|
||||||
|
|
||||||
if (DMSDocument_versions::$enable_versions) {
|
if (DMSDocument_versions::$enable_versions) {
|
||||||
//using the same db relations for the versioned documents, as for the actual documents
|
//using the same db relations for the versioned documents, as for the actual documents
|
||||||
Config::inst()->update('DMSDocument_versions', 'db', DMSDocument::$db);
|
Config::inst()->update('DMSDocument_versions', 'db', DMSDocument::$db);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,15 +5,16 @@ class DMSSiteTreeExtension extends DataExtension {
|
||||||
'Documents' => 'DMSDocument'
|
'Documents' => 'DMSDocument'
|
||||||
);
|
);
|
||||||
|
|
||||||
static $noDocumentsList = array(
|
static $noDocumentsList = array();
|
||||||
);
|
static $showDocumentsList = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not show the documents tab on the array of pages set here
|
* Do not show the documents tab on the array of pages set here
|
||||||
* @static
|
* @static
|
||||||
* @param $mixed Array of page types to not show the Documents tab on
|
* @param $mixed Array of page types to not show the Documents tab on
|
||||||
*/
|
*/
|
||||||
static function no_documents_tab($array) {
|
static function no_documents_tab($array = array()) {
|
||||||
|
if (empty($array)) return;
|
||||||
if (is_array($array)) {
|
if (is_array($array)) {
|
||||||
self::$noDocumentsList = $array;
|
self::$noDocumentsList = $array;
|
||||||
} else {
|
} else {
|
||||||
|
@ -21,9 +22,25 @@ class DMSSiteTreeExtension extends DataExtension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only show the documents tab on the list of pages set here. Any pages set in the no_documents_tab array will
|
||||||
|
* still not be shown. If this isn't called, or if it is called with an empty array, all pages will get Document tabs.
|
||||||
|
* @static
|
||||||
|
* @param $array Array of page types to show the Documents tab on
|
||||||
|
*/
|
||||||
|
static function show_documents_tab($array = array()) {
|
||||||
|
if (empty($array)) return;
|
||||||
|
if (is_array($array)) {
|
||||||
|
self::$showDocumentsList = $array;
|
||||||
|
} else {
|
||||||
|
self::$showDocumentsList = array($array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateCMSFields(FieldList $fields){
|
function updateCMSFields(FieldList $fields){
|
||||||
//prevent certain pages from having a Document tab in the CMS
|
//prevent certain pages from having a Document tab in the CMS
|
||||||
if (in_array($this->owner->ClassName,self::$noDocumentsList)) return;
|
if (in_array($this->owner->ClassName,self::$noDocumentsList)) return;
|
||||||
|
if (count(self::$showDocumentsList) > 0 && !in_array($this->owner->ClassName,self::$showDocumentsList)) return;
|
||||||
|
|
||||||
//javascript to customize the grid field for the DMS document (overriding entwine in FRAMEWORK_DIR.'/javascript/GridField.js'
|
//javascript to customize the grid field for the DMS document (overriding entwine in FRAMEWORK_DIR.'/javascript/GridField.js'
|
||||||
Requirements::javascript(DMS_DIR.'/javascript/DMSGridField.js');
|
Requirements::javascript(DMS_DIR.'/javascript/DMSGridField.js');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user