- Timestamp:
- Apr 26, 2011, 3:38:22 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/include/xpress_block_render.php
r716 r719 68 68 { 69 69 $xoopsDB =& Database::getInstance(); 70 $modules_tbl = $xoopsDB->prefix('modules'); 70 $modules_tbl = $xoopsDB->prefix('modules'); 71 71 72 72 $sql = "SELECT mid FROM $modules_tbl WHERE dirname = '$mydirname'"; … … 87 87 $wp_prefix = preg_replace('/wordpress/','wp',$mydirname); 88 88 89 $module_tbl = $xoopsDB->prefix($wp_prefix).'_options'; 90 $theme_name = ''; 89 $module_tbl = $xoopsDB->prefix($wp_prefix).'_options'; 90 $theme_name = ''; 91 91 92 92 $sql = "SELECT option_value FROM $module_tbl WHERE option_name LIKE 'template'"; … … 139 139 function xpress_block_render($mydirname,$block_function_name,$options) 140 140 { 141 global $wpdb,$xoops_config ;141 global $wpdb,$xoops_config,$xoopsUserIsAdmin; 142 142 $func_file = $block_function_name; 143 143 $call_theme_function_name = str_replace(".php", "", $block_function_name); … … 148 148 $this_block_url = '/' . $mydirname . '/'; 149 149 $call_url = $_SERVER['REQUEST_URI']; 150 150 $block['err_message'] = ''; 151 151 152 if (strstr($call_url , $this_block_url) !== false && strstr($call_url , $this_block_url . 'admin/') === false){ 152 153 $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name); … … 154 155 $block = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name. 155 156 if (!empty($block_theme_file['error'])) 156 $block['err_message'] = $block_theme_file['error']; 157 } else { 158 global $xoops_config,$xoopsUserIsAdmin; 159 $cache_dir = $xoops_config->xoops_cache_path; 160 if(!is_writable($cache_dir)){ 161 $block['err_message'] = _MB_XP2_CACHE_NOT_WRITABLE ; 162 if($xoopsUserIsAdmin) 163 $block['err_message'] .= " ($cache_dir)"; 157 $block['err_message'] .= $block_theme_file['error']; 158 } else { 159 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 160 $xml = xpress_block_cache_read($mydirname,$cache_title. $blockID); 161 $block = $xml['block']; 164 162 } else { 165 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 166 $xml = xpress_block_cache_read($mydirname,$cache_title. $blockID); 167 $block = $xml['block']; 168 } else { 169 $block['err_message'] = sprintf(_MB_XP2_BLOCK_CACHE_ERR, '<a href="' . XOOPS_URL . '/modules/' . $mydirname . '">' . $mydirname .'</a>'); 170 } 163 $block['err_message'] .= sprintf(_MB_XP2_BLOCK_CACHE_ERR, '<a href="' . XOOPS_URL . '/modules/' . $mydirname . '">' . $mydirname .'</a>'); 164 } 165 } 166 167 if(!cache_is_writable()){ 168 $block['err_message'] ='<span style="color:#ff0000">'; 169 $block['err_message'] .= _MB_XP2_CACHE_NOT_WRITABLE ; 170 if($xoopsUserIsAdmin){ 171 $block['err_message'] .= " ($cache_dir)"; 172 $block['err_message'] .= '</span>'; 171 173 } 172 174 } … … 253 255 if (!empty($block_theme_file['error'])) 254 256 $render_array['block']['err_message'] = $block_theme_file['error']; 255 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 256 $render_serialize = xpress_XML_serialize($render_array); 257 $render_md5 = md5($render_serialize); 258 259 $cache_serialize = xpress_cache_read($mydirname,$cache_title. $blockID.'.xml'); 260 $cache_md5 = md5($cache_serialize); 261 262 if ($render_md5 != $cache_md5){ 257 if(cache_is_writable()){ 258 if (xpress_block_cache_found($mydirname,$cache_title. $blockID)){ 259 $render_serialize = xpress_XML_serialize($render_array); 260 $render_md5 = md5($render_serialize); 261 262 $cache_serialize = xpress_cache_read($mydirname,$cache_title. $blockID.'.xml'); 263 $cache_md5 = md5($cache_serialize); 264 265 if ($render_md5 != $cache_md5){ 266 xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array); 267 } 268 } else { 263 269 xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array); 264 270 } 265 } else {266 xpress_block_cache_write($mydirname,$cache_title. $blockID, $render_array);267 271 } 268 272 }
Note: See TracChangeset
for help on using the changeset viewer.