Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
PageConfig | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getContentModel | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getSuppressTOC | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getLinkTarget | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getNs | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPageId | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getPageLanguageBcp47 | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getPageLanguageDir | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getRevisionId | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getParentRevisionId | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getRevisionTimestamp | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getRevisionUser | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getRevisionUserId | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getRevisionSha1 | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getRevisionSize | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getRevisionContent | n/a |
0 / 0 |
n/a |
0 / 0 |
0 | |||||
getVariantBcp47 | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
setVariantBcp47 | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getPageMainContent | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace Wikimedia\Parsoid\Config; |
5 | |
6 | use Wikimedia\Bcp47Code\Bcp47Code; |
7 | use Wikimedia\Parsoid\Core\LinkTarget; |
8 | |
9 | /** |
10 | * Page-level configuration interface for Parsoid |
11 | */ |
12 | abstract class PageConfig { |
13 | |
14 | /** |
15 | * Non-null to record the fact that conversion has been done on |
16 | * this page (to the specified variant). |
17 | * @var ?Bcp47Code |
18 | */ |
19 | private $htmlVariant = null; |
20 | |
21 | /** |
22 | * Base constructor. |
23 | * |
24 | * This constructor is public because it is used to create mock objects |
25 | * in our test suite. |
26 | */ |
27 | public function __construct() { |
28 | } |
29 | |
30 | /** |
31 | * Get content model |
32 | * @return string |
33 | */ |
34 | abstract public function getContentModel(): string; |
35 | |
36 | /** |
37 | * Whether to suppress the Table of Contents for this page |
38 | * (a function of content model). |
39 | * @return bool |
40 | */ |
41 | public function getSuppressTOC(): bool { |
42 | // This will eventually be abstract; for now default to 'false' |
43 | return false; |
44 | } |
45 | |
46 | /** |
47 | * The page's title, as a LinkTarget. |
48 | * @return LinkTarget |
49 | */ |
50 | abstract public function getLinkTarget(): LinkTarget; |
51 | |
52 | /** |
53 | * The page's namespace ID |
54 | * @return int |
55 | * @deprecated Use ::getLinkTarget()->getNamespace() instead |
56 | */ |
57 | public function getNs(): int { |
58 | return $this->getLinkTarget()->getNamespace(); |
59 | } |
60 | |
61 | /** |
62 | * The page's ID, if any |
63 | * @return int 0 if the page doesn't (yet?) exist |
64 | */ |
65 | abstract public function getPageId(): int; |
66 | |
67 | /** |
68 | * The page's language code. |
69 | * |
70 | * @return Bcp47Code a BCP-47 language code |
71 | */ |
72 | abstract public function getPageLanguageBcp47(): Bcp47Code; |
73 | |
74 | /** |
75 | * The page's language direction |
76 | * @return string 'ltr' or 'rtl' |
77 | */ |
78 | abstract public function getPageLanguageDir(): string; |
79 | |
80 | /** |
81 | * The revision's ID, if any |
82 | * @return int|null |
83 | */ |
84 | abstract public function getRevisionId(): ?int; |
85 | |
86 | /** |
87 | * The revision's parent ID, if any |
88 | * @return int|null |
89 | */ |
90 | abstract public function getParentRevisionId(): ?int; |
91 | |
92 | /** |
93 | * The revision's timestamp, if any |
94 | * @return string|null "YYYYMMDDHHIISS" format |
95 | */ |
96 | abstract public function getRevisionTimestamp(): ?string; |
97 | |
98 | /** |
99 | * The revision's author's user name, if any |
100 | * @return string|null |
101 | */ |
102 | abstract public function getRevisionUser(): ?string; |
103 | |
104 | /** |
105 | * The revision's author's user ID, if any |
106 | * @return int|null 0 if the user is not registered |
107 | */ |
108 | abstract public function getRevisionUserId(): ?int; |
109 | |
110 | /** |
111 | * The revision's SHA1 checksum, if any |
112 | * @return string|null Hex encoded |
113 | */ |
114 | abstract public function getRevisionSha1(): ?string; |
115 | |
116 | /** |
117 | * The revision's length, if known |
118 | * @return int|null Bytes |
119 | */ |
120 | abstract public function getRevisionSize(): ?int; |
121 | |
122 | /** |
123 | * The revision's content |
124 | * @return PageContent|null |
125 | */ |
126 | abstract public function getRevisionContent(): ?PageContent; |
127 | |
128 | /** |
129 | * Get the page's language variant |
130 | * @return ?Bcp47Code a BCP-47 language code |
131 | */ |
132 | public function getVariantBcp47(): ?Bcp47Code { |
133 | return $this->htmlVariant; # stored as BCP-47 |
134 | } |
135 | |
136 | /** |
137 | * Set the page's language variant. (Records the fact that |
138 | * conversion has been done in the parser pipeline.) |
139 | * @param Bcp47Code $htmlVariant a BCP-47 language code |
140 | */ |
141 | public function setVariantBcp47( Bcp47Code $htmlVariant ): void { |
142 | $this->htmlVariant = $htmlVariant; # stored as BCP-47 |
143 | } |
144 | |
145 | /** |
146 | * FIXME: Once we remove the hardcoded slot name here, |
147 | * the name of this method could be updated, if necessary. |
148 | * |
149 | * Shortcut method to get page source |
150 | * @deprecated Use $this->topFrame->getSrcText() |
151 | * @return string |
152 | */ |
153 | public function getPageMainContent(): string { |
154 | return $this->getRevisionContent()->getContent( 'main' ); |
155 | } |
156 | |
157 | } |