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

273 lines
8.0KB

  1. <?php if (!defined('DEDEINC')) exit("Request Error!");
  2. /**
  3. * 提示窗口对话框类
  4. *
  5. * @version $Id: oxwindow.class.php 2 13:53 2010-11-11 tianya $
  6. * @package DedeBIZ.Libraries
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(DEDEINC . "/dedetag.class.php");
  12. /**
  13. * 提示窗口对话框类
  14. *
  15. * @package OxWindow
  16. * @subpackage DedeBIZ.Libraries
  17. * @link https://www.dedebiz.com
  18. */
  19. class OxWindow
  20. {
  21. var $myWin = "";
  22. var $myWinItem = "";
  23. var $checkCode = "";
  24. var $formName = "";
  25. var $tmpCode = "//checkcode";
  26. var $hasStart = false;
  27. /**
  28. * 初始化为含表单的页面
  29. *
  30. * @param string $formaction 表单操作action
  31. * @param string $checkScript 检测验证js
  32. * @param string $formmethod 表单类型
  33. * @param string $formname 表单名称
  34. * @return void
  35. */
  36. function Init($formaction = "", $checkScript = "js/blank.js", $formmethod = "POST", $formname = "myform")
  37. {
  38. $this->myWin .= "<script language='javascript'>\r\n";
  39. if ($checkScript != "" && file_exists($checkScript)) {
  40. $fp = fopen($checkScript, "r");
  41. $this->myWin .= fread($fp, filesize($checkScript));
  42. fclose($fp);
  43. } else {
  44. $this->myWin .= "<!-- function CheckSubmit()\r\n{ return true; } -->";
  45. }
  46. $this->myWin .= "</script>\r\n";
  47. $this->formName = $formname;
  48. $this->myWin .= "<form name='$formname' method='$formmethod' onSubmit='return CheckSubmit();' action='$formaction'>\r\n";
  49. }
  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' bgcolor='#DADADA'>\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 bgcolor='#DADADA'>\r\n";
  128. $this->myWinItem .= "<td $colspan background='{$cfg_static_dir}/img/wbg.gif' height='26'><font color='#666600'><b>$title</b></font></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' bgcolor='#F9FCEF'>
  194. <table width='270' border='0' cellpadding='0' cellspacing='0'>
  195. <tr align='center' height='28'>
  196. <td width='90'><button type='submit' class='btn btn-secondary'>$tt</button></td>
  197. <td width='90'><button onClick='this.form.reset();return false;' type='button' class='btn btn-secondary'>重置</button></td>
  198. <td><button onClick='history.go(-1);' type='button' class='btn btn-secondary'>返回</button></td>
  199. </tr>
  200. </table>
  201. </td>
  202. </tr>";
  203. } else {
  204. if ($msg != '') {
  205. $this->myWin .= "<tr><td bgcolor='#F5F5F5'>$msg</td></tr>";
  206. } else {
  207. $this->myWin .= '';
  208. }
  209. }
  210. }
  211. $this->CloseWin($isform);
  212. return $this->myWin;
  213. }
  214. /**
  215. * 显示页面
  216. *
  217. * @access public
  218. * @param string $modfile 模型模板
  219. * @return string
  220. */
  221. function Display($modfile = "")
  222. {
  223. global $cfg_templets_dir, $wecome_info, $cfg_basedir;
  224. if (empty($wecome_info)) {
  225. $wecome_info = "DedeBIZ OX 通用对话框:";
  226. }
  227. $ctp = new DedeTagParse();
  228. if ($modfile == '') {
  229. $ctp->LoadTemplate($cfg_basedir . $cfg_templets_dir . '/plus/win_templet.htm');
  230. } else {
  231. $ctp->LoadTemplate($modfile);
  232. }
  233. $emnum = $ctp->Count;
  234. for ($i = 0; $i <= $emnum; $i++) {
  235. if (isset($GLOBALS[$ctp->CTags[$i]->GetTagName()])) {
  236. $ctp->Assign($i, $GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  237. }
  238. }
  239. $ctp->Display();
  240. $ctp->Clear();
  241. }
  242. } //End Class
  243. /**
  244. * 显示一个不带表单的普通提示
  245. *
  246. * @access public
  247. * @param string $msg 消息提示信息
  248. * @param string $title 提示标题
  249. * @return string
  250. */
  251. function ShowMsgWin($msg, $title)
  252. {
  253. $win = new OxWindow();
  254. $win->Init();
  255. $win->mainTitle = "DedeBIZ系统提示:";
  256. $win->AddTitle($title);
  257. $win->AddMsgItem("<div style='padding-left:20px;line-height:150%'>$msg</div>");
  258. $winform = $win->GetWindow("hand");
  259. $win->Display();
  260. }