NobuNobu
nobun****@users*****
2006年 8月 23日 (水) 12:24:56 JST
Index: xoops2jp/html/kernel/XCube_Delegate.class.php diff -u xoops2jp/html/kernel/XCube_Delegate.class.php:1.1.2.12 xoops2jp/html/kernel/XCube_Delegate.class.php:1.1.2.13 --- xoops2jp/html/kernel/XCube_Delegate.class.php:1.1.2.12 Mon Aug 7 20:24:25 2006 +++ xoops2jp/html/kernel/XCube_Delegate.class.php Wed Aug 23 12:24:56 2006 @@ -1,6 +1,6 @@ <?php /** - * @version $Id: XCube_Delegate.class.php,v 1.1.2.12 2006/08/07 11:24:25 minahito Exp $ + * @version $Id: XCube_Delegate.class.php,v 1.1.2.13 2006/08/23 03:24:56 nobunobu Exp $ */ @@ -71,7 +71,8 @@ * This is register name for lazy registering. */ var $_mLazyRegisterName = null; - + + var $_mUniqueID; /** * Constructor. The parameter of the constructor is a variable argument * style to specify the sigunature of this delegate. If the argument is @@ -88,6 +89,7 @@ if (func_num_args() > 0) { $this->_setSignatures(func_get_args()); } + $this->_mUniqueID = md5(uniqid(rand(), true)); } /** @@ -287,6 +289,11 @@ } } } + + function getID() + { + return $this->_mUniqueID; + } } /** @@ -328,15 +335,13 @@ */ function register($name, &$delegate) { - if (!isset($this->_mDelegates[$name])) { - $this->_mDelegates[$name] =& $delegate; + if (!isset($this->_mDelegates[$name][$delegate->getID()])) { + $this->_mDelegates[$name][$delegate->getID()] =& $delegate; if (isset($this->_mCallbacks[$name]) && count($this->_mCallbacks[$name]) > 0) { foreach (array_keys($this->_mCallbacks[$name]) as $key) { $delegate->add($this->_mCallbacks[$name][$key], $this->_mCallbackParameters[$name][$key][0], $this->_mCallbackParameters[$name][$key][1]); } - unset($this->_mCallbacks[$name]); - unset($this->_mCallbackParameters[$name]); } return true; @@ -361,12 +366,12 @@ function add($name, $callback, $param3 = null, $param4 = null) { if (isset($this->_mDelegates[$name])) { - $this->_mDelegates[$name]->add($callback, $param3, $param4); - } - else { - $this->_mCallbacks[$name][] = $callback; - $this->_mCallbackParameters[$name][] = array('0' => $param3, '1' => $param4); + foreach(array_keys($this->_mDelegates[$name]) as $key) { + $this->_mDelegates[$name][$key]->add($callback, $param3, $param4); + } } + $this->_mCallbacks[$name][] = $callback; + $this->_mCallbackParameters[$name][] = array('0' => $param3, '1' => $param4); } /** @@ -380,18 +385,19 @@ function delete($name, $delcallback) { if (isset($this->_mDelegates[$name])) { - $this->_mDelegates[$name]->delete($delcallback); - } else { - if (isset($this->_mCallbacks[$name])) { - foreach(array_keys($this->_mCallbacks[$name]) as $key) { - $callback = $this->_mCallbacks[$name][$key]; - if (XCube_DelegateUtils::_compareCallback($callback, $delcallback)) { - unset($this->_mCallbacks[$name][$key]); - unset($this->_mCallbackParameters[$name][$key]); - } - } - } - } + foreach(array_keys($this->_mDelegates[$name]) as $key) { + $this->_mDelegates[$name][$key]->delete($delcallback); + } + } + if (isset($this->_mCallbacks[$name])) { + foreach(array_keys($this->_mCallbacks[$name]) as $key) { + $callback = $this->_mCallbacks[$name][$key]; + if (XCube_DelegateUtils::_compareCallback($callback, $delcallback)) { + unset($this->_mCallbacks[$name][$key]); + unset($this->_mCallbackParameters[$name][$key]); + } + } + } } /** @@ -404,13 +410,14 @@ function reset($name) { if (isset($this->_mDelegates[$name])) { - $this->_mDelegates[$name]->reset(); - } else { - if (isset($this->_mCallbacks[$name])) { - unset($this->_mCallbacks[$name]); - unset($this->_mCallbackParameters[$name]); - } - } + foreach(array_keys($this->_mDelegates[$name]) as $key) { + $this->_mDelegates[$name][$key]->reset(); + } + } + if (isset($this->_mCallbacks[$name])) { + unset($this->_mCallbacks[$name]); + unset($this->_mCallbackParameters[$name]); + } } @@ -458,7 +465,8 @@ if ($root->mDelegateManager != null) { $delegates = $root->mDelegateManager->getDelegates(); if (isset($delegates[$delegateName])) { - $delegate =& $delegates[$delegateName]; + $keys = array_keys($delegates[$delegateName]); + $delegate =& $delegates[$delegateName][$keys[0]]; } else { $delegate =& new XCube_Delegate; $root->mDelegateManager->register($delegateName, $delegate);