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