[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();
|
---|
| 66 | wp_head();
|
---|
[650] | 67 | comment_quicktags_plus_patch();
|
---|
[573] | 68 | $header_str = ob_get_contents();
|
---|
| 69 | ob_end_clean();
|
---|
| 70 | $pattern = '<\s*link\s+rel\s*=[^>]*?>';
|
---|
| 71 | $header_str = preg_replace("/".$pattern."/s" , '' , $header_str);
|
---|
| 72 | $pattern = '<\s*meta\s+name\s*=[^>]*?>';
|
---|
| 73 | $header_str = preg_replace("/".$pattern."/i" , '' , $header_str);
|
---|
[580] | 74 | // $pattern = "<style type.*<\/style>";
|
---|
| 75 | // $header_str = preg_replace("/".$pattern."/s" , '' , $header_str);
|
---|
[573] | 76 | $pattern = "^\s*\n";
|
---|
| 77 | $header_str = preg_replace("/".$pattern."/m" , '' , $header_str);
|
---|
| 78 | $pattern = "^";
|
---|
| 79 | $header_str = preg_replace("/".$pattern."/m" , "\t" , $header_str);
|
---|
| 80 | ob_start();
|
---|
| 81 | wp_footer();
|
---|
| 82 | $footer_str = ob_get_contents();
|
---|
| 83 | ob_end_clean();
|
---|
| 84 | $pattern = "^";
|
---|
| 85 | $footer_str = preg_replace("/".$pattern."/m" , "\t" , $footer_str);
|
---|
| 86 |
|
---|
| 87 | $block_header = "<!-- XPressME added block header -->\n";
|
---|
| 88 | $block_header .= "\t<!-- from bloginfo('stylesheet_url') -->\n";
|
---|
| 89 | $block_header .= $stylesheet_link ."\n";
|
---|
| 90 | $block_header .= $block_stylesheet_link ."\n";
|
---|
| 91 | $block_header .= "\t<!-- from wp_head() -->\n";
|
---|
| 92 | $block_header .= $header_str ."\n";
|
---|
| 93 | $block_header .= "\t<!-- from wp_footer() -->\n";
|
---|
| 94 | $block_header .= $footer_str ."\n";
|
---|
| 95 | $block_header .= "<!-- end of XPressME added block header -->\n";
|
---|
| 96 | $data = array();
|
---|
| 97 | $data['block_header']= $block_header;
|
---|
| 98 | xpress_block_header_cash_write($mydirname,$data);
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | }
|
---|
| 102 | ?> |
---|