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

256 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='3' 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 .= "
  192. <tr>
  193. <td colspan='2' align='center'>
  194. <button type='submit' class='btn btn-success btn-sm'>$tt</button>
  195. <button type='button' class='btn btn-outline-success btn-sm' onClick='history.go(-1);'>返回</button>
  196. </td>
  197. </tr>";
  198. } else {
  199. if ($msg != '') {
  200. $this->myWin .= "<tr><td>$msg</td></tr>";
  201. } else {
  202. $this->myWin .= '';
  203. }
  204. }
  205. }
  206. $this->CloseWin($isform);
  207. return $this->myWin;
  208. }
  209. /**
  210. * 显示页面
  211. *
  212. * @access public
  213. * @param string $modfile 模型模板
  214. * @return string
  215. */
  216. function Display($modfile = "")
  217. {
  218. global $cfg_templets_dir, $wecome_info, $cfg_basedir;
  219. if (empty($wecome_info)) {
  220. $wecome_info = "通用对话框";
  221. }
  222. $ctp = new DedeTagParse();
  223. if ($modfile == '') {
  224. $ctp->LoadTemplate($cfg_basedir.$cfg_templets_dir.'/plus/win_templet.htm');
  225. } else {
  226. $ctp->LoadTemplate($modfile);
  227. }
  228. $emnum = $ctp->Count;
  229. for ($i = 0; $i <= $emnum; $i++) {
  230. if (isset($GLOBALS[$ctp->CTags[$i]->GetTagName()])) {
  231. $ctp->Assign($i, $GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  232. }
  233. }
  234. $ctp->Display();
  235. $ctp->Clear();
  236. }
  237. }//End Class
  238. /**
  239. * 显示一个不带表单的普通提示
  240. *
  241. * @access public
  242. * @param string $msg 消息提示信息
  243. * @param string $title 提示标题
  244. * @return string
  245. */
  246. function ShowMsgWin($msg, $title)
  247. {
  248. $win = new OxWindow();
  249. $win->Init();
  250. $win->mainTitle = "系统提示";
  251. $win->AddTitle($title);
  252. $win->AddMsgItem("$msg");
  253. $winform = $win->GetWindow("hand");
  254. $win->Display();
  255. }
  256. ?>