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

234 lines
6.7KB

  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. class OxWindow
  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 = "js/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' method='$formmethod' onSubmit='return CheckSubmit();' action='$formaction'>";
  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 .= "<table width='100%'>";
  63. }
  64. /**
  65. * 添加单列的标题
  66. *
  67. * @access public
  68. * @param string $title 标题
  69. * @param string $col 列数
  70. * @return string
  71. */
  72. function AddTitle($title, $col = "2")
  73. {
  74. if ($col != "" && $col != "0") {
  75. $colspan = "colspan='$col'";
  76. } else {
  77. $colspan = "";
  78. }
  79. $this->myWinItem .= "<tr>";
  80. $this->myWinItem .= "<td $colspan>$title</td>";
  81. $this->myWinItem .= "</tr>";
  82. }
  83. /**
  84. * 添加单列的消息
  85. *
  86. * @access public
  87. * @param string $ivalue 消息行
  88. * @param string $col 列数
  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 string
  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 .= "</table>";
  120. } else {
  121. $this->myWin .= "</table></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 bgcolor='#f5f5f5' 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='history.go(-1);'>返回</button>
  174. </td>
  175. </tr>";
  176. } else {
  177. if ($msg != '') {
  178. $this->myWin .= "<tr><td>$msg</td></tr>";
  179. } else {
  180. $this->myWin .= '';
  181. }
  182. }
  183. }
  184. $this->CloseWin($isform);
  185. return $this->myWin;
  186. }
  187. /**
  188. * 显示页面
  189. *
  190. * @access public
  191. * @param string $modfile 模型模板
  192. * @return string
  193. */
  194. function Display($modfile = "")
  195. {
  196. global $cfg_templets_dir, $wecome_info, $cfg_basedir;
  197. if (empty($wecome_info)) {
  198. $wecome_info = "提示对话框";
  199. }
  200. $ctp = new DedeTagParse();
  201. if ($modfile == '') {
  202. $ctp->LoadTemplate($cfg_basedir.$cfg_templets_dir.'/apps/win_templet.htm');
  203. } else {
  204. $ctp->LoadTemplate($modfile);
  205. }
  206. $emnum = $ctp->Count;
  207. for ($i = 0; $i <= $emnum; $i++) {
  208. if (isset($GLOBALS[$ctp->CTags[$i]->GetTagName()])) {
  209. $ctp->Assign($i, $GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  210. }
  211. }
  212. $ctp->Display();
  213. $ctp->Clear();
  214. }
  215. }//End Class
  216. /**
  217. * 显示一个不带表单的普通提示
  218. *
  219. * @access public
  220. * @param string $msg 消息提示信息
  221. * @param string $title 提示标题
  222. * @return string
  223. */
  224. function ShowMsgWin($msg, $title)
  225. {
  226. $win = new OxWindow();
  227. $win->Init();
  228. $win->mainTitle = "系统提示";
  229. $win->AddTitle($title);
  230. $win->AddMsgItem("$msg");
  231. $winform = $win->GetWindow("hand");
  232. $win->Display();
  233. }
  234. ?>