Minahito
minah****@users*****
2006年 1月 14日 (土) 02:33:40 JST
Index: xoops2jp/html/modules/legacyRender/class/tplset.php diff -u xoops2jp/html/modules/legacyRender/class/tplset.php:1.1.2.1 xoops2jp/html/modules/legacyRender/class/tplset.php:1.1.2.2 --- xoops2jp/html/modules/legacyRender/class/tplset.php:1.1.2.1 Thu Jan 12 20:21:32 2006 +++ xoops2jp/html/modules/legacyRender/class/tplset.php Sat Jan 14 02:33:40 2006 @@ -5,9 +5,10 @@ function LegacyRenderTplsetObject() { $this->initVar('tplset_id', XOBJ_DTYPE_INT, '', true); - $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 255); - $this->initVar('desc', XOBJ_DTYPE_STRING, '', false, 255); - $this->initVar('lock', XOBJ_DTYPE_BOOL, '0', true); + $this->initVar('tplset_name', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('tplset_desc', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('tplset_credits', XOBJ_DTYPE_TEXT, '', true); + $this->initVar('tplset_created', XOBJ_DTYPE_INT, time(), true); } } @@ -16,6 +17,26 @@ var $mTable = "tplset"; var $mPrimary = "tplset_id"; var $mClass = "LegacyRenderTplsetObject"; + + function insertClone($original, $clone) + { + if (!$this->insert($clone)) { + return false; + } + + // + // fetch all tplfile object and do cloning. + // + $handler =& xoops_getmodulehandler('tplfile'); + + $files =& $handler->getObjects(new Criteria('tpl_tplset', $original->get('tplset_name'))); + foreach ($files as $file) { + $cloneFile =& $file->createClone($clone->get('tplset_name')); + $handler->insert($cloneFile); + } + + return true; ///< TODO + } } ?> Index: xoops2jp/html/modules/legacyRender/class/tplfile.php diff -u xoops2jp/html/modules/legacyRender/class/tplfile.php:1.1.2.2 xoops2jp/html/modules/legacyRender/class/tplfile.php:1.1.2.3 --- xoops2jp/html/modules/legacyRender/class/tplfile.php:1.1.2.2 Fri Jan 13 00:12:06 2006 +++ xoops2jp/html/modules/legacyRender/class/tplfile.php Sat Jan 14 02:33:40 2006 @@ -2,24 +2,86 @@ class LegacyRenderTplfileObject extends XoopsSimpleObject { + /** + * @access public + */ + var $Source = null; + function LegacyRenderTplfileObject() { - $this->initVar('tplfile_id', XOBJ_DTYPE_INT, '', true); - $this->initVar('tplset_id', XOBJ_DTYPE_INT, '0', true); - $this->initVar('ref_id', XOBJ_DTYPE_INT, '0', true); - $this->initVar('dirname', XOBJ_DTYPE_STRING, '', true, 25); - $this->initVar('filename', XOBJ_DTYPE_STRING, '', true, 255); - $this->initVar('enable_cache', XOBJ_DTYPE_BOOL, '1', true); - $this->initVar('tpl_type', XOBJ_DTYPE_INT, '0', true); - $this->initVar('source', XOBJ_DTYPE_TEXT, '', true); + $this->initVar('tpl_id', XOBJ_DTYPE_INT, '', true); + $this->initVar('tpl_refid', XOBJ_DTYPE_INT, '0', true); + $this->initVar('tpl_module', XOBJ_DTYPE_STRING, '', true, 25); + $this->initVar('tpl_tplset', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('tpl_file', XOBJ_DTYPE_STRING, '', true, 50); + $this->initVar('tpl_desc', XOBJ_DTYPE_STRING, '', true, 255); + $this->initVar('tpl_lastmodified', XOBJ_DTYPE_INT, '0', true); + $this->initVar('tpl_lastimported', XOBJ_DTYPE_INT, '0', true); + $this->initVar('tpl_type', XOBJ_DTYPE_STRING, '', true, 20); + } + + function loadSource() + { + if (!is_object($this->Source)) { + $handler =& xoops_getmodulehandler('tplsource'); + $this->Source =& $handler->get($this->get('tpl_id')); + if (!is_object($this->Source)) { + $this->Source =& $handler->create(); + } + } + } + + function &createClone($name) + { + $this->loadSource(); + + $obj =& new LegacyRenderTplfileObject(); + + $obj->set('tpl_refid', $this->get('tpl_refid')); + $obj->set('tpl_module', $this->get('tpl_module')); + + $obj->set('tpl_tplset', $name); + + $obj->set('tpl_file', $this->get('tpl_file')); + $obj->set('tpl_desc', $this->get('tpl_desc')); + $obj->set('tpl_lastmodified', $this->get('tpl_lastmodified')); + $obj->set('tpl_lastimported', $this->get('tpl_lastimported')); + $obj->set('tpl_type', $this->get('tpl_type')); + + $handler =& xoops_getmodulehandler('tplsource'); + $obj->Source =& $handler->create(); + + $obj->Source->set('tpl_source', $this->Source->get('tpl_source')); + + return $obj; } } class LegacyRenderTplfileHandler extends XoopsObjectGenericHandler { var $mTable = "tplfile"; - var $mPrimary = "tplfile_id"; + var $mPrimary = "tpl_id"; var $mClass = "LegacyRenderTplfileObject"; + + function insert(&$obj, $force = false) + { + if (!parent::insert($obj, $force)) { + return false; + } + + if (!is_object($obj->Source)) { + return true; + } + else { + $handler =& xoops_getmodulehandler('tplsource'); + + if ($obj->Source->isNew()) { + $obj->Source->set('tpl_id', $obj->get('tpl_id')); + } + + return $handler->insert($obj->Source, $force); + } + } } ?> Index: xoops2jp/html/modules/legacyRender/class/tplsource.php diff -u /dev/null xoops2jp/html/modules/legacyRender/class/tplsource.php:1.1.2.1 --- /dev/null Sat Jan 14 02:33:40 2006 +++ xoops2jp/html/modules/legacyRender/class/tplsource.php Sat Jan 14 02:33:40 2006 @@ -0,0 +1,19 @@ +<?php + +class LegacyRenderTplsourceObject extends XoopsSimpleObject +{ + function LegacyRenderTplsourceObject() + { + $this->initVar('tpl_id', XOBJ_DTYPE_INT, '0', true); + $this->initVar('tpl_source', XOBJ_DTYPE_TEXT, '', true); + } +} + +class LegacyRenderTplsourceHandler extends XoopsObjectGenericHandler +{ + var $mTable = "tplsource"; + var $mPrimary = "tpl_id"; + var $mClass = "LegacyRenderTplsourceObject"; +} + +?>