27use InvalidArgumentException;
34use Wikimedia\Assert\Assert;
100 Assert::parameterType(
'string|boolean', $wikiId,
'$wikiId' );
103 $this->mSlots = $slots;
104 $this->mWiki = $wikiId;
107 $this->mPageId = $title->getArticleID();
116 throw new LogicException( __CLASS__ .
' is not serializable.' );
126 if ( $rec === $this ) {
165 public function getContent( $role, $audience = self::FOR_PUBLIC,
User $user =
null ) {
169 if ( !$this->
audienceCan( self::DELETED_TEXT, $audience, $user ) ) {
173 $content = $this->
getSlot( $role, $audience, $user )->getContent();
174 return $content->copy();
189 public function getSlot( $role, $audience = self::FOR_PUBLIC,
User $user =
null ) {
190 $slot = $this->mSlots->getSlot( $role );
192 if ( !$this->
audienceCan( self::DELETED_TEXT, $audience, $user ) ) {
207 return $this->mSlots->hasSlot( $role );
217 return $this->mSlots->getSlotRoles();
321 public function getUser( $audience = self::FOR_PUBLIC,
User $user =
null ) {
322 if ( !$this->
audienceCan( self::DELETED_USER, $audience, $user ) ) {
347 if ( !$this->
audienceCan( self::DELETED_COMMENT, $audience, $user ) ) {
414 if ( $audience == self::FOR_PUBLIC && $this->
isDeleted( $field ) ) {
416 } elseif ( $audience == self::FOR_THIS_USER ) {
418 throw new InvalidArgumentException(
419 'A User object must be given when checking FOR_THIS_USER audience.'
423 if ( !$this->
userCan( $field, $user ) ) {
465 if ( $bitfield & $field ) {
466 if ( $bitfield & self::DELETED_RESTRICTED ) {
467 $permissions = [
'suppressrevision',
'viewsuppressed' ];
468 } elseif ( $field & self::DELETED_TEXT ) {
469 $permissions = [
'deletedtext' ];
471 $permissions = [
'deletedhistory' ];
473 $permissionlist = implode(
', ', $permissions );
474 if ( $title ===
null ) {
475 wfDebug(
"Checking for $permissionlist due to $field match on $bitfield\n" );
476 return call_user_func_array( [ $user,
'isAllowedAny' ], $permissions );
478 $text = $title->getPrefixedText();
479 wfDebug(
"Checking for $permissionlist on $text due to $field match on $bitfield\n" );
480 foreach ( $permissions as $perm ) {
481 if ( $title->userCan( $perm, $user ) ) {
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Represents a title within MediaWiki.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
namespace and then decline to actually register it file or subcat img or subcat $title
Base interface for content objects.