- Timestamp:
- 03/14/08 17:53:51 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/xml/stubShowLastXMLInterceptor.php
r1360 r1426 1 1 <?php 2 2 /** 3 * Interceptor that stores the last XML tree in the session and 4 * is able to display it. 5 * 6 * This interceptor must be added as pre-interceptor AND 7 * post-interceptor. In the post-interceptor queue, it should 8 * be added prior to the XSL transformation processor. 9 * 10 * In the pre-interceptor queue, it cancels the request in case 11 * the request param showLastRequestXML is set and the session 12 * is not new. 3 * Preinterceptor that is able to display the last created XML result document. 13 4 * 14 5 * @author Frank Kleine <mikey@stubbles.net> … … 17 8 * @subpackage websites_xml 18 9 */ 19 stubClassLoader::load('net::stubbles::ipo::interceptors::stubPreInterceptor', 20 'net::stubbles::websites::xml::stubXMLAbstractPostInterceptor' 21 ); 10 stubClassLoader::load('net::stubbles::ipo::interceptors::stubPreInterceptor'); 22 11 /** 23 * Interceptor that stores the last XML tree in the session and 24 * is able to display it. 12 * Preinterceptor that is able to display the last created XML result document. 25 13 * 26 * This interceptor must be added as pre-interceptor AND 27 * post-interceptor. In the post-interceptor queue, it should 28 * be added prior to the XSL transformation processor. 29 * 30 * In the pre-interceptor queue, it cancels the request in case 31 * the request param showLastRequestXML is set and the session 32 * is not new. 14 * This interceptor cancels the request in case the request param 15 * showLastRequestXML is set and the session is not new. 33 16 * 34 17 * @package stubbles 35 18 * @subpackage websites_xml 36 19 */ 37 class stubShowLastXMLInterceptor extends stub XMLAbstractPostInterceptorimplements stubPreInterceptor20 class stubShowLastXMLInterceptor extends stubBaseObject implements stubPreInterceptor 38 21 { 39 /**40 * key with which last xml is stored in session41 */42 const SESSION_KEY = 'net.stubbles.websites.lastRequestResponseData';43 44 22 /** 45 23 * does the preprocessing stuff … … 53 31 if ($request->hasValue('showLastRequestXML') === true && $session->isNew() === false) { 54 32 $response->addHeader('Content-type', 'text/xml'); 55 $response->write($session->getValue( self::SESSION_KEY));33 $response->write($session->getValue('net.stubbles.websites.lastRequestResponseData')); 56 34 $request->cancel(); 57 35 } 58 36 } 59 60 /**61 * does the postprocessing stuff62 *63 * @param stubRequest $request access to request data64 * @param stubSession $session access to session data65 * @param stubXMLResponse $response access to response data66 */67 protected function doPostProcess(stubRequest $request, stubSession $session, stubXMLResponse $response)68 {69 $xmlStreamWriter = $response->getXMLStreamWriter();70 if ($xmlStreamWriter->isFinished() === false) {71 $xmlStreamWriter->writeEndElement();72 }73 74 $session->putValue(self::SESSION_KEY, $xmlStreamWriter->asXML());75 }76 37 } 77 38 ?>
