- Timestamp:
- Nov 27, 2009, 3:27:01 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/include/xpress_block_render.php
r456 r463 52 52 } 53 53 return $block_id; 54 } 55 56 function get_block_mid($mydirname) 57 { 58 $xoopsDB =& Database::getInstance(); 59 $modules_tbl = $xoopsDB->prefix('modules'); 60 61 $sql = "SELECT mid FROM $modules_tbl WHERE dirname = '$mydirname'"; 62 $result = $xoopsDB->query($sql, 0, 0); 63 if ($xoopsDB->getRowsNum($result) > 0){ 64 $row = $xoopsDB->fetchArray($result); 65 $mid = $row['mid']; 66 } 67 return $mid; 54 68 } 55 69 … … 190 204 $option = explode('|' , $block['options']); 191 205 192 if (isset($option[1])) 206 if (isset($option[1])) { 193 207 $templates_file = $option[1]; 194 else208 } else { 195 209 $templates_file = 'db:'.$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 210 } 211 196 212 $tpl =& new XoopsTpl() ; 213 $tpl->template_dir = $xoops_config->module_path . '/templates'; 214 if (!$tpl->template_exists($templates_file)){ 215 $src_file_path = $xoops_config->module_path . '/templates/' .$mydirname. '_' . str_replace(".php", ".html", $block_function_name); 216 add_xpress_tpl($mydirname,$templates_file,$src_file_path); 217 } 197 218 $tpl->assign( 'block' , $block ) ; 198 219 $ret['content'] = $tpl->fetch( $templates_file ) ; 199 220 return $ret ; 221 } 222 223 function add_xpress_tpl($mydirname,$templates='',$src_file_path){ 224 global $wpdb,$xoops_config , $xoops_db; 225 226 $mid = get_block_mid($mydirname); 227 228 $temp_parm = explode(':' , $templates); 229 if (empty($temp_parm[1])) { 230 $filename=$temp_parm[0]; 231 $type = 'db'; 232 } else { 233 $filename=$temp_parm[1]; 234 $type = $temp_parm[0]; 235 } 236 $temp_file_path = $xoops_config->module_path . '/templates/'. $filename; 237 $pattern = '^' . $mydirname . '_'; 238 if (preg_match('/' . $pattern . '/' , $filename, $match)){ // file prefix check 239 if (!file_exists($temp_file_path)){ // Repetition check 240 if (file_exists($src_file_path)){ // source file check 241 $rcd = copy($src_file_path, $temp_file_path); 242 } 243 } 244 } 200 245 } 201 246 … … 250 295 { 251 296 global $xoops_db,$xoops_config; 297 252 298 $mid = get_xpress_modid(); 253 299 $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid AND visible = 1"; … … 294 340 return $xu_row['conf_value']; 295 341 } 296 } 297 342 } 298 343 } 299 344 ?>
Note: See TracChangeset
for help on using the changeset viewer.