Minahito
minah****@users*****
2006年 9月 10日 (日) 14:55:46 JST
Index: xoops2jp/html/kernel/configoption.php diff -u xoops2jp/html/kernel/configoption.php:1.2.8.2 xoops2jp/html/kernel/configoption.php:1.2.8.3 --- xoops2jp/html/kernel/configoption.php:1.2.8.2 Tue May 16 22:25:07 2006 +++ xoops2jp/html/kernel/configoption.php Sun Sep 10 14:55:46 2006 @@ -1,5 +1,5 @@ <?php -// $Id: configoption.php,v 1.2.8.2 2006/05/16 13:25:07 nobunobu Exp $ +// $Id: configoption.php,v 1.2.8.3 2006/09/10 05:55:46 minahito Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -79,6 +79,22 @@ { return defined($this->get('confop_name')) ? constant($this->get('confop_name')) : $this->get('confop_name'); } + /** + * Compare with contents of $config object. If it's equal, return true. + * This member function doesn't use 'conf_id' & 'conf_order' to compare. + * + * @param XoopsConfigItem $config + * @return bool + */ + function isEqual(&$option) + { + $flag = true; + + $flag &= ($this->get('confop_name') == $option->get('confop_name')); + $flag &= ($this->get('confop_value') == $option->get('confop_value')); + + return $flag; + } } /** Index: xoops2jp/html/kernel/configitem.php diff -u xoops2jp/html/kernel/configitem.php:1.2.8.6 xoops2jp/html/kernel/configitem.php:1.2.8.7 --- xoops2jp/html/kernel/configitem.php:1.2.8.6 Fri May 19 19:23:56 2006 +++ xoops2jp/html/kernel/configitem.php Sun Sep 10 14:55:46 2006 @@ -1,5 +1,5 @@ <?php -// $Id: configitem.php,v 1.2.8.6 2006/05/19 10:23:56 minahito Exp $ +// $Id: configitem.php,v 1.2.8.7 2006/09/10 05:55:46 minahito Exp $ // ------------------------------------------------------------------------ // // XOOPS - PHP Content Management System // // Copyright (c) 2000 XOOPS.org // @@ -196,6 +196,91 @@ { return $this->_confOptions; } + + /** + * Compare with contents of $config object. If it's equal, return true. + * This member function doesn't use 'conf_id' & 'conf_value' & 'conf_order' to compare. + * + * @param XoopsConfigItem $config + * @return bool + */ + function isEqual(&$config) + { + $flag = true; + + $flag &= ($this->get('conf_modid') == $config->get('conf_modid')); + $flag &= ($this->get('conf_catid') == $config->get('conf_catid')); + $flag &= ($this->get('conf_name') == $config->get('conf_name')); + $flag &= ($this->get('conf_title') == $config->get('conf_title')); + $flag &= ($this->get('conf_desc') == $config->get('conf_desc')); + $flag &= ($this->get('conf_formtype') == $config->get('conf_formtype')); + $flag &= ($this->get('conf_valuetype') == $config->get('conf_valuetype')); + + // + // Compare options + // + $thisOptions =& $this->getOptionItems(); + $hisOptions =& $config->getConfOptions(); + + if (count($thisOptions) == count($hisOptions)) { + foreach (array_keys($thisOptions) as $t_thiskey) { + $t_okFlag = false; + foreach (array_keys($hisOptions) as $t_hiskey) { + if ($thisOptions[$t_thiskey]->isEqual($hisOptions[$t_hiskey])) { + $t_okFlag = true; + } + } + + if (!$t_okFlag) { + $flag = false; + break; + } + } + } + else { + $flag = false; + } + + return $flag; + } + + /** + * Set values by config info which is array from xoops_version.php. + * + * @var int $modid ID of the module + * @var array $configInfo + * @var int $order conf_order + */ + function loadFromConfigInfo($mid, &$configInfo, $order = null) + { + $this->set('conf_modid', $mid); + $this->set('conf_catid', 0); + $this->set('conf_name', $configInfo['name']); + $this->set('conf_title', $configInfo['title'], true); + if (isset($configInfo['description'])) { + $this->set('conf_desc', $configInfo['description'], true); + } + $this->set('conf_formtype', $configInfo['formtype'], true); + $this->set('conf_valuetype', $configInfo['valuetype'], true); + $this->setConfValueForInput($configInfo['default'], true); + if (isset($configInfo['order'])) { + $this->set('conf_order', $configInfo['order']); + } + else { + $this->set('conf_order', $order); + } + + if (isset($configInfo['options']) && is_array($configInfo['options'])) { + $configHandler =& xoops_gethandler('config'); + foreach ($configInfo['options'] as $key => $value) { + $configOption =& $configHandler->createConfigOption(); + $configOption->setVar('confop_name', $key, true); + $configOption->setVar('confop_value', $value, true); + $this->setConfOptions($configOption); + unset($configOption); + } + } + } }