悠然云影同学正在做一个音乐类论坛,刚才问我如何修改模板,于是找出来去年为争渡读屏论坛写的一个模板优化脚本,现在发上来,或许会有人感兴趣,希望有多一个discuz论坛使用,为盲人带来一点方便。

本工具适用于使用discuzx2.0默认模板的论坛。主要功能有:

  1. 补全部分表单元素的label标签
  2. 重要页面的重要位置添加快捷键
  3. 主要快捷键有alt加x和alt加z
  4. 通过给元素增加accesskey属性实现快捷键
<?php
/**
discuzx2.0 默认模板无障碍优化工具
主要功能有:
1 补全部分表单元素的label标签
2 重要页面的重要位置添加快捷键
3 主要快捷键有alt加x和alt加z
4 通过给元素增加accesskey属性实现快捷键

本工具适用于使用discuzx2.0默认模板的论坛。
经本工具优化之后,可以大幅度提高键盘用户的论坛操作效率。
用法:将代码保存为dxaccess.php,上传到论坛根目录,访问一次即可。注意运行后删除,以免重复执行造成意外。
作者: 杨永全
E-mail: qt.hk@gmail.com
博客: http://www.qt.hk/
该工具演示论坛: http://f.zdsr.net/

p.s:
对于表单元素的label缺失,希望官方日后能补全。
*/

$odiscuz = array('{/if}">$cat[name]</a>','<a href="$forumurl"{if $forum[redirect]} target="_blank"{/if}><img','{/if}>$forum[name]</a>','lastpost#lastpost" class="xi2"');
$ndiscuz = array('{/if}" accesskey="z">$cat[name]</a>','<a tabindex="-1" href="$forumurl"{if $forum[redirect]} target="_blank"{/if}><img','{/if} accesskey="x">$forum[name]</a>','lastpost#lastpost" class="xi2" accesskey="x"');
$oforumdisplay = array('class="nvhm" title="{lang homepage}">$_G[setting][bbname]</a>','forum.php">{lang return_index}</a>','title="{lang send_posts}"><img','<script type="text/javascript">document.onkeyup','$page);}</script>');
$nforumdisplay = array('class="nvhm" title="{lang homepage}" accesskey="z">$_G[setting][bbname]</a>','forum.php" accesskey="z">{lang return_index}</a>','title="{lang send_posts}" accesskey="z"><img','<!-- <script type="text/javascript">document.onkeyup','$page);}</script> -->');
$oforumdisplay_list = array('>$thread[subject]</a>');
$nforumdisplay_list = array(' title="$thread[subject]{LF}作者:$thread[author]{LF}发表时间:$thread[dateline]{LF}浏览次数:$thread[views]{LF}回复次数:$thread[replies]{LF}最后回复:$thread[lastposter]" accesskey="x">$thread[subject]</a>');
$oviewthread = array('class="nvhm" title="{lang homepage}">$_G[setting][bbname]</a>','">{lang return_forumdisplay}</a>','<script type="text/javascript">document.onkeyup','$page);}</script>');
$nviewthread = array('class="nvhm" title="{lang homepage}" accesskey="z">$_G[setting][bbname]</a>','" accesskey="z">{lang return_forumdisplay}</a>','<!-- <script type="text/javascript">document.onkeyup','$page);}</script> -->');
$oviewthread_node = array('rel="nofollow">{lang thread_show_author}</a>','rel="nofollow">{lang thread_show_all}</a>');
$nviewthread_node = array('rel="nofollow" accesskey="x" title="$post[author] <!--{if !empty($postno[$post[number]])}-->$postno[$post[number]]<!--{else}-->{$post[number]}{$postno[0]}<!--{/if}-->">{lang thread_show_author}</a>','rel="nofollow" accesskey="x" title="$post[author] <!--{if !empty($postno[$post[number]])}-->$postno[$post[number]]<!--{else}-->{$post[number]}{$postno[0]}<!--{/if}-->">{lang thread_show_all}</a>');
$oforumdisplay_fastpost = array('<input type="text" id="subject"','<textarea rows');
$nforumdisplay_fastpost = array('<label for="subject">{lang subject}</label><input accesskey="x" type="text" id="subject"','<label for="fastpostmessage">{lang modcp_report_content}</label><textarea accesskey="x" rows');
$oviewthread_fastpost = array('<input type="text" id="subject"','<textarea rows');
$nviewthread_fastpost = array('<label for="subject">{lang subject}</label><input accesskey="x" type="text" id="subject','<label for="fastpostmessage">{lang modcp_report_content}</label><textarea accesskey="x" rows');
$opost_editor_extra = array('<span><input type="text" name="subject"');
$npost_editor_extra = array('<label for="subject">{lang subject}</label><span><input accesskey="x" type="text" name="subject"');
$opost_editor_body = array('<textarea name="$editor[textarea]"');
$npost_editor_body = array('<label for="{$editorid}_textarea">{lang modcp_report_content}</label><textarea accesskey="x" name="$editor[textarea]"');
$opost_infloat = array('<span><input name="subject"','<textarea rows="7"');
$npost_infloat = array('<label for="subject">{lang subject}</label><span><input accesskey="x" type="text" name="subject"','<label for="postmessage">{lang modcp_report_content}</label><textarea accesskey="x" rows="7"');
$opost = array('title="{lang homepage}"','<button type="submit" id="postsubmit"','<button type="button" id="postsubmit"');
$npost = array('title="{lang homepage}" accesskey="z"','<button tabindex="2" type="submit" id="postsubmit"','<button tabindex="2" type="button" id="postsubmit"');
$opost_poll = array('<input id="pollchecked" type="checkbox"','<a href="javascript:;"');
$npost_poll =array('<input id="pollchecked" tabindex="1" type="checkbox"','<a tabindex="1" href="javascript:;"');

dxaccess("template/default/forum/discuz.htm",$odiscuz,$ndiscuz);
dxaccess("template/default/forum/forumdisplay.htm",$oforumdisplay,$nforumdisplay);
dxaccess("template/default/forum/forumdisplay_list.htm",$oforumdisplay_list,$nforumdisplay_list);
dxaccess("template/default/forum/viewthread.htm",$oviewthread,$nviewthread);
dxaccess("template/default/forum/viewthread_node.htm",$oviewthread_node,$nviewthread_node);
dxaccess("template/default/forum/forumdisplay_fastpost.htm",$oforumdisplay_fastpost,$nforumdisplay_fastpost);
dxaccess("template/default/forum/viewthread_fastpost.htm",$oviewthread_fastpost,$nviewthread_fastpost);
dxaccess("template/default/forum/post_editor_body.htm",$opost_editor_body,$npost_editor_body);
dxaccess("template/default/forum/post_editor_extra.htm",$opost_editor_extra,$npost_editor_extra);
dxaccess("template/default/forum/post_infloat.htm",$opost_infloat,$npost_infloat);
dxaccess("template/default/forum/post.htm",$opost,$npost);
dxaccess("template/default/forum/post_poll.htm",$opost_poll,$npost_poll);


function dxaccess($file,$ostr,$nstr) {
$content = file_get_contents($file);
$content = str_replace($ostr,$nstr,$content);
copy($file,$file.'.bak');
$fp = fopen($file, "w");
fwrite($fp, $content);
fclose($fp);
echo $file . "完成";
}
?>

标签: none

仅有一条评论

  1. 为何看不到下载地址?discuzx:2.5可否使用该工具呢?谢谢!

添加新评论