国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
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.

200 lines
5.7KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 前台提示对话框
  5. *
  6. * @version $id:WebWindow.class.php 2 13:53 2010-11-11 tianya $
  7. * @package DedeBIZ.Libraries
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  10. * @link https://www.dedebiz.com
  11. */
  12. require_once(DEDEINC."/dedetag.class.php");
  13. class WebWindow
  14. {
  15. var $myWin = '';
  16. var $myWinItem = '';
  17. var $checkCode = '';
  18. var $formName = '';
  19. var $tmpCode = "//checkcode";
  20. var $hasStart = false;
  21. /**
  22. * 初始化为含表单的页面
  23. *
  24. * @param string $formaction 表单操作action
  25. * @param string $checkScript 检测验证脚本
  26. * @param string $formmethod 表单类型
  27. * @param string $formname 表单名称
  28. * @return void
  29. */
  30. function Init($formaction = "", $checkScript = "/static/web/js/admin.blank.js", $formmethod = "POST", $formname = "myform")
  31. {
  32. $this->myWin .= "<script>";
  33. if ($checkScript != "" && file_exists($checkScript)) {
  34. $fp = fopen($checkScript, "r");
  35. $this->myWin .= fread($fp, filesize($checkScript));
  36. fclose($fp);
  37. } else {
  38. $this->myWin .= "function CheckSubmit(){return true;}";
  39. }
  40. $this->myWin .= "</script>";
  41. $this->formName = $formname;
  42. $this->myWin .= "<form name='$formname' action='$formaction' method='$formmethod' onSubmit='return CheckSubmit();'>";
  43. }
  44. /**
  45. * 添加隐藏域
  46. *
  47. * @param string $iname 隐藏域名称
  48. * @param string $ivalue 隐藏域值
  49. * @return void
  50. */
  51. function AddHidden($iname, $ivalue)
  52. {
  53. $this->myWin .= "<input type='hidden' name='$iname' value='$ivalue'>";
  54. }
  55. /**
  56. * 开始窗口
  57. *
  58. * @return void
  59. */
  60. function StartWin()
  61. {
  62. $this->myWin .= "<div class='table-responsive'>";
  63. }
  64. /**
  65. * 添加单列信息
  66. *
  67. * @access public
  68. * @param string $ivalue 信息
  69. * @return void
  70. */
  71. function AddMsgItem($ivalue)
  72. {
  73. $this->myWinItem .= $ivalue;
  74. }
  75. /**
  76. * 结束窗口
  77. *
  78. * @param bool $isform
  79. * @return void
  80. */
  81. function CloseWin($isform = true)
  82. {
  83. if (!$isform) {
  84. $this->myWin .= "</div>";
  85. } else {
  86. $this->myWin .= "</div></form>";
  87. }
  88. }
  89. /**
  90. * 添加自定义脚本
  91. *
  92. * @param string $scripts
  93. * @return void
  94. */
  95. function SetCheckScript($scripts)
  96. {
  97. $pos = strpos($this->myWin, $this->tmpCode);
  98. if ($pos > 0) {
  99. $this->myWin = substr_replace($this->myWin, $scripts, $pos, strlen($this->tmpCode));
  100. }
  101. }
  102. /**
  103. * 获取窗口
  104. *
  105. * @param string $wintype 菜单类型
  106. * @param string $msg 短消息
  107. * @param bool $isform 是否是表单
  108. * @return string
  109. */
  110. function GetWindow($wintype = "save", $msg = "", $isform = true)
  111. {
  112. global $cfg_static_dir;
  113. $this->StartWin();
  114. $this->myWin .= $this->myWinItem;
  115. $tt = '';
  116. switch ($wintype) {
  117. case 'back':
  118. $tt = "返回";
  119. break;
  120. case 'ok':
  121. $tt = "确定";
  122. break;
  123. case 'reset':
  124. $tt = "重置";
  125. break;
  126. case 'search':
  127. $tt = "搜索";
  128. break;
  129. default:
  130. $tt = "保存";
  131. break;
  132. }
  133. if ($wintype != "") {
  134. if ($wintype != "hand") {
  135. $this->myWin .= "<div class='text-center'>
  136. <button type='submit' class='btn btn-success btn-sm'>$tt</button>
  137. <button type='button' class='btn btn-outline-success btn-sm' onclick='javascript:history.go(-1);'>返回</button>
  138. </div>";
  139. } else {
  140. if ($msg != "") {
  141. $this->myWin .= "<div class='mb-3'>$msg</div>
  142. <div class='text-center'>
  143. <button type='button' class='btn btn-success btn-sm' onclick='javascript:history.go(-1);'>返回</button></td>
  144. </div>";
  145. } else {
  146. $this->myWin .= '';
  147. }
  148. }
  149. }
  150. $this->CloseWin($isform);
  151. return $this->myWin;
  152. }
  153. /**
  154. * 显示页面
  155. *
  156. * @access public
  157. * @param string $modfile 模型模板
  158. * @return string
  159. */
  160. function Display($modfile = "")
  161. {
  162. global $cfg_member_dir, $wintitle, $cfg_basedir;
  163. if (empty($wintitle)) {
  164. $wintitle = "提示对话框";
  165. }
  166. $ctp = new DedeTagParse();
  167. if ($modfile == '') {
  168. $ctp->LoadTemplate($cfg_basedir.$cfg_member_dir.'/templets/win_templet.htm');
  169. } else {
  170. $ctp->LoadTemplate($modfile);
  171. }
  172. $emnum = $ctp->Count;
  173. for ($i = 0; $i <= $emnum; $i++) {
  174. if (isset($GLOBALS[$ctp->CTags[$i]->GetTagName()])) {
  175. $ctp->Assign($i, $GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  176. }
  177. }
  178. $ctp->Display();
  179. $ctp->Clear();
  180. }
  181. }
  182. /**
  183. * 显示一个不带表单的普通提示
  184. *
  185. * @access public
  186. * @param string $msg 提示信息
  187. * @param string $title 提示标题
  188. * @return string
  189. */
  190. function ShowMsgWin($msg, $title)
  191. {
  192. $win = new WebWindow();
  193. $win->Init();
  194. $win->mainTitle = "系统提示";
  195. $win->AddTitle($title);
  196. $win->AddMsgItem($msg);
  197. $winform = $win->GetWindow("hand");
  198. $win->Display();
  199. }
  200. ?>