| 1 | <?php | 
|---|
| 2 | function xpress_user_access_level(){ | 
|---|
| 3 | global $current_user; | 
|---|
| 4 |  | 
|---|
| 5 | $level = @$current_user->user_level; | 
|---|
| 6 | $role = @$current_user->roles[0]; | 
|---|
| 7 | switch ($role){ | 
|---|
| 8 | case 'administrator': | 
|---|
| 9 | $role_level = 10; | 
|---|
| 10 | break; | 
|---|
| 11 | case 'editor': | 
|---|
| 12 | $role_level = 7; | 
|---|
| 13 | break; | 
|---|
| 14 | case 'author': | 
|---|
| 15 | $role_level = 2; | 
|---|
| 16 | break; | 
|---|
| 17 | case 'contributor': | 
|---|
| 18 | $role_level = 1; | 
|---|
| 19 | break; | 
|---|
| 20 | default: | 
|---|
| 21 | $role_level = 0; | 
|---|
| 22 | } | 
|---|
| 23 |  | 
|---|
| 24 | if ($level > $role_level){ | 
|---|
| 25 | return $level; | 
|---|
| 26 | } else { | 
|---|
| 27 | return $role_level; | 
|---|
| 28 | } | 
|---|
| 29 | } | 
|---|
| 30 |  | 
|---|
| 31 |  | 
|---|
| 32 |  | 
|---|
| 33 | function xpress_is_contributor() | 
|---|
| 34 | { | 
|---|
| 35 | global $current_user; | 
|---|
| 36 | get_currentuserinfo(); | 
|---|
| 37 | if (xpress_user_access_level() > 3) | 
|---|
| 38 | return true; | 
|---|
| 39 | else | 
|---|
| 40 | return false; | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | function xpress_is_wpmu() { | 
|---|
| 44 | global $xoops_config; | 
|---|
| 45 |  | 
|---|
| 46 | return $xoops_config->is_wpmu; | 
|---|
| 47 | } | 
|---|
| 48 |  | 
|---|
| 49 | function xpress_is_multiblog() { | 
|---|
| 50 | global $xoops_config; | 
|---|
| 51 |  | 
|---|
| 52 | if (defined('MULTISITE')) return MULTISITE; | 
|---|
| 53 | return $xoops_config->multiblog; | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | function xpress_is_multiblog_root() { | 
|---|
| 57 | global $blog_id; | 
|---|
| 58 | if (defined('MULTISITE') && MULTISITE && $blog_id == 1){ | 
|---|
| 59 | return true; | 
|---|
| 60 | } else { | 
|---|
| 61 | return false; | 
|---|
| 62 | } | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|
| 65 | function xpress_is_wp_version($operator='==',$comp_version){ | 
|---|
| 66 | global $xoops_config; | 
|---|
| 67 | return version_compare($xoops_config->wp_version, $comp_version, $operator); | 
|---|
| 68 | } | 
|---|
| 69 |  | 
|---|
| 70 | function xpress_is_theme_sidebar_disp(){ | 
|---|
| 71 | global $xpress_config; | 
|---|
| 72 | if (is_wordpress_style()) return true; | 
|---|
| 73 | return $xpress_config->is_theme_sidebar_disp; | 
|---|
| 74 | } | 
|---|
| 75 |  | 
|---|
| 76 | function xpress_is_author_view_count(){ | 
|---|
| 77 | global $xpress_config; | 
|---|
| 78 | return $xpress_config->is_author_view_count; | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 | function xpress_is_multi_user(){ | 
|---|
| 82 | global $xpress_config; | 
|---|
| 83 | return $xpress_config->is_multi_user; | 
|---|
| 84 | } | 
|---|
| 85 |  | 
|---|
| 86 |  | 
|---|
| 87 | function xpress_the_title($args = '') | 
|---|
| 88 | { | 
|---|
| 89 | $defaults = array( | 
|---|
| 90 | 'echo' => 1 | 
|---|
| 91 | ); | 
|---|
| 92 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 93 |  | 
|---|
| 94 | extract( $r ); | 
|---|
| 95 |  | 
|---|
| 96 | $output = '<div class ="xpress-post-header">' . "\n"; | 
|---|
| 97 |  | 
|---|
| 98 | if (function_exists('hotDates')) { | 
|---|
| 99 | ob_start(); | 
|---|
| 100 | hotDates(); | 
|---|
| 101 | $output .= ob_get_contents(); | 
|---|
| 102 | ob_end_clean(); | 
|---|
| 103 | } | 
|---|
| 104 | $output .= '<div class ="xpress-post-title">' . "\n"; | 
|---|
| 105 | $output .= '<h2><a href="'; | 
|---|
| 106 | ob_start(); | 
|---|
| 107 | the_permalink(); | 
|---|
| 108 | $output .= ob_get_contents(); | 
|---|
| 109 | ob_end_clean(); | 
|---|
| 110 |  | 
|---|
| 111 | if(function_exists('the_title_attribute')){ | 
|---|
| 112 | $title = the_title_attribute('echo=0'); | 
|---|
| 113 | } else { | 
|---|
| 114 | ob_start(); | 
|---|
| 115 | the_title(); | 
|---|
| 116 | $title = ob_get_contents(); | 
|---|
| 117 | ob_end_clean(); | 
|---|
| 118 | } | 
|---|
| 119 |  | 
|---|
| 120 | $output .= '" rel="bookmark" title="'; | 
|---|
| 121 | $output .= sprintf(__('Permanent Link to %s', 'xpress'), $title); | 
|---|
| 122 | $output .= '">'; | 
|---|
| 123 | $output .= $title; | 
|---|
| 124 | $output .= '</a></h2>' . "\n"; | 
|---|
| 125 | $output .= '</div>' . "\n"; | 
|---|
| 126 | $output .= '</div>' . "\n"; | 
|---|
| 127 |  | 
|---|
| 128 | if ($echo) | 
|---|
| 129 | echo $output; | 
|---|
| 130 | else | 
|---|
| 131 | return $output; | 
|---|
| 132 |  | 
|---|
| 133 | } | 
|---|
| 134 |  | 
|---|
| 135 | function xpress_selected_author($args ='' ) { | 
|---|
| 136 | $defaults = array( | 
|---|
| 137 | 'echo' => 1 | 
|---|
| 138 | ); | 
|---|
| 139 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 140 |  | 
|---|
| 141 | extract( $r ); | 
|---|
| 142 |  | 
|---|
| 143 | $output = ''; | 
|---|
| 144 | $author_cookie = 'select_' . get_xpress_dir_name() . "_author" ; | 
|---|
| 145 | if (!empty($_COOKIE[$author_cookie])){ | 
|---|
| 146 | $uid = intval($_COOKIE[$author_cookie]); | 
|---|
| 147 | $user_info = get_userdata($uid); | 
|---|
| 148 | $output = $user_info->display_name; | 
|---|
| 149 | } | 
|---|
| 150 | if ($echo) | 
|---|
| 151 | echo $output; | 
|---|
| 152 | else | 
|---|
| 153 | return $output; | 
|---|
| 154 |  | 
|---|
| 155 | } | 
|---|
| 156 | function xpress_selected_author_id($args ='' ) { | 
|---|
| 157 | $defaults = array( | 
|---|
| 158 | 'echo' => 1 | 
|---|
| 159 | ); | 
|---|
| 160 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 161 |  | 
|---|
| 162 | extract( $r ); | 
|---|
| 163 | $output = ''; | 
|---|
| 164 | $author_cookie = 'select_' . get_xpress_dir_name() . "_author" ; | 
|---|
| 165 | if (!empty($_COOKIE[$author_cookie])){ | 
|---|
| 166 | $output = intval($_COOKIE[$author_cookie]); | 
|---|
| 167 | } else { | 
|---|
| 168 | $output = ''; | 
|---|
| 169 | } | 
|---|
| 170 | if ($echo) | 
|---|
| 171 | echo $output; | 
|---|
| 172 | else | 
|---|
| 173 | return $output; | 
|---|
| 174 | } | 
|---|
| 175 |  | 
|---|
| 176 | function xpress_now_user_level($args ='' ) { | 
|---|
| 177 | global $current_user; | 
|---|
| 178 | $defaults = array( | 
|---|
| 179 | 'echo' => 1 | 
|---|
| 180 | ); | 
|---|
| 181 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 182 |  | 
|---|
| 183 | extract( $r ); | 
|---|
| 184 |  | 
|---|
| 185 | $output = xpress_user_access_level(); | 
|---|
| 186 | if ($echo) | 
|---|
| 187 | echo $output; | 
|---|
| 188 | else | 
|---|
| 189 | return $output; | 
|---|
| 190 | } | 
|---|
| 191 |  | 
|---|
| 192 | function xpress_credit($args ='') | 
|---|
| 193 | { | 
|---|
| 194 | global $wp_version , $xoops_config; | 
|---|
| 195 | if ($xoops_config->is_wpmu) { | 
|---|
| 196 | global $wpmu_version; | 
|---|
| 197 | } | 
|---|
| 198 |  | 
|---|
| 199 | $defaults = array( | 
|---|
| 200 | 'echo' => 1, | 
|---|
| 201 | 'no_link' => 0 | 
|---|
| 202 | ); | 
|---|
| 203 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 204 |  | 
|---|
| 205 | extract( $r ); | 
|---|
| 206 |  | 
|---|
| 207 | $xpress_version = $xoops_config->module_version; | 
|---|
| 208 | $xpress_codename = $xoops_config->module_codename; | 
|---|
| 209 | if ($no_link){ | 
|---|
| 210 | if ($xoops_config->is_wpmu) { | 
|---|
| 211 | $output = 'XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename); | 
|---|
| 212 | $output .= '(included WordPress MU ' . $wpmu_version. ')'; | 
|---|
| 213 | } else { | 
|---|
| 214 | $output = 'XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename); | 
|---|
| 215 | if (strstr($wp_version,'ME')){ | 
|---|
| 216 | $output .= '(included WordPress ' . $wp_version . ')'; | 
|---|
| 217 | } else { | 
|---|
| 218 | $output .= '(included WordPress ' . $wp_version . ')'; | 
|---|
| 219 | } | 
|---|
| 220 | } | 
|---|
| 221 | } else { | 
|---|
| 222 | if ($xoops_config->is_wpmu) { | 
|---|
| 223 | $output = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressMU Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>'; | 
|---|
| 224 | $output .= '(included <a href="http://mu.wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress MU ' . $wpmu_version . '</a>)'; | 
|---|
| 225 | } else { | 
|---|
| 226 | $output = '<a href="http://ja.xpressme.info"'. " target='_blank'" . '>XPressME Ver.' . sprintf('%.2f %s',$xpress_version,$xpress_codename) .'</a>'; | 
|---|
| 227 | if (strstr($wp_version,'ME')){ | 
|---|
| 228 | $output .= '(included <a href="http://wpme.sourceforge.jp/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)'; | 
|---|
| 229 | } else { | 
|---|
| 230 | $output .= '(included <a href="http://wordpress.org/" title="Powered by WordPress"'." target='_blank'". '>WordPress ' . $wp_version . '</a>)'; | 
|---|
| 231 | } | 
|---|
| 232 | } | 
|---|
| 233 | } | 
|---|
| 234 | if ($echo) | 
|---|
| 235 | echo $output; | 
|---|
| 236 | else | 
|---|
| 237 | return $output; | 
|---|
| 238 | } | 
|---|
| 239 |  | 
|---|
| 240 | function xpress_convert_time($args ='') | 
|---|
| 241 | { | 
|---|
| 242 | $defaults = array( | 
|---|
| 243 | 'echo' => 1, | 
|---|
| 244 | 'format' => '(%.3f sec.)' | 
|---|
| 245 | ); | 
|---|
| 246 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 247 |  | 
|---|
| 248 | extract( $r ); | 
|---|
| 249 |  | 
|---|
| 250 | $output =  sprintf($format,timer_stop(0)); | 
|---|
| 251 | if ($echo) | 
|---|
| 252 | echo $output; | 
|---|
| 253 | else | 
|---|
| 254 | return $output; | 
|---|
| 255 | } | 
|---|
| 256 |  | 
|---|
| 257 | function xpress_left_arrow_post_link($args ='') | 
|---|
| 258 | { | 
|---|
| 259 | global $xpress_config; | 
|---|
| 260 | $defaults = array( | 
|---|
| 261 | 'echo' => 1 | 
|---|
| 262 | ); | 
|---|
| 263 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 264 |  | 
|---|
| 265 | extract( $r ); | 
|---|
| 266 |  | 
|---|
| 267 | $ret = ''; | 
|---|
| 268 |  | 
|---|
| 269 | if($xpress_config->is_left_postnavi_old){ | 
|---|
| 270 | $link_title = $xpress_config->old_post_link_text; | 
|---|
| 271 | ob_start(); | 
|---|
| 272 | if ($xpress_config->is_postnavi_title_disp) | 
|---|
| 273 | previous_post_link('« %link'); | 
|---|
| 274 | else | 
|---|
| 275 | previous_post_link('« %link',$link_title); | 
|---|
| 276 | $ret = ob_get_contents(); | 
|---|
| 277 | ob_end_clean(); | 
|---|
| 278 | ob_start(); | 
|---|
| 279 | previous_post_link('%link',$link_title); | 
|---|
| 280 | $GLOBALS['left_arrow_post_link'] = ob_get_contents(); | 
|---|
| 281 | ob_end_clean(); | 
|---|
| 282 |  | 
|---|
| 283 | } else { | 
|---|
| 284 | $link_title = $xpress_config->newer_post_link_text; | 
|---|
| 285 | ob_start(); | 
|---|
| 286 | if ($xpress_config->is_postnavi_title_disp) | 
|---|
| 287 | next_post_link('« %link'); | 
|---|
| 288 | else | 
|---|
| 289 | next_post_link('« %link',$link_title); | 
|---|
| 290 | $ret = ob_get_contents(); | 
|---|
| 291 | ob_end_clean(); | 
|---|
| 292 | ob_start(); | 
|---|
| 293 | next_post_link('%link',$link_title); | 
|---|
| 294 | $GLOBALS['left_arrow_post_link'] = ob_get_contents(); | 
|---|
| 295 | ob_end_clean(); | 
|---|
| 296 |  | 
|---|
| 297 | } | 
|---|
| 298 |  | 
|---|
| 299 | if ($xpress_config->is_postnavi_title_disp){ | 
|---|
| 300 | $on_mouse_show = $link_title; | 
|---|
| 301 | } else  { | 
|---|
| 302 | if($xpress_config->is_left_postnavi_old){ | 
|---|
| 303 | ob_start(); | 
|---|
| 304 | previous_post_link('%link'); | 
|---|
| 305 | $on_mouse_show = ob_get_contents(); | 
|---|
| 306 | ob_end_clean(); | 
|---|
| 307 | } else { | 
|---|
| 308 | ob_start(); | 
|---|
| 309 | next_post_link('%link'); | 
|---|
| 310 | $on_mouse_show = ob_get_contents(); | 
|---|
| 311 | ob_end_clean(); | 
|---|
| 312 | } | 
|---|
| 313 | $pattern = "<a[^>]*?>(.*)<\/a>"; | 
|---|
| 314 | preg_match("/".$pattern."/s",  $on_mouse_show, $body_matches); | 
|---|
| 315 | $on_mouse_show = $body_matches[1]; | 
|---|
| 316 | } | 
|---|
| 317 | $output = str_replace('">','" title="'.$on_mouse_show . '">' , $ret); | 
|---|
| 318 |  | 
|---|
| 319 | if ($echo) | 
|---|
| 320 | echo $output; | 
|---|
| 321 | else | 
|---|
| 322 | return $output; | 
|---|
| 323 | } | 
|---|
| 324 |  | 
|---|
| 325 | function xpress_right_arrow_post_link($args ='') | 
|---|
| 326 | { | 
|---|
| 327 | global $xpress_config; | 
|---|
| 328 | $defaults = array( | 
|---|
| 329 | 'echo' => 1 | 
|---|
| 330 | ); | 
|---|
| 331 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 332 |  | 
|---|
| 333 | extract( $r ); | 
|---|
| 334 |  | 
|---|
| 335 | $ret = ''; | 
|---|
| 336 |  | 
|---|
| 337 | if($xpress_config->is_left_postnavi_old){ | 
|---|
| 338 | $link_title = $xpress_config->newer_post_link_text; | 
|---|
| 339 | ob_start(); | 
|---|
| 340 | if ($xpress_config->is_postnavi_title_disp) | 
|---|
| 341 | next_post_link('%link »'); | 
|---|
| 342 | else | 
|---|
| 343 | next_post_link('%link »',$link_title); | 
|---|
| 344 | $ret = ob_get_contents(); | 
|---|
| 345 | ob_end_clean(); | 
|---|
| 346 | ob_start(); | 
|---|
| 347 | next_post_link('%link',$link_title); | 
|---|
| 348 | $GLOBALS['right_arrow_post_link'] = ob_get_contents(); | 
|---|
| 349 | ob_end_clean(); | 
|---|
| 350 |  | 
|---|
| 351 | } else { | 
|---|
| 352 | $link_title = $xpress_config->old_post_link_text; | 
|---|
| 353 | ob_start(); | 
|---|
| 354 | if ($xpress_config->is_postnavi_title_disp) | 
|---|
| 355 | previous_post_link('%link »'); | 
|---|
| 356 | else | 
|---|
| 357 | previous_post_link('%link »',$link_title); | 
|---|
| 358 | $ret = ob_get_contents(); | 
|---|
| 359 | ob_end_clean(); | 
|---|
| 360 | ob_start(); | 
|---|
| 361 | previous_post_link('%link',$link_title); | 
|---|
| 362 | $GLOBALS['right_arrow_post_link'] = ob_get_contents(); | 
|---|
| 363 | ob_end_clean(); | 
|---|
| 364 |  | 
|---|
| 365 | } | 
|---|
| 366 |  | 
|---|
| 367 | if ($xpress_config->is_postnavi_title_disp){ | 
|---|
| 368 | $on_mouse_show = $link_title; | 
|---|
| 369 | } else  { | 
|---|
| 370 | if($xpress_config->is_left_postnavi_old){ | 
|---|
| 371 | ob_start(); | 
|---|
| 372 | next_post_link('%link'); | 
|---|
| 373 | $on_mouse_show = ob_get_contents(); | 
|---|
| 374 | ob_end_clean(); | 
|---|
| 375 | } else { | 
|---|
| 376 | ob_start(); | 
|---|
| 377 | previous_post_link('%link'); | 
|---|
| 378 | $on_mouse_show = ob_get_contents(); | 
|---|
| 379 | ob_end_clean(); | 
|---|
| 380 | } | 
|---|
| 381 | $pattern = "<a[^>]*?>(.*)<\/a>"; | 
|---|
| 382 | preg_match("/".$pattern."/s",  $on_mouse_show, $body_matches); | 
|---|
| 383 | $on_mouse_show = $body_matches[1]; | 
|---|
| 384 | } | 
|---|
| 385 | $output = str_replace('">','" title="'.$on_mouse_show . '">' , $ret); | 
|---|
| 386 |  | 
|---|
| 387 | if ($echo) | 
|---|
| 388 | echo $output; | 
|---|
| 389 | else | 
|---|
| 390 | return $output; | 
|---|
| 391 | } | 
|---|
| 392 | // page link | 
|---|
| 393 | function xpress_left_arrow_posts_link($args ='') | 
|---|
| 394 | { | 
|---|
| 395 | global $xpress_config; | 
|---|
| 396 | $defaults = array( | 
|---|
| 397 | 'echo' => 1 | 
|---|
| 398 | ); | 
|---|
| 399 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 400 |  | 
|---|
| 401 | extract( $r ); | 
|---|
| 402 |  | 
|---|
| 403 | $output = ''; | 
|---|
| 404 |  | 
|---|
| 405 | if($xpress_config->is_left_page_navi_old){ | 
|---|
| 406 | $link_title = $xpress_config->old_page_link_text; | 
|---|
| 407 | ob_start(); | 
|---|
| 408 | next_posts_link("« $link_title"); | 
|---|
| 409 | $output = ob_get_contents(); | 
|---|
| 410 | ob_end_clean(); | 
|---|
| 411 | } else { | 
|---|
| 412 | $link_title = $xpress_config->newer_page_link_text; | 
|---|
| 413 | ob_start(); | 
|---|
| 414 | previous_posts_link("« $link_title"); | 
|---|
| 415 | $output = ob_get_contents(); | 
|---|
| 416 | ob_end_clean(); | 
|---|
| 417 | } | 
|---|
| 418 |  | 
|---|
| 419 | if ($echo) | 
|---|
| 420 | echo $output; | 
|---|
| 421 | else | 
|---|
| 422 | return $output; | 
|---|
| 423 | } | 
|---|
| 424 |  | 
|---|
| 425 | function xpress_right_arrow_posts_link($args ='') | 
|---|
| 426 | { | 
|---|
| 427 | global $xpress_config; | 
|---|
| 428 | $defaults = array( | 
|---|
| 429 | 'echo' => 1 | 
|---|
| 430 | ); | 
|---|
| 431 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 432 |  | 
|---|
| 433 | extract( $r ); | 
|---|
| 434 |  | 
|---|
| 435 | $output = ''; | 
|---|
| 436 |  | 
|---|
| 437 | if($xpress_config->is_left_page_navi_old){ | 
|---|
| 438 | $link_title = $xpress_config->newer_page_link_text; | 
|---|
| 439 | ob_start(); | 
|---|
| 440 | previous_posts_link("$link_title »"); | 
|---|
| 441 | $output = ob_get_contents(); | 
|---|
| 442 | ob_end_clean(); | 
|---|
| 443 | } else { | 
|---|
| 444 | $link_title = $xpress_config->old_page_link_text; | 
|---|
| 445 | ob_start(); | 
|---|
| 446 | next_posts_link("$link_title »"); | 
|---|
| 447 | $output = ob_get_contents(); | 
|---|
| 448 | ob_end_clean(); | 
|---|
| 449 | } | 
|---|
| 450 |  | 
|---|
| 451 | if ($echo) | 
|---|
| 452 | echo $output; | 
|---|
| 453 | else | 
|---|
| 454 | return $output; | 
|---|
| 455 | } | 
|---|
| 456 |  | 
|---|
| 457 | function xpress_substr($str, $start, $length, $trimmarker = '...') | 
|---|
| 458 | { | 
|---|
| 459 | if (function_exists('mb_substr')){ | 
|---|
| 460 | $str2 = mb_substr( $str , $start , $length); | 
|---|
| 461 | return $str2 . ( mb_strlen($str)!=mb_strlen($str2) ? $trimmarker : '' ); | 
|---|
| 462 | } else { | 
|---|
| 463 | return ( strlen($str) - $start <= $length ) ? substr( $str, $start, $length ) : substr( $str, $start, $length - strlen($trimmarker) ) . $trimmarker; | 
|---|
| 464 | } | 
|---|
| 465 | } | 
|---|
| 466 |  | 
|---|
| 467 |  | 
|---|
| 468 | // views count | 
|---|
| 469 | // Set and retrieves post views given a post ID or post object. | 
|---|
| 470 | // Retrieves post views given a post ID or post object. | 
|---|
| 471 | function xpress_post_views_count($args ='') { | 
|---|
| 472 | global $xoops_db,$wpdb; | 
|---|
| 473 | global $blog_id; | 
|---|
| 474 | static $post_cache_views; | 
|---|
| 475 |  | 
|---|
| 476 | $defaults = array( | 
|---|
| 477 | 'post_id' => 0, | 
|---|
| 478 | 'format'=> __('views :%d','xpressme'), | 
|---|
| 479 | 'echo' => 1 | 
|---|
| 480 | ); | 
|---|
| 481 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 482 |  | 
|---|
| 483 | extract( $r ); | 
|---|
| 484 |  | 
|---|
| 485 | if ( empty($post_id) ) { | 
|---|
| 486 | if ( isset($GLOBALS['post']) ) | 
|---|
| 487 | $post_id = $GLOBALS['post']->ID; | 
|---|
| 488 | } | 
|---|
| 489 |  | 
|---|
| 490 | $post_id = intval($post_id); | 
|---|
| 491 | if($post_id==0) return null; | 
|---|
| 492 | if(!isset($post_cache_views[$post_id])){ | 
|---|
| 493 | if (is_null($blog_id)){ | 
|---|
| 494 | $blog_where = ''; | 
|---|
| 495 | } else { | 
|---|
| 496 | $blog_where = ' AND blog_id = '. $blog_id; | 
|---|
| 497 | } | 
|---|
| 498 | $sql = "SELECT post_views FROM " . get_wp_prefix() . "views" . " WHERE post_id=$post_id " .  $blog_where; | 
|---|
| 499 | $post_views = $xoops_db->get_var($sql); | 
|---|
| 500 | if (!$post_views) { | 
|---|
| 501 | $post_cache_views[$post_id] = 0; | 
|---|
| 502 | }else{ | 
|---|
| 503 | $post_cache_views[$post_id] = $post_views; | 
|---|
| 504 | } | 
|---|
| 505 | } | 
|---|
| 506 | $v_count = intval($post_cache_views[$post_id]); | 
|---|
| 507 |  | 
|---|
| 508 | if (empty($format)) $format = __('views :%d','xpressme'); | 
|---|
| 509 |  | 
|---|
| 510 | $output = sprintf($format,$v_count); | 
|---|
| 511 |  | 
|---|
| 512 | if ($echo) | 
|---|
| 513 | echo $output; | 
|---|
| 514 | else | 
|---|
| 515 | return $output; | 
|---|
| 516 | } | 
|---|
| 517 |  | 
|---|
| 518 | function set_post_views_count($content) { | 
|---|
| 519 | if ( empty($_GET["feed"]) &&  empty($GLOBALS["feed"]) && empty($GLOBALS["doing_trackback"]) && empty($GLOBALS["doing_rss"]) && empty($_POST) && is_single() ){ | 
|---|
| 520 | post_views_counting(); | 
|---|
| 521 | } | 
|---|
| 522 | return $content; | 
|---|
| 523 | } | 
|---|
| 524 |  | 
|---|
| 525 | // Set post views given a post ID or post object. | 
|---|
| 526 | function post_views_counting($post_id = 0) { | 
|---|
| 527 | global $xoops_db,$wpdb; | 
|---|
| 528 | global $table_prefix; | 
|---|
| 529 | global $blog_id; | 
|---|
| 530 | static $views; | 
|---|
| 531 |  | 
|---|
| 532 | $post_id = intval($post_id); | 
|---|
| 533 | if ( empty($post_id) && isset($GLOBALS['post']) ){ | 
|---|
| 534 | $post_id = $GLOBALS['post']->ID; | 
|---|
| 535 | } | 
|---|
| 536 |  | 
|---|
| 537 | $views_db = get_wp_prefix() . 'views'; | 
|---|
| 538 | if (is_null($blog_id)) $blog_id = 0; | 
|---|
| 539 |  | 
|---|
| 540 | if($post_id==0 || !empty($views[$post_id])) return null; | 
|---|
| 541 |  | 
|---|
| 542 | if(!xpress_is_author_view_count()){ | 
|---|
| 543 | $current_user_id = $GLOBALS['current_user']->ID; | 
|---|
| 544 | $post_author_id = $GLOBALS['post']->post_author; | 
|---|
| 545 | if ($current_user_id ==$post_author_id) return null; | 
|---|
| 546 | } | 
|---|
| 547 | if (is_null($blog_id)){ | 
|---|
| 548 | $blog_where = ''; | 
|---|
| 549 | } else { | 
|---|
| 550 | $blog_where = ' AND blog_id = ' . $blog_id; | 
|---|
| 551 | } | 
|---|
| 552 | $sql = "SELECT post_views FROM " . $views_db . " WHERE post_id=$post_id" . $blog_where; | 
|---|
| 553 | $post_views_found = $xoops_db->get_var($sql); | 
|---|
| 554 | if($post_views_found){ | 
|---|
| 555 | $sql = "UPDATE " . $views_db . " SET post_views=post_views+1 WHERE post_id=$post_id" . $blog_where; | 
|---|
| 556 | }else{ | 
|---|
| 557 | if (is_null($blog_id)){ | 
|---|
| 558 | $sql = "INSERT INTO " . $views_db . " (post_id, post_views) VALUES ($post_id, 1)"; | 
|---|
| 559 | } else { | 
|---|
| 560 | $sql = "INSERT INTO " . $views_db . " (blog_id, post_id, post_views) VALUES ($blog_id, $post_id, 1)"; | 
|---|
| 561 | } | 
|---|
| 562 | } | 
|---|
| 563 | $xoops_db->query($sql); | 
|---|
| 564 | return true; | 
|---|
| 565 | } | 
|---|
| 566 |  | 
|---|
| 567 | function get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$more_link_text = '') { | 
|---|
| 568 | global $post,$xpress_config; | 
|---|
| 569 |  | 
|---|
| 570 | $blog_encoding = get_option('blog_charset'); | 
|---|
| 571 | $text = get_the_content(''); | 
|---|
| 572 | if (function_exists('strip_shortcodes')){ //@since WP2.5 | 
|---|
| 573 | $text = strip_shortcodes( $text ); | 
|---|
| 574 | } | 
|---|
| 575 | $text = apply_filters('the_content', $text); | 
|---|
| 576 | $text = str_replace(']]>', ']]>', $text); | 
|---|
| 577 | $text = strip_tags($text); | 
|---|
| 578 | $is_almost_ascii = ($xpress_config->ascii_judged_rate < round(@(mb_strlen($text, $blog_encoding) / strlen($text)) * 100)) ? true : false; | 
|---|
| 579 | if($is_almost_ascii) { | 
|---|
| 580 | $words = explode(' ', $text, $excerpt_length_word + 1); | 
|---|
| 581 |  | 
|---|
| 582 | if(count($words) > $excerpt_length_word) { | 
|---|
| 583 | array_pop($words); | 
|---|
| 584 | array_push($words, ' ... '); | 
|---|
| 585 | $text = implode(' ', $words); | 
|---|
| 586 | if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>'; | 
|---|
| 587 |  | 
|---|
| 588 | } | 
|---|
| 589 | } | 
|---|
| 590 | elseif(mb_strlen($text, $blog_encoding) > $excerpt_length_character) { | 
|---|
| 591 | $text = mb_substr($text, 0, $xpress_config->excerpt_length_character, $blog_encoding) . ' ... '; | 
|---|
| 592 | if (!empty($more_link_text)) $text .= '<p align="center"><a href="'. get_permalink() . "\">".$more_link_text .'</a></p>'; | 
|---|
| 593 | } | 
|---|
| 594 |  | 
|---|
| 595 | return $text; | 
|---|
| 596 | } | 
|---|
| 597 |  | 
|---|
| 598 | function xpress_the_content($args ='') | 
|---|
| 599 | { | 
|---|
| 600 | global $post,$xpress_config; | 
|---|
| 601 |  | 
|---|
| 602 | $defaults = array( | 
|---|
| 603 | 'more_link_text'=> $xpress_config->more_link_text, | 
|---|
| 604 | 'stripteaser' => 0, | 
|---|
| 605 | 'more_file' => '', | 
|---|
| 606 | 'configration_select' => 1, | 
|---|
| 607 | 'do_excerpt' => 0, | 
|---|
| 608 | 'excerpt_length_word' => $xpress_config->excerpt_length_word , | 
|---|
| 609 | 'excerpt_length_character' => $xpress_config->excerpt_length_character , | 
|---|
| 610 | 'excerpt_more_link_text' => $xpress_config->excerpt_more_link_text , | 
|---|
| 611 | 'echo' => 1 | 
|---|
| 612 | ); | 
|---|
| 613 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 614 |  | 
|---|
| 615 | extract( $r ); | 
|---|
| 616 |  | 
|---|
| 617 | if ($configration_select){ | 
|---|
| 618 | if ($xpress_config->is_content_excerpt) | 
|---|
| 619 | $do_excerpt = 1; | 
|---|
| 620 | else | 
|---|
| 621 | $do_excerpt = 0; | 
|---|
| 622 | } | 
|---|
| 623 |  | 
|---|
| 624 | if ($do_excerpt){ | 
|---|
| 625 | $content = get_xpress_excerpt_contents($excerpt_length_word,$excerpt_length_character,$excerpt_more_link_text); | 
|---|
| 626 | } else { | 
|---|
| 627 | $content = get_the_content($more_link_text,$stripteaser,$more_file); | 
|---|
| 628 | $content = apply_filters('the_content', $content); | 
|---|
| 629 | $content = str_replace(']]>', ']]>', $content); | 
|---|
| 630 | } | 
|---|
| 631 | if ($echo) | 
|---|
| 632 | echo $content; | 
|---|
| 633 | else | 
|---|
| 634 | return $content; | 
|---|
| 635 | } | 
|---|
| 636 |  | 
|---|
| 637 | function xpress_post_new_link($args ='') | 
|---|
| 638 | { | 
|---|
| 639 | global $xoops_config; | 
|---|
| 640 |  | 
|---|
| 641 | $defaults = array( | 
|---|
| 642 | 'link_title'=> 'Post New', | 
|---|
| 643 | 'echo' => 1 | 
|---|
| 644 | ); | 
|---|
| 645 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 646 |  | 
|---|
| 647 | extract( $r ); | 
|---|
| 648 |  | 
|---|
| 649 |  | 
|---|
| 650 | if (xpress_is_wp_version('>=','2.1')){ | 
|---|
| 651 | $output = '<a href="'. get_bloginfo('url') . '/wp-admin/post-new.php' . '">' . $link_title . '</a>'; | 
|---|
| 652 | } else { | 
|---|
| 653 | $output = '<a href="'. get_bloginfo('url') . '/wp-admin/post.php' . '">' . $link_title . '</a>'; | 
|---|
| 654 | } | 
|---|
| 655 | if ($echo) | 
|---|
| 656 | echo $output; | 
|---|
| 657 | else | 
|---|
| 658 | return $output; | 
|---|
| 659 | } | 
|---|
| 660 |  | 
|---|
| 661 | function xpress_conditional_title($args ='') | 
|---|
| 662 | { | 
|---|
| 663 | $defaults = array( | 
|---|
| 664 | 'echo' => 1 | 
|---|
| 665 | ); | 
|---|
| 666 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 667 |  | 
|---|
| 668 | extract( $r ); | 
|---|
| 669 |  | 
|---|
| 670 | $selected_author = xpress_selected_author('echo=0'); | 
|---|
| 671 |  | 
|---|
| 672 | $output = __('Main', 'xpressme'); | 
|---|
| 673 | $output = ''; | 
|---|
| 674 | if (is_category()) | 
|---|
| 675 | $output = sprintf(__('Archive for the ‘%s’ Category', 'xpressme'), single_cat_title('', false)); | 
|---|
| 676 | if (function_exists( 'is_tag' )){ | 
|---|
| 677 | if (is_tag()) | 
|---|
| 678 | $output = sprintf(__('Posts Tagged ‘%s’', 'xpressme'), single_tag_title('', false) ); | 
|---|
| 679 | } | 
|---|
| 680 | if (is_day()) | 
|---|
| 681 | $output = sprintf(__('Archive for %s|Daily archive page', 'xpressme'), get_the_time(__('F jS, Y', 'xpressme'))); | 
|---|
| 682 | if (is_month()) | 
|---|
| 683 | $output = sprintf(__('Archive for %s|Monthly archive page', 'xpressme'), get_the_time(__('F, Y', 'xpressme'))); | 
|---|
| 684 | if (is_year()) | 
|---|
| 685 | $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme'))); | 
|---|
| 686 | if (is_author()){ | 
|---|
| 687 | if (empty($selected_author)) | 
|---|
| 688 | $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author'))); | 
|---|
| 689 | } | 
|---|
| 690 | if (is_search()) | 
|---|
| 691 | $output = sprintf(__('Search Results of word ‘%s’', 'xpressme'), get_search_query()); | 
|---|
| 692 |  | 
|---|
| 693 | if (!empty($selected_author)){ | 
|---|
| 694 | $selected_id = xpress_selected_author_id('echo=0'); | 
|---|
| 695 | //              $output = get_avatar($selected_id,$size = '32') . sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output; | 
|---|
| 696 | if (empty($output)) | 
|---|
| 697 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) ; | 
|---|
| 698 | else | 
|---|
| 699 | $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output; | 
|---|
| 700 | } | 
|---|
| 701 | if ($echo) | 
|---|
| 702 | echo $output; | 
|---|
| 703 | else | 
|---|
| 704 | return $output; | 
|---|
| 705 | } | 
|---|
| 706 |  | 
|---|
| 707 | // The content of the trackback/pingback to the post is returned by the list. | 
|---|
| 708 | function xpress_pings_list($args =''){ | 
|---|
| 709 | $defaults = array( | 
|---|
| 710 | 'echo' => 1 | 
|---|
| 711 | ); | 
|---|
| 712 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 713 |  | 
|---|
| 714 | extract( $r ); | 
|---|
| 715 |  | 
|---|
| 716 | $trackbacks = xpress_get_pings(); | 
|---|
| 717 | if (! empty($trackbacks)) { | 
|---|
| 718 | $output = '<ol id="xpress_pingslist"> '; | 
|---|
| 719 |  | 
|---|
| 720 | foreach ($trackbacks as $trackback){ | 
|---|
| 721 | $list = date(get_settings('date_format'),$trackback['date']) . ' <a target="_blank" href="' . $trackback['site_url'] . '" rel="external nofollow">' . sprintf(__('From %1$s on site %2$s','xpressme'),$trackback['title'],$trackback['site_name']) . "</a>\n" ; | 
|---|
| 722 |  | 
|---|
| 723 | $output .=  '<li>'; | 
|---|
| 724 | $output .=  $list ; | 
|---|
| 725 | $output .=  '</li>'; | 
|---|
| 726 |  | 
|---|
| 727 | } | 
|---|
| 728 | $output .= '</ol>' ; | 
|---|
| 729 | } else { | 
|---|
| 730 | $output = ''; | 
|---|
| 731 | } | 
|---|
| 732 |  | 
|---|
| 733 | if ($echo) | 
|---|
| 734 | echo $output; | 
|---|
| 735 | else | 
|---|
| 736 | return $output; | 
|---|
| 737 | } | 
|---|
| 738 |  | 
|---|
| 739 | // The amount of the trackback/pingback to the post is returned. | 
|---|
| 740 | function xpress_pings_number( $args ='' ) { | 
|---|
| 741 | $defaults = array( | 
|---|
| 742 | 'zero' => __('No Trackback/Pingback', 'xpressme'), | 
|---|
| 743 | 'one' => __('One Trackback/Pingback', 'xpressme'), | 
|---|
| 744 | 'more' => __('% TrackBack/Pingback', 'xpressme'), | 
|---|
| 745 | 'deprecated' => '', | 
|---|
| 746 | 'echo' => 1 | 
|---|
| 747 | ); | 
|---|
| 748 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 749 |  | 
|---|
| 750 | extract( $r ); | 
|---|
| 751 |  | 
|---|
| 752 | $pings = xpress_get_pings(); | 
|---|
| 753 | if (empty($pings)){ | 
|---|
| 754 | $number = 0; | 
|---|
| 755 | }else { | 
|---|
| 756 | $number = count($pings); | 
|---|
| 757 | } | 
|---|
| 758 | if ( $number > 1 ) | 
|---|
| 759 | $output = str_replace('%', number_format_i18n($number), $more); | 
|---|
| 760 | elseif ( $number == 0 ) | 
|---|
| 761 | $output = $zero; | 
|---|
| 762 | else // must be one | 
|---|
| 763 | $output = $one; | 
|---|
| 764 |  | 
|---|
| 765 | if ($echo) | 
|---|
| 766 | echo $output; | 
|---|
| 767 | else | 
|---|
| 768 | return $output; | 
|---|
| 769 | } | 
|---|
| 770 |  | 
|---|
| 771 | // xpress_get_pings() is a subfunction used with xpress_pings_number() and xpress_pings_list(). | 
|---|
| 772 | function xpress_get_pings() | 
|---|
| 773 | { | 
|---|
| 774 | global $withcomments, $post, $wpdb, $id, $trackback, $user_login, $user_ID, $user_identity; | 
|---|
| 775 |  | 
|---|
| 776 | if ( ! (is_single() || is_page() || $withcomments) ) | 
|---|
| 777 | return; | 
|---|
| 778 |  | 
|---|
| 779 | /** @todo Use API instead of SELECTs. */ | 
|---|
| 780 | if ( $user_ID) { | 
|---|
| 781 | $trackbacks = $wpdb->get_results(sprintf("SELECT * , UNIX_TIMESTAMP(comment_date) AS comment_timestamp ,UNIX_TIMESTAMP(comment_date_gmt) AS comment_timestamp_gmt FROM $wpdb->comments WHERE comment_post_ID = %d AND (comment_approved = '1' OR ( user_id = %d AND comment_approved = '0' ) ) AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID, $user_ID)); | 
|---|
| 782 | } else if ( empty($trackback_author) ) { | 
|---|
| 783 | $trackbacks = $wpdb->get_results(sprintf("SELECT * , UNIX_TIMESTAMP(comment_date) AS comment_timestamp ,UNIX_TIMESTAMP(comment_date_gmt) AS comment_timestamp_gmt FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID)); | 
|---|
| 784 | } else { | 
|---|
| 785 | $trackbacks = $wpdb->get_results(sprintf("SELECT * , UNIX_TIMESTAMP(comment_date) AS comment_timestamp ,UNIX_TIMESTAMP(comment_date_gmt) AS comment_timestamp_gmt FROM $wpdb->comments WHERE comment_post_ID = %d AND ( comment_approved = '1' OR ( comment_author = %s AND comment_author_email = %s AND comment_approved = '0' ) ) AND ( comment_type = 'trackback' OR comment_type = 'pingback' ) ORDER BY comment_date", $post->ID, $trackback_author, $trackback_author_email)); | 
|---|
| 786 | } | 
|---|
| 787 |  | 
|---|
| 788 | if ($trackbacks){ | 
|---|
| 789 | $ret = array(); | 
|---|
| 790 | foreach ($trackbacks as $trackback){ | 
|---|
| 791 |  | 
|---|
| 792 | $pattern = '<strong>(.*)<\/strong>(.*)'; | 
|---|
| 793 | if ( preg_match ( "/".$pattern."/i", $trackback->comment_content , $match ) ){ | 
|---|
| 794 | $title = $match[1]; | 
|---|
| 795 | $content = $match[2]; | 
|---|
| 796 | } | 
|---|
| 797 | if (empty($title)) $title = $trackback->comment_author; | 
|---|
| 798 |  | 
|---|
| 799 |  | 
|---|
| 800 | $row_data = array( | 
|---|
| 801 | 'ID'            => $trackback->comment_ID , | 
|---|
| 802 | 'post_ID'       => $trackback->comment_post_ID , | 
|---|
| 803 | 'site_name' => $trackback->comment_author , | 
|---|
| 804 | 'site_url' => $trackback->comment_author_url , | 
|---|
| 805 | 'title' => $title , | 
|---|
| 806 | 'content' => $content , | 
|---|
| 807 | 'date'          => $trackback->comment_timestamp , | 
|---|
| 808 | 'date_gmt'              => $trackback->comment_timestamp_gmt , | 
|---|
| 809 | 'agent'         => $trackback->comment_agent , | 
|---|
| 810 | 'type'          => $trackback->comment_type , | 
|---|
| 811 | 'IP'            => $trackback->comment_author_IP , | 
|---|
| 812 | ); | 
|---|
| 813 | array_push($ret,$row_data); | 
|---|
| 814 | } | 
|---|
| 815 | return $ret; | 
|---|
| 816 | } | 
|---|
| 817 | return false; | 
|---|
| 818 | } | 
|---|
| 819 |  | 
|---|
| 820 | function xpress_get_calendar($args = '') { | 
|---|
| 821 | global $wpdb, $m, $monthnum, $year, $wp_locale, $posts , $xoops_config; | 
|---|
| 822 |  | 
|---|
| 823 | $defaults = array( | 
|---|
| 824 | sun_color => '#DB0000', | 
|---|
| 825 | sat_color => '#004D99', | 
|---|
| 826 | initial => true | 
|---|
| 827 | ); | 
|---|
| 828 | $r = wp_parse_args( $args, $defaults ); | 
|---|
| 829 |  | 
|---|
| 830 | extract( $r ); | 
|---|
| 831 |  | 
|---|
| 832 | ob_start(); | 
|---|
| 833 | get_calendar(true); | 
|---|
| 834 | $calendar = ob_get_contents(); | 
|---|
| 835 | ob_end_clean(); | 
|---|
| 836 | $calendar = preg_replace('/<th abbr=/', '<th align="center"  abbr=', $calendar); //week name align center | 
|---|
| 837 | $calendar = preg_replace('/<td>/', '<td align="center">', $calendar); //days align center | 
|---|
| 838 | $calendar = preg_replace('/<td id="today">/', '<td id="today" align="center">', $calendar); //today align center | 
|---|
| 839 | $calendar = preg_replace('/<span style="color:[^>]*>/', '', $calendar); //wp2011 color delete | 
|---|
| 840 | $calendar = preg_replace('/<\/span>/', '', $calendar); //wp2011 color delete | 
|---|
| 841 |  | 
|---|
| 842 | $week_begins = intval(get_option('start_of_week')); | 
|---|
| 843 | $head_pattrn = '<thead>\s*<tr>\s*(<th[^>]*>[^<]*<\/th>)\s*(<th[^>]*>[^<]*<\/th>)\s*(<th[^>]*>[^<]*<\/th>)\s*(<th[^>]*>[^<]*<\/th>)\s*(<th[^>]*>[^<]*<\/th>)\s*(<th[^>]*>[^<]*<\/th>)\s*(<th[^>]*>[^<]*<\/th>)\s*<\/tr>\s*<\/thead>'; | 
|---|
| 844 | if(preg_match('/'. $head_pattrn . '/s' ,$calendar,$head_match)){ | 
|---|
| 845 | $sun_index = 1 - $week_begins; | 
|---|
| 846 | if ($sun_index < 1) $sun_index = $sun_index +7; | 
|---|
| 847 | $sat_index = 7 - $week_begins; | 
|---|
| 848 | if ($sat_index < 1) $sat_index = $sat_index +7; | 
|---|
| 849 |  | 
|---|
| 850 | $sun_head = $head_match[$sun_index]; | 
|---|
| 851 | $sat_head = $head_match[$sat_index]; | 
|---|
| 852 |  | 
|---|
| 853 | $pattrn = '(<th[^>]*>)(.*)(<\/th>)'; | 
|---|
| 854 | if(preg_match('/'. $pattrn . '/' ,$sun_head,$sun_match)){ | 
|---|
| 855 | $sun_head_after = $sun_match[1] . '<span style="color: ' . $sun_color . '">' . $sun_match[2] . '</span>'. $sun_match[3]; | 
|---|
| 856 | $calendar = str_replace($sun_head,$sun_head_after,$calendar); | 
|---|
| 857 | } | 
|---|
| 858 | if(preg_match('/'. $pattrn . '/' ,$sat_head,$sat_match)){ | 
|---|
| 859 | $sat_head_after = $sat_match[1] . '<span style="color: ' . $sat_color . '">' . $sat_match[2] . '</span>'. $sat_match[3]; | 
|---|
| 860 | $calendar = str_replace($sat_head,$sat_head_after,$calendar); | 
|---|
| 861 | } | 
|---|
| 862 | } | 
|---|
| 863 | return $calendar; | 
|---|
| 864 | } | 
|---|
| 865 | ?> | 
|---|