MediaWiki  1.23.2
TitleValue.php
Go to the documentation of this file.
1 <?php
36 class TitleValue {
37 
41  protected $namespace;
42 
46  protected $dbkey;
47 
51  protected $fragment;
52 
69  public function __construct( $namespace, $dbkey, $fragment = '' ) {
70  if ( !is_int( $namespace ) ) {
71  throw new InvalidArgumentException( '$namespace must be an integer' );
72  }
73 
74  if ( !is_string( $dbkey ) ) {
75  throw new InvalidArgumentException( '$dbkey must be a string' );
76  }
77 
78  // Sanity check, no full validation or normalization applied here!
79  if ( preg_match( '/^_|[ \r\n\t]|_$/', $dbkey ) ) {
80  throw new InvalidArgumentException( '$dbkey must be a valid DB key: ' . $dbkey );
81  }
82 
83  if ( !is_string( $fragment ) ) {
84  throw new InvalidArgumentException( '$fragment must be a string' );
85  }
86 
87  if ( $dbkey === '' ) {
88  throw new InvalidArgumentException( '$dbkey must not be empty' );
89  }
90 
91  $this->namespace = $namespace;
92  $this->dbkey = $dbkey;
93  $this->fragment = $fragment;
94  }
95 
99  public function getNamespace() {
100  return $this->namespace;
101  }
102 
106  public function getFragment() {
107  return $this->fragment;
108  }
109 
116  public function getDBkey() {
117  return $this->dbkey;
118  }
119 
131  public function getText() {
132  return str_replace( '_', ' ', $this->getDBkey() );
133  }
134 
142  public function createFragmentTitle( $fragment ) {
143  return new TitleValue( $this->namespace, $this->dbkey, $fragment );
144  }
145 
153  public function __toString() {
154  $name = $this->namespace . ':' . $this->dbkey;
155 
156  if ( $this->fragment !== '' ) {
157  $name .= '#' . $this->fragment;
158  }
159 
160  return $name;
161  }
162 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
TitleValue\$namespace
int $namespace
Definition: TitleValue.php:40
TitleValue\$fragment
string $fragment
Definition: TitleValue.php:48
TitleValue\getDBkey
getDBkey()
Returns the title's DB key, as supplied to the constructor, without namespace prefix or fragment.
Definition: TitleValue.php:113
TitleValue\__toString
__toString()
Returns a string representation of the title, for logging.
Definition: TitleValue.php:150
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:336
TitleValue\getFragment
getFragment()
Definition: TitleValue.php:103
TitleValue\getText
getText()
Returns the title in text form, without namespace prefix or fragment.
Definition: TitleValue.php:128
TitleValue\__construct
__construct( $namespace, $dbkey, $fragment='')
Constructs a TitleValue.
Definition: TitleValue.php:66
TitleValue\getNamespace
getNamespace()
Definition: TitleValue.php:96
TitleValue\$dbkey
string $dbkey
Definition: TitleValue.php:44
TitleValue\createFragmentTitle
createFragmentTitle( $fragment)
Creates a new TitleValue for a different fragment of the same page.
Definition: TitleValue.php:139
if
if(!function_exists('version_compare')||version_compare(phpversion(), '5.3.2')< 0)
Definition: api.php:37
TitleValue
Represents a page (or page fragment) title within MediaWiki.
Definition: TitleValue.php:36