Blogs
Drupal 6 Views模块
Submitted by wilson on Mon, 08/25/2008 - 11:25一、 原理
Views模块通过hook_menu_alter()插入页面项,通过hook_form_alter插入block项。模块的核心为view对象,通过执行view对象的execute_display()方法来获取输出,View对象是数据库表views_view的映射。对view对象的各个属性(如field、argument、sort、filter等)通过handler对象实现,view对象的界面方面则通过plugin对象和hook_views_plugins()来实现。在views_theme()函数里通过调用views_fetch_plugin_data()将各个plugin集成到theme_registry里。
对于页面,view对象通过execute_hook_menu()方法获得该view对象的页面menu项,通过views_arg_load()函数加载路径上的对象,通过views_access()函数判断该menu项的access属性,通过views_page()函数来获取输出,而views_page()函数内部则调用view对象的execute_display()方法。
Drupal 6 CCK模块
Submitted by wilson on Mon, 08/25/2008 - 11:23一、 原理
通过hook_form_alter()挂接CCK Field,通过hook_nodeapi()对挂接的CCK Field进行各项操作(CRUD)。核心函数_content_type_info()搜集当前节点系统的field types列表,widget types列表,['field types'] ['formatters']列表,fields列表和content types列表,模拟如下
Array(
'field types' => array(
‘text’ => array(
‘label’ =>
‘description’ =>
‘callbacks’ => array (
‘tables’ => CONTENT_CALLBACK_DEFAULT
‘arguments’ => CONTENT_CALLBACK_DEFAULT
)
‘module’ =>
‘formatters’ => array (
‘theme_name’ => array(
‘label’ => t(),
‘field types’ => array(),
‘multiple values’ => CONTENT_HANDLE_CORE
‘module’ =>
)
)
),
)
Drupal 6 Theme系统
Submitted by wilson on Mon, 08/25/2008 - 11:22一、原理
二、流程
1. 系统调用函数theme(),进入theme系统;
2. init_theme()
3. theme_get_registry(),获得theme_registry列表;
4. 遍历theme_registry,选取当前调用的theme单元;
5. 判断该theme单元是否有[‘file’]、[‘path’],有则引用该文件;
6. 如果当前theme存在function,则调用该function;
7. 否则当前theme为template调用。默认渲染函数为theme_render_template(),可以自定义渲染函数和模板文件扩展名。
8. 执行该theme单元的preprocess functions注册函数,根据传进来的变量$variables['template_file']中系统中寻找合适的模板文件,执行渲染函数theme_render_template()。
三、API
1. hook_theme(),应用于module、theme_engine、theme里,返回theme单元数组;
2. 返回数组的参数:
Array(
‘hook_name’ => array(
‘function’ => ‘’, //调用函数,若省略默认为theme_hook_name;
Drupal 6 Menu系统
Submitted by wilson on Mon, 08/25/2008 - 11:21一、 原理
Drupal6的Menu被分为两种,一种是用于导航的Menu_router,一种是用于显示的Menu_links。Menu_links是Menu_router的一个子集。
二、 Menu Router流程
1、 系统接收请求之后启动,调用函数menu_execute_active_handler()进入Menu router系统;
2、 系统调用menu_get_item()函数寻找该请求路径对应的处理单元,判断该单元的access属性,如果为真,判断该处理单元是否需要加载额外的file文件,然后调用该处理单元的回调函数,返回相应的结果;
3、 在menu_get_item()内部,系统获取当前的$_GET[‘q’]路径,或者引用传入的路径,根据该路径组成一个优先调用的路径数组列表,在menu_router表里根据优先等级搜寻最适合的menu项,取出;
4、 调用_menu_translate()函数,将取出的menu项根据当前的实际路径值进行翻译。载入路径需要载入的对象,判断路径的access值,如果为真,进行_menu_item_localize();
三、 Menu Links流程
1、 通过调用menu_navigation_links()或者menu_local_tasks()进入Menu Links系统;
Running Drupal under Lighttpd
Submitted by wilson on Tue, 07/29/2008 - 22:51There is no doubt about the popularity of Apache among all available webservers, but there is one webserver with excellent performance which started to attract very important actor in the market : Lighttpd.
Lighttpd key features are security, speed, compliance, and flexibility. It have been optimized for high performance environments, with small memory footprint compared to other web-servers, effective management of the cpu-load, and advanced feature set (FastCGI, CGI, Auth, Output-Compression, URL-Rewriting and many more).
Some thoughts about multilingual support in drupal6
Submitted by wilson on Tue, 07/29/2008 - 20:41recently we've just redesigned our site to support multi languages. This is also our first test in drupal6(6.3). We were impressed by the more elegant and light-weight architecture of drupal6, the embeded mulitilingual support is much better than drupal5 but still need improvement. The contributed modlue i18n do a great favor, but there are still some issues in drupal core need to be solved.

