[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 |
|
---|
[229] | 118 | //PHP_SELF and GET are remake for the XOOPS event notification.
|
---|
| 119 | function xpress_remake_global_for_permlink(){
|
---|
| 120 | global $wp_db,$wp_query;
|
---|
| 121 | $php_self = $_SERVER['PHP_SELF'];
|
---|
| 122 | $get = $_GET;
|
---|
| 123 |
|
---|
| 124 | if (preg_match('/\/$/',$php_self) && !preg_match('/index.php/',$php_self)) {
|
---|
| 125 | $php_self = $php_self . 'index.php';
|
---|
| 126 | $_SERVER['PHP_SELF'] = $php_self;
|
---|
| 127 | }
|
---|
| 128 | if (empty($_GET)){
|
---|
| 129 | $query_vars = $wp_query->query_vars;
|
---|
| 130 | $post = $wp_query->post;
|
---|
| 131 | if ($wp_query->is_single) {
|
---|
| 132 | $_GET = array('p'=>$post->ID);
|
---|
| 133 | } else if($wp_query->is_category){
|
---|
| 134 | $_GET = array('cat'=>$query_vars['cat']);
|
---|
| 135 | } else if($wp_query->is_author){
|
---|
| 136 | $_GET = array('author'=>$query_vars['author']);
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 | }
|
---|
| 140 |
|
---|
[1] | 141 | //rendering for the module header and the body
|
---|
| 142 | function xpress_render($contents){
|
---|
[201] | 143 | global $xoops_config , $xoopsTpl,$xpress_config;
|
---|
[229] | 144 | xpress_remake_global_for_permlink();
|
---|
[109] | 145 | $mydirname = basename(dirname(dirname(__FILE__)));
|
---|
[96] | 146 | include $xoops_config->xoops_root_path ."/header.php";
|
---|
[1] | 147 | $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
|
---|
[201] | 148 | $page_title = $GLOBALS["xoopsModule"]->getVar("name"). ' »'. get_xpress_title($contents);
|
---|
[1] | 149 | $xoopsTpl->assign('xoops_pagetitle', $page_title);
|
---|
[201] | 150 |
|
---|
| 151 | $xoops_keywords = $xoopsTpl->get_template_vars('xoops_meta_keywords');
|
---|
| 152 | $wp_keyword = get_xpress_meta_name('keywords',$contents);
|
---|
| 153 | switch ($xpress_config->meta_keyword_type){
|
---|
| 154 | case 'xoops':
|
---|
| 155 | break;
|
---|
| 156 | case 'wordpress':
|
---|
| 157 | if (!empty($wp_keyword))
|
---|
| 158 | $xoopsTpl->assign('xoops_meta_keywords', $wp_keyword);
|
---|
| 159 | break;
|
---|
| 160 | case 'wordpress_xoops':
|
---|
| 161 | if (!empty($wp_keyword)){
|
---|
| 162 | if (!empty($xoops_keywords)){
|
---|
| 163 | $keywords = $wp_keyword . ', ' . $xoops_keywords;
|
---|
| 164 | } else {
|
---|
| 165 | $keywords = $wp_keyword;
|
---|
| 166 | }
|
---|
| 167 | $xoopsTpl->assign('xoops_meta_keywords', $keywords);
|
---|
| 168 | }
|
---|
| 169 | break;
|
---|
| 170 | default :
|
---|
| 171 | }
|
---|
| 172 |
|
---|
| 173 | $xoops_description = $xoopsTpl->get_template_vars('xoops_meta_description');
|
---|
| 174 | $wp_description = get_xpress_meta_name('description',$contents);
|
---|
| 175 | switch ($xpress_config->meta_description_type){
|
---|
| 176 | case 'xoops':
|
---|
| 177 | break;
|
---|
| 178 | case 'wordpress':
|
---|
| 179 | if (!empty($wp_description))
|
---|
| 180 | $xoopsTpl->assign('xoops_meta_description', $wp_description);
|
---|
| 181 | break;
|
---|
| 182 | case 'wordpress_xoops':
|
---|
| 183 | if (!empty($wp_description)){
|
---|
| 184 | if (!empty($xoops_description)){
|
---|
| 185 | $description = $wp_description . ' ' . $xoops_description;
|
---|
| 186 | } else {
|
---|
| 187 | $description = $wp_description;
|
---|
| 188 | }
|
---|
| 189 | $xoopsTpl->assign('xoops_meta_description', $description);
|
---|
| 190 | }
|
---|
| 191 | break;
|
---|
| 192 | default :
|
---|
| 193 | }
|
---|
[202] | 194 |
|
---|
| 195 | $wp_robots = get_xpress_meta_name('robots',$contents);
|
---|
| 196 | switch ($xpress_config->meta_robot_type){
|
---|
| 197 | case 'xoops':
|
---|
| 198 | break;
|
---|
| 199 | case 'wordpress':
|
---|
| 200 | if (!empty($wp_robots))
|
---|
| 201 | $xoopsTpl->assign('xoops_meta_robots', $wp_robots);
|
---|
| 202 | break;
|
---|
| 203 | default :
|
---|
| 204 | }
|
---|
[201] | 205 |
|
---|
[164] | 206 | $xpress_data['body_contents'] = get_body($contents);
|
---|
| 207 | // used $GLOBALS. becose xpress_left_arrow_post_link() and xpress_right_arrow_post_link() is other loop in this position
|
---|
| 208 | $xpress_data['left_post_link'] = $GLOBALS['left_arrow_post_link'];
|
---|
| 209 | $xpress_data['right_post_link'] = $GLOBALS['right_arrow_post_link'];
|
---|
| 210 | $xpress_data['left_posts_link'] = str_replace('«','',xpress_left_arrow_posts_link(false));
|
---|
| 211 | $xpress_data['right_posts_link'] = str_replace('»','',xpress_right_arrow_posts_link(false));
|
---|
| 212 | $xpress_data['now_user_level'] = xpress_now_user_level(false);
|
---|
| 213 |
|
---|
| 214 | $xoopsTpl->assign('xpress', $xpress_data);
|
---|
[109] | 215 | $templates_file = 'db:'.$mydirname. '_index.html';
|
---|
| 216 | echo $xoopsTpl->fetch( $templates_file ) ;
|
---|
[96] | 217 | require_once( ABSPATH .'/include/xpress_breadcrumbs.php' );
|
---|
| 218 | include $xoops_config->xoops_root_path . '/footer.php';
|
---|
[1] | 219 | }
|
---|
| 220 |
|
---|
| 221 | ?> |
---|