File size: 3,383 Bytes
82413ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
-- Minimal mw.wikibase compatibility shim.
-- This intentionally returns nil/empty results because the container does not
-- include a local Wikidata repository. The goal is to keep zhwiki modules from
-- crashing when they probe mw.wikibase.

local wikibase = {}

local function emptyTable()
    return {}
end

local dummyEntity = {
    id = nil,
    type = 'item',
    schemaVersion = 2,
    labels = {},
    descriptions = {},
    aliases = {},
    claims = {},
    statements = {},
    sitelinks = {}
}

function dummyEntity:getLabel()
    return nil
end

function dummyEntity:getLabelWithLang()
    return nil, nil
end

function dummyEntity:getDescription()
    return nil
end

function dummyEntity:getAliases()
    return {}
end

function dummyEntity:getSitelink()
    return nil
end

function dummyEntity:getBestStatements()
    return {}
end

function dummyEntity:getAllStatements()
    return {}
end

function dummyEntity:formatPropertyValues()
    return {}
end

function dummyEntity:formatStatements()
    return {}
end

function dummyEntity:getProperties()
    return {}
end

local function newDummyEntity( id )
    local entity = {}
    for k, v in pairs( dummyEntity ) do
        entity[k] = v
    end
    entity.id = id
    return entity
end

function wikibase.getEntity( id )
    if id == nil or id == '' then
        return nil
    end
    return newDummyEntity( id )
end

function wikibase.getEntityObject( id )
    return wikibase.getEntity( id )
end

function wikibase.getEntityIdForCurrentPage()
    return nil
end

function wikibase.getEntityIdForTitle()
    return nil
end

function wikibase.getEntityUrl( id )
    if type( id ) == 'string' and id ~= '' then
        return 'https://www.wikidata.org/wiki/' .. id
    end
    return nil
end

function wikibase.getLabel()
    return nil
end

function wikibase.getLabelWithLang()
    return nil, nil
end

function wikibase.getLabelByLang()
    return nil
end

function wikibase.getDescription()
    return nil
end

function wikibase.getDescriptionWithLang()
    return nil, nil
end

function wikibase.getDescriptionByLang()
    return nil
end

function wikibase.getAliases()
    return {}
end

function wikibase.getSitelink()
    return nil
end

function wikibase.getBadges()
    return {}
end

function wikibase.getBestStatements()
    return {}
end

function wikibase.getAllStatements()
    return {}
end

function wikibase.getStatement()
    return nil
end

function wikibase.formatValue()
    return nil
end

function wikibase.renderSnak()
    return nil
end

function wikibase.renderSnaks()
    return nil
end

function wikibase.formatStatement()
    return nil
end

function wikibase.formatStatements()
    return {}
end

function wikibase.getReferencedEntityId()
    return nil
end

function wikibase.resolvePropertyId( id )
    if type( id ) == 'string' and id:match( '^P%d+$' ) then
        return id
    end
    return nil
end

function wikibase.getPropertyId( id )
    return wikibase.resolvePropertyId( id )
end

function wikibase.getLanguageFallbacksFor( lang )
    if type( lang ) == 'string' and lang ~= '' then
        return { lang }
    end
    return {}
end

function wikibase.setupInterface()
    wikibase.setupInterface = nil
    mw = mw or {}
    mw.wikibase = wikibase
    package.loaded['mw.wikibase'] = wikibase
    package.loaded['mw.wikibase.entity'] = dummyEntity
end

return wikibase