Changeset 1507
- Timestamp:
- 04/06/08 15:47:09 (1 month ago)
- Files:
-
- trunk/src/main/php/net/stubbles/websites/rasmus/stubPageRasmusFactory.php (deleted)
- trunk/src/main/php/net/stubbles/websites/rasmus/stubRasmusPage.php (deleted)
- trunk/src/main/php/net/stubbles/websites/rasmus/stubRasmusProcessor.php (modified) (3 diffs)
- trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php (modified) (1 diff)
- trunk/src/test/php/net/stubbles/websites/rasmus (added)
- trunk/src/test/php/net/stubbles/websites/rasmus/stubRasmusProcessorTestCase.php (added)
- trunk/src/test/php/net/stubbles/websites/rasmus/testpage.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/websites/rasmus/stubRasmusProcessor.php
r1442 r1507 7 7 * @subpackage websites_rasmus 8 8 */ 9 stubClassLoader::load('net::stubbles::websites::processors::stubAbstractProcessor', 10 'net::stubbles::websites::processors::stubPageBasedProcessor' 9 stubClassLoader::load('net::stubbles::util::stubRegistry', 10 'net::stubbles::util::validators::stubRegexValidator', 11 'net::stubbles::websites::processors::stubAbstractProcessor' 11 12 ); 12 13 /** … … 16 17 * @subpackage websites_rasmus 17 18 */ 18 class stubRasmusProcessor extends stubAbstractProcessor implements stubPageBasedProcessor19 class stubRasmusProcessor extends stubAbstractProcessor 19 20 { 20 21 /** 21 * page to display 22 * registry key under which the page path is stored 23 */ 24 const PAGEPATH_REGISTRY_KEY = 'net.stubbles.websites.rasmus.pagePath'; 25 /** 26 * the default path where pages are located 22 27 * 23 * @var st ubPage28 * @var string 24 29 */ 25 protected $page;30 protected static $defaultPath; 26 31 27 32 /** 28 * selects the page to display with help of the page factory 29 * 30 * @param stubPageFactory $pageFactory 33 * static initializer 31 34 */ 32 public function selectPage(stubPageFactory $pageFactory) 35 // @codeCoverageIgnoreStart 36 public static function __static() 33 37 { 34 $this->page = $pageFactory->getPage($pageFactory->getPageName($this->request));38 self::$defaultPath = realpath(stubConfig::getConfigPath() . '/../pages'); 35 39 } 40 // @codeCoverageIgnoreEnd 36 41 37 42 /** … … 40 45 public function process() 41 46 { 42 $this->page->render($this->request, $this->session, $this->response); 43 $this->response->addHeader('X-Generator', 'Rasmus\' Template Engine :-) powered by Stubbles, http://stubbles.net/'); 47 $this->response->write($this->render($this->getPageName())); 48 } 49 50 /** 51 * retrieves the page name 52 * 53 * @return string 54 */ 55 protected function getPageName() 56 { 57 if ($this->request->hasValue('page') === true) { 58 $pageName = $this->request->getValidatedValue(new stubRegexValidator('/([a-zA-Z0-9_])/'), 'page'); 59 if (null != $pageName && file_exists(stubRegistry::getConfig(self::PAGEPATH_REGISTRY_KEY, self::$defaultPath) . DIRECTORY_SEPARATOR . $pageName . '.php') === true) { 60 return $pageName; 61 } 62 } 63 64 return 'index'; 65 } 66 67 /** 68 * does the real rendering by including the page file 69 * 70 * @param string $pageName 71 * @return string 72 */ 73 protected function render($pageName) 74 { 75 ob_start(); 76 include stubRegistry::getConfig(self::PAGEPATH_REGISTRY_KEY, self::$defaultPath) . DIRECTORY_SEPARATOR . $pageName . '.php'; 77 return ob_get_clean(); 44 78 } 45 79 } trunk/src/test/php/net/stubbles/websites/WebsitesTestSuite.php
r1504 r1507 52 52 $suite->addTestFile($dir . '/processors/stubProcessorResolverXJConfFactoryTestCase.php'); 53 53 $suite->addTestFile($dir . '/processors/stubSimpleProcessorResolverTestCase.php'); 54 55 // rasmus 56 $suite->addTestFile($dir . '/rasmus/stubRasmusProcessorTestCase.php'); 54 57 55 58 // xml
