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

239 line
7.0KB

  1. <?php
  2. if (!defined('DEDEINC')) exit('dedebiz');
  3. /**
  4. * 后台提示对话框
  5. *
  6. * @version $id:oxwindow.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 OxWindow
  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'><table class='table table-borderless'><tbody>";
  64. }
  65. /**
  66. * 添加单列标题
  67. *
  68. * @access public
  69. * @param string $title 标题
  70. * @param string $col 列
  71. * @return void
  72. */
  73. function AddTitle($title, $col = "2")
  74. {
  75. if ($col != "" && $col != "0") {
  76. $colspan = "colspan='$col'";
  77. } else {
  78. $colspan = '';
  79. }
  80. $this->myWinItem .= "<tr>";
  81. $this->myWinItem .= "<td $colspan>$title</td>";
  82. $this->myWinItem .= "</tr>";
  83. }
  84. /**
  85. * 添加单列信息
  86. *
  87. * @access public
  88. * @param string $ivalue 信息
  89. * @return void
  90. */
  91. function AddMsgItem($ivalue)
  92. {
  93. $this->myWinItem .= $ivalue;
  94. }
  95. /**
  96. * 添加两列信息
  97. *
  98. * @access public
  99. * @param string $iname 名称
  100. * @param string $ivalue 值
  101. * @return void
  102. */
  103. function AddItem($iname, $ivalue)
  104. {
  105. $this->myWinItem .= "<tr>";
  106. $this->myWinItem .= "<td width='260'>$iname</td>";
  107. $this->myWinItem .= "<td>$ivalue</td>";
  108. $this->myWinItem .= "</tr>";
  109. }
  110. /**
  111. * 结束窗口
  112. *
  113. * @param bool $isform
  114. * @return void
  115. */
  116. function CloseWin($isform = true)
  117. {
  118. if (!$isform) {
  119. $this->myWin .= "</tbody></table></div>";
  120. } else {
  121. $this->myWin .= "</tbody></table></div></form>";
  122. }
  123. }
  124. /**
  125. * 添加自定义脚本
  126. *
  127. * @param string $scripts
  128. * @return void
  129. */
  130. function SetCheckScript($scripts)
  131. {
  132. $pos = strpos($this->myWin, $this->tmpCode);
  133. if ($pos > 0) {
  134. $this->myWin = substr_replace($this->myWin, $scripts, $pos, strlen($this->tmpCode));
  135. }
  136. }
  137. /**
  138. * 获取窗口
  139. *
  140. * @param string $wintype 菜单类型
  141. * @param string $msg 短消息
  142. * @param bool $isform 是否是表单
  143. * @return string
  144. */
  145. function GetWindow($wintype = "save", $msg = "", $isform = true)
  146. {
  147. global $cfg_static_dir;
  148. $this->StartWin();
  149. $this->myWin .= $this->myWinItem;
  150. $tt = '';
  151. switch ($wintype) {
  152. case 'back':
  153. $tt = "返回";
  154. break;
  155. case 'ok':
  156. $tt = "确定";
  157. break;
  158. case 'reset':
  159. $tt = "重置";
  160. break;
  161. case 'search':
  162. $tt = "搜索";
  163. break;
  164. default:
  165. $tt = "保存";
  166. break;
  167. }
  168. if ($wintype != "") {
  169. if ($wintype != "hand") {
  170. $this->myWin .= "<tr>
  171. <td colspan='2' align='center'>
  172. <button type='submit' class='btn btn-success btn-sm'>$tt</button>
  173. <button type='button' class='btn btn-outline-success btn-sm' onclick='javascript:history.go(-1);'>返回</button>
  174. </td>
  175. </tr>";
  176. } else {
  177. if ($msg != "") {
  178. $this->myWin .= "<tr>
  179. <td>$msg</td>
  180. </tr>
  181. <tr>
  182. <td colspan='2' align='center'><button type='button' class='btn btn-success btn-sm' onclick='javascript:history.go(-1);'>返回</button></td>
  183. </tr>";
  184. } else {
  185. $this->myWin .= '';
  186. }
  187. }
  188. }
  189. $this->CloseWin($isform);
  190. return $this->myWin;
  191. }
  192. /**
  193. * 显示页面
  194. *
  195. * @access public
  196. * @param string $modfile 模型模板
  197. * @return void
  198. */
  199. function Display($modfile = "")
  200. {
  201. global $cfg_templets_dir, $wintitle, $cfg_basedir;
  202. if (empty($wintitle)) {
  203. $wintitle = "提示对话框";
  204. }
  205. $ctp = new DedeTagParse();
  206. if ($modfile == '') {
  207. $ctp->LoadTemplate($cfg_basedir.$cfg_templets_dir.'/apps/win_templet.htm');
  208. } else {
  209. $ctp->LoadTemplate($modfile);
  210. }
  211. $emnum = $ctp->Count;
  212. for ($i = 0; $i <= $emnum; $i++) {
  213. if (isset($GLOBALS[$ctp->CTags[$i]->GetTagName()])) {
  214. $ctp->Assign($i, $GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  215. }
  216. }
  217. $ctp->Display();
  218. $ctp->Clear();
  219. }
  220. }
  221. /**
  222. * 显示一个不带表单的普通提示
  223. *
  224. * @access public
  225. * @param string $msg 提示信息
  226. * @param string $title 提示标题
  227. * @return void
  228. */
  229. function ShowMsgWin($msg, $title)
  230. {
  231. $win = new OxWindow();
  232. $win->Init();
  233. $win->mainTitle = "系统提示";
  234. $win->AddTitle($title);
  235. $win->AddMsgItem($msg);
  236. $winform = $win->GetWindow("hand");
  237. $win->Display();
  238. }
  239. ?>