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

255 lines
7.3KB

  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 .Libraries
  8. * @copyright Copyright (c) 2022, .COM
  9. * @license https://www..com/license
  10. * @link https://www..com
  11. */
  12. require_once(DEDEINC."/dedetag.class.php");
  13. /**
  14. * 提示窗口对话框类
  15. *
  16. * @package OxWindow
  17. * @subpackage .Libraries
  18. * @link https://www..com
  19. */
  20. class OxWindow
  21. {
  22. var $myWin = "";
  23. var $myWinItem = "";
  24. var $checkCode = "";
  25. var $formName = "";
  26. var $tmpCode = "//checkcode";
  27. var $hasStart = false;
  28. /**
  29. * 初始化为含表单的页面
  30. *
  31. * @param string $formaction 表单操作action
  32. * @param string $checkScript 检测验证js
  33. * @param string $formmethod 表单类型
  34. * @param string $formname 表单名称
  35. * @return void
  36. */
  37. function Init($formaction = "", $checkScript = "js/blank.js", $formmethod = "POST", $formname = "myform")
  38. {
  39. $this->myWin .= "<script>";
  40. if ($checkScript != "" && file_exists($checkScript)) {
  41. $fp = fopen($checkScript, "r");
  42. $this->myWin .= fread($fp, filesize($checkScript));
  43. fclose($fp);
  44. } else {
  45. $this->myWin .= "<!--function CheckSubmit(){return true;}-->";
  46. }
  47. $this->myWin .= "</script>";
  48. $this->formName = $formname;
  49. $this->myWin .= "<form name='$formname' method='$formmethod' onSubmit='return CheckSubmit();' action='$formaction'>";
  50. }
  51. /**
  52. * 添加隐藏域
  53. *
  54. * @param string $iname 隐藏域名称
  55. * @param string $ivalue 隐藏域值
  56. * @return void
  57. */
  58. function AddHidden($iname, $ivalue)
  59. {
  60. $this->myWin .= "<input type='hidden' name='$iname' value='$ivalue'>";
  61. }
  62. /**
  63. * 开始创建窗口
  64. *
  65. * @return void
  66. */
  67. function StartWin()
  68. {
  69. $this->myWin .= "<table width='100%' cellpadding='1' cellspacing='1'>";
  70. }
  71. /**
  72. * 添加一个两列的行
  73. *
  74. * @access public
  75. * @param string $iname 名称
  76. * @param string $ivalue 值
  77. * @return string
  78. */
  79. function AddItem($iname, $ivalue)
  80. {
  81. $this->myWinItem .= "<tr>";
  82. $this->myWinItem .= "<td width='260'>$iname</td>";
  83. $this->myWinItem .= "<td>$ivalue</td>";
  84. $this->myWinItem .= "</tr>";
  85. }
  86. /**
  87. * 添加一个单列的消息行
  88. *
  89. * @access public
  90. * @param string $ivalue 短消息值
  91. * @param string $height 消息框高度
  92. * @param string $col 显示列数
  93. * @return void
  94. */
  95. function AddMsgItem($ivalue, $height = "auto", $col = "2")
  96. {
  97. if ($height != "" && $height != "0") {
  98. $height = " height='$height'";
  99. } else {
  100. $height = "";
  101. }
  102. if ($col != "" && $col != 0) {
  103. $colspan = "colspan='$col'";
  104. } else {
  105. $colspan = "";
  106. }
  107. $this->myWinItem .= "<tr>";
  108. $this->myWinItem .= "<td $colspan $height>$ivalue</td>";
  109. $this->myWinItem .= "</tr>";
  110. }
  111. /**
  112. * 添加单列的标题行
  113. *
  114. * @access public
  115. * @param string $title 标题
  116. * @param string $col 列
  117. * @return string
  118. */
  119. function AddTitle($title, $col = "2")
  120. {
  121. global $cfg_static_dir;
  122. if ($col != "" && $col != "0") {
  123. $colspan = "colspan='$col'";
  124. } else {
  125. $colspan = "";
  126. }
  127. $this->myWinItem .= "<tr>";
  128. $this->myWinItem .= "<td $colspan>$title</td>";
  129. $this->myWinItem .= "</tr>";
  130. }
  131. /**
  132. * 结束Window
  133. *
  134. * @param bool $isform
  135. * @return void
  136. */
  137. function CloseWin($isform = true)
  138. {
  139. if (!$isform) {
  140. $this->myWin .= "</table>";
  141. } else {
  142. $this->myWin .= "</table></form>";
  143. }
  144. }
  145. /**
  146. * 添加自定义JS脚本
  147. *
  148. * @param string $scripts
  149. * @return void
  150. */
  151. function SetCheckScript($scripts)
  152. {
  153. $pos = strpos($this->myWin, $this->tmpCode);
  154. if ($pos > 0) {
  155. $this->myWin = substr_replace($this->myWin, $scripts, $pos, strlen($this->tmpCode));
  156. }
  157. }
  158. /**
  159. * 获取窗口
  160. *
  161. * @param string $wintype 菜单类型
  162. * @param string $msg 短消息
  163. * @param bool $isform 是否是表单
  164. * @return string
  165. */
  166. function GetWindow($wintype = "save", $msg = "", $isform = true)
  167. {
  168. global $cfg_static_dir;
  169. $this->StartWin();
  170. $this->myWin .= $this->myWinItem;
  171. $tt = "";
  172. switch ($wintype) {
  173. case 'back':
  174. $tt = "返回";
  175. break;
  176. case 'ok':
  177. $tt = "确定";
  178. break;
  179. case 'reset':
  180. $tt = "重置";
  181. break;
  182. case 'search':
  183. $tt = "搜索";
  184. break;
  185. default:
  186. $tt = "保存";
  187. break;
  188. }
  189. if ($wintype != "") {
  190. if ($wintype != "hand") {
  191. $this->myWin .= "<tr>
  192. <td colspan='2' align='center'>
  193. <button type='submit' class='btn btn-success btn-sm'>$tt</button>
  194. <button type='button' class='btn btn-outline-success btn-sm' onClick='history.go(-1);'>返回</button>
  195. </td>
  196. </tr>";
  197. } else {
  198. if ($msg != '') {
  199. $this->myWin .= "<tr><td>$msg</td></tr>";
  200. } else {
  201. $this->myWin .= '';
  202. }
  203. }
  204. }
  205. $this->CloseWin($isform);
  206. return $this->myWin;
  207. }
  208. /**
  209. * 显示页面
  210. *
  211. * @access public
  212. * @param string $modfile 模型模板
  213. * @return string
  214. */
  215. function Display($modfile = "")
  216. {
  217. global $cfg_templets_dir, $wecome_info, $cfg_basedir;
  218. if (empty($wecome_info)) {
  219. $wecome_info = "通用对话框";
  220. }
  221. $ctp = new DedeTagParse();
  222. if ($modfile == '') {
  223. $ctp->LoadTemplate($cfg_basedir.$cfg_templets_dir.'/plus/win_templet.htm');
  224. } else {
  225. $ctp->LoadTemplate($modfile);
  226. }
  227. $emnum = $ctp->Count;
  228. for ($i = 0; $i <= $emnum; $i++) {
  229. if (isset($GLOBALS[$ctp->CTags[$i]->GetTagName()])) {
  230. $ctp->Assign($i, $GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  231. }
  232. }
  233. $ctp->Display();
  234. $ctp->Clear();
  235. }
  236. }//End Class
  237. /**
  238. * 显示一个不带表单的普通提示
  239. *
  240. * @access public
  241. * @param string $msg 消息提示信息
  242. * @param string $title 提示标题
  243. * @return string
  244. */
  245. function ShowMsgWin($msg, $title)
  246. {
  247. $win = new OxWindow();
  248. $win->Init();
  249. $win->mainTitle = "系统提示";
  250. $win->AddTitle($title);
  251. $win->AddMsgItem("$msg");
  252. $winform = $win->GetWindow("hand");
  253. $win->Display();
  254. }
  255. ?>