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.

47 lines
1003 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 Action
  12. {
  13. public function __construct()
  14. {
  15. $this->extractParams();
  16. $this->execute();
  17. }
  18. protected function extractParams()
  19. {
  20. foreach (Env::getParam() as $name => $value) {
  21. if (is_string($name)) {
  22. $this->$name = $value;
  23. }
  24. }
  25. }
  26. abstract protected function execute();
  27. /**
  28. * Redirect
  29. *
  30. * @param mixed $url
  31. * @param mixed $relative Default to true
  32. */
  33. protected function redirect($url = null, $relative = true)
  34. {
  35. $url = ($url) ? $url : Env::getRequestUri();
  36. if ($relative) {
  37. $url = FrontController::getInstance()->getBaseUrl() . $url;
  38. }
  39. header('Location: ' . $url);
  40. exit();
  41. }
  42. }