- Timestamp:
- Dec 15, 2009, 4:52:57 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/XPressMU/xpressme_integration_kit/include/xpress_block_render.php
r451 r488 29 29 $ret = @xpress_XML_unserialize($xml_data); 30 30 if (strstr($xml_data, '<?xml version="1.0" encoding="EUC-JP" ?>') !== false){ 31 $ans = mb_convert_variables('EUC-JP' , 'UTF-8', &$ret); 31 if (version_compare(PHP_VERSION, '5.0.0', '>')) { 32 $ans = mb_convert_variables('EUC-JP' , 'UTF-8', &$ret); //xpress_XML_unserialize() Return UTF-8 at PHP5 33 } 32 34 } 33 35 return $ret; … … 52 54 } 53 55 return $block_id; 56 } 57 58 function get_block_mid($mydirname) 59 { 60 $xoopsDB =& Database::getInstance(); 61 $modules_tbl = $xoopsDB->prefix('modules'); 62 63 $sql = "SELECT mid FROM $modules_tbl WHERE dirname = '$mydirname'"; 64 $result = $xoopsDB->query($sql, 0, 0); 65 if ($xoopsDB->getRowsNum($result) > 0){ 66 $row = $xoopsDB->fetchArray($result); 67 $mid = $row['mid']; 68 } 69 return $mid; 54 70 } 55 71 … … 160 176 function xpress_block_render($mydirname,$block_function_name,$options) 161 177 { 162 global $wpdb ;178 global $wpdb,$xoops_config; 163 179 $func_file = $block_function_name; 164 180 $call_theme_function_name = str_replace(".php", "", $block_function_name); … … 167 183 $blockID =get_block_id($mydirname,$func_file,$options); 168 184 169 $this_ url = '/modules/'. $mydirname;185 $this_block_url = '/' . $mydirname . '/'; 170 186 $call_url = $_SERVER['REQUEST_URI']; 171 187 172 188 xpress_block_css_set($mydirname); 173 if (strstr($call_url ,$this_url)){189 if (strstr($call_url , $this_block_url) !== false){ 174 190 $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name); 175 191 require_once $block_theme_file['file_path']; … … 185 201 } 186 202 } 187 188 $templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 203 $temp_option = explode(':' , $options[1]); 204 205 if (isset($temp_option[1])) { 206 $templates_file = $temp_option[1]; 207 } else { 208 $templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 209 } 210 189 211 $tpl =& new XoopsTpl() ; 212 $tpl->template_dir = $xoops_config->module_path . '/templates'; 213 if (!$tpl->template_exists($templates_file)){ 214 $src_file_path = $xoops_config->module_path . '/templates/' .$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 215 $templates_file = add_xpress_tpl($mydirname,$templates_file,$src_file_path); 216 } 190 217 $tpl->assign( 'block' , $block ) ; 191 218 $ret['content'] = $tpl->fetch( $templates_file ) ; 192 219 return $ret ; 220 } 221 222 function add_xpress_tpl($mydirname,$templates='',$src_file_path){ 223 global $wpdb,$xoops_config , $xoops_db; 224 225 $mid = get_block_mid($mydirname); 226 227 $temp_parm = explode(':' , $templates); 228 if (empty($temp_parm[1])) { 229 $filename=$temp_parm[0]; 230 $type = 'db'; 231 } else { 232 $filename=$temp_parm[1]; 233 $type = $temp_parm[0]; 234 } 235 $temp_file_path = $xoops_config->module_path . '/templates/'. $filename; 236 $pattern = '^' . $mydirname . '_'; 237 if (preg_match('/' . $pattern . '/' , $filename, $match)){ // file prefix check 238 if (!file_exists($temp_file_path)){ // Repetition check 239 if (file_exists($src_file_path)){ // source file check 240 $rcd = copy($src_file_path, $temp_file_path); 241 } 242 } 243 return 'file:' . $filename; 244 } 245 return $templates; 193 246 } 194 247 … … 243 296 { 244 297 global $xoops_db,$xoops_config; 298 245 299 $mid = get_xpress_modid(); 246 300 $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1"; … … 260 314 if ($dh = opendir($cache_dir)) { 261 315 while (($file = readdir($dh)) !== false) { 262 if (preg_match('/^' . preg_quote($mydirname) . ' /', $file)) {316 if (preg_match('/^' . preg_quote($mydirname) . '_/', $file)) { 263 317 if(! preg_match('/' . $pattern . '/', $file)) { 264 318 unlink($cache_dir.$file); … … 287 341 return $xu_row['conf_value']; 288 342 } 289 } 290 343 } 291 344 } 292 345 ?>
Note: See TracChangeset
for help on using the changeset viewer.