Difference between revisions of "RC-Summary.php"

From Organic Design wiki
m
m ({{legacy}})
 
(12 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<?
+
{{legacy}}
 +
<php><?
 
# Appends article with a compact list of last 5 non-minor changes
 
# Appends article with a compact list of last 5 non-minor changes
global $wgLang, $wgContLang, $$title;
+
global $xwIsAdmin, $xwUserGroups, $wgLang, $wgContLang, $$title;
 
if ( $event == 'view' ) {
 
if ( $event == 'view' ) {
 
$article = $$title;
 
$article = $$title;
Line 7: Line 8:
 
}
 
}
 
else {
 
else {
# Get the changes from the db
+
# Get changes from the db (get more than needed incase some private)
 
$db =& wfGetDB( DB_MASTER );
 
$db =& wfGetDB( DB_MASTER );
 
$result = $db->query("
 
$result = $db->query("
 
SELECT rc_id, rc_timestamp, rc_user_text, rc_namespace, rc_title, rc_comment
 
SELECT rc_id, rc_timestamp, rc_user_text, rc_namespace, rc_title, rc_comment
FROM recentchanges WHERE rc_minor=0 ORDER BY rc_timestamp DESC LIMIT 10
+
FROM recentchanges WHERE rc_minor=0 ORDER BY rc_timestamp DESC LIMIT 50
 
");
 
");
 
# Format the items for display
 
# Format the items for display
 
$changes = array();
 
$changes = array();
 
$i = -1;
 
$i = -1;
while ($row = mysql_fetch_assoc($result)) {
+
$first = 0;
 +
while ( $row = mysql_fetch_assoc($result) ) {
 
$t = $wgLang->time( $row['rc_timestamp'], true );
 
$t = $wgLang->time( $row['rc_timestamp'], true );
 
$n = $wgContLang->getNsText( $row['rc_namespace'] );
 
$n = $wgContLang->getNsText( $row['rc_namespace'] );
 
$a = $n ? "$n:".$row['rc_title'] : $row['rc_title'];
 
$a = $n ? "$n:".$row['rc_title'] : $row['rc_title'];
$id = $row['rc_id'];
+
# Get read-perms for article
$changes[++$i] = "item$i=$id,$t,".$row['rc_user_text'].",$a,".$row['rc_comment'];
+
if ( !$readable = $xwIsAdmin ) {
if ($i == 0) $first = $id;
+
$readable = xwGetListByTagname( xwArticleProperties($a), 'read' ) + array('anyone');
 +
$readable = count( array_intersect( $readable, $xwUserGroups ) );
 +
}
 +
# Store change if readable
 +
if ( $readable ) {
 +
$id = $row['rc_id'];
 +
if ( $readable ) $changes[++$i] = "item$i=$id,$t,".$row['rc_user_text'].",$a,".$row['rc_comment'];
 +
if ( $first == 0 ) $first = $id;
 +
}
 
}
 
}
 
# If SWF format requested, remove all view-transforms and replace with self
 
# If SWF format requested, remove all view-transforms and replace with self
Line 29: Line 39:
 
xwSetProperty($properties, 'view', $tTitle);
 
xwSetProperty($properties, 'view', $tTitle);
 
# Only return content if first ID changed
 
# Only return content if first ID changed
$$title = $swf == $first ? '' : join( '&', $changes ) );
+
if ( $$title = $swf == $first ? '' : join( '&', $changes ) ) {
$$title = preg_replace( "/\\[{2}(.+?)\\|(.+?)\\]{2}/", '<u><a href="$1">$2</a></u>', $$title );
+
$$title = preg_replace( "/\\[{2}([^\\]]+?)\\|(.+?)\\]{2}/", '<u><a href="$1">$2</a></u>', $$title );
$$title = preg_replace( "/\\[{2}(.+?)\\]{2}/", '<u><a href="$1">$1</a></u>', $$title );
+
$$title = preg_replace( "/\\[{2}(.+?)\\]{2}/", '<u><a href="$1">$1</a></u>', $$title );
 +
}
 
}
 
}
 
# SWF not requested, render a nice table for embedding
 
# SWF not requested, render a nice table for embedding
 
else {
 
else {
$article = join( '<br>', $changes );
+
for ( $i = 0; $i < 10; $i++ ) $article .= $changes[$i].'<br>';
 
}
 
}
 
}
 
}
?>
+
?></php>

Latest revision as of 10:14, 28 June 2007

Legacy.svg Legacy: This article describes a concept that has been superseded in the course of ongoing development on the Organic Design wiki. Please do not develop this any further or base work on this concept, this is only useful for a historic record of work done. You may find a link to the currently used concept or function in this article, if not you can contact the author to find out what has taken the place of this legacy item.

<php><?

  1. Appends article with a compact list of last 5 non-minor changes

global $xwIsAdmin, $xwUserGroups, $wgLang, $wgContLang, $$title; if ( $event == 'view' ) { $article = $$title; header( 'Content-type: application/x-www-urlform-encoded' ); } else { # Get changes from the db (get more than needed incase some private) $db =& wfGetDB( DB_MASTER ); $result = $db->query(" SELECT rc_id, rc_timestamp, rc_user_text, rc_namespace, rc_title, rc_comment FROM recentchanges WHERE rc_minor=0 ORDER BY rc_timestamp DESC LIMIT 50 "); # Format the items for display $changes = array(); $i = -1; $first = 0; while ( $row = mysql_fetch_assoc($result) ) { $t = $wgLang->time( $row['rc_timestamp'], true ); $n = $wgContLang->getNsText( $row['rc_namespace'] ); $a = $n ? "$n:".$row['rc_title'] : $row['rc_title']; # Get read-perms for article if ( !$readable = $xwIsAdmin ) { $readable = xwGetListByTagname( xwArticleProperties($a), 'read' ) + array('anyone'); $readable = count( array_intersect( $readable, $xwUserGroups ) ); } # Store change if readable if ( $readable ) { $id = $row['rc_id']; if ( $readable ) $changes[++$i] = "item$i=$id,$t,".$row['rc_user_text'].",$a,".$row['rc_comment']; if ( $first == 0 ) $first = $id; } } # If SWF format requested, remove all view-transforms and replace with self if ( $swf = $_REQUEST['SWF'] ) { xwRemoveElement( $properties, 'view' ); xwSetProperty($properties, 'view', $tTitle); # Only return content if first ID changed if ( $$title = $swf == $first ?  : join( '&', $changes ) ) { $$title = preg_replace( "/\\[{2}([^\\]]+?)\\|(.+?)\\]{2}/", '<a href="$1">$2</a>', $$title ); $$title = preg_replace( "/\\[{2}(.+?)\\]{2}/", '<a href="$1">$1</a>', $$title ); } } # SWF not requested, render a nice table for embedding else { for ( $i = 0; $i < 10; $i++ ) $article .= $changes[$i].'
'; } } ?></php>