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

238 lines
6.9KB

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