Action.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * Base action class
  4. *
  5. * */
  6. session_start();
  7. class Action extends Smarty{
  8. protected $actionName;
  9. protected $lang;
  10. public function __construct(){
  11. parent::__construct();
  12. $this->smartyInit();
  13. $this->assign('uname',$_SESSION['mds_user']);
  14. }
  15. public function run($action){
  16. $this->actionName = $action;
  17. $this->requestRoute();
  18. }
  19. public function display($template = null, $cache_id = null, $compile_id = null, $parent = null){
  20. if(strpos($template,'/')){
  21. $this->fetch($template, $cache_id, $compile_id, $parent, true);
  22. }else{
  23. // display template
  24. $this->fetch(strtolower($this->actionName).'/'.$template, $cache_id, $compile_id, $parent, true);
  25. }
  26. }
  27. private function smartyInit(){
  28. $this->template_dir = ONU_ROOT . "application/module/view";
  29. $this->config_dir = ONU_ROOT . "config";
  30. $this->cache_dir = ONU_ROOT . "application/cache";
  31. $this->compile_dir = ONU_ROOT . "application/compile";
  32. $this->left_delimiter = "<{";
  33. $this->right_delimiter = "}>";
  34. $this->caching = false;
  35. $this->cache_lifetime = "3000";
  36. }
  37. private function requestRoute(){
  38. $m = isset($_GET["m"])?$_GET["m"]:"index";
  39. if(method_exists($this,$m)){
  40. $this->$m();
  41. }
  42. else{
  43. die("Module '{$m}' Not Exists!");
  44. }
  45. }
  46. }