Changeset 448 for trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_common_functions.php
- Timestamp:
- Nov 20, 2009, 12:46:12 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/xpressme_integration_kit/wp-content/plugins/xpressme/include/xpress_common_functions.php
r389 r448 365 365 } 366 366 367 function get_block_file_path($mydirname,$file_name) 368 { 369 global $xoops_config, $xpress_config; 370 $mydirpath = $xoops_config->xoops_root_path . '/modules/' . $mydirname; 371 $select_theme = xpress_ThemeTemplate(get_xpress_theme_name($mydirname)); 372 $xpress_default_theme = 'xpress_default'; 373 $select_block = '/wp-content/themes/' . $select_theme . '/blocks/' . $file_name; 374 $default_block = '/wp-content/themes/xpress_default/blocks/' . $file_name; 375 $select_block_path = $mydirpath . $select_block; 376 $default_block_path = $mydirpath . $default_block; 377 378 $block_file_data = array(); 379 $block_file_data['file_path'] = $default_block_path; 380 $block_file_data['error'] = ''; 381 382 if($select_theme != $xpress_default_theme){ 383 if (file_exists($select_block_path)){ 384 $select_block_version = get_block_version($select_block_path); 385 $default_block_version = get_block_version($default_block_path); 386 if (version_compare($select_block_version,$default_block_version, "<")){ 387 $block_file_data['file_path'] = $default_block_path; 388 if ($xpress_config->is_block_error_display){ 389 $error_str = '<div style="color:red">'; 390 $error_str .= sprintf(__('Block file %1$s is an old version %2$s.<br />used block file %3$s of new version %4$s.','xpressme'),$select_block,$select_block_version,$default_block,$default_block_version); 391 $error_str .= '</div>'; 392 $block_file_data['error'] = $error_str; 393 } 394 } else { 395 $block_file_data['file_path'] = $select_block_path; 396 $block_file_data['error'] = ''; 397 } 398 } 399 } 400 return $block_file_data; 401 } 402 403 function get_block_version($file_path = ''){ 404 $array_file = file($file_path); 405 $pattern = '^[\s|\/]*[B|b]lock\s+[V|v]ersion\s*[:|;]\s*([0-9|.]*)'; 406 $version = '0.1'; 407 if (empty($file_path)) return $version; 408 if (!file_exists($file_path)) return $version; 409 if (count($array_file) > 5) $file_count = 5; else $file_count = count($array_file); 410 for ($i = 0 ; $i < $file_count ; $i++){ 411 if (preg_match('/' . $pattern . '/' ,$array_file[$i],$matchs)){ 412 $version = $matchs[1]; 413 break; 414 } 415 } 416 return $version; 417 } 418 367 419 ?>
Note: See TracChangeset
for help on using the changeset viewer.