/** * SITE_HOME sites should be able to override any template */ public function testSiteOverrides() { $template = new Template('test', 'test'); $expectedOutput = file_get_contents(__DIR__ . '/templates/test/test.inc'); $this->assertEquals($expectedOutput, $template->render()); $helper = $template->getHelper('test'); $this->assertEquals('something', $helper->test('something')); $template = new Template('partials', 'test'); $expectedOutput = file_get_contents(__DIR__ . '/templates/test/partials/testPartial.inc'); $this->assertEquals($expectedOutput, $template->render()); }
public function testNormalRendering() { $template = new Template('test', 'html'); $expectedOutput = file_get_contents(APPLICATION_HOME . '/templates/html/test.inc'); $this->assertEquals($expectedOutput, $template->render()); $helper = $template->getHelper('test'); $this->assertEquals('something', $helper->test('something')); $template = new Template('partials', 'html'); $expectedOutput = file_get_contents(APPLICATION_HOME . '/templates/html/partials/testPartial.inc'); $this->assertEquals($expectedOutput, $template->render()); }
$resource = 'media'; $action = 'resize'; $_REQUEST['size'] = $matches[1]; $_REQUEST['media_id'] = $matches[2]; } elseif (preg_match('#' . BASE_URI . '(/([a-zA-Z0-9]+))?(/([a-zA-Z0-9]+))?#', $_SERVER['REQUEST_URI'], $matches)) { $resource = isset($matches[2]) ? $matches[2] : 'index'; $action = isset($matches[4]) ? $matches[4] : 'index'; } // Create the Template $format = !empty($_REQUEST['format']) ? $_REQUEST['format'] : 'html'; $template = new Template('default', $format); // Execute the Controller::action() if (isset($resource) && isset($action) && $ZEND_ACL->hasResource($resource)) { $role = isset($_SESSION['USER']) ? $_SESSION['USER']->getRole() : 'Anonymous'; if ($ZEND_ACL->isAllowed($role, $resource, $action)) { $controller = 'Application\\Controllers\\' . ucfirst($resource) . 'Controller'; $c = new $controller($template); $c->{$action}(); } else { header('HTTP/1.1 403 Forbidden', true, 403); $_SESSION['errorMessages'][] = new \Exception('noAccessAllowed'); } } else { header('HTTP/1.1 404 Not Found', true, 404); $template->blocks[] = new Block('404.inc'); } if (!empty($_REQUEST['partial'])) { $template->setFilename('partial'); } echo $template->render();