[95] | 1 | <?php
|
---|
| 2 | // xoops db
|
---|
| 3 | function get_xpress_dir_path()
|
---|
| 4 | {
|
---|
| 5 | return ABSPATH;
|
---|
| 6 | }
|
---|
| 7 |
|
---|
| 8 | function get_xpress_dir_name()
|
---|
| 9 | {
|
---|
| 10 | return basename(ABSPATH);
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | function get_wp_prefix_only()
|
---|
| 14 | {
|
---|
| 15 | $dir_name = get_xpress_dir_name();
|
---|
| 16 | $prefix = $dir_name;
|
---|
| 17 | if ($prefix == 'wordpress') $prefix = 'wp';
|
---|
| 18 |
|
---|
| 19 | $prefix = $prefix . '_';
|
---|
| 20 | return $prefix;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | function get_xoops_prefix()
|
---|
| 24 | {
|
---|
| 25 | global $xoops_config;
|
---|
| 26 | $ret =$xoops_config->xoops_db_prefix . '_';
|
---|
| 27 | return $ret;
|
---|
| 28 | }
|
---|
| 29 | function get_wp_prefix()
|
---|
| 30 | {
|
---|
| 31 | $prefix = get_xoops_prefix() . get_wp_prefix_only();
|
---|
| 32 | return $prefix;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | function get_xpress_modid()
|
---|
| 36 | {
|
---|
| 37 | global $xoops_db;
|
---|
| 38 |
|
---|
| 39 | $modulename = get_xpress_dir_name();
|
---|
| 40 | $sql = "SELECT mid FROM " . get_xoops_prefix() . "modules WHERE dirname = '$modulename'";
|
---|
| 41 | $mid = $xoops_db->get_var($sql);
|
---|
| 42 | return $mid;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | function get_xpress_db_version()
|
---|
| 46 | {
|
---|
| 47 | include get_xpress_dir_path() . '/wp-includes/version.php';
|
---|
| 48 | return $wp_db_version;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | function block_cache_refresh()
|
---|
| 52 | {
|
---|
| 53 | global $xoops_db;
|
---|
| 54 | $mid = get_xpress_modid();
|
---|
| 55 | $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid";
|
---|
| 56 | $blocks = $xoops_db->get_results($sql);
|
---|
| 57 | $mydirname = get_xpress_dir_name();
|
---|
| 58 | require_once get_xpress_dir_path() . '/include/xpress_block_render.php';
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 | foreach($blocks as $block){
|
---|
| 62 | $func_file = $block->func_file;
|
---|
| 63 | $call_theme_function_name = str_replace(".php", "", $func_file);
|
---|
| 64 | $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php';
|
---|
| 65 | $cache_title = str_replace(".php", "", $func_file);
|
---|
| 66 | $blockID = $block->bid;
|
---|
| 67 | $options = explode("|", $block->options);
|
---|
| 68 |
|
---|
| 69 | $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name);
|
---|
| 70 | require_once $block_theme_file;
|
---|
| 71 | $block_render = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name.
|
---|
| 72 | $xml['block'] = $block_render;
|
---|
| 73 | xpress_block_cache_write($mydirname,$cache_title. $blockID, $xml);
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | ?> |
---|