Skip to:
Content

BuddyPress.org

Opened 16 years ago

Closed 15 years ago

#654 closed defect (bug) (worksforme)

activity/recent posts widgets not showing excerpts correctly on i18n environment

Reported by: takuya's profile takuya Owned by:
Milestone: 1.2 Priority: major
Severity: Version: 1.0
Component: Keywords: activity, excerpt, i18n, utf8, dev-feedback, needs-patch, reporter-feedback
Cc:

Description

activity feed is showing full contents if the content is not English, especially Japanese or perhaps Chinese.

I have several wordpress plugins to generate excerpts, or even a Japanese plugin to make sure excerpts generated when Kanji is used. But it seems it doesn't work on buddypress theme.

http://buddypress.org/forums/topic.php?id=1981

WordPress and wpmu does support automatic creation of excerpts when the_excerpts is used. But it seems buddypress's excerpt function isn't working properly.

Attachments (1)

2009-10-09_085621.jpg (134.6 KB) - added by takuya 15 years ago.
Activity excerpts not working on 1.1.1

Download all attachments as: .zip

Change History (16)

#1 @takuya
16 years ago

In Japan we have the following plugin. Could you take the following example and create new bp_create_excerpt function to make sure it works?

<?php
/*
Plugin Name: Multibyte Excerpt
Plugin URI: http://www.techdego.com/2007/02/mb_excerpt_plugin.php
Description: This plugin fooks the_excerpt(), the_excerpt_rss() and comment_excerpt() function to excerpt the multibyte words such as Japanese with the number of characters (not words).
Author: Junon
Version: 0.91b
Author URI: http://www.techdego.net/
*/ 


$mb_excerpt_word = 100; // how many mb characters to show
$mb_rss_word = 100;
$mb_comment_word = 80;

mb_internal_encoding(get_bloginfo('charset'));

function is_singlebytechar($character) {
    if (ord($character)>=32 && ord($character)<=126) 
    	return true;
    else
    	return false;
}

function mb_wordwrap($mb_word, $txt) {
   $pointer = 0;
   $result_text = "";

   while ($pointer < mb_strlen($txt)) {
       $this_char = mb_substr($txt,$pointer,1);
       if (is_singlebytechar($this_char)){
	       $mb_word++; // Do not count single byte char;
	   } elseif ($pointer > $mb_word) {
	   	   return mb_substr($txt,0,$pointer);
       }
       $pointer++;
    }
    return $txt; //Since length not exceeded return whole text
}

function mb_excerpt($content) {
	global $mb_excerpt_word;
	$text = mb_wordwrap($mb_excerpt_word, $content);
	if (preg_match("/(\.{3}|&#8230;)$/",strip_tags($text)) == 1) // …:&#8230;
		return $text;
	else {
		return $text.'...';
	}
}

function mb_excerpt_rss($content) {
	global $mb_rss_word;
	return mb_wordwrap($mb_rss_word, $content);
}

function mb_comment_excerpt($content) {
	global $mb_comment_word;
	return mb_wordwrap($mb_comment_word, $content);
}

// Now we set that function up to execute when the tag is called
add_filter('the_excerpt', 'mb_excerpt', 9);
add_filter('the_excerpt_rss', 'mb_excerpt_rss', 9);
add_filter('comment_excerpt', 'mb_comment_excerpt', 9);
?>

#2 @takuya
16 years ago

  • Keywords internationalization localization removed
  • Summary changed from activity feeds not showing excerpts on i18n environment to activity/recent posts widgets not showing excerpts correctly on i18n environment
  • Version set to 1.0

I'm using r1324, but this still happens.

#3 @nicolagreco
15 years ago

  • Milestone set to Core 1.0

#4 @apeatling
15 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [1325]) Fixes #654

#5 @(none)
15 years ago

  • Milestone Core 1.0 deleted

Milestone Core 1.0 deleted

#6 @takuya
15 years ago

  • Milestone set to 1.1.1
  • Resolution fixed deleted
  • Status changed from closed to reopened

I'm reopening this ticket as I found 1.1 is missing this r1325 fix.

#7 @takuya
15 years ago

  • Priority changed from major to minor

It seems 1.1 changed number(s) of characters in excerpts from 1.0.3 or previous versions, which I thought excerpt function is broken again. #1132 might fix.

btw, This functions requires the first plugin I posted to be in mu-plugins to work. I was hoping that plugin function is embed into bp-core.

#8 @takuya
15 years ago

  • Priority changed from minor to major

#1132 doesn't seem to fix. With version 1.1.1 I still see this bug. New image attached, where activity feed doesn't show excerpts but full post (content). Also I'm changing this to major.

@takuya
15 years ago

Activity excerpts not working on 1.1.1

#9 @DJPaul
15 years ago

  • Keywords dev-feedback added

John James Jacoby, is this something you could comment on? I mean the_excerpt I think is a Wordpress hook so maybe this should go there?

#10 @takuya
15 years ago

It should not go to wordpress trac, as there's already fix (http://eastcoder.com/code/wp-multibyte-patch) for wordpress. This is buddypress specific issue. Everything works fine on WordPress, but not on buddypress.

In fact that it used to be working on 1.0.3, but 1.1.1 or 1.1.x broke it again in some way.

#11 @DJPaul
15 years ago

  • Keywords needs-patch added

#12 @johnjamesjacoby
15 years ago

Filter "bp_create_excerpt" is now applied to the $text value. You should be able to hook into that filter and change the output as needed? Is that enough to let you re-filter the content accordingly?

Also, bp_create_excerpt is now run through a number of WordPress filters to try to ensure that things are serialized correctly. See...
http://trac.buddypress.org/browser/branches/1.1/bp-core/bp-core-templatetags.php#L710

...and down below it for the filters.

#13 @johnjamesjacoby
15 years ago

--- not "serialized correctly" but "filtered correctly" (was looking at the bp_is_serialized function when I typed it haha!

#14 @DJPaul
15 years ago

  • Keywords reporter-feedback added

Please would someone confirm this is still an issue with current WP and the BP trunk?

#15 @apeatling
15 years ago

  • Resolution set to worksforme
  • Status changed from reopened to closed

Reopen if still broken.

Note: See TracTickets for help on using tickets.