1 | <?php
|
---|
2 |
|
---|
3 | //< style >< script >< link > tag is pulled out from the header of html contents.
|
---|
4 | function get_mod_header($contents)
|
---|
5 | {
|
---|
6 | $pattern = "<head[^>]*?>(.*)<\/head>";
|
---|
7 | preg_match("/".$pattern."/s", $contents, $head_matches);
|
---|
8 | $head_str = $head_matches[1];
|
---|
9 |
|
---|
10 | $pattern = "<style[^>]*?>(.*)<\/style>";
|
---|
11 | preg_match("/".$pattern."/s", $head_str, $style_matches);
|
---|
12 | if (empty($style_matches[0]))
|
---|
13 | $style = '';
|
---|
14 | else
|
---|
15 | $style = $style_matches[0];
|
---|
16 |
|
---|
17 | $pattern = "<link(.*)>";
|
---|
18 | preg_match_all("/".$pattern."/", $head_str, $link_match,PREG_PATTERN_ORDER);
|
---|
19 | $links = $link_match[0];
|
---|
20 | $link_str ='';
|
---|
21 | foreach ( $links as $link){
|
---|
22 | ob_start();
|
---|
23 | echo $link . "\n";
|
---|
24 |
|
---|
25 | $link_str .= ob_get_contents();
|
---|
26 | ob_end_clean();
|
---|
27 | }
|
---|
28 |
|
---|
29 | $pattern = "<script[^>]*?>(.*)<\/script>";
|
---|
30 | preg_match_all("/".$pattern."/s", $head_str, $script_match,PREG_PATTERN_ORDER);
|
---|
31 | $scripts = $script_match[0];
|
---|
32 | $script_str ='';
|
---|
33 | foreach ( $scripts as $script){
|
---|
34 | if (($GLOBALS["xoopsModuleConfig"]['use_d3forum'] != 1) || (strpos($script,'function wpopen') ===false))
|
---|
35 | $script_str .= $script;
|
---|
36 | }
|
---|
37 | return $link_str."\n".$style . "\n" . $script_str ."\n";
|
---|
38 | }
|
---|
39 |
|
---|
40 | // get sidebar rendaring
|
---|
41 | function get_sidebar_rander($name = null)
|
---|
42 | {
|
---|
43 | $templates = array();
|
---|
44 | if ( isset($name) )
|
---|
45 | $templates[] = "sidebar-{$name}.php";
|
---|
46 |
|
---|
47 | $templates[] = "sidebar.php";
|
---|
48 |
|
---|
49 | $link= locate_template($templates, false);
|
---|
50 | if ('' == $link)
|
---|
51 | $link = get_theme_root() . '/default/sidebar.php';
|
---|
52 |
|
---|
53 | ob_start();
|
---|
54 | require($link);
|
---|
55 | $sidebar = ob_get_contents();
|
---|
56 | ob_end_clean();
|
---|
57 | return $sidebar;
|
---|
58 | }
|
---|
59 |
|
---|
60 | // < body > tag is pulled out from the header of html contents.
|
---|
61 | function get_body($contents)
|
---|
62 | {
|
---|
63 | $xpess_config = new XPressME_Class();
|
---|
64 | $pattern = "<body[^>]*?>(.*)<\/body>";
|
---|
65 | preg_match("/".$pattern."/s", $contents, $body_matches);
|
---|
66 | $body = $body_matches[1];
|
---|
67 |
|
---|
68 | if (!$xpess_config->is_theme_sidebar_disp){
|
---|
69 | $side_panel = get_sidebar_rander();
|
---|
70 | $body = str_replace($side_panel,'',$body);
|
---|
71 | }
|
---|
72 | return $body;
|
---|
73 | }
|
---|
74 |
|
---|
75 | //Making of module header
|
---|
76 | function get_xpress_module_header($contents)
|
---|
77 | {
|
---|
78 | global $xoopsTpl;
|
---|
79 | if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
|
---|
80 | $preload_make_module_header = $xoopsTpl->get_template_vars('xoops_module_header');
|
---|
81 | } else {
|
---|
82 | $preload_make_module_header = '';
|
---|
83 | }
|
---|
84 |
|
---|
85 | if (! empty($preload_make_module_header)){
|
---|
86 | $preload_make_module_header = '<!-- preload added module header -->
|
---|
87 | ' . $preload_make_module_header . '
|
---|
88 | ';
|
---|
89 | }
|
---|
90 |
|
---|
91 | $wp_module_header = '<!-- wordpress added module header -->
|
---|
92 | ' . get_mod_header($contents) . '
|
---|
93 | <!-- end of wordpress added module header -->';
|
---|
94 |
|
---|
95 | return $preload_make_module_header . $wp_module_header;
|
---|
96 | }
|
---|
97 |
|
---|
98 | //rendering for the module header and the body
|
---|
99 | function xpress_render($contents){
|
---|
100 | global $xoops_config , $xoopsTpl;
|
---|
101 | $mydirname = basename(dirname(dirname(__FILE__)));
|
---|
102 | include $xoops_config->xoops_root_path ."/header.php";
|
---|
103 | $page_title = $GLOBALS["xoopsModule"]->getVar("name")." ".wp_title('»', false);
|
---|
104 | $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
|
---|
105 | $xoopsTpl->assign('xoops_pagetitle', $page_title);
|
---|
106 | $xpress_data['body_contents'] = get_body($contents);
|
---|
107 | // used $GLOBALS. becose xpress_left_arrow_post_link() and xpress_right_arrow_post_link() is other loop in this position
|
---|
108 | $xpress_data['left_post_link'] = $GLOBALS['left_arrow_post_link'];
|
---|
109 | $xpress_data['right_post_link'] = $GLOBALS['right_arrow_post_link'];
|
---|
110 | $xpress_data['left_posts_link'] = str_replace('«','',xpress_left_arrow_posts_link(false));
|
---|
111 | $xpress_data['right_posts_link'] = str_replace('»','',xpress_right_arrow_posts_link(false));
|
---|
112 | $xpress_data['now_user_level'] = xpress_now_user_level(false);
|
---|
113 |
|
---|
114 | $xoopsTpl->assign('xpress', $xpress_data);
|
---|
115 | $templates_file = 'db:'.$mydirname. '_index.html';
|
---|
116 | echo $xoopsTpl->fetch( $templates_file ) ;
|
---|
117 | require_once( ABSPATH .'/include/xpress_breadcrumbs.php' );
|
---|
118 | include $xoops_config->xoops_root_path . '/footer.php';
|
---|
119 | }
|
---|
120 |
|
---|
121 | ?> |
---|