From 9e7eeece047081a95a9cc8f460bb557e8ecb647b Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 16 Sep 2007 16:02:26 +0000 Subject: [PATCH] bfojcapell: Added new field type MoreLessField? (merged from branches/gsoc) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@42108 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/MoreLessField.php | 60 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 forms/MoreLessField.php diff --git a/forms/MoreLessField.php b/forms/MoreLessField.php new file mode 100755 index 000000000..c1ad8670e --- /dev/null +++ b/forms/MoreLessField.php @@ -0,0 +1,60 @@ +moreText = $moreText; + $this->lessText = $lessText; + $this->charNum = $chars; + parent::__construct($name, $title, $value); + } + + function Field() { + $valforInput = $this->value ? Convert::raw2att($this->value) : ""; + $rawInput = Convert::html2raw($valforInput); + if ($this->charNum) $reducedVal = substr($rawInput,0,$this->charNum); + else $reducedVal = ereg_replace('([^\.]\.)[[:space:]].*','\\1',$rawInput); + if (strlen($reducedVal) < strlen($rawInput)) { + return <<$reducedVal + $this->moreText + + +
+HTML; + } else { + $this->dontEscape = true; + return parent::Field(); + } + } + + function setMoreText($moreText) { + $this->moreText = $moreText; + } + + function setLessText($lessText) { + $this->lessText = $lessText; + } + +} + +?> \ No newline at end of file