mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge branch 'silverstripe-big-o-SSF-65'
This commit is contained in:
commit
108ea1d0e6
@ -2438,6 +2438,36 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A flag provides the user with additional data about the current page status,
|
||||||
|
* for example a "removed from draft" status. Each page can have more than one status flag.
|
||||||
|
* Returns a map of a unique key to a (localized) title for the flag.
|
||||||
|
* The unique key can be reused as a CSS class.
|
||||||
|
* Use the 'updateStatusFlags' extension point to customize the flags.
|
||||||
|
* Example: "deletedonlive" => "Deleted"
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function getStatusFlags() {
|
||||||
|
$flags = array();
|
||||||
|
if($this->IsDeletedFromStage) {
|
||||||
|
if($this->ExistsOnLive) {
|
||||||
|
$flags['removedfromdraft'] = _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft');
|
||||||
|
} else {
|
||||||
|
$flags['deletedonlive'] = _t('SiteTree.DELETEDPAGESHORT', 'Deleted');
|
||||||
|
}
|
||||||
|
} else if($this->IsAddedToStage) {
|
||||||
|
$flags['addedtodraft'] = _t('SiteTree.ADDEDTODRAFTSHORT', 'New');
|
||||||
|
} else if($this->IsModifiedOnStage) {
|
||||||
|
$flags['modified'] = _t('SiteTree.MODIFIEDONDRAFTSHORT', 'Modified');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->extend('updateStatusFlags', $flags);
|
||||||
|
|
||||||
|
return $flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated 3.0 Use getTreeTitle()
|
* @deprecated 3.0 Use getTreeTitle()
|
||||||
*/
|
*/
|
||||||
@ -2447,29 +2477,27 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TitleWithStatus will return the title in an <ins>, <del> or
|
* getTreeTitle will return three <span> html DOM elements, an empty <span> with
|
||||||
* <span class=\"modified\"> tag depending on its publication status.
|
* the class 'jstree-pageicon' in front, following by a <span> wrapping around its
|
||||||
|
* MenutTitle, then following by a <span> indicating its publication status.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string a html string ready to be directly used in a template
|
||||||
*/
|
*/
|
||||||
function getTreeTitle() {
|
function getTreeTitle() {
|
||||||
$text = Convert::raw2xml(str_replace(array("\n","\r"),"",$this->MenuTitle));
|
$flags = $this->getStatusFlags();
|
||||||
if($this->IsDeletedFromStage) {
|
$treeTitle = sprintf(
|
||||||
if($this->ExistsOnLive) {
|
"<span class=\"jstree-pageicon\"></span><span class=\"item\">%s</span>",
|
||||||
$tag ="<span class=\"del item\" title=\"" . _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft') . "\" >{$text}</span> <span class=\"badge removedfromdraft\">" . _t('SiteTree.REMOVEDFROMDRAFTSHORT', 'Removed from draft') . "</span>";
|
Convert::raw2xml(str_replace(array("\n","\r"),"",$this->MenuTitle))
|
||||||
} else {
|
);
|
||||||
$tag ="<span class=\"del item\" title=\"" . _t('SiteTree.DELETEDPAGESHORT', 'Deleted') . "\">{$text}</span> <span class=\"badge deletedonlive\">". _t('SiteTree.DELETEDPAGESHORT', 'Deleted') . "</span>";
|
foreach($flags as $class => $title) {
|
||||||
}
|
$treeTitle .= sprintf(
|
||||||
} elseif($this->IsAddedToStage) {
|
"<span class=\"badge %s\">%s</span>",
|
||||||
$tag = "<span class=\"ins item\" title=\"" . _t('SiteTree.ADDEDTODRAFTSHORT', 'New') . "\">{$text}</span> <span class=\"badge addedtodraft\">". _t('SiteTree.ADDEDTODRAFTSHORT', 'New') . "</span>";
|
Convert::raw2xml($class),
|
||||||
} elseif($this->IsModifiedOnStage) {
|
Convert::raw2xml($title)
|
||||||
$tag = "<span title=\"" . _t('SiteTree.MODIFIEDONDRAFTSHORT', 'Modified') . "\" class=\"ins item\">{$text}</span> <span class=\"badge modified\">" . _t('SiteTree.MODIFIEDONDRAFTSHORT', 'Modified') . "</span>";
|
);
|
||||||
} else {
|
|
||||||
$tag = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $treeTitle;
|
||||||
return ($tag) ? "<span class=\"jstree-pageicon\"></span>". $tag : "<span class=\"jstree-pageicon\"></span>". $text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -17,6 +17,7 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
'SiteTreeTest_ClassD',
|
'SiteTreeTest_ClassD',
|
||||||
'SiteTreeTest_ClassCext',
|
'SiteTreeTest_ClassCext',
|
||||||
'SiteTreeTest_NotRoot',
|
'SiteTreeTest_NotRoot',
|
||||||
|
'SiteTreeTest_StageStatusInherit',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -866,7 +867,15 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$isDetected) $this->fail('Fails validation with $can_be_root=false');
|
if(!$isDetected) $this->fail('Fails validation with $can_be_root=false');
|
||||||
|
}
|
||||||
|
|
||||||
|
function testModifyStatusFlagByInheritance(){
|
||||||
|
$node = new SiteTreeTest_StageStatusInherit();
|
||||||
|
$treeTitle = $node->getTreeTitle();
|
||||||
|
$this->assertContains('InheritedTitle', $treeTitle);
|
||||||
|
$this->assertContains('inherited-class', $treeTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
@ -928,4 +937,12 @@ class SiteTreeTest_ClassCext extends SiteTreeTest_ClassC implements TestOnly {
|
|||||||
|
|
||||||
class SiteTreeTest_NotRoot extends Page implements TestOnly {
|
class SiteTreeTest_NotRoot extends Page implements TestOnly {
|
||||||
static $can_be_root = false;
|
static $can_be_root = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
class SiteTreeTest_StageStatusInherit extends SiteTree implements TestOnly {
|
||||||
|
function getStatusFlags(){
|
||||||
|
$flags = parent::getStatusFlags();
|
||||||
|
$flags['inherited-class'] = "InheritedTitle";
|
||||||
|
return $flags;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user