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

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