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

301 lines
8.2KB

  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 DedeCMS.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 DedeCMS.Libraries
  17. * @link http://www.dedecms.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. {
  41. $fp = fopen($checkScript,"r");
  42. $this->myWin .= fread($fp,filesize($checkScript));
  43. fclose($fp);
  44. }
  45. else
  46. {
  47. $this->myWin .= "<!-- function CheckSubmit()\r\n{ return true; } -->";
  48. }
  49. $this->myWin .= "</script>\r\n";
  50. $this->formName = $formname;
  51. $this->myWin .= "<form name='$formname' method='$formmethod' onSubmit='return CheckSubmit();' action='$formaction'>\r\n";
  52. }
  53. //
  54. /**
  55. * 增加隐藏域
  56. *
  57. * @param string $iname 隐藏域名称
  58. * @param string $ivalue 隐藏域值
  59. * @return void
  60. */
  61. function AddHidden($iname,$ivalue)
  62. {
  63. $this->myWin .= "<input type='hidden' name='$iname' value='$ivalue'>\r\n";
  64. }
  65. /**
  66. * 开始创建窗口
  67. *
  68. * @return void
  69. */
  70. function StartWin()
  71. {
  72. $this->myWin .= "<table width='100%' border='0' cellpadding='3' cellspacing='1' bgcolor='#DADADA'>\r\n";
  73. }
  74. /**
  75. * 增加一个两列的行
  76. *
  77. * @access public
  78. * @param string $iname 名称
  79. * @param string $ivalue 值
  80. * @return string
  81. */
  82. function AddItem($iname, $ivalue)
  83. {
  84. $this->myWinItem .= "<tr bgcolor='#FFFFFF'>\r\n";
  85. $this->myWinItem .= "<td width='25%'>$iname</td>\r\n";
  86. $this->myWinItem .= "<td width='75%'>$ivalue</td>\r\n";
  87. $this->myWinItem .= "</tr>\r\n";
  88. }
  89. /**
  90. * 增加一个单列的消息行
  91. *
  92. * @access public
  93. * @param string $ivalue 短消息值
  94. * @param string $height 消息框高度
  95. * @param string $col 显示列数
  96. * @return void
  97. */
  98. function AddMsgItem($ivalue, $height="auto", $col="2")
  99. {
  100. if($height!=""&&$height!="0")
  101. {
  102. $height = " height='$height'";
  103. }
  104. else
  105. {
  106. $height="";
  107. }
  108. if($col!=""&&$col!=0)
  109. {
  110. $colspan="colspan='$col'";
  111. }
  112. else
  113. {
  114. $colspan="";
  115. }
  116. $this->myWinItem .= "<tr bgcolor='#FFFFFF'>\r\n";
  117. $this->myWinItem .= "<td $colspan $height> $ivalue </td>\r\n";
  118. $this->myWinItem .= "</tr>\r\n";
  119. }
  120. /**
  121. * 增加单列的标题行
  122. *
  123. * @access public
  124. * @param string $title 标题
  125. * @param string $col 列
  126. * @return string
  127. */
  128. function AddTitle($title, $col="2")
  129. {
  130. global $cfg_static_dir;
  131. if($col!=""&&$col!="0")
  132. {
  133. $colspan="colspan='$col'";
  134. }
  135. else
  136. {
  137. $colspan="";
  138. }
  139. $this->myWinItem .= "<tr bgcolor='#DADADA'>\r\n";
  140. $this->myWinItem .= "<td $colspan background='{$cfg_static_dir}/img/wbg.gif' height='26'><font color='#666600'><b>$title</b></font></td>\r\n";
  141. $this->myWinItem .= "</tr>\r\n";
  142. }
  143. /**
  144. * 结束Window
  145. *
  146. * @param bool $isform
  147. * @return void
  148. */
  149. function CloseWin($isform=true)
  150. {
  151. if(!$isform)
  152. {
  153. $this->myWin .= "</table>\r\n";
  154. }
  155. else
  156. {
  157. $this->myWin .= "</table></form>\r\n";
  158. }
  159. }
  160. /**
  161. * 增加自定义JS脚本
  162. *
  163. * @param string $scripts
  164. * @return void
  165. */
  166. function SetCheckScript($scripts)
  167. {
  168. $pos = strpos($this->myWin,$this->tmpCode);
  169. if($pos > 0)
  170. {
  171. $this->myWin = substr_replace($this->myWin,$scripts,$pos,strlen($this->tmpCode));
  172. }
  173. }
  174. /**
  175. * 获取窗口
  176. *
  177. * @param string $wintype 菜单类型
  178. * @param string $msg 短消息
  179. * @param bool $isform 是否是表单
  180. * @return string
  181. */
  182. function GetWindow($wintype="save", $msg="", $isform=true)
  183. {
  184. global $cfg_static_dir;
  185. $this->StartWin();
  186. $this->myWin .= $this->myWinItem;
  187. $tt = "";
  188. switch ($wintype) {
  189. case 'back':
  190. $tt = "返回";
  191. break;
  192. case 'ok':
  193. $tt = "确定";
  194. break;
  195. case 'reset':
  196. $tt = "重置";
  197. break;
  198. case 'search':
  199. $tt = "搜索";
  200. break;
  201. default:
  202. $tt = "保存";
  203. break;
  204. }
  205. if($wintype!="")
  206. {
  207. if($wintype!="hand")
  208. {
  209. $this->myWin .= "
  210. <tr>
  211. <td colspan='2' bgcolor='#F9FCEF'>
  212. <table width='270' border='0' cellpadding='0' cellspacing='0'>
  213. <tr align='center' height='28'>
  214. <td width='90'><button type='submit' class='btn btn-secondary'>$tt</button></td>
  215. <td width='90'><button onClick='this.form.reset();return false;' type='button' class='btn btn-secondary'>重置</button></td>
  216. <td><button onClick='history.go(-1);' type='button' class='btn btn-secondary'>返回</button></td>
  217. </tr>
  218. </table>
  219. </td>
  220. </tr>";
  221. }
  222. else
  223. {
  224. if($msg!='')
  225. {
  226. $this->myWin .= "<tr><td bgcolor='#F5F5F5'>$msg</td></tr>";
  227. }
  228. else
  229. {
  230. $this->myWin .= '';
  231. }
  232. }
  233. }
  234. $this->CloseWin($isform);
  235. return $this->myWin;
  236. }
  237. /**
  238. * 显示页面
  239. *
  240. * @access public
  241. * @param string $modfile 模型模板
  242. * @return string
  243. */
  244. function Display($modfile="")
  245. {
  246. global $cfg_templets_dir,$wecome_info,$cfg_basedir;
  247. if(empty($wecome_info))
  248. {
  249. $wecome_info = "DedeCMS OX 通用对话框:";
  250. }
  251. $ctp = new DedeTagParse();
  252. if($modfile=='')
  253. {
  254. $ctp->LoadTemplate($cfg_basedir.$cfg_templets_dir.'/plus/win_templet.htm');
  255. }
  256. else
  257. {
  258. $ctp->LoadTemplate($modfile);
  259. }
  260. $emnum = $ctp->Count;
  261. for($i=0;$i<=$emnum;$i++)
  262. {
  263. if(isset($GLOBALS[$ctp->CTags[$i]->GetTagName()]))
  264. {
  265. $ctp->Assign($i,$GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  266. }
  267. }
  268. $ctp->Display();
  269. $ctp->Clear();
  270. }
  271. } //End Class
  272. /**
  273. * 显示一个不带表单的普通提示
  274. *
  275. * @access public
  276. * @param string $msg 消息提示信息
  277. * @param string $title 提示标题
  278. * @return string
  279. */
  280. function ShowMsgWin($msg, $title)
  281. {
  282. $win = new OxWindow();
  283. $win->Init();
  284. $win->mainTitle = "DedeCMS系统提示:";
  285. $win->AddTitle($title);
  286. $win->AddMsgItem("<div style='padding-left:20px;line-height:150%'>$msg</div>");
  287. $winform = $win->GetWindow("hand");
  288. $win->Display();
  289. }