function xpress_block_render($mydirname, $block_function_name, $options) { global $wpdb, $xoops_config, $xoopsUserIsAdmin; $func_file = $block_function_name; $call_theme_function_name = str_replace(".php", "", $block_function_name); $inc_theme_file_name = $call_theme_function_name . '_theme.php'; $cache_title = str_replace(".php", "", $block_function_name); $blockID = get_block_id($mydirname, $func_file, $options); $this_block_url = '/' . $mydirname . '/'; $call_url = $_SERVER['REQUEST_URI']; $block['err_message'] = ''; if (strstr($call_url, $this_block_url) !== false && strstr($call_url, $this_block_url . 'admin/') === false) { $block_theme_file = get_block_file_path($mydirname, $inc_theme_file_name); require_once $block_theme_file['file_path']; $block = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name. if (!empty($block_theme_file['error'])) { $block['err_message'] .= $block_theme_file['error']; } } else { if (xpress_block_cache_found($mydirname, $cache_title . $blockID)) { $xml = xpress_block_cache_read($mydirname, $cache_title . $blockID); $block = $xml['block']; } else { $block['err_message'] .= sprintf(_MB_XP2_BLOCK_CACHE_ERR, '<a href="' . XOOPS_URL . '/modules/' . $mydirname . '">' . $mydirname . '</a>'); } } if (!cache_is_writable()) { $block['err_message'] = '<span style="color:#ff0000">'; $block['err_message'] .= _MB_XP2_CACHE_NOT_WRITABLE; if ($xoopsUserIsAdmin) { $block['err_message'] .= " ({$cache_dir})"; $block['err_message'] .= '</span>'; } } xpress_block_header_set($mydirname); $block['request_uri'] = $_SERVER['REQUEST_URI']; $temp_option = @explode(':', $options[1]); if (isset($temp_option[1])) { $templates_file = $options[1]; } else { $templates_file = 'db:' . $mydirname . '_' . str_replace(".php", ".html", $block_function_name); } $tpl = new XoopsTpl(); $tpl->template_dir = $xoops_config->module_path . '/templates'; if (!$tpl->template_exists($templates_file)) { $src_file_path = $xoops_config->module_path . '/templates/' . $mydirname . '_' . str_replace(".php", ".html", $block_function_name); $templates_file = add_xpress_tpl($mydirname, $templates_file, $src_file_path); } $tpl->assign('block', $block); $ret['content'] = $tpl->fetch($templates_file); if (preg_match('/\\S/', $ret['content'])) { return $ret; } else { return null; } }