Changeset 1248
- Timestamp:
- 01/16/08 18:00:58 (6 months ago)
- Files:
-
- trunk/src/main/php/net/stubbles/service/jsonrpc/stubJsonRpcProcessor.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisProcessor.php (modified) (3 diffs)
- trunk/src/main/php/net/stubbles/websites/processors/stubAbstractPageProcessor.php (added)
- trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/websites/rasmus/stubRasmusProcessor.php (modified) (2 diffs)
- trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php (modified) (3 diffs)
- trunk/src/main/php/org/stubbles/test/BarProcessor.php (modified) (1 diff)
- trunk/src/main/php/org/stubbles/test/FooProcessor.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorTestCase.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/service/jsonrpc/stubJsonRpcProcessor.php
r1237 r1248 75 75 * This method only dispatches the request to different methods. 76 76 */ 77 public function doProcess()77 public function process() 78 78 { 79 79 $this->loadServiceConfig($this->getServiceFilePath()); … … 96 96 $this->processGetRequest(); 97 97 } 98 99 return $this; 98 100 } 99 101 trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisProcessor.php
r1247 r1248 15 15 'net::stubbles::util::validators::stubPreSelectValidator', 16 16 'net::stubbles::websites::cache::stubCachableProcessor', 17 'net::stubbles::websites::processors::stubAbstractP rocessor',17 'net::stubbles::websites::processors::stubAbstractPageProcessor', 18 18 'net::stubbles::websites::memphis::stubMemphisConfig', 19 19 'net::stubbles::websites::memphis::stubMemphisTemplate' … … 25 25 * @subpackage websites_memphis 26 26 */ 27 class stubMemphisProcessor extends stubAbstractP rocessor implements stubCachableProcessor27 class stubMemphisProcessor extends stubAbstractPageProcessor implements stubCachableProcessor 28 28 { 29 29 /** … … 99 99 /** 100 100 * does the real processing 101 */ 102 protected function doProcess() 103 { 104 $pageName = $this->getPageName(); 105 $page = $this->pageFactory->getPage($pageName); 101 * 102 * @param stubPage $page the page to process 103 * @param string $pageName name of the page to process 104 */ 105 protected function doProcess(stubPage $page, $pageName) 106 { 106 107 $elements = $page->getElements(); 107 108 $prefixRequest = new stubRequestPrefixDecorator($this->request, ''); trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php
r1247 r1248 110 110 111 111 /** 112 * processes the request113 *114 * @return stubProcessor115 */116 public function process()117 {118 $this->doProcess();119 return $this;120 }121 122 /**123 * does the real processing124 */125 protected abstract function doProcess();126 127 /**128 112 * returns the created response 129 113 * … … 134 118 return $this->response; 135 119 } 136 137 /**138 * retrieves the page name139 *140 * @param string $dirPrefix directory prefix to use for page factory141 * @return string142 */143 protected function getPageName($dirPrefix = null)144 {145 if (null != $dirPrefix) {146 $dirPrefix .= DIRECTORY_SEPARATOR;147 }148 149 if ($this->request->hasValue('page') == true) {150 $pageName = $this->request->getValidatedValue(new stubRegexValidator('/([a-zA-Z0-9_])/'), 'page');151 if (null == $pageName || $this->pageFactory->hasPage($dirPrefix . $pageName) == false) {152 $pageName = 'index';153 }154 } else {155 $pageName = 'index';156 }157 158 $this->session->putValue('net.stubbles.websites.lastPage', $pageName);159 return $pageName;160 }161 120 } 162 121 ?> trunk/src/main/php/net/stubbles/websites/rasmus/stubRasmusProcessor.php
r1231 r1248 7 7 * @subpackage websites_rasmus 8 8 */ 9 stubClassLoader::load('net::stubbles::websites::processors::stubAbstractP rocessor');9 stubClassLoader::load('net::stubbles::websites::processors::stubAbstractPageProcessor'); 10 10 /** 11 11 * Processor for rasmus pages. … … 14 14 * @subpackage websites_rasmus 15 15 */ 16 class stubRasmusProcessor extends stubAbstractP rocessor16 class stubRasmusProcessor extends stubAbstractPageProcessor 17 17 { 18 18 /** 19 19 * does the real processing 20 * 21 * @param stubPage $page the page to process 22 * @param string $pageName name of the page to process 20 23 */ 21 protected function doProcess( )24 protected function doProcess(stubPage $page, $pageName) 22 25 { 23 $pageName = $this->getPage();24 try {25 $page = $this->pageFactory->getPage($pageName);26 } catch (stubPageConfigurationException $pce) {27 $this->response->replaceData((string) $pce);28 return;29 }30 31 26 $page->render($this->request, $this->session, $this->response); 32 27 $this->response->addHeader('X-Generator', 'Rasmus\' Template Engine :-) powered by Stubbles, http://stubbles.net/'); trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php
r1242 r1248 8 8 * @subpackage websites_xml 9 9 */ 10 stubClassLoader::load('net::stubbles::websites::processors::stubAbstractP rocessor',10 stubClassLoader::load('net::stubbles::websites::processors::stubAbstractPageProcessor', 11 11 'net::stubbles::websites::xml::stubXMLResponse', 12 12 'net::stubbles::ipo::request::stubRequestPrefixDecorator', … … 22 22 * @subpackage websites_xml 23 23 */ 24 class stubXMLProcessor extends stubAbstractP rocessor24 class stubXMLProcessor extends stubAbstractPageProcessor 25 25 { 26 26 /** … … 36 36 $response = new stubXMLResponse($response); 37 37 parent::__construct($request, $session, $response, $pageFactory); 38 $this->pageDirPrefix = 'conf/'; 38 39 } 39 40 40 41 /** 41 42 * does the real processing 42 */ 43 protected function doProcess() 43 * 44 * @param stubPage $page the page to process 45 * @param string $pageName name of the page to process 46 */ 47 protected function doProcess(stubPage $page, $pageName) 44 48 { 45 49 $pageName = $this->getPageName('conf'); 46 50 $xmlSerializer = $this->createXMLSerializer(); 47 51 $xmlStreamWriter = $this->createXMLStreamWriter(); 48 $page = $this->pageFactory->getPage('conf/' . $pageName);49 $page->setProperty('name', $pageName);50 52 $this->response->setPage($page); 51 53 $elements = $page->getElements(); trunk/src/main/php/org/stubbles/test/BarProcessor.php
r1221 r1248 19 19 * does the real processing 20 20 */ 21 p rotected function doProcess()21 public function process() 22 22 { 23 23 // nothing to process here trunk/src/main/php/org/stubbles/test/FooProcessor.php
r1221 r1248 19 19 * does the real processing 20 20 */ 21 p rotected function doProcess()21 public function process() 22 22 { 23 23 // nothing to process here trunk/src/test/php/net/stubbles/websites/memphis/stubMemphisProcessorTestCase.php
r1247 r1248 172 172 * helper method to call protected method doProcess() 173 173 */ 174 public function callDoProcess( )175 { 176 $this->doProcess( );174 public function callDoProcess($page, $pageName) 175 { 176 $this->doProcess($page, $pageName); 177 177 } 178 178 } … … 275 275 $this->mockResponse->expectNever('getData'); 276 276 $this->mockResponse->expectNever('replaceData'); 277 $memphisProcessor->callDoProcess( );277 $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 278 278 } 279 279 … … 307 307 $this->mockSession->setReturnValue('getName', 'name'); 308 308 $this->mockResponse->expectOnce('replaceData', array('name=idnameid')); 309 $memphisProcessor->callDoProcess( );309 $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 310 310 } 311 311 … … 338 338 $this->mockSession->setReturnValue('getName', 'name'); 339 339 $this->mockResponse->expectOnce('replaceData', array('name=idnameid')); 340 $memphisProcessor->callDoProcess( );340 $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 341 341 } 342 342 … … 366 366 $this->mockResponse->expectNever('getData'); 367 367 $this->mockResponse->expectNever('replaceData'); 368 $memphisProcessor->callDoProcess( );368 $memphisProcessor->callDoProcess($this->mockPage, 'foo'); 369 369 } 370 370
