<?php
-# See title.doc
-
+/**
+ * $Id$
+ * See title.doc
+ *
+ * @package MediaWiki
+ */
+
+/** */
+require_once( 'normal/UtfNormal.php' );
+
+/**
+ *
+ */
$wgTitleInterwikiCache = array();
-
-# Title class
-#
-# * Represents a title, which may contain an interwiki designation or namespace
-# * Can fetch various kinds of data from the database, albeit inefficiently.
-#
-
define ( 'GAID_FOR_UPDATE', 1 );
+/**
+ * Title class
+ * - Represents a title, which may contain an interwiki designation or namespace
+ * - Can fetch various kinds of data from the database, albeit inefficiently.
+ *
+ * @todo migrate comments to phpdoc format
+ * @package MediaWiki
+ */
class Title {
# All member variables should be considered private
# Please use the accessor functions
# from some external search tools.
$s = str_replace( '+', ' ', $url );
- # For links that came from outside, check for alternate/legacy
- # character encoding.
- wfDebug( "Servr: $wgServer\n" );
- if( empty( $_SERVER['HTTP_REFERER'] ) ||
- strncmp($wgServer, $_SERVER['HTTP_REFERER'], strlen( $wgServer ) ) )
- {
- $s = $wgLang->checkTitleEncoding( $s );
- } else {
- wfDebug( "Refer: {$_SERVER['HTTP_REFERER']}\n" );
- }
-
$t->mDbkeyform = str_replace( ' ', '_', $s );
if( $t->secureAndSplit() ) {
# check that length of title is < cur_title size
if ( count( $titles ) == 0 ) {
return;
}
+ $dbw =& wfGetDB( DB_MASTER );
if ( $timestamp == '' ) {
- $timestamp = wfTimestampNow();
+ $timestamp = $dbw->timestamp();
}
- $dbw =& wfGetDB( DB_MASTER );
$cur = $dbw->tableName( 'cur' );
$sql = "UPDATE $cur SET cur_touched='{$timestamp}' WHERE cur_id IN (";
$first = true;
$dbw =& wfGetDB( DB_MASTER );
$success = $dbw->updateArray( 'cur',
array( /* SET */
- 'cur_touched' => wfTimestampNow()
+ 'cur_touched' => $dbw->timestamp()
), array( /* WHERE */
'cur_namespace' => $this->getNamespace() ,
'cur_title' => $this->getDBkey()
wfProfileOut( $fname );
return false;
}
+
+ global $wgUseLatin1;
+ if( !$wgUseLatin1 && false !== strpos( $t, UTF8_REPLACEMENT ) ) {
+ # Contained illegal UTF-8 sequences or forbidden Unicode chars.
+ wfProfileOut( $fname );
+ return false;
+ }
$this->mDbkeyform = $t;
$done = false;
# Change the name of the target page:
$dbw->updateArray( 'cur',
/* SET */ array(
- 'cur_touched' => $now,
+ 'cur_touched' => $dbw->timestamp($now),
'cur_namespace' => $nt->getNamespace(),
'cur_title' => $nt->getDBkey()
),
$redirectText = $wgMwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
$dbw->updateArray( 'cur',
/* SET */ array(
- 'cur_touched' => $now,
- 'cur_timestamp' => $now,
+ 'cur_touched' => $dbw->timestamp($now),
+ 'cur_timestamp' => $dbw->timestamp($now),
'inverse_timestamp' => $won,
'cur_namespace' => $this->getNamespace(),
'cur_title' => $this->getDBkey(),
$fname = 'MovePageForm::moveToNewTitle';
$comment = wfMsg( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
- $now = wfTimestampNow();
- $won = wfInvertTimestamp( $now );
$newid = $nt->getArticleID();
$oldid = $this->getArticleID();
$dbw =& wfGetDB( DB_MASTER );
+ $now = $dbw->timestamp();
+ $won = wfInvertTimestamp( wfTimestamp(TS_MW,$now) );
# Rename cur entry
$dbw->updateArray( 'cur',
$wgLinkCache->clearLink( $nt->getPrefixedDBkey() );
- # Insert redirct
+ # Insert redirect
$dbw->insertArray( 'cur', array(
+ 'cur_id' => $dbw->nextSequenceValue('cur_cur_id_seq'),
'cur_namespace' => $this->getNamespace(),
'cur_title' => $this->getDBkey(),
'cur_comment' => $comment,
# Get categories to wich belong this title and return an array of
# categories names.
- function getParentCategories( ) {
+ # Return an array of parents in the form:
+ # $parent => $currentarticle
+ function getParentCategories() {
global $wgLang,$wgUser;
$titlekey = $this->getArticleId();
- $cns = Namespace::getCategory();
$sk =& $wgUser->getSkin();
$parents = array();
$dbr =& wfGetDB( DB_SLAVE );
$cur = $dbr->tableName( 'cur' );
$categorylinks = $dbr->tableName( 'categorylinks' );
- # get the parents categories of this title from the database
- $sql = "SELECT DISTINCT cur_id FROM $cur,$categorylinks
- WHERE cl_from='$titlekey' AND cl_to=cur_title AND cur_namespace='$cns'
- ORDER BY cl_sortkey" ;
+ # NEW SQL
+ $sql = "SELECT * FROM categorylinks"
+ ." WHERE cl_from='$titlekey'"
+ ." AND cl_from <> '0'"
+ ." ORDER BY cl_sortkey";
+
$res = $dbr->query ( $sql ) ;
if($dbr->numRows($res) > 0) {
- while ( $x = $dbr->fetchObject ( $res ) ) $data[] = $x ;
+ while ( $x = $dbr->fetchObject ( $res ) )
+ //$data[] = Title::newFromText($wgLang->getNSText ( NS_CATEGORY ).':'.$x->cl_to);
+ $data[$wgLang->getNSText ( NS_CATEGORY ).':'.$x->cl_to] = $this->getFullText();
$dbr->freeResult ( $res ) ;
} else {
$data = '';
}
return $data;
}
-
- # will get the parents and grand-parents
- # TODO : not sure what's happening when a loop happen like:
- # Encyclopedia > Astronomy > Encyclopedia
- function getAllParentCategories(&$stack) {
- global $wgUser,$wgLang;
- $result = '';
-
- # getting parents
- $parents = $this->getParentCategories( );
- if($parents == '')
- {
- # The current element has no more parent so we dump the stack
- # and make a clean line of categories
- $sk =& $wgUser->getSkin() ;
-
- foreach ( array_reverse($stack) as $child => $parent )
+ # Go through all parents
+ function getCategorieBrowser() {
+ $parents = $this->getParentCategories();
+
+ if($parents != '') {
+ foreach($parents as $parent => $current)
{
- # make a link of that parent
- $result .= $sk->makeLink($wgLang->getNSText ( Namespace::getCategory() ).':'.$parent,$parent);
- $result .= ' > ';
- $lastchild = $child;
+ $nt = Title::newFromText($parent);
+ $stack[$parent] = $nt->getCategorieBrowser();
}
- # append the last child.
- # TODO : We should have a last child unless there is an error in the
- # "categorylinks" table.
- if(isset($lastchild)) { $result .= $lastchild; }
-
- $result .= "<br/>\n";
-
- # now we can empty the stack
- $stack = array();
-
+ return $stack;
} else {
- # look at parents of current category
- foreach($parents as $parent)
- {
- # create a title object for the parent
- $tpar = Title::newFromID($parent->cur_id);
- # add it to the stack
- $stack[$this->getText()] = $tpar->getText();
- # grab its parents
- $result .= $tpar->getAllParentCategories($stack);
- }
+ return array();
}
-
- if(isset($result)) { return $result; }
- else { return ''; };
}
+
# Returns an associative array for selecting this title from cur
function curCond() {
return array( 'cur_namespace' => $this->mNamespace, 'cur_title' => $this->mDbkeyform );