“Discuz!X/后台HTML显示函数”的版本间的差异
来自Blueidea
< Discuz!X
1033289127(讨论 | 贡献) (→表单结尾标签显示函数(showsubmenu)) |
1033289127(讨论 | 贡献) |
||
第126行: | 第126行: | ||
//调用表单内容输出完毕后直接调用这个参数即可 | //调用表单内容输出完毕后直接调用这个参数即可 | ||
showformfooter() | showformfooter() | ||
+ | |||
+ | == 按钮显示函数(showformfooter) == | ||
+ | |||
+ | *函数原型 | ||
+ | <syntaxhighlight lang="php"> | ||
+ | function showsubmit($name = '', $value = 'submit', $before = '', $after = '', $floatright = '', $entersubmit = true) { | ||
+ | global $_G; | ||
+ | if(!empty($_G['showsetting_multi'])) { | ||
+ | return; | ||
+ | } | ||
+ | $str = '<tr>'; | ||
+ | $str .= $name && in_array($before, array('del', 'select_all', 'td')) ? '<td class="td25">'.($before != 'td' ? '<input type="checkbox" name="chkall" id="chkall'.($chkkallid = random(4)).'" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'delete\')" /><label for="chkall'.$chkkallid.'">'.cplang($before) : '').'</label></td>' : ''; | ||
+ | $str .= '<td colspan="15">'; | ||
+ | $str .= $floatright ? '<div class="cuspages right">'.$floatright.'</div>' : ''; | ||
+ | $str .= '<div class="fixsel">'; | ||
+ | $str .= $before && !in_array($before, array('del', 'select_all', 'td')) ? $before.' ' : ''; | ||
+ | $str .= $name ? '<input type="submit" class="btn" id="submit_'.$name.'" name="'.$name.'" title="'.($entersubmit ? cplang('submit_tips') : '').'" value="'.cplang($value).'" />' : ''; | ||
+ | $after = $after == 'more_options' ? '<input class="checkbox" type="checkbox" value="1" onclick="$(\'advanceoption\').style.display = $(\'advanceoption\').style.display == \'none\' ? \'\' : \'none\'; this.value = this.value == 1 ? 0 : 1; this.checked = this.value == 1 ? false : true" id="btn_more" /><label for="btn_more">'.cplang('more_options').'</label>' : $after; | ||
+ | $str = $after ? $str.(($before && $before != 'del') || $name ? ' ' : '').$after : $str; | ||
+ | $str .= '</div></td>'; | ||
+ | $str .= '</tr>'; | ||
+ | echo $str.($name && $entersubmit ? '<script type="text/JavaScript">_attachEvent(document.documentElement, \'keydown\', function (e) { entersubmit(e, \''.$name.'\'); });</script>' : ''); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | *参数解释 | ||
+ | $name 按钮名称 | ||
+ | $value 按钮值 | ||
+ | |||
+ | *使用范例 | ||
+ | showsubmit('editsubmit'); |
2011-07-08T11:55:12的版本
discuzx 后台模块开发大多直接调用后台HTML函数输出,使用HTML输出函数更加方便快捷的构建一个后台WEB页面。
目录
- 函数原型
function shownav($header = '', $menu = '', $nav = '') { global $action, $operation; $title = 'cplog_'.$action.($operation ? '_'.$operation : ''); if(in_array($action, array('home', 'custommenu'))) { $customtitle = ''; } elseif(cplang($title, false)) { $customtitle = $title; } elseif(cplang('nav_'.($header ? $header : 'index'), false)) { $customtitle = 'nav_'.$header; } else { $customtitle = rawurlencode($nav ? $nav : ($menu ? $menu : '')); } $title = cplang('header_'.($header ? $header : 'index')).($menu ? ' » '.cplang($menu) : '').($nav ? ' » '.cplang($nav) : ''); $ctitle = cplang('header_'.($header ? $header : 'index')); if($menu) { $ctitle = cplang($menu); } if($nav) { $ctitle = cplang($nav); } $addtomenu = " <a target=\"main\" title=\"".cplang('custommenu_addto')."\" href=\"".ADMINSCRIPT."?action=misc&operation=custommenu&do=add&title=".rawurlencode($ctitle)."&url=".rawurlencode(cpurl())."\">[+]</a>"; $dtitle = str_replace("'", "\'", cplang('admincp_title').' - '.str_replace(' » ', ' - ', $title)); echo '<script type="text/JavaScript">parent.document.title = \''.$dtitle.'\';if(parent.$(\'admincpnav\')) parent.$(\'admincpnav\').innerHTML=\''.$title.$addtomenu.'\';</script>'; }
- 参数解释
$header 导航模块名 $menu 菜单 $nav 当前导航名
- 使用范例
//品网后台导航显示 shownav('pages', 'menu_pages_sortoption');
- 函数原型
function showsubmenu($title, $menus = array(), $right = '', $replace = array()) { if(empty($menus)) { $s = '<div class="itemtitle">'.$right.'<h3>'.cplang($title, $replace).'</h3></div>'; } elseif(is_array($menus)) { $s = '<div class="itemtitle">'.$right.'<h3>'.cplang($title, $replace).'</h3>'; if(is_array($menus)) { $s .= '<ul class="tab1">'; foreach($menus as $k => $menu) { if(is_array($menu[0])) { $s .= '<li id="addjs'.$k.'" class="'.($menu[1] ? 'current' : 'hasdropmenu').'" onmouseover="dropmenu(this);"><a href="#"><span>'.cplang($menu[0]['menu']).'<em> </em></span></a><div id="addjs'.$k.'child" class="dropmenu" style="display:none;">'; if(is_array($menu[0]['submenu'])) { foreach($menu[0]['submenu'] as $submenu) { $s .= $submenu[1] ? '<a href="'.ADMINSCRIPT.'?action='.$submenu[1].'" class="'.($submenu[2] ? 'current' : '').'" onclick="'.$submenu[3].'">'.cplang($submenu[0]).'</a>' : '<a><b>'.cplang($submenu[0]).'</b></a>'; } } $s .= '</div></li>'; } else { $s .= '<li'.($menu[2] ? ' class="current"' : '').'><a href="'.(!$menu[4] ? ADMINSCRIPT.'?action='.$menu[1] : $menu[1]).'"'.(!empty($menu[3]) ? ' target="_blank"' : '').'><span>'.cplang($menu[0]).'</span></a></li>'; } } $s .= '</ul>'; } $s .= '</div>'; } echo !empty($menus) ? '<div class="floattop">'.$s.'</div><div class="floattopempty"></div>' : $s; }
- 参数解释
$title 二级导航标题 $menus 展示的二级菜单(数组)
- 使用范例
showsubmenu('menu_pages_sortoption');
表单头示函数(showformheader)
- 函数原型
function showformheader($action, $extra = '', $name = 'cpform', $method = 'post') { global $_G; $anchor = isset($_G['gp_anchor']) ? htmlspecialchars($_G['gp_anchor']) : ''; echo '<form name="'.$name.'" method="'.$method.'" autocomplete="off" action="'.ADMINSCRIPT.'?action='.$action.'" id="'.$name.'"'.($extra == 'enctype' ? ' enctype="multipart/form-data"' : " $extra").'>'. '<input type="hidden" name="formhash" value="'.FORMHASH.'" />'. '<input type="hidden" id="formscrolltop" name="scrolltop" value="" />'. '<input type="hidden" name="anchor" value="'.$anchor.'" />'; }
- 参数解释
$action 提交页面地址 $extra 表单编码方式指定 $name 表单名称 $method 表单提交方式 例如 post,get 等
- 使用范例
showformheader('pages&operation=sort&do='.$do);
- 函数原型
function showformfooter() { global $_G; if(!empty($_G['setting_JS'])) { echo '<script type="text/JavaScript">'.$_G['setting_JS'].'</script>'; } updatesession(); echo '</form>'."\n"; if($scrolltop = intval(getgpc('scrolltop'))) { echo '<script type="text/JavaScript">_attachEvent(window, \'load\', function () { scroll(0,'.$scrolltop.') }, document);</script>'; } }
- 使用范例
//调用表单内容输出完毕后直接调用这个参数即可 showformfooter()
- 函数原型
function showsubmit($name = '', $value = 'submit', $before = '', $after = '', $floatright = '', $entersubmit = true) { global $_G; if(!empty($_G['showsetting_multi'])) { return; } $str = '<tr>'; $str .= $name && in_array($before, array('del', 'select_all', 'td')) ? '<td class="td25">'.($before != 'td' ? '<input type="checkbox" name="chkall" id="chkall'.($chkkallid = random(4)).'" class="checkbox" onclick="checkAll(\'prefix\', this.form, \'delete\')" /><label for="chkall'.$chkkallid.'">'.cplang($before) : '').'</label></td>' : ''; $str .= '<td colspan="15">'; $str .= $floatright ? '<div class="cuspages right">'.$floatright.'</div>' : ''; $str .= '<div class="fixsel">'; $str .= $before && !in_array($before, array('del', 'select_all', 'td')) ? $before.' ' : ''; $str .= $name ? '<input type="submit" class="btn" id="submit_'.$name.'" name="'.$name.'" title="'.($entersubmit ? cplang('submit_tips') : '').'" value="'.cplang($value).'" />' : ''; $after = $after == 'more_options' ? '<input class="checkbox" type="checkbox" value="1" onclick="$(\'advanceoption\').style.display = $(\'advanceoption\').style.display == \'none\' ? \'\' : \'none\'; this.value = this.value == 1 ? 0 : 1; this.checked = this.value == 1 ? false : true" id="btn_more" /><label for="btn_more">'.cplang('more_options').'</label>' : $after; $str = $after ? $str.(($before && $before != 'del') || $name ? ' ' : '').$after : $str; $str .= '</div></td>'; $str .= '</tr>'; echo $str.($name && $entersubmit ? '<script type="text/JavaScript">_attachEvent(document.documentElement, \'keydown\', function (e) { entersubmit(e, \''.$name.'\'); });</script>' : ''); }
- 参数解释
$name 按钮名称 $value 按钮值
- 使用范例
showsubmit('editsubmit');