1: <?php
2: /**
3: *
4: * @package XCube
5: * @version $Id: XCube_RenderSystem.class.php,v 1.3 2008/10/12 04:30:27 minahito Exp $
6: * @copyright Copyright 2005-2007 XOOPS Cube Project <https://github.com/xoopscube/legacy>
7: * @license https://github.com/xoopscube/legacy/blob/master/docs/bsd_licenses.txt Modified BSD license
8: *
9: */
10:
11: define("XCUBE_RENDER_MODE_NORMAL",1);
12: define("XCUBE_RENDER_MODE_DIALOG",2);
13:
14: /**
15: * We had to define classes that are XCube_RenderTargetBuffer, XCube_RenderTargetTheme,
16: * XCube_RenderTargetBlock and XCube_RenderTargetMain. And, a render-system had
17: * to define render-sub-system that renders to these render-target. However, this
18: * style gives a heavy load to our XOOPS Cube system that is a PHP application.
19: *
20: * We prepare the following constants for the flag of a render-target instead of
21: * the group of many classes.
22: */
23: define("XCUBE_RENDER_TARGET_TYPE_BUFFER", null);
24: define("XCUBE_RENDER_TARGET_TYPE_THEME", 'theme');
25: define("XCUBE_RENDER_TARGET_TYPE_BLOCK", 'block');
26: define("XCUBE_RENDER_TARGET_TYPE_MAIN", 'main');
27:
28: /**
29: * This is a target whom a render-system renders. This has a buffer and receives
30: * a result of a render-system to the buffer. A developer can control rendering
31: * with using this class.
32: */
33: class XCube_RenderTarget
34: {
35: var $mName = null;
36:
37: var $mRenderBuffer = null;
38:
39: var $mModuleName = null;
40:
41: var $mTemplateName = null;
42:
43: var $mAttributes = array();
44:
45: /**
46: * @deprecated
47: */
48: var $mType = XCUBE_RENDER_TARGET_TYPE_BUFFER;
49:
50: var $mCacheTime = null;
51:
52: function XCube_RenderTarget()
53: {
54: }
55:
56: function setName($name)
57: {
58: $this->mName = $name;
59: }
60:
61: function getName()
62: {
63: return $this->mName;
64: }
65:
66: function setTemplateName($name)
67: {
68: $this->mTemplateName = $name;
69: }
70:
71: function getTemplateName()
72: {
73: return $this->mTemplateName;
74: }
75:
76: function setAttribute($key,$value)
77: {
78: $this->mAttributes[$key] = $value;
79: }
80:
81: function setAttributes($attr)
82: {
83: $this->mAttributes = $attr;
84: }
85:
86: function getAttribute($key)
87: {
88: return isset($this->mAttributes[$key]) ? $this->mAttributes[$key] : null;
89: }
90:
91: function getAttributes()
92: {
93: return $this->mAttributes;
94: }
95:
96: /**
97: * Set render-target type.
98: * @param $type int Use constants that are defined by us.
99: * @deprecated
100: */
101: function setType($type)
102: {
103: $this->mType = $type;
104: $this->setAttribute('legacy_buffertype', $type);
105: }
106:
107: /**
108: * Return render-target type.
109: * @return int
110: * @deprecated
111: */
112: function getType()
113: {
114: return $this->getAttribute('legacy_buffertype', $type);
115: //return $this->mType;
116: }
117:
118: function setResult(&$result)
119: {
120: $this->mRenderBuffer = $result;
121: }
122:
123: function getResult()
124: {
125: return $this->mRenderBuffer;
126: }
127:
128: /**
129: * Reset a template name and attributes in own properties.
130: */
131: function reset()
132: {
133: $this->setTemplateName(null);
134: unset($this->mAttributes);
135: $this->mAttributes = array();
136: $this->mRenderBuffer = null;
137: }
138: }
139:
140: /**
141: * This system is in charge of rendering and contents cache management.
142: * For cache management, this system must talk with a business logic before business logic executes.
143: * This class has a bad design so that the template engine is strongly tied to cache management.
144: * We must divide this class into renderer and cache management.
145: */
146: class XCube_RenderSystem
147: {
148: /**
149: @access private
150: */
151: var $mController;
152:
153: var $mRenderMode = XCUBE_RENDER_MODE_NORMAL;
154:
155: function XCube_RenderSystem()
156: {
157: }
158:
159: /**
160: * Prepare.
161: *
162: * @param XCube_Controller $controller
163: */
164: function prepare(&$controller)
165: {
166: $this->mController =& $controller;
167: }
168:
169: /**
170: * Create an object of the render-target, and return it.
171: *
172: * @return XCube_RenderTarget
173: */
174: function &createRenderTarget()
175: {
176: $renderTarget = new XCube_RenderTarget();
177: return $renderTarget;
178: }
179:
180: /**
181: * Render to $target.
182: *
183: * @param XCube_RenderTarget $target
184: */
185: function render(&$target)
186: {
187: }
188: }
189:
190: ?>