You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
955 B

  1. <?php
  2. /**
  3. * @copyright NetMonsters <team@netmonsters.ru>
  4. * @link http://netmonsters.ru
  5. * @package Majestic
  6. * @subpackage app
  7. * @since 2010-02-25
  8. * @version SVN: $Id$
  9. * @filesource $URL$
  10. */
  11. abstract class ViewAction extends Action
  12. {
  13. protected $template;
  14. /**
  15. * @var PHPView
  16. */
  17. protected $view;
  18. public function __construct()
  19. {
  20. $this->view = FrontController::getInstance()->getView();
  21. parent::__construct();
  22. }
  23. protected function getTemplate()
  24. {
  25. $class = get_class($this);
  26. $template = ($this->template) ? $this->template : substr($class, 0, -6/*strlen('Action')*/);
  27. $dir = array_slice(explode('/', Load::getFilePath($class)), -2, 1);
  28. return '/actions/' . array_pop($dir) . '/' . $template;
  29. }
  30. public function fetch()
  31. {
  32. $this->view->assignObject($this);
  33. return $this->view->fetch($this->getTemplate());
  34. }
  35. }