1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22:
23: namespace picon;
24:
25: 26: 27: 28: 29: 30:
31: class WebPage extends MarkupContainer implements RequestablePage
32: {
33: private $autoIndex = 0;
34:
35: public function __construct()
36: {
37: parent::__construct(PageMap::getNextPageId());
38: }
39:
40: protected function onRender()
41: {
42: $pageMarkup = $this->getMarkup();
43: parent::renderAll(array(&$pageMarkup));
44: }
45:
46: public function renderPage()
47: {
48: $this->render();
49: }
50:
51: public function isPageStateless()
52: {
53: $stateless = $this->isStateless();
54:
55: if(!$stateless)
56: {
57: return $stateless;
58: }
59:
60: $reflection = new \ReflectionClass(get_called_class());
61: $constructor = $reflection->getConstructor();
62: $params = $constructor->getParameters();
63:
64:
65: $stateless = count($params)==0;
66:
67: if(!$stateless)
68: {
69: return $stateless;
70: }
71:
72: $callback = function($component) use (&$stateless)
73: {
74: if(!$component->isStateless())
75: {
76: $stateless = false;
77: return Component::VISITOR_STOP_TRAVERSAL;
78: }
79: return Component::VISITOR_CONTINUE_TRAVERSAL;
80: };
81: $this->visitChildren(Component::getIdentifier(), $callback);
82: return $stateless;
83: }
84:
85: public function afterPageRender()
86: {
87: parent::afterPageRender();
88: if(!$this->isPageStateless())
89: {
90: PageMap::get()->addOrUpdate($this);
91: }
92: FeedbackModel::get()->cleanup();
93: }
94:
95: public function beforePageRender()
96: {
97: parent::beforePageRender();
98: if(!$this->isInitialized())
99: {
100: $this->internalInitialize();
101: }
102: }
103:
104: public function getAutoIndex()
105: {
106: $this->autoIndex++;
107: return $this->autoIndex;
108: }
109: }
110:
111: ?>
112: