XPressME Integration Kit

Trac

source: trunk/include/xoops_block_cache.php @ 43

Last change on this file since 43 was 43, checked in by toemon, 15 years ago

ブロックキャッシュの認識子としてブロックIDを使用するように変更、 #49
概要抽出用の関数xpress_substr()を追加

File size: 1.6 KB
Line 
1<?php
2        require_once dirname( __FILE__ ) .'/xml.php' ;
3        require_once dirname( __FILE__ ) .'/xpress_cache.php' ;
4       
5        function xpress_block_cache_write($mydirname,$block_name,$block)
6        {
7                        $xml = xpress_XML_serialize($block);
8                        $xml_name = $block_name . '.xml';
9                        xpress_cache_write($mydirname,$xml_name,$xml);
10        }
11        function xpress_block_cache_read($mydirname,$block_name)
12        {
13                        $xml_name = $block_name . '.xml';
14                        $xml_data = xpress_cache_read($mydirname,$xml_name);
15                        return @xpress_XML_unserialize($xml_data);
16        }
17       
18        function get_block_id($mydirname,$func_file,$options)
19        {
20                $options_string = '';
21                foreach ($options as $val){
22                        if (!empty($options_string)) $options_string .='|';
23                        $options_string .= $val;
24                }
25                        $xoopsDB =& Database::getInstance();
26                        $block_tbl = $xoopsDB->prefix('newblocks');     
27                        $module_dir = XOOPS_ROOT_PATH . '/modules/' . $mydirname;
28
29                        $sql = "SELECT bid FROM $block_tbl WHERE (func_file LIKE '$func_file') AND (options LIKE '$options_string')";
30                        $result =  $xoopsDB->query($sql, 0, 0);
31                        if ($xoopsDB->getRowsNum($result)  > 0){
32                                $row = $xoopsDB->fetchArray($result);
33                                $block_id = $row['bid'];
34                        }
35                        return $block_id;
36        }
37       
38        function block_render($mydirname)
39        {               $block_theme_file = get_block_file_path($mydirname,$block_render_file_name);
40                        require_once $block_theme_file;
41                        $block = recent_comments_block($options);
42                       
43                        require_once $mydirpath.'/include/xoops_block_cache.php';
44                        $my_name = basename( __FILE__ );
45                        $blockID =get_block_id($mydirname,$my_name,$options);                   
46                        xpress_block_cache_write($mydirname,$block_render_file_name. $blockID, $block);
47        }
48?>
Note: See TracBrowser for help on using the repository browser.