View.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. if(!isset($ajaxbool))$ajaxbool = $rock->jm->gettoken('ajaxbool', 'false');
  3. $ajaxbool = $rock->get('ajaxbool', $ajaxbool);
  4. $p = PROJECT;
  5. if(!isset($m))$m='index';
  6. if(!isset($a))$a='default';
  7. if(!isset($d))$d='';
  8. $m = $rock->get('m', $m);
  9. $a = $rock->get('a', $a);
  10. $d = $rock->get('d', $d);
  11. define('M', $m);
  12. define('A', $a);
  13. define('D', $d);
  14. define('P', $p);
  15. $_m = $m;
  16. if($rock->contain($m, '|')){
  17. $_mas = explode('|', $m);
  18. $m = $_mas[0];
  19. $_m = $_mas[1];
  20. }
  21. include_once($rock->strformat('?0/?1/?1Action.php',ROOT_PATH, $p));
  22. $rand = date('YmdHis').rand(1000,9999);
  23. if(substr($d,-1)!='/' && $d!='')$d.='/';
  24. $errormsg = '';
  25. $methodbool = true;
  26. $actpath = $rock->strformat('?0/?1/?2?3',ROOT_PATH, $p, $d, $_m);
  27. define('ACTPATH', $actpath);
  28. $actfile = $rock->strformat('?0/?1Action.php',$actpath, $m);
  29. $actfile1 = $rock->strformat('?0/?1Action.php',$actpath, $_m);
  30. $actbstr = null;
  31. if(file_exists($actfile1))include_once($actfile1);
  32. if(file_exists($actfile)){
  33. include_once($actfile);
  34. $clsname = ''.$m.'ClassAction';
  35. $xhrock = new $clsname();
  36. $actname = ''.$a.'Action';
  37. if($ajaxbool == 'true')$actname = ''.$a.'Ajax';
  38. if(method_exists($xhrock, $actname)){
  39. $xhrock->beforeAction();
  40. $actbstr = $xhrock->$actname();
  41. $xhrock->bodyMessage = $actbstr;
  42. if(is_string($actbstr)){echo $actbstr;$xhrock->display=false;}
  43. if(is_array($actbstr)){echo json_encode($actbstr);$xhrock->display=false;}
  44. }else{
  45. $methodbool = false;
  46. if($ajaxbool == 'false')echo ''.$actname.' not found;';
  47. }
  48. $xhrock->afterAction();
  49. }else{
  50. echo 'actionfile not exists;';
  51. $xhrock = new Action();
  52. }
  53. $_showbool = false;
  54. if($xhrock->display && ($ajaxbool == 'html' || $ajaxbool == 'false')){
  55. $xhrock->smartydata['p'] = $p;
  56. $xhrock->smartydata['a'] = $a;
  57. $xhrock->smartydata['m'] = $m;
  58. $xhrock->smartydata['d'] = $d;
  59. $xhrock->smartydata['rand'] = $rand;
  60. $xhrock->smartydata['qom'] = QOM;
  61. $xhrock->smartydata['path'] = PATH;
  62. $xhrock->smartydata['sysurl']= SYSURL;
  63. $temppath = ''.ROOT_PATH.'/'.$p.'/';
  64. $tplpaths = ''.$temppath.''.$d.''.$m.'/';
  65. $tplname = 'tpl_'.$m.'';
  66. if($a!='default')$tplname .= '_'.$a.'';
  67. $tplname .= '.'.$xhrock->tpldom.'';
  68. $mpathname = $tplpaths.$tplname;
  69. if($xhrock->displayfile!='' && file_exists($xhrock->displayfile))$mpathname = $xhrock->displayfile;
  70. if(!file_exists($mpathname) || !$methodbool){
  71. if(!$methodbool){
  72. $errormsg = 'in ('.$m.') not found Method('.$a.');';
  73. }else{
  74. $errormsg = ''.$tplname.' not exists;';
  75. }
  76. echo $errormsg;
  77. }else{
  78. $_showbool = true;
  79. }
  80. }
  81. if($xhrock->display && ($ajaxbool == 'html' || $xhrock->tpltype=='html' || $ajaxbool == 'false') && $_showbool){
  82. $xhrock->setHtmlData();
  83. $da = $xhrock->smartydata;
  84. foreach($xhrock->assigndata as $_k=>$_v)$$_k=$_v;
  85. include_once($mpathname);
  86. $_showbool = false;
  87. }
粤ICP备19079148号