$this->mOldComment = $sk->formatComment($this->mOldComment);
$this->mNewComment = $sk->formatComment($this->mNewComment);
- $oldUserLink = $sk->makeLinkObj( Title::makeTitle( NS_USER, $this->mOldUser ), $this->mOldUser );
- $newUserLink = $sk->makeLinkObj( Title::makeTitle( NS_USER, $this->mNewUser ), $this->mNewUser );
- $oldUTLink = $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $this->mOldUser ), $talk );
- $newUTLink = $sk->makeLinkObj( Title::makeTitle( NS_USER_TALK, $this->mNewUser ), $talk );
+ $oldUserLink = $sk->makeLinkObj( Title::makeTitleSafe( NS_USER, $this->mOldUser ), $this->mOldUser );
+ $newUserLink = $sk->makeLinkObj( Title::makeTitleSafe( NS_USER, $this->mNewUser ), $this->mNewUser );
+ $oldUTLink = $sk->makeLinkObj( Title::makeTitleSafe( NS_USER_TALK, $this->mOldUser ), $talk );
+ $newUTLink = $sk->makeLinkObj( Title::makeTitleSafe( NS_USER_TALK, $this->mNewUser ), $talk );
$oldContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Contributions' ), $contribs,
'target=' . urlencode($this->mOldUser) );
$newContribs = $sk->makeKnownLinkObj( Title::makeTitle( NS_SPECIAL, 'Contributions' ), $contribs,
global $wgUploadDirectory;
$this->name = $name;
- $this->title = Title::makeTitle( Namespace::getImage(), $this->name );
+ $this->title = Title::makeTitleSafe( NS_IMAGE, $this->name );
//$this->imagePath = wfImagePath( $name );
$hash = md5( $this->title->getDBkey() );
$this->imagePath = $wgUploadDirectory . '/' . $hash{0} . '/' .substr( $hash, 0, 2 ) . "/{$name}";
'img_user_text' => $wgUser->getName(),
), $fname, 'IGNORE'
);
- $descTitle = Title::makeTitle( NS_IMAGE, $name );
+ $descTitle = Title::makeTitleSafe( NS_IMAGE, $name );
if ( $dbw->affectedRows() ) {
# Successfully inserted, this is a new image
foreach ( $namespaces as $key => $val ) {
# Make title object
$dbk = $dbkeys[$key];
- $title = $titles[$key] = Title::makeTitle( $val, $dbk );
+ $title = $titles[$key] = Title::makeTitleSafe( $val, $dbk );
# Skip invalid entries.
# Result will be ugly, but prevents crash.
}
# this can be passed the NS number as defined in Language.php
/*static*/ function makeNSUrl( $name, $urlaction='', $namespace=0 ) {
- $title = Title::makeTitle( $namespace, $name );
+ $title = Title::makeTitleSafe( $namespace, $name );
$this->checkTitle($title, $name);
return $title->getLocalURL( $urlaction );
}
}
function makeImageLink( $name, $url, $alt = '' ) {
- $nt = Title::makeTitle( Namespace::getImage(), $name );
+ $nt = Title::makeTitleSafe( NS_IMAGE, $name );
return $this->makeImageLinkObj( $nt, $alt );
}
# $img is an Image object
function makeThumbLinkObj( $img, $label = '', $align = 'right', $boxwidth = 180, $boxheight=false, $framed=false , $manual_thumb = "" ) {
global $wgStylePath, $wgLang;
- # $image = Title::makeTitle( Namespace::getImage(), $name );
+ # $image = Title::makeTitleSafe( NS_IMAGE, $name );
$url = $img->getURL();
#$label = htmlspecialchars( $label );
if ( $manual_thumb != '' ) # Use manually specified thumbnail
{
- $manual_title = Title::makeTitle( Namespace::getImage(), $manual_thumb ); #new Title ( $manual_thumb ) ;
+ $manual_title = Title::makeTitleSafe( NS_IMAGE, $manual_thumb ); #new Title ( $manual_thumb ) ;
$manual_img = Image::newFromTitle( $manual_title );
$thumbUrl = $manual_img->getURL();
if ( $manual_img->exists() )
}
function makeMediaLink( $name, $url, $alt = "" ) {
- $nt = Title::makeTitle( Namespace::getMedia(), $name );
+ $nt = Title::makeTitleSafe( Namespace::getMedia(), $name );
return $this->makeMediaLinkObj( $nt, $alt );
}
# First, see if we have a custom list setup in
# [[Wikipedia:Book sources]] or equivalent.
- $bstitle = Title::makeTitle( NS_WIKIPEDIA, wfMsg( "booksources" ) );
+ $bstitle = Title::makeTitleSafe( NS_WIKIPEDIA, wfMsg( "booksources" ) );
$dbr =& wfGetDB( DB_SLAVE );
$bstext = $dbr->selectField( 'cur', 'cur_text', $bstitle->curCond(), $fname );
if( $bstext ) {
}
# From a namespace index and a DB key.
- # It's assumed that $ns and $title are *valid*, for instance
- # when they came directly from the database.
+ # It's assumed that $ns and $title are *valid*, for instance when
+ # they came directly from the database or a special page name.
/* static */ function &makeTitle( $ns, $title ) {
$t =& new Title();
$t->mInterwiki = '';
$t->mTextform = str_replace( '_', ' ', $title );
return $t;
}
+
+ # From a namespace index and a DB key.
+ # These will be checked for validity, which is a bit slower
+ # than makeTitle() but safer for user-provided data.
+ /* static */ function makeTitleSafe( $ns, $title ) {
+ $t = new Title();
+ $t->mDbkeyform = Title::makeName( $ns, $title );
+ if( $t->secureAndSplit() ) {
+ return $t;
+ } else {
+ return NULL;
+ }
+ }
/* static */ function newMainPage() {
return Title::newFromText( wfMsg( 'mainpage' ) );
SpecialPage::executePath( $wgTitle );
} else {
if ( Namespace::getMedia() == $wgTitle->getNamespace() ) {
- $wgTitle = Title::makeTitle( Namespace::getImage(), $wgTitle->getDBkey() );
+ $wgTitle = Title::makeTitle( NS_IMAGE, $wgTitle->getDBkey() );
}
switch( $wgTitle->getNamespace() ) {