我只是粗粗用过 DZ 没有仔细用过它各个方面的功能 ,但现在研究它的代码了 . 有些地方因为没用过 , 光看代码有无法看出其意思来 , 请懂的朋友解答下 .
if(!empty($_G['forum']['threadsorts']['types'])) {
require_once libfile('function/threadsort'); $showpic = intval($_G['gp_showpic']);
$templatearray = $sortoptionarray = array();
foreach($_G['forum']['threadsorts']['types'] as $stid => $sortname) {
loadcache(array('threadsort_option_'.$stid, 'threadsort_template_'.$stid));
sortthreadsortselectoption($stid);
$templatearray[$stid] = $_G['cache']['threadsort_template_'.$stid]['subject'];
$sortoptionarray[$stid] = $_G['cache']['threadsort_option_'.$stid];
} if(!empty($_G['forum']['threadsorts']['defaultshow']) && empty($_G['gp_sortid']) && empty($_G['gp_sortall'])) {
$_G['gp_sortid'] = $_G['forum']['threadsorts']['defaultshow'];
$_G['gp_filter'] = 'sortid';
$_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'].'&sortid='.$_G['gp_sortid'] : 'sortid='.$_G['gp_sortid'];
$filterurladd = '&filter=sort';
} $_G['gp_sortid'] = $_G['gp_sortid'] ? $_G['gp_sortid'] : $_G['gp_searchsortid'];
if(isset($_G['gp_sortid']) && $_G['forum']['threadsorts']['types'][$_G['gp_sortid']]) {
$searchsortoption = $sortoptionarray[$_G['gp_sortid']];
$quicksearchlist = quicksearch($searchsortoption);
$_G['forum_optionlist'] = $_G['cache']['threadsort_option_'.$_G['gp_sortid']];
$forum_optionlist = getsortedoptionlist();
}
}
简单的来说 , 就这段 , 不知能否详细解释一下 ?

解决方案 »

  1.   

    额 , 不好意思 , 我忘了说了 , 这个就是 DZ 源码 . 
    出自 : 
    Discuz! X2 版本
    /source/module/forum/forum_forumdisplay.php
    的第 195 行 .
    非常感谢 , 懂的人请解答下 , 这个文件的其他部分全都看懂了 , 这文件的作用很简单 , 就是帖子列表 .
    但这一个判断我不知其意 . 请帮我解答下 , 谢谢 .望各位喷子“嘴下留情”, 如果不是喷子那说话语气好点别那么喷 , 比如 : andyxl .
    如果懂的话 , 请解答下 , 谢谢 .
      

  2.   

    而且 , 你就算把
    if(!empty($_G['forum']['threadsorts']['types'])) {
    改为
    if(true)
    强制其执行这一段 , 个被催的 , 也看不出区别 ...
      

  3.   

    var_dump($_G)
    输出参数可以看到  这个变量保存了很多信息,诸如用户ID,名称神马神马的。
    提交到source/目录下。具体看时function还是module
      

  4.   

    我在单位局域网里也建立了这个论坛Discuz! X2 ,加入了在线考试插件,还不错,只是还没有空来研究后台的代码。
      

  5.   

    今天已经确认 , 这个来自于
    /source/function/function_forum.php 的第 399 行 , loadforum 函数 . 在该文件第 506 行有对四个字段序列化的操作 , 其中有这个字段 .
    代码 :
    foreach(array('threadtypes', 'threadsorts', 'creditspolicy', 'modrecommend') as $key) {
    $forum[$key] = !empty($forum[$key]) ? unserialize($forum[$key]) : array();
    if(!is_array($forum[$key])) {
    $forum[$key] = array();
    }
    }
    按照常理来讲 , 这个东西中存的应该是数组 .
    而在该文件的第 467 行可以看到 $forum 是什么 :
    $forum = DB::fetch_first("SELECT f.fid, f.*, ff.* $accessadd1 $modadd1, f.fid AS fid
    FROM ".DB::table('forum_forum')." f
    LEFT JOIN ".DB::table("forum_forumfield")." ff ON ff.fid=f.fid $accessadd2 $modadd2
    WHERE f.fid='$fid'");
    显然可以知道 , 这个字段就是 forum_forum / forum_forumfield 表中的一个字段 , 经过确认 , 该字段为
    forum_forumfield , 根据我前两天的研究 , 知道这个表是 discuz 版块的拓展表 . 所以到现在大部分问题已经解开了 , 而转到 
    if(!empty($_G['forum']['threadsorts']['types']))
    第一帖的第一行代码中 , 显然知道这个字段存放的是 serialize 之后的数组 , 可 TM 是什么 , 就是不清楚 , 希望某高人能说明白
      

  6.   

    顺便跟帖说明一下 
    $_G['forum']....
    来操作刚刚数据库中取到的 $forum , 是因为
    /source/function/function_forum.php
    中 loadforum 函数结尾部 ( 该文件的第 557 行 ) 写了如下几行代码 :
    $_G['fid'] = $fid;
    $_G['tid'] = $tid;
    $_G['forum'] = &$forum;
    $_G['current_grouplevel'] = &$grouplevel;
    呵呵 , 是引用哦 , 不是直接赋值 .
    在线等懂的朋友出现
      

  7.   


    if(!empty($_G['forum']['threadsorts']['types'])) {//分类信息是否为空
        require_once libfile('function/threadsort');    $showpic = intval($_G['gp_showpic']);//图片?
        $templatearray = $sortoptionarray = array();
        foreach($_G['forum']['threadsorts']['types'] as $stid => $sortname) {
            loadcache(array('threadsort_option_'.$stid, 'threadsort_template_'.$stid));
            sortthreadsortselectoption($stid);
            $templatearray[$stid] = $_G['cache']['threadsort_template_'.$stid]['subject'];
            $sortoptionarray[$stid] = $_G['cache']['threadsort_option_'.$stid];//得到当前所有分类信息
        }    if(!empty($_G['forum']['threadsorts']['defaultshow']) && empty($_G['gp_sortid']) && empty($_G['gp_sortall'])) {
            $_G['gp_sortid'] = $_G['forum']['threadsorts']['defaultshow'];
            $_G['gp_filter'] = 'sortid';
            $_SERVER['QUERY_STRING'] = $_SERVER['QUERY_STRING'] ? $_SERVER['QUERY_STRING'].'&sortid='.$_G['gp_sortid'] : 'sortid='.$_G['gp_sortid'];
            $filterurladd = '&filter=sort';
        }    $_G['gp_sortid'] = $_G['gp_sortid'] ? $_G['gp_sortid'] : $_G['gp_searchsortid'];
        if(isset($_G['gp_sortid']) && $_G['forum']['threadsorts']['types'][$_G['gp_sortid']]) {
            $searchsortoption = $sortoptionarray[$_G['gp_sortid']];
            $quicksearchlist = quicksearch($searchsortoption);
            $_G['forum_optionlist'] = $_G['cache']['threadsort_option_'.$_G['gp_sortid']];
            $forum_optionlist = getsortedoptionlist();
        }
    }//以上代码应该是处理分类信息
      

  8.   

    补一贴 , 设置之后在命令行下选择 DZ 数据库用这个 SQL 试试看 ...
    select threadsorts from pre_forum_forumfield
    就可以看到了
      

  9.   

    楼主,现在DZ学的怎么样?现在刚开始学习DZ,一穷二白的,没有资料,看半天程序一点儿感觉没有,头昏脑胀的,楼主有没有好的资料或者学习的网站,博客什么的呢?
    不吝赐教啊~~~