茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    Discuz X2新添加關聯(lián)鏈接
    來源:易賢網(wǎng) 閱讀:1483 次 日期:2014-09-04 11:23:11
    溫馨提示:易賢網(wǎng)小編為您整理了“Discuz X2新添加關聯(lián)鏈接”,方便廣大網(wǎng)友查閱!

    在 X2.0 中增加了關聯(lián)鏈接,可以在指定范圍內把 指定的文字 加上鏈接。

    在 后臺->運營->關聯(lián)鏈接 處設置。

    這里可以直接 添加、刪除、更新 關聯(lián)鏈接,并且可以選擇該鏈接分別在 文章、論壇主題、群組主題、日志 中是否啟用。

    我們分析下這個代碼的執(zhí)行過程。

    首先這個功能的路徑是 /admin.php?action=misc&operation=relatedlink ,

    我們根據(jù)這個鏈接可以定位到代碼在 /source/admincp/admincp_misc.php 中,打開這個文件,搜 relatedlink

    } elseif($operation == 'relatedlink') {

    if(!submitcheck('linksubmit')) {

    ?>

    <script type="text/JavaScript">

    var rowtypedata = [

    [

    [1,'', 'td25'],

    [1,'<input type="text" class="txt" name="newname[]" size="15">'],

    [1,'<input type="text" name="newurl[]" size="50">'],

    [1,'<input class="checkbox" type="checkbox" value="1" name="newarticle[]">'],

    [1,'<input class="checkbox" type="checkbox" value="1" name="newforum[]">'],

    [1,'<input class="checkbox" type="checkbox" value="1" name="newgroup[]">'],

    [1,'<input class="checkbox" type="checkbox" value="1" name="newblog[]">']

    ]

    ]

    </script>

    <?php

    shownav('extended', 'misc_relatedlink');

    showsubmenu('nav_misc_relatedlink');

    /*search={"misc_relatedlink":"action=misc&operation=relatedlink"}*/

    showtips('misc_relatedlink_tips');

    /*search*/

    showformheader('misc&operation=relatedlink');

    showtableheader();

    showsubtitle(array('', 'misc_relatedlink_edit_name', 'misc_relatedlink_edit_url', '<input class="checkbox" type="checkbox" name="articleall">'.cplang('misc_relatedlink_extent_article'), '<input class="checkbox" type="checkbox" name="forumall">'.cplang('misc_relatedlink_extent_forum'), '<input class="checkbox" type="checkbox" name="groupall">'.cplang('misc_relatedlink_extent_group'),'<input class="checkbox" type="checkbox" name="blogall">'.cplang('misc_relatedlink_extent_blog')));

    $query = DB::query("SELECT * FROM ".DB::table('common_relatedlink')." ORDER BY id DESC");

    while($link = DB::fetch($query)) {

    $extent = sprintf('%04b', $link['extent']);

    showtablerow('', array('class="td25"', '', '', 'class="td26"', 'class="td26"', 'class="td26"', ''), array(

    '<input type="checkbox" class="checkbox" name="delete[]" value="'.$link['id'].'" />',

    '<input type="text" class="txt" name="name['.$link[id].']" value="'.$link['name'].'" size="15" />',

    '<input type="text" name="url['.$link[id].']" value="'.$link['url'].'" size="50" />',

    '<input class="checkbox" type="checkbox" value="1" name="article['.$link[id].']" '.($extent[0] ? "checked" : '').'>',

    '<input class="checkbox" type="checkbox" value="1" name="forum['.$link[id].']" '.($extent[1] ? "checked" : '').'>',

    '<input class="checkbox" type="checkbox" value="1" name="group['.$link[id].']" '.($extent[2] ? "checked" : '').'>',

    '<input class="checkbox" type="checkbox" value="1" name="blog['.$link[id].']" '.($extent[3] ? "checked" : '').'>',

    ));

    }

    echo '<tr><td></td><td colspan="6"><div><a href="###" class="addtr">'.$lang['misc_relatedlink_add'].'</a></div></td></tr>';

    showsubmit('linksubmit', 'submit', 'del');

    showtablefooter();

    showformfooter();

    } else {

    if($_G['gp_delete']) {

    DB::delete('common_relatedlink', "id IN (".dimplode($_G['gp_delete']).")");

    }

    if(is_array($_G['gp_name'])) {

    foreach($_G['gp_name'] as $id => $val) {

    $extent_str = intval($_G['gp_article'][$id]).intval($_G['gp_forum'][$id]).intval($_G['gp_group'][$id]).intval($_G['gp_blog'][$id]);

    $extent_str = intval($extent_str, '2');

    DB::update('common_relatedlink', array(

    'name' => $_G['gp_name'][$id],

    'url' => $_G['gp_url'][$id],

    'extent' => $extent_str,

    ), array(

    'id' => $id,

    ));

    }

    }

    if(is_array($_G['gp_newname'])) {

    foreach($_G['gp_newname'] as $key => $value) {

    if($value) {

    $extent_str = intval($_G['gp_newarticle'][$key]).intval($_G['gp_newforum'][$key]).intval($_G['gp_newgroup'][$key]).intval($_G['gp_newblog'][$key]);

    $extent_str = intval($extent_str, '2');

    DB::insert('common_relatedlink', array(

    'name' => $value,

    'url' => $_G['gp_newurl'][$key],

    'extent' => $extent_str,

    ));

    }

    }

    }

    updatecache('relatedlink');

    cpmsg('relatedlink_succeed', 'action=misc&operation=relatedlink', 'succeed');

    } 當直接打開這個頁面的時候,就是顯示默認的已經存在的關聯(lián)鏈接。

    當點擊 提交 的時候,會做三個處理。

    1.刪除處理

    如果提交之前,把某些關聯(lián)鏈接前的 刪除 勾打上的話,那么這里會先處理 刪除 的操作。

    代碼為:

    if($_G['gp_delete']) {

    DB::delete('common_relatedlink', "id IN (".dimplode($_G['gp_delete']).")");

    }

    2.更新操作

    如果在操作之前,已經存在的關聯(lián)鏈接被修改過,那么在提交的時候,這些鏈接會先做下更新。

    對應的代碼為:

    if(is_array($_G['gp_name'])) {

    foreach($_G['gp_name'] as $id => $val) {

    $extent_str = intval($_G['gp_article'][$id]).intval($_G['gp_forum'][$id]).intval($_G['gp_group'][$id]).intval($_G['gp_blog'][$id]);

    $extent_str = intval($extent_str, '2');

    DB::update('common_relatedlink', array(

    'name' => $_G['gp_name'][$id],

    'url' => $_G['gp_url'][$id],

    'extent' => $extent_str,

    ), array(

    'id' => $id,

    ));

    }

    }

    3.新添加的操作

    在提交前,如果有新添加的管鏈鏈接,則會執(zhí)行相應的代碼插入到數(shù)據(jù)中。

    對應的代碼為:

    if(is_array($_G['gp_newname'])) {

    foreach($_G['gp_newname'] as $key => $value) {

    if($value) {

    $extent_str = intval($_G['gp_newarticle'][$key]).intval($_G['gp_newforum'][$key]).intval($_G['gp_newgroup'][$key]).intval($_G['gp_newblog'][$key]);

    $extent_str = intval($extent_str, '2');

    DB::insert('common_relatedlink', array(

    'name' => $value,

    'url' => $_G['gp_newurl'][$key],

    'extent' => $extent_str,

    ));

    }

    }

    } 需要注意的時候,不管是更新還是新添加, 關聯(lián)鏈接 在進入數(shù)據(jù)庫之前,關于在那些模塊啟用的地方,都用了二進制形式來控制在那里顯示,然后再變?yōu)?10 進制存的。

    存儲完以后,緊跟著做了緩存的更新,對應的代碼是:

    updatecache('relatedlink'); 關于的緩存的更新,需要查看 /source/function/function_cache.php

    然后調用了 /source/function/cache/cache_relatedlink.php

    function build_cache_relatedlink() {

    global $_G;

    $data = array();

    $query = DB::query("SELECT * FROM ".DB::table('common_relatedlink'));

    while($link = DB::fetch($query)) {

    if(substr($link['url'], 0, 7) != 'http://') {

    $link['url'] = 'http://'.$link['url'];

    }

    $data[] = $link;

    }

    save_syscache('relatedlink', $data);

    }

    從這里能看到,最后緩存存到了 pre_common_syscache 中,其中 cname 就是 relatedlink 。

    我們在看下前臺發(fā)帖子等時候,使用我們剛剛添加的 關聯(lián)鏈接的情況。

    當我們查看帖子的時候,執(zhí)行的文件是 /source/module/forum/forum_viewthread.php 文件。

    在這個文件中,先得到設置在帖子中顯示的關聯(lián)鏈接,相應的代碼是:

    if(!defined('IN_ARCHIVER')) {

    $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $_G['forum']['allowsmilies'], $_G['forum']['allowbbcode'], ($_G['forum']['allowimgcode'] && $_G['setting']['showimages'] ? 1 : 0), $_G['forum']['allowhtml'], ($_G['forum']['jammer'] && $post['authorid'] != $_G['uid'] ? 1 : 0), 0, $post['authorid'], $_G['cache']['usergroups'][$post['groupid']]['allowmediacode'] && $_G['forum']['allowmediacode'], $post['pid']);

    if($post['first']) {

    if(!$_G['forum_thread']['isgroup']) {

    $_G['relatedlinks'] = getrelatedlink('forum');

    } else {

    $_G['relatedlinks'] = getrelatedlink('group');

    }

    }

    }

    把得到的 關聯(lián)鏈接 存放到了全局變量 $_G 中,然后在 模板文件 中使用。

    顯示帖子的時候調用的模板文件是:/template/default/forum/viewthread.htm 文件。

    這個文件相關的代碼為:

    <!--{if $_G['relatedlinks']}-->

    <div style="display: none">

    <ul>

    <!--{loop $_G['relatedlinks'] $key $link}-->

    <li><a id="relatedlink_$key" href="$link[url]">$link[name]</a></li>

    <!--{/loop}-->

    </ul>

    </div>

    <script type="text/javascript">relatedlinks('postmessage_$_G[forum_firstpid]');</script>

    <!--{/if}-->

    然后執(zhí)行了 js 的 relatedlinks 函數(shù),該函數(shù)在 /static/js/common.js

    通過這個文件中的 js 方法,使得 關聯(lián)鏈接 在頁面中顯示。

    更多信息請查看IT技術專欄

    更多信息請查看CMS教程
    易賢網(wǎng)手機網(wǎng)站地址:Discuz X2新添加關聯(lián)鏈接
    由于各方面情況的不斷調整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢?yōu)闇剩?/div>
    相關閱讀CMS教程

    2026國考·省考課程試聽報名

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網(wǎng)