筍子工作雜記

七月 29, 2006

主選單生成分析

Filed under: xoops — shinnlu @ 8:08 下午

系統主選單是如何產生的呢,下面是分析步驟
由 index.php 引入 header.php 開始
/header.php
// Get blocks
$block_handler =& xoops_gethandler(‘block’);(註1)
$block_handler->assignBlocks();

/kernel/block.php
function assignBlocks() //取得區塊供樣板引擎使用
$bcontent = $xoopsTpl->fetch( “db:$btpl", “blk_$instanceid" );//取得區塊內容,經由 smarty 執行 system_blocks.php
$xoopsTpl->clear_assign(‘block’);
$querycount = count( $xoopsLogger->queries[$xoopsLogger->context] ) – $querycountbefore;
$xoopsLogger->addBlock( $block_arr[$i]->block->getVar(‘name’), false, 0, $querycount );
//$block_arr[$i]->block->getVar(‘name’) 區塊名稱


資料庫參考資料 table:xoops_block_instance
instid bid options title side weight visible bctime
1 1 a:0:{} 使用者選單 0 0 1 0
2 2 a:0:{} 登入 0 0 1 0
3 5 a:0:{} 主選單 0 0 1 0

/modules/system/blocks/system_blocks.php(註2)
function b_system_main_show(){
$module_handler =& xoops_gethandler(‘module’);(註1)//取得模組物件(xoops_config, xoops_session, privileges(user,group), modules, config, 選單區塊)
$modules =& $module_handler->getObjects($criteria, true);//取得該模組物件下的選單資料(在此只注意主選單區塊)
foreach (array_keys($modules) as $i) {
if (in_array($i, $read_allowed)) {
$block['modules'][$i]['name'] = $modules[$i]->getVar(‘name’);//模組名稱
$block['modules'][$i]['name'] = $modules[$i]->getVar(‘name’);


資料庫參考資料 table:xoops_block_module_link
block_id module_id pageid
6 0 0
6 2 0
6 3 0
6 4 0
6 5 0
6 6 0

補充說明
註1:呼叫 &xoops_gethandler 時,都會動態載入相對應的物件
/includes/functions.php

function &xoops_gethandler($name, $optional = false )
if ( file_exists( $hnd_file = XOOPS_ROOT_PATH.’/kernel/’.$name.’.php’ ) ) {//載入 {module}.php
if (class_exists($class)) {
$handlers[$name] =& new $class($GLOBALS['xoopsDB']);
$handlers[$name] =& new XoopsModuleHandler(object(xoopsmysqldatabaseproxy));
}

註2:為什麼上面追到一半,會跑去 b_system_main_show() 去呢?原因如下

資料庫參考資料 table:xoops_newblocks
bid mid options name isactive dirname func_file show_func edit_func template
5 1 a:1:{i:0;s:0:"";} 主選單 1 system system_blocks.php b_system_main_show system_block_mainmenu.html

無迴響 »

仍無迴響。

此篇文章迴響的訂閱源料 TrackBack URL

發表迴響

Powered by WordPress