XPressME Integration Kit

Trac

source: trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php @ 99

Last change on this file since 99 was 99, checked in by toemon, 16 years ago

D3Forumのフォーラムリストボックスからコメント統合を選択するための設定画面を作成
設定値はXPressME_Classクラスの
is_use_d3forum;
d3forum_module_dir;
d3forum_forum_id;
d3forum_external_link_format;
プロパティーから取得できます。

File size: 3.9 KB
Line 
1<?php
2global $xoops_config;
3if (!is_object($xoops_config)){ // is call other modules
4        require_once dirname( __FILE__ ) .'/config_from_xoops.class.php' ;
5        $xoops_config = new ConfigFromXoops;
6}
7
8// xoops db
9function get_xpress_dir_path()
10{
11        return ABSPATH;
12}
13
14function get_xpress_dir_name()
15{
16        return basename(ABSPATH);
17}
18
19function get_wp_prefix_only()
20{
21        $dir_name = get_xpress_dir_name();
22        $prefix = $dir_name;
23        if ($prefix == 'wordpress') $prefix = 'wp';
24       
25        $prefix = $prefix . '_';
26        return $prefix;
27}
28
29function get_xoops_prefix()
30{
31        global $xoops_config;
32        $ret =$xoops_config->xoops_db_prefix . '_';
33        return $ret;
34}
35
36function get_xoops_root_path()
37{
38        global $xoops_config;
39        $ret =$xoops_config->xoops_root_path;
40        return $ret;
41}
42
43function get_wp_prefix()
44{
45        $prefix = get_xoops_prefix() . get_wp_prefix_only();
46        return $prefix;
47}
48
49function get_xpress_modid()
50{
51        global $xoops_db;
52       
53        $modulename = get_xpress_dir_name();   
54        $sql = "SELECT mid FROM " . get_xoops_prefix() . "modules WHERE dirname = '$modulename'";
55        $mid = $xoops_db->get_var($sql);
56        return $mid;   
57}
58
59function get_xpress_db_version()
60{
61        include get_xpress_dir_path() . '/wp-includes/version.php';
62        return $wp_db_version;
63}
64
65function is_block_cache_found($block_name)
66{
67        global $xoops_config;
68        $mydirname = get_xpress_dir_name();
69
70        if(defined('XOOPS_ROOT_PATH')){
71                $cache_dir = XOOPS_ROOT_PATH . '/cache/';
72        } else {
73                $cache_dir = $xoops_config->xoops_root_path . '/cache/';
74        }
75        $xml_name = $block_name . '.xml';
76
77    $filename = $cache_dir .$mydirname . '_' . $xml_name;
78        $cache_time = 0;
79//        if (file_exists($filename) && ((time() - filemtime($filename)) < $cache_time)) {
80    if (file_exists($filename)) {
81        return true;
82        } else {
83                return false;
84        }
85}
86
87
88//When there is no block cash, and an optional block is different, false is returned.
89function is_block_cache_normal()
90{
91        global $xoops_config;
92        global $xoops_db;
93        $mid = get_xpress_modid();
94        $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid ";
95        $blocks = $xoops_db->get_results($sql);
96        $mydirname = get_xpress_dir_name();
97        require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
98
99        foreach($blocks as $block){
100                $func_file = $block->func_file;
101                $call_theme_function_name = str_replace(".php", "", $func_file);
102                $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
103                $cache_title = str_replace(".php", "", $func_file);
104                $blockID = $block->bid;
105                $options = explode("|", $block->options);
106               
107                if (!is_block_cache_found($cache_title . $blockID)) return false;
108                $xml = xpress_block_cache_read($mydirname,$cache_title. $blockID);
109                $options = '';
110                $options = @$xml['block']['options'];
111                if( strcmp($options,$block->options) != 0 ) return false;
112        }
113        return true;
114}
115
116
117function block_cache_refresh()
118{
119        global $xoops_db;
120        $mid = get_xpress_modid();
121        $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid";
122        $blocks = $xoops_db->get_results($sql);
123        $mydirname = get_xpress_dir_name();
124        require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
125
126
127        foreach($blocks as $block){
128                $func_file = $block->func_file;
129                $call_theme_function_name = str_replace(".php", "", $func_file);
130                $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
131                $cache_title = str_replace(".php", "", $func_file);
132                $blockID = $block->bid;
133                $options = explode("|", $block->options);
134
135                $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name);
136                require_once $block_theme_file;
137                $block_render = $call_theme_function_name($options);            //The block name and the called function name should be assumed to be the same name.                   
138                $xml['block'] = $block_render;
139                $xml['block']['options'] = $block->options;
140                xpress_block_cache_write($mydirname,$cache_title. $blockID, $xml);
141        }
142}
143
144?>
Note: See TracBrowser for help on using the repository browser.