1: <?php
2:
3: if (!defined('XOOPS_ROOT_PATH')) exit();
4:
5: class LegacyRenderModuletplObject extends XoopsSimpleObject
6: {
7: function LegacyRenderModuletplObject()
8: {
9: static $initVars;
10: if (isset($initVars)) {
11: $this->mVars = $initVars;
12: return;
13: }
14: $this->initVar('mid', XOBJ_DTYPE_INT, '', true);
15: $this->initVar('name', XOBJ_DTYPE_STRING, '', true, 150);
16: $this->initVar('dirname', XOBJ_DTYPE_STRING, '', true, 150);
17: $this->initVar('count', XOBJ_DTYPE_INT, 0, true);
18: $initVars=$this->mVars;
19: }
20: }
21:
22: class LegacyRenderTplsetObject extends XoopsSimpleObject
23: {
24: var $mModuleTemplates = array();
25:
26: function LegacyRenderTplsetObject()
27: {
28: static $initVars;
29: if (isset($initVars)) {
30: $this->mVars = $initVars;
31: return;
32: }
33: $this->initVar('tplset_id', XOBJ_DTYPE_INT, '', true);
34: $this->initVar('tplset_name', XOBJ_DTYPE_STRING, '', true, 50);
35: $this->initVar('tplset_desc', XOBJ_DTYPE_STRING, '', true, 255);
36: $this->initVar('tplset_credits', XOBJ_DTYPE_TEXT, '', true);
37: $this->initVar('tplset_created', XOBJ_DTYPE_INT, time(), true);
38: $initVars=$this->mVars;
39: }
40:
41: function loadModuletpl()
42: {
43:
44:
45:
46: $moduleHandler =& xoops_gethandler('module');
47: $modules =& $moduleHandler->getObjects();
48:
49: $tplfileHandler =& xoops_getmodulehandler('tplfile', 'legacyRender');
50:
51: foreach ($modules as $module) {
52: $modtpl =new LegacyRenderModuletplObject();
53:
54: $modtpl->set('mid', $module->get('mid'));
55: $modtpl->set('dirname', $module->get('dirname'));
56: $modtpl->set('name', $module->get('name'));
57:
58: $criteria = new CriteriaCompo();
59: $criteria->add(new Criteria('tpl_module', $module->get('dirname')));
60: $criteria->add(new Criteria('tpl_tplset', $this->get('tplset_name')));
61:
62: $count = $tplfileHandler->getCount($criteria);
63: $modtpl->set('count', $count);
64:
65: $this->mModuleTemplates[] =& $modtpl;
66: unset($modtpl);
67: }
68: }
69: }
70:
71: class LegacyRenderTplsetHandler extends XoopsObjectGenericHandler
72: {
73: var $mTable = "tplset";
74: var $mPrimary = "tplset_id";
75: var $mClass = "LegacyRenderTplsetObject";
76:
77: function insertClone($original, $clone)
78: {
79: if (!$this->insert($clone)) {
80: return false;
81: }
82:
83:
84:
85:
86: $handler =& xoops_getmodulehandler('tplfile', 'legacyRender');
87:
88: $files =& $handler->getObjects(new Criteria('tpl_tplset', $original->get('tplset_name')));
89: foreach ($files as $file) {
90: $cloneFile =& $file->createClone($clone->get('tplset_name'));
91: $handler->insert($cloneFile);
92: }
93:
94: return true;
95: }
96:
97: function delete(&$obj, $force)
98: {
99: $handler =& xoops_getmodulehandler('tplfile', 'legacyRender');
100: $handler->deleteAll(new Criteria('tpl_tplset', $obj->get('tplset_name')));
101:
102: return parent::delete($obj, $force);
103: }
104: }
105:
106: ?>
107: