Discuz! 让分类信息代码功能研究
隐藏空值方法template/default/forum/viewthread_node_body.htm找到
function threadsortshow($sortid, $tid) { global $_G; loadcache(array('threadsort_option_'.$sortid, 'threadsort_template_'.$sortid)); $sortoptionarray = $_G['cache']['threadsort_option_'.$sortid]; value $templatearray = $_G['cache']['threadsort_template_'.$sortid]; $threadsortshow = $optiondata = $searchtitle = $searchvalue = $searchunit = $memberinfofield = $_G['forum_option'] = array(); if($sortoptionarray) { foreach(C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tid) as $option) { $optiondata[$option['optionid']]['value'] = $option['value']; $optiondata[$option['optionid']]['expiration'] = $option['expiration'] && $option['expiration'] <= TIMESTAMP ? 1 : 0; $sortdataexpiration = $option['expiration']; } foreach($sortoptionarray as $optionid => $option) { $_G['forum_option'][$option['identifier']]['title'] = $option['title']; $_G['forum_option'][$option['identifier']]['unit'] = $option['unit']; $_G['forum_option'][$option['identifier']]['type'] = $option['type']; if(($option['expiration'] && !$optiondata[$optionid]['expiration']) || empty($option['expiration'])) { if(!protectguard($option['protect'])) { if($option['type'] == 'checkbox') { $_G['forum_option'][$option['identifier']]['value'] = ''; foreach(explode("\t", $optiondata[$optionid]['value']) as $choiceid) { $_G['forum_option'][$option['identifier']]['value'] .= $option['choices'][$choiceid].' '; } } elseif($option['type'] == 'radio') { $_G['forum_option'][$option['identifier']]['value'] = $option['choices'][$optiondata[$optionid]['value']]; } elseif($option['type'] == 'select') { $tmpchoiceid = $tmpidentifiervalue = array(); foreach(explode('.', $optiondata[$optionid]['value']) as $choiceid) { $tmpchoiceid[] = $choiceid; $tmpidentifiervalue[] = $option['choices']; } $_G['forum_option'][$option['identifier']]['value'] = implode(' » ', $tmpidentifiervalue); unset($tmpchoiceid, $tmpidentifiervalue); } elseif($option['type'] == 'image') { $imgoptiondata = dunserialize($optiondata[$optionid]['value']); $threadsortshow['sortaids'][] = $imgoptiondata['aid']; if(empty($templatearray['viewthread'])) { $maxwidth = $option['maxwidth'] ? 'width="'.$option['maxwidth'].'"' : ''; $maxheight = $option['maxheight'] ? 'height="'.$option['maxheight'].'"' : ''; if(!defined('IN_MOBILE')) { $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<img src="".$imgoptiondata['url']."" onload="thumbImg(this)" $maxwidth $maxheight border="0">" : ''; } else { $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<a href="".$imgoptiondata['url']."" target="_blank">".lang('forum/misc', 'click_view')."</a>" : ''; } } else { $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? $imgoptiondata['url'] : './static/image/common/nophoto.gif'; } } elseif($option['type'] == 'url') { $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? "<a href="".$optiondata[$optionid]['value']."" target="_blank">".$optiondata[$optionid]['value']."</a>" : ''; } elseif($option['type'] == 'number') { $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value']; } else { if($option['protect']['status'] && $optiondata[$optionid]['value']) { $optiondata[$optionid]['value'] = $option['protect']['mode'] == 1 ? '<image src="'.stringtopic($optiondata[$optionid]['value']).'">' : (!defined('IN_MOBILE') ? '<span id="sortmessage_'.$option['identifier'].'"><a href="###" onclick="ajaxget(\'forum.php?mod=misc&action=protectsort&tid='.$tid.'&optionid='.$optionid.'\', \'sortmessage_'.$option['identifier'].'\');return false;">'.lang('forum/misc', 'click_view').'</a></span>' : $optiondata[$optionid]['value']); $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue']; } elseif($option['type'] == 'textarea') { $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] != '' ? nl2br($optiondata[$optionid]['value']) : ''; } else { $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] != '' ? $optiondata[$optionid]['value'] : $option['defaultvalue']; } } } else { if(empty($option['permprompt'])) { $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'view_noperm'); } else { $_G['forum_option'][$option['identifier']]['value'] = $option['permprompt']; } } } else { $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'has_expired'); } } $typetemplate = ''; if($templatearray['viewthread']) { foreach($sortoptionarray as $option) { $searchtitle[] = '/{('.$option['identifier'].')}/'; $searchvalue[] = '/\[('.$option['identifier'].')value\]/'; $searchvalue[] = '/{('.$option['identifier'].')_value}/'; $searchunit[] = '/\[('.$option['identifier'].')unit\]/'; $searchunit[] = '/{('.$option['identifier'].')_unit}/'; } $threadexpiration = $sortdataexpiration ? dgmdate($sortdataexpiration) : lang('forum/misc', 'never_expired'); $typetemplate = preg_replace(array("/\{expiration\}/i"), array($threadexpiration), stripslashes($templatearray['viewthread'])); $typetemplate = preg_replace_callback($searchtitle, "threadsortshow_callback_showoption_title1", $typetemplate); $typetemplate = preg_replace_callback($searchvalue, "threadsortshow_callback_showoption_value1", $typetemplate); $typetemplate = preg_replace_callback($searchunit, "threadsortshow_callback_showoption_unit1", $typetemplate); } } $threadsortshow['optionlist'] = !$optionexpiration ? $_G['forum_option'] : 'expire'; $threadsortshow['typetemplate'] = $typetemplate; $threadsortshow['expiration'] = dgmdate($sortdataexpiration, 'd'); return $threadsortshow;}
页:
[1]