[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);
|
---|
[361] | 38 | $head_str = $head_str . "\n<!-- credit " . 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){
|
---|
[346] | 149 | global $xoops_config;
|
---|
| 150 | global $xoopsUser , $xoopsTpl,$xpress_config , $xoopsModule , $xoopsLogger, $xoopsConfig ; //for XOOPS
|
---|
[422] | 151 |
|
---|
| 152 | require_once( ABSPATH .'/include/xpress_breadcrumbs.php' );
|
---|
[432] | 153 | $xoops_breadcrumbs = get_breadcrumbs();
|
---|
| 154 |
|
---|
[229] | 155 | xpress_remake_global_for_permlink();
|
---|
[109] | 156 | $mydirname = basename(dirname(dirname(__FILE__)));
|
---|
[96] | 157 | include $xoops_config->xoops_root_path ."/header.php";
|
---|
[432] | 158 | $xoopsTpl->assign('xoops_breadcrumbs', $xoops_breadcrumbs);
|
---|
[1] | 159 | $xoopsTpl->assign('xoops_module_header', get_xpress_module_header($contents));
|
---|
[201] | 160 | $page_title = $GLOBALS["xoopsModule"]->getVar("name"). ' »'. get_xpress_title($contents);
|
---|
[1] | 161 | $xoopsTpl->assign('xoops_pagetitle', $page_title);
|
---|
[201] | 162 |
|
---|
| 163 | $xoops_keywords = $xoopsTpl->get_template_vars('xoops_meta_keywords');
|
---|
| 164 | $wp_keyword = get_xpress_meta_name('keywords',$contents);
|
---|
| 165 | switch ($xpress_config->meta_keyword_type){
|
---|
| 166 | case 'xoops':
|
---|
| 167 | break;
|
---|
| 168 | case 'wordpress':
|
---|
| 169 | if (!empty($wp_keyword))
|
---|
| 170 | $xoopsTpl->assign('xoops_meta_keywords', $wp_keyword);
|
---|
| 171 | break;
|
---|
| 172 | case 'wordpress_xoops':
|
---|
| 173 | if (!empty($wp_keyword)){
|
---|
| 174 | if (!empty($xoops_keywords)){
|
---|
| 175 | $keywords = $wp_keyword . ', ' . $xoops_keywords;
|
---|
| 176 | } else {
|
---|
| 177 | $keywords = $wp_keyword;
|
---|
| 178 | }
|
---|
| 179 | $xoopsTpl->assign('xoops_meta_keywords', $keywords);
|
---|
| 180 | }
|
---|
| 181 | break;
|
---|
| 182 | default :
|
---|
| 183 | }
|
---|
| 184 |
|
---|
| 185 | $xoops_description = $xoopsTpl->get_template_vars('xoops_meta_description');
|
---|
| 186 | $wp_description = get_xpress_meta_name('description',$contents);
|
---|
| 187 | switch ($xpress_config->meta_description_type){
|
---|
| 188 | case 'xoops':
|
---|
| 189 | break;
|
---|
| 190 | case 'wordpress':
|
---|
| 191 | if (!empty($wp_description))
|
---|
| 192 | $xoopsTpl->assign('xoops_meta_description', $wp_description);
|
---|
| 193 | break;
|
---|
| 194 | case 'wordpress_xoops':
|
---|
| 195 | if (!empty($wp_description)){
|
---|
| 196 | if (!empty($xoops_description)){
|
---|
| 197 | $description = $wp_description . ' ' . $xoops_description;
|
---|
| 198 | } else {
|
---|
| 199 | $description = $wp_description;
|
---|
| 200 | }
|
---|
| 201 | $xoopsTpl->assign('xoops_meta_description', $description);
|
---|
| 202 | }
|
---|
| 203 | break;
|
---|
| 204 | default :
|
---|
| 205 | }
|
---|
[202] | 206 |
|
---|
| 207 | $wp_robots = get_xpress_meta_name('robots',$contents);
|
---|
| 208 | switch ($xpress_config->meta_robot_type){
|
---|
| 209 | case 'xoops':
|
---|
| 210 | break;
|
---|
| 211 | case 'wordpress':
|
---|
| 212 | if (!empty($wp_robots))
|
---|
| 213 | $xoopsTpl->assign('xoops_meta_robots', $wp_robots);
|
---|
| 214 | break;
|
---|
| 215 | default :
|
---|
| 216 | }
|
---|
[201] | 217 |
|
---|
[164] | 218 | $xpress_data['body_contents'] = get_body($contents);
|
---|
| 219 | // used $GLOBALS. becose xpress_left_arrow_post_link() and xpress_right_arrow_post_link() is other loop in this position
|
---|
| 220 | $xpress_data['left_post_link'] = $GLOBALS['left_arrow_post_link'];
|
---|
| 221 | $xpress_data['right_post_link'] = $GLOBALS['right_arrow_post_link'];
|
---|
[272] | 222 | $xpress_data['left_posts_link'] = str_replace('«','',xpress_left_arrow_posts_link('echo=0'));
|
---|
| 223 | $xpress_data['right_posts_link'] = str_replace('»','',xpress_right_arrow_posts_link('echo=0'));
|
---|
| 224 | $xpress_data['now_user_level'] = xpress_now_user_level('echo=0');
|
---|
[164] | 225 |
|
---|
[343] | 226 | //If notification_select.php is not executed in CMS other than XCL, the selector of in-line is not displayed.
|
---|
| 227 | if (is_object($xoopsModule) && $xoopsModule->getVar('hasnotification') == 1 && is_object($xoopsUser)) {
|
---|
| 228 | require_once $xoops_config->xoops_root_path . '/include/notification_select.php';
|
---|
| 229 | }
|
---|
| 230 |
|
---|
[164] | 231 | $xoopsTpl->assign('xpress', $xpress_data);
|
---|
[109] | 232 | $templates_file = 'db:'.$mydirname. '_index.html';
|
---|
| 233 | echo $xoopsTpl->fetch( $templates_file ) ;
|
---|
[96] | 234 | include $xoops_config->xoops_root_path . '/footer.php';
|
---|
[1] | 235 | }
|
---|
| 236 |
|
---|
| 237 | ?> |
---|