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

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