| | 97 | } |
| | 98 | |
| | 99 | /** |
| | 100 | * sets the page |
| | 101 | * |
| | 102 | * @param stubPage $page |
| | 103 | * @Inject |
| | 104 | */ |
| | 105 | public function setPage(stubPage $page) |
| | 106 | { |
| | 107 | $this->page = $page; |
| | 108 | if (count($this->page->getResources()) > 0) { |
| | 109 | $this->isCachable = false; |
| | 110 | } |
| | 111 | |
| | 112 | foreach ($this->page->getElements() as $name => $element) { |
| | 113 | $this->request->setPrefix($name); |
| | 114 | $this->injector->handleInjections($element); |
| | 115 | $element->init($this->request, $this->session, $this->response); |
| | 116 | if ($element->isAvailable() === true) { |
| | 117 | $this->pageElements[$name] = $element; |
| | 118 | // we can spare this if the page is not cachable |
| | 119 | if (true === $this->isCachable) { |
| | 120 | if ($element->isCachable() === false) { |
| | 121 | $this->isCachable = false; |
| | 122 | } elseif (true === $this->isCachable) { |
| | 123 | $this->cacheVars = array_merge($this->cacheVars, $element->getCacheVars()); |
| | 124 | $this->usedFiles = array_merge($this->usedFiles, $element->getUsedFiles()); |
| | 125 | } |
| | 126 | } |
| | 127 | } |
| | 128 | } |
| | 129 | } |
| | 130 | |
| | 131 | /** |
| | 132 | * checks whether document part is cachable or not |
| | 133 | * |
| | 134 | * Document part is cachable if page has no session resources and all page |
| | 135 | * elements are cachable. |
| | 136 | * |
| | 137 | * @return bool |
| | 138 | */ |
| | 139 | public function isCachable() |
| | 140 | { |
| | 141 | return $this->isCachable; |
| | 142 | } |
| | 143 | |
| | 144 | /** |
| | 145 | * returns a list of variables that have an influence on caching |
| | 146 | * |
| | 147 | * @return array<string,scalar> |
| | 148 | */ |
| | 149 | public function getCacheVars() |
| | 150 | { |
| | 151 | return $this->cacheVars; |
| | 152 | } |
| | 153 | |
| | 154 | /** |
| | 155 | * returns a list of files used to create the content |
| | 156 | * |
| | 157 | * @return array<string> |
| | 158 | */ |
| | 159 | public function getUsedFiles() |
| | 160 | { |
| | 161 | return $this->usedFiles; |
| 85 | | $prefixRequest = new stubRequestPrefixDecorator($this->request, ''); |
| 86 | | $formValues = array(); |
| 87 | | foreach ($this->page->getElements() as $name => $element) { |
| 88 | | $prefixRequest->setPrefix($name); |
| 89 | | $this->injector->handleInjections($element); |
| 90 | | $element->init($prefixRequest, $this->session, $this->response); |
| 91 | | if ($element->isAvailable() === true) { |
| 92 | | $data = $element->process(); |
| 93 | | if ($prefixRequest->isCancelled() === true) { |
| 94 | | return; |
| 95 | | } |
| 96 | | |
| 97 | | $xmlSerializer->serialize($data, $xmlStreamWriter, array(stubXMLSerializer::OPT_ROOT_TAG => $name)); |
| 98 | | if ($element instanceof stubXMLPageElement) { |
| 99 | | $formValues[$name] = $element->getFormValues(); |
| 100 | | } |
| | 172 | $formValues = array(); |
| | 173 | foreach ($this->pageElements as $name => $element) { |
| | 174 | $this->request->setPrefix($name); |
| | 175 | $element->init($this->request, $this->session, $this->response); |
| | 176 | $data = $element->process(); |
| | 177 | if ($this->request->isCancelled() === true) { |
| | 178 | return; |
| | 179 | } |
| | 180 | |
| | 181 | $xmlSerializer->serialize($data, $xmlStreamWriter, array(stubXMLSerializer::OPT_ROOT_TAG => $name)); |
| | 182 | if ($element instanceof stubXMLPageElement) { |
| | 183 | $formValues[$name] = $element->getFormValues(); |