[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' ;
|
---|
[757] | 6 | global $mod_info;
|
---|
[573] | 7 |
|
---|
[757] | 8 | if (!is_object($mod_info)){ // is call other modules
|
---|
| 9 | require_once dirname(dirname( __FILE__ )) .'/class/modInfo_class.php' ;
|
---|
| 10 | $mod_info = new modInfoClass;
|
---|
[573] | 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 | }
|
---|
[719] | 20 | if(cache_is_writable())
|
---|
| 21 | xpress_cache_write($mydirname,$xml_name,$xml);
|
---|
[573] | 22 | }
|
---|
| 23 | function xpress_block_header_cache_read($mydirname)
|
---|
| 24 | {
|
---|
| 25 | $xml_name = 'block_header.xml';
|
---|
| 26 | $xml_data = xpress_cache_read($mydirname,$xml_name);
|
---|
| 27 |
|
---|
| 28 | $GLOBALS['DO_LIBXML_PATCH'] = get_xpress_mod_config($mydirname,'libxml_patch');
|
---|
| 29 |
|
---|
| 30 | // The character-code not treatable exists when 'XML_unserialize' of PHP5 processes EUC-JP.
|
---|
| 31 | // And, the result is returned by character-code UTF-8.
|
---|
| 32 | // Measures
|
---|
| 33 | // After the character-code is converted into UTF-8, XML_unserialize will be processed.
|
---|
| 34 | if ( strstr($xml_data, '<?xml version="1.0" encoding="EUC-JP" ?>') !== false
|
---|
| 35 | && version_compare(PHP_VERSION, '5.0.0', '>') )
|
---|
| 36 | {
|
---|
| 37 | $xml_data = str_replace('<?xml version="1.0" encoding="EUC-JP" ?>', '<?xml version="1.0" encoding="UTF-8" ?>', $xml_data);
|
---|
| 38 | $ans = mb_convert_variables('UTF-8' , 'EUC-JP', &$xml_data); //EUC-JP to UTF-8
|
---|
| 39 | $ret = @xpress_XML_unserialize($xml_data);
|
---|
| 40 | $ans = mb_convert_variables('EUC-JP' , 'UTF-8', &$ret); //UTF-8 to EUC-JP
|
---|
| 41 | } else {
|
---|
| 42 | $ret = xpress_XML_unserialize($xml_data);
|
---|
| 43 | }
|
---|
| 44 | return $ret;
|
---|
| 45 | }
|
---|
| 46 | function get_block_stylesheet_url($mydirname)
|
---|
| 47 | {
|
---|
[757] | 48 | global $mod_info;
|
---|
| 49 | $mydirpath = $mod_info->get_xoops_root_path() . '/modules/' . $mydirname;
|
---|
[573] | 50 | $select_theme = get_xpress_theme_name($mydirname);
|
---|
| 51 | $style_file = $mydirpath . '/wp-content/themes/' . $select_theme . '/blocks/block_style.css';
|
---|
| 52 | if (file_exists($style_file))
|
---|
[757] | 53 | return $mod_info->get_xoops_url() . '/modules/' .$mydirname . '/wp-content/themes/' . $select_theme . '/blocks/block_style.css';
|
---|
[573] | 54 | else
|
---|
[757] | 55 | return $mod_info->get_xoops_url() . '/modules/' .$mydirname . '/wp-content/themes/xpress_default/blocks/block_style.css';
|
---|
[573] | 56 | }
|
---|
| 57 |
|
---|
| 58 | function set_xpress_block_header($mydirname)
|
---|
| 59 | {
|
---|
| 60 | ob_start();
|
---|
| 61 | bloginfo('stylesheet_url');
|
---|
| 62 | $stylesheet_link = "\t".'<link rel="stylesheet" href="' . ob_get_contents() . '" type="text/css" media="screen" />';
|
---|
| 63 | ob_end_clean();
|
---|
| 64 | $block_stylesheet_link = "\t".'<link rel="stylesheet" href="' . get_block_stylesheet_url($mydirname) . '" type="text/css" media="screen" />';
|
---|
| 65 |
|
---|
| 66 | ob_start();
|
---|
[655] | 67 | $now_ob_level = ob_get_level();
|
---|
[573] | 68 | wp_head();
|
---|
[655] | 69 | ob_end_flush_child($now_ob_level);
|
---|
[573] | 70 | $header_str = ob_get_contents();
|
---|
| 71 | ob_end_clean();
|
---|
[683] | 72 |
|
---|
| 73 | if(function_exists('_admin_bar_bump_cb')){
|
---|
| 74 | //remove admin_bar_bump_cb
|
---|
| 75 | ob_start();
|
---|
| 76 | _admin_bar_bump_cb();
|
---|
| 77 | $admin_bar_bump_cb_str = ob_get_contents();
|
---|
| 78 | ob_end_clean();
|
---|
| 79 | $header_str = str_replace_ex($admin_bar_bump_cb_str,'',$header_str);
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | if(function_exists('wp_admin_bar_header')){
|
---|
| 83 | //remove wp_adminbar_header
|
---|
| 84 | ob_start();
|
---|
| 85 | wp_admin_bar_header();
|
---|
| 86 | $wp_admin_bar_header_str = ob_get_contents();
|
---|
| 87 | ob_end_clean();
|
---|
| 88 | $header_str = str_replace_ex($wp_admin_bar_header_str,'',$header_str);
|
---|
| 89 | }
|
---|
| 90 |
|
---|
[573] | 91 | $pattern = '<\s*link\s+rel\s*=[^>]*?>';
|
---|
| 92 | $header_str = preg_replace("/".$pattern."/s" , '' , $header_str);
|
---|
| 93 | $pattern = '<\s*meta\s+name\s*=[^>]*?>';
|
---|
| 94 | $header_str = preg_replace("/".$pattern."/i" , '' , $header_str);
|
---|
[580] | 95 | // $pattern = "<style type.*<\/style>";
|
---|
| 96 | // $header_str = preg_replace("/".$pattern."/s" , '' , $header_str);
|
---|
[573] | 97 | $pattern = "^\s*\n";
|
---|
| 98 | $header_str = preg_replace("/".$pattern."/m" , '' , $header_str);
|
---|
| 99 | $pattern = "^";
|
---|
| 100 | $header_str = preg_replace("/".$pattern."/m" , "\t" , $header_str);
|
---|
[683] | 101 |
|
---|
| 102 | ob_start();
|
---|
| 103 | global $show_admin_bar;
|
---|
| 104 | $show_admin_bar = false; //remove adminbar
|
---|
[573] | 105 | wp_footer();
|
---|
| 106 | $footer_str = ob_get_contents();
|
---|
| 107 | ob_end_clean();
|
---|
| 108 | $pattern = "^";
|
---|
| 109 | $footer_str = preg_replace("/".$pattern."/m" , "\t" , $footer_str);
|
---|
| 110 |
|
---|
| 111 | $block_header = "<!-- XPressME added block header -->\n";
|
---|
| 112 | $block_header .= "\t<!-- from bloginfo('stylesheet_url') -->\n";
|
---|
| 113 | $block_header .= $stylesheet_link ."\n";
|
---|
| 114 | $block_header .= $block_stylesheet_link ."\n";
|
---|
| 115 | $block_header .= "\t<!-- from wp_head() -->\n";
|
---|
| 116 | $block_header .= $header_str ."\n";
|
---|
| 117 | $block_header .= "\t<!-- from wp_footer() -->\n";
|
---|
| 118 | $block_header .= $footer_str ."\n";
|
---|
| 119 | $block_header .= "<!-- end of XPressME added block header -->\n";
|
---|
| 120 | $data = array();
|
---|
| 121 | $data['block_header']= $block_header;
|
---|
| 122 | xpress_block_header_cash_write($mydirname,$data);
|
---|
| 123 | }
|
---|
[683] | 124 |
|
---|
| 125 | function str_replace_ex($regx,$replace,$str){
|
---|
| 126 |
|
---|
| 127 | if (empty($regx)) return $str;
|
---|
| 128 | $pattern = preg_quote($regx,'/');
|
---|
| 129 | if (preg_match('/\r/',$pattern)){
|
---|
| 130 | $pattern=preg_replace('/\r/','\\r',$pattern);
|
---|
| 131 | }
|
---|
| 132 | if (preg_match('/\n/',$pattern)){
|
---|
| 133 | $pattern=preg_replace('/\n/','\\n',$pattern);
|
---|
| 134 | }
|
---|
| 135 | if (preg_match('/\t/',$pattern)){
|
---|
| 136 | $pattern=preg_replace('/\t/','\\t',$pattern);
|
---|
| 137 | }
|
---|
| 138 | $pattern = '/'. $pattern . '/';
|
---|
| 139 | if (preg_match($pattern,$str)){
|
---|
| 140 | $str=preg_replace($pattern,$replace,$str);
|
---|
| 141 | }
|
---|
| 142 | return $str;
|
---|
| 143 | }
|
---|
[573] | 144 |
|
---|
| 145 | }
|
---|
| 146 | ?> |
---|