Changeset 292
- Timestamp:
- 02/23/07 16:02:18 (1 year ago)
- Files:
-
- trunk/docroot/xml.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/stubXJConfPageFactory.php (modified) (1 diff)
- trunk/src/main/php/net/stubbles/websites/xml/stubXMLPagePostInterceptor.php (modified) (5 diffs)
- trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php (modified) (4 diffs)
- trunk/src/main/php/net/stubbles/websites/xml/stubXMLResponse.php (added)
- trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/xml/stubXMLProcessorTestCase.php (modified) (6 diffs)
- trunk/src/test/php/net/stubbles/websites/xml/stubXMLResponseTestCase.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docroot/xml.php
r279 r292 25 25 $processor = new stubXMLProcessor($request, $session, $pageFactory); 26 26 $postInterceptor = new stubXMLPagePostInterceptor(); 27 $postInterceptor->setRequest($request);28 27 $response = $processor->process()->getResponse(); 29 28 $postInterceptor->setResponse($response); trunk/src/main/php/net/stubbles/websites/stubXJConfPageFactory.php
r279 r292 10 10 'net.stubbles.util.xjconf.stubXJConfLoader', 11 11 'net.stubbles.websites.stubPageConfigurationException', 12 'net.stubbles.websites.stubPageFactory' 12 'net.stubbles.websites.stubPageFactory', 13 'net.stubbles.stubFactory' 13 14 ); 14 15 XJConfLoader::load('DefinitionParser', trunk/src/main/php/net/stubbles/websites/xml/stubXMLPagePostInterceptor.php
r276 r292 11 11 'net.stubbles.xml.xsl.util.stubXSLImageDimensions', 12 12 'net.stubbles.xml.stubXMLXIncludeStreamWrapper', 13 'net.stubbles.xml.stubDomXMLStreamWriter' 13 'net.stubbles.xml.stubDomXMLStreamWriter', 14 'net.stubbles.stubFactory' 14 15 ); 15 16 /** … … 18 19 * @package stubbles 19 20 * @subpackage websites_xml 20 * @Inject(stubRequest:stubResponse) 21 * @todo enable using different skins (needs an idea how to transport 22 * the skin information from the page configuration to this class 21 * @Inject(stubResponse) 23 22 * @todo make <xsl:import href="copy.xsl"/> work if loaded from a star file 24 23 * in master.xsl and masterXInclude.xsl … … 28 27 class stubXMLPagePostInterceptor extends stubBaseObject implements stubPostInterceptor 29 28 { 30 /**31 * request data32 *33 * @var stubRequest34 */35 protected $request;36 29 /** 37 30 * response data … … 62 55 stubXMLXIncludeStreamWrapper::setXSLProcessor($xslProcessor); 63 56 } 64 65 /** 66 * set the request object 67 * 68 * @param stubRequest $request 69 */ 70 public function setRequest(stubRequest $request) 71 { 72 $this->request = $request; 73 } 74 57 75 58 /** 76 59 * set the response object … … 92 75 $xslProcessor->registerCallback('image', $this->callbacks['image']); 93 76 $xslProcessor->importXSLStylesheet(DOMDocument::load(stubFactory::getResourceURI('xsl/master.xsl'))); 94 if ($this->request->hasValue('page') == true) {95 $pageName = $this->request->getValidatedValue(new stubRegexValidator('([a-zA-Z0-9_])*'), 'page');96 if (null == $pageName || file_exists(stubConfig::getConfigPath() . '/xml/pages/conf/' . $pageName . '.xml') == false) {97 $pageName = 'index';98 }77 78 $page = $this->response->getPage(); 79 $xslProcessor->setParameter('', 'page', $page->getProperty('name')); 80 if ($page->hasProperty('skin') == true) { 81 $skin = $page->getProperty('skin'); 99 82 } else { 100 $ pageName = 'index';83 $skin = 'default'; 101 84 } 102 $xslProcessor->setParameter('', 'page', $pageName); 103 $xslProcessor->setXMLDocument(DOMDocument::load(stubConfig::getConfigPath() . '/xml/pages/skin/default.xml')); 85 $xslProcessor->setXMLDocument(DOMDocument::load(stubConfig::getConfigPath() . '/xml/pages/skin/' . $skin . '.xml')); 104 86 $resultXSL = $xslProcessor->transformToDoc(); 105 87 $resultXSL->xinclude(); 88 106 89 // now we use the created xsl to transform the xml document created by the application 107 90 $xslProcessor = new stubXSLProcessor(); trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php
r280 r292 8 8 */ 9 9 stubClassLoader::load('net.stubbles.websites.processors.stubAbstractProcessor', 10 'net.stubbles.websites.xml.stubXMLResponse', 10 11 'net.stubbles.ipo.response.stubBaseResponse', 11 12 'net.stubbles.util.validators.stubRegexValidator', … … 18 19 * @package stubbles 19 20 * @subpackage websites_xml 20 * @todo think about how to get the skin information from21 * stubPage into the stubXMLPagePostInterceptor22 21 */ 23 22 class stubXMLProcessor extends stubAbstractProcessor … … 33 32 { 34 33 parent::__construct($request, $session, $pageFactory); 35 $this->response = new stub BaseResponse();34 $this->response = new stubXMLResponse(new stubBaseResponse()); 36 35 } 37 36 … … 55 54 $xmlStreamWriter = $this->createXMLStreamWriter(); 56 55 $page = $this->pageFactory->getPage('conf/' . $pageName); 56 $page->setProperty('name', $pageName); 57 $this->response->setPage($page); 57 58 $elements = $page->getElements(); 58 59 $xmlStreamWriter->writeStartElement('document'); trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php
r289 r292 34 34 // xml tests 35 35 $this->addTestFile($dir . '/xml/stubXMLProcessorTestCase.php'); 36 $this->addTestFile($dir . '/xml/stubXMLResponseTestCase.php'); 36 37 } 37 38 } trunk/src/test/php/net/stubbles/websites/xml/stubXMLProcessorTestCase.php
r287 r292 10 10 Mock::generate('stubRequest'); 11 11 Mock::generate('stubSession'); 12 Mock::generate('stubPage');13 12 Mock::generate('stubPageElement'); 14 13 Mock::generate('stubPageFactory'); … … 87 86 * mocked page configuration instance 88 87 * 89 * @var SimpleMock88 * @var stubPage 90 89 */ 91 protected $ mockPage;90 protected $page; 92 91 93 92 /** … … 104 103 $this->xmlProcessor->setXMLStreamWriter($this->mockXMLStreamWriter); 105 104 $this->xmlProcessor->setXMLSerializer($this->mockXMLSerializer); 106 $this-> mockPage = new MockstubPage();107 $this->mockPageFactory->setReturnValue('getPage', $this-> mockPage);105 $this->page = new stubPage(); 106 $this->mockPageFactory->setReturnValue('getPage', $this->page); 108 107 } 109 108 … … 114 113 { 115 114 $this->mockRequest->setReturnValue('hasValue', false); 116 $this->mockPage->setReturnValue('getElements', array());117 115 $this->mockPageFactory->expectOnce('getPage', array('conf/index')); 118 116 $this->mockXMLStreamWriter->expectOnce('writeStartElement', array('document')); … … 137 135 $response = $this->xmlProcessor->getResponse(); 138 136 $pageElement1 = new MockstubPageElement(); 137 $pageElement1->setReturnValue('getName', 'foo'); 139 138 $pageElement1->setReturnValue('process', 'foo'); 140 $pageElement1->expectOnce('process' , array($this->mockRequest, $this->mockSession, $response));139 $pageElement1->expectOnce('process'); 141 140 $pageElement2 = new MockstubPageElement(); 141 $pageElement2->setReturnValue('getName', 'bar'); 142 142 $pageElement2->setReturnValue('process', 'bar'); 143 $pageElement2->expectOnce('process', array($this->mockRequest, $this->mockSession, $response)); 144 $this->mockPage->setReturnValue('getElements', array('foo' => $pageElement1, 'bar' => $pageElement2)); 143 $pageElement2->expectOnce('process'); 144 $this->page->addElement($pageElement1); 145 $this->page->addElement($pageElement2); 145 146 $this->mockXMLStreamWriter->expectOnce('writeStartElement', array('document')); 146 147 $this->mockXMLStreamWriter->expectOnce('writeEndElement'); … … 164 165 $this->mockPageFactory->expectOnce('getPage', array('conf/baz')); 165 166 $this->mockPageFactory->setReturnValue('hasPage', true); 166 $this->mockPage->setReturnValue('getElements', array());167 167 $this->xmlProcessor->process(); 168 168 }
