[573] | 1 | <?php
|
---|
| 2 | if(!defined('XPRESS_BLOCK_HEADER_FUNCTION_READ')){
|
---|
| 3 | define('XPRESS_BLOCK_HEADER_FUNCTION_READ',1);
|
---|
| 4 | require_once dirname( __FILE__ ) .'/xml.php' ;
|
---|
| 5 | require_once dirname( __FILE__ ) .'/xpress_cache.php' ;
|
---|
| 6 | global $xoops_config;
|
---|
| 7 |
|
---|
| 8 | if (!is_object($xoops_config)){ // is call other modules
|
---|
| 9 | require_once dirname(dirname( __FILE__ )) .'/class/config_from_xoops.class.php' ;
|
---|
| 10 | $xoops_config = new ConfigFromXoops;
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | function xpress_block_header_cash_write($mydirname,$block_header)
|
---|
| 14 | {
|
---|
| 15 | $xml = xpress_XML_serialize($block_header);
|
---|
| 16 | $xml_name = 'block_header.xml';
|
---|
| 17 | if (WPLANG == 'ja_EUC'){
|
---|
| 18 | $xml = str_replace('<?xml version="1.0" ?>', '<?xml version="1.0" encoding="EUC-JP" ?>' , $xml);
|
---|
| 19 | }
|
---|
| 20 | xpress_cache_write($mydirname,$xml_name,$xml);
|
---|
| 21 | }
|
---|
| 22 | function xpress_block_header_cache_read($mydirname)
|
---|
| 23 | {
|
---|
| 24 | $xml_name = 'block_header.xml';
|
---|
| 25 | $xml_data = xpress_cache_read($mydirname,$xml_name);
|
---|
| 26 |
|
---|
| 27 | $GLOBALS['DO_LIBXML_PATCH'] = get_xpress_mod_config($mydirname,'libxml_patch');
|
---|
| 28 |
|
---|
| 29 | // The character-code not treatable exists when 'XML_unserialize' of PHP5 processes EUC-JP.
|
---|
| 30 | // And, the result is returned by character-code UTF-8.
|
---|
| 31 | // Measures
|
---|
| 32 | // After the character-code is converted into UTF-8, XML_unserialize will be processed.
|
---|
| 33 | if ( strstr($xml_data, '<?xml version="1.0" encoding="EUC-JP" ?>') !== false
|
---|
| 34 | && version_compare(PHP_VERSION, '5.0.0', '>') )
|
---|
| 35 | {
|
---|
| 36 | $xml_data = str_replace('<?xml version="1.0" encoding="EUC-JP" ?>', '<?xml version="1.0" encoding="UTF-8" ?>', $xml_data);
|
---|
| 37 | $ans = mb_convert_variables('UTF-8' , 'EUC-JP', &$xml_data); //EUC-JP to UTF-8
|
---|
| 38 | $ret = @xpress_XML_unserialize($xml_data);
|
---|
| 39 | $ans = mb_convert_variables('EUC-JP' , 'UTF-8', &$ret); //UTF-8 to EUC-JP
|
---|
| 40 | } else {
|
---|
| 41 | $ret = xpress_XML_unserialize($xml_data);
|
---|
| 42 | }
|
---|
| 43 | return $ret;
|
---|
| 44 | }
|
---|
| 45 | function get_block_stylesheet_url($mydirname)
|
---|
| 46 | {
|
---|
| 47 | global $xoops_config;
|
---|
| 48 | $mydirpath = $xoops_config->xoops_root_path . '/modules/' . $mydirname;
|
---|
| 49 | $select_theme = get_xpress_theme_name($mydirname);
|
---|
| 50 | $style_file = $mydirpath . '/wp-content/themes/' . $select_theme . '/blocks/block_style.css';
|
---|
| 51 | if (file_exists($style_file))
|
---|
| 52 | return $xoops_config->xoops_url . '/modules/' .$mydirname . '/wp-content/themes/' . $select_theme . '/blocks/block_style.css';
|
---|
| 53 | else
|
---|
| 54 | return $xoops_config->xoops_url . '/modules/' .$mydirname . '/wp-content/themes/xpress_default/blocks/block_style.css';
|
---|
| 55 | }
|
---|
| 56 |
|
---|
| 57 | function set_xpress_block_header($mydirname)
|
---|
| 58 | {
|
---|
| 59 | ob_start();
|
---|
| 60 | bloginfo('stylesheet_url');
|
---|
| 61 | $stylesheet_link = "\t".'<link rel="stylesheet" href="' . ob_get_contents() . '" type="text/css" media="screen" />';
|
---|
| 62 | ob_end_clean();
|
---|
| 63 | $block_stylesheet_link = "\t".'<link rel="stylesheet" href="' . get_block_stylesheet_url($mydirname) . '" type="text/css" media="screen" />';
|
---|
| 64 |
|
---|
| 65 | ob_start();
|
---|
[655] | 66 | $now_ob_level = ob_get_level();
|
---|
[573] | 67 | wp_head();
|
---|
[655] | 68 | ob_end_flush_child($now_ob_level);
|
---|
[573] | 69 | $header_str = ob_get_contents();
|
---|
| 70 | ob_end_clean();
|
---|
| 71 | $pattern = '<\s*link\s+rel\s*=[^>]*?>';
|
---|
| 72 | $header_str = preg_replace("/".$pattern."/s" , '' , $header_str);
|
---|
| 73 | $pattern = '<\s*meta\s+name\s*=[^>]*?>';
|
---|
| 74 | $header_str = preg_replace("/".$pattern."/i" , '' , $header_str);
|
---|
[580] | 75 | // $pattern = "<style type.*<\/style>";
|
---|
| 76 | // $header_str = preg_replace("/".$pattern."/s" , '' , $header_str);
|
---|
[573] | 77 | $pattern = "^\s*\n";
|
---|
| 78 | $header_str = preg_replace("/".$pattern."/m" , '' , $header_str);
|
---|
| 79 | $pattern = "^";
|
---|
| 80 | $header_str = preg_replace("/".$pattern."/m" , "\t" , $header_str);
|
---|
| 81 | ob_start();
|
---|
| 82 | wp_footer();
|
---|
| 83 | $footer_str = ob_get_contents();
|
---|
| 84 | ob_end_clean();
|
---|
| 85 | $pattern = "^";
|
---|
| 86 | $footer_str = preg_replace("/".$pattern."/m" , "\t" , $footer_str);
|
---|
| 87 |
|
---|
| 88 | $block_header = "<!-- XPressME added block header -->\n";
|
---|
| 89 | $block_header .= "\t<!-- from bloginfo('stylesheet_url') -->\n";
|
---|
| 90 | $block_header .= $stylesheet_link ."\n";
|
---|
| 91 | $block_header .= $block_stylesheet_link ."\n";
|
---|
| 92 | $block_header .= "\t<!-- from wp_head() -->\n";
|
---|
| 93 | $block_header .= $header_str ."\n";
|
---|
| 94 | $block_header .= "\t<!-- from wp_footer() -->\n";
|
---|
| 95 | $block_header .= $footer_str ."\n";
|
---|
| 96 | $block_header .= "<!-- end of XPressME added block header -->\n";
|
---|
| 97 | $data = array();
|
---|
| 98 | $data['block_header']= $block_header;
|
---|
| 99 | xpress_block_header_cash_write($mydirname,$data);
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | }
|
---|
| 103 | ?> |
---|