Changeset 369

Show
Ignore:
Timestamp:
03/13/07 14:06:34 (2 years ago)
Author:
mikey
Message:

some refactoring to save the name of the last used processor and page

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/websites/memphis/stubMemphisProcessor.php

    r317 r369  
    3737    protected function doProcess() 
    3838    { 
    39         if ($this->request->hasValue('page') == true) { 
    40             $pageName = $this->request->getValidatedValue(new stubRegexValidator('[a-zA-Z0-9_'), 'page'); 
    41             if (null == $pageName || $this->pageFactory->hasPage('memphis/' . $pageName) == false) { 
    42                 $pageName = 'index'; 
    43             } 
    44         } else { 
    45             $pageName = 'index'; 
    46         } 
    47  
     39        $pageName = $this->getPage('memphis'); 
    4840        try { 
    4941            $page = $this->pageFactory->getPage('memphis/' . $pageName); 
  • trunk/src/main/php/net/stubbles/websites/processors/stubAbstractProcessor.php

    r315 r369  
    77 * @subpackage  websites_processors 
    88 */ 
    9 stubClassLoader::load('net.stubbles.websites.processors.stubProcessor'); 
     9stubClassLoader::load('net.stubbles.websites.processors.stubProcessor', 
     10                      'net.stubbles.util.validators.stubRegexValidator' 
     11); 
    1012/** 
    1113 * Base processor implementation. 
     
    8284        return $this->response; 
    8385    } 
     86     
     87    /** 
     88     * retrieves the page name 
     89     * 
     90     * @param   string  $dirPrefix  directory prefix to use for page factory 
     91     * @return  string 
     92     */ 
     93    protected function getPage($dirPrefix = null) 
     94    { 
     95        if (null != $dirPrefix) { 
     96            $dirPrefix .= DIRECTORY_SEPARATOR; 
     97        } 
     98         
     99        if ($this->request->hasValue('page') == true) { 
     100            $pageName = $this->request->getValidatedValue(new stubRegexValidator('([a-zA-Z0-9_])'), 'page'); 
     101            if (null == $pageName || $this->pageFactory->hasPage($dirPrefix . $pageName) == false) { 
     102                $pageName = 'index'; 
     103            } 
     104        } else { 
     105            $pageName = 'index'; 
     106        } 
     107         
     108        $this->session->putValue('net.stubbles.websites.lastPage', $pageName); 
     109        return $pageName; 
     110    } 
    84111} 
    85112?> 
  • trunk/src/main/php/net/stubbles/websites/processors/stubDefaultProcessorResolver.php

    r368 r369  
    114114        } 
    115115         
     116        $session->putValue('net.stubbles.websites.lastProcessor', $paramValue); 
    116117        return $processor; 
    117118    } 
  • trunk/src/main/php/net/stubbles/websites/xml/stubXMLProcessor.php

    r356 r369  
    4242    protected function doProcess() 
    4343    { 
    44         if ($this->request->hasValue('page') == true) { 
    45             $pageName = $this->request->getValidatedValue(new stubRegexValidator('([a-zA-Z0-9_])'), 'page'); 
    46             if (null == $pageName || $this->pageFactory->hasPage('conf/' . $pageName) == false) { 
    47                 $pageName = 'index'; 
    48             } 
    49         } else { 
    50             $pageName = 'index'; 
    51         } 
    52  
     44        $pageName        = $this->getPage('conf'); 
    5345        $xmlSerializer   = $this->createXMLSerializer(); 
    5446        $xmlStreamWriter = $this->createXMLStreamWriter();