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

  1. <?php
  2. if (!defined('DEDEINC')) exit("Request Error!");
  3. /**
  4. * 提示窗口对话框类
  5. *
  6. * @version $Id: oxwindow.class.php 2 13:53 2010-11-11 tianya $
  7. * @package .Libraries
  8. * @copyright Copyright (c) 2021, .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 language='javascript'>\r\n";
  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()\r\n{ return true; } -->";
  46. }
  47. $this->myWin .= "</script>\r\n";
  48. $this->formName = $formname;
  49. $this->myWin .= "<form name='$formname' method='$formmethod' onSubmit='return CheckSubmit();' action='$formaction'>\r\n";
  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'>\r\n";
  61. }
  62. /**
  63. * 开始创建窗口
  64. *
  65. * @return void
  66. */
  67. function StartWin()
  68. {
  69. $this->myWin .= "<table width='100%' border='0' cellpadding='3' cellspacing='1'>\r\n";
  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 bgcolor='#FFFFFF'>\r\n";
  82. $this->myWinItem .= "<td width='25%'>$iname</td>\r\n";
  83. $this->myWinItem .= "<td width='75%'>$ivalue</td>\r\n";
  84. $this->myWinItem .= "</tr>\r\n";
  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 bgcolor='#FFFFFF'>\r\n";
  108. $this->myWinItem .= "<td $colspan $height> $ivalue </td>\r\n";
  109. $this->myWinItem .= "</tr>\r\n";
  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>\r\n";
  128. $this->myWinItem .= "<td $colspan height='26'>$title</td>\r\n";
  129. $this->myWinItem .= "</tr>\r\n";
  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>\r\n";
  141. } else {
  142. $this->myWin .= "</table></form>\r\n";
  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' height='30'>
  194. <button type='submit' class='btn btn-success'>$tt</button>&nbsp;&nbsp;
  195. <button type='button' class='btn btn-success' onClick='this.form.reset();return false;'>重置</button>&nbsp;&nbsp;
  196. <button type='button' class='btn btn-success' onClick='history.go(-1);'>返回</button>
  197. </td>
  198. </tr>";
  199. } else {
  200. if ($msg != '') {
  201. $this->myWin .= "<tr><td>$msg</td></tr>";
  202. } else {
  203. $this->myWin .= '';
  204. }
  205. }
  206. }
  207. $this->CloseWin($isform);
  208. return $this->myWin;
  209. }
  210. /**
  211. * 显示页面
  212. *
  213. * @access public
  214. * @param string $modfile 模型模板
  215. * @return string
  216. */
  217. function Display($modfile = "")
  218. {
  219. global $cfg_templets_dir, $wecome_info, $cfg_basedir;
  220. if (empty($wecome_info)) {
  221. $wecome_info = "通用对话框:";
  222. }
  223. $ctp = new DedeTagParse();
  224. if ($modfile == '') {
  225. $ctp->LoadTemplate($cfg_basedir . $cfg_templets_dir . '/plus/win_templet.htm');
  226. } else {
  227. $ctp->LoadTemplate($modfile);
  228. }
  229. $emnum = $ctp->Count;
  230. for ($i = 0; $i <= $emnum; $i++) {
  231. if (isset($GLOBALS[$ctp->CTags[$i]->GetTagName()])) {
  232. $ctp->Assign($i, $GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  233. }
  234. }
  235. $ctp->Display();
  236. $ctp->Clear();
  237. }
  238. }//End Class
  239. /**
  240. * 显示一个不带表单的普通提示
  241. *
  242. * @access public
  243. * @param string $msg 消息提示信息
  244. * @param string $title 提示标题
  245. * @return string
  246. */
  247. function ShowMsgWin($msg, $title)
  248. {
  249. $win = new OxWindow();
  250. $win->Init();
  251. $win->mainTitle = "系统提示:";
  252. $win->AddTitle($title);
  253. $win->AddMsgItem("<div style='padding-left:20px;line-height:150%'>$msg</div>");
  254. $winform = $win->GetWindow("hand");
  255. $win->Display();
  256. }