同じフィルタを複数回登録できるpatch

思いついたのでpatch。家に帰ってからメーリングリストに飛ばします。
maple.iniでセクションを[フィルタ名:エイリアス名]とすることで登録できます。
エイリアス名を省略した場合は[フィルタ名:フィルタ名]とみなします。

[Hoge:Hoge1]
key1 = val1
[Hoge:Hoge2]
key1 = val1
key2 = val2


FilterChain.class.php

diff -rc org/maple/core/FilterChain.class.php new/maple/core/FilterChain.class.php
*** org/maple/core/FilterChain.class.php	Tue Sep 20 21:30:40 2005
--- new/maple/core/FilterChain.class.php	Thu Dec  1 09:07:34 2005
***************
*** 67,83 ****
  	 * FilterChainの最後にFilterを追加
  	 *
  	 * @param	string	$name	Filterのクラス名
  	 * @access	public
  	 * @since	3.0.0
  	 **/
! 	function add($name) {
  		$log =& LogFactory::getLog();
  
  		//
  		// Filterの実行が既に始まっていたらエラー(実行後の追加はエラー)
  		//
  		if ($this->_index > -1) {
! 			$log->error("実行後にFilterが追加されています(${name})", "FilterChain#add");
  			return false;
  		}
  
--- 67,88 ----
  	 * FilterChainの最後にFilterを追加
  	 *
  	 * @param	string	$name	Filterのクラス名
+ 	 * @param	string	$alias	Filterのalias名
  	 * @access	public
  	 * @since	3.0.0
  	 **/
! 	function add($name, $alias = '') {
  		$log =& LogFactory::getLog();
  
+ 		if (empty($alias)) {
+ 			$alias = $name;
+ 		}
+ 
  		//
  		// Filterの実行が既に始まっていたらエラー(実行後の追加はエラー)
  		//
  		if ($this->_index > -1) {
! 			$log->error("実行後にFilterが追加されています(${name},${alias})", "FilterChain#add");
  			return false;
  		}
  
***************
*** 85,91 ****
  		// Filterのクラス名が不正だったらエラー
  		//
  		if (!preg_match("/^[0-9a-zA-Z_]+$/", $name)) {
! 			$log->error("不正なFilterが指定されています(${name})", "FilterChain#add");
  			return false;
  		}
  
--- 90,96 ----
  		// Filterのクラス名が不正だったらエラー
  		//
  		if (!preg_match("/^[0-9a-zA-Z_]+$/", $name)) {
! 			$log->error("不正なFilterが指定されています(${name},${alias})", "FilterChain#add");
  			return false;
  		}
  
***************
*** 96,110 ****
  		$filename  = FILTER_DIR . "/${className}.class.php";
  
  		if (!@file_exists($filename)) {
! 			$log->error("存在していないFilterが指定されています(${name})", "FilterChain#add");
  			return false;
  		}
  
  		//
  		// 既に同名のFilterが追加されていたら何もしない
  		//
! 		if (isset($this->_list[$name]) && is_object($this->_list[$name])) {
! 			$log->info("このFilterは既に登録されています(${name})", "FilterChain#add");
  			return true;
  		}
  
--- 101,115 ----
  		$filename  = FILTER_DIR . "/${className}.class.php";
  
  		if (!@file_exists($filename)) {
! 			$log->error("存在していないFilterが指定されています(${name},${alias})", "FilterChain#add");
  			return false;
  		}
  
  		//
  		// 既に同名のFilterが追加されていたら何もしない
  		//
! 		if (isset($this->_list[$alias]) && is_object($this->_list[$alias])) {
! 			$log->info("このFilterは既に登録されています(${name},${alias})", "FilterChain#add");
  			return true;
  		}
  
***************
*** 116,127 ****
  		$filter =& new $className();
  
  		if (!is_object($filter)) {
! 			$log->error("Filterの生成に失敗しました(${name})", "FilterChain#add");
  			return false;
  		}
  
! 		$this->_list[$name] =& $filter;
! 		$this->_position[]  =  $name;
  
  		return true;
  	}
--- 121,132 ----
  		$filter =& new $className();
  
  		if (!is_object($filter)) {
! 			$log->error("Filterの生成に失敗しました(${name},${alias})", "FilterChain#add");
  			return false;
  		}
  
! 		$this->_list[$alias] =& $filter;
! 		$this->_position[]  = $alias;
  
  		return true;
  	}
***************
*** 222,234 ****
  		$log =& LogFactory::getLog();
  
  		foreach ($config->getConfig() as $section => $value) {
  			$filterConfig =& $config->getSectionConfig($section);
! 			if (!$this->add($section)) {
  				$log->error("FilterChainへの追加に失敗しました(${section})", "FilterChain#build");
  				return false;
  			}
  			if (is_array($filterConfig) && (count($filterConfig) > 0)) {
! 				$this->setAttributes($section, $filterConfig);
  			}
  		}
  
--- 227,241 ----
  		$log =& LogFactory::getLog();
  
  		foreach ($config->getConfig() as $section => $value) {
+ 			list($realsection, $aliassection) = explode(':', $section);
+ 			$aliassection = ($aliassection)? $aliassection: $realsection;
  			$filterConfig =& $config->getSectionConfig($section);
! 			if (!$this->add($realsection, $aliassection)) {
  				$log->error("FilterChainへの追加に失敗しました(${section})", "FilterChain#build");
  				return false;
  			}
  			if (is_array($filterConfig) && (count($filterConfig) > 0)) {
! 				$this->setAttributes($aliassection, $filterConfig);
  			}
  		}