From a114bb550977ff3f2efa8eac4b9649fee62b7595 Mon Sep 17 00:00:00 2001 From: Nathan Glasl Date: Mon, 20 Apr 2015 10:28:44 +1000 Subject: [PATCH] Cleaning up a class definition. --- code/dataobjects/MediaAttribute.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/dataobjects/MediaAttribute.php b/code/dataobjects/MediaAttribute.php index 94165d6..4da13e7 100644 --- a/code/dataobjects/MediaAttribute.php +++ b/code/dataobjects/MediaAttribute.php @@ -223,7 +223,13 @@ public function getTemplateClass() { public function forTemplate() { - return ltrim(preg_replace('/[A-Z]+[^A-Z]/', ' $0', $this->Title)) . ": {$this->Content}"; + // Add spaces between words, other characters and numbers. + + return ltrim(preg_replace(array( + '/([A-Z][a-z]+)/', + '/([A-Z]{2,})/', + '/([_.0-9]+)/' + ), ' $0', $this->Title)) . ": {$this->Content}"; } }