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

283 lines
7.9KB

  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) 2007 - 2020, DesDev, Inc.
  8. * @license http://help.dedecms.com/usersguide/license.html
  9. * @link http://www.dedecms.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="100", $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. if($wintype!="")
  188. {
  189. if($wintype!="hand")
  190. {
  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'><input name='imageField1' type='image' class='np' src='{$cfg_static_dir}/img/button_".$wintype.".gif' width='60' height='22' border='0' /></td>
  197. <td width='90'><a href='#'><img class='np' src='{$cfg_static_dir}/img/button_reset.gif' width='60' height='22' border='0' onClick='this.form.reset();return false;' /></a></td>
  198. <td><a href='#'><img src='{$cfg_static_dir}/img/button_back.gif' width='60' height='22' border='0' onClick='history.go(-1);' /></a></td>
  199. </tr>
  200. </table>
  201. </td>
  202. </tr>";
  203. }
  204. else
  205. {
  206. if($msg!='')
  207. {
  208. $this->myWin .= "<tr><td bgcolor='#F5F5F5'>$msg</td></tr>";
  209. }
  210. else
  211. {
  212. $this->myWin .= '';
  213. }
  214. }
  215. }
  216. $this->CloseWin($isform);
  217. return $this->myWin;
  218. }
  219. /**
  220. * 显示页面
  221. *
  222. * @access public
  223. * @param string $modfile 模型模板
  224. * @return string
  225. */
  226. function Display($modfile="")
  227. {
  228. global $cfg_templets_dir,$wecome_info,$cfg_basedir;
  229. if(empty($wecome_info))
  230. {
  231. $wecome_info = "DedeCMS OX 通用对话框:";
  232. }
  233. $ctp = new DedeTagParse();
  234. if($modfile=='')
  235. {
  236. $ctp->LoadTemplate($cfg_basedir.$cfg_templets_dir.'/plus/win_templet.htm');
  237. }
  238. else
  239. {
  240. $ctp->LoadTemplate($modfile);
  241. }
  242. $emnum = $ctp->Count;
  243. for($i=0;$i<=$emnum;$i++)
  244. {
  245. if(isset($GLOBALS[$ctp->CTags[$i]->GetTagName()]))
  246. {
  247. $ctp->Assign($i,$GLOBALS[$ctp->CTags[$i]->GetTagName()]);
  248. }
  249. }
  250. $ctp->Display();
  251. $ctp->Clear();
  252. }
  253. } //End Class
  254. /**
  255. * 显示一个不带表单的普通提示
  256. *
  257. * @access public
  258. * @param string $msg 消息提示信息
  259. * @param string $title 提示标题
  260. * @return string
  261. */
  262. function ShowMsgWin($msg, $title)
  263. {
  264. $win = new OxWindow();
  265. $win->Init();
  266. $win->mainTitle = "DeDeCMS系统提示:";
  267. $win->AddTitle($title);
  268. $win->AddMsgItem("<div style='padding-left:20px;line-height:150%'>$msg</div>");
  269. $winform = $win->GetWindow("hand");
  270. $win->Display();
  271. }