[1] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | //< style >< script >< link > tag is pulled out from the header of html contents.
|
---|
| 4 | function get_mod_header($contents)
|
---|
| 5 | {
|
---|
[201] | 6 | global $xpress_config;
|
---|
[1] | 7 | $pattern = "<head[^>]*?>(.*)<\/head>";
|
---|
| 8 | preg_match("/".$pattern."/s", $contents, $head_matches);
|
---|
| 9 | $head_str = $head_matches[1];
|
---|
| 10 |
|
---|
[201] | 11 | $pattern = '<head[^>]*?>';
|
---|
| 12 | $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
|
---|
| 13 | $pattern = '<\/head>';
|
---|
| 14 | $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
|
---|
| 15 | $pattern = '<\s*html\s+xmlns[^>]*?>';
|
---|
| 16 | $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
|
---|
| 17 | $pattern = '<\s*head\s+profile[^>]*?>';
|
---|
| 18 | $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
|
---|
| 19 | $pattern = '<\s*meta\s+http-equiv[^>]*?>';
|
---|
| 20 | $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
|
---|
| 21 | $pattern = '<title[^>]*?>(.*)<\s*\/\s*title\s*>';
|
---|
| 22 | $head_str = preg_replace("/".$pattern."/s" , '' , $head_str);
|
---|
| 23 |
|
---|
| 24 | $head_str = meta_name_cut('robots',$head_str);
|
---|
| 25 | $head_str = meta_name_cut('keywords',$head_str);
|
---|
| 26 | $head_str = meta_name_cut('description',$head_str);
|
---|
| 27 | $head_str = meta_name_cut('rating',$head_str);
|
---|
| 28 | $head_str = meta_name_cut('author',$head_str);
|
---|
| 29 | $head_str = meta_name_cut('copyright',$head_str);
|
---|
| 30 | $head_str = meta_name_cut('generator',$head_str);
|
---|
| 31 |
|
---|
| 32 | $head_str = preg_replace("/^(\s)*(\r|\n|\r\n)/m", "", $head_str);
|
---|
| 33 | return $head_str;
|
---|
[1] | 34 | }
|
---|
| 35 |
|
---|
[201] | 36 | function meta_name_cut($name = '', $head_str)
|
---|
| 37 | {
|
---|
| 38 | $pattern = '<\s*meta\s+name\s*=\s*["\']' . $name . '["\'][^>]*?>';
|
---|
| 39 | $head_str = preg_replace("/".$pattern."/i" , '' , $head_str);
|
---|
| 40 | return $head_str;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
| 43 | // for title reprace plugin (all in one seo pack)
|
---|
| 44 | function get_xpress_title($contents)
|
---|
| 45 | {
|
---|
| 46 | $pattern = '<title[^>]*?>(.*)<\s*\/\s*title\s*>';
|
---|
| 47 | preg_match("/".$pattern."/i", $contents, $head_matches);
|
---|
| 48 | $title_str = $head_matches[1];
|
---|
| 49 | return $title_str;
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | function get_xpress_meta_name($name = '',$contents)
|
---|
| 53 | {
|
---|
| 54 | $pattern = '<\s*meta\s+name\s*=\s*["\']' . $name . '["\']\s*content\s*=\s*[\'"](.*)[\'"]\s*\/\s*>';
|
---|
| 55 | preg_match("/".$pattern."/i", $contents, $head_matches);
|
---|
| 56 | $meta = $head_matches[1];
|
---|
| 57 | return $meta;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
[26] | 60 | // get sidebar rendaring
|
---|
| 61 | function get_sidebar_rander($name = null)
|
---|
| 62 | {
|
---|
| 63 | $templates = array();
|
---|
| 64 | if ( isset($name) )
|
---|
| 65 | $templates[] = "sidebar-{$name}.php";
|
---|
| 66 |
|
---|
| 67 | $templates[] = "sidebar.php";
|
---|
| 68 |
|
---|
| 69 | $link= locate_template($templates, false);
|
---|
| 70 | if ('' == $link)
|
---|
| 71 | $link = get_theme_root() . '/default/sidebar.php';
|
---|
| 72 |
|
---|
| 73 | ob_start();
|
---|
| 74 | require($link);
|
---|
| 75 | $sidebar = ob_get_contents();
|
---|
| 76 | ob_end_clean();
|
---|
| 77 | return $sidebar;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
[1] | 80 | // < body > tag is pulled out from the header of html contents.
|
---|
| 81 | function get_body($contents)
|
---|
| 82 | {
|
---|
[26] | 83 | $xpess_config = new XPressME_Class();
|
---|
[1] | 84 | $pattern = "<body[^>]*?>(.*)<\/body>";
|
---|
| 85 | preg_match("/".$pattern."/s", $contents, $body_matches);
|
---|
| 86 | $body = $body_matches[1];
|
---|
[26] | 87 |
|
---|
| 88 | if (!$xpess_config->is_theme_sidebar_disp){
|
---|
| 89 | $side_panel = get_sidebar_rander();
|
---|
| 90 | $body = str_replace($side_panel,'',$body);
|
---|
| 91 | }
|
---|
[1] | 92 | return $body;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | //Making of module header
|
---|
| 96 | function get_xpress_module_header($contents)
|
---|
| 97 | {
|
---|
| 98 | global $xoopsTpl;
|
---|
| 99 | if( defined( 'XOOPS_CUBE_LEGACY' ) ) {
|
---|
| 100 | $preload_make_module_header = $xoopsTpl->get_template_vars('xoops_module_header');
|
---|
| 101 | } else {
|
---|
| 102 | $preload_make_module_header = '';
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | if (! empty($preload_make_module_header)){
|
---|
| 106 | $preload_make_module_header = '<!-- preload added module header -->
|
---|
| 107 | ' . $preload_make_module_header . '
|
---|
| 108 | ';
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | $wp_module_header = '<!-- wordpress added module header -->
|
---|
| 112 | ' . get_mod_header($contents) . '
|
---|
| 113 | <!-- end of wordpress added module header -->';
|
---|
| 114 |
|
---|
| 115 | return $preload_make_module_header . $wp_module_header;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | //rendering for the module header and the body
|
---|
| 119 | function xpress_render($contents){
|
---|
[201] | 120 | global $xoops_config , $xoopsTpl,$xpress_config;
|
---|
[109] | 121 | $mydirname = basename(dirname(dirname(__FILE__)));
|
---|
[96] | 122 | include $xoops_config->xoops_root_path ."/header.php";
|
---|
[1] | 123 | $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
|
---|
[201] | 124 | $page_title = $GLOBALS["xoopsModule"]->getVar("name"). ' »'. get_xpress_title($contents);
|
---|
[1] | 125 | $xoopsTpl->assign('xoops_pagetitle', $page_title);
|
---|
[201] | 126 |
|
---|
| 127 | $xoops_keywords = $xoopsTpl->get_template_vars('xoops_meta_keywords');
|
---|
| 128 | $wp_keyword = get_xpress_meta_name('keywords',$contents);
|
---|
| 129 | switch ($xpress_config->meta_keyword_type){
|
---|
| 130 | case 'xoops':
|
---|
| 131 | break;
|
---|
| 132 | case 'wordpress':
|
---|
| 133 | if (!empty($wp_keyword))
|
---|
| 134 | $xoopsTpl->assign('xoops_meta_keywords', $wp_keyword);
|
---|
| 135 | break;
|
---|
| 136 | case 'wordpress_xoops':
|
---|
| 137 | if (!empty($wp_keyword)){
|
---|
| 138 | if (!empty($xoops_keywords)){
|
---|
| 139 | $keywords = $wp_keyword . ', ' . $xoops_keywords;
|
---|
| 140 | } else {
|
---|
| 141 | $keywords = $wp_keyword;
|
---|
| 142 | }
|
---|
| 143 | $xoopsTpl->assign('xoops_meta_keywords', $keywords);
|
---|
| 144 | }
|
---|
| 145 | break;
|
---|
| 146 | default :
|
---|
| 147 | }
|
---|
| 148 |
|
---|
| 149 | $xoops_description = $xoopsTpl->get_template_vars('xoops_meta_description');
|
---|
| 150 | $wp_description = get_xpress_meta_name('description',$contents);
|
---|
| 151 | switch ($xpress_config->meta_description_type){
|
---|
| 152 | case 'xoops':
|
---|
| 153 | break;
|
---|
| 154 | case 'wordpress':
|
---|
| 155 | if (!empty($wp_description))
|
---|
| 156 | $xoopsTpl->assign('xoops_meta_description', $wp_description);
|
---|
| 157 | break;
|
---|
| 158 | case 'wordpress_xoops':
|
---|
| 159 | if (!empty($wp_description)){
|
---|
| 160 | if (!empty($xoops_description)){
|
---|
| 161 | $description = $wp_description . ' ' . $xoops_description;
|
---|
| 162 | } else {
|
---|
| 163 | $description = $wp_description;
|
---|
| 164 | }
|
---|
| 165 | $xoopsTpl->assign('xoops_meta_description', $description);
|
---|
| 166 | }
|
---|
| 167 | break;
|
---|
| 168 | default :
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 |
|
---|
[164] | 172 | $xpress_data['body_contents'] = get_body($contents);
|
---|
| 173 | // used $GLOBALS. becose xpress_left_arrow_post_link() and xpress_right_arrow_post_link() is other loop in this position
|
---|
| 174 | $xpress_data['left_post_link'] = $GLOBALS['left_arrow_post_link'];
|
---|
| 175 | $xpress_data['right_post_link'] = $GLOBALS['right_arrow_post_link'];
|
---|
| 176 | $xpress_data['left_posts_link'] = str_replace('«','',xpress_left_arrow_posts_link(false));
|
---|
| 177 | $xpress_data['right_posts_link'] = str_replace('»','',xpress_right_arrow_posts_link(false));
|
---|
| 178 | $xpress_data['now_user_level'] = xpress_now_user_level(false);
|
---|
| 179 |
|
---|
| 180 | $xoopsTpl->assign('xpress', $xpress_data);
|
---|
[109] | 181 | $templates_file = 'db:'.$mydirname. '_index.html';
|
---|
| 182 | echo $xoopsTpl->fetch( $templates_file ) ;
|
---|
[96] | 183 | require_once( ABSPATH .'/include/xpress_breadcrumbs.php' );
|
---|
| 184 | include $xoops_config->xoops_root_path . '/footer.php';
|
---|
[1] | 185 | }
|
---|
| 186 |
|
---|
| 187 | ?> |
---|