4 * Represents the sites database table.
5 * All access to this table should be done through this class.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
27 * @licence GNU GPL v2+
28 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
30 class SitesTable
extends ORMTable
{
33 * @see IORMTable::getName()
37 public function getName() {
42 * @see IORMTable::getFieldPrefix()
46 public function getFieldPrefix() {
51 * @see IORMTable::getRowClass()
55 public function getRowClass() {
60 * @see IORMTable::getFields()
64 public function getFields() {
69 'global_key' => 'str',
85 * @see IORMTable::getDefaults()
89 public function getDefaults() {
91 'type' => Site
::TYPE_UNKNOWN
,
92 'group' => Site
::GROUP_NONE
,
93 'source' => Site
::SOURCE_LOCAL
,
102 * Returns the class name for the provided site type.
106 * @param integer $siteType
110 protected static function getClassForType( $siteType ) {
112 return array_key_exists( $siteType, $wgSiteTypes ) ?
$wgSiteTypes[$siteType] : 'SiteObject';
116 * Factory method to construct a new Site instance.
121 * @param boolean $loadDefaults
125 public function newRow( array $data, $loadDefaults = false ) {
126 if ( !array_key_exists( 'type', $data ) ) {
127 $data['type'] = Site
::TYPE_UNKNOWN
;
130 $class = static::getClassForType( $data['type'] );
132 return new $class( $this, $data, $loadDefaults );