Changeset 340

Show
Ignore:
Timestamp:
03/06/07 17:02:05 (1 year ago)
Author:
mikey
Message:

added possibility to set the language via session, page configuration or overall configuration
fallback to en_EN if none of those is set

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docroot/xml.php

    r339 r340  
    5050        $postInterceptor = new stubXMLPagePostInterceptor(); 
    5151        $response = $processor->process()->getResponse(); 
     52        $postInterceptor->setSession($session); 
    5253        $postInterceptor->setResponse($response); 
    5354        $postInterceptor->postProcess(); 
  • trunk/src/main/php/net/stubbles/websites/xml/stubXMLPagePostInterceptor.php

    r302 r340  
    88 */ 
    99stubClassLoader::load('net.stubbles.ipo.interceptors.stubPostInterceptor', 
     10                      'net.stubbles.ipo.response.stubResponse', 
     11                      'net.stubbles.ipo.session.stubSession', 
     12                      'net.stubbles.util.stubRegistry', 
    1013                      'net.stubbles.xml.xsl.stubXSLProcessor', 
    1114                      'net.stubbles.xml.xsl.util.stubXSLImageDimensions', 
     
    2730{ 
    2831    /** 
     32     * access to session 
     33     * 
     34     * @var  stubSession 
     35     */ 
     36    protected $session; 
     37    /** 
    2938     * response data 
    3039     * 
     
    4150        stubXMLXIncludeStreamWrapper::setIncludePath(stubConfig::getConfigPath() . '/xml/pages/txt'); 
    4251        stubXMLXIncludeStreamWrapper::setCachePath(stubConfig::getCachePath()); 
     52    } 
     53     
     54    /** 
     55     * set the session object 
     56     * 
     57     * @param  stubSession  $session 
     58     */ 
     59    public function setSession(stubSession $session) 
     60    { 
     61        $this->session = $session; 
    4362    } 
    4463 
     
    6685        $page = $this->response->getPage(); 
    6786        $xslProcessor->setParameter('', 'page', $page->getProperty('name')); 
     87        if ($this->session->hasValue('net.stubbles.language') == true) { 
     88            $language = $this->session->getValue('net.stubbles.language'); 
     89        } elseif ($page->hasProperty('language') == true) { 
     90            $language = $page->getProperty('language'); 
     91        } elseif (stubRegistry::hasConfig('net.stubbles.language') == true) { 
     92            $language = stubRegistry::getConfig('net.stubbles.language'); 
     93        } else { 
     94            $language = 'en_EN'; 
     95        } 
     96        $xslProcessor->setParameter('', 'lang', $language); 
    6897        // use same xsl processor for the xincludes 
    6998        stubXMLXIncludeStreamWrapper::setXSLProcessor($xslProcessor);