国内流行的内容管理系统(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.

220 lines
6.2KB

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