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