mirror of
https://github.com/processwire/processwire.git
synced 2025-08-15 11:14:12 +02:00
Minor improvements in core MarkupFieldtype class
This commit is contained in:
@@ -58,6 +58,16 @@ class MarkupFieldtype extends WireData implements Module {
|
|||||||
*/
|
*/
|
||||||
protected $renderIsUseless = false;
|
protected $renderIsUseless = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Properties that are potentially linkable to source page in markup
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected $linkableProperties = array(
|
||||||
|
'name', 'url', 'httpUrl', 'path', 'title',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the MarkupFieldtype
|
* Construct the MarkupFieldtype
|
||||||
*
|
*
|
||||||
@@ -108,8 +118,8 @@ class MarkupFieldtype extends WireData implements Module {
|
|||||||
foreach($value as $page) {
|
foreach($value as $page) {
|
||||||
$v = $page->getFormatted($property);
|
$v = $page->getFormatted($property);
|
||||||
$v = $field->type->markupValue($page, $field, $v);
|
$v = $field->type->markupValue($page, $field, $v);
|
||||||
if($page->viewable()) {
|
if($this->isLinkablePageProperty($page, $property)) {
|
||||||
$a[] = "<a href='$page->url'>$v</a>";
|
$a[] = "<a href='$page->url'>$property: $v</a>";
|
||||||
} else {
|
} else {
|
||||||
$a[] = $v;
|
$a[] = $v;
|
||||||
}
|
}
|
||||||
@@ -356,6 +366,20 @@ class MarkupFieldtype extends WireData implements Module {
|
|||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is the given page property/field name one that should be linked to the source page in output?
|
||||||
|
*
|
||||||
|
* @param Page $page
|
||||||
|
* @param $property
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function isLinkablePageProperty(Page $page, $property) {
|
||||||
|
if(!in_array($property, $this->linkableProperties)) return false;
|
||||||
|
if(!$page->viewable($property)) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The string value of a MarkupFieldtype is always the fully rendered field
|
* The string value of a MarkupFieldtype is always the fully rendered field
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user