首先在發帖/回帖的時候,在右側的選擇項里有使用個人簽名的功能,如圖。 勾選后發帖,相應處理進入source\include\post\post_newthread.php文件,在452行附近,相關代碼 - $usesig =!empty($_G['gp_usesig']) && $_G['group']['maxsigsize'] ? 1 : 0;
復制代碼
$usesig為是否使用個人簽名的標志,1表示使用個人簽名,0為不使用。 其中$_G['gp_usesig']就是前面說的使用個人簽名的值,$_G['group']['maxsigsize']為所在用戶組下的簽名文字最大長度,如圖。
回帖的處理類似,不做敘述。
下面看下瀏覽帖子內容時是如何處理個人簽名的。 在source\module\forum\forum_viewthread.php文件,964行附近,代碼如下。 - $post['signature'] = $post['usesig'] ? ($_G['setting']['sigviewcond'] ? (strlen($post['message']) > $_G['setting']['sigviewcond'] ? $post['signature'] : '') : $post['signature']) : '';
復制代碼
首先判斷是否使用個人簽名,$post['usesig']即為前面的使用個人簽名的值,1為使用,0為不使用。 $_G['setting']['sigviewcond']為簽名顯示條件,只有帖子字數大于這個數值后才顯示簽名,具體位置如圖:
$post['signature']為個人簽名。 第一個三元表達式: - (strlen($post['message'])> $_G['setting']['sigviewcond'] ? $post['signature'] : '')
復制代碼
這句代碼為: 如果帖子內容的字數>簽名顯示條件設置的字數,就為$post['signature'],否則為空。
第二個三元表達式: - ($_G['setting']['sigviewcond']? (strlen($post['message']) > $_G['setting']['sigviewcond'] ?$post['signature'] : '') : $post['signature'])
復制代碼
如果設置了簽名顯示條件,就顯示為上面第一個表達式的值,否則顯示為個人簽名。
第三個三元表達式: - $post['usesig'] ?($_G['setting']['sigviewcond'] ? (strlen($post['message']) >$_G['setting']['sigviewcond'] ? $post['signature'] : '') : $post['signature']): '';
復制代碼
如果帖子里選擇了使用個人簽名,則顯示為上面第二個表達式的值,否則為空。
然后看模板中是如何處理的。 在template\default\forum\viewthread_node.htm,287行附近,代碼如下: - <!--{if$post['signature'] && ($_G['setting']['bannedmessages'] & 4&& ($post['memberstatus'] == '-1' || ($post['authorid'] &&!$post['username']) || ($post['groupid'] == 4 || $post['groupid'] == 5) ||($post['status'] & 1)))}--><divclass="sign">{lang member_signature_banned}</div><!--{elseif$post['signature'] && !$post['anonymous'] &&$showsignatures}--><divclass="sign"style="max-height:{$_G['setting']['maxsigrows']}px;maxHeightIE:{$_G['setting']['maxsigrows']}px;">$post[signature]</div><!--{/if}-->
復制代碼
- <!--{if$post['signature'] && ($_G['setting']['bannedmessages'] & 4&& ($post['memberstatus'] == '-1' || ($post['authorid'] &&!$post['username']) || ($post['groupid'] == 4 || $post['groupid'] == 5) ||($post['status'] & 1)))}--><divclass="sign">{lang member_signature_banned}</div>
復制代碼
為用戶被禁止下的顯示情況,此時簽名顯示為簽名被屏蔽。
- <!--{elseif$post['signature'] && !$post['anonymous'] &&$showsignatures}--><divclass="sign"style="max-height:{$_G['setting']['maxsigrows']}px;maxHeightIE:{$_G['setting']['maxsigrows']}px;">$post[signature]</div><!--{/if}-->
復制代碼
為正常情況下的顯示。
|