function getValue() { $suffix = ''; if ($this->isConstant()) { $value = $this->base->getValue(); switch (count($this->parameters)) { case 1: return lmb_substr($value, 0, $this->parameters[0]->getValue()); break; case 2: return lmb_substr($value, $this->parameters[1]->getValue(), $this->parameters[0]->getValue()); break; case 3: $suffix = $this->_getSuffix($value, $this->parameters[0]->getValue(), $this->parameters[1]->getValue(), $this->parameters[2]->getValue()); return lmb_substr($value, $this->parameters[1]->getValue(), $this->parameters[0]->getValue()) . $suffix; break; case 4: $limit = $this->parameters[0]->getValue(); $offset = $this->parameters[1]->getValue(); $word_wrap = $this->parameters[3]->getValue(); $suffix = $this->_getSuffix($value, $limit, $offset, $this->parameters[2]->getValue()); if (strtoupper(substr($word_wrap, 0, 1)) != 'N') { if (lmb_preg_match('~^(.{0,' . $limit . '}(?U)\\w*)\\b~ism', lmb_substr($value, $offset), $match)) { return $match[1] . $suffix; } else { return ''; } } else { return lmb_substr($value, $offset, $limit) . $suffix; } break; default: throw new WactException('Wrong number of filter parameters(1..4)'); } } else { $this->raiseUnresolvedBindingError(); } }
function _makeGap($gap_pos, $text_chunk) { $result = ''; $chunk_len = lmb_strlen($text_chunk); if ($gap_pos == 'middle') { if ($chunk_len > 2 * $this->radius) { $result = lmb_substr($text_chunk, 0, $this->radius) . $this->gaps_pattern . lmb_substr($text_chunk, -1 * $this->radius, $this->radius); } else { $result = $text_chunk; } } elseif ($gap_pos == 'left') { if ($chunk_len > $this->radius) { $result = $this->gaps_pattern . lmb_substr($text_chunk, -1 * $this->radius, $this->radius); } else { $result = $text_chunk; } } elseif ($gap_pos == 'right') { if ($chunk_len > $this->radius) { $result = lmb_substr($text_chunk, 0, $this->radius) . $this->gaps_pattern; } else { $result = $text_chunk; } } return $result; }