<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[BuddyPress] [2681] trunk: Remove non-content HTML from the activity table.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>2681</dd>
<dt>Author</dt> <dd>apeatling</dd>
<dt>Date</dt> <dd>2010-02-11 17:12:15 +0000 (Thu, 11 Feb 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove non-content HTML from the activity table.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpactivitybpactivityclassesphp">trunk/bp-activity/bp-activity-classes.php</a></li>
<li><a href="#trunkbpactivitybpactivitytemplatetagsphp">trunk/bp-activity/bp-activity-templatetags.php</a></li>
<li><a href="#trunkbpactivityphp">trunk/bp-activity.php</a></li>
<li><a href="#trunkbpgroupsphp">trunk/bp-groups.php</a></li>
<li><a href="#trunkbpthemesbpdefault_inccssdefaultcss">trunk/bp-themes/bp-default/_inc/css/default.css</a></li>
<li><a href="#trunkbpthemesbpdefaultactivityentryphp">trunk/bp-themes/bp-default/activity/entry.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpactivitybpactivityclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-classes.php (2680 => 2681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-classes.php        2010-02-11 16:19:46 UTC (rev 2680)
+++ trunk/bp-activity/bp-activity-classes.php        2010-02-11 17:12:15 UTC (rev 2681)
</span><span class="lines">@@ -221,7 +221,7 @@
</span><span class="cx">                         $where_args[] = $wpdb-&gt;prepare( &quot;secondary_item_id = %s&quot;, $secondary_item_id );
</span><span class="cx"> 
</span><span class="cx">                 if ( !empty( $action ) )
</span><del>-                        $where_args[] = $wpdb-&gt;prepare( &quot;action = %s&quot;, bp_activity_add_timesince_placeholder( $action ) );
</del><ins>+                        $where_args[] = $wpdb-&gt;prepare( &quot;action = %s&quot;, $action );
</ins><span class="cx"> 
</span><span class="cx">                 if ( !empty( $content ) )
</span><span class="cx">                         $where_args[] = $wpdb-&gt;prepare( &quot;content = %s&quot;, $content );
</span><span class="lines">@@ -262,7 +262,7 @@
</span><span class="cx">                         $where_args[] = $wpdb-&gt;prepare( &quot;user_id = %d&quot;, $user_id );
</span><span class="cx"> 
</span><span class="cx">                 if ( !empty( $action ) )
</span><del>-                        $where_args[] = $wpdb-&gt;prepare( &quot;action = %s&quot;, bp_activity_add_timesince_placeholder( $action ) );
</del><ins>+                        $where_args[] = $wpdb-&gt;prepare( &quot;action = %s&quot;, $action );
</ins><span class="cx"> 
</span><span class="cx">                 if ( !empty( $content ) )
</span><span class="cx">                         $where_args[] = $wpdb-&gt;prepare( &quot;content = %s&quot;, $content );
</span></span></pre></div>
<a id="trunkbpactivitybpactivitytemplatetagsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity/bp-activity-templatetags.php (2680 => 2681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity/bp-activity-templatetags.php        2010-02-11 16:19:46 UTC (rev 2680)
+++ trunk/bp-activity/bp-activity-templatetags.php        2010-02-11 17:12:15 UTC (rev 2681)
</span><span class="lines">@@ -438,7 +438,12 @@
</span><span class="cx">         function bp_get_activity_action() {
</span><span class="cx">                 global $activities_template;
</span><span class="cx"> 
</span><del>-                return apply_filters( 'bp_get_activity_action', bp_activity_content_filter( $activities_template-&gt;activity-&gt;action, $activities_template-&gt;activity-&gt;date_recorded ), $activities_template-&gt;activity-&gt;component, $activities_template-&gt;activity-&gt;type );
</del><ins>+                $action = $activities_template-&gt;activity-&gt;action;
+
+                if ( !empty( $action ) )
+                        $action = bp_insert_activity_meta( $action );
+
+                return apply_filters( 'bp_get_activity_action', $action, &amp;$activities_template-&gt;activity );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_activity_content_body() {
</span><span class="lines">@@ -447,10 +452,11 @@
</span><span class="cx">         function bp_get_activity_content_body() {
</span><span class="cx">                 global $activities_template;
</span><span class="cx"> 
</span><del>-                if ( empty( $activities_template-&gt;activity-&gt;action ) )
-                        $activities_template-&gt;activity-&gt;content = bp_activity_content_filter( $activities_template-&gt;activity-&gt;content, $activities_template-&gt;activity-&gt;date_recorded );
</del><ins>+                /* Backwards compatibility if action is not being used */
+                if ( empty( $activities_template-&gt;activity-&gt;action ) &amp;&amp; !empty( $activities_template-&gt;activity-&gt;content ) )
+                        $activities_template-&gt;activity-&gt;content = bp_insert_activity_meta( $activities_template-&gt;activity-&gt;content );
</ins><span class="cx"> 
</span><del>-                return apply_filters( 'bp_get_activity_content_body', $activities_template-&gt;activity-&gt;content );
</del><ins>+                return apply_filters( 'bp_get_activity_content_body', $activities_template-&gt;activity-&gt;content, &amp;$activities_template-&gt;activity );
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> function bp_activity_content() {
</span><span class="lines">@@ -470,37 +476,25 @@
</span><span class="cx">                 return apply_filters( 'bp_get_activity_content', $content );
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-function bp_activity_content_filter( $content, $date_recorded ) {
-        global $activities_template, $bp;
</del><ins>+        function bp_insert_activity_meta( $content ) {
+                global $activities_template;
</ins><span class="cx"> 
</span><del>-        if ( !$content )
-                return false;
</del><ins>+                /* Strip any legacy time since placeholders -- TODO: Remove this in 1.3 */
+                $content = str_replace( '&lt;span class=&quot;time-since&quot;&gt;%s&lt;/span&gt;', '', $content );
</ins><span class="cx"> 
</span><del>-        /* Split the content so we don't evaluate and replace text on content we don't want to */
-        $content = explode( '%s', $content );
</del><ins>+                /* Insert the time since. */
+                $content .= ' ' . apply_filters( 'bp_activity_time_since', '&lt;span class=&quot;time-since&quot;&gt;' . sprintf( __( '&amp;nbsp; %s ago', 'buddypress' ), bp_core_time_since( $activities_template-&gt;activity-&gt;date_recorded ) ) . '&lt;/span&gt;', &amp;$activities_template-&gt;activity );
</ins><span class="cx"> 
</span><del>-        /* Re-add the exploded %s */
-        $content[0] .= '%s';
</del><ins>+                /* Insert the permalink */
+                $content .= apply_filters( 'bp_activity_permalink', ' &amp;middot; &lt;a href=&quot;' . bp_activity_get_permalink( $activities_template-&gt;activity-&gt;id, $activities_template-&gt;activity ) . '&quot; class=&quot;view&quot; title=&quot;' . __( 'View Thread / Permalink', 'buddypress' ) . '&quot;&gt;' . __( 'View', 'buddypress' ) . '&lt;/a&gt;', &amp;$activities_template-&gt;activity );
</ins><span class="cx"> 
</span><del>-        /* Insert the time since */
-        $content[0] = bp_activity_insert_time_since( $content[0], $date_recorded );
</del><ins>+                /* Add the delete link if the user has permission on this item */
+                if ( ( $activities_template-&gt;activity-&gt;user_id == $bp-&gt;loggedin_user-&gt;id ) || $bp-&gt;is_item_admin || is_site_admin() )
+                         $content .= apply_filters( 'bp_activity_delete_link', ' &amp;middot; ' . bp_get_activity_delete_link(), &amp;$activities_template-&gt;activity );
</ins><span class="cx"> 
</span><del>-        /* Add the permalink */
-        $meta = ' &amp;middot; &lt;a href=&quot;' . bp_activity_get_permalink( $activities_template-&gt;activity-&gt;id, $activities_template-&gt;activity ) . '&quot; class=&quot;view&quot; title=&quot;' . __( 'View Thread / Permalink', 'buddypress' ) . '&quot;&gt;' . __( 'View', 'buddypress' ) . '&lt;/a&gt;';
</del><ins>+                return apply_filters( 'bp_insert_activity_meta', $content );
+        }
</ins><span class="cx"> 
</span><del>-        /* Add the delete link if the user has permission on this item */
-        if ( ( $activities_template-&gt;activity-&gt;user_id == $bp-&gt;loggedin_user-&gt;id ) || $bp-&gt;is_item_admin || is_site_admin() )
-                 $meta .= ' &amp;middot; ' . bp_get_activity_delete_link();
-
-        $content[1] = $meta . '&lt;/span&gt;' . $content[1];
-        $content_new = '';
-
-        for ( $i = 0; $i &lt; count($content); $i++ )
-                $content_new .= $content[$i];
-
-        return apply_filters( 'bp_activity_content_filter', $content_new );
-}
-
</del><span class="cx"> function bp_activity_parent_content( $args = '' ) {
</span><span class="cx">         echo bp_get_activity_parent_content($args);
</span><span class="cx"> }
</span><span class="lines">@@ -527,7 +521,7 @@
</span><span class="cx">                 else
</span><span class="cx">                         $content = $activities_template-&gt;activity_parents[$parent_id]-&gt;action . $activities_template-&gt;activity_parents[$parent_id]-&gt;content;
</span><span class="cx"> 
</span><del>-                /* Remove the time since content */
</del><ins>+                /* Remove the time since content for backwards compatibility */
</ins><span class="cx">                 $content = str_replace( '&lt;span class=&quot;time-since&quot;&gt;%s&lt;/span&gt;', '', $content );
</span><span class="cx"> 
</span><span class="cx">                 /* Remove images */
</span><span class="lines">@@ -620,16 +614,6 @@
</span><span class="cx">                         return $count;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-function bp_activity_insert_time_since( $content, $date ) {
-        if ( !$content || !$date )
-                return false;
-
-        // Make sure we don't have any URL encoding in links when trying to insert the time.
-        $content = urldecode($content);
-
-        return apply_filters( 'bp_activity_insert_time_since', @sprintf( $content, @sprintf( __( '&amp;nbsp; %s ago', 'buddypress' ), bp_core_time_since( $date ) ) ) );
-}
-
</del><span class="cx"> function bp_activity_permalink_id() {
</span><span class="cx">         echo bp_get_activity_permalink_id();
</span><span class="cx"> }
</span><span class="lines">@@ -871,10 +855,8 @@
</span><span class="cx">                 if ( ':' == substr( $title, -1 ) )
</span><span class="cx">                         $title = substr( $title, 0, -1 );
</span><span class="cx"> 
</span><del>-                if ( 'activity_update' == $activities_template-&gt;activity-&gt;type ) {
-                        $content = explode( '&lt;div class=&quot;activity-inner&quot;&gt;', $activities_template-&gt;activity-&gt;content );
-                        $title .= ': ' . strip_tags( bp_create_excerpt( $content[1], 15 ));
-                }
</del><ins>+                if ( 'activity_update' == $activities_template-&gt;activity-&gt;type )
+                        $title .= ': ' . strip_tags( bp_create_excerpt( $activities_template-&gt;activity-&gt;content, 15 ) );
</ins><span class="cx"> 
</span><span class="cx">                 return apply_filters( 'bp_get_activity_feed_item_title', $title );
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkbpactivityphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-activity.php (2680 => 2681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-activity.php        2010-02-11 16:19:46 UTC (rev 2680)
+++ trunk/bp-activity.php        2010-02-11 17:12:15 UTC (rev 2681)
</span><span class="lines">@@ -537,12 +537,6 @@
</span><span class="cx">         if ( empty( $type ) &amp;&amp; !empty( $component_action ) )
</span><span class="cx">                 $type = $component_action;
</span><span class="cx"> 
</span><del>-        /* Insert the &quot;time-since&quot; placeholder (use content if action empty for backwards compat) */
-        if ( !empty( $action ) )
-                $action = bp_activity_add_timesince_placeholder( $action );
-        else if ( empty( $action ) &amp;&amp; !empty( $content ) )
-                $content = bp_activity_add_timesince_placeholder( $content );
-
</del><span class="cx">         $activity = new BP_Activity_Activity( $id );
</span><span class="cx"> 
</span><span class="cx">         $activity-&gt;user_id = $user_id;
</span><span class="lines">@@ -586,7 +580,7 @@
</span><span class="cx">         /* Record this on the user's profile */
</span><span class="cx">         $from_user_link = bp_core_get_userlink( $user_id );
</span><span class="cx">         $activity_action = sprintf( __( '%s posted an update:', 'buddypress' ), $from_user_link );
</span><del>-        $activity_content = '&lt;div class=&quot;activity-inner&quot;&gt;' . $content . '&lt;/div&gt;';
</del><ins>+        $activity_content = $content;
</ins><span class="cx"> 
</span><span class="cx">         $primary_link = bp_core_get_userlink( $user_id, false, true );
</span><span class="cx"> 
</span><span class="lines">@@ -637,7 +631,7 @@
</span><span class="cx">         /* Insert the activity comment */
</span><span class="cx">         $comment_id = bp_activity_add( array(
</span><span class="cx">                 'action' =&gt; apply_filters( 'bp_activity_comment_action', sprintf( __( '%s posted a new activity comment:', 'buddypress' ), bp_core_get_userlink( $user_id ) ) ),
</span><del>-                'content' =&gt; apply_filters( 'bp_activity_comment_content', '&lt;div class=&quot;activity-inner&quot;&gt;' . $content . '&lt;/div&gt;' ),
</del><ins>+                'content' =&gt; apply_filters( 'bp_activity_comment_content', $content ),
</ins><span class="cx">                 'component' =&gt; $bp-&gt;activity-&gt;id,
</span><span class="cx">                 'type' =&gt; 'activity_comment',
</span><span class="cx">                 'user_id' =&gt; $user_id,
</span><span class="lines">@@ -811,31 +805,6 @@
</span><span class="cx">         return apply_filters( 'bp_activity_get_permalink', $link );
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-function bp_activity_add_timesince_placeholder( $content ) {
-        /* Check a time-since span doesn't already exist */
-        if ( false === strpos( $content, '&lt;span class=&quot;time-since&quot;&gt;' ) ) {
-                if ( !$pos = strpos( $content, '&lt;blockquote' ) ) {
-                        if ( !$pos = strpos( $content, '&lt;div' ) ) {
-                                if ( !$pos = strpos( $content, '&lt;ul' ) ) {
-                                        $content .= ' &lt;span class=&quot;time-since&quot;&gt;%s&lt;/span&gt;';
-                                }
-                        }
-                }
-        }
-
-        if ( (int) $pos ) {
-                $before = substr( $content, 0, (int) $pos );
-                $after = substr( $content, (int) $pos, strlen( $content ) );
-
-                /* Escape any existing % signs */
-                $before = str_replace( '%', '%%', $before );
-
-                $content = $before . ' &lt;span class=&quot;time-since&quot;&gt;%s&lt;/span&gt;' . $after;
-        }
-
-        return apply_filters( 'bp_activity_add_timesince_placeholder', $content );
-}
-
</del><span class="cx"> function bp_activity_hide_user_activity( $user_id ) {
</span><span class="cx">         return BP_Activity_Activity::hide_all_for_user( $user_id );
</span><span class="cx"> }
</span><span class="lines">@@ -966,9 +935,6 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function bp_activity_check_exists_by_content( $content ) {
</span><del>-        /* Insert the &quot;time-since&quot; placeholder to match the existing content in the DB */
-        $content = bp_activity_add_timesince_placeholder( $content );
-
</del><span class="cx">         return apply_filters( 'bp_activity_check_exists_by_content', BP_Activity_Activity::check_exists_by_content( $content ) );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkbpgroupsphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-groups.php (2680 => 2681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-groups.php        2010-02-11 16:19:46 UTC (rev 2680)
+++ trunk/bp-groups.php        2010-02-11 17:12:15 UTC (rev 2681)
</span><span class="lines">@@ -1889,7 +1889,7 @@
</span><span class="cx"> 
</span><span class="cx">         /* Record this in activity streams */
</span><span class="cx">         $activity_action = sprintf( __( '%s posted an update in the group %s:', 'buddypress'), bp_core_get_userlink( $user_id ), '&lt;a href=&quot;' . bp_get_group_permalink( $bp-&gt;groups-&gt;current_group ) . '&quot;&gt;' . attribute_escape( $bp-&gt;groups-&gt;current_group-&gt;name ) . '&lt;/a&gt;' );
</span><del>-        $activity_content = '&lt;div class=&quot;activity-inner&quot;&gt;' . $content . '&lt;/div&gt;';
</del><ins>+        $activity_content = $content;
</ins><span class="cx"> 
</span><span class="cx">         $activity_id = groups_record_activity( array(
</span><span class="cx">                 'user_id' =&gt; $user_id,
</span></span></pre></div>
<a id="trunkbpthemesbpdefault_inccssdefaultcss"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/_inc/css/default.css (2680 => 2681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/_inc/css/default.css        2010-02-11 16:19:46 UTC (rev 2680)
+++ trunk/bp-themes/bp-default/_inc/css/default.css        2010-02-11 17:12:15 UTC (rev 2681)
</span><span class="lines">@@ -1139,15 +1139,14 @@
</span><span class="cx">                         margin-bottom: 0;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><del>-        .activity-list .activity-content &gt; p:first-child,
</del><ins>+        .activity-list .activity-content .activity-header,
</ins><span class="cx">         .activity-list .activity-content .comment-header {
</span><span class="cx">                 font-size: 11px;
</span><span class="cx">                 color: #888;
</span><span class="cx">                 line-height: 220%;
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        .activity-list .activity-content &gt; p &gt; a:first-child, span.highlight,
-        .activity-list .activity-content &gt; .comment-header &gt; a:first-child {
</del><ins>+        .activity-list .activity-header a:first-child, span.highlight {
</ins><span class="cx">                 background: #EBF7FF;
</span><span class="cx">                 border-bottom: 1px solid #a1dcfa;
</span><span class="cx">                 border-right: 1px solid #a1dcfa;
</span><span class="lines">@@ -1159,8 +1158,7 @@
</span><span class="cx">                 border-radius: 4px;
</span><span class="cx">                 margin-right: 3px;
</span><span class="cx">         }
</span><del>-                .activity-list .activity-content &gt; p &gt; a:first-child:hover,
-                .activity-list .activity-content &gt;.comment-header &gt; a:first-child:hover {
</del><ins>+                .activity-list .activity-header a:first-child:hover {
</ins><span class="cx">                         background: #059AE7 !important;
</span><span class="cx">                         color: #fff !important;
</span><span class="cx">                 }
</span><span class="lines">@@ -1194,6 +1192,9 @@
</span><span class="cx">                         margin-top: 5px;
</span><span class="cx">                 }
</span><span class="cx"> 
</span><ins>+                /* Backwards compatibility. */
+                .activity-inner &gt; .activity-inner { margin: 0 !important; }
+
</ins><span class="cx">         .activity-list .activity-content img.thumbnail {
</span><span class="cx">                 float: left;
</span><span class="cx">                 margin: 0 10px 5px 0;
</span></span></pre></div>
<a id="trunkbpthemesbpdefaultactivityentryphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-themes/bp-default/activity/entry.php (2680 => 2681)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-themes/bp-default/activity/entry.php        2010-02-11 16:19:46 UTC (rev 2680)
+++ trunk/bp-themes/bp-default/activity/entry.php        2010-02-11 17:12:15 UTC (rev 2681)
</span><span class="lines">@@ -10,9 +10,15 @@
</span><span class="cx">         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">         &lt;div class=&quot;activity-content&quot;&gt;
</span><del>-                &lt;?php /* You can also split this into bp_activity_action() and bp_activity_content_body() */ ?&gt;
-                &lt;?php bp_activity_content() ?&gt;
</del><span class="cx"> 
</span><ins>+                &lt;div class=&quot;activity-header&quot;&gt;
+                        &lt;?php bp_activity_action() ?&gt;
+                &lt;/div&gt;
+
+                &lt;div class=&quot;activity-inner&quot;&gt;
+                        &lt;?php bp_activity_content_body() ?&gt;
+                &lt;/div&gt;
+
</ins><span class="cx">                 &lt;?php do_action( 'bp_activity_entry_content' ) ?&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;div class=&quot;activity-meta&quot;&gt;
</span></span></pre>
</div>
</div>

</body>
</html>