Texts.php
00001 <?php
00012 class Dsao_Filter_Texts implements Zend_Filter_Interface
00013 {
00020 public function filter($value)
00021 {
00022 return $this->filterOutput($value);
00023 }
00024
00036 public function filterInput($value, $maxLength = 0, $truncate = true)
00037 {
00038
00039 $valueFiltered = trim($value);
00040
00041
00042
00043
00044 if ($maxLength > 0
00045 && strlen($valueUtf8 = utf8_decode($valueFiltered)) > $maxLength)
00046 {
00047
00048 if ($truncate)
00049 {
00050 return utf8_encode(substr($valueUtf8, 0, $maxLength));
00051 }
00052
00053 return false;
00054 }
00055
00056 return $valueFiltered;
00057 }
00058
00067 public function filterOutput($value)
00068 {
00069
00070 $valueFiltered = nl2br(htmlspecialchars($value));
00071
00072 return $valueFiltered;
00073 }
00074 }