Changeset 155 for trunk/wp-content/plugins/xpressme/include
- Timestamp:
- Apr 4, 2009, 6:47:22 PM (16 years ago)
- Location:
- trunk/wp-content/plugins/xpressme/include
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/plugins/xpressme/include/custom_functions.php
r154 r155 1 1 <?php 2 function xpress_selected_author($show=true ) { 3 $output = ''; 4 $author_cookie = get_xpress_dir_name() . "_select_author" ; 5 if (!empty($_COOKIE[$author_cookie])){ 6 $uid = intval($_COOKIE[$author_cookie]); 7 $user_info = get_userdata($uid); 8 $output = $user_info->display_name; 9 } 10 if (empty($show)) 11 return $output; 12 else 13 echo $output; 14 15 } 2 16 3 17 function xpress_list_pings($trackback, $args, $depth) { … … 199 213 } 200 214 215 function xpress_is_multi_user(){ 216 global $xpress_config; 217 return $xpress_config->is_multi_user; 218 } 219 220 201 221 function xpress_substr($str, $start, $length, $trimmarker = '...') 202 222 { … … 352 372 function xpress_conditional_title($display = true) 353 373 { 374 $selected_author = xpress_selected_author(false); 375 354 376 $output = __('Main', 'xpressme'); 355 377 if (is_category()) … … 363 385 if (is_year()) 364 386 $output = sprintf(__('Archive for %s|Yearly archive page', 'xpressme'), get_the_time(__('Y', 'xpressme'))); 365 if (is_author()) 366 $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author'))); 387 if (is_author()){ 388 if (empty($selected_author)) 389 $output = sprintf(__('Archive for the ‘%s’ Author', 'xpressme'), get_author_name( get_query_var('author'))); 390 } 367 391 if (is_search()) 368 392 $output = sprintf(__('Search Results of word ‘%s’', 'xpressme'), get_search_query()); 393 394 if (!empty($selected_author)) 395 $output = sprintf(__('Article of %s', 'xpressme'), $selected_author) . ' - ' . $output; 369 396 370 397 if ($display) -
trunk/wp-content/plugins/xpressme/include/xpress_common_functions.php
r147 r155 235 235 } 236 236 237 function xpress_set_author_cookie() 238 { 239 $author_cookie = get_xpress_dir_name() . "_select_author" ; 240 if(xpress_is_multi_user()){ 241 if (empty($_GET)){ 242 // $GLOBALS["wp_xoops_author"] = null; 243 setcookie($author_cookie, 0); 244 $_COOKIE[$author_cookie] = 0; 245 246 } else { 247 $auth = intval( @$_GET["author"] ); 248 if ($auth > 0){ 249 setcookie($author_cookie, $auth); 250 $_COOKIE[$author_cookie] = $auth; 251 } 252 } 253 }else{ 254 // $GLOBALS["wp_xoops_author"] = null; 255 setcookie($author_cookie, 0); 256 $_COOKIE[$author_cookie] = 0; 257 } 258 } 259 260 function xpress_query_filter(&$query) 261 { 262 $author_cookie = get_xpress_dir_name() . "_select_author" ; 263 264 if (strpos($query,'SELECT') !==0) return $query; 265 266 $select_pattern = "SELECT(.*)post_author(.*)FROM"; 267 if (preg_match ( "/".$select_pattern."/i", $query, $select_match )) 268 return $query; 269 270 $query = preg_replace('/\s\s+/', ' ', $query); 271 if (!empty($_COOKIE[$author_cookie])){ 272 $pattern = "WHERE(.*)post_type(.*)=(.*)'post'"; 273 if ( preg_match ( "/".$pattern."/i", $query, $match ) ){ 274 $where_str = "$match[0]"; 275 $where_arry = split(' ',$where_str); 276 $post_prefix = ''; 277 foreach ($where_arry as $p){ 278 if ( preg_match ( "/post_type/", $p, $match3 ) ){ 279 $post_prefix = preg_replace("/post_type/", "", $p); 280 break; 281 } 282 } 283 preg_match ( "/post_type(.*)/", $where_str, $p_match ); 284 $patern = $p_match[0]; 285 $replace = $patern . " AND {$post_prefix}post_author = " . intval($_COOKIE[$author_cookie]) . " "; 286 $query = preg_replace("/$patern/", $replace, $query); 287 } 288 } 289 // xpress_show_sql_quary($query); 290 return $query; 291 } 237 292 ?>
Note: See TracChangeset
for help on using the changeset viewer.