I am curious... why would personal views interest a reader ?
And talk pages already exist for this I think...
Ant
Simon Kissane a écrit:
Hi all,
I have implemented the following feature in MediaWiki, which maybe some might find interesting/useful -- "Personal Views". Basically, any article page has a "Personal Views" page attached to it; on subpages of the personal views page, User's can record their personal views of the topic of the article.
So, for example, User:Foo can record their personal viewpoint on Microsoft on the page Personal_Views:Microsoft/Foo, a page which only User:Foo can edit. And by going to "Personal_Views:Microsoft", we can see everyone's personal views on Microsoft.
Some questions:
- Any comments on how I implemented this? Anything in adding a new
namespace I forget to do? 2. Can I add this to the CVS?
Also, since my changes are relatively small, it might serve as an example of how to add a new namespace to WikiMedia. (Maybe I can turn it into a tutorial...)
Cheers Simon Kissane
? config/LocalSettings.php ? includes/PersonalViews.php Index: index.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/index.php,v retrieving revision 1.53 diff -u -r1.53 index.php --- index.php 22 Aug 2004 23:55:35 -0000 1.53 +++ index.php 28 Aug 2004 14:34:37 -0000 @@ -104,6 +104,10 @@ require_once( "includes/ImagePage.php" ); $wgArticle = new ImagePage( $wgTitle ); break;
case NS_PERSONAL_VIEWS:
require_once( "includes/PersonalViews.php" );
$wgArticle = new PersonalViews ( $wgTitle );
case NS_CATEGORY: if ( $wgUseCategoryMagic ) { require_once( "includes/CategoryPage.php" );break;
Index: includes/Article.php
RCS file: /cvsroot/wikipedia/phase3/includes/Article.php,v retrieving revision 1.209 diff -u -r1.209 Article.php --- includes/Article.php 24 Aug 2004 18:04:37 -0000 1.209 +++ includes/Article.php 28 Aug 2004 14:34:37 -0000 @@ -345,7 +345,7 @@ # Pre-fill content with error message so that if something # fails we'll have something telling us what we intended.
$t = $this->mTitle->getPrefixedText();
if ( isset( $oldid ) ) { $oldid = IntVal( $oldid ); $t .= ',oldid='.$oldid;$t = $this->getTitle();
@@ -390,7 +390,7 @@ array( 'cur_id' => $rid ), $fname, $this->getSelectOptions() );
if ( $redirRow !== false ) {
$this->mRedirectedFrom = $this->mTitle->getPrefixedText();
$this->mRedirectedFrom = $this->getTitle(); $this->mTitle = $rt; $s = $redirRow; }
@@ -467,7 +467,7 @@ array( 'cur_id' => $rid ), $fname, $this->getSelectOptions() );
if ( $redirRow !== false ) {
$this->mRedirectedFrom = $this->mTitle->getPrefixedText();
$this->mRedirectedFrom = $this->getTitle(); $this->mTitle = $rt; $s = $redirRow; }
@@ -662,7 +662,7 @@
if ( !is_null( $diff ) ) { require_once( 'DifferenceEngine.php' );
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
$wgOut->setPageTitle( $this->getTitle() ); $de = new DifferenceEngine( intval($oldid), intval($diff), intval($rcid) ); $de->showDiffPage(); wfProfileOut( $fname );
@@ -747,7 +747,7 @@ $wgOut->addWikiText( $text ); } }
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
# If we have been passed an &rcid= parameter, we want to give the user a # chance to mark this new article as patrolled. if ( $wgUseRCPatrol && !is_null ( $rcid ) && $rcid != 0 && $wgUser->getID() != 0 &&$wgOut->setPageTitle( $this->getTitle() );
@@ -1088,7 +1088,7 @@ global $wgOut, $wgUseValidation; if( $wgUseValidation ) { require_once ( 'SpecialValidate.php' ) ;
$wgOut->setPagetitle( wfMsg( 'validate' ) . ': ' . $this->mTitle->getPrefixedText() );
$wgOut->setPagetitle( wfMsg( 'validate' ) . ': ' . $this->getTitle() ); $wgOut->setRobotpolicy( 'noindex,follow' ); if( $this->mTitle->getNamespace() != 0 ) { $wgOut->addHTML( wfMsg( 'val_validate_article_namespace_only' ) );
@@ -1127,7 +1127,7 @@ RecentChange::markPatrolled( $rcid ); $wgOut->setPagetitle( wfMsg( 'markedaspatrolled' ) ); $wgOut->addWikiText( wfMsg( 'markedaspatrolledtext' ) );
$wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
} else {$wgOut->returnToMain( true, $this->getTitle() );
@@ -1159,7 +1159,7 @@ $wgOut->setRobotpolicy( 'noindex,follow' );
$sk = $wgUser->getSkin() ;
$link = $this->mTitle->getPrefixedText();
$link = $this->getTitle();
if($add) $text = wfMsg( 'addedwatchtext', $link );
@@ -1170,7 +1170,7 @@ $up = new UserUpdate(); array_push( $wgDeferredUpdateList, $up );
$wgOut->returnToMain( true, $this->mTitle->getPrefixedText() );
$wgOut->returnToMain( true, $this->getTitle() );
}
function unwatch() {
@@ -1231,7 +1231,7 @@
wfDebug( "Article::confirmProtect\n" );
$sub = htmlspecialchars( $this->mTitle->getPrefixedText() );
$sub = htmlspecialchars( $this->getTitle() );
$wgOut->setRobotpolicy( 'noindex,nofollow' );
$check = '';
@@ -1408,7 +1408,7 @@
wfDebug( "Article::confirmDelete\n" );
$sub = htmlspecialchars( $this->mTitle->getPrefixedText() );
$wgOut->setSubtitle( wfMsg( 'deletesub', $sub ) ); $wgOut->setRobotpolicy( 'noindex,nofollow' ); $wgOut->addWikiText( wfMsg( 'confirmdeletetext' ) );$sub = htmlspecialchars( $this->getTitle() );
@@ -1462,7 +1462,7 @@ wfDebug( $fname."\n" );
if ( $this->doDeleteArticle( $reason ) ) {
$deleted = $this->mTitle->getPrefixedText();
$deleted = $this->getTitle(); $wgOut->setPagetitle( wfMsg( 'actioncomplete' ) ); $wgOut->setRobotpolicy( 'noindex,nofollow' );
@@ -1641,7 +1641,7 @@ if( $from != $s->cur_user_text ) { $wgOut->setPageTitle(wfmsg('rollbackfailed')); $wgOut->addWikiText( wfMsg( 'alreadyrolled',
htmlspecialchars( $this->mTitle->getPrefixedText()),
htmlspecialchars( $this->getTitle()), htmlspecialchars( $from ), htmlspecialchars( $s->cur_user_text ) ) ); if($s->cur_comment != '') {
@@ -2044,6 +2044,18 @@ } } }
- # Added by SJK 28-Aug-2004 to implement Personal_Views: support
- function getTitle() {
if ( NS_PERSONAL_VIEWS == $this->mTitle->getNamespace()
and preg_match('/^([^\/]*)\/([^\/]*)$/',$this->mTitle->getText(),$matches) ) {
return wfMsg( 'personalviews_articleheader', $matches[2], $matches[1] ) ;
}
else if ( NS_PERSONAL_VIEWS == $this->mTitle->getNamespace() ) {
return wfMsg( 'personalviews_header', $this->mTitle->getText() );
}
return $this->mTitle->getPrefixedText();
- }
}
?> Index: includes/Defines.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/Defines.php,v retrieving revision 1.5 diff -u -r1.5 Defines.php --- includes/Defines.php 25 Aug 2004 02:12:02 -0000 1.5 +++ includes/Defines.php 28 Aug 2004 14:34:37 -0000 @@ -28,6 +28,8 @@ define('NS_HELP_TALK', 13); define('NS_CATEGORY', 14); define('NS_CATEGORY_TALK', 15); +define('NS_PERSONAL_VIEWS', 16); +define('NS_PERSONAL_VIEWS_TALK', 17);
# Fix the code and remove these... define('NS_WP', NS_PROJECT); Index: includes/Namespace.php =================================================================== RCS file: /cvsroot/wikipedia/phase3/includes/Namespace.php,v retrieving revision 1.20 diff -u -r1.20 Namespace.php --- includes/Namespace.php 22 Aug 2004 17:24:50 -0000 1.20 +++ includes/Namespace.php 28 Aug 2004 14:34:37 -0000 @@ -29,7 +29,9 @@ NS_HELP => 'Help', NS_HELP_TALK => 'Help_talk', NS_CATEGORY => 'Category',
- NS_CATEGORY_TALK => 'Category_talk'
- NS_CATEGORY_TALK => 'Category_talk',
NS_PERSONAL_VIEWS => 'Personal_Views',
NS_PERSONAL_VIEWS_TALK => 'Personal_Views_talk'
);
class Namespace { @@ -44,7 +46,7 @@
function isMovable( $index ) {
if ( $index < NS_MAIN || $index == NS_IMAGE || $index == NS_CATEGORY ) {
} return true;if ( $index < NS_MAIN || $index == NS_IMAGE || $index == NS_CATEGORY) { return false;
@@ -55,7 +57,7 @@ if ( NS_TALK == $index || NS_USER_TALK == $index || NS_WP_TALK == $index || NS_IMAGE_TALK == $index || NS_MEDIAWIKI_TALK == $index || NS_TEMPLATE_TALK == $index || NS_HELP_TALK == $index ||
- NS_CATEGORY_TALK == $index ) {
- NS_CATEGORY_TALK == $index || NS_PERSONAL_VIEWS_TALK == $index) { return true; } return false;
Index: includes/Skin.php
RCS file: /cvsroot/wikipedia/phase3/includes/Skin.php,v retrieving revision 1.263 diff -u -r1.263 Skin.php --- includes/Skin.php 25 Aug 2004 02:13:32 -0000 1.263 +++ includes/Skin.php 28 Aug 2004 14:34:38 -0000 @@ -1706,6 +1706,12 @@ $this->checkTitle($title, $name); return $title->getLocalURL( $urlaction ); }
- /*static*/ function makePersonalViewsUrl ( $name, $urlaction='' ) {
$title = Title::newFromText( $name );
$title = $title->getPersonalViews();
$this->checkTitle($title, $name);
return $title->getLocalURL( $urlaction );
- } /*static*/ function makeArticleUrl ( $name, $urlaction='' ) { $title = Title::newFromText( $name ); $title= $title->getSubjectPage();
Index: includes/SkinPHPTal.php
RCS file: /cvsroot/wikipedia/phase3/includes/SkinPHPTal.php,v retrieving revision 1.99 diff -u -r1.99 SkinPHPTal.php --- includes/SkinPHPTal.php 28 Aug 2004 00:38:59 -0000 1.99 +++ includes/SkinPHPTal.php 28 Aug 2004 14:34:38 -0000 @@ -319,7 +319,8 @@ if( $this->iscontent ) {
$nskey = $this->getNameSpaceKey();
$is_active = !Namespace::isTalk( $wgTitle->getNamespace()) ;
$is_active = !Namespace::isTalk( $wgTitle->getNamespace())
&& $wgTitle->getNamespace() != NS_PERSONAL_VIEWS; if ( $action == 'validate' ) $is_active = false ; # Show article tab deselected when validating $content_actions[$nskey] = array('class' => ($is_active) ? 'selected' : false, 'text' => wfMsg($nskey),
@@ -344,6 +345,30 @@ ); }
/* personal views */
if ($wgTitle->getNamespace() == NS_MAIN) {
$persviews_class = false;
$persviewstitle = Title::newFromText( $this->titletxt );
$persviewstitle = $persviewstitle->getPersonalViews();
$this->checkTitle($persviewstitle, $this->titletxt);
$content_actions['personal_views'] = array(
'class' => $persviews_class,
'text' => wfMsg('personal_views'),
'href' => $this->makePersonalViewsUrl($this->titletxt)
);
}
else if ($wgTitle->getNamespace() == NS_PERSONAL_VIEWS) {
$persviews_class = 'selected';
$persviewstitle = Title::newFromText( $this->titletxt );
$persviewstitle = $persviewstitle->getPersonalViews();
$this->checkTitle($persviewstitle, $this->titletxt);
$content_actions['personal_views'] = array(
'class' => $persviews_class,
'text' => wfMsg('personal_views'),
'href' => $this->makePersonalViewsUrl($this->titletxt)
);
}
if ( $wgTitle->userCanEdit() ) { $oid = ( $oldid && ! isset( $diff ) ) ? "&oldid={$oldid}" : false; $istalk = ( Namespace::isTalk( $wgTitle->getNamespace()) );
Index: includes/Title.php
RCS file: /cvsroot/wikipedia/phase3/includes/Title.php,v retrieving revision 1.103 diff -u -r1.103 Title.php --- includes/Title.php 23 Aug 2004 00:49:02 -0000 1.103 +++ includes/Title.php 28 Aug 2004 14:34:38 -0000 @@ -541,6 +541,12 @@ and !$wgUser->isSysop() and !preg_match('/^'.preg_quote($wgUser->getName(), '/').'/', $this->mTextform) ) { return false; }
# Disable editing of "Personal Views" user subpages except by appropriate user
if ( NS_PERSONAL_VIEWS == $this->mNamespace
and preg_match('/^[^\/]*\/(.*)$/',$this->mTextform,$matches )
and !$wgUser->isSysop()
and $matches[1] != $wgUser->getName() )
$ur = $wgUser->getRights(); foreach ( $this->getRestrictions() as $r ) { if ( '' != $r && ( ! in_array( $r, $ur ) ) ) {{ return false; }
@@ -650,8 +656,7 @@ 'cur_title' => $this->getDBkey() ), 'Title::invalidateCache' );
return $success;
- }
return $success; }
# Prefixes some arbitrary text with the namespace or interwiki prefix of this object /* private */ function prefix( $name ) {
@@ -800,9 +805,19 @@ function getTalkPage() { return Title::makeTitle( Namespace::getTalk( $this->getNamespace() ), $this->getDBkey() ); }
- # Get a title object associated with the personal views page of the article
- function getPersonalViews() {
return Title::makeTitle ( NS_PERSONAL_VIEWS, $this->getDBkey() );
- }
- # Get a title object associated with the subject page of this talk page function getSubjectPage() {
if ( $this->getNamespace() == NS_PERSONAL_VIEWS ) {
$dbkey = $this->getDBkey();
if (preg_match('/^([^\/]+)\/([^\/]+)$/',$dbkey,$matches)) { $dbkey = $matches[1]; }
return Title::makeTitle ( NS_MAIN , $dbkey );
return Title::makeTitle( Namespace::getSubject( $this->getNamespace() ), $this->getDBkey() ); }}
Index: languages/Language.php
RCS file: /cvsroot/wikipedia/phase3/languages/Language.php,v retrieving revision 1.323 diff -u -r1.323 Language.php --- languages/Language.php 27 Aug 2004 14:55:41 -0000 1.323 +++ languages/Language.php 28 Aug 2004 14:34:39 -0000 @@ -43,7 +43,9 @@ NS_HELP => 'Help', NS_HELP_TALK => 'Help_talk', NS_CATEGORY => 'Category',
- NS_CATEGORY_TALK => 'Category_talk'
- NS_CATEGORY_TALK => 'Category_talk',
NS_PERSONAL_VIEWS => 'Personal_Views',
NS_PERSONAL_VIEWS_TALK => 'Personal_Views_talk'
);
/* private */ $wgDefaultUserOptionsEn = array( @@ -292,6 +294,11 @@ 'category_header' => 'Articles in category "$1"', 'subcategories' => 'Subcategories',
+'personalviews_header' => 'Personal views on the topic of "$1"', +'personalviews_articleheader' => "$1's personal views on $2", +'personalviews_viewyours' => "What you've had to say on this topic.", +'personalviews_submityours' => "Submit your view on this topic.", +'personalviews_notloggedin' => "If you were logged-in, you could submit your view on this topic.",
'linktrail' => '/^([a-z]+)(.*)$/sD', 'mainpage' => 'Main Page', @@ -360,6 +367,8 @@ 'articlepage' => 'View content page', 'subjectpage' => 'View subject', # For compatibility 'talk' => 'Discussion', +'personal_views' => 'Personal Views', +'personal_views_article' => 'Article page', 'toolbox' => 'Toolbox', 'userpage' => 'View user page', 'wikipediapage' => 'View project page', @@ -1442,6 +1451,8 @@ 'categoryarticlecount' => "There are $1 articles in this category.", 'categoryarticlecount1' => "There is $1 article in this category.", 'usenewcategorypage' => "1\n\nSet first character to "0" to disable the new category page layout.", +'personalviewscount' => "$1 users have submitted personal viewpoints on the topic of this article.", +'personalviewscount1' => "$1 user has submitted a personal viewpoint on the topic of this article.",
# Info page "infosubtitle" => "Information for page",
Wikitech-l mailing list Wikitech-l@wikimedia.org http://mail.wikipedia.org/mailman/listinfo/wikitech-l