*/
public static function newFromID( $id ) {
$t = Title::newFromID( $id );
- # @todo FIXME: Doesn't inherit right
- return $t == null ? null : new self( $t );
- # return $t == null ? null : new static( $t ); // PHP 5.3
+ return $t == null ? null : new static( $t );
}
/**
return new WikiCategoryPage( $title );
}
- /**
- * Constructor from a page id
- * @param int $id Article ID to load
- * @return CategoryPage|null
- */
- public static function newFromID( $id ) {
- $t = Title::newFromID( $id );
- # @todo FIXME: Doesn't inherit right
- return $t == null ? null : new self( $t );
- # return $t == null ? null : new static( $t ); // PHP 5.3
- }
-
function view() {
$request = $this->getContext()->getRequest();
$diff = $request->getVal( 'diff' );
return new WikiFilePage( $title );
}
- /**
- * Constructor from a page id
- * @param int $id Article ID to load
- * @return ImagePage|null
- */
- public static function newFromID( $id ) {
- $t = Title::newFromID( $id );
- # @todo FIXME: Doesn't inherit right
- return $t == null ? null : new self( $t );
- # return $t == null ? null : new static( $t ); // PHP 5.3
- }
-
/**
* @param File $file
* @return void
* @return bool
*/
public function hasViewableContent() {
- return $this->exists() || $this->mTitle->isAlwaysKnown();
+ return $this->mTitle->isKnown();
}
/**
Hooks::run( 'WikiPageDeletionUpdates', [ $this, $content, &$updates ] );
return $updates;
}
+
+ /**
+ * Whether this content displayed on this page
+ * comes from the local database
+ *
+ * @since 1.28
+ * @return bool
+ */
+ public function isLocal() {
+ return true;
+ }
}
/**
* Get the string representation of the token at a timestamp
- * @param int timestamp
+ * @param int $timestamp
* @return string
*/
protected function toStringAtTimestamp( $timestamp ) {
$content_navigation['namespaces'][$talkId]['context'] = 'talk';
if ( $userCanRead ) {
- $isForeignFile = $title->inNamespace( NS_FILE ) && $this->canUseWikiPage() &&
- $this->getWikiPage() instanceof WikiFilePage && !$this->getWikiPage()->isLocal();
-
- // Adds view view link
- if ( $title->exists() || $isForeignFile ) {
+ // Adds "view" view link
+ if ( $title->isKnown() ) {
$content_navigation['views']['view'] = $this->tabAction(
$isTalk ? $talkPage : $subjectPage,
[ "$skname-view-view", 'view' ],
$content_navigation['views']['view']['redundant'] = true;
}
+ $isForeignFile = $title->inNamespace( NS_FILE ) && $this->canUseWikiPage() &&
+ $this->getWikiPage() instanceof WikiFilePage && !$this->getWikiPage()->isLocal();
+
// If it is a non-local file, show a link to the file in its own repository
+ // @todo abstract this for remote content that isn't a file
if ( $isForeignFile ) {
$file = $this->getWikiPage()->getFile();
$content_navigation['views']['view-foreign'] = [
'href' => $title->getLocalURL( 'action=edit§ion=new' )
];
}
- // Checks if the page has some kind of viewable content
+ // Checks if the page has some kind of viewable source content
} elseif ( $title->hasSourceText() ) {
// Adds view source view link
$content_navigation['views']['viewsource'] = [
const AUDIENCE_PUBLIC = 1;
const AUDIENCE_RAW = 2;
- /** @var CentralIdLookup[][] */
+ /** @var CentralIdLookup[] */
private static $instances = [];
/** @var string */
}
$audience = $this->checkAudience( $audience );
- $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA );
- $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING )
- ? [ 'LOCK IN SHARE MODE' ]
- : [];
+ list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
+ $db = wfGetDB( $index );
$tables = [ 'user' ];
$fields = [ 'user_id', 'user_name' ];
}
$audience = $this->checkAudience( $audience );
- $db = wfGetDB( ( $flags & self::READ_LATEST ) ? DB_MASTER : DB_REPLICA );
- $options = ( ( $flags & self::READ_LOCKING ) == self::READ_LOCKING )
- ? [ 'LOCK IN SHARE MODE' ]
- : [];
+ list( $index, $options ) = DBAccessObjectUtils::getDBOptions( $flags );
+ $db = wfGetDB( $index );
$tables = [ 'user' ];
$fields = [ 'user_id', 'user_name' ];