4 * Interface for site objects.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * http://www.gnu.org/copyleft/gpl.html
26 * @licence GNU GPL v2+
27 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
31 const TYPE_UNKNOWN
= 'unknown';
32 const TYPE_MEDIAWIKI
= 'mediawiki';
34 const GROUP_NONE
= 'none';
36 const ID_INTERWIKI
= 'interwiki';
37 const ID_EQUIVALENT
= 'equivalent';
39 const SOURCE_LOCAL
= 'local';
42 * Returns the global site identifier (ie enwiktionary).
48 public function getGlobalId();
51 * Sets the global site identifier (ie enwiktionary).
55 * @param string $globalId
57 public function setGlobalId( $globalId );
60 * Returns the type of the site (ie mediawiki).
66 public function getType();
69 * Sets the type of the site (ie mediawiki).
70 * TODO: remove, we cannot change this after instantiation
76 public function setType( $type );
79 * Gets the type of the site (ie wikipedia).
85 public function getGroup();
88 * Sets the type of the site (ie wikipedia).
92 * @param string $group
94 public function setGroup( $group );
97 * Returns the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').
103 public function getSource();
106 * Sets the source of the site data (ie 'local', 'wikidata', 'my-magical-repo').
110 * @param string $source
112 public function setSource( $source );
115 * Returns the protocol of the site, ie 'http://', 'irc://', '//'
116 * Or false if it's not known.
120 * @return string|false
122 public function getProtocol();
125 * Returns the domain of the site, ie en.wikipedia.org
126 * Or false if it's not known.
130 * @return string|false
132 public function getDomain();
135 * Returns the full URL for the given page on the site.
136 * Or false if the needed information is not known.
138 * This generated URL is usually based upon the path returned by getLinkPath(),
139 * but this is not a requirement.
142 * @see Site::getLinkPath()
144 * @param bool|String $page
146 * @return string|false
148 public function getPageUrl( $page = false );
151 * Returns language code of the sites primary language.
152 * Or false if it's not known.
156 * @return string|false
158 public function getLanguageCode();
161 * Sets language code of the sites primary language.
165 * @param string $languageCode
167 public function setLanguageCode( $languageCode );
170 * Returns the normalized, canonical form of the given page name.
171 * How normalization is performed or what the properties of a normalized name are depends on the site.
172 * The general contract of this method is that the normalized form shall refer to the same content
173 * as the original form, and any other page name referring to the same content will have the same normalized form.
175 * Note that this method may call out to the target site to perform the normalization, so it may be slow
176 * and fail due to IO errors.
180 * @param string $pageName
182 * @return string the normalized page name
184 public function normalizePageName( $pageName );
187 * Returns the interwiki link identifiers that can be used for this site.
191 * @return array of string
193 public function getInterwikiIds();
196 * Returns the equivalent link identifiers that can be used to make
197 * the site show up in interfaces such as the "language links" section.
201 * @return array of string
203 public function getNavigationIds();
206 * Adds an local identifier to the site.
210 * @param string $type The type of the identifier, element of the Site::ID_ enum
211 * @param string $identifier
213 public function addLocalId( $type, $identifier );
216 * Adds an interwiki id to the site.
220 * @param string $identifier
222 public function addInterwikiId( $identifier );
225 * Adds a navigation id to the site.
229 * @param string $identifier
231 public function addNavigationId( $identifier );
238 * @param string|null $functionName
240 public function save( $functionName = null );
243 * Returns the internal ID of the site.
249 public function getInternalId();
252 * Sets the provided url as path of the specified type.
256 * @param string $pathType
257 * @param string $fullUrl
259 public function setPath( $pathType, $fullUrl );
262 * Returns the path of the provided type or false if there is no such path.
266 * @param string $pathType
268 * @return string|false
270 public function getPath( $pathType );
273 * Sets the path used to construct links with.
274 * Shall be equivalent to setPath( getLinkPathType(), $fullUrl ).
276 * @param string $fullUrl
280 public function setLinkPath( $fullUrl );
283 * Returns the path used to construct links with or false if there is no such path.
284 * Shall be equivalent to getPath( getLinkPathType() ).
286 * @return string|false
288 public function getLinkPath();
291 * Returns the path type used to construct links with.
293 * @return string|false
295 public function getLinkPathType();
298 * Returns the paths as associative array.
299 * The keys are path types, the values are the path urls.
303 * @return array of string
305 public function getAllPaths();
308 * Removes the path of the provided type if it's set.
312 * @param string $pathType
314 public function removePath( $pathType );