26 #require_once 'Zend/Filter.php'; 31 #require_once 'Zend/Loader/PluginLoader.php'; 82 $temp[
'target'] = array_shift(
$options);
86 $temp[
'rules'] = array_shift(
$options);
90 $temp[
'throwTargetExceptionsOn'] = array_shift(
$options);
94 $temp[
'targetReplacementIdentifier'] = array_shift(
$options);
111 $this->_pluginLoader =
new Zend_Loader_PluginLoader(array(
'Zend_Filter_' =>
'Zend/Filter/'), __CLASS__);
125 $this->_pluginLoader = $pluginLoader;
153 if (array_key_exists(
'filterPrefixPath',
$options)) {
154 if (!is_scalar(
$options[
'filterPrefixPath'])) {
161 if (array_key_exists(
'throwTargetExceptionsOn',
$options)) {
165 if (array_key_exists(
'targetReplacementIdentifier',
$options)) {
169 if (array_key_exists(
'target',
$options)) {
173 if (array_key_exists(
'rules',
$options)) {
202 $this->_throwTargetExceptionsOn = ($throwTargetExceptionsOn ==
true) ?
true :
false;
224 if ($targetReplacementIdentifier) {
225 $this->_targetReplacementIdentifier = (string) $targetReplacementIdentifier;
250 $this->_target = (string)
$target;
308 $keys = array_keys(
$rules);
309 foreach ($keys as $spec) {
310 if ($spec[0] ==
':') {
331 if (
null !== $spec) {
333 if (isset($this->_rules[$spec])) {
334 return $this->_rules[$spec];
352 if (isset($this->_rules[$spec]) && is_array($this->_rules[$spec])) {
353 if (isset($this->_rules[$spec][
$index])) {
354 return $this->_rules[$spec][
$index];
367 $this->_rules = array();
382 $this->_rules[$spec] = array();
396 if (!isset($this->_rules[$spec])) {
397 $this->_rules[$spec] = array();
400 if (!is_array($ruleSet)) {
401 $ruleSet = array($ruleSet);
404 if (is_string($this->_rules[$spec])) {
405 $temp = $this->_rules[$spec];
406 $this->_rules[$spec] = array();
407 $this->_rules[$spec][] = $temp;
410 foreach ($ruleSet as
$rule) {
411 $this->_rules[$spec][] = $this->
_getRule($rule);
445 $this->_rules[
$name] =& $reference;
458 foreach ( (array)
$source as $sourceName => $sourceValue) {
459 $source[ltrim($sourceName,
':')] = $sourceValue;
462 $pregQuotedTargetReplacementIdentifier = preg_quote($this->_targetReplacementIdentifier,
'#');
463 $processedParts = array();
465 foreach ($this->_rules as $ruleName => $ruleValue) {
466 if (isset(
$source[$ruleName])) {
467 if (is_string($ruleValue)) {
469 $processedParts[
'#'.$pregQuotedTargetReplacementIdentifier.$ruleName.
'#'] = str_replace(
'\\',
'\\\\',
$source[$ruleName]);
470 }
elseif (is_array($ruleValue)) {
471 $processedPart =
$source[$ruleName];
472 foreach ($ruleValue as $ruleFilter) {
473 $processedPart = $ruleFilter->filter($processedPart);
475 $processedParts[
'#'.$pregQuotedTargetReplacementIdentifier.$ruleName.
'#'] = str_replace(
'\\',
'\\\\', $processedPart);
477 }
elseif (is_string($ruleValue)) {
478 $processedParts[
'#'.$pregQuotedTargetReplacementIdentifier.$ruleName.
'#'] = str_replace(
'\\',
'\\\\', $ruleValue);
483 $inflectedTarget = preg_replace(array_keys($processedParts), array_values($processedParts), $this->_target);
485 if ($this->_throwTargetExceptionsOn && (preg_match(
'#(?='.$pregQuotedTargetReplacementIdentifier.
'[A-Za-z]{1})#', $inflectedTarget) ==
true)) {
486 #require_once 'Zend/Filter/Exception.php'; 487 throw new Zend_Filter_Exception(
'A replacement identifier ' . $this->_targetReplacementIdentifier .
' was found inside the inflected target, perhaps a rule was not satisfied with a target source? Unsatisfied inflected target: ' . $inflectedTarget);
490 return $inflectedTarget;
501 return ltrim((
string) $spec,
':&');
521 #require_once 'Zend/Filter/Exception.php'; getTargetReplacementIdentifier()
elseif(isset( $params[ 'redirect_parent']))
setConfig(Zend_Config $config)
$_throwTargetExceptionsOn
setStaticRuleReference($name, &$reference)
addFilterPrefixPath($prefix, $path)
setFilterRule($spec, $ruleSet)
isThrowTargetExceptionsOn()
setStaticRule($name, $value)
$_targetReplacementIdentifier
addFilterRule($spec, $ruleSet)
__construct($options=null)
setPluginLoader(Zend_Loader_PluginLoader_Interface $pluginLoader)
setTargetReference(&$target)
setTargetReplacementIdentifier($targetReplacementIdentifier)
setThrowTargetExceptionsOn($throwTargetExceptionsOn)
if(!isset($_GET['name'])) $name