mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
MINOR SiteTreeURLSegmentField has new methods to aid in displaying URL prefix and secondary information text (fixes #6852)
This commit is contained in:
parent
7ffb5056a4
commit
21289128bb
@ -12,6 +12,14 @@
|
|||||||
*/
|
*/
|
||||||
class SiteTreeURLSegmentField extends TextField {
|
class SiteTreeURLSegmentField extends TextField {
|
||||||
|
|
||||||
|
protected $template = 'SiteTreeURLSegmentField';
|
||||||
|
|
||||||
|
/** @var String */
|
||||||
|
protected $helpText;
|
||||||
|
|
||||||
|
/** @var String */
|
||||||
|
protected $urlPrefix;
|
||||||
|
|
||||||
static $allowed_actions = array(
|
static $allowed_actions = array(
|
||||||
'suggest'
|
'suggest'
|
||||||
);
|
);
|
||||||
@ -39,8 +47,40 @@ class SiteTreeURLSegmentField extends TextField {
|
|||||||
$idField = $this->getForm()->dataFieldByName('ID');
|
$idField = $this->getForm()->dataFieldByName('ID');
|
||||||
return ($idField && $idField->Value()) ? DataObject::get_by_id('SiteTree', $idField->Value()) : singleton('SiteTree');
|
return ($idField && $idField->Value()) ? DataObject::get_by_id('SiteTree', $idField->Value()) : singleton('SiteTree');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string the secondary text to show
|
||||||
|
*/
|
||||||
|
function setHelpText($string){
|
||||||
|
$this->helpText = $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string the secondary text to show in the template
|
||||||
|
*/
|
||||||
|
function getHelpText(){
|
||||||
|
return $this->helpText;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param the url that prefixes the page url segment field
|
||||||
|
*/
|
||||||
|
function setURLPrefix($url){
|
||||||
|
$this->urlPrefix = $url;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the url prefixes the page url segment field to show in template
|
||||||
|
*/
|
||||||
|
function getURLPrefix(){
|
||||||
|
return $this->urlPrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function Type() {
|
function Type() {
|
||||||
return 'text sitetreeurlsegment';
|
return 'text sitetreeurlsegment';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -1830,8 +1830,12 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
(self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
|
(self::nested_urls() && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$url = (strlen($baseLink) > 36) ? "..." .substr($baseLink, -32) : $baseLink;
|
$url = (strlen($baseLink) > 36) ? "..." .substr($baseLink, -32) : $baseLink;
|
||||||
$urlHelper = sprintf("<span>%s</span>", $url);
|
$urlsegment = new SiteTreeURLSegmentField("URLSegment", $this->fieldLabel('URLSegment'));
|
||||||
|
$urlsegment->setURLPrefix($url);
|
||||||
|
$urlsegment->setHelpText(self::nested_urls() && count($this->Children()) ? $this->fieldLabel('LinkChangeNote'): false);
|
||||||
|
|
||||||
$fields = new FieldList(
|
$fields = new FieldList(
|
||||||
$rootTab = new TabSet("Root",
|
$rootTab = new TabSet("Root",
|
||||||
@ -1841,10 +1845,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
$htmlField = new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))
|
$htmlField = new HtmlEditorField("Content", _t('SiteTree.HTMLEDITORTITLE', "Content", PR_MEDIUM, 'HTML editor title'))
|
||||||
),
|
),
|
||||||
$tabMeta = new Tab('Metadata',
|
$tabMeta = new Tab('Metadata',
|
||||||
new SiteTreeURLSegmentField("URLSegment", $this->fieldLabel('URLSegment') . $urlHelper),
|
$urlsegment,
|
||||||
new LiteralField('LinkChangeNote', self::nested_urls() && count($this->Children()) ?
|
|
||||||
'<p>' . $this->fieldLabel('LinkChangeNote'). '</p>' : null
|
|
||||||
),
|
|
||||||
new HeaderField('MetaTagsHeader',$this->fieldLabel('MetaTagsHeader')),
|
new HeaderField('MetaTagsHeader',$this->fieldLabel('MetaTagsHeader')),
|
||||||
new TextField("MetaTitle", $this->fieldLabel('MetaTitle')),
|
new TextField("MetaTitle", $this->fieldLabel('MetaTitle')),
|
||||||
new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords'), 1),
|
new TextareaField("MetaKeywords", $this->fieldLabel('MetaKeywords'), 1),
|
||||||
@ -1881,6 +1882,7 @@ class SiteTree extends DataObject implements PermissionProvider,i18nEntityProvid
|
|||||||
return $fields;
|
return $fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns fields related to configuration aspects on this record, e.g. access control.
|
* Returns fields related to configuration aspects on this record, e.g. access control.
|
||||||
* See {@link getCMSFields()} for content-related fields.
|
* See {@link getCMSFields()} for content-related fields.
|
||||||
|
@ -430,7 +430,7 @@ $lang['en_US']['SiteTree']['TABMETA'] = 'Metadata';
|
|||||||
$lang['en_US']['SiteTree']['TOPLEVEL'] = 'Site Content (Top Level)';
|
$lang['en_US']['SiteTree']['TOPLEVEL'] = 'Site Content (Top Level)';
|
||||||
$lang['en_US']['SiteTree']['TOPLEVELCREATORGROUPS'] = 'Top level creators';
|
$lang['en_US']['SiteTree']['TOPLEVELCREATORGROUPS'] = 'Top level creators';
|
||||||
$lang['en_US']['SiteTree']['URLSegment'] = array(
|
$lang['en_US']['SiteTree']['URLSegment'] = array(
|
||||||
'URL Segment',
|
'URL',
|
||||||
PR_MEDIUM,
|
PR_MEDIUM,
|
||||||
'URL for this page'
|
'URL for this page'
|
||||||
);
|
);
|
||||||
|
4
templates/forms/SiteTreeURLSegmentField.ss
Normal file
4
templates/forms/SiteTreeURLSegmentField.ss
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<span>$URLPrefix</span> <input $AttributesHTML />
|
||||||
|
<% if HelpText %>
|
||||||
|
<p class="help">$HelpText</p>
|
||||||
|
<% end_if %>
|
Loading…
Reference in New Issue
Block a user